| CRM64Pro GDK v0.19.0 A free cross-platform game development kit built on top of SDL 3.0

Loading...
Searching...
No Matches
CRM64Pro::CursorMgrfinal
Graphics modules » Cursor

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.
Sint32 | close (Sint32 idCursor) override
| Close and destroy a cursor.
Sint32 | getCount () const override
| Get number of loaded objects.
Sint32 | setName (Sint32 idCursor, const string &sName) override
| Change the object name.
Cursor * | get (Sint32 idCursor)
| Get a pointer to the cursor using its handle.
Sint32 | select (Sint32 idCursor)
| Select a mouse cursor.
Sint32 | getSelectedCursor () const
| Get the selected mouse cursor.
bool | show ()
| Make visible the selected mouse cursor.
bool | hide ()
| Hide the mouse cursor.
eGeneralStatus | 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 idCursor)
| Create a child cursor dependent on the provided one (the parent).
Sint32 | load (const string &sCDCFile, const string &sName)
| Load a cursor stored in a CDC file.
Sint32 | load (Sint32 idCDC, const string &sName)
| Load a cursor stored in a CDC file.
Sint32 | loadFromBuffer (const void *pBuffer, Sint32 iSize, const string &sName)
| Load a cursor from an image memory buffer.
Sint32 | remove (Sint32 idCDC, const string &sName)
| Remove a cursor stored in a CDC file.
bool | exists (Sint32 idCDC, const string &sName) const
| Check if a cursor is stored in a CDC file.
bool | exists (const string &sCDCFile, const string &sName) const
| 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 manager information to the default log.

Parameters

  iMode | -1 to display only manager information. 0 (default) to display manager and all objects. A specific object ID displays manager information 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

  sName | The cursor name (e.g. 'demoCursor'). Must be unique and shorter than 64 characters.
  iVersion | Cursor 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()

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

Close and destroy a cursor.

Parameters

  idCursor | 0 for closing all cursors or the Cursor id. Stand-alone and child cursors can be closed but parent ones cannot as they have at least one dependency (a child).

Returns
  0 on success, or a negative error code 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 | idCursor,
|  | const string & | sName )
| override

Change the object name.

Parameters

  idCursor | Cursor id.
  sName | The cursor name (e.g. 'demoCursor'). Must be unique and shorter than 64 characters.

Returns
  0 on success, or a negative error code on failure.

## ◆ get()

Cursor * CRM64Pro::CursorMgr::get | ( | Sint32 | idCursor | ) |

Get a pointer to the cursor using its handle.

Parameters

  idCursor | Cursor id.

Returns
  Borrowed pointer to the Cursor object, or nullptr if not found.

Note
  The returned pointer must not be deleted. It remains valid until the Cursor is closed or CursorMgr is reset or terminated.

## ◆ select()

Sint32 CRM64Pro::CursorMgr::select | ( | Sint32 | idCursor | ) |

Select a mouse cursor.

Parameters

  idCursor | Cursor id. It also supports any SDL_SystemCursor.

Returns
  0 on success, or a negative error code on failure.

Note
  Cursors are dynamically built the first time they are selected. You can use Cursor::build() to build them in advance.

## ◆ getSelectedCursor()

Sint32 CRM64Pro::CursorMgr::getSelectedCursor | ( |  | ) | const

Get the selected mouse cursor.

Returns
  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()

eGeneralStatus CRM64Pro::CursorMgr::status | ( |  | ) | const

Get the cursor status.

Returns
  ::GS_HIDDEN (cursor is hidden) or ::GS_SHOWN (cursor is shown).

## ◆ setPosition()

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

Set the mouse cursor position.

Parameters

  fX | float with x position.
  fY | float with y position.
  idScreen | Screen 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
  Greater than 0 on success (the Screen id), or a negative error code on failure.

Note
  Use Main::getKeyboardFocus() to query the current keyboard focus.

## ◆ child()

Sint32 CRM64Pro::CursorMgr::child | ( | Sint32 | idCursor | ) |

Create a child cursor dependent 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

  idCursor | parent 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

  sCDCFile | string containing [directory]+filename. Directory separators '\' and '/' are supported.
  sName | string with the cursor name (shorter than 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 | ( | Sint32 | idCDC,
|  | const string & | sName )

Load a cursor stored in a CDC file.

Parameters

  idCDC | CDC id.
  sName | string with the cursor name (shorter than 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.

## ◆ loadFromBuffer()

Sint32 CRM64Pro::CursorMgr::loadFromBuffer | ( | const void * | pBuffer,
|  | Sint32 | iSize,
|  | const string & | sName )

Load a cursor from an image memory buffer.

Parameters

  pBuffer | Pointer to the memory buffer containing the image (BMP or PNG).
  iSize | Size of the buffer in bytes.
  sName | string with the cursor name (shorter than 64 characters).

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

  idCDC | CDC id.
  sName | string with the cursor name (shorter than 64 characters).

Returns
  0 on success, or a negative error code on failure.

Note
  The cursor must be closed before trying to remove it from the CDC.

## ◆ exists() [1/2]

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

Check if a cursor is stored in a CDC file.

Parameters

  idCDC | CDC id.
  sName | string with the cursor name (shorter than 64 characters).

Returns
  true if the resource is stored in the CDC file, or false otherwise. No error is reported.

Note
  It is normally used for checking if a cursor is present without throwing any error.

## ◆ exists() [2/2]

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

Check if a cursor is stored in a CDC file.

Parameters

  sCDCFile | Path to the CDC archive file.
  sName | string with the cursor name (shorter than 64 characters).

Returns
  true if the resource is stored in the CDC file, or false otherwise. No error is reported.

Note
  It is normally used for checking if a cursor is present without throwing any error.