Contents Up Previous Next

wxCursor: wxBitmap

A cursor is a small bitmap usually used for denoting where the mouse pointer is, with a picture that might indicate the interpretation of a mouse click. As with icons, cursors in X and MS Windows are created in a different manner. Therefore, separate cursors will be created for the different environments. Platform-specific methods for creating a wxCursor object are catered for, and this is an occasion where conditional compilation will probably be required (see wxIcon for an example).

A single cursor object may be used in many windows (any subwindow type). The wxWindows convention is to set the cursor for a window, as in X, rather than to set it globally as in MS Windows, although a global ::wxSetCursor is also available for MS Windows use.

Run the hello demo program to see what stock cursors are available.

wxCursor::wxCursor
wxCursor::~wxCursor


wxCursor::wxCursor

void wxCursor(void)

Default constructor.

void wxCursor(short bits[], int width, int height, int hotSpotX=-1, int hotSpotY=-1, char *maskBits=NULL)

Construct a cursor by passing an array of bits (XView and Motif only). maskBits is used only under Motif.

If either hotSpotX or hotSpotY is -1, the hotspot will be the centre of the cursor image (values ignored under XView).

void wxCursor(char *cursorName, long flags, int hotSpotX=0, int hotSpotY=0)

Construct a cursor by passing a string resource name or filename. Under Motif, flags defaults to wxBITMAP_TYPE_XBM | wxBITMAP_DISCARD_COLOURMAP. Under Windows, it defaults to wxBITMAP_TYPE_CUR_RESOURCE | wxBITMAP_DISCARD_COLOURMAP.

hotSpotX and hotSpotY are currently only used under Windows when loading from an icon file, to specify the cursor hotspot relative to the top left of the image.

Under X, the permitted cursor types in the flags bitlist are:

wxBITMAP_TYPE_XBM Load an X bitmap file.

Under Windows, the permitted types are:

wxBITMAP_TYPE_CUR Load a cursor from a .cur cursor file (only if USE_RESOURCE_LOADING_IN_MSW is enabled in wx_setup.h).
wxBITMAP_TYPE_CUR_RESOURCE Load a Windows resource (as specified in the .rc file).
wxBITMAP_TYPE_ICO Load a cursor from a .ico icon file (only if USE_RESOURCE_LOADING_IN_MSW is enabled in wx_setup.h). Specify hotSpotX and hotSpotY.

void wxCursor(int id)

Create a cursor by passing a stock cursor id. The following stock cursor ids may be used:


wxCursor::~wxCursor

void ~wxCursor(void)

Destroys the cursor. Unlike an icon, a cursor can be reused for more than one window, and does not get destroyed when the window is destroyed. wxWindows destroys all cursors on application exit.