Irrlicht 3D Engine
ICursorControl.h
Go to the documentation of this file.
00001 // Copyright (C) 2002-2012 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         IGUISpriteBank * SpriteBank;
00077         s32 SpriteId;
00078         core::position2d<s32> HotSpot;
00079     };
00080 
00082     enum ECURSOR_PLATFORM_BEHAVIOR
00083     {
00085         ECPB_NONE = 0,
00086 
00088 
00093         ECPB_X11_CACHE_UPDATES = 1
00094     };
00095 
00097     class ICursorControl : public virtual IReferenceCounted
00098     {
00099     public:
00100 
00102 
00104         virtual void setVisible(bool visible) = 0;
00105 
00107 
00108         virtual bool isVisible() const = 0;
00109 
00111 
00116         virtual void setPosition(const core::position2d<f32> &pos) = 0;
00117 
00119 
00125         virtual void setPosition(f32 x, f32 y) = 0;
00126 
00128 
00129         virtual void setPosition(const core::position2d<s32> &pos) = 0;
00130 
00132 
00134         virtual void setPosition(s32 x, s32 y) = 0;
00135 
00137 
00139         virtual const core::position2d<s32>& getPosition() = 0;
00140 
00142 
00146         virtual core::position2d<f32> getRelativePosition() = 0;
00147 
00149 
00154         virtual void setReferenceRect(core::rect<s32>* rect=0) = 0;
00155 
00156 
00158 
00159         virtual void setActiveIcon(ECURSOR_ICON iconId) {}
00160 
00162         virtual ECURSOR_ICON getActiveIcon() const { return gui::ECI_NORMAL; }
00163 
00165 
00166         virtual ECURSOR_ICON addIcon(const gui::SCursorSprite& icon) { return gui::ECI_NORMAL; }
00167 
00169 
00173         virtual void changeIcon(ECURSOR_ICON iconId, const gui::SCursorSprite& sprite) {}
00174 
00176         virtual core::dimension2di getSupportedIconSize() const { return core::dimension2di(0,0); }
00177 
00179         virtual void setPlatformBehavior(ECURSOR_PLATFORM_BEHAVIOR behavior) {}
00180 
00182 
00184         virtual ECURSOR_PLATFORM_BEHAVIOR getPlatformBehavior() const { return ECPB_NONE; }
00185     };
00186 
00187 
00188 } // end namespace gui
00189 } // end namespace irr
00190 
00191 #endif
00192