CRM64Pro GDK v0.14.0
A free cross-platform game development kit built on top of SDL 3.0
Loading...
Searching...
No Matches
CRM64Pro::CursorMgr

Cursor Manager class. More...

Detailed Description

Cursor Manager class.

Public Member Functions

bool info (Sint32 iMode=0) override
 Request Cursor Manager information.
Sint32 create (const string &sName, Uint32 iVersion=10) override
 Create a new cursor.
bool close (Sint32 idCursor) override
 Close and destroy a cursor.
Sint32 getCount () const override
 Get number of loaded objects.
Sint32 setName (Sint32 idCur, const string &sName) override
 Change the object name.
Cursorget (Sint32 idCur)
 Get a pointer to the cursor using its handler.
Sint32 select (Sint32 idCur)
 Select a mouse cursor.
Sint32 getSelect () const
 Get selected mouse cursor.
bool show ()
 Make visible the selected mouse cursor.
bool hide ()
 Hide the mouse cursor.
Sint32 status () const
 Get the cursor status.
bool setPosition (float fX, float fY, Sint32 idScreen=0)
 Set the mouse cursor position.
float getX () const
 Get the mouse cursor X position.
float getY () const
 Get the mouse cursor Y position.
Sint32 getButtons () const
 Get the mouse buttons.
Sint32 getButtonsPrev () const
 Get the previous mouse buttons.
Sint32 getFocus () const
 Get the Screen id which currently has mouse focus.
Sint32 child (Sint32 idCur)
 Create a child cursor dependant on the provided one(the parent).
Sint32 load (const string &sCDCFile, const string &sName)
 Load a cursor stored in a CDC file.
Sint32 load (const Sint32 idCDC, const string &sName)
 Load a cursor stored in a CDC file.
Sint32 remove (Sint32 idCDC, const string &sName)
 Remove a cursor stored in a CDC file.
bool exist (Sint32 idCDC, const string &sName)
 Check if a cursor is stored in a CDC file.
bool exist (const string &sCDCFile, const string &sName)
 Check if a cursor is stored in a CDC file.

Member Function Documentation

◆ info()

bool CRM64Pro::CursorMgr::info ( Sint32 iMode = 0)
override

Request Cursor Manager information.

Writes information to the default log.

Parameters
iMode-1 to display only manager information. 0 (default) to display manager and all objects. Specific object ID to display manager and only that object.
Returns
true on success, or false on failure.

◆ create()

Sint32 CRM64Pro::CursorMgr::create ( const string & sName,
Uint32 iVersion = 10 )
override

Create a new cursor.

Creates an empty cursor (no image). Use Cursor::assignImage() to assign an image.

Parameters
sNameThe cursor name (e.g. 'myCursor'). Must be unique, max 64 characters.
iVersionCursor version. 10 means v1.0 (only version supported). Default v1.0.
Returns
greater than 0 on success (the Cursor id) or a negative error code on failure.
Note
Returns error if name already exists.

◆ close()

bool CRM64Pro::CursorMgr::close ( Sint32 idCursor)
override

Close and destroy a cursor.

Parameters
idCursor0 for closing all cursors or the Cursor id. Stand-alone and child cursors can be closed but parent ones, can not as they have at least one dependency (a child).
Returns
true on success or false on failure.
Note
If you forget to close a Cursor, it will be automatically closed once the GDK is terminated.

◆ getCount()

Sint32 CRM64Pro::CursorMgr::getCount ( ) const
override

Get number of loaded objects.

Returns
the number of cursors.

◆ setName()

Sint32 CRM64Pro::CursorMgr::setName ( Sint32 idCur,
const string & sName )
override

Change the object name.

Parameters
idCurCursor id.
sNameThe cursor name (e.g. 'myCursor'). Must be unique, max 64 characters.
Returns
0 on success, or a negative error code on failure.
Note
Image name is internally modified (prefixed with '#' + internal code + cursor name).

◆ get()

Cursor * CRM64Pro::CursorMgr::get ( Sint32 idCur)

Get a pointer to the cursor using its handler.

Parameters
idCurCursor id.
Returns
nullptr the cursor was not found.
A pointer to the cursor object.

◆ select()

Sint32 CRM64Pro::CursorMgr::select ( Sint32 idCur)

Select a mouse cursor.

Parameters
idCurCursor id. It also supports any SDL_SystemCursor.
Returns
0 on success, or a negative error code on failure.
Note
Cursors are dinamically build on the first time they are selected. You can use Cursor::build() for building them in advance.

◆ getSelect()

Sint32 CRM64Pro::CursorMgr::getSelect ( ) const

Get selected mouse cursor.

Returns
Current selected Cursor id.

◆ show()

bool CRM64Pro::CursorMgr::show ( )

Make visible the selected mouse cursor.

Returns
true on success or false on failure.

