ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
virtual-keyboard-gui.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 COMMON_VIRTUAL_KEYBOARD_GUI_H
23 #define COMMON_VIRTUAL_KEYBOARD_GUI_H
24 
25 #include "common/scummsys.h"
26 
27 #ifdef ENABLE_VKEYBD
28 
29 #include "backends/vkeybd/virtual-keyboard.h"
30 #include "common/rect.h"
31 #include "common/system.h"
32 #include "graphics/font.h"
33 #include "graphics/surface.h"
34 
35 namespace Common {
36 
43 class VirtualKeyboardGUI {
44 
45 public:
46 
47  VirtualKeyboardGUI(VirtualKeyboard *kbd);
48  ~VirtualKeyboardGUI();
49 
53  void initMode(VirtualKeyboard::Mode *mode);
54 
58  void run();
59 
63  void close();
64 
65  bool isDisplaying() { return _displaying; }
66 
70  void reset();
71 
76  void startDrag(int16 x, int16 y);
77 
81  void endDrag();
82 
87  void checkScreenChanged();
88 
92  void initSize(int16 w, int16 h);
93 
94 private:
95 
96  OSystem *_system;
97 
98  VirtualKeyboard *_kbd;
99  Rect _kbdBound;
100  Graphics::Surface *_kbdSurface;
101  uint32 _kbdTransparentColor;
102 
103  Point _dragPoint;
104  bool _drag;
105  static const int SNAP_WIDTH = 10;
106 
107  Graphics::Surface _overlayBackup;
108  Rect _dirtyRect;
109 
110  bool _displayEnabled;
111  Graphics::Surface _dispSurface;
112  const Graphics::Font *_dispFont;
113  int16 _dispX, _dispY;
114  uint _dispI;
115  uint32 _dispForeColor, _dispBackColor;
116 
117  int _lastScreenChanged;
118  int16 _screenW, _screenH;
119 
120  bool _displaying;
121  bool _firstRun;
122 
123  void setupDisplayArea(Rect &r, uint32 forecolor);
124  void move(int16 x, int16 y);
125  void moveToDefaultPosition();
126  void screenChanged();
127  void mainLoop();
128  void extendDirtyRect(const Rect &r);
129  void resetDirtyRect();
130  void redraw();
131  void forceRedraw();
132  void updateDisplay();
133  bool fontIsSuitable(const Graphics::Font *font, const Rect &rect);
134  uint calculateEndIndex(const String &str, uint startIndex);
135 
136  bool _drawCaret;
137  int16 _caretX;
138  static const int kCaretBlinkTime = 500;
139  void animateCaret();
140 
141  static const int kCursorAnimateDelay = 250;
142  int _cursorAnimateCounter;
143  int _cursorAnimateTimer;
144  byte _cursor[2048];
145  void setupCursor();
146  void removeCursor();
147  void animateCursor();
148 
149 };
150 
151 } // End of namespace Common
152 
153 #endif // #ifdef ENABLE_VKEYBD
154 
155 #endif // #ifndef COMMON_VIRTUAL_KEYBOARD_GUI_H
Definition: font.h:83
Definition: surface.h:67
Definition: display_client.h:58
Definition: algorithm.h:29
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
Definition: system.h:161