1998-05-20 14:25:30 +00:00
\section { \class { wxCursor} } \label { wxcursor}
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 { \bf
wxCursor} object are catered for, and this is an occasion where
conditional compilation will probably be required (see \helpref { wxIcon} { wxicon} for
an example).
A single cursor object may be used in many windows (any subwindow type).
2004-05-04 08:27:20 +00:00
The wxWidgets convention is to set the cursor for a window, as in X,
1998-05-20 14:25:30 +00:00
rather than to set it globally as in MS Windows, although a
global \helpref { ::wxSetCursor} { wxsetcursor} is also available for MS Windows use.
\wxheading { Derived from}
\helpref { wxBitmap} { wxbitmap} \\
\helpref { wxGDIObject} { wxgdiobject} \\
\helpref { wxObject} { wxobject}
1999-02-15 20:41:29 +00:00
\wxheading { Include files}
<wx/cursor.h>
1999-03-01 13:06:15 +00:00
\wxheading { Predefined objects}
Objects:
{ \bf wxNullCursor}
Pointers:
{ \bf wxSTANDARD\_ CURSOR\\
wxHOURGLASS\_ CURSOR\\
wxCROSS\_ CURSOR}
1998-05-20 14:25:30 +00:00
\wxheading { See also}
\helpref { wxBitmap} { wxbitmap} , \helpref { wxIcon} { wxicon} , \helpref { wxWindow::SetCursor} { wxwindowsetcursor} ,\rtfsp
\helpref { ::wxSetCursor} { wxsetcursor}
\latexignore { \rtfignore { \wxheading { Members} } }
2004-09-30 11:15:59 +00:00
\membersection { wxCursor::wxCursor} \label { wxcursorctor}
1998-05-20 14:25:30 +00:00
\func { } { wxCursor} { \void }
Default constructor.
1998-06-14 12:11:50 +00:00
\func { } { wxCursor} { \param { const char} { bits[]} , \param { int } { width} ,
2004-02-08 15:34:16 +00:00
\param { int } { height} , \param { int } { hotSpotX=-1} , \param { int } { hotSpotY=-1} , \param { const char } { maskBits[]=NULL} ,
\param { wxColour*} { fg=NULL} , \param { wxColour*} { bg=NULL} }
1998-05-20 14:25:30 +00:00
2004-02-08 15:34:16 +00:00
Constructs a cursor by passing an array of bits (Motif and GTK+ only). { \it maskBits} is used only under
2004-02-08 18:48:55 +00:00
Motif and GTK+. The parameters { \it fg} and { \it bg} are only present on GTK+, and force the
2004-02-08 15:34:16 +00:00
cursor to use particular background and foreground colours.
1998-05-20 14:25:30 +00:00
If either { \it hotSpotX} or { \it hotSpotY} is -1, the hotspot will be the centre of the cursor image (Motif only).
1998-06-14 12:11:50 +00:00
\func { } { wxCursor} { \param { const wxString\& } { cursorName} , \param { long } { type} , \param { int } { hotSpotX=0} , \param { int } { hotSpotY=0} }
1998-05-20 14:25:30 +00:00
Constructs a cursor by passing a string resource name or filename.
2003-01-13 19:07:08 +00:00
On MacOS when specifying a string resource name, first the color cursors 'crsr' and then the black/white cursors 'CURS' in the resource chain are scanned through.
1998-05-20 14:25:30 +00:00
{ \it hotSpotX} and { \it 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.
1998-06-14 12:11:50 +00:00
\func { } { wxCursor} { \param { int} { cursorId} }
1998-05-20 14:25:30 +00:00
Constructs a cursor using a cursor identifier.
2002-02-21 15:22:58 +00:00
\func { } { wxCursor} { \param { const wxImage\& } { image} }
2002-06-07 20:15:28 +00:00
Constructs a cursor from a wxImage. The cursor is monochrome, colors with the RGB elements all greater
2002-02-21 15:22:58 +00:00
than 127 will be foreground, colors less than this background. The mask (if any) will be used as transparent.
2005-03-04 18:33:57 +00:00
In MSW the foreground will be white and the background black. If the cursor is larger than 32x32 it is resized.
2002-02-21 15:22:58 +00:00
In GTK, the two most frequent colors will be used for foreground and background. The cursor will be displayed
at the size of the image.
2005-03-04 18:33:57 +00:00
On MacOS if the cursor is larger than 16x16 it is resized and currently only shown as black/white (mask respected).
2002-02-21 15:22:58 +00:00
1998-05-20 14:25:30 +00:00
\func { } { wxCursor} { \param { const wxCursor\& } { cursor} }
Copy constructor. This uses reference counting so is a cheap operation.
\wxheading { Parameters}
\docparam { bits} { An array of bits.}
\docparam { maskBits} { Bits for a mask bitmap.}
\docparam { width} { Cursor width.}
\docparam { height} { Cursor height.}
\docparam { hotSpotX} { Hotspot x coordinate.}
\docparam { hotSpotY} { Hotspot y coordinate.}
\docparam { type} { Icon type to load. Under Motif, { \it type} defaults to { \bf wxBITMAP\_ TYPE\_ XBM} . Under Windows,
2003-01-13 19:07:08 +00:00
it defaults to { \bf wxBITMAP\_ TYPE\_ CUR\_ RESOURCE} . Under MacOS, it defaults to { \bf wxBITMAP\_ TYPE\_ MACCURSOR\_ RESOURCE} .
1998-05-20 14:25:30 +00:00
Under X, the permitted cursor types are:
\twocolwidtha { 6cm}
\begin { twocollist} \itemsep =0pt
\twocolitem { \windowstyle { wxBITMAP\_ TYPE\_ XBM} } { Load an X bitmap file.}
\end { twocollist}
Under Windows, the permitted types are:
\twocolwidtha { 6cm}
\begin { twocollist} \itemsep =0pt
\twocolitem { \windowstyle { wxBITMAP\_ TYPE\_ CUR} } { Load a cursor from a .cur cursor file (only if USE\_ RESOURCE\_ LOADING\_ IN\_ MSW
1999-02-28 23:39:59 +00:00
is enabled in setup.h).}
1998-05-20 14:25:30 +00:00
\twocolitem { \windowstyle { wxBITMAP\_ TYPE\_ CUR\_ RESOURCE} } { Load a Windows resource (as specified in the .rc file).}
\twocolitem { \windowstyle { wxBITMAP\_ TYPE\_ ICO} } { Load a cursor from a .ico icon file (only if USE\_ RESOURCE\_ LOADING\_ IN\_ MSW
1999-02-28 23:39:59 +00:00
is enabled in setup.h). Specify { \it hotSpotX} and { \it hotSpotY} .}
1998-05-20 14:25:30 +00:00
\end { twocollist} }
\docparam { cursorId} { A stock cursor identifier. May be one of:
\twocolwidtha { 6cm}
\begin { twocollist} \itemsep =0pt
\twocolitem { { \bf wxCURSOR\_ ARROW} } { A standard arrow cursor.}
2002-03-15 22:52:15 +00:00
\twocolitem { { \bf wxCURSOR\_ RIGHT\_ ARROW} } { A standard arrow cursor
pointing to the right.}
2002-04-03 19:17:30 +00:00
\twocolitem { { \bf wxCURSOR\_ BLANK} } { Transparent cursor.}
1998-05-20 14:25:30 +00:00
\twocolitem { { \bf wxCURSOR\_ BULLSEYE} } { Bullseye cursor.}
\twocolitem { { \bf wxCURSOR\_ CHAR} } { Rectangular character cursor.}
\twocolitem { { \bf wxCURSOR\_ CROSS} } { A cross cursor.}
\twocolitem { { \bf wxCURSOR\_ HAND} } { A hand cursor.}
\twocolitem { { \bf wxCURSOR\_ IBEAM} } { An I-beam cursor (vertical line).}
\twocolitem { { \bf wxCURSOR\_ LEFT\_ BUTTON} } { Represents a mouse with the left button depressed.}
\twocolitem { { \bf wxCURSOR\_ MAGNIFIER} } { A magnifier icon.}
\twocolitem { { \bf wxCURSOR\_ MIDDLE\_ BUTTON} } { Represents a mouse with the middle button depressed.}
\twocolitem { { \bf wxCURSOR\_ NO\_ ENTRY} } { A no-entry sign cursor.}
\twocolitem { { \bf wxCURSOR\_ PAINT\_ BRUSH} } { A paintbrush cursor.}
\twocolitem { { \bf wxCURSOR\_ PENCIL} } { A pencil cursor.}
\twocolitem { { \bf wxCURSOR\_ POINT\_ LEFT} } { A cursor that points left.}
\twocolitem { { \bf wxCURSOR\_ POINT\_ RIGHT} } { A cursor that points right.}
\twocolitem { { \bf wxCURSOR\_ QUESTION\_ ARROW} } { An arrow and question mark.}
\twocolitem { { \bf wxCURSOR\_ RIGHT\_ BUTTON} } { Represents a mouse with the right button depressed.}
\twocolitem { { \bf wxCURSOR\_ SIZENESW} } { A sizing cursor pointing NE-SW.}
\twocolitem { { \bf wxCURSOR\_ SIZENS} } { A sizing cursor pointing N-S.}
\twocolitem { { \bf wxCURSOR\_ SIZENWSE} } { A sizing cursor pointing NW-SE.}
\twocolitem { { \bf wxCURSOR\_ SIZEWE} } { A sizing cursor pointing W-E.}
\twocolitem { { \bf wxCURSOR\_ SIZING} } { A general sizing cursor.}
\twocolitem { { \bf wxCURSOR\_ SPRAYCAN} } { A spraycan cursor.}
\twocolitem { { \bf wxCURSOR\_ WAIT} } { A wait cursor.}
\twocolitem { { \bf wxCURSOR\_ WATCH} } { A watch cursor.}
2001-04-19 19:08:24 +00:00
\twocolitem { { \bf wxCURSOR\_ ARROWWAIT} } { A cursor with both an arrow and
an hourglass, (windows.)}
1998-05-20 14:25:30 +00:00
\end { twocollist} \twocolwidtha { 5cm}
Note that not all cursors are available on all platforms.}
\docparam { cursor} { Pointer or reference to a cursor to copy.}
1999-02-19 07:58:02 +00:00
\pythonnote { Constructors supported by wxPython are:\par
\indented { 2cm} { \begin { twocollist}
1999-12-25 20:34:56 +00:00
\twocolitem { { \bf wxCursor(name, flags, hotSpotX=0,
1999-02-19 07:58:02 +00:00
hotSpotY=0)} } { Constructs a cursor from a filename}
1999-12-25 20:34:56 +00:00
\twocolitem { { \bf wxStockCursor(id)} } { Constructs a stock cursor }
1999-02-19 07:58:02 +00:00
\end { twocollist} }
}
2002-06-07 20:15:28 +00:00
\perlnote { Constructors supported by wxPerl are:\par
2000-12-20 16:10:46 +00:00
\begin { itemize}
\item { Wx::Cursor->new( name, type, hotSpotX = 0, hotSpotY = 0 )}
\item { Wx::Cursor->new( id )}
2002-07-05 16:43:21 +00:00
\item { Wx::Cursor->new( image )}
\item { Wx::Cursor->newData( bits, width, height, hotSpotX = -1, hotSpotY = -1, maskBits = 0 )}
2000-12-20 16:10:46 +00:00
\end { itemize}
}
2004-02-08 15:34:16 +00:00
\wxheading { Example}
The following is an example of creating a
cursor from 32x32 bitmap data ({ \tt down\_ bits} ) and a mask
({ \tt down\_ mask} ) where 1 is black and 0 is white for
the bits, and 1 is opaque and 0 is transparent for
the mask. It works on Windows and GTK+.
\begin { verbatim}
static char down_ bits[] = { 255, 255, 255, 255, 31,
255, 255, 255, 31, 255, 255, 255, 31, 255, 255, 255,
31, 255, 255, 255, 31, 255, 255, 255, 31, 255, 255,
255, 31, 255, 255, 255, 31, 255, 255, 255, 25, 243,
255, 255, 19, 249, 255, 255, 7, 252, 255, 255, 15, 254,
255, 255, 31, 255, 255, 255, 191, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255 } ;
static char down_ mask[] = { 240, 1, 0, 0, 240, 1,
0, 0, 240, 1, 0, 0, 240, 1, 0, 0, 240, 1, 0, 0, 240, 1,
0, 0, 240, 1, 0, 0, 240, 1, 0, 0, 255, 31, 0, 0, 255,
31, 0, 0, 254, 15, 0, 0, 252, 7, 0, 0, 248, 3, 0, 0,
240, 1, 0, 0, 224, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0 } ;
#ifdef _ _ WXMSW_ _
wxBitmap down_ bitmap(down_ bits, 32, 32);
wxBitmap down_ mask_ bitmap(down_ mask, 32, 32);
down_ bitmap.SetMask(new wxMask(down_ mask_ bitmap));
wxImage down_ image = down_ bitmap.ConvertToImage();
down_ image.SetOption(wxIMAGE_ OPTION_ CUR_ HOTSPOT_ X, 6);
down_ image.SetOption(wxIMAGE_ OPTION_ CUR_ HOTSPOT_ Y, 14);
wxCursor down_ cursor = wxCursor(down_ image);
#else
wxCursor down_ cursor = wxCursor(down_ bits, 32, 32,
6, 14, down_ mask, wxWHITE, wxBLACK);
#endif
\end { verbatim}
2004-09-30 11:15:59 +00:00
\membersection { wxCursor::\destruct { wxCursor} } \label { wxcursordtor}
1998-05-20 14:25:30 +00:00
\func { } { \destruct { wxCursor} } { \void }
Destroys the cursor. A cursor can be reused for more
than one window, and does not get destroyed when the window is
2004-05-04 08:27:20 +00:00
destroyed. wxWidgets destroys all cursors on application exit, although
2000-07-15 19:51:35 +00:00
it is best to clean them up explicitly.
1998-05-20 14:25:30 +00:00
\membersection { wxCursor::Ok} \label { wxcursorok}
\constfunc { bool} { Ok} { \void }
2003-01-18 00:16:34 +00:00
Returns true if cursor data is present.
1998-05-20 14:25:30 +00:00
\membersection { wxCursor::operator $ = $ } \label { wxcursorassignment}
\func { wxCursor\& } { operator $ = $ } { \param { const wxCursor\& } { cursor} }
Assignment operator, using reference counting. Returns a reference
to `this'.
\membersection { wxCursor::operator $ = = $ } \label { wxcursorequals}
\func { bool} { operator $ = = $ } { \param { const wxCursor\& } { cursor} }
Equality operator. Two cursors are equal if they contain pointers
to the same underlying cursor data. It does not compare each attribute,
so two independently-created cursors using the same parameters will
fail the test.
\membersection { wxCursor::operator $ ! = $ } \label { wxcursornotequals}
\func { bool} { operator $ ! = $ } { \param { const wxCursor\& } { cursor} }
Inequality operator. Two cursors are not equal if they contain pointers
to different underlying cursor data. It does not compare each attribute.