Version: 3.3.0

#include <wx/cursor.h>

Detailed Description

A cursor bundle is a set of different versions of the same cursor at different sizes.

This class relationship with wxCursor is similar to that of wxBitmapBundle with wxBitmap, but it has a simpler interface because cursors are never scaled and always use the closest available size. It is typically used like the following:

MyFrame::MyFrame()
{
SetCursorBundle(wxCursorBundle(wxBitmapBundle::FromResources("mycursor"),
wxPoint(1, 1)));
}
static wxBitmapBundle FromResources(const wxString &name)
Create a bundle from the bitmaps in the application resources.
wxCursorBundle()
Default ctor constructs an empty bundle.
A wxPoint is a useful data structure for graphics operations.
Definition: gdicmn.h:682

Please see wxBitmapBundle documentation for more information about different ways of creating it.

Library:  wxCore
Category:  Graphics Device Interface (GDI)
Since
3.3.0

Public Member Functions

 wxCursorBundle ()
 Default ctor constructs an empty bundle. More...
 
 wxCursorBundle (const wxBitmapBundle &bitmaps, const wxPoint &hotSpot)
 Create a cursor bundle from the given bitmap bundle. More...
 
 wxCursorBundle (const wxBitmapBundle &bitmaps, int hotSpotX=0, int hotSpotY=0)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
 wxCursorBundle (const wxCursorBundle &other)
 Copy constructor performs a shallow copy of the bundle. More...
 
wxCursorBundleoperator= (const wxCursorBundle &other)
 Assignment operator performs a shallow copy of the bundle. More...
 
bool IsOk () const
 Check if cursor bundle is non-empty. More...
 
void Clear ()
 Clear the bundle contents. More...
 
wxCursor GetCursorFor (const wxWindow *window) const
 Get the cursor of the size suitable for the given window. More...
 
wxCursor GetCursorForMainWindow () const
 Get the cursor of the default size. More...
 
bool IsSameAs (const wxCursorBundle &other) const
 Check if two objects refer to the same bundle. More...
 

Constructor & Destructor Documentation

◆ wxCursorBundle() [1/4]

wxCursorBundle::wxCursorBundle ( )

Default ctor constructs an empty bundle.

Such bundle represents the absence of any custom cursor but not an empty cursor (wxCURSOR_BLANK can be used if this is really needed).

You can use the assignment operator to set the bundle contents later.

◆ wxCursorBundle() [2/4]

wxCursorBundle::wxCursorBundle ( const wxBitmapBundle bitmaps,
const wxPoint hotSpot 
)
explicit

Create a cursor bundle from the given bitmap bundle.

Parameters
bitmapsThe bitmap bundle to use for the cursor, typically containing bitmap in at least two sizes.
hotSpotHotspot coordinates (relative to the top left of the image). The coordinates are relative to the default size of the bitmap bundle and are scaled by wxWidgets for other sizes.

◆ wxCursorBundle() [3/4]

wxCursorBundle::wxCursorBundle ( const wxBitmapBundle bitmaps,
int  hotSpotX = 0,
int  hotSpotY = 0 
)
explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ wxCursorBundle() [4/4]

wxCursorBundle::wxCursorBundle ( const wxCursorBundle other)

Copy constructor performs a shallow copy of the bundle.

This operation is cheap as it doesn't copy any bitmaps.

Member Function Documentation

◆ Clear()

void wxCursorBundle::Clear ( )

Clear the bundle contents.

IsOk() will return false after doing this.

Use the assignment operator to set the bundle contents later.

◆ GetCursorFor()

wxCursor wxCursorBundle::GetCursorFor ( const wxWindow window) const

Get the cursor of the size suitable for the given window.

◆ GetCursorForMainWindow()

wxCursor wxCursorBundle::GetCursorForMainWindow ( ) const

Get the cursor of the default size.

Prefer to use GetCursorFor() instead if there is a suitable window available, this function only exists as last resort.

◆ IsOk()

bool wxCursorBundle::IsOk ( ) const

Check if cursor bundle is non-empty.

◆ IsSameAs()

bool wxCursorBundle::IsSameAs ( const wxCursorBundle other) const

Check if two objects refer to the same bundle.

Note that this compares the object identity, i.e. this function returns true only for copies of the same bundle, but false for two bundles created from the same bitmap bundle and same hotspot coordinates.

◆ operator=()

wxCursorBundle& wxCursorBundle::operator= ( const wxCursorBundle other)

Assignment operator performs a shallow copy of the bundle.

This operation is cheap as it doesn't copy any bitmaps.