FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
FIFE::Cursor Class Reference

Cursor class manages mouse cursor handling. More...

#include <cursor.h>

+ Collaboration diagram for FIFE::Cursor:

Public Member Functions

 Cursor (RenderBackend *renderbackend)
 Constructor. More...
 
virtual ~Cursor ()
 Destructor. More...
 
void invalidate ()
 
virtual void draw ()
 draws cursor on screen More...
 
void set (uint32_t cursor_id=0)
 Sets the current mouse cursor. More...
 
void set (ImagePtr image)
 Sets the current mouse cursor type to image. More...
 
void set (AnimationPtr anim)
 Sets the current mouse cursor type to animation. More...
 
void setDrag (ImagePtr image, int32_t drag_offset_x=0, int32_t drag_offset_y=0)
 Sets the current drag image cursor. More...
 
void setDrag (AnimationPtr anim, int32_t drag_offset_x=0, int32_t drag_offset_y=0)
 Sets the current drag animated cursor. More...
 
void resetDrag ()
 Resets the cursor drag type to CURSOR_NONE. More...
 
MouseCursorType getType () const
 Gets the current mouse cursor type. More...
 
uint32_t getId () const
 Gets the current mouse cursor handle. More...
 
ImagePtr getImage ()
 Gets the current mouse image. More...
 
AnimationPtr getAnimation ()
 Gets the current mouse animation. More...
 
MouseCursorType getDragType () const
 Gets the current mouse cursor type. More...
 
ImagePtr getDragImage ()
 Gets the current mouse drag image. More...
 
AnimationPtr getDragAnimation ()
 Gets the current mouse drag animation. More...
 
uint32_t getX () const
 Gets the current mouse x position. More...
 
uint32_t getY () const
 Gets the current mouse y position. More...
 
void setPosition (uint32_t x, uint32_t y)
 Set the mouse position. More...
 
void getPosition (int32_t *x, int32_t *y)
 Get the current mouse position. More...
 
void setNativeImageCursorEnabled (bool native_image_cursor_enabled)
 Enables or disables the native image cursor feature. More...
 
bool isNativeImageCursorEnabled () const
 Returns whether cursors set to an image or an animation are drawn natively. More...
 

Protected Member Functions

void setNativeCursor (uint32_t cursor_id)
 Sets the cursor to a native type. More...
 
bool setNativeImageCursor (ImagePtr image)
 Sets the SDL cursor to the specified image. More...
 
uint32_t getNativeId (uint32_t cursor_id)
 To get some consistancy between platforms, this function checks if cursor_id matches any of the values in NativeCursor, and returns the SDL_SystemCursor. More...
 

Private Attributes

uint32_t m_cursor_id
 
MouseCursorType m_cursor_type
 
MouseCursorType m_drag_type
 
SDL_Cursor * m_native_cursor
 
ImagePtr m_cursor_image
 
ImagePtr m_cursor_drag_image
 
AnimationPtr m_cursor_animation
 
AnimationPtr m_cursor_drag_animation
 
RenderBackendm_renderbackend
 
uint32_t m_animtime
 
uint32_t m_drag_animtime
 
int32_t m_drag_offset_x
 
int32_t m_drag_offset_y
 
int32_t m_mx
 
int32_t m_my
 
TimeManagerm_timemanager
 
bool m_invalidated
 
bool m_native_image_cursor_enabled
 
ImagePtr m_native_cursor_image
 

Detailed Description

Cursor class manages mouse cursor handling.

Definition at line 73 of file cursor.h.

Constructor & Destructor Documentation

FIFE::Cursor::Cursor ( RenderBackend renderbackend)

Constructor.

Definition at line 47 of file cursor.cpp.

References m_cursor_id, and m_timemanager.

virtual FIFE::Cursor::~Cursor ( )
inlinevirtual

Destructor.

Definition at line 81 of file cursor.h.

References draw(), invalidate(), resetDrag(), and setDrag().

Member Function Documentation

AnimationPtr FIFE::Cursor::getAnimation ( )
inline

Gets the current mouse animation.

Definition at line 138 of file cursor.h.

