xoreos  0.0.5
cursorman.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos 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 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos 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 xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef GRAPHICS_AURORA_CURSORMAN_H
26 #define GRAPHICS_AURORA_CURSORMAN_H
27 
28 #include <map>
29 
30 #include "src/common/types.h"
31 #include "src/common/ustring.h"
32 #include "src/common/singleton.h"
33 #include "src/common/mutex.h"
34 
35 namespace Graphics {
36 
37 namespace Aurora {
38 
39 class Cursor;
40 
42 class CursorManager : public Common::Singleton<CursorManager> {
43 public:
44  CursorManager();
46 
48  void clear();
49 
60  bool add(const Common::UString &name, const Common::UString &group,
61  const Common::UString &state = "", int hotspotX = -1, int hotspotY = -1);
62 
64  void setDefault(const Common::UString &group, const Common::UString &state = "");
65 
67  void set(const Common::UString &group, const Common::UString &state = "");
68 
70  void setGroup(const Common::UString &group);
72  void setState(const Common::UString &state);
73 
75  void set();
76 
78  void reset();
79 
80  void hideCursor();
81  void showCursor();
82 
84  uint8 getPosition(int &x, int &y) const;
86  void setPosition(int x, int y);
87 
89  void toScreenCoordinates(int x, int y, float &sX, float &sY);
91  void fromScreenCoordinates(float sX, float sY, int &x, int &y);
92 
93  bool isVisible() const;
94 
96  const Common::UString &getCurrentGroup() const;
98  const Common::UString &getCurrentState() const;
99 
100 private:
101  typedef std::map<Common::UString, Cursor *> StateMap;
102  typedef std::map<Common::UString, StateMap> CursorMap;
103 
105 
108 
111 
112  bool _hidden;
113 
115 
117 
118 
119  Cursor *find(Common::UString &group, Common::UString &state, bool def = false) const;
120 
121  void update();
122 };
123 
124 } // End of namespace Aurora
125 
126 } // End of namespace Graphics
127 
129 #define CursorMan Graphics::Aurora::CursorManager::instance()
130 
131 #endif // GRAPHICS_AURORA_CURSORMAN_H
bool add(const Common::UString &name, const Common::UString &group, const Common::UString &state="", int hotspotX=-1, int hotspotY=-1)
Add a cursor.
Definition: cursorman.cpp:79
Class and macro for implementing singletons.
void setPosition(int x, int y)
Move the cursor to a specific position.
Definition: cursorman.cpp:163
const Common::UString & getCurrentGroup() const
Return the current group.
Definition: cursorman.cpp:53
Common::UString _currentState
Definition: cursorman.h:107
A class holding an UTF-8 string.
Definition: ustring.h:48
void reset()
Reset the cursor to the system&#39;s default.
Definition: cursorman.cpp:119
uint8_t uint8
Definition: types.h:200
void setGroup(const Common::UString &group)
Set the cursor to another group, using the current state name.
Definition: cursorman.cpp:136
void setState(const Common::UString &state)
Set the cursor to a different state within the current group.
Definition: cursorman.cpp:142
Common::UString _currentGroup
Definition: cursorman.h:106
const Common::UString & getCurrentState() const
Return the current state.
Definition: cursorman.cpp:57
void clear()
Remove all managed cursors.
Definition: cursorman.cpp:61
Generic template base class for implementing the singleton design pattern.
Definition: singleton.h:61
A mutex.
Definition: mutex.h:40
void toScreenCoordinates(int x, int y, float &sX, float &sY)
Convert cursor position to screen position.
Definition: cursorman.cpp:167
bool isVisible() const
Is a cursor current visible?
Definition: cursorman.cpp:49
Cursor * find(Common::UString &group, Common::UString &state, bool def=false) const
Definition: cursorman.cpp:199
Common::UString _defaultState
Definition: cursorman.h:110
void hideCursor()
Hide the cursor completely.
Definition: cursorman.cpp:183
Low-level type definitions to handle fixed width types portably.
void setDefault(const Common::UString &group, const Common::UString &state="")
Register this cursor as the default cursor.
Definition: cursorman.cpp:112
The global Aurora cursor manager.
Definition: cursorman.h:42
Common::UString _defaultGroup
Definition: cursorman.h:109
Unicode string handling.
Thread mutex classes.
void fromScreenCoordinates(float sX, float sY, int &x, int &y)
Convert screen position to cursor position.
Definition: cursorman.cpp:175
std::map< Common::UString, Cursor * > StateMap
Definition: cursorman.h:101
std::map< Common::UString, StateMap > CursorMap
Definition: cursorman.h:102
A cursor as used in the Aurora engines.
Definition: cursor.h:39
void showCursor()
Unhide the cursor.
Definition: cursorman.cpp:191
uint8 getPosition(int &x, int &y) const
Get the current cursor position.
Definition: cursorman.cpp:159