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

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

Cursor Object class. More...

## Detailed Description

Cursor Object class.

## Public Member Functions
bool | info (Sint32 iMode=0) override
| Request Cursor object information.
const string & | getName () const override
| Get the name.
Sint32 | getID () const override
| Get the ID.
Sint32 | assignImage (Sint32 idImage, Sint32 iOwnership=0)
| Assign an Image to this cursor.
Sint32 | getImage () const
| Get the assigned Image of this cursor.
Sint32 | build ()
| Build the cursor.
bool | setHotSpot (const Position &rHotX, const Position &rHotY)
| Set the cursor hotspots.
bool | getHotSpot (Sint32 *iHotX, Sint32 *iHotY) const
| Get the cursor hotspots.
Sint32 | save (const string &sCDCFile, const string &sResourceName="")
| Save the cursor to a CDC file.
Sint32 | save (Sint32 idCDC, const string &sResourceName="")
| Save the cursor to a CDC file.

## Member Function Documentation

## ◆ info()

bool CRM64Pro::Cursor::info | ( | Sint32 | iMode = 0 | ) |
| override

Request Cursor object information.

Writes information to the default log.

Parameters

  iMode | Reserved for future use. Pass 0.

Returns
  true on success, or false on failure.

## ◆ getName()

const string & CRM64Pro::Cursor::getName | ( |  | ) | const
| override

Get the name.

Returns
  The object name.

## ◆ getID()

Sint32 CRM64Pro::Cursor::getID | ( |  | ) | const
| override

Get the ID.

Returns
  Object ID.

## ◆ assignImage()

Sint32 CRM64Pro::Cursor::assignImage | ( | Sint32 | idImage,
|  | Sint32 | iOwnership = 0 )

Assign an Image to this cursor.

Used for associating an Image to cursors created via CursorMgr::create().

Parameters

  idImage | Image id.
  iOwnership | 0 (default) creates a copy; any other value takes ownership (image cannot be owned by another item).

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

Note
  Re-assigning closes the old image. SDL system cursors don't support image assignments.

## ◆ getImage()

Sint32 CRM64Pro::Cursor::getImage | ( |  | ) | const

Get the assigned Image of this cursor.

Returns
  Greater than 0 on success (the Image id), or a negative error code on failure.

## ◆ build()

Sint32 CRM64Pro::Cursor::build | ( |  | ) |

Build the cursor.

If the assigned Image colorkey is modified, this method rebuilds the cursor. Other Image attributes (color/alpha modulation) have no effect on cursors.

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

Note
  Cursors are dynamically built when first selected. Use this method to build them in advance.

## ◆ setHotSpot()

bool CRM64Pro::Cursor::setHotSpot | ( | const Position & | rHotX,
|  | const Position & | rHotY )

Set the cursor hotspots.

Parameters

  rHotX | Position with x hotspot. Can be absolute (float) or use ::PH_CENTER / ::PH_SIZE helpers with integer offset.
  rHotY | Position with y hotspot. Can be absolute (float) or use ::PH_CENTER / ::PH_SIZE helpers with integer offset.

Returns
  true on success, or false on failure.

Note
  Hotspot of SDL system cursors cannot be modified, they are fixed to (0,0).
  Supports implicit conversion: setHotSpot(10.0f, 20.0f), setHotSpot(Position(PH_CENTER, -2), Position(PH_SIZE))

## ◆ getHotSpot()

bool CRM64Pro::Cursor::getHotSpot | ( | Sint32 * | iHotX,
|  | Sint32 * | iHotY ) const

Get the cursor hotspots.

Parameters

  iHotX | an integer pointer filled in with x hotspot position of the cursor. If nullptr is passed, the method ignores the retrieving of this value.
  iHotY | an integer pointer filled in with y hotspot position of the cursor. If nullptr is passed, the method ignores the retrieving of this value.

Returns
  true on success, or false on failure.

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

## ◆ save() [1/2]

Sint32 CRM64Pro::Cursor::save | ( | const string & | sCDCFile,
|  | const string & | sResourceName = "" )

Save the cursor to a CDC file.

The associated image will also be saved to the same CDC file.

Parameters

  sCDCFile | string containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported.
  sResourceName | Optional resource name to use in the CDC. If empty (default), uses the Cursor object's internal name.

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

Note
  Existing cursor is overwritten. Cannot save child cursors or SDL system cursors.

## ◆ save() [2/2]

Sint32 CRM64Pro::Cursor::save | ( | Sint32 | idCDC,
|  | const string & | sResourceName = "" )

Save the cursor to a CDC file.

The associated image will also be saved to the same CDC file.

Parameters

  idCDC | CDC id.
  sResourceName | Optional resource name to use in the CDC. If empty (default), uses the Cursor object's internal name.

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

Note
  Existing cursor is overwritten. If a child, calls parent's save method. Cannot save SDL system cursors.