]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{\class{wxCursor}}\label{wxcursor} |
2 | ||
3 | A cursor is a small bitmap usually used for denoting where the mouse | |
4 | pointer is, with a picture that might indicate the interpretation of a | |
5 | mouse click. As with icons, cursors in X and MS Windows are created | |
6 | in a different manner. Therefore, separate cursors will be created for the | |
7 | different environments. Platform-specific methods for creating a {\bf | |
8 | wxCursor} object are catered for, and this is an occasion where | |
9 | conditional compilation will probably be required (see \helpref{wxIcon}{wxicon} for | |
10 | an example). | |
11 | ||
12 | A single cursor object may be used in many windows (any subwindow type). | |
13 | The wxWindows convention is to set the cursor for a window, as in X, | |
14 | rather than to set it globally as in MS Windows, although a | |
15 | global \helpref{::wxSetCursor}{wxsetcursor} is also available for MS Windows use. | |
16 | ||
17 | \wxheading{Derived from} | |
18 | ||
19 | \helpref{wxBitmap}{wxbitmap}\\ | |
20 | \helpref{wxGDIObject}{wxgdiobject}\\ | |
21 | \helpref{wxObject}{wxobject} | |
22 | ||
954b8ae6 JS |
23 | \wxheading{Include files} |
24 | ||
25 | <wx/cursor.h> | |
26 | ||
20e85460 JS |
27 | \wxheading{Predefined objects} |
28 | ||
29 | Objects: | |
30 | ||
31 | {\bf wxNullCursor} | |
32 | ||
33 | Pointers: | |
34 | ||
35 | {\bf wxSTANDARD\_CURSOR\\ | |
36 | wxHOURGLASS\_CURSOR\\ | |
37 | wxCROSS\_CURSOR} | |
38 | ||
a660d684 KB |
39 | \wxheading{See also} |
40 | ||
41 | \helpref{wxBitmap}{wxbitmap}, \helpref{wxIcon}{wxicon}, \helpref{wxWindow::SetCursor}{wxwindowsetcursor},\rtfsp | |
42 | \helpref{::wxSetCursor}{wxsetcursor} | |
43 | ||
44 | \latexignore{\rtfignore{\wxheading{Members}}} | |
45 | ||
46 | \membersection{wxCursor::wxCursor}\label{wxcursorconstr} | |
47 | ||
48 | \func{}{wxCursor}{\void} | |
49 | ||
50 | Default constructor. | |
51 | ||
eaaa6a06 JS |
52 | \func{}{wxCursor}{\param{const char}{ bits[]}, \param{int }{width}, |
53 | \param{int }{ height}, \param{int }{hotSpotX=-1}, \param{int }{hotSpotY=-1}, \param{const char }{maskBits[]=NULL}} | |
a660d684 KB |
54 | |
55 | Constructs a cursor by passing an array of bits (Motif and Xt only). {\it maskBits} is used only under Motif. | |
56 | ||
57 | If either {\it hotSpotX} or {\it hotSpotY} is -1, the hotspot will be the centre of the cursor image (Motif only). | |
58 | ||
eaaa6a06 | 59 | \func{}{wxCursor}{\param{const wxString\& }{cursorName}, \param{long }{type}, \param{int }{hotSpotX=0}, \param{int }{hotSpotY=0}} |
a660d684 KB |
60 | |
61 | Constructs a cursor by passing a string resource name or filename. | |
62 | ||
63 | {\it hotSpotX} and {\it hotSpotY} are currently only used under Windows when loading from an | |
64 | icon file, to specify the cursor hotspot relative to the top left of the image. | |
65 | ||
eaaa6a06 | 66 | \func{}{wxCursor}{\param{int}{ cursorId}} |
a660d684 KB |
67 | |
68 | Constructs a cursor using a cursor identifier. | |
69 | ||
bff4ec63 VZ |
70 | \func{}{wxCursor}{\param{const wxImage\&}{ image}} |
71 | ||
72 | Constructs a cursor from a wxImage. The cursor is monochome, colors with the RGB elements all greater | |
73 | than 127 will be foreground, colors less than this background. The mask (if any) will be used as transparent. | |
74 | ||
75 | In MSW the foreground will be white and the background black. The cursor is resized to 32x32 | |
76 | In GTK, the two most frequent colors will be used for foreground and background. The cursor will be displayed | |
77 | at the size of the image. | |
78 | ||
a660d684 KB |
79 | \func{}{wxCursor}{\param{const wxCursor\&}{ cursor}} |
80 | ||
81 | Copy constructor. This uses reference counting so is a cheap operation. | |
82 | ||
a660d684 KB |
83 | \wxheading{Parameters} |
84 | ||
85 | \docparam{bits}{An array of bits.} | |
86 | ||
87 | \docparam{maskBits}{Bits for a mask bitmap.} | |
88 | ||
89 | \docparam{width}{Cursor width.} | |
90 | ||
91 | \docparam{height}{Cursor height.} | |
92 | ||
93 | \docparam{hotSpotX}{Hotspot x coordinate.} | |
94 | ||
95 | \docparam{hotSpotY}{Hotspot y coordinate.} | |
96 | ||
97 | \docparam{type}{Icon type to load. Under Motif, {\it type} defaults to {\bf wxBITMAP\_TYPE\_XBM}. Under Windows, | |
98 | it defaults to {\bf wxBITMAP\_TYPE\_CUR\_RESOURCE}. | |
99 | ||
100 | Under X, the permitted cursor types are: | |
101 | ||
102 | \twocolwidtha{6cm} | |
103 | \begin{twocollist}\itemsep=0pt | |
104 | \twocolitem{\windowstyle{wxBITMAP\_TYPE\_XBM}}{Load an X bitmap file.} | |
105 | \end{twocollist} | |
106 | ||
107 | Under Windows, the permitted types are: | |
108 | ||
109 | \twocolwidtha{6cm} | |
110 | \begin{twocollist}\itemsep=0pt | |
111 | \twocolitem{\windowstyle{wxBITMAP\_TYPE\_CUR}}{Load a cursor from a .cur cursor file (only if USE\_RESOURCE\_LOADING\_IN\_MSW | |
9a05fd8d | 112 | is enabled in setup.h).} |
a660d684 KB |
113 | \twocolitem{\windowstyle{wxBITMAP\_TYPE\_CUR\_RESOURCE}}{Load a Windows resource (as specified in the .rc file).} |
114 | \twocolitem{\windowstyle{wxBITMAP\_TYPE\_ICO}}{Load a cursor from a .ico icon file (only if USE\_RESOURCE\_LOADING\_IN\_MSW | |
9a05fd8d | 115 | is enabled in setup.h). Specify {\it hotSpotX} and {\it hotSpotY}.} |
a660d684 KB |
116 | \end{twocollist}} |
117 | ||
118 | \docparam{cursorId}{A stock cursor identifier. May be one of: | |
119 | ||
120 | \twocolwidtha{6cm} | |
121 | \begin{twocollist}\itemsep=0pt | |
122 | \twocolitem{{\bf wxCURSOR\_ARROW}}{A standard arrow cursor.} | |
15dadf31 RD |
123 | \twocolitem{{\bf wxCURSOR\_RIGHT\_ARROW}}{A standard arrow cursor |
124 | pointing to the right.} | |
a660d684 KB |
125 | \twocolitem{{\bf wxCURSOR\_BULLSEYE}}{Bullseye cursor.} |
126 | \twocolitem{{\bf wxCURSOR\_CHAR}}{Rectangular character cursor.} | |
127 | \twocolitem{{\bf wxCURSOR\_CROSS}}{A cross cursor.} | |
128 | \twocolitem{{\bf wxCURSOR\_HAND}}{A hand cursor.} | |
129 | \twocolitem{{\bf wxCURSOR\_IBEAM}}{An I-beam cursor (vertical line).} | |
130 | \twocolitem{{\bf wxCURSOR\_LEFT\_BUTTON}}{Represents a mouse with the left button depressed.} | |
131 | \twocolitem{{\bf wxCURSOR\_MAGNIFIER}}{A magnifier icon.} | |
132 | \twocolitem{{\bf wxCURSOR\_MIDDLE\_BUTTON}}{Represents a mouse with the middle button depressed.} | |
133 | \twocolitem{{\bf wxCURSOR\_NO\_ENTRY}}{A no-entry sign cursor.} | |
134 | \twocolitem{{\bf wxCURSOR\_PAINT\_BRUSH}}{A paintbrush cursor.} | |
135 | \twocolitem{{\bf wxCURSOR\_PENCIL}}{A pencil cursor.} | |
136 | \twocolitem{{\bf wxCURSOR\_POINT\_LEFT}}{A cursor that points left.} | |
137 | \twocolitem{{\bf wxCURSOR\_POINT\_RIGHT}}{A cursor that points right.} | |
138 | \twocolitem{{\bf wxCURSOR\_QUESTION\_ARROW}}{An arrow and question mark.} | |
139 | \twocolitem{{\bf wxCURSOR\_RIGHT\_BUTTON}}{Represents a mouse with the right button depressed.} | |
140 | \twocolitem{{\bf wxCURSOR\_SIZENESW}}{A sizing cursor pointing NE-SW.} | |
141 | \twocolitem{{\bf wxCURSOR\_SIZENS}}{A sizing cursor pointing N-S.} | |
142 | \twocolitem{{\bf wxCURSOR\_SIZENWSE}}{A sizing cursor pointing NW-SE.} | |
143 | \twocolitem{{\bf wxCURSOR\_SIZEWE}}{A sizing cursor pointing W-E.} | |
144 | \twocolitem{{\bf wxCURSOR\_SIZING}}{A general sizing cursor.} | |
145 | \twocolitem{{\bf wxCURSOR\_SPRAYCAN}}{A spraycan cursor.} | |
146 | \twocolitem{{\bf wxCURSOR\_WAIT}}{A wait cursor.} | |
147 | \twocolitem{{\bf wxCURSOR\_WATCH}}{A watch cursor.} | |
83f96286 RD |
148 | \twocolitem{{\bf wxCURSOR\_ARROWWAIT}}{A cursor with both an arrow and |
149 | an hourglass, (windows.)} | |
a660d684 KB |
150 | \end{twocollist}\twocolwidtha{5cm} |
151 | ||
152 | Note that not all cursors are available on all platforms.} | |
153 | ||
154 | \docparam{cursor}{Pointer or reference to a cursor to copy.} | |
155 | ||
06d20283 RD |
156 | \pythonnote{Constructors supported by wxPython are:\par |
157 | \indented{2cm}{\begin{twocollist} | |
c9110876 | 158 | \twocolitem{{\bf wxCursor(name, flags, hotSpotX=0, |
06d20283 | 159 | hotSpotY=0)}}{Constructs a cursor from a filename} |
c9110876 | 160 | \twocolitem{{\bf wxStockCursor(id)}}{Constructs a stock cursor } |
06d20283 RD |
161 | \end{twocollist}} |
162 | } | |
163 | ||
5873607e VZ |
164 | \perlnote{Contructors supported by wxPerl are:\par |
165 | \begin{itemize} | |
166 | \item{Wx::Cursor->new( name, type, hotSpotX = 0, hotSpotY = 0 )} | |
167 | \item{Wx::Cursor->new( id )} | |
168 | \end{itemize} | |
169 | } | |
170 | ||
a660d684 KB |
171 | \membersection{wxCursor::\destruct{wxCursor}} |
172 | ||
173 | \func{}{\destruct{wxCursor}}{\void} | |
174 | ||
175 | Destroys the cursor. A cursor can be reused for more | |
176 | than one window, and does not get destroyed when the window is | |
177 | destroyed. wxWindows destroys all cursors on application exit, although | |
f6bcfd97 | 178 | it is best to clean them up explicitly. |
a660d684 KB |
179 | |
180 | \membersection{wxCursor::Ok}\label{wxcursorok} | |
181 | ||
182 | \constfunc{bool}{Ok}{\void} | |
183 | ||
184 | Returns TRUE if cursor data is present. | |
185 | ||
186 | \membersection{wxCursor::operator $=$}\label{wxcursorassignment} | |
187 | ||
188 | \func{wxCursor\&}{operator $=$}{\param{const wxCursor\& }{cursor}} | |
189 | ||
190 | Assignment operator, using reference counting. Returns a reference | |
191 | to `this'. | |
192 | ||
193 | \membersection{wxCursor::operator $==$}\label{wxcursorequals} | |
194 | ||
195 | \func{bool}{operator $==$}{\param{const wxCursor\& }{cursor}} | |
196 | ||
197 | Equality operator. Two cursors are equal if they contain pointers | |
198 | to the same underlying cursor data. It does not compare each attribute, | |
199 | so two independently-created cursors using the same parameters will | |
200 | fail the test. | |
201 | ||
202 | \membersection{wxCursor::operator $!=$}\label{wxcursornotequals} | |
203 | ||
204 | \func{bool}{operator $!=$}{\param{const wxCursor\& }{cursor}} | |
205 | ||
206 | Inequality operator. Two cursors are not equal if they contain pointers | |
207 | to different underlying cursor data. It does not compare each attribute. | |
208 | ||
209 |