Irrlicht 3D Engine
 
Loading...
Searching...
No Matches
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
12namespace irr
13{
14namespace 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
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
79 };
80
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
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
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
Base class of most objects of the Irrlicht Engine.
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.h:22
Interface to manipulate the mouse cursor.
virtual core::dimension2di getSupportedIconSize() const
Return a system-specific size which is supported for cursors. Larger icons will fail,...
virtual ECURSOR_ICON addIcon(const gui::SCursorSprite &icon)
Add a custom sprite as cursor icon.
virtual void setReferenceRect(core::rect< s32 > *rect=0)=0
Sets an absolute reference rect for setting and retrieving the cursor position.
virtual void setPosition(s32 x, s32 y)=0
Sets the new position of the cursor.
virtual void changeIcon(ECURSOR_ICON iconId, const gui::SCursorSprite &sprite)
replace a cursor icon.
virtual void setPosition(const core::position2d< s32 > &pos)=0
Sets the new position of the cursor.
virtual void setPosition(const core::position2d< f32 > &pos)=0
Sets the new position of the cursor.
virtual ECURSOR_PLATFORM_BEHAVIOR getPlatformBehavior() const
Return platform specific behavior.
virtual const core::position2d< s32 > & getPosition()=0
Returns the current position of the mouse cursor.
virtual void setVisible(bool visible)=0
Changes the visible state of the mouse cursor.
virtual void setPlatformBehavior(ECURSOR_PLATFORM_BEHAVIOR behavior)
Set platform specific behavior flags.
virtual void setPosition(f32 x, f32 y)=0
Sets the new position of the cursor.
virtual bool isVisible() const =0
Returns if the cursor is currently visible.
virtual ECURSOR_ICON getActiveIcon() const
Gets the currently active icon.
virtual void setActiveIcon(ECURSOR_ICON iconId)
Sets the active cursor icon.
virtual core::position2d< f32 > getRelativePosition()=0
Returns the current position of the mouse cursor.
Sprite bank interface.
dimension2d< s32 > dimension2di
Typedef for an integer dimension.
const c8 *const GUICursorIconNames[ECI_COUNT+1]
Names for ECURSOR_ICON.
ECURSOR_PLATFORM_BEHAVIOR
platform specific behavior flags for the cursor
@ ECPB_X11_CACHE_UPDATES
On X11 try caching cursor updates as XQueryPointer calls can be expensive.
@ ECPB_NONE
default - no platform specific behavior
ECURSOR_ICON
Default icons for cursors.
Everything in the Irrlicht Engine can be found in this namespace.
Definition aabbox3d.h:13
float f32
32 bit floating point variable.
Definition irrTypes.h:104
char c8
8 bit character variable.
Definition irrTypes.h:31
signed int s32
32 bit signed variable.
Definition irrTypes.h:66
structure used to set sprites as cursors.
SCursorSprite(gui::IGUISpriteBank *spriteBank, s32 spriteId, const core::position2d< s32 > &hotspot=(core::position2d< s32 >(0, 0)))
IGUISpriteBank * SpriteBank
core::position2d< s32 > HotSpot