ScummVM API documentation
textview.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 ULTIMA4_VIEWS_TEXTVIEW_H
23 #define ULTIMA4_VIEWS_TEXTVIEW_H
24 
25 #include "ultima/ultima4/views/view.h"
26 #include "ultima/ultima4/gfx/image.h"
27 #include "common/array.h"
28 #include "common/rect.h"
29 
30 namespace Ultima {
31 namespace Ultima4 {
32 
33 #define PRINTF_LIKE(x,y)
34 
35 #define CHAR_WIDTH 8
36 #define CHAR_HEIGHT 8
37 
41 class TextView : public View {
42  struct Option : public Common::Rect {
43  char _key;
44  Option() : Common::Rect(), _key('\0') {}
45  Option(const Common::Rect &r, char key) : Common::Rect(r), _key(key) {}
46  };
47 protected:
48  int _columns, _rows;
51  int _cursorX, _cursorY;
53  static Image *_charset;
54  Common::Array<Option> _options;
55 public:
56  TextView(int x, int y, int columns, int rows);
57  virtual ~TextView();
58 
59  void reinit();
60 
61  int getCursorX() const {
62  return _cursorX;
63  }
64  int getCursorY() const {
65  return _cursorY;
66  }
67  bool getCursorEnabled() const {
68  return _cursorEnabled;
69  }
70  int getWidth() const {
71  return _columns;
72  }
73 
77  void drawChar(int chr, int x, int y);
78 
85  void drawCharMasked(int chr, int x, int y, byte mask);
86 
90  void textAt(int x, int y, const char *fmt, ...);
91 
95  void optionAt(int x, int y, char key, const char *fmt, ...);
96 
97  void scroll();
98 
99  void setCursorFollowsText(bool follows) {
100  _cursorFollowsText = follows;
101  }
102  void setCursorPos(int x, int y, bool clearOld = true);
103  void enableCursor();
104  void disableCursor();
105  void drawCursor();
106  static void cursorTimer(void *data);
107 
108  // functions to modify the charset font palette
109  void setFontColor(ColorFG fg, ColorBG bg);
110  void setFontColorFG(ColorFG fg);
111  void setFontColorBG(ColorBG bg);
112 
113  // functions to add color to strings
117  void textSelectedAt(int x, int y, const char *text);
118 
122  Common::String colorizeStatus(char statustype);
123 
127  Common::String colorizeString(Common::String input, ColorFG color, uint colorstart, uint colorlength = 0);
128 
132  char getOptionAt(const Common::Point &mousePos);
133 
137  void clearOptions();
138 
143  Common::Rect getTextBounds(int x, int y, int textWidth) const;
144 };
145 
146 } // End of namespace Ultima4
147 } // End of namespace Ultima
148 
149 #endif
Definition: str.h:59
int _cursorY
Definition: textview.h:51
char getOptionAt(const Common::Point &mousePos)
void textSelectedAt(int x, int y, const char *text)
int _cursorPhase
Definition: textview.h:52
void drawChar(int chr, int x, int y)
Definition: rect.h:144
Definition: textview.h:41
void optionAt(int x, int y, char key, const char *fmt,...)
static Image * _charset
Definition: textview.h:53
Common::String colorizeString(Common::String input, ColorFG color, uint colorstart, uint colorlength=0)
Definition: detection.h:27
Definition: rect.h:45
Common::String colorizeStatus(char statustype)
bool _cursorEnabled
Definition: textview.h:49
Common::Rect getTextBounds(int x, int y, int textWidth) const
Definition: view.h:36
bool _cursorFollowsText
Definition: textview.h:50
Definition: movie_decoder.h:32
void textAt(int x, int y, const char *fmt,...)
void drawCharMasked(int chr, int x, int y, byte mask)
int _rows
Definition: textview.h:48