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 
172  void replaceCursor(const Graphics::Cursor *cursor, bool dontScale = false);
173 
181  void popAllCursors();
182 
192  bool supportsCursorPalettes();
193 
199  void disableCursorPalette(bool disable);
200 
216  void pushCursorPalette(const byte *colors, uint start, uint num);
217 
224  void popCursorPalette();
225 
238  void replaceCursorPalette(const byte *colors, uint start, uint num);
239 
246  void lock(bool locked);
247 
256  void setDefaultArrowCursor(bool push = false);
257 
258 private:
262  friend class Common::Singleton<SingletonBaseType>;
263  // Even though this is basically the default constructor we implement it
264  // ourselves, so it is private and thus there is no way to create this class
265  // except from the Singleton code.
266  CursorManager() {
267  _locked = false;
268  }
269  ~CursorManager();
270 
271  struct Cursor {
272  Surface _surf;
273  byte *_mask;
274  bool _visible;
275  int _hotspotX;
276  int _hotspotY;
277  uint32 _keycolor;
278  bool _dontScale;
279 
280  uint _size;
281 
282  // _surf set to default by Graphics::Surface default constructor
283  Cursor() : _mask(0), _visible(false), _hotspotX(0), _hotspotY(0), _keycolor(0), _dontScale(false), _size(0) {}
284 
285  Cursor(const Surface &surf, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const byte *mask);
286  ~Cursor();
287  };
288 
289  struct Palette {
290  byte *_data;
291  uint _start;
292  uint _num;
293  uint _size;
294 
295  bool _disabled;
296 
297  Palette() : _data(0), _start(0), _num(0), _size(0), _disabled(false) {}
298 
299  Palette(const byte *colors, uint start, uint num);
300  ~Palette();
301  };
302  Common::Stack<Cursor *> _cursorStack;
303  Common::Stack<Palette *> _cursorPaletteStack;
304  bool _locked;
305 
306  bool systemSupportsCursorMask(const byte *mask, uint width, uint height);
307 };
309 } // End of namespace Graphics
310 
311 #define CursorMan (::Graphics::CursorManager::instance())
312 
313 #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