]> git.saurik.com Git - wxWidgets.git/blame_incremental - interface/wx/cursor.h
Implement setFont on the iOS port of wxStaticText.
[wxWidgets.git] / interface / wx / cursor.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: cursor.h
3// Purpose: interface of wxCursor
4// Author: wxWidgets team
5// Licence: wxWindows licence
6/////////////////////////////////////////////////////////////////////////////
7
8/**
9 @class wxCursor
10
11 A cursor is a small bitmap usually used for denoting where the mouse
12 pointer is, with a picture that might indicate the interpretation of a
13 mouse click. As with icons, cursors in X and MS Windows are created in a
14 different manner. Therefore, separate cursors will be created for the
15 different environments. Platform-specific methods for creating a wxCursor
16 object are catered for, and this is an occasion where conditional
17 compilation will probably be required (see wxIcon for an example).
18
19 A single cursor object may be used in many windows (any subwindow type).
20 The wxWidgets convention is to set the cursor for a window, as in X, rather
21 than to set it globally as in MS Windows, although a global wxSetCursor()
22 function is also available for MS Windows use.
23
24 @section cursor_custom Creating a Custom Cursor
25
26 The following is an example of creating a cursor from 32x32 bitmap data
27 (down_bits) and a mask (down_mask) where 1 is black and 0 is white for the
28 bits, and 1 is opaque and 0 is transparent for the mask.
29 It works on Windows and GTK+.
30
31 @code
32 static char down_bits[] = { 255, 255, 255, 255, 31,
33 255, 255, 255, 31, 255, 255, 255, 31, 255, 255, 255,
34 31, 255, 255, 255, 31, 255, 255, 255, 31, 255, 255,
35 255, 31, 255, 255, 255, 31, 255, 255, 255, 25, 243,
36 255, 255, 19, 249, 255, 255, 7, 252, 255, 255, 15, 254,
37 255, 255, 31, 255, 255, 255, 191, 255, 255, 255, 255,
38 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
39 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
40 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
41 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
42 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
43 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
44 255 };
45
46 static char down_mask[] = { 240, 1, 0, 0, 240, 1,
47 0, 0, 240, 1, 0, 0, 240, 1, 0, 0, 240, 1, 0, 0, 240, 1,
48 0, 0, 240, 1, 0, 0, 240, 1, 0, 0, 255, 31, 0, 0, 255,
49 31, 0, 0, 254, 15, 0, 0, 252, 7, 0, 0, 248, 3, 0, 0,
50 240, 1, 0, 0, 224, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0,
51 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
52 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
53 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
54 0, 0, 0, 0, 0 };
55
56 #ifdef __WXMSW__
57 wxBitmap down_bitmap(down_bits, 32, 32);
58 wxBitmap down_mask_bitmap(down_mask, 32, 32);
59
60 down_bitmap.SetMask(new wxMask(down_mask_bitmap));
61 wxImage down_image = down_bitmap.ConvertToImage();
62 down_image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, 6);
63 down_image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, 14);
64 wxCursor down_cursor = wxCursor(down_image);
65 #elif defined(__WXGTK__) or defined(__WXMOTIF__)
66 wxCursor down_cursor = wxCursor(down_bits, 32, 32, 6, 14,
67 down_mask, wxWHITE, wxBLACK);
68 #endif
69 @endcode
70
71 @library{wxcore}
72 @category{gdi}
73
74 @stdobjects
75 - ::wxNullCursor
76 - ::wxSTANDARD_CURSOR
77 - ::wxHOURGLASS_CURSOR
78 - ::wxCROSS_CURSOR
79
80 @see wxBitmap, wxIcon, wxWindow::SetCursor(), wxSetCursor(), ::wxStockCursor
81*/
82class wxCursor : public wxGDIObject
83{
84public:
85 /**
86 Default constructor.
87 */
88 wxCursor();
89
90 /**
91 Constructs a cursor by passing an array of bits (XBM data).
92
93 The parameters @a fg and @a bg have an effect only on GTK+, and force
94 the cursor to use particular background and foreground colours.
95
96 If either @a hotSpotX or @a hotSpotY is -1, the hotspot will be the
97 centre of the cursor image (Motif only).
98
99 @param bits
100 An array of XBM data bits.
101 @param width
102 Cursor width.
103 @param height
104 Cursor height.
105 @param hotSpotX
106 Hotspot x coordinate (relative to the top left of the image).
107 @param hotSpotY
108 Hotspot y coordinate (relative to the top left of the image).
109 @param maskBits
110 Bits for a mask bitmap.
111
112 @onlyfor{wxgtk,wxmotif}
113
114 @beginWxPerlOnly
115 In wxPerl use Wx::Cursor->newData(bits, width, height, hotSpotX = -1, hotSpotY = -1, maskBits = 0).
116 @endWxPerlOnly
117 */
118 wxCursor(const char bits[], int width, int height,
119 int hotSpotX = -1, int hotSpotY = -1,
120 const char maskBits[] = NULL);
121
122 /**
123 Constructs a cursor by passing a string resource name or filename.
124
125 The arguments @a hotSpotX and @a hotSpotY are only used when there's no
126 hotspot info in the resource/image-file to load (e.g. when using
127 @c wxBITMAP_TYPE_ICO under wxMSW or @c wxBITMAP_TYPE_XPM under wxGTK).
128
129 @param cursorName
130 The name of the resource or the image file to load.
131 @param type
132 Icon type to load. It defaults to @c wxCURSOR_DEFAULT_TYPE,
133 which is a @#define associated to different values on different
134 platforms:
135 - under Windows, it defaults to @c wxBITMAP_TYPE_CUR_RESOURCE.
136 Other permitted types under Windows are @c wxBITMAP_TYPE_CUR
137 (to load a cursor from a .cur cursor file), @c wxBITMAP_TYPE_ICO
138 (to load a cursor from a .ico icon file) and @c wxBITMAP_TYPE_ANI
139 (to load a cursor from a .ani icon file).
140 - under MacOS, it defaults to @c wxBITMAP_TYPE_MACCURSOR_RESOURCE;
141 when specifying a string resource name, first the color cursors 'crsr'
142 and then the black/white cursors 'CURS' in the resource chain are scanned
143 through. Note that resource forks are deprecated on OS X so this
144 is only available for legacy reasons and should not be used in
145 new code.
146 - under GTK, it defaults to @c wxBITMAP_TYPE_XPM.
147 See the wxCursor(const wxImage& image) ctor for more info.
148 - under X11, it defaults to @c wxBITMAP_TYPE_XPM.
149 - under Motif, it defaults to @c wxBITMAP_TYPE_XBM.
150 @param hotSpotX
151 Hotspot x coordinate (relative to the top left of the image).
152 @param hotSpotY
153 Hotspot y coordinate (relative to the top left of the image).
154 */
155 wxCursor(const wxString& cursorName,
156 wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
157 int hotSpotX = 0, int hotSpotY = 0);
158
159 /**
160 Constructs a cursor using a cursor identifier.
161
162 @param cursorId
163 A stock cursor identifier. See ::wxStockCursor.
164 */
165 wxCursor(wxStockCursor cursorId);
166
167 /**
168 Constructs a cursor from a wxImage. If cursor are monochrome on the
169 current platform, colors with the RGB elements all greater than 127
170 will be foreground, colors less than this background. The mask (if any)
171 will be used to specify the transparent area.
172
173 In wxMSW the foreground will be white and the background black.
174 If the cursor is larger than 32x32 it is resized.
175
176 In wxGTK, colour cursors and alpha channel are supported (starting from
177 GTK+ 2.2). Otherwise the two most frequent colors will be used for
178 foreground and background. In any case, the cursor will be displayed
179 at the size of the image.
180
181 Under wxMac (Cocoa), large cursors are supported.
182
183 Notice that the @a image can define the cursor hot spot. To set it you
184 need to use wxImage::SetOption() with @c wxIMAGE_OPTION_CUR_HOTSPOT_X
185 or @c wxIMAGE_OPTION_CUR_HOTSPOT_Y, e.g.
186 @code
187 image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, hotSpotX);
188 image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, hotSpotY);
189 @endcode
190 */
191 wxCursor(const wxImage& image);
192
193 /**
194 Copy constructor, uses @ref overview_refcount "reference counting".
195
196 @param cursor
197 Pointer or reference to a cursor to copy.
198 */
199 wxCursor(const wxCursor& cursor);
200
201 /**
202 Destroys the cursor. See
203 @ref overview_refcount_destruct "reference-counted object destruction"
204 for more info.
205
206 A cursor can be reused for more than one window, and does not get
207 destroyed when the window is destroyed. wxWidgets destroys all cursors
208 on application exit, although it is best to clean them up explicitly.
209 */
210 virtual ~wxCursor();
211
212 /**
213 Returns @true if cursor data is present.
214 */
215 virtual bool IsOk() const;
216
217 /**
218 Assignment operator, using @ref overview_refcount "reference counting".
219 */
220 wxCursor& operator =(const wxCursor& cursor);
221};
222
223
224/**
225 @name Predefined cursors.
226
227 @see wxStockCursor
228*/
229//@{
230wxCursor wxNullCursor;
231wxCursor* wxSTANDARD_CURSOR;
232wxCursor* wxHOURGLASS_CURSOR;
233wxCursor* wxCROSS_CURSOR;
234//@}
235