◆ hide()

bool CRM64Pro::CursorMgr::hide ( )

Hide the mouse cursor.

Returns
true on success or false on failure.

◆ status()

Sint32 CRM64Pro::CursorMgr::status ( ) const

Get the cursor status.

Returns
C64_STATUS_HIDDEN (cursor is hidden) or C64_STATUS_SHOWN (cursor is shown).

◆ setPosition()

bool CRM64Pro::CursorMgr::setPosition ( float fX,
float fY,
Sint32 idScreen = 0 )

Set the mouse cursor position.

Parameters
fXfloat with x position.
fYfloat with y position.
idScreenScreen id. Default 0 uses the screen with mouse focus.
Returns
true on success or false on failure.

◆ getX()

float CRM64Pro::CursorMgr::getX ( ) const

Get the mouse cursor X position.

Returns
The mouse X position.
Note
The mouse cursor position is internally updated in Main::update() each Logic Frame update.

◆ getY()

float CRM64Pro::CursorMgr::getY ( ) const

Get the mouse cursor Y position.

Returns
The mouse Y position.
Note
The mouse cursor position is internally updated in Main::update() each Logic Frame update.

◆ getButtons()

Sint32 CRM64Pro::CursorMgr::getButtons ( ) const

Get the mouse buttons.

Returns
32 bit button bitmask of the current button state.
Note
The mouse buttons are internally updated in Main::update() each Logic Frame update. The button bitmask can be tested using the SDL_BUTTON(X) macros where X is generally 1 for the left, 2 for middle, 3 for the right button.

◆ getButtonsPrev()

Sint32 CRM64Pro::CursorMgr::getButtonsPrev ( ) const

Get the previous mouse buttons.

Returns
32 bit button bitmask of the previous(the last Logic Frame) button state.
Note
The mouse buttons are internally updated in Main::update() each Logic Frame update. The button bitmask can be tested using the SDL_BUTTON(X) macros where X is generally 1 for the left, 2 for middle, 3 for the right button.

◆ getFocus()

Sint32 CRM64Pro::CursorMgr::getFocus ( ) const

Get the Screen id which currently has mouse focus.

Returns
0 or greater on success(the Screen id) or a negative error code on failure.
Note
For getting the keyboard focus you can use Main::getKeyboardFocus() method.

◆ child()

Sint32 CRM64Pro::CursorMgr::child ( Sint32 idCur)

Create a child cursor dependant on the provided one(the parent).

A child cursor uses parent's attributes and creates a child image for different attributes. Currently only different Hotspots are supported, as colorkey cannot be modified on child images and other attributes are not supported by the SDL cursor system.

Parameters
idCurparent Cursor id. If the provided cursor is a child, the request is redirected to its parent.
Returns
greater than 0 on success (the Cursor id) or a negative error code on failure.
Note
The child uses the parent's name.

◆ load() [1/2]

Sint32 CRM64Pro::CursorMgr::load ( const string & sCDCFile,
const string & sName )

Load a cursor stored in a CDC file.

Parameters
sCDCFilestring containing [directory]+filename. Directory separators '\' and '/' are supported.
sNamestring with the cursor name (max 64 characters). If already exists, creates a child instead.
Returns
greater than 0 on success (the Cursor id) or a negative error code on failure.

◆ load() [2/2]

Sint32 CRM64Pro::CursorMgr::load ( const Sint32 idCDC,
const string & sName )

Load a cursor stored in a CDC file.

Parameters
idCDCCDC id.
sNamestring with the cursor name (max 64 characters). If already exists, creates a child instead.
Returns
greater than 0 on success (the Cursor id) or a negative error code on failure.

◆ remove()

Sint32 CRM64Pro::CursorMgr::remove ( Sint32 idCDC,
const string & sName )

Remove a cursor stored in a CDC file.

Parameters
idCDCCDC id.
sNamestring with the cursor name (maximum size of 64 characters).
Returns
greater than 0 on success, or a negative error code on failure.
Note
The cursor must be closed before trying to remove it from the CDC.

◆ exist() [1/2]

bool CRM64Pro::CursorMgr::exist ( Sint32 idCDC,
const string & sName )

Check if a cursor is stored in a CDC file.

Parameters
idCDCCDC id.
sNamestring with the cursor name (maximum size of 64 characters).
Returns
true on success(it exists) or false on failure (it does not exist).
Note
It is normally used for checking if a cursor is present without throwing any error.

◆ exist() [2/2]

bool CRM64Pro::CursorMgr::exist ( const string & sCDCFile,
const string & sName )

Check if a cursor is stored in a CDC file.

Parameters
sCDCFilePath to the CDC archive file.
sNamestring with the cursor name (maximum size of 64 characters).
Returns
true on success(it exists) or false on failure (it does not exist).
Note
It is normally used for checking if a cursor is present without throwing any error.