References m_cursor_animation.

Referenced by fcn::ResizableWindow::saveCursor().

+ Here is the caller graph for this function:

AnimationPtr FIFE::Cursor::getDragAnimation ( )
inline

Gets the current mouse drag animation.

Definition at line 150 of file cursor.h.

References m_cursor_drag_animation.

ImagePtr FIFE::Cursor::getDragImage ( )
inline

Gets the current mouse drag image.

Definition at line 146 of file cursor.h.

References m_cursor_drag_image.

MouseCursorType FIFE::Cursor::getDragType ( ) const
inline

Gets the current mouse cursor type.

Definition at line 142 of file cursor.h.

References m_drag_type.

uint32_t FIFE::Cursor::getId ( ) const
inline

Gets the current mouse cursor handle.

Definition at line 130 of file cursor.h.

References m_cursor_id.

Referenced by fcn::ResizableWindow::saveCursor().

+ Here is the caller graph for this function:

ImagePtr FIFE::Cursor::getImage ( )
inline

Gets the current mouse image.

Definition at line 134 of file cursor.h.

References m_cursor_image.

Referenced by fcn::ResizableWindow::saveCursor().

+ Here is the caller graph for this function:

uint32_t FIFE::Cursor::getNativeId ( uint32_t  cursor_id)
protected

To get some consistancy between platforms, this function checks if cursor_id matches any of the values in NativeCursor, and returns the SDL_SystemCursor.

If no match is found, cursor_id is returned.

Parameters
cursor_idOne of the values in NativeCursor

Definition at line 242 of file cursor.cpp.

References FIFE::NC_ARROW, FIFE::NC_CROSS, FIFE::NC_HAND, FIFE::NC_IBEAM, FIFE::NC_NO, FIFE::NC_RESIZEALL, FIFE::NC_RESIZENESW, FIFE::NC_RESIZENS, FIFE::NC_RESIZENWSE, FIFE::NC_RESIZEWE, FIFE::NC_WAIT, and FIFE::NC_WAITARROW.

Referenced by getY(), and setNativeCursor().

+ Here is the caller graph for this function:

void FIFE::Cursor::getPosition ( int32_t *  x,
int32_t *  y 
)

Get the current mouse position.

Definition at line 164 of file cursor.cpp.

References m_mx, and m_my.

Referenced by getY().

+ Here is the caller graph for this function:

MouseCursorType FIFE::Cursor::getType ( ) const
inline

Gets the current mouse cursor type.

Definition at line 126 of file cursor.h.

References m_cursor_type.

Referenced by fcn::ResizableWindow::saveCursor().

+ Here is the caller graph for this function:

uint32_t FIFE::Cursor::getX ( ) const
inline

Gets the current mouse x position.

Definition at line 154 of file cursor.h.

References m_mx.

uint32_t FIFE::Cursor::getY ( ) const
inline
void FIFE::Cursor::invalidate ( )

Definition at line 169 of file cursor.cpp.

References m_invalidated, m_native_cursor, m_native_cursor_image, and FIFE::SharedPtr< T >::reset().

Referenced by FIFE::Engine::changeScreenMode(), and ~Cursor().

+ Here is the caller graph for this function:

bool FIFE::Cursor::isNativeImageCursorEnabled ( ) const

Returns whether cursors set to an image or an animation are drawn natively.

See also
setNativeImageCursorEnabled()

Definition at line 341 of file cursor.cpp.

References m_native_image_cursor_enabled.

Referenced by getY().

+ Here is the caller graph for this function:

void FIFE::Cursor::resetDrag ( )

Resets the cursor drag type to CURSOR_NONE.

Definition at line 147 of file cursor.cpp.

References FIFE::CURSOR_NONE, m_cursor_drag_animation, m_cursor_drag_image, m_drag_animtime, m_drag_offset_x, m_drag_offset_y, m_drag_type, and FIFE::SharedPtr< T >::reset().

Referenced by ~Cursor().

+ Here is the caller graph for this function:

void FIFE::Cursor::set ( uint32_t  cursor_id = 0)

Sets the current mouse cursor.

