Crazy Eddies GUI System  0.6.0
CEGUIMouseCursor.h
1 /***********************************************************************
2  filename: CEGUIMouseCursor.h
3  created: 21/2/2004
4  author: Paul D Turner
5 
6  purpose: Defines interface for the MouseCursor class
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIMouseCursor_h_
31 #define _CEGUIMouseCursor_h_
32 
33 #include "CEGUIBase.h"
34 #include "CEGUIString.h"
35 #include "CEGUISingleton.h"
36 #include "CEGUIVector.h"
37 #include "CEGUIRect.h"
38 #include "CEGUIEventSet.h"
39 #include "CEGUIInputEvent.h"
40 #include "CEGUIUDim.h"
41 
42 
43 #if defined(_MSC_VER)
44 # pragma warning(push)
45 # pragma warning(disable : 4275)
46 # pragma warning(disable : 4251)
47 #endif
48 
49 
50 // Start of CEGUI namespace section
51 namespace CEGUI
52 {
53 
59 {
62 };
63 
64 
71 class CEGUIEXPORT MouseCursor : public EventSet, public Singleton<MouseCursor>
72 {
73 public:
74  static const String EventNamespace;
75 
76  /*************************************************************************
77  Event name constants
78  *************************************************************************/
79  // generated internally by MouseCursor
80  static const String EventImageChanged;
81 
82 
87  MouseCursor(void);
88 
89 
94  ~MouseCursor(void);
95 
96 
104  static MouseCursor& getSingleton(void);
105 
106 
114  static MouseCursor* getSingletonPtr(void);
115 
116 
132  void setImage(const String& imageset, const String& image_name);
133 
134 
139  void setImage(const Image* image);
140 
141 
148  const Image* getImage(void) const {return d_cursorImage;}
149 
150 
158  void draw(void) const;
159 
160 
168  void setPosition(const Point& position);
169 
170 
181  void offsetPosition(const Point& offset);
182 
183 
196  void setConstraintArea(const Rect* area);
197 
198 
211  void setUnifiedConstraintArea(const URect* area);
212 
213 
221  void hide(void) {d_visible = false;}
222 
223 
231  void show(void) {d_visible = true;}
232 
233 
244  void setVisible(bool visible) {d_visible = visible;}
245 
246 
254  bool isVisible(void) const {return d_visible;}
255 
256 
264  Point getPosition(void) const {return Point(d_position.d_x, d_position.d_y);}
265 
266 
274  Rect getConstraintArea(void) const;
275 
276 
284  const URect& getUnifiedConstraintArea(void) const;
285 
286 
296  Point getDisplayIndependantPosition(void) const;
297 
298 
299 protected:
300  /*************************************************************************
301  New event handlers
302  *************************************************************************/
307  virtual void onImageChanged(MouseCursorEventArgs& e);
308 
309 
310 private:
311  /*************************************************************************
312  Implementation Methods
313  *************************************************************************/
318  void constrainPosition(void);
319 
320 
321  /*************************************************************************
322  Implementation Data
323  *************************************************************************/
324  const Image* d_cursorImage;
325  Vector3 d_position;
326  bool d_visible;
327  URect d_constraints;
328 };
329 
330 } // End of CEGUI namespace section
331 
332 #if defined(_MSC_VER)
333 # pragma warning(pop)
334 #endif
335 
336 #endif // end of guard _CEGUIMouseCursor_h_