Jimcpp 2.1.0
Jimcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
ICursorControl.hpp
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 jimcpp/jimcpp.hpp
4
5#ifndef JPP_I_CURSOR_CONTROL_HPP_INCLUDED
6#define JPP_I_CURSOR_CONTROL_HPP_INCLUDED
7
8#include <jimcpp/core/engine/IReferenceCounted.hpp>
9#include <jimcpp/core/engine/position2d.hpp>
10#include <jimcpp/core/engine/rect.hpp>
11
12namespace jpp
13{
14namespace gui
15{
16
17 class IGUISpriteBank;
18
21 {
22 // Following cursors might be system specific, or might use an Jimcpp 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 {
66 public:
68 : SpriteBank(0), SpriteId(-1)
69 {
70 }
71
72 SCursorSprite( gui::IGUISpriteBank * spriteBank, s32 spriteId, const core::position2d<s32> &hotspot=(core::position2d<s32>(0,0)) )
73 : SpriteBank(spriteBank), SpriteId(spriteId), HotSpot(hotspot)
74 {
75 }
76
77 public:
78 IGUISpriteBank * SpriteBank;
79 s32 SpriteId;
81 };
82
97
99 class ICursorControl : public virtual IReferenceCounted
100 {
101 public:
102
104
106 virtual void setVisible(bool visible) = 0;
107
109
110 virtual bool isVisible() const = 0;
111
113
118 virtual void setPosition(const core::position2d<f32> &pos) = 0;
119
121
127 virtual void setPosition(f32 x, f32 y) = 0;
128
130
131 virtual void setPosition(const core::position2d<s32> &pos) = 0;
132
134
136 virtual void setPosition(s32 x, s32 y) = 0;
137
139
144 virtual const core::position2d<s32>& getPosition(bool updateCursor=true) = 0;
145
147
155 virtual core::position2d<f32> getRelativePosition(bool updateCursor=true) = 0;
156
158
163 virtual void setReferenceRect(core::rect<s32>* rect=0) = 0;
164
165
167
168 virtual void setActiveIcon(ECURSOR_ICON iconId) {}
169
171 virtual ECURSOR_ICON getActiveIcon() const { return gui::ECI_NORMAL; }
172
174
175 virtual ECURSOR_ICON addIcon(const gui::SCursorSprite& icon) { return gui::ECI_NORMAL; }
176
178
182 virtual void changeIcon(ECURSOR_ICON iconId, const gui::SCursorSprite& sprite) {}
183
186
189
191
194 };
195
196
197} // end namespace gui
198} // end namespace jpp
199
200#endif
Base class of most objects of the Jimcpp Engine.
Definition IReferenceCounted.hpp:46
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
Interface to manipulate the mouse cursor.
Definition ICursorControl.hpp:100
virtual bool isVisible() const =0
Returns if the cursor is currently visible.
virtual ECURSOR_PLATFORM_BEHAVIOR getPlatformBehavior() const
Return platform specific behavior.
Definition ICursorControl.hpp:193
virtual const core::position2d< s32 > & getPosition(bool updateCursor=true)=0
Returns the current position of the mouse cursor.
virtual void setPosition(f32 x, f32 y)=0
Sets the new position of the cursor.
virtual void setReferenceRect(core::rect< s32 > *rect=0)=0
Sets an absolute reference rect for setting and retrieving the cursor position.
virtual void setActiveIcon(ECURSOR_ICON iconId)
Sets the active cursor icon.
Definition ICursorControl.hpp:168
virtual void setPlatformBehavior(ECURSOR_PLATFORM_BEHAVIOR behavior)
Set platform specific behavior flags.
Definition ICursorControl.hpp:188
virtual void setVisible(bool visible)=0
Changes the visible state of the mouse cursor.
virtual void setPosition(const core::position2d< f32 > &pos)=0
Sets the new position of the cursor.
virtual core::dimension2di getSupportedIconSize() const
Return a system-specific size which is supported for cursors. Larger icons will fail,...
Definition ICursorControl.hpp:185
virtual ECURSOR_ICON getActiveIcon() const
Gets the currently active icon.
Definition ICursorControl.hpp:171
virtual ECURSOR_ICON addIcon(const gui::SCursorSprite &icon)
Add a custom sprite as cursor icon.
Definition ICursorControl.hpp:175
virtual void changeIcon(ECURSOR_ICON iconId, const gui::SCursorSprite &sprite)
replace a cursor icon.
Definition ICursorControl.hpp:182
virtual void setPosition(const core::position2d< s32 > &pos)=0
Sets the new position of the cursor.
virtual core::position2d< f32 > getRelativePosition(bool updateCursor=true)=0
Returns the current position of the mouse cursor.
virtual void setPosition(s32 x, s32 y)=0
Sets the new position of the cursor.
Sprite bank interface.
Definition IGUISpriteBank.hpp:71
class used to set sprites as cursors.
Definition ICursorControl.hpp:65
dimension2d< s32 > dimension2di
using type alias for an integer dimension.
Definition dimension2d.hpp:217
ECURSOR_PLATFORM_BEHAVIOR
platform specific behavior flags for the cursor
Definition ICursorControl.hpp:85
@ ECPB_NONE
default - no platform specific behavior
Definition ICursorControl.hpp:87
@ ECPB_X11_CACHE_UPDATES
On X11 try caching cursor updates as XQueryPointer calls can be expensive.
Definition ICursorControl.hpp:95
const c8 *const GUICursorIconNames[ECI_COUNT+1]
Names for ECURSOR_ICON.
Definition ICursorControl.hpp:45
ECURSOR_ICON
Default icons for cursors.
Definition ICursorControl.hpp:21
As of Jimcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11
signed int s32
32 bit signed variable.
Definition irrTypes.hpp:72
float f32
32 bit floating point variable.
Definition irrTypes.hpp:110
char c8
8 bit character variable.
Definition irrTypes.hpp:37

Jimcpp    @cppfx.xyz

K