Crazy Eddie's GUI System  0.8.7
MouseCursor.h
1 /***********************************************************************
2  created: 21/2/2004
3  author: Paul D Turner
4 
5  purpose: Defines interface for the MouseCursor class
6 *************************************************************************/
7 /***************************************************************************
8  * Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining
11  * a copy of this software and associated documentation files (the
12  * "Software"), to deal in the Software without restriction, including
13  * without limitation the rights to use, copy, modify, merge, publish,
14  * distribute, sublicense, and/or sell copies of the Software, and to
15  * permit persons to whom the Software is furnished to do so, subject to
16  * the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be
19  * included in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  ***************************************************************************/
29 #ifndef _CEGUIMouseCursor_h_
30 #define _CEGUIMouseCursor_h_
31 
32 #include "CEGUI/Base.h"
33 #include "CEGUI/String.h"
34 #include "CEGUI/Vector.h"
35 #include "CEGUI/Rect.h"
36 #include "CEGUI/EventSet.h"
37 #include "CEGUI/InputEvent.h"
38 #include "CEGUI/UDim.h"
39 
40 
41 #if defined(_MSC_VER)
42 # pragma warning(push)
43 # pragma warning(disable : 4275)
44 # pragma warning(disable : 4251)
45 #endif
46 
47 // Start of CEGUI namespace section
48 namespace CEGUI
49 {
51 class CEGUIEXPORT MouseCursor :
52  public EventSet,
53  public AllocatedObject<MouseCursor>
54 {
55 public:
57  static const String EventNamespace;
58 
65  static const String EventImageChanged;
66 
75 
80  MouseCursor(void);
81 
82 
87  ~MouseCursor(void);
88 
89 
102  void setImage(const String& name);
103 
104 
109  void setImage(const Image* image);
110 
111 
118  const Image* getImage(void) const {return d_cursorImage;}
119 
128  void setDefaultImage(const Image* image);
129 
140  void setDefaultImage(const String& name);
141 
151  const Image* getDefaultImage() const;
152 
153 
161  void draw(void) const;
162 
163 
171  void setPosition(const Vector2f& position);
172 
173 
184  void offsetPosition(const Vector2f& offset);
185 
186 
199  void setConstraintArea(const Rectf* area);
200 
201 
214  void setUnifiedConstraintArea(const URect* area);
215 
216 
224  void hide(void) {d_visible = false;}
225 
226 
234  void show(void) {d_visible = true;}
235 
236 
247  void setVisible(bool visible) {d_visible = visible;}
248 
249 
257  bool isVisible(void) const {return d_visible;}
258 
259 
267  Vector2f getPosition(void) const
268  { return d_position; }
269 
270 
278  Rectf getConstraintArea(void) const;
279 
280 
288  const URect& getUnifiedConstraintArea(void) const;
289 
290 
300  Vector2f getDisplayIndependantPosition(void) const;
301 
313  void notifyDisplaySizeChanged(const Sizef& new_size);
314 
330  void setExplicitRenderSize(const Sizef& size);
331 
337  const Sizef& getExplicitRenderSize() const;
338 
353  static void setInitialMousePosition(const Vector2f& position);
354 
360  void invalidate();
361 
362 protected:
363  /*************************************************************************
364  New event handlers
365  *************************************************************************/
367  virtual void onImageChanged(MouseCursorEventArgs& e);
369  virtual void onDefaultImageChanged(MouseCursorEventArgs& e);
370 
371 
372 private:
373  /*************************************************************************
374  Implementation Methods
375  *************************************************************************/
380  void constrainPosition(void);
381 
383  void cacheGeometry() const;
384 
386  void calculateCustomOffset() const;
387 
388  /*************************************************************************
389  Implementation Data
390  *************************************************************************/
392  const Image* d_cursorImage;
394  const Image* d_defaultCursorImage;
395  Vector2f d_position;
396  bool d_visible;
397  URect d_constraints;
398  GeometryBuffer* d_geometry;
401  Sizef d_customSize;
403  mutable Vector2f d_customOffset;
405  static bool s_initialPositionSet;
407  static Vector2f 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_
Class that provides mouse cursor support.
Definition: MouseCursor.h:51
Definition: MemoryAllocatedObject.h:109
void hide(void)
Hides the mouse cursor.
Definition: MouseCursor.h:224
Interface for Image.
Definition: Image.h:158
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: GeometryBuffer.h:42
static const String EventImageChanged
Definition: MouseCursor.h:65
static const String EventDefaultImageChanged
Definition: MouseCursor.h:74
bool isVisible(void) const
return whether the mouse cursor is visible.
Definition: MouseCursor.h:257
static const String EventNamespace
Namespace for global events.
Definition: MouseCursor.h:57
Vector2f getPosition(void) const
Return the current mouse cursor position as a pixel offset from the top-left corner of the display...
Definition: MouseCursor.h:267
EventArgs based class that is used for objects passed to input event handlers concerning mouse cursor...
Definition: InputEvent.h:299
const Image * getImage(void) const
Get the current mouse cursor image.
Definition: MouseCursor.h:118
void setVisible(bool visible)
Set the visibility of the mouse cursor.
Definition: MouseCursor.h:247
Interface providing event signaling and handling.
Definition: EventSet.h:166
void show(void)
Shows the mouse cursor.
Definition: MouseCursor.h:234
String class used within the GUI system.
Definition: String.h:62