IrrlichtEngine
ICursorControl.h
Go to the documentation of this file.
00001 // Copyright (C) 2002-2011 Nikolaus Gebhardt
00002 // This file is part of the "Irrlicht Engine".
00003 // For conditions of distribution and use, see copyright notice in irrlicht.h
00004 
00005 #ifndef __I_CURSOR_CONTROL_H_INCLUDED__
00006 #define __I_CURSOR_CONTROL_H_INCLUDED__
00007 
00008 #include "IReferenceCounted.h"
00009 #include "position2d.h"
00010 #include "rect.h"
00011 
00012 namespace irr
00013 {
00014 namespace gui
00015 {
00016 
00017         class IGUISpriteBank;
00018 
00020         enum ECURSOR_ICON
00021         {
00022                 // Following cursors might be system specific, or might use an Irrlicht icon-set. No guarantees so far.
00023                 ECI_NORMAL,             // arrow
00024                 ECI_CROSS,              // Crosshair
00025                 ECI_HAND,               // Hand
00026                 ECI_HELP,               // Arrow and question mark
00027                 ECI_IBEAM,              // typical text-selection cursor
00028                 ECI_NO,                 // should not click icon
00029                 ECI_WAIT,               // hourclass
00030                 ECI_SIZEALL,    // arrow in all directions
00031                 ECI_SIZENESW,   // resizes in direction north-east or south-west
00032                 ECI_SIZENWSE,   // resizes in direction north-west or south-east
00033                 ECI_SIZENS,     // resizes in direction north or south
00034                 ECI_SIZEWE,     // resizes in direction west or east
00035                 ECI_UP,                 // up-arrow
00036 
00037                 // Implementer note: Should we add system specific cursors, which use guaranteed the system icons,
00038                 // then I would recommend using a naming scheme like ECI_W32_CROSS, ECI_X11_CROSSHAIR and adding those
00039                 // additionally.
00040 
00041                 ECI_COUNT               // maximal of defined cursors. Note that higher values can be created at runtime
00042         };
00043 
00045         const c8* const GUICursorIconNames[ECI_COUNT+1] =
00046         {
00047                 "normal",
00048                 "cross",
00049                 "hand",
00050                 "help",
00051                 "ibeam",
00052                 "no",
00053                 "wait",
00054                 "sizeall",
00055                 "sizenesw",
00056                 "sizenwse",
00057                 "sizens",
00058                 "sizewe",
00059                 "sizeup",
00060                 0
00061         };
00062 
00064         struct SCursorSprite
00065         {
00066                 SCursorSprite()
00067                 : SpriteBank(0), SpriteId(-1)
00068                 {
00069                 }
00070 
00071                 SCursorSprite( gui::IGUISpriteBank * spriteBank, s32 spriteId, const core::position2d<s32> &hotspot=core::position2d<s32>(0,0) )
00072                 : SpriteBank(spriteBank), SpriteId(spriteId), HotSpot(hotspot)
00073                 {
00074                 }
00075 
00076                 gui::IGUISpriteBank * SpriteBank;
00077                 s32 SpriteId;
00078                 core::position2d<s32> HotSpot;
00079         };
00080 
00082         class ICursorControl : public virtual IReferenceCounted
00083         {
00084         public:
00085 
00087 
00089                 virtual void setVisible(bool visible) = 0;
00090 
00092 
00093                 virtual bool isVisible() const = 0;
00094 
00096 
00101                 virtual void setPosition(const core::position2d<f32> &pos) = 0;
00102 
00104 
00110                 virtual void setPosition(f32 x, f32 y) = 0;
00111 
00113 
00114                 virtual void setPosition(const core::position2d<s32> &pos) = 0;
00115 
00117 
00119                 virtual void setPosition(s32 x, s32 y) = 0;
00120 
00122 
00124                 virtual const core::position2d<s32>& getPosition() = 0;
00125 
00127 
00131                 virtual core::position2d<f32> getRelativePosition() = 0;
00132 
00134 
00139                 virtual void setReferenceRect(core::rect<s32>* rect=0) = 0;
00140 
00141 
00143 
00144                 virtual void setActiveIcon(ECURSOR_ICON iconId) {}
00145 
00147                 virtual ECURSOR_ICON getActiveIcon() const { return gui::ECI_NORMAL; }
00148 
00150 
00151                 virtual ECURSOR_ICON addIcon(const gui::SCursorSprite& icon) { return gui::ECI_NORMAL; }
00152 
00154 
00158                 virtual void changeIcon(ECURSOR_ICON iconId, const gui::SCursorSprite& sprite) {}
00159 
00161                 virtual core::dimension2di getSupportedIconSize() const { return core::dimension2di(0,0); }
00162         };
00163 
00164 
00165 } // end namespace gui
00166 } // end namespace irr
00167 
00168 #endif
00169