Parameters
cursor_idFor native cursors, this is the resource id to native cursor, or one of the values in NativeCursor

Definition at line 66 of file cursor.cpp.

References FIFE::CURSOR_NATIVE, m_cursor_animation, m_cursor_image, m_cursor_type, FIFE::SharedPtr< T >::reset(), and setNativeCursor().

Referenced by fcn::ResizableWindow::mouseMoved(), and fcn::ResizableWindow::restoreCursor().

+ Here is the caller graph for this function:

void FIFE::Cursor::set ( ImagePtr  image)

Sets the current mouse cursor type to image.

Parameters
imageImagePtr to a image used for the cursor

Definition at line 78 of file cursor.cpp.

References FIFE::CURSOR_IMAGE, m_cursor_animation, m_cursor_id, m_cursor_image, m_cursor_type, m_native_image_cursor_enabled, FIFE::NC_ARROW, FIFE::SharedPtr< T >::reset(), and setNativeImageCursor().

void FIFE::Cursor::set ( AnimationPtr  anim)

Sets the current mouse cursor type to animation.

Parameters
animAnimationPtr to a loaded animation used for the cursor

Definition at line 100 of file cursor.cpp.

References FIFE::CURSOR_ANIMATION, FIFE::Animation::getFrameByTimestamp(), FIFE::TimeManager::getTime(), m_animtime, m_cursor_animation, m_cursor_id, m_cursor_image, m_cursor_type, m_native_image_cursor_enabled, m_timemanager, FIFE::NC_ARROW, FIFE::SharedPtr< T >::reset(), and setNativeImageCursor().

void FIFE::Cursor::setDrag ( ImagePtr  image,
int32_t  drag_offset_x = 0,
int32_t  drag_offset_y = 0 
)

Sets the current drag image cursor.

Parameters
imageImagePtr to a image used for the drag
drag_offset_xX Offset to display image when dragging.
drag_offset_yY Offset to display image when dragging.
Note
to reset the cursors drag call cursor.setDrag(Cursor::CURSOR_NONE, 0, 0)

Definition at line 123 of file cursor.cpp.

References FIFE::CURSOR_IMAGE, m_cursor_drag_animation, m_cursor_drag_image, m_drag_offset_x, m_drag_offset_y, m_drag_type, and FIFE::SharedPtr< T >::reset().

Referenced by ~Cursor().

+ Here is the caller graph for this function:

void FIFE::Cursor::setDrag ( AnimationPtr  anim,
int32_t  drag_offset_x = 0,
int32_t  drag_offset_y = 0 
)

Sets the current drag animated cursor.

Parameters
animAnimationPtr to a loaded animation used for the drag
drag_offset_xX Offset to display animation when dragging.
drag_offset_yY Offset to display animation when dragging.
Note
to reset the cursors drag call cursor.setDrag(Cursor::CURSOR_NONE, 0, 0)

Definition at line 134 of file cursor.cpp.

References FIFE::CURSOR_ANIMATION, FIFE::TimeManager::getTime(), m_cursor_drag_animation, m_cursor_drag_image, m_drag_animtime, m_drag_offset_x, m_drag_offset_y, m_drag_type, m_timemanager, and FIFE::SharedPtr< T >::reset().

void FIFE::Cursor::setNativeCursor ( uint32_t  cursor_id)
protected

Sets the cursor to a native type.

Parameters
cursor_idOne of the values in NativeCursor

Definition at line 272 of file cursor.cpp.

References FIFE::_log, FL_WARN, getNativeId(), and m_native_cursor.

Referenced by getY(), and set().

+ Here is the caller graph for this function:

bool FIFE::Cursor::setNativeImageCursor ( ImagePtr  image)
protected
void FIFE::Cursor::setNativeImageCursorEnabled ( bool  native_image_cursor_enabled)

Enables or disables the native image cursor feature.

If enabled, cursors set to an image or an animation will be set using SDL and drawn by the native platform; otherwise they will be drawn by FIFE. This setting has no effect on NativeCursor types which are always native and on the drag cursor which is always drawn by FIFE.

