ScummVM API documentation
text.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef PETKA_TEXT_H
23 #define PETKA_TEXT_H
24 
25 #include "common/rect.h"
26 #include "common/ustr.h"
27 #include "common/str-array.h"
28 
29 #include "graphics/font.h"
30 
31 #include "petka/objects/object.h"
32 
33 namespace Petka {
34 
35 class QText : public QVisibleObject {
36 public:
37  QText(const Common::U32String &text, uint16 textColor, uint16 outlineColor);
38 
39  void draw();
40  void update(int time);
41  const Common::Rect &getRect();
42 
43 protected:
44  QText();
45 
46  static void drawOutline(Graphics::Surface *surface, uint16 color);
47  static Common::Rect calculateBoundingBoxForText(const Common::U32String &text, Graphics::Font &font);
48  static void drawText(Graphics::Surface &s, int y, int maxWidth, const Common::U32String &text, uint color, Graphics::Font &font, Graphics::TextAlign alignment);
49 
50 protected:
51  Common::Rect _rect;
52 };
53 
54 class QTextPhrase : public QText {
55 public:
56  QTextPhrase(const Common::U32String &phrase, uint16 textColor, uint16 outlineColor);
57 
58  void draw() override;
59  void update(int time) override;
60  void onClick(Common::Point p) override;
61  bool isInPoint(Common::Point p) override { return true; }
62 
63 private:
64  Common::U32String _phrase;
65  uint _time;
66 };
67 
68 class QTextDescription : public QText {
69 public:
70  QTextDescription(const Common::U32String &desc, uint32 frame);
71 
72  void draw() override;
73  void onClick(Common::Point p) override;
74  bool isInPoint(Common::Point p) override { return true; }
75  void update(int t) override {}
76 };
77 
78 class QTextChoice : public QText {
79 public:
80  QTextChoice(const Common::Array<Common::U32String> &choices, uint16 color, uint16 outlineColor, uint16 selectedColor);
81 
82  void onMouseMove(Common::Point p) override;
83  void onClick(Common::Point p) override;
84  bool isInPoint(Common::Point p) override { return true; }
85 
86 private:
89  uint _activeChoice;
90  uint16 _outlineColor;
91  uint16 _choiceColor;
92  uint16 _selectedColor;
93 };
94 
95 } // End of namespace Petka
96 
97 #endif
Definition: font.h:83
TextAlign
Definition: font.h:48
Definition: surface.h:67
Definition: text.h:68
Definition: rect.h:144
Definition: ustr.h:57
Definition: object.h:37
Definition: rect.h:45
Definition: text.h:78
Definition: text.h:54
Definition: base.h:27
Definition: text.h:35