Crazy Eddie's GUI System 0.8.7
Loading...
Searching...
No Matches
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
48namespace CEGUI
49{
51class CEGUIEXPORT MouseCursor :
52 public EventSet,
53 public AllocatedObject<MouseCursor>
54{
55public:
57 static const String EventNamespace;
58
66
75
81
82
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
200
201
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
268 { return d_position; }
269
270
279
280
288 const URect& getUnifiedConstraintArea(void) const;
289
290
301
314
330 void setExplicitRenderSize(const Sizef& size);
331
338
353 static void setInitialMousePosition(const Vector2f& position);
354
361
362protected:
363 /*************************************************************************
364 New event handlers
365 *************************************************************************/
370
371
372private:
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;
399 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_
Definition MemoryAllocatedObject.h:110
Interface providing event signaling and handling.
Definition EventSet.h:167
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition GeometryBuffer.h:44
Interface for Image.
Definition Image.h:161
EventArgs based class that is used for objects passed to input event handlers concerning mouse cursor...
Definition InputEvent.h:300
Class that provides mouse cursor support.
Definition MouseCursor.h:54
void setConstraintArea(const Rectf *area)
Set the area that the mouse cursor is constrained to.
void draw(void) const
Makes the cursor draw itself.
void offsetPosition(const Vector2f &offset)
Offset the mouse cursor position by the deltas specified in offset.
void setImage(const String &name)
Set the current mouse cursor image.
static const String EventNamespace
Namespace for global events.
Definition MouseCursor.h:57
Rectf getConstraintArea(void) const
return the current constraint area of the mouse cursor.
~MouseCursor(void)
Destructor for MouseCursor objects.
static void setInitialMousePosition(const Vector2f &position)
Static function to pre-initialise the mouse cursor position (prior to MouseCursor instantiation).
void setUnifiedConstraintArea(const URect *area)
Set the area that the mouse cursor is constrained to.
void show(void)
Shows the mouse cursor.
Definition MouseCursor.h:234
const Image * getDefaultImage() const
Return the currently set default mouse cursor image.
virtual void onImageChanged(MouseCursorEventArgs &e)
Event triggered internally when mouse cursor image is changed.
void setDefaultImage(const String &name)
Set the image to be used as the default mouse cursor.
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
void setImage(const Image *image)
Set the current mouse cursor image.
void notifyDisplaySizeChanged(const Sizef &new_size)
Function used to notify the MouseCursor of changes in the display size.
void setPosition(const Vector2f &position)
Set the current mouse cursor position.
void setExplicitRenderSize(const Sizef &size)
Set an explicit size for the mouse cursor image to be drawn at.
static const String EventImageChanged
Definition MouseCursor.h:65
MouseCursor(void)
Constructor for MouseCursor objects.
const URect & getUnifiedConstraintArea(void) const
return the current constraint area of the mouse cursor.
static const String EventDefaultImageChanged
Definition MouseCursor.h:74
void invalidate()
Mark the cached geometry as invalid so it will be recached next time the mouse cursor is drawn.
const Sizef & getExplicitRenderSize() const
Return the explicit render size currently set. A return size of (0, 0) indicates that the real image ...
void setDefaultImage(const Image *image)
Set the image to be used as the default mouse cursor.
void hide(void)
Hides the mouse cursor.
Definition MouseCursor.h:224
const Image * getImage(void) const
Get the current mouse cursor image.
Definition MouseCursor.h:118
virtual void onDefaultImageChanged(MouseCursorEventArgs &e)
Event triggered internally when mouse cursor default image is changed.
bool isVisible(void) const
return whether the mouse cursor is visible.
Definition MouseCursor.h:257
Vector2f getDisplayIndependantPosition(void) const
Return the current mouse cursor position as display resolution independant values.
void setVisible(bool visible)
Set the visibility of the mouse cursor.
Definition MouseCursor.h:247
String class used within the GUI system.
Definition String.h:64
base class for properties able to do native set/get
Definition TypedProperty.h:50
Main namespace for Crazy Eddie's GUI Library.
Definition arch_overview.dox:1