Irrlicht 3D Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
139  virtual const core::position2d<s32>& getPosition() = 0;
140 
142 
146  virtual core::position2d<f32> getRelativePosition() = 0;
147 
149 
154  virtual void setReferenceRect(core::rect<s32>* rect=0) = 0;
155 
156 
158 
159  virtual void setActiveIcon(ECURSOR_ICON iconId) {}
160 
162  virtual ECURSOR_ICON getActiveIcon() const { return gui::ECI_NORMAL; }
163 
165 
166  virtual ECURSOR_ICON addIcon(const gui::SCursorSprite& icon) { return gui::ECI_NORMAL; }
167 
169 
173  virtual void changeIcon(ECURSOR_ICON iconId, const gui::SCursorSprite& sprite) {}
174 
177 
180 
182 
185  };
186 
187 
188 } // end namespace gui
189 } // end namespace irr
190 
191 #endif
192