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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef TITANIC_TEXT_CURSOR_H 24 #define TITANIC_TEXT_CURSOR_H 25 26 #include "common/scummsys.h" 27 #include "titanic/support/rect.h" 28 29 namespace Titanic { 30 31 class CScreenManager; 32 class CVideoSurface; 33 34 class CTextCursor { 35 private: 36 CScreenManager *_screenManager; 37 CVideoSurface *_backRenderSurface; 38 CVideoSurface *_frontRenderSurface; 39 Point _pos; 40 Rect _screenBounds; 41 uint _blinkDelay; 42 bool _blinkVisible; 43 Point _size; 44 Point _screenTopLeft; 45 uint _priorBlinkTime; 46 byte _cursorR; 47 byte _cursorG; 48 byte _cursorB; 49 CVideoSurface *_surface; 50 int _mode; 51 public: 52 bool _active; 53 public: 54 CTextCursor(CScreenManager *screenManager); 55 ~CTextCursor(); 56 57 /** 58 * Sets the position of the cursor 59 */ setPos(const Point & pt)60 void setPos(const Point &pt) { _pos = pt; } 61 62 /** 63 * Sets the size of the cursor 64 */ setSize(const Point & size)65 void setSize(const Point &size) { _size = size; } 66 67 /** 68 * Returns the bounds for the cursor 69 */ getCursorBounds()70 Rect getCursorBounds() const { 71 return Rect(_pos.x, _pos.y, _pos.x + _size.x, _pos.y + _size.y); 72 } 73 74 /** 75 * Set bounds 76 */ setBounds(const Rect & r)77 void setBounds(const Rect &r) { _screenBounds = r; } 78 79 /** 80 * Clear the bounds 81 */ clearBounds()82 void clearBounds() { _screenBounds.clear(); } 83 84 /** 85 * Set the blinking rate 86 */ setBlinkRate(uint ticks)87 void setBlinkRate(uint ticks) { _blinkDelay = ticks; } 88 89 /** 90 * Set the cursor color 91 */ 92 void setColor(byte r, byte g, byte b); 93 94 /** 95 * Returns whether the text cursor is active 96 */ isActive()97 bool isActive() const { return _active; } 98 getMode()99 int getMode() const { return _mode; } 100 setMode(int mode)101 void setMode(int mode) { _mode = mode; } 102 103 /** 104 * Show the text cursor 105 */ 106 void show(); 107 108 /** 109 * Hide the text cursor 110 */ 111 void hide(); 112 113 /** 114 * Update and draw the cursor if necessary 115 */ 116 void draw(); 117 }; 118 119 } // End of namespace Titanic 120 121 #endif /* TITANIC_TEXT_CURSOR_H */ 122