Crazy Eddies GUI System  0.7.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 - 2009 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 {
58 {
61 };
62 
63 
70 class CEGUIEXPORT MouseCursor : public EventSet, public Singleton<MouseCursor>
71 {
72 public:
73  static const String EventNamespace;
74 
75  /*************************************************************************
76  Event name constants
77  *************************************************************************/
78  // generated internally by MouseCursor
79  static const String EventImageChanged;
80 
81 
86  MouseCursor(void);
87 
88 
93  ~MouseCursor(void);
94 
95 
103  static MouseCursor& getSingleton(void);
104 
105 
113  static MouseCursor* getSingletonPtr(void);
114 
115 
131  void setImage(const String& imageset, const String& image_name);
132 
133 
138  void setImage(const Image* image);
139 
140 
147  const Image* getImage(void) const {return d_cursorImage;}
148 
149 
157  void draw(void) const;
158 
159 
167  void setPosition(const Point& position);
168 
169 
180  void offsetPosition(const Point& offset);
181 
182 
195  void setConstraintArea(const Rect* area);
196 
197 
210  void setUnifiedConstraintArea(const URect* area);
211 
212 
220  void hide(void) {d_visible = false;}
221 
222 
230  void show(void) {d_visible = true;}
231 
232 
243  void setVisible(bool visible) {d_visible = visible;}
244 
245 
253  bool isVisible(void) const {return d_visible;}
254 
255 
263  Point getPosition(void) const
264  { return d_position; }
265 
266 
274  Rect getConstraintArea(void) const;
275 
276 
284  const URect& getUnifiedConstraintArea(void) const;
285 
286 
296  Point getDisplayIndependantPosition(void) const;
297 
309  void notifyDisplaySizeChanged(const Size& new_size);
310 
311 protected:
312  /*************************************************************************
313  New event handlers
314  *************************************************************************/
319  virtual void onImageChanged(MouseCursorEventArgs& e);
320 
321 
322 private:
323  /*************************************************************************
324  Implementation Methods
325  *************************************************************************/
330  void constrainPosition(void);
331 
332  /*************************************************************************
333  Implementation Data
334  *************************************************************************/
335  const Image* d_cursorImage;
336  Vector2 d_position;
337  bool d_visible;
338  URect d_constraints;
339 
340  GeometryBuffer* d_geometry;
341 };
342 
343 } // End of CEGUI namespace section
344 
345 #if defined(_MSC_VER)
346 # pragma warning(pop)
347 #endif
348 
349 #endif // end of guard _CEGUIMouseCursor_h_