1/**
2 * Copyright (c) 2006-2023 LOVE Development Team
3 *
4 * This software is provided 'as-is', without any express or implied
5 * warranty. In no event will the authors be held liable for any damages
6 * arising from the use of this software.
7 *
8 * Permission is granted to anyone to use this software for any purpose,
9 * including commercial applications, and to alter it and redistribute it
10 * freely, subject to the following restrictions:
11 *
12 * 1. The origin of this software must not be misrepresented; you must not
13 * claim that you wrote the original software. If you use this software
14 * in a product, an acknowledgment in the product documentation would be
15 * appreciated but is not required.
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 * 3. This notice may not be removed or altered from any source distribution.
19 **/
20
21#ifndef LOVE_MOUSE_CURSOR_H
22#define LOVE_MOUSE_CURSOR_H
23
24// LOVE
25#include "image/ImageData.h"
26#include "common/Object.h"
27#include "common/StringMap.h"
28
29namespace love
30{
31namespace mouse
32{
33
34class Cursor : public Object
35{
36public:
37
38 static love::Type type;
39
40 // Types of system cursors.
41 enum SystemCursor
42 {
43 CURSOR_ARROW,
44 CURSOR_IBEAM,
45 CURSOR_WAIT,
46 CURSOR_CROSSHAIR,
47 CURSOR_WAITARROW,
48 CURSOR_SIZENWSE,
49 CURSOR_SIZENESW,
50 CURSOR_SIZEWE,
51 CURSOR_SIZENS,
52 CURSOR_SIZEALL,
53 CURSOR_NO,
54 CURSOR_HAND,
55 CURSOR_MAX_ENUM
56 };
57
58 enum CursorType
59 {
60 CURSORTYPE_SYSTEM,
61 CURSORTYPE_IMAGE,
62 CURSORTYPE_MAX_ENUM
63 };
64
65 virtual ~Cursor();
66
67 /**
68 * Returns a pointer to the implementation-dependent handle of this Cursor.
69 **/
70 virtual void *getHandle() const = 0;
71
72 /**
73 * Returns whether this Cursor is system-defined or a custom image.
74 **/
75 virtual CursorType getType() const = 0;
76
77 /**
78 * Returns the type type of system cursor used, if this Cursor is using a
79 * system-defined image.
80 **/
81 virtual SystemCursor getSystemType() const = 0;
82
83 static bool getConstant(const char *in, SystemCursor &out);
84 static bool getConstant(SystemCursor in, const char *&out);
85
86 static bool getConstant(const char *in, CursorType &out);
87 static bool getConstant(CursorType in, const char *&out);
88
89private:
90
91 static StringMap<SystemCursor, CURSOR_MAX_ENUM>::Entry systemCursorEntries[];
92 static StringMap<SystemCursor, CURSOR_MAX_ENUM> systemCursors;
93
94 static StringMap<CursorType, CURSORTYPE_MAX_ENUM>::Entry typeEntries[];
95 static StringMap<CursorType, CURSORTYPE_MAX_ENUM> types;
96
97};
98
99} // mouse
100} // love
101
102#endif // LOVE_MOUSE_CURSOR_H
103