arsa  2.7
ICursorControl.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
4 
5 #ifndef __I_CURSOR_CONTROL_H_INCLUDED__
6 #define __I_CURSOR_CONTROL_H_INCLUDED__
7 
8 #include "IReferenceCounted.h"
9 #include "position2d.h"
10 #include "rect.h"
11 
12 namespace irr
13 {
14 namespace gui
15 {
16 
17  class IGUISpriteBank;
18 
21  {
22  // Following cursors might be system specific, or might use an Irrlicht icon-set. No guarantees so far.
23  ECI_NORMAL, // arrow
24  ECI_CROSS, // Crosshair
25  ECI_HAND, // Hand
26  ECI_HELP, // Arrow and question mark
27  ECI_IBEAM, // typical text-selection cursor
28  ECI_NO, // should not click icon
29  ECI_WAIT, // hourclass
30  ECI_SIZEALL, // arrow in all directions
31  ECI_SIZENESW, // resizes in direction north-east or south-west
32  ECI_SIZENWSE, // resizes in direction north-west or south-east
33  ECI_SIZENS, // resizes in direction north or south
34  ECI_SIZEWE, // resizes in direction west or east
35  ECI_UP, // up-arrow
36 
37  // Implementer note: Should we add system specific cursors, which use guaranteed the system icons,
38  // then I would recommend using a naming scheme like ECI_W32_CROSS, ECI_X11_CROSSHAIR and adding those
39  // additionally.
40 
41  ECI_COUNT // maximal of defined cursors. Note that higher values can be created at runtime
42  };
43 
45  const c8* const GUICursorIconNames[ECI_COUNT+1] =
46  {
47  "normal",
48  "cross",
49  "hand",
50  "help",
51  "ibeam",
52  "no",
53  "wait",
54  "sizeall",
55  "sizenesw",
56  "sizenwse",
57  "sizens",
58  "sizewe",
59  "sizeup",
60  0
61  };
62 
65  {
67  : SpriteBank(0), SpriteId(-1)
68  {
69  }
70 
71  SCursorSprite( gui::IGUISpriteBank * spriteBank, s32 spriteId, const core::position2d<s32> &hotspot=(core::position2d<s32>(0,0)) )
72  : SpriteBank(spriteBank), SpriteId(spriteId), HotSpot(hotspot)
73  {
74  }
75 
78  core::position2d<s32> HotSpot;
79  };
80 
83  {
85  ECPB_NONE = 0,
86 
88 
94  };
95 
97  class ICursorControl : public virtual IReferenceCounted
98  {
99  public:
100 
102 
104  virtual void setVisible(bool visible) = 0;
105 
107 
108  virtual bool isVisible() const = 0;
109 
111 
116  virtual void setPosition(const core::position2d<f32> &pos) = 0;
117 
119 
125  virtual void setPosition(f32 x, f32 y) = 0;
126 
128 
129  virtual void setPosition(const core::position2d<s32> &pos) = 0;
130 
132 
134  virtual void setPosition(s32 x, s32 y) = 0;
135 
137 
142  virtual const core::position2d<s32>& getPosition(bool updateCursor=true) = 0;
143 
145 
153  virtual core::position2d<f32> getRelativePosition(bool updateCursor=true) = 0;
154 
156 
161  virtual void setReferenceRect(core::rect<s32>* rect=0) = 0;
162 
163 
165 
166  virtual void setActiveIcon(ECURSOR_ICON iconId) {}
167 
169  virtual ECURSOR_ICON getActiveIcon() const { return gui::ECI_NORMAL; }
170 
172 
173  virtual ECURSOR_ICON addIcon(const gui::SCursorSprite& icon) { return gui::ECI_NORMAL; }
174 
176 
180  virtual void changeIcon(ECURSOR_ICON iconId, const gui::SCursorSprite& sprite) {}
181 
184 
187 
189 
192  };
193 
194 
195 } // end namespace gui
196 } // end namespace irr
197 
198 #endif
199 
dimension2d< s32 > dimension2di
Typedef for an integer dimension.
Definition: dimension2d.h:217
virtual ECURSOR_PLATFORM_BEHAVIOR getPlatformBehavior() const
Return platform specific behavior.
Sprite bank interface.
float f32
32 bit floating point variable.
Definition: irrTypes.h:108
char c8
8 bit character variable.
Definition: irrTypes.h:35
virtual void setReferenceRect(core::rect< s32 > *rect=0)=0
Sets an absolute reference rect for setting and retrieving the cursor position.
virtual ECURSOR_ICON addIcon(const gui::SCursorSprite &icon)
Add a custom sprite as cursor icon.
virtual bool isVisible() const =0
Returns if the cursor is currently visible.
structure used to set sprites as cursors.
Everything in the Irrlicht Engine can be found in this namespace.
Definition: CARSADPad.h:6
virtual void changeIcon(ECURSOR_ICON iconId, const gui::SCursorSprite &sprite)
replace a cursor icon.
Specifies a 2 dimensional size.
Definition: dimension2d.h:20
virtual const core::position2d< s32 > & getPosition(bool updateCursor=true)=0
Returns the current position of the mouse cursor.
ECURSOR_ICON
Default icons for cursors.
virtual void setActiveIcon(ECURSOR_ICON iconId)
Sets the active cursor icon.
signed int s32
32 bit signed variable.
Definition: irrTypes.h:70
IGUISpriteBank * SpriteBank
virtual void setPosition(const core::position2d< f32 > &pos)=0
Sets the new position of the cursor.
virtual ECURSOR_ICON getActiveIcon() const
Gets the currently active icon.
Interface to manipulate the mouse cursor.
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
default - no platform specific behavior
virtual core::position2d< f32 > getRelativePosition(bool updateCursor=true)=0
Returns the current position of the mouse cursor.
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
virtual core::dimension2di getSupportedIconSize() const
Return a system-specific size which is supported for cursors. Larger icons will fail,...
virtual void setVisible(bool visible)=0
Changes the visible state of the mouse cursor.
const c8 *const GUICursorIconNames[ECI_COUNT+1]
Names for ECURSOR_ICON.
Base class of most objects of the Irrlicht Engine.
SCursorSprite(gui::IGUISpriteBank *spriteBank, s32 spriteId, const core::position2d< s32 > &hotspot=(core::position2d< s32 >(0, 0)))
core::position2d< s32 > HotSpot
On X11 try caching cursor updates as XQueryPointer calls can be expensive.
ECURSOR_PLATFORM_BEHAVIOR
platform specific behavior flags for the cursor
virtual void setPlatformBehavior(ECURSOR_PLATFORM_BEHAVIOR behavior)
Set platform specific behavior flags.