ScummVM API documentation
text_control.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 TITANIC_TEXT_CONTROL_H
23 #define TITANIC_TEXT_CONTROL_H
24 
25 #include "common/keyboard.h"
26 #include "titanic/support/screen_manager.h"
27 #include "titanic/support/strings.h"
28 
29 namespace Titanic {
30 
31 class CScreenManager;
32 class CTextCursor;
33 class SimpleFile;
34 
35 class CTextControl {
36  struct ArrayEntry {
37  CString _line;
38  CString _rgb;
39  CString _string3;
40  };
41 
42 private:
44  CString _lines;
45  bool _stringsMerged;
46  Rect _bounds;
47  int _maxCharsPerLine;
48  int _lineCount;
49  int _displayEndCharIndex;
50  int _unused1;
51  int _unused2;
52  int _unused3;
53  int _backR;
54  int _backG;
55  int _backB;
56  int _textR;
57  int _textG;
58  int _textB;
59  int _fontNumber;
60  int _npcFlag;
61  int _npcId;
62  bool _hasBorder;
63  int _scrollTop;
64  CTextCursor *_textCursor;
65 private:
66  void setupArrays(int count);
67 
68  void freeArrays();
69 
73  void mergeStrings();
74 
78  void appendText(const CString &str);
79 
80  void updateStr3(int lineNum);
81 
85  void constrainScrollUp(CScreenManager *screenManager);
86 
90  void constrainScrollDown(CScreenManager *screenManager);
91 
95  int getPageHeight(CScreenManager *screenManager);
96 public:
97  CTextControl(uint count = 10);
98 
102  void setup();
103 
107  void load(SimpleFile *file, int param);
108 
112  void save(SimpleFile *file, int indent);
113 
117  void setBounds(const Rect &bounds) { _bounds = bounds; }
118 
122  void setHasBorder(bool val) { _hasBorder = val; }
123 
127  void draw(CScreenManager *screenManager);
128 
129  void resize(uint count);
130 
134  CString getText() const;
135 
139  void setText(const CString &str);
140 
144  void setText(StringId stringId);
145 
149  void setColor(uint col);
150 
154  void setColor(byte r, byte g, byte b);
155 
159  void setLineColor(uint lineNum, byte r, byte g, byte b);
160 
164  static CString getColorText(byte r, byte g, byte b);
165 
169  void setLineColor(uint lineNum, uint col);
170 
174  void setMaxCharsPerLine(int maxChars);
175 
179  void deleteLastChar();
180 
184  void setNPC(int npcFlag, int npcId);
185 
190  int displayEndIndex() const { return _displayEndCharIndex; }
191 
195  void scrollUp(CScreenManager *screenManager);
196 
200  void scrollDown(CScreenManager *screenManager);
201 
205  void scrollUpPage(CScreenManager *screenManager);
206 
210  void scrollDownPage(CScreenManager *screenManager);
211 
215  void scrollToTop(CScreenManager *screenManager);
216 
220  void scrollToBottom(CScreenManager *screenManager);
221 
225  void addLine(const CString &str);
226 
230  void addLine(const CString &str, uint color);
231 
235  void addLine(const CString &str, byte r, byte g, byte b);
236 
242  bool handleKey(char c);
243 
248  void showCursor(int mode);
249 
253  void hideCursor();
254 
262  int getNPCNum(uint ident, uint startIndex);
263 
268  void remapColors(uint count, uint *srcColors, uint *destColors);
269 
273  void setFontNumber(int fontNumber);
274 
278  int getTextWidth(CScreenManager *screenManager);
279 
283  int getTextHeight(CScreenManager *screenManager);
284 };
285 
286 } // End of namespace Titanic
287 
288 #endif /* TITANIC_TEXT_CONTROL_H */
void scrollUpPage(CScreenManager *screenManager)
void setFontNumber(int fontNumber)
Definition: text_control.h:35
void save(SimpleFile *file, int indent)
void showCursor(int mode)
void remapColors(uint count, uint *srcColors, uint *destColors)
void scrollDown(CScreenManager *screenManager)
int getTextWidth(CScreenManager *screenManager)
void draw(CScreenManager *screenManager)
Definition: simple_file.h:49
void scrollToBottom(CScreenManager *screenManager)
void scrollDownPage(CScreenManager *screenManager)
CString getText() const
void setText(const CString &str)
Definition: screen_manager.h:49
int getTextHeight(CScreenManager *screenManager)
Definition: rect.h:35
static CString getColorText(byte r, byte g, byte b)
int displayEndIndex() const
Definition: text_control.h:190
Definition: arm.h:30
Definition: string.h:40
void load(SimpleFile *file, int param)
Definition: text_cursor.h:33
void setMaxCharsPerLine(int maxChars)
void setNPC(int npcFlag, int npcId)
bool handleKey(char c)
int getNPCNum(uint ident, uint startIndex)
void setLineColor(uint lineNum, byte r, byte g, byte b)
void scrollToTop(CScreenManager *screenManager)
void setBounds(const Rect &bounds)
Definition: text_control.h:117
void addLine(const CString &str)
void scrollUp(CScreenManager *screenManager)
void setHasBorder(bool val)
Definition: text_control.h:122
void setColor(uint col)