]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: cursor.cpp | |
3 | // Purpose: wxCursor class | |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Stefan Csomor | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "cursor.h" | |
14 | #endif | |
15 | ||
16 | #include "wx/defs.h" | |
17 | ||
18 | #include "wx/app.h" | |
19 | #include "wx/cursor.h" | |
20 | #include "wx/icon.h" | |
21 | #include "wx/image.h" | |
22 | #include "wx/xpmdecod.h" | |
23 | ||
24 | #include "wx/mac/private.h" | |
25 | ||
26 | #if !USE_SHARED_LIBRARIES | |
27 | IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap) | |
28 | #endif | |
29 | ||
30 | const short kwxCursorBullseye = 0 ; | |
31 | const short kwxCursorBlank = 1 ; | |
32 | const short kwxCursorPencil = 2 ; | |
33 | const short kwxCursorMagnifier = 3 ; | |
34 | const short kwxCursorNoEntry = 4 ; | |
35 | const short kwxCursorPaintBrush = 5 ; | |
36 | const short kwxCursorPointRight = 6 ; | |
37 | const short kwxCursorPointLeft = 7 ; | |
38 | const short kwxCursorQuestionArrow = 8 ; | |
39 | const short kwxCursorRightArrow = 9 ; | |
40 | const short kwxCursorSizeNS = 10 ; | |
41 | const short kwxCursorSize = 11 ; | |
42 | const short kwxCursorSizeNESW = 12 ; | |
43 | const short kwxCursorSizeNWSE = 13 ; | |
44 | const short kwxCursorRoller = 14 ; | |
45 | const short kwxCursorLast = kwxCursorRoller ; | |
46 | ||
47 | Cursor gMacCursors[kwxCursorLast+1] = | |
48 | { | |
49 | ||
50 | { | |
51 | {0x0000, 0x03E0, 0x0630, 0x0808, 0x1004, 0x31C6, 0x2362, 0x2222, | |
52 | 0x2362, 0x31C6, 0x1004, 0x0808, 0x0630, 0x03E0, 0x0000, 0x0000}, | |
53 | {0x0000, 0x03E0, 0x07F0, 0x0FF8, 0x1FFC, 0x3FFE, 0x3FFE, 0x3FFE, | |
54 | 0x3FFE, 0x3FFE, 0x1FFC, 0x0FF8, 0x07F0, 0x03E0, 0x0000, 0x0000}, | |
55 | {0x0007, 0x0008} | |
56 | }, | |
57 | ||
58 | { | |
59 | {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | |
60 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, | |
61 | {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | |
62 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, | |
63 | {0x0000, 0x0000} | |
64 | }, | |
65 | ||
66 | { | |
67 | {0x00F0, 0x0088, 0x0108, 0x0190, 0x0270, 0x0220, 0x0440, 0x0440, | |
68 | 0x0880, 0x0880, 0x1100, 0x1E00, 0x1C00, 0x1800, 0x1000, 0x0000}, | |
69 | {0x00F0, 0x00F8, 0x01F8, 0x01F0, 0x03F0, 0x03E0, 0x07C0, 0x07C0, | |
70 | 0x0F80, 0x0F80, 0x1F00, 0x1E00, 0x1C00, 0x1800, 0x1000, 0x0000}, | |
71 | {0x000E, 0x0003} | |
72 | }, | |
73 | ||
74 | { | |
75 | {0x0000, 0x1E00, 0x2100, 0x4080, 0x4080, 0x4080, 0x4080, 0x2180, | |
76 | 0x1FC0, 0x00E0, 0x0070, 0x0038, 0x001C, 0x000E, 0x0006, 0x0000}, | |
77 | {0x3F00, 0x7F80, 0xFFC0, 0xFFC0, 0xFFC0, 0xFFC0, 0xFFC0, 0x7FC0, | |
78 | 0x3FE0, 0x1FF0, 0x00F8, 0x007C, 0x003E, 0x001F, 0x000F, 0x0007}, | |
79 | {0x0004, 0x0004} | |
80 | }, | |
81 | ||
82 | { | |
83 | {0x0000, 0x07E0, 0x1FF0, 0x3838, 0x3C0C, 0x6E0E, 0x6706, 0x6386, | |
84 | 0x61C6, 0x60E6, 0x7076, 0x303C, 0x1C1C, 0x0FF8, 0x07E0, 0x0000}, | |
85 | {0x0540, 0x0FF0, 0x3FF8, 0x3C3C, 0x7E0E, 0xFF0F, 0x6F86, 0xE7C7, | |
86 | 0x63E6, 0xE1F7, 0x70FE, 0x707E, 0x3C3C, 0x1FFC, 0x0FF0, 0x0540}, | |
87 | {0x0007, 0x0007} | |
88 | }, | |
89 | ||
90 | { | |
91 | {0x0000, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0FE0, | |
92 | 0x1FF0, 0x1FF0, 0x0000, 0x1FF0, 0x1FF0, 0x1550, 0x1550, 0x1550}, | |
93 | {0x07C0, 0x07C0, 0x07C0, 0x07C0, 0x07C0, 0x07C0, 0x0FE0, 0x1FF0, | |
94 | 0x3FF8, 0x3FF8, 0x3FF8, 0x3FF8, 0x3FF8, 0x3FF8, 0x3FF8, 0x3FF8}, | |
95 | {0x000B, 0x0007} | |
96 | }, | |
97 | ||
98 | { | |
99 | {0x00C0, 0x0140, 0x0640, 0x08C0, 0x3180, 0x47FE, 0x8001, 0x8001, | |
100 | 0x81FE, 0x8040, 0x01C0, 0x0040, 0x03C0, 0xC080, 0x3F80, 0x0000}, | |
101 | {0x00C0, 0x01C0, 0x07C0, 0x0FC0, 0x3F80, 0x7FFE, 0xFFFF, 0xFFFF, | |
102 | 0xFFFE, 0xFFC0, 0xFFC0, 0xFFC0, 0xFFC0, 0xFF80, 0x3F80, 0x0000}, | |
103 | {0x0006, 0x000F} | |
104 | }, | |
105 | ||
106 | { | |
107 | {0x0100, 0x0280, 0x0260, 0x0310, 0x018C, 0x7FE3, 0x8000, 0x8000, | |
108 | 0x7F80, 0x0200, 0x0380, 0x0200, 0x03C0, 0x0107, 0x01F8, 0x0000}, | |
109 | {0x0100, 0x0380, 0x03E0, 0x03F0, 0x01FC, 0x7FFF, 0xFFFF, 0xFFFF, | |
110 | 0xFFFF, 0x03FF, 0x03FF, 0x03FF, 0x03FF, 0x01FF, 0x01F8, 0x0000}, | |
111 | {0x0006, 0x0000} | |
112 | }, | |
113 | ||
114 | { | |
115 | {0x0000, 0x4078, 0x60FC, 0x71CE, 0x7986, 0x7C06, 0x7E0E, 0x7F1C, | |
116 | 0x7FB8, 0x7C30, 0x6C30, 0x4600, 0x0630, 0x0330, 0x0300, 0x0000}, | |
117 | {0xC078, 0xE0FC, 0xF1FE, 0xFBFF, 0xFFCF, 0xFF8F, 0xFF1F, 0xFFBE, | |
118 | 0xFFFC, 0xFE78, 0xFF78, 0xEFF8, 0xCFF8, 0x87F8, 0x07F8, 0x0300}, | |
119 | {0x0001, 0x0001} | |
120 | }, | |
121 | ||
122 | { | |
123 | {0x0000, 0x0002, 0x0006, 0x000E, 0x001E, 0x003E, 0x007E, 0x00FE, | |
124 | 0x01FE, 0x003E, 0x0036, 0x0062, 0x0060, 0x00C0, 0x00C0, 0x0000}, | |
125 | {0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, | |
126 | 0x03FF, 0x07FF, 0x007F, 0x00F7, 0x00F3, 0x01E1, 0x01E0, 0x01C0}, | |
127 | {0x0001, 0x000E} | |
128 | }, | |
129 | ||
130 | { | |
131 | {0x0000, 0x0080, 0x01C0, 0x03E0, 0x0080, 0x0080, 0x0080, 0x1FFC, | |
132 | 0x1FFC, 0x0080, 0x0080, 0x0080, 0x03E0, 0x01C0, 0x0080, 0x0000}, | |
133 | {0x0080, 0x01C0, 0x03E0, 0x07F0, 0x0FF8, 0x01C0, 0x3FFE, 0x3FFE, | |
134 | 0x3FFE, 0x3FFE, 0x01C0, 0x0FF8, 0x07F0, 0x03E0, 0x01C0, 0x0080}, | |
135 | {0x0007, 0x0008} | |
136 | }, | |
137 | ||
138 | { | |
139 | {0x0000, 0x0080, 0x01C0, 0x03E0, 0x0080, 0x0888, 0x188C, 0x3FFE, | |
140 | 0x188C, 0x0888, 0x0080, 0x03E0, 0x01C0, 0x0080, 0x0000, 0x0000}, | |
141 | {0x0080, 0x01C0, 0x03E0, 0x07F0, 0x0BE8, 0x1DDC, 0x3FFE, 0x7FFF, | |
142 | 0x3FFE, 0x1DDC, 0x0BE8, 0x07F0, 0x03E0, 0x01C0, 0x0080, 0x0000}, | |
143 | {0x0007, 0x0008} | |
144 | }, | |
145 | ||
146 | { | |
147 | {0x0000, 0x001E, 0x000E, 0x060E, 0x0712, 0x03A0, 0x01C0, 0x00E0, | |
148 | 0x0170, 0x1238, 0x1C18, 0x1C00, 0x1E00, 0x0000, 0x0000, 0x0000}, | |
149 | {0x007F, 0x003F, 0x0E1F, 0x0F0F, 0x0F97, 0x07E3, 0x03E1, 0x21F0, | |
150 | 0x31F8, 0x3A7C, 0x3C3C, 0x3E1C, 0x3F00, 0x3F80, 0x0000, 0x0000}, | |
151 | {0x0006, 0x0009} | |
152 | }, | |
153 | ||
154 | { | |
155 | {0x0000, 0x7800, 0x7000, 0x7060, 0x48E0, 0x05C0, 0x0380, 0x0700, | |
156 | 0x0E80, 0x1C48, 0x1838, 0x0038, 0x0078, 0x0000, 0x0000, 0x0000}, | |
157 | {0xFE00, 0xFC00, 0xF870, 0xF0F0, 0xE9F0, 0xC7E0, 0x87C0, 0x0F84, | |
158 | 0x1F8C, 0x3E5C, 0x3C3C, 0x387C, 0x00FC, 0x01FC, 0x0000, 0x0000}, | |
159 | {0x0006, 0x0006} | |
160 | }, | |
161 | ||
162 | { | |
163 | {0x0006, 0x000E, 0x001C, 0x0018, 0x0020, 0x0040, 0x00F8, 0x0004, | |
164 | 0x1FF4, 0x200C, 0x2AA8, 0x1FF0, 0x1F80, 0x3800, 0x6000, 0x8000}, | |
165 | {0x000F, 0x001F, 0x003E, 0x007C, 0x0070, 0x00E0, 0x01FC, 0x3FF6, | |
166 | 0x7FF6, 0x7FFE, 0x7FFC, 0x7FF8, 0x3FF0, 0x7FC0, 0xF800, 0xE000}, | |
167 | {0x000A, 0x0006} | |
168 | }, | |
169 | ||
170 | } ; | |
171 | ||
172 | wxCursor gMacCurrentCursor ; | |
173 | ||
174 | CursHandle wxGetStockCursor( int number ) | |
175 | { | |
176 | wxASSERT_MSG( number >= 0 && number <=kwxCursorLast , wxT("invalid stock cursor id") ) ; | |
177 | CursHandle c = (CursHandle) NewHandle( sizeof(Cursor) ) ; | |
178 | memcpy( *c , &gMacCursors[number] , sizeof( Cursor ) ) ; | |
179 | return c ; | |
180 | } | |
181 | ||
182 | wxCursorRefData::wxCursorRefData() | |
183 | { | |
184 | m_width = 16; | |
185 | m_height = 16; | |
186 | m_hCursor = NULL ; | |
187 | m_disposeHandle = false ; | |
188 | m_releaseHandle = false ; | |
189 | m_isColorCursor = false ; | |
190 | m_themeCursor = -1 ; | |
191 | } | |
192 | ||
193 | wxCursorRefData::~wxCursorRefData() | |
194 | { | |
195 | if ( m_isColorCursor ) | |
196 | { | |
197 | ::DisposeCCursor( (CCrsrHandle) m_hCursor ) ; | |
198 | } | |
199 | else if ( m_disposeHandle ) | |
200 | { | |
201 | ::DisposeHandle( (Handle ) m_hCursor ) ; | |
202 | } | |
203 | else if ( m_releaseHandle ) | |
204 | { | |
205 | // we don't release the resource since it may already | |
206 | // be in use again | |
207 | } | |
208 | } | |
209 | ||
210 | // Cursors | |
211 | wxCursor::wxCursor() | |
212 | { | |
213 | } | |
214 | ||
215 | wxCursor::wxCursor(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height), | |
216 | int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY), const char WXUNUSED(maskBits)[]) | |
217 | { | |
218 | } | |
219 | ||
220 | wxCursor::wxCursor( const wxImage &image ) | |
221 | { | |
222 | CreateFromImage( image ) ; | |
223 | } | |
224 | ||
225 | wxCursor::wxCursor(const char **bits) | |
226 | { | |
227 | (void) CreateFromXpm(bits); | |
228 | } | |
229 | ||
230 | wxCursor::wxCursor(char **bits) | |
231 | { | |
232 | (void) CreateFromXpm((const char **)bits); | |
233 | } | |
234 | ||
235 | bool wxCursor::CreateFromXpm(const char **bits) | |
236 | { | |
237 | wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid cursor data") ) | |
238 | wxXPMDecoder decoder; | |
239 | wxImage img = decoder.ReadData(bits); | |
240 | wxCHECK_MSG( img.Ok(), FALSE, wxT("invalid cursor data") ) | |
241 | CreateFromImage( img ) ; | |
242 | return TRUE; | |
243 | } | |
244 | ||
245 | short GetCTabIndex( CTabHandle colors , RGBColor *col ) | |
246 | { | |
247 | short retval = 0 ; | |
248 | unsigned long bestdiff = 0xFFFF ; | |
249 | for ( int i = 0 ; i < (**colors).ctSize ; ++i ) | |
250 | { | |
251 | unsigned long diff = abs(col->red - (**colors).ctTable[i].rgb.red ) + | |
252 | abs(col->green - (**colors).ctTable[i].rgb.green ) + | |
253 | abs(col->blue - (**colors).ctTable[i].rgb.blue ) ; | |
254 | if ( diff < bestdiff ) | |
255 | { | |
256 | bestdiff = diff ; | |
257 | retval = (**colors).ctTable[i].value ; | |
258 | } | |
259 | } | |
260 | return retval ; | |
261 | } | |
262 | ||
263 | void wxCursor::CreateFromImage(const wxImage & image) | |
264 | { | |
265 | m_refData = new wxCursorRefData; | |
266 | ||
267 | wxImage image16 = image.Scale(16,16) ; | |
268 | unsigned char * rgbBits = image16.GetData(); | |
269 | ||
270 | ||
271 | int w = image16.GetWidth() ; | |
272 | int h = image16.GetHeight() ; | |
273 | bool bHasMask = image16.HasMask() ; | |
274 | ||
275 | int hotSpotX = image16.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X); | |
276 | int hotSpotY = image16.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y); | |
277 | if (hotSpotX < 0 || hotSpotX >= w) | |
278 | hotSpotX = 0; | |
279 | if (hotSpotY < 0 || hotSpotY >= h) | |
280 | hotSpotY = 0; | |
281 | ||
282 | PixMapHandle pm = (PixMapHandle) NewHandleClear( sizeof (PixMap)) ; | |
283 | short extent = 16 ; | |
284 | short bytesPerPixel = 1 ; | |
285 | short depth = 8 ; | |
286 | Rect bounds = { 0 , 0 , extent , extent } ; | |
287 | CCrsrHandle ch = (CCrsrHandle) NewHandleClear ( sizeof( CCrsr ) ) ; | |
288 | CTabHandle newColors = GetCTable( 8 ) ; | |
289 | HandToHand((Handle *) &newColors); | |
290 | // set the values to the indices | |
291 | for ( int i = 0 ; i < (**newColors).ctSize ; ++i ) | |
292 | { | |
293 | (**newColors).ctTable[i].value = i ; | |
294 | } | |
295 | HLock( (Handle) ch) ; | |
296 | (**ch).crsrType = 0x8001 ; // color cursors | |
297 | (**ch).crsrMap = pm ; | |
298 | short bytesPerRow = bytesPerPixel * extent ; | |
299 | ||
300 | (**pm).baseAddr = 0; | |
301 | (**pm).rowBytes = bytesPerRow | 0x8000; | |
302 | (**pm).bounds = bounds; | |
303 | (**pm).pmVersion = 0; | |
304 | (**pm).packType = 0; | |
305 | (**pm).packSize = 0; | |
306 | (**pm).hRes = 0x00480000; /* 72 DPI default res */ | |
307 | (**pm).vRes = 0x00480000; /* 72 DPI default res */ | |
308 | (**pm).pixelSize = depth; | |
309 | (**pm).pixelType = 0; | |
310 | (**pm).cmpCount = 1; | |
311 | (**pm).cmpSize = depth; | |
312 | (**pm).pmTable = newColors; | |
313 | ||
314 | (**ch).crsrData = NewHandleClear( extent * bytesPerRow ) ; | |
315 | (**ch).crsrXData = NULL ; | |
316 | (**ch).crsrXValid = 0; | |
317 | (**ch).crsrXHandle = NULL; | |
318 | ||
319 | (**ch).crsrHotSpot.h = hotSpotX ; | |
320 | (**ch).crsrHotSpot.v = hotSpotY ; | |
321 | (**ch).crsrXTable = NULL ; | |
322 | (**ch).crsrID = GetCTSeed() ; | |
323 | ||
324 | memset( (**ch).crsr1Data , 0 , sizeof( Bits16 ) ) ; | |
325 | memset( (**ch).crsrMask , 0 , sizeof( Bits16 ) ) ; | |
326 | ||
327 | unsigned char mr = image16.GetMaskRed() ; | |
328 | unsigned char mg = image16.GetMaskGreen() ; | |
329 | unsigned char mb = image16.GetMaskBlue() ; | |
330 | for ( int y = 0 ; y < h ; ++y ) | |
331 | { | |
332 | short rowbits = 0 ; | |
333 | short maskbits = 0 ; | |
334 | ||
335 | for ( int x = 0 ; x < w ; ++x ) | |
336 | { | |
337 | long pos = (y * w + x) * 3; | |
338 | ||
339 | unsigned char r = rgbBits[pos] ; | |
340 | unsigned char g = rgbBits[pos+1] ; | |
341 | unsigned char b = rgbBits[pos+2] ; | |
342 | RGBColor col = { 0xFFFF ,0xFFFF, 0xFFFF } ; | |
343 | ||
344 | if ( bHasMask && r==mr && g==mg && b==mb ) | |
345 | { | |
346 | // masked area, does not appear anywhere | |
347 | } | |
348 | else | |
349 | { | |
350 | if ( (int)r + (int)g + (int)b < 0x0200 ) | |
351 | { | |
352 | rowbits |= ( 1 << (15-x) ) ; | |
353 | } | |
354 | maskbits |= ( 1 << (15-x) ) ; | |
355 | ||
356 | col = *((RGBColor*) wxColor( r , g , b ).GetPixel()) ; | |
357 | } | |
358 | *((*(**ch).crsrData) + y * bytesPerRow + x) = | |
359 | GetCTabIndex( newColors , &col) ; | |
360 | } | |
361 | (**ch).crsr1Data[y] = rowbits ; | |
362 | (**ch).crsrMask[y] = maskbits ; | |
363 | } | |
364 | if ( !bHasMask ) | |
365 | { | |
366 | memcpy( (**ch).crsrMask , (**ch).crsr1Data , sizeof( Bits16) ) ; | |
367 | } | |
368 | ||
369 | HUnlock((Handle) ch) ; | |
370 | M_CURSORDATA->m_hCursor = ch ; | |
371 | M_CURSORDATA->m_isColorCursor = true ; | |
372 | } | |
373 | ||
374 | wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int hotSpotY) | |
375 | { | |
376 | m_refData = new wxCursorRefData; | |
377 | if ( flags == wxBITMAP_TYPE_MACCURSOR_RESOURCE ) | |
378 | { | |
379 | Str255 theName ; | |
380 | wxMacStringToPascal( cursor_file , theName ) ; | |
381 | ||
382 | Handle resHandle = ::GetNamedResource( 'crsr' , theName ) ; | |
383 | if ( resHandle ) | |
384 | { | |
385 | short theId = -1 ; | |
386 | OSType theType ; | |
387 | GetResInfo( resHandle , &theId , &theType , theName ) ; | |
388 | ReleaseResource( resHandle ) ; | |
389 | M_CURSORDATA->m_hCursor = GetCCursor( theId ) ; | |
390 | if ( M_CURSORDATA->m_hCursor ) | |
391 | M_CURSORDATA->m_isColorCursor = true ; | |
392 | } | |
393 | else | |
394 | { | |
395 | Handle resHandle = ::GetNamedResource( 'CURS' , theName ) ; | |
396 | if ( resHandle ) | |
397 | { | |
398 | short theId = -1 ; | |
399 | OSType theType ; | |
400 | GetResInfo( resHandle , &theId , &theType , theName ) ; | |
401 | ReleaseResource( resHandle ) ; | |
402 | M_CURSORDATA->m_hCursor = GetCursor( theId ) ; | |
403 | if ( M_CURSORDATA->m_hCursor ) | |
404 | M_CURSORDATA->m_releaseHandle = true ; | |
405 | } | |
406 | } | |
407 | } | |
408 | else | |
409 | { | |
410 | wxImage image ; | |
411 | image.LoadFile( cursor_file , flags ) ; | |
412 | if( image.Ok() ) | |
413 | { | |
414 | image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X,hotSpotX ) ; | |
415 | image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y,hotSpotY ) ; | |
416 | delete m_refData ; | |
417 | CreateFromImage(image) ; | |
418 | } | |
419 | } | |
420 | } | |
421 | ||
422 | // Cursors by stock number | |
423 | wxCursor::wxCursor(int cursor_type) | |
424 | { | |
425 | m_refData = new wxCursorRefData; | |
426 | ||
427 | switch (cursor_type) | |
428 | { | |
429 | case wxCURSOR_COPY_ARROW: | |
430 | M_CURSORDATA->m_themeCursor = kThemeCopyArrowCursor ; | |
431 | break; | |
432 | case wxCURSOR_WAIT: | |
433 | M_CURSORDATA->m_themeCursor = kThemeWatchCursor ; | |
434 | break; | |
435 | case wxCURSOR_IBEAM: | |
436 | M_CURSORDATA->m_themeCursor = kThemeIBeamCursor ; | |
437 | break; | |
438 | case wxCURSOR_CROSS: | |
439 | M_CURSORDATA->m_themeCursor = kThemeCrossCursor; | |
440 | break; | |
441 | case wxCURSOR_SIZENWSE: | |
442 | { | |
443 | M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNWSE); | |
444 | } | |
445 | break; | |
446 | case wxCURSOR_SIZENESW: | |
447 | { | |
448 | M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNESW); | |
449 | } | |
450 | break; | |
451 | case wxCURSOR_SIZEWE: | |
452 | { | |
453 | M_CURSORDATA->m_themeCursor = kThemeResizeLeftRightCursor; | |
454 | } | |
455 | break; | |
456 | case wxCURSOR_SIZENS: | |
457 | { | |
458 | M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSizeNS); | |
459 | } | |
460 | break; | |
461 | case wxCURSOR_SIZING: | |
462 | { | |
463 | M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorSize); | |
464 | } | |
465 | break; | |
466 | case wxCURSOR_HAND: | |
467 | { | |
468 | M_CURSORDATA->m_themeCursor = kThemePointingHandCursor; | |
469 | } | |
470 | break; | |
471 | case wxCURSOR_BULLSEYE: | |
472 | { | |
473 | M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorBullseye); | |
474 | } | |
475 | break; | |
476 | case wxCURSOR_PENCIL: | |
477 | { | |
478 | M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPencil); | |
479 | } | |
480 | break; | |
481 | case wxCURSOR_MAGNIFIER: | |
482 | { | |
483 | M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorMagnifier); | |
484 | } | |
485 | break; | |
486 | case wxCURSOR_NO_ENTRY: | |
487 | { | |
488 | M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorNoEntry); | |
489 | } | |
490 | break; | |
491 | case wxCURSOR_WATCH: | |
492 | { | |
493 | M_CURSORDATA->m_themeCursor = kThemeWatchCursor; | |
494 | break; | |
495 | } | |
496 | case wxCURSOR_PAINT_BRUSH: | |
497 | { | |
498 | M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPaintBrush); | |
499 | break; | |
500 | } | |
501 | case wxCURSOR_POINT_LEFT: | |
502 | { | |
503 | M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPointLeft); | |
504 | break; | |
505 | } | |
506 | case wxCURSOR_POINT_RIGHT: | |
507 | { | |
508 | M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorPointRight); | |
509 | break; | |
510 | } | |
511 | case wxCURSOR_QUESTION_ARROW: | |
512 | { | |
513 | M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorQuestionArrow); | |
514 | break; | |
515 | } | |
516 | case wxCURSOR_BLANK: | |
517 | { | |
518 | M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorBlank); | |
519 | break; | |
520 | } | |
521 | case wxCURSOR_RIGHT_ARROW: | |
522 | { | |
523 | M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorRightArrow); | |
524 | break; | |
525 | } | |
526 | case wxCURSOR_SPRAYCAN: | |
527 | { | |
528 | M_CURSORDATA->m_hCursor = wxGetStockCursor(kwxCursorRoller); | |
529 | break; | |
530 | } | |
531 | case wxCURSOR_CHAR: | |
532 | case wxCURSOR_ARROW: | |
533 | case wxCURSOR_LEFT_BUTTON: | |
534 | case wxCURSOR_RIGHT_BUTTON: | |
535 | case wxCURSOR_MIDDLE_BUTTON: | |
536 | default: | |
537 | M_CURSORDATA->m_themeCursor = kThemeArrowCursor ; | |
538 | break; | |
539 | } | |
540 | if ( M_CURSORDATA->m_themeCursor == -1 ) | |
541 | M_CURSORDATA->m_releaseHandle = true ; | |
542 | } | |
543 | ||
544 | void wxCursor::MacInstall() const | |
545 | { | |
546 | gMacCurrentCursor = *this ; | |
547 | if ( m_refData && M_CURSORDATA->m_themeCursor != -1 ) | |
548 | { | |
549 | SetThemeCursor( M_CURSORDATA->m_themeCursor ) ; | |
550 | } | |
551 | else if ( m_refData && M_CURSORDATA->m_hCursor ) | |
552 | { | |
553 | if ( M_CURSORDATA->m_isColorCursor ) | |
554 | ::SetCCursor( (CCrsrHandle) M_CURSORDATA->m_hCursor ) ; | |
555 | else | |
556 | ::SetCursor( * (CursHandle) M_CURSORDATA->m_hCursor ) ; | |
557 | } | |
558 | else | |
559 | { | |
560 | SetThemeCursor( kThemeArrowCursor ) ; | |
561 | } | |
562 | } | |
563 | ||
564 | wxCursor::~wxCursor() | |
565 | { | |
566 | } | |
567 | ||
568 | // Global cursor setting | |
569 | void wxSetCursor(const wxCursor& cursor) | |
570 | { | |
571 | cursor.MacInstall() ; | |
572 | } | |
573 | ||
574 |