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 "common/frac.h"
29#include "graphics/cursor.h"
30#include "graphics/surface.h"
31
32namespace Graphics {
33
43class CursorManager : public Common::Singleton<CursorManager> {
44public:
46 bool isVisible();
47
63 bool showMouse(bool visible);
64
91 void pushCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, const Graphics::PixelFormat *format = NULL, const byte *mask = nullptr, frac_t scaleX = FRAC_ONE, frac_t scaleY = FRAC_ONE);
92
115 void pushCursor(const Surface &surf, int hotspotX, int hotspotY, uint32 keycolor, const byte *mask = nullptr, frac_t scaleX = FRAC_ONE, frac_t scaleY = FRAC_ONE);
116
123 void popCursor();
124
148 void replaceCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, const Graphics::PixelFormat *format = nullptr, const byte *mask = nullptr, frac_t scaleX = FRAC_ONE, frac_t scaleY = FRAC_ONE);
149
169 void replaceCursor(const Surface &surf, int hotspotX, int hotspotY, uint32 keycolor, const byte *mask = nullptr, frac_t scaleX = FRAC_ONE, frac_t scaleY = FRAC_ONE);
170
183 void replaceCursor(const Graphics::Cursor *cursor, frac_t scaleX = FRAC_ONE, frac_t scaleY = FRAC_ONE);
184
193
204
210 void disableCursorPalette(bool disable);
211
227 void pushCursorPalette(const byte *colors, uint start, uint num);
228
236
249 void replaceCursorPalette(const byte *colors, uint start, uint num);
250
257 void lock(bool locked);
258
267 void setDefaultArrowCursor(bool push = false);
268
269private:
273 friend class Common::Singleton<SingletonBaseType>;
274 // Even though this is basically the default constructor we implement it
275 // ourselves, so it is private and thus there is no way to create this class
276 // except from the Singleton code.
277 CursorManager() {
278 _locked = false;
279 }
281
282 struct Cursor {
283 Surface _surf;
284 byte *_mask;
285 bool _visible;
286 int _hotspotX;
287 int _hotspotY;
288 uint32 _keycolor;
289 frac_t _scaleX;
290 frac_t _scaleY;
291
292 uint _size;
293
294 // _surf set to default by Graphics::Surface default constructor
295 Cursor() : _mask(0), _visible(false), _hotspotX(0), _hotspotY(0), _keycolor(0), _scaleX(FRAC_ONE), _scaleY(FRAC_ONE), _size(0) {}
296
297 Cursor(const Surface &surf, int hotspotX, int hotspotY, uint32 keycolor, const byte *mask, frac_t scaleX, frac_t scaleY);
298 ~Cursor();
299 };
300
301 struct Palette {
302 byte *_data;
303 uint _start;
304 uint _num;
305 uint _size;
306
307 bool _disabled;
308
309 Palette() : _data(0), _start(0), _num(0), _size(0), _disabled(false) {}
310
311 Palette(const byte *colors, uint start, uint num);
312 ~Palette();
313 };
314 Common::Stack<Cursor *> _cursorStack;
315 Common::Stack<Palette *> _cursorPaletteStack;
316 bool _locked;
317
318 bool systemSupportsCursorMask(const byte *mask, uint width, uint height);
319};
321} // End of namespace Graphics
322
323#define CursorMan (::Graphics::CursorManager::instance())
324
325#endif
Definition: singleton.h:42
Definition: cursor.h:42
Definition: cursorman.h:43
void setDefaultArrowCursor(bool push=false)
void replaceCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, const Graphics::PixelFormat *format=nullptr, const byte *mask=nullptr, frac_t scaleX=FRAC_ONE, frac_t scaleY=FRAC_ONE)
void pushCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, const Graphics::PixelFormat *format=NULL, const byte *mask=nullptr, frac_t scaleX=FRAC_ONE, frac_t scaleY=FRAC_ONE)
void pushCursorPalette(const byte *colors, uint start, uint num)
void disableCursorPalette(bool disable)
void replaceCursor(const Surface &surf, int hotspotX, int hotspotY, uint32 keycolor, const byte *mask=nullptr, frac_t scaleX=FRAC_ONE, frac_t scaleY=FRAC_ONE)
bool showMouse(bool visible)
void pushCursor(const Surface &surf, int hotspotX, int hotspotY, uint32 keycolor, const byte *mask=nullptr, frac_t scaleX=FRAC_ONE, frac_t scaleY=FRAC_ONE)
void replaceCursorPalette(const byte *colors, uint start, uint num)
void lock(bool locked)
void replaceCursor(const Graphics::Cursor *cursor, frac_t scaleX=FRAC_ONE, frac_t scaleY=FRAC_ONE)
Definition: atari-screen.h:42
int32 frac_t
Definition: frac.h:52
Definition: formatinfo.h:28
Definition: atari-cursor.h:35
Definition: pixelformat.h:138
Definition: surface.h:67