ScummVM API documentation
controls32.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 SCI_GRAPHICS_CONTROLS32_H
23 #define SCI_GRAPHICS_CONTROLS32_H
24 
25 #include "sci/graphics/text32.h"
26 
27 namespace Sci {
28 
29 class GfxCache;
30 class GfxScreen;
31 class GfxText32;
32 
33 enum MessageBoxStyle {
34  kMessageBoxOK = 0x0,
35  kMessageBoxYesNo = 0x4
36 };
37 
38 struct TextEditor {
43 
47  int16 width;
48 
53 
59 
63  int16 borderColor;
64 
68  uint8 foreColor;
69 
73  uint8 backColor;
74 
78  uint8 skipColor;
79 
83  GuiResourceId fontId;
84 
89 
94 
99 
103  uint16 maxLength;
104 };
105 
115 
120  TextAlign alignment;
121 
126  int16 foreColor;
127 
132  GuiResourceId fontId;
133 
138 };
139 
140 class ScreenItem;
141 
146 public:
147  ScrollWindow(SegManager *segMan, const Common::Rect &gameRect, const Common::Point &position, const reg_t planeObj, const uint8 defaultForeColor, const uint8 defaultBackColor, const GuiResourceId defaultFontId, const TextAlign defaultAlignment, const int16 defaultBorderColor, const uint16 maxNumEntries);
148  ~ScrollWindow();
149 
154  reg_t add(const Common::String &text, const GuiResourceId fontId, const int16 foreColor, const TextAlign alignment, const bool scrollTo);
155 
161  reg_t modify(const reg_t id, const Common::String &text, const GuiResourceId fontId, const int16 foreColor, const TextAlign alignment, const bool scrollTo);
162 
166  void show();
167 
171  void hide();
172 
177  Ratio where() const;
178 
182  void go(const Ratio location);
183 
187  void home();
188 
192  void end();
193 
197  void upArrow();
198 
202  void downArrow();
203 
207  void pageUp();
208 
212  void pageDown();
213 
218  const reg_t getBitmap() const { return _bitmap; }
219 
220 private:
221  SegManager *_segMan;
222 
224 
228  void fillEntry(ScrollWindowEntry &entry, const Common::String &text, const GuiResourceId fontId, const int16 foreColor, const TextAlign alignment);
229 
238  void computeLineIndices();
239 
247  void update(const bool doFrameOut);
248 
252  GfxText32 _gfxText32;
253 
257  EntriesList _entries;
258 
263  uint _maxNumEntries;
264 
268  Common::Array<int> _startsOfLines;
269 
273  Common::String _text;
274 
278  Common::String _visibleText;
279 
283  int _firstVisibleChar;
284 
288  int _topVisibleLine;
289 
294  int _lastVisibleChar;
295 
300  int _bottomVisibleLine;
301 
306  int _numLines;
307 
312  int _numVisibleLines;
313 
317  reg_t _plane;
318 
322  uint8 _foreColor;
323 
327  uint8 _backColor;
328 
333  int16 _borderColor;
334 
338  GuiResourceId _fontId;
339 
343  TextAlign _alignment;
344 
348  bool _visible;
349 
354  Common::Rect _textRect;
355 
360  Common::Point _position;
361 
366  uint8 _pointSize;
367 
371  reg_t _bitmap;
372 
377  uint16 _nextEntryId;
378 
382  ScreenItem *_screenItem;
383 };
384 
390 public:
391  GfxControls32(SegManager *segMan, GfxCache *cache, GfxText32 *text);
392  ~GfxControls32();
393 
394 private:
395  SegManager *_segMan;
396  GfxCache *_gfxCache;
397  GfxText32 *_gfxText32;
398 
399 #pragma mark -
400 #pragma mark Text input control
401 public:
402  reg_t kernelEditText(const reg_t controlObject);
403  reg_t kernelInputText(const reg_t textObject, const reg_t titleTextObject, const int16 maxTextLength);
404 
405 private:
410  bool _overwriteMode;
411 
415  uint32 _nextCursorFlashTick;
416 
420  void drawCursor(TextEditor &editor);
421 
425  void eraseCursor(TextEditor &editor);
426 
431  void flashCursor(TextEditor &editor);
432 
437  bool processEditTextEvent(const SciEvent &event, TextEditor &editor, ScreenItem *screenItem, bool &clearTextOnInput);
438 
439 #pragma mark -
440 #pragma mark Scrollable window control
441 public:
446  reg_t makeScrollWindow(const Common::Rect &gameRect, const Common::Point &position, const reg_t plane, const uint8 defaultForeColor, const uint8 defaultBackColor, const GuiResourceId defaultFontId, const TextAlign defaultAlignment, const int16 defaultBorderColor, const uint16 maxNumEntries);
447 
451  ScrollWindow *getScrollWindow(const reg_t id);
452 
456  void destroyScrollWindow(const reg_t id);
457 
458 private:
460 
464  uint16 _nextScrollWindowId;
465 
469  ScrollWindowMap _scrollWindows;
470 
471 #pragma mark -
472 #pragma mark Message box
473 public:
477  reg_t kernelMessageBox(const Common::String &message, const Common::String &title, const uint16 style);
478 
479 private:
483  int16 showMessageBox(const Common::U32String &message, const Common::U32String &okLabel, const Common::U32String &altLabel, const int16 okValue, const int16 altValue);
484 };
485 
486 } // End of namespace Sci
487 
488 #endif // SCI_GRAPHICS_CONTROLS32_H
Definition: controls32.h:38
Definition: str.h:59
uint8 backColor
Definition: controls32.h:73
Definition: text32.h:53
Common::Rect cursorRect
Definition: controls32.h:98
uint8 skipColor
Definition: controls32.h:78
Definition: rect.h:144
Definition: rational.h:40
int16 width
Definition: controls32.h:47
reg_t bitmap
Definition: controls32.h:42
Common::String text
Definition: controls32.h:52
bool cursorIsDrawn
Definition: controls32.h:93
int16 foreColor
Definition: controls32.h:126
GuiResourceId fontId
Definition: controls32.h:83
Definition: controls32.h:145
Definition: ustr.h:57
Common::String text
Definition: controls32.h:137
GuiResourceId fontId
Definition: controls32.h:132
Definition: event.h:120
Common::Rect textRect
Definition: controls32.h:58
const reg_t getBitmap() const
Definition: controls32.h:218
Definition: cache.h:38
Definition: rect.h:45
Definition: controls32.h:109
Definition: console.h:28
uint16 maxLength
Definition: controls32.h:103
Definition: seg_manager.h:48
Definition: controls32.h:389
Definition: screen_item32.h:53
uint8 foreColor
Definition: controls32.h:68
int16 borderColor
Definition: controls32.h:63
Definition: vm_types.h:39
uint16 cursorCharPosition
Definition: controls32.h:88
reg_t id
Definition: controls32.h:114
TextAlign alignment
Definition: controls32.h:120