Definition at line 329 of file cursor.cpp.

References FIFE::CURSOR_ANIMATION, FIFE::CURSOR_IMAGE, m_cursor_animation, m_cursor_image, m_cursor_type, and m_native_image_cursor_enabled.

Referenced by getY(), FIFE::Engine::init(), and setNativeImageCursor().

+ Here is the caller graph for this function:

void FIFE::Cursor::setPosition ( uint32_t  x,
uint32_t  y 
)

Set the mouse position.

Parameters
x,yThe new position in screen coordinates

Definition at line 158 of file cursor.cpp.

References FIFE::DynamicSingleton< RenderBackend >::instance(), m_mx, and m_my.

Referenced by getY().

+ Here is the caller graph for this function:

Member Data Documentation

uint32_t FIFE::Cursor::m_animtime
private

Definition at line 218 of file cursor.h.

Referenced by draw(), and set().

AnimationPtr FIFE::Cursor::m_cursor_animation
private

Definition at line 213 of file cursor.h.

Referenced by draw(), getAnimation(), set(), and setNativeImageCursorEnabled().

AnimationPtr FIFE::Cursor::m_cursor_drag_animation
private

Definition at line 214 of file cursor.h.

Referenced by draw(), getDragAnimation(), resetDrag(), and setDrag().

ImagePtr FIFE::Cursor::m_cursor_drag_image
private

Definition at line 211 of file cursor.h.

Referenced by draw(), getDragImage(), resetDrag(), and setDrag().

uint32_t FIFE::Cursor::m_cursor_id
private

Definition at line 204 of file cursor.h.

Referenced by Cursor(), draw(), getId(), and set().

ImagePtr FIFE::Cursor::m_cursor_image
private

Definition at line 210 of file cursor.h.

Referenced by draw(), getImage(), set(), and setNativeImageCursorEnabled().

MouseCursorType FIFE::Cursor::m_cursor_type
private

Definition at line 205 of file cursor.h.

Referenced by draw(), getType(), set(), and setNativeImageCursorEnabled().

uint32_t FIFE::Cursor::m_drag_animtime
private

Definition at line 219 of file cursor.h.

Referenced by draw(), resetDrag(), and setDrag().

int32_t FIFE::Cursor::m_drag_offset_x
private

Definition at line 221 of file cursor.h.

Referenced by draw(), resetDrag(), and setDrag().

int32_t FIFE::Cursor::m_drag_offset_y
private

Definition at line 222 of file cursor.h.

Referenced by draw(), resetDrag(), and setDrag().

MouseCursorType FIFE::Cursor::m_drag_type
private

Definition at line 206 of file cursor.h.

Referenced by draw(), getDragType(), resetDrag(), and setDrag().

bool FIFE::Cursor::m_invalidated
private

Definition at line 227 of file cursor.h.

Referenced by draw(), and invalidate().

int32_t FIFE::Cursor::m_mx
private

Definition at line 223 of file cursor.h.

Referenced by draw(), getPosition(), getX(), and setPosition().

int32_t FIFE::Cursor::m_my
private

Definition at line 224 of file cursor.h.

Referenced by draw(), getPosition(), getY(), and setPosition().

SDL_Cursor* FIFE::Cursor::m_native_cursor
private

Definition at line 208 of file cursor.h.

Referenced by invalidate(), setNativeCursor(), and setNativeImageCursor().

ImagePtr FIFE::Cursor::m_native_cursor_image
private

Definition at line 229 of file cursor.h.

Referenced by invalidate(), and setNativeImageCursor().

bool FIFE::Cursor::m_native_image_cursor_enabled
private

Definition at line 228 of file cursor.h.

Referenced by draw(), isNativeImageCursorEnabled(), set(), and setNativeImageCursorEnabled().

RenderBackend* FIFE::Cursor::m_renderbackend
private

Definition at line 216 of file cursor.h.

Referenced by draw().

TimeManager* FIFE::Cursor::m_timemanager
private

Definition at line 225 of file cursor.h.

Referenced by Cursor(), draw(), set(), and setDrag().


The documentation for this class was generated from the following files: