Crazy Eddie's GUI System  0.8.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
MouseCursor.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 - 2012 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 "CEGUI/Base.h"
34 #include "CEGUI/String.h"
35 #include "CEGUI/Vector.h"
36 #include "CEGUI/Rect.h"
37 #include "CEGUI/EventSet.h"
38 #include "CEGUI/InputEvent.h"
39 #include "CEGUI/UDim.h"
40 
41 
42 #if defined(_MSC_VER)
43 # pragma warning(push)
44 # pragma warning(disable : 4275)
45 # pragma warning(disable : 4251)
46 #endif
47 
48 // Start of CEGUI namespace section
49 namespace CEGUI
50 {
52 class CEGUIEXPORT MouseCursor :
53  public EventSet,
54  public AllocatedObject<MouseCursor>
55 {
56 public:
58  static const String EventNamespace;
59 
66  static const String EventImageChanged;
67 
76 
81  MouseCursor(void);
82 
83 
88  ~MouseCursor(void);
89 
90 
103  void setImage(const String& name);
104 
105 
110  void setImage(const Image* image);
111 
112 
119  const Image* getImage(void) const {return d_cursorImage;}
120 
129  void setDefaultImage(const Image* image);
130 
141  void setDefaultImage(const String& name);
142 
152  const Image* getDefaultImage() const;
153 
154 
162  void draw(void) const;
163 
164 
172  void setPosition(const Vector2f& position);
173 
174 
185  void offsetPosition(const Vector2f& offset);
186 
187 
200  void setConstraintArea(const Rectf* area);
201 
202 
215  void setUnifiedConstraintArea(const URect* area);
216 
217 
225  void hide(void) {d_visible = false;}
226 
227 
235  void show(void) {d_visible = true;}
236 
237 
248  void setVisible(bool visible) {d_visible = visible;}
249 
250 
258  bool isVisible(void) const {return d_visible;}
259 
260 
268  Vector2f getPosition(void) const
269  { return d_position; }
270 
271 
279  Rectf getConstraintArea(void) const;
280 
281 
289  const URect& getUnifiedConstraintArea(void) const;
290 
291 
301  Vector2f getDisplayIndependantPosition(void) const;
302 
314  void notifyDisplaySizeChanged(const Sizef& new_size);
315 
331  void setExplicitRenderSize(const Sizef& size);
332 
338  const Sizef& getExplicitRenderSize() const;
339 
354  static void setInitialMousePosition(const Vector2f& position);
355 
361  void invalidate();
362 
363 protected:
364  /*************************************************************************
365  New event handlers
366  *************************************************************************/
368  virtual void onImageChanged(MouseCursorEventArgs& e);
370  virtual void onDefaultImageChanged(MouseCursorEventArgs& e);
371 
372 
373 private:
374  /*************************************************************************
375  Implementation Methods
376  *************************************************************************/
381  void constrainPosition(void);
382 
384  void cacheGeometry() const;
385 
387  void calculateCustomOffset() const;
388 
389  /*************************************************************************
390  Implementation Data
391  *************************************************************************/
393  const Image* d_cursorImage;
395  const Image* d_defaultCursorImage;
396  Vector2f d_position;
397  bool d_visible;
398  URect d_constraints;
399 
400  GeometryBuffer* d_geometry;
402  Sizef d_customSize;
404  mutable Vector2f d_customOffset;
406  static bool s_initialPositionSet;
408  static Vector2f s_initialPosition;
410  mutable bool d_cachedGeometryValid;
411 };
412 
413 } // End of CEGUI namespace section
414 
415 #if defined(_MSC_VER)
416 # pragma warning(pop)
417 #endif
418 
419 #endif // end of guard _CEGUIMouseCursor_h_