Crazy Eddies GUI System  0.7.8
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
85  static const String EventImageChanged;
86 
87 
92  MouseCursor(void);
93 
94 
99  ~MouseCursor(void);
100 
101 
109  static MouseCursor& getSingleton(void);
110 
111 
119  static MouseCursor* getSingletonPtr(void);
120 
121 
137  void setImage(const String& imageset, const String& image_name);
138 
139 
144  void setImage(const Image* image);
145 
146 
153  const Image* getImage(void) const {return d_cursorImage;}
154 
155 
163  void draw(void) const;
164 
165 
173  void setPosition(const Point& position);
174 
175 
186  void offsetPosition(const Point& offset);
187 
188 
201  void setConstraintArea(const Rect* area);
202 
203 
216  void setUnifiedConstraintArea(const URect* area);
217 
218 
226  void hide(void) {d_visible = false;}
227 
228 
236  void show(void) {d_visible = true;}
237 
238 
249  void setVisible(bool visible) {d_visible = visible;}
250 
251 
259  bool isVisible(void) const {return d_visible;}
260 
261 
269  Point getPosition(void) const
270  { return d_position; }
271 
272 
280  Rect getConstraintArea(void) const;
281 
282 
290  const URect& getUnifiedConstraintArea(void) const;
291 
292 
302  Point getDisplayIndependantPosition(void) const;
303 
315  void notifyDisplaySizeChanged(const Size& new_size);
316 
332  void setExplicitRenderSize(const Size& size);
333 
339  const Size& getExplicitRenderSize() const;
340 
355  static void setInitialMousePosition(const Point& position);
356 
362  void invalidate();
363 
364 protected:
365  /*************************************************************************
366  New event handlers
367  *************************************************************************/
372  virtual void onImageChanged(MouseCursorEventArgs& e);
373 
374 
375 private:
376  /*************************************************************************
377  Implementation Methods
378  *************************************************************************/
383  void constrainPosition(void);
384 
386  void cacheGeometry() const;
387 
389  void calculateCustomOffset() const;
390 
391  /*************************************************************************
392  Implementation Data
393  *************************************************************************/
394  const Image* d_cursorImage;
395  Vector2 d_position;
396  bool d_visible;
397  URect d_constraints;
398 
399  GeometryBuffer* d_geometry;
401  Size d_customSize;
403  mutable Point d_customOffset;
405  static bool s_initialPositionSet;
407  static Point s_initialPosition;
409  mutable bool d_cachedGeometryValid;
410 };
411 
412 } // End of CEGUI namespace section
413 
414 #if defined(_MSC_VER)
415 # pragma warning(pop)
416 #endif
417 
418 #endif // end of guard _CEGUIMouseCursor_h_