FIFE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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...
 

Protected Member Functions

void setNativeCursor (uint32_t cursor_id)
 Sets the cursor to a native type. 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 resource ID specific to the running platform. 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
 

Detailed Description

Cursor class manages mouse cursor handling.

Definition at line 84 of file cursor.h.

Constructor & Destructor Documentation

FIFE::Cursor::Cursor ( RenderBackend renderbackend)

Constructor.

Definition at line 79 of file cursor.cpp.

References m_cursor_id, m_timemanager, and set().

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

Destructor.

Definition at line 92 of file cursor.h.

References invalidate().

Member Function Documentation

AnimationPtr FIFE::Cursor::getAnimation ( )
inline

Gets the current mouse animation.

Definition at line 149 of file cursor.h.

References m_cursor_animation.

AnimationPtr FIFE::Cursor::getDragAnimation ( )
inline

Gets the current mouse drag animation.

Definition at line 161 of file cursor.h.

References m_cursor_drag_animation.

ImagePtr FIFE::Cursor::getDragImage ( )
inline

Gets the current mouse drag image.

Definition at line 157 of file cursor.h.

References m_cursor_drag_image.

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

Gets the current mouse cursor type.

Definition at line 153 of file cursor.h.

References m_drag_type.

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

Gets the current mouse cursor handle.

Definition at line 141 of file cursor.h.

References m_cursor_id.

ImagePtr FIFE::Cursor::getImage ( )
inline

Gets the current mouse image.

Definition at line 145 of file cursor.h.

References m_cursor_image.

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 resource ID specific to the running platform.

If no match is found, cursor_id is returned.

Parameters
cursor_idOne of the values in NativeCursor

Definition at line 246 of file cursor.cpp.

References FIFE::NC_APPSTARTING, FIFE::NC_ARROW, FIFE::NC_CROSS, FIFE::NC_HAND, FIFE::NC_HELP, FIFE::NC_IBEAM, FIFE::NC_NO, FIFE::NC_RESIZEALL, FIFE::NC_RESIZEE, FIFE::NC_RESIZEN, FIFE::NC_RESIZENE, FIFE::NC_RESIZENW, FIFE::NC_RESIZES, FIFE::NC_RESIZESE, FIFE::NC_RESIZESW, FIFE::NC_RESIZEW, FIFE::NC_UPARROW, and FIFE::NC_WAIT.

Referenced by 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 179 of file cursor.cpp.

References m_mx, and m_my.

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

Gets the current mouse cursor type.

Definition at line 137 of file cursor.h.

References m_cursor_type.

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

Gets the current mouse x position.

Definition at line 165 of file cursor.h.

References m_mx.

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

Gets the current mouse y position.

Definition at line 169 of file cursor.h.

References m_my.

void FIFE::Cursor::invalidate ( )

Definition at line 184 of file cursor.cpp.

References m_invalidated, and m_native_cursor.

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

+ Here is the caller graph for this function:

void FIFE::Cursor::resetDrag ( )

Resets the cursor drag type to CURSOR_NONE.

Definition at line 162 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().

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 97 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 Cursor(), and draw().

+ 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 109 of file cursor.cpp.

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

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 123 of file cursor.cpp.

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

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 138 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().

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 149 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_idResource id to native cursor, or one of the values in NativeCursor

Definition at line 334 of file cursor.cpp.

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

Referenced by set().

+ Here is the caller graph for this function:

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

Set the mouse position.

Parameters
x,y,:The new position in screen coordinates

Definition at line 173 of file cursor.cpp.

References m_mx, and m_my.

Member Data Documentation

uint32_t FIFE::Cursor::m_animtime
private

Definition at line 210 of file cursor.h.

Referenced by draw(), and set().

AnimationPtr FIFE::Cursor::m_cursor_animation
private

Definition at line 205 of file cursor.h.

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

AnimationPtr FIFE::Cursor::m_cursor_drag_animation
private

Definition at line 206 of file cursor.h.

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

ImagePtr FIFE::Cursor::m_cursor_drag_image
private

Definition at line 203 of file cursor.h.

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

uint32_t FIFE::Cursor::m_cursor_id
private

Definition at line 196 of file cursor.h.

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

ImagePtr FIFE::Cursor::m_cursor_image
private

Definition at line 202 of file cursor.h.

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

MouseCursorType FIFE::Cursor::m_cursor_type
private

Definition at line 197 of file cursor.h.

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

uint32_t FIFE::Cursor::m_drag_animtime
private

Definition at line 211 of file cursor.h.

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

int32_t FIFE::Cursor::m_drag_offset_x
private

Definition at line 213 of file cursor.h.

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

int32_t FIFE::Cursor::m_drag_offset_y
private

Definition at line 214 of file cursor.h.

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

MouseCursorType FIFE::Cursor::m_drag_type
private

Definition at line 198 of file cursor.h.

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

bool FIFE::Cursor::m_invalidated
private

Definition at line 219 of file cursor.h.

Referenced by draw(), and invalidate().

int32_t FIFE::Cursor::m_mx
private

Definition at line 215 of file cursor.h.

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

int32_t FIFE::Cursor::m_my
private

Definition at line 216 of file cursor.h.

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

SDL_Cursor* FIFE::Cursor::m_native_cursor
private

Definition at line 200 of file cursor.h.

Referenced by invalidate(), and setNativeCursor().

RenderBackend* FIFE::Cursor::m_renderbackend
private

Definition at line 208 of file cursor.h.

Referenced by draw().

TimeManager* FIFE::Cursor::m_timemanager
private

Definition at line 217 of file cursor.h.

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


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