ScummVM API documentation
text_view.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 MM1_VIEWS_ENH_TEXT_VIEW_H
23 #define MM1_VIEWS_ENH_TEXT_VIEW_H
24 
25 #include "graphics/font.h"
26 #include "mm/mm1/events.h"
27 #include "mm/shared/utils/xeen_font.h"
28 
29 namespace MM {
30 namespace MM1 {
31 namespace ViewsEnh {
32 
33 class TextView : public UIElement {
34 private:
35  XeenFont *getFont() const;
36 
40  void rawWriteString(const Common::String &str);
41 
42 protected:
43  Common::Point _textPos;
44  int _colorsNum = 0;
45  bool _fontReduced = false;
46 
50  byte setTextColor(byte col);
51 
55  void writeChar(unsigned char c);
56  void writeChar(int x, int y, unsigned char c);
57 
61  void writeString(const Common::String &str,
62  TextAlign align = ALIGN_LEFT);
63  void writeString(int x, int y, const Common::String &str,
64  TextAlign align = ALIGN_LEFT);
65 
69  void writeNumber(int val);
70  void writeNumber(int x, int y, int val);
71 
75  void writeLine(int lineNum, const Common::String &str,
76  TextAlign align = ALIGN_LEFT, int xp = 0);
77 
81  size_t getStringWidth(const Common::String &str);
82 
86  void newLine();
87 
92  int firstLineWidth = -1);
93 
97  void clearSurface() override;
98 
99  void drawGraphic(int gfxNum);
100 
101 public:
102  TextView(const Common::String &name);
103  TextView(const Common::String &name, UIElement *owner);
104  virtual ~TextView() {}
105 
109  void setReduced(bool flag) {
110  _fontReduced = flag;
111  }
112 };
113 
114 } // namespace ViewsEnh
115 } // namespace MM1
116 } // namespace MM
117 
118 #endif
Definition: str.h:59
void clearSurface() override
Common::StringArray splitLines(const Common::String &str, int firstLineWidth=-1)
void setReduced(bool flag)
Definition: text_view.h:109
void writeChar(unsigned char c)
void writeLine(int lineNum, const Common::String &str, TextAlign align=ALIGN_LEFT, int xp=0)
Definition: detection.h:27
Definition: rect.h:45
Definition: text_view.h:33
Definition: events.h:68
Definition: xeen_font.h:35
size_t getStringWidth(const Common::String &str)
void writeString(const Common::String &str, TextAlign align=ALIGN_LEFT)