ScummVM API documentation
cursorman.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 GRAPHICS_CURSORMAN_H
23 #define GRAPHICS_CURSORMAN_H
24 
25 #include "common/scummsys.h"
26 #include "common/stack.h"
27 #include "common/singleton.h"
28 #include "graphics/cursor.h"
29 #include "graphics/surface.h"
30 
31 namespace Graphics {
32 
42 class CursorManager : public Common::Singleton<CursorManager> {
43 public:
45  bool isVisible();
46 
62  bool showMouse(bool visible);
63 
88  void pushCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL, const byte *mask = nullptr);
89 
110  void pushCursor(const Surface &surf, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const byte *mask = nullptr);
111 
118  void popCursor();
119 
141  void replaceCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = nullptr, const byte *mask = nullptr);
142 
160  void replaceCursor(const Surface &surf, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const byte *mask = nullptr);
161 
170  void replaceCursor(const Graphics::Cursor *cursor);
171 
179  void popAllCursors();
180 
190  bool supportsCursorPalettes();
191 
197  void disableCursorPalette(bool disable);
198 
214  void pushCursorPalette(const byte *colors, uint start, uint num);
215 
222  void popCursorPalette();
223 
236  void replaceCursorPalette(const byte *colors, uint start, uint num);
237 
244  void lock(bool locked);
245 
254  void setDefaultArrowCursor(bool push = false);
255 
256 private:
260  friend class Common::Singleton<SingletonBaseType>;
261  // Even though this is basically the default constructor we implement it
262  // ourselves, so it is private and thus there is no way to create this class
263  // except from the Singleton code.
264  CursorManager() {
265  _locked = false;
266  }
267  ~CursorManager();
268 
269  struct Cursor {
270  Surface _surf;
271  byte *_mask;
272  bool _visible;
273  int _hotspotX;
274  int _hotspotY;
275  uint32 _keycolor;
276  bool _dontScale;
277 
278  uint _size;
279 
280  // _surf set to default by Graphics::Surface default constructor
281  Cursor() : _mask(0), _visible(false), _hotspotX(0), _hotspotY(0), _keycolor(0), _dontScale(false), _size(0) {}
282 
283  Cursor(const Surface &surf, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const byte *mask);
284  ~Cursor();
285  };
286 
287  struct Palette {
288  byte *_data;
289  uint _start;
290  uint _num;
291  uint _size;
292 
293  bool _disabled;
294 
295  Palette() : _data(0), _start(0), _num(0), _size(0), _disabled(false) {}
296 
297  Palette(const byte *colors, uint start, uint num);
298  ~Palette();
299  };
300  Common::Stack<Cursor *> _cursorStack;
301  Common::Stack<Palette *> _cursorPaletteStack;
302  bool _locked;
303 };
305 } // End of namespace Graphics
306 
307 #define CursorMan (::Graphics::CursorManager::instance())
308 
309 #endif
Definition: surface.h:67
void replaceCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale=false, const Graphics::PixelFormat *format=nullptr, const byte *mask=nullptr)
void pushCursorPalette(const byte *colors, uint start, uint num)
Definition: pixelformat.h:138
void lock(bool locked)
Definition: cursorman.h:42
void setDefaultArrowCursor(bool push=false)
Definition: cursor.h:42
Definition: formatinfo.h:28
void disableCursorPalette(bool disable)
bool showMouse(bool visible)
void replaceCursorPalette(const byte *colors, uint start, uint num)
Definition: stack.h:102
void pushCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale=false, const Graphics::PixelFormat *format=NULL, const byte *mask=nullptr)
Definition: singleton.h:42