]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/cursor.mm
Remove duplicate wxFileKind definition from documentation.
[wxWidgets.git] / src / cocoa / cursor.mm
CommitLineData
a24aff65 1/////////////////////////////////////////////////////////////////////////////
c8326d64 2// Name: src/cocoa/cursor.mm
5558135c
RN
3// Purpose: wxCursor class for wxCocoa
4// Author: Ryan Norton
fe686e5a 5// David Elliott
a24aff65 6// Modified by:
5558135c 7// Created: 2004-10-05
a24aff65 8// RCS-ID: $Id$
5558135c 9// Copyright: (c) Ryan Norton
fe686e5a 10// 2007, Software 2000 Ltd.
526954c5 11// Licence: wxWindows licence
a24aff65
DE
12/////////////////////////////////////////////////////////////////////////////
13
449c5673 14#include "wx/wxprec.h"
c8326d64
WS
15
16#include "wx/cursor.h"
17
449c5673
DE
18#ifndef WX_PRECOMP
19 #include "wx/icon.h"
69659fd7 20 #include "wx/log.h"
449c5673 21#endif //WX_PRECOMP
a24aff65 22
5558135c
RN
23#import <AppKit/NSCursor.h>
24#import <AppKit/NSImage.h>
d8418952 25#include "wx/cocoa/string.h"
69659fd7 26#include "wx/cocoa/autorelease.h"
5558135c 27
a24aff65 28IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
a24aff65 29
06386448
RN
30typedef struct tagClassicCursor
31{
32 wxUint16 bits[16];
33 wxUint16 mask[16];
08264272 34 wxInt16 hotspot[2];
06386448
RN
35}ClassicCursor;
36
fe686e5a 37///////////////////////////////////////////////////////////////////////////
526954c5 38// This is a direct copy from src/osx/carbon/cursor.cpp and should be
fe686e5a
DE
39// changed to use common code if we plan on keeping it this way.
40// Note that this is basically an array of classic 'CURS' resources.
41
06386448
RN
42const short kwxCursorBullseye = 0 ;
43const short kwxCursorBlank = 1 ;
44const short kwxCursorPencil = 2 ;
45const short kwxCursorMagnifier = 3 ;
46const short kwxCursorNoEntry = 4 ;
47const short kwxCursorPaintBrush = 5 ;
48const short kwxCursorPointRight = 6 ;
49const short kwxCursorPointLeft = 7 ;
50const short kwxCursorQuestionArrow = 8 ;
51const short kwxCursorRightArrow = 9 ;
52const short kwxCursorSizeNS = 10 ;
53const short kwxCursorSize = 11 ;
54const short kwxCursorSizeNESW = 12 ;
55const short kwxCursorSizeNWSE = 13 ;
56const short kwxCursorRoller = 14 ;
57const short kwxCursorLast = kwxCursorRoller ;
58
59ClassicCursor gMacCursors[kwxCursorLast+1] =
60{
61
62{
63{0x0000, 0x03E0, 0x0630, 0x0808, 0x1004, 0x31C6, 0x2362, 0x2222,
640x2362, 0x31C6, 0x1004, 0x0808, 0x0630, 0x03E0, 0x0000, 0x0000},
65{0x0000, 0x03E0, 0x07F0, 0x0FF8, 0x1FFC, 0x3FFE, 0x3FFE, 0x3FFE,
660x3FFE, 0x3FFE, 0x1FFC, 0x0FF8, 0x07F0, 0x03E0, 0x0000, 0x0000},
67{0x0007, 0x0008}
68},
69
70{
71{0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
720x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000},
73{0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
740x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000},
75{0x0000, 0x0000}
76},
77
78{
79{0x00F0, 0x0088, 0x0108, 0x0190, 0x0270, 0x0220, 0x0440, 0x0440,
800x0880, 0x0880, 0x1100, 0x1E00, 0x1C00, 0x1800, 0x1000, 0x0000},
81{0x00F0, 0x00F8, 0x01F8, 0x01F0, 0x03F0, 0x03E0, 0x07C0, 0x07C0,
820x0F80, 0x0F80, 0x1F00, 0x1E00, 0x1C00, 0x1800, 0x1000, 0x0000},
83{0x000E, 0x0003}
84},
85
86{
87{0x0000, 0x1E00, 0x2100, 0x4080, 0x4080, 0x4080, 0x4080, 0x2180,
880x1FC0, 0x00E0, 0x0070, 0x0038, 0x001C, 0x000E, 0x0006, 0x0000},
89{0x3F00, 0x7F80, 0xFFC0, 0xFFC0, 0xFFC0, 0xFFC0, 0xFFC0, 0x7FC0,
900x3FE0, 0x1FF0, 0x00F8, 0x007C, 0x003E, 0x001F, 0x000F, 0x0007},
91{0x0004, 0x0004}
92},
93
94{
95{0x0000, 0x07E0, 0x1FF0, 0x3838, 0x3C0C, 0x6E0E, 0x6706, 0x6386,
960x61C6, 0x60E6, 0x7076, 0x303C, 0x1C1C, 0x0FF8, 0x07E0, 0x0000},
97{0x0540, 0x0FF0, 0x3FF8, 0x3C3C, 0x7E0E, 0xFF0F, 0x6F86, 0xE7C7,
980x63E6, 0xE1F7, 0x70FE, 0x707E, 0x3C3C, 0x1FFC, 0x0FF0, 0x0540},
99{0x0007, 0x0007}
100},
101
102{
103{0x0000, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0FE0,
1040x1FF0, 0x1FF0, 0x0000, 0x1FF0, 0x1FF0, 0x1550, 0x1550, 0x1550},
105{0x07C0, 0x07C0, 0x07C0, 0x07C0, 0x07C0, 0x07C0, 0x0FE0, 0x1FF0,
1060x3FF8, 0x3FF8, 0x3FF8, 0x3FF8, 0x3FF8, 0x3FF8, 0x3FF8, 0x3FF8},
107{0x000B, 0x0007}
108},
109
110{
111{0x00C0, 0x0140, 0x0640, 0x08C0, 0x3180, 0x47FE, 0x8001, 0x8001,
1120x81FE, 0x8040, 0x01C0, 0x0040, 0x03C0, 0xC080, 0x3F80, 0x0000},
113{0x00C0, 0x01C0, 0x07C0, 0x0FC0, 0x3F80, 0x7FFE, 0xFFFF, 0xFFFF,
1140xFFFE, 0xFFC0, 0xFFC0, 0xFFC0, 0xFFC0, 0xFF80, 0x3F80, 0x0000},
115{0x0006, 0x000F}
116},
117
118{
119{0x0100, 0x0280, 0x0260, 0x0310, 0x018C, 0x7FE3, 0x8000, 0x8000,
1200x7F80, 0x0200, 0x0380, 0x0200, 0x03C0, 0x0107, 0x01F8, 0x0000},
121{0x0100, 0x0380, 0x03E0, 0x03F0, 0x01FC, 0x7FFF, 0xFFFF, 0xFFFF,
1220xFFFF, 0x03FF, 0x03FF, 0x03FF, 0x03FF, 0x01FF, 0x01F8, 0x0000},
123{0x0006, 0x0000}
124},
125
126{
127{0x0000, 0x4078, 0x60FC, 0x71CE, 0x7986, 0x7C06, 0x7E0E, 0x7F1C,
1280x7FB8, 0x7C30, 0x6C30, 0x4600, 0x0630, 0x0330, 0x0300, 0x0000},
129{0xC078, 0xE0FC, 0xF1FE, 0xFBFF, 0xFFCF, 0xFF8F, 0xFF1F, 0xFFBE,
1300xFFFC, 0xFE78, 0xFF78, 0xEFF8, 0xCFF8, 0x87F8, 0x07F8, 0x0300},
131{0x0001, 0x0001}
132},
133
134{
135{0x0000, 0x0002, 0x0006, 0x000E, 0x001E, 0x003E, 0x007E, 0x00FE,
1360x01FE, 0x003E, 0x0036, 0x0062, 0x0060, 0x00C0, 0x00C0, 0x0000},
137{0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF,
1380x03FF, 0x07FF, 0x007F, 0x00F7, 0x00F3, 0x01E1, 0x01E0, 0x01C0},
139{0x0001, 0x000E}
140},
141
142{
143{0x0000, 0x0080, 0x01C0, 0x03E0, 0x0080, 0x0080, 0x0080, 0x1FFC,
1440x1FFC, 0x0080, 0x0080, 0x0080, 0x03E0, 0x01C0, 0x0080, 0x0000},
145{0x0080, 0x01C0, 0x03E0, 0x07F0, 0x0FF8, 0x01C0, 0x3FFE, 0x3FFE,
1460x3FFE, 0x3FFE, 0x01C0, 0x0FF8, 0x07F0, 0x03E0, 0x01C0, 0x0080},
147{0x0007, 0x0008}
148},
149
150{
151{0x0000, 0x0080, 0x01C0, 0x03E0, 0x0080, 0x0888, 0x188C, 0x3FFE,
1520x188C, 0x0888, 0x0080, 0x03E0, 0x01C0, 0x0080, 0x0000, 0x0000},
153{0x0080, 0x01C0, 0x03E0, 0x07F0, 0x0BE8, 0x1DDC, 0x3FFE, 0x7FFF,
1540x3FFE, 0x1DDC, 0x0BE8, 0x07F0, 0x03E0, 0x01C0, 0x0080, 0x0000},
155{0x0007, 0x0008}
156},
157
158{
159{0x0000, 0x001E, 0x000E, 0x060E, 0x0712, 0x03A0, 0x01C0, 0x00E0,
1600x0170, 0x1238, 0x1C18, 0x1C00, 0x1E00, 0x0000, 0x0000, 0x0000},
161{0x007F, 0x003F, 0x0E1F, 0x0F0F, 0x0F97, 0x07E3, 0x03E1, 0x21F0,
1620x31F8, 0x3A7C, 0x3C3C, 0x3E1C, 0x3F00, 0x3F80, 0x0000, 0x0000},
163{0x0006, 0x0009}
164},
165
166{
167{0x0000, 0x7800, 0x7000, 0x7060, 0x48E0, 0x05C0, 0x0380, 0x0700,
1680x0E80, 0x1C48, 0x1838, 0x0038, 0x0078, 0x0000, 0x0000, 0x0000},
169{0xFE00, 0xFC00, 0xF870, 0xF0F0, 0xE9F0, 0xC7E0, 0x87C0, 0x0F84,
1700x1F8C, 0x3E5C, 0x3C3C, 0x387C, 0x00FC, 0x01FC, 0x0000, 0x0000},
171{0x0006, 0x0006}
172},
173
174{
175{0x0006, 0x000E, 0x001C, 0x0018, 0x0020, 0x0040, 0x00F8, 0x0004,
1760x1FF4, 0x200C, 0x2AA8, 0x1FF0, 0x1F80, 0x3800, 0x6000, 0x8000},
177{0x000F, 0x001F, 0x003E, 0x007C, 0x0070, 0x00E0, 0x01FC, 0x3FF6,
1780x7FF6, 0x7FFE, 0x7FFC, 0x7FF8, 0x3FF0, 0x7FC0, 0xF800, 0xE000},
179{0x000A, 0x0006}
180},
181
182} ;
183
526954c5 184// End of data copied from src/osx/carbon/cursor.cpp
fe686e5a
DE
185///////////////////////////////////////////////////////////////////////////
186
69659fd7 187/* NSCursorCreateWithPrivateId
fe686e5a
DE
188 * Returns a newly allocated (i.e. retainCount == 1) NSCursor based on the
189 * classic Mac OS cursor data in this source file. This allows us to
190 * implement the "stock" wxWidgets cursors which aren't present in Cocoa.
fe686e5a 191 */
69659fd7 192static inline NSCursor* NSCursorCreateWithPrivateId(short sIndex)
06386448
RN
193{
194 ClassicCursor* pCursor = &gMacCursors[sIndex];
195
c8326d64 196 //Classic mac cursors are 1bps 16x16 black and white with a
06386448
RN
197 //identical mask that is 1 for on and 0 for off
198 NSImage *theImage = [[NSImage alloc] initWithSize:NSMakeSize(16.0,16.0)];
c8326d64 199
fe686e5a
DE
200 NSBitmapImageRep *theRep = [[NSBitmapImageRep alloc]
201 initWithBitmapDataPlanes: NULL // Tell Cocoa to allocate the planes for us.
202 pixelsWide: 16 // All classic cursors are 16x16
203 pixelsHigh: 16
204 bitsPerSample: 1 // All classic cursors are bitmaps with bitmasks
205 samplesPerPixel: 2 // Sample 0:image 1:mask
206 hasAlpha: YES // Identify last sample as a mask
207 isPlanar: YES // Use a separate array for each sample
208 colorSpaceName: NSCalibratedWhiteColorSpace // 0.0=black 1.0=white
209 bytesPerRow: 2 // Rows in each plane are on 2-byte boundaries (no pad)
210 bitsPerPixel: 1]; // same as bitsPerSample since data is planar
211 // XXX: Should we use NSDeviceWhiteColorSpace? Does it matter?
212
213 // Ensure that Cocoa allocated 2 and only 2 of the 5 possible planes
214 unsigned char *planes[5];
215 [theRep getBitmapDataPlanes:planes];
216 wxASSERT(planes[0] != NULL);
217 wxASSERT(planes[1] != NULL);
218 wxASSERT(planes[2] == NULL);
219 wxASSERT(planes[3] == NULL);
220 wxASSERT(planes[4] == NULL);
221
222 // NOTE1: The Cursor's bits field is white=0 black=1.. thus the bitwise-not
223 // Why not use NSCalibratedBlackColorSpace? Because that reverses the
224 // sense of the alpha (mask) plane.
225 // NOTE2: The mask data is 0=off 1=on
226 // NOTE3: Cocoa asks for "premultiplied" color planes. Since we have a
227 // 1-bit color plane and a 1-bit alpha plane we can just do a bitwise-and
228 // on the two. The original cursor bitmaps have 0 (white actually) for
229 // any masked-off pixels. Therefore every masked-off pixel would be wrong
230 // since we bit-flip all of the picture bits. In practice, Cocoa doesn't
231 // seem to care, but we are following the documentation.
232
233 // Fill in the color (black/white) plane
234 for(int i=0; i<16; ++i)
235 {
236 planes[0][2*i ] = (~pCursor->bits[i] & pCursor->mask[i]) >> 8 & 0xff;
237 planes[0][2*i+1] = (~pCursor->bits[i] & pCursor->mask[i]) & 0xff;
238 }
239 // Fill in the alpha (i.e. mask) plane
240 for(int i=0; i<16; ++i)
06386448 241 {
fe686e5a
DE
242 planes[1][2*i ] = pCursor->mask[i] >> 8 & 0xff;
243 planes[1][2*i+1] = pCursor->mask[i] & 0xff;
06386448
RN
244 }
245
246 //add the representation (data) to the image
247 [theImage addRepresentation:theRep];
c8326d64 248
06386448 249 //create the new cursor
c8326d64 250 NSCursor* theCursor = [[NSCursor alloc] initWithImage:theImage
08264272 251 hotSpot:NSMakePoint(pCursor->hotspot[1], pCursor->hotspot[0])
06386448 252 ];
c8326d64 253
06386448 254 //do the usual cleanups
c8326d64 255 [theRep release];
06386448 256 [theImage release];
c8326d64 257
06386448
RN
258 //return the new cursor
259 return theCursor;
c8326d64 260}
06386448 261
5558135c
RN
262wxCursorRefData::wxCursorRefData() :
263 m_width(32), m_height(32), m_hCursor(nil)
a24aff65 264{
a24aff65
DE
265}
266
267wxCursorRefData::~wxCursorRefData()
268{
5558135c
RN
269 if (m_hCursor)
270 [m_hCursor release];
a24aff65
DE
271}
272
273// Cursors
274wxCursor::wxCursor()
275{
276}
277
278wxCursor::wxCursor(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height),
279 int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY), const char WXUNUSED(maskBits)[])
280{
281}
282
283wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int hotSpotY)
284{
285 m_refData = new wxCursorRefData;
c8326d64 286
5558135c
RN
287 //TODO: Not sure if this works or not
288 NSImage* theImage;
c8326d64 289
5558135c
RN
290 if (flags & wxBITMAP_TYPE_MACCURSOR_RESOURCE)
291 {
292 //[NSBundle bundleForClass:[self class]]?
c8326d64 293 theImage = [[NSImage alloc]
5558135c
RN
294 initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:wxNSStringWithWxString(cursor_file) ofType:nil]
295 ];
c8326d64 296
5558135c 297 }
c8326d64 298 else
5558135c
RN
299 theImage = [[NSImage alloc] initByReferencingFile:wxNSStringWithWxString(cursor_file)
300 ];
c8326d64 301
5558135c 302 wxASSERT(theImage);
c8326d64 303
5558135c
RN
304 M_CURSORDATA->m_hCursor = [[NSCursor alloc] initWithImage:theImage
305 hotSpot:NSMakePoint(hotSpotX, hotSpotY)
306 ];
c8326d64 307
5558135c 308 [theImage release];
a24aff65
DE
309}
310
69659fd7
DE
311// Returns a system cursor given the NSCursor class method selector or
312// nil if NSCursor does not respond to the message.
313// For example, OS X before 10.3 won't respond to pointingHandCursor.
314static inline NSCursor* GetSystemCursorWithSelector(SEL cursorSelector)
315{
316 if([NSCursor respondsToSelector: cursorSelector])
317 return [NSCursor performSelector: cursorSelector];
318 else
319 return nil;
320}
321
322// Please maintain order as if this were an array keyed on wxStockCursor
323static inline SEL GetCursorSelectorForStockCursor(int stock_cursor_id)
324{
325 switch(stock_cursor_id)
326 {
327 case wxCURSOR_ARROW: return @selector(arrowCursor);
328 case wxCURSOR_RIGHT_ARROW: break;
329 case wxCURSOR_BULLSEYE: break;
330 case wxCURSOR_CHAR: break;
331 case wxCURSOR_CROSS: return @selector(crosshairCursor);
332 case wxCURSOR_HAND: return @selector(pointingHandCursor);
333 case wxCURSOR_IBEAM: return @selector(IBeamCursor);
334 case wxCURSOR_LEFT_BUTTON: break;
335 case wxCURSOR_MAGNIFIER: break;
336 case wxCURSOR_MIDDLE_BUTTON: break;
337 case wxCURSOR_NO_ENTRY: break;
338 case wxCURSOR_PAINT_BRUSH: break;
339 case wxCURSOR_PENCIL: break;
340 case wxCURSOR_POINT_LEFT: break;
341 case wxCURSOR_POINT_RIGHT: break;
342 case wxCURSOR_QUESTION_ARROW: break;
343 case wxCURSOR_RIGHT_BUTTON: break;
344 case wxCURSOR_SIZENESW: break;
345 case wxCURSOR_SIZENS: return @selector(resizeUpDownCursor);
346 case wxCURSOR_SIZENWSE: break;
347 case wxCURSOR_SIZEWE: return @selector(resizeLeftRightCursor);
348 case wxCURSOR_SIZING: break;
349 case wxCURSOR_SPRAYCAN: break;
350 case wxCURSOR_WAIT: break;
351 case wxCURSOR_WATCH: break;
352 case wxCURSOR_BLANK: break;
353 case wxCURSOR_ARROWWAIT: break;
354 default: break;
355 }
356 return NULL;
357}
358
359// Please maintain order as if this were an array keyed on wxStockCursor
360static inline int GetPrivateCursorIdForStockCursor(int stock_cursor_id)
361{
362 switch(stock_cursor_id)
363 {
364 case wxCURSOR_ARROW: break; // NSCursor
365 case wxCURSOR_RIGHT_ARROW: return kwxCursorRightArrow;
366 case wxCURSOR_BULLSEYE: return kwxCursorBullseye;
367 case wxCURSOR_CHAR: break;
368 case wxCURSOR_CROSS: break; // NSCursor
369 case wxCURSOR_HAND: break; // NSCursor (OS X >= 10.3)
370 case wxCURSOR_IBEAM: break; // NSCursor
371 case wxCURSOR_LEFT_BUTTON: break;
372 case wxCURSOR_MAGNIFIER: return kwxCursorMagnifier;
373 case wxCURSOR_MIDDLE_BUTTON: break;
374 case wxCURSOR_NO_ENTRY: return kwxCursorNoEntry;
375 case wxCURSOR_PAINT_BRUSH: return kwxCursorPaintBrush;
376 case wxCURSOR_PENCIL: return kwxCursorPencil;
377 case wxCURSOR_POINT_LEFT: return kwxCursorPointLeft;
378 case wxCURSOR_POINT_RIGHT: return kwxCursorPointRight;
379 case wxCURSOR_QUESTION_ARROW: return kwxCursorQuestionArrow;
380 case wxCURSOR_RIGHT_BUTTON: break;
381 case wxCURSOR_SIZENESW: return kwxCursorSizeNESW;
382 case wxCURSOR_SIZENS: return kwxCursorSizeNS; // also NSCursor
383 case wxCURSOR_SIZENWSE: return kwxCursorSizeNWSE;
384 case wxCURSOR_SIZEWE: break; // NSCursor
385 case wxCURSOR_SIZING: return kwxCursorSize;
386 case wxCURSOR_SPRAYCAN: return kwxCursorRoller;
387 case wxCURSOR_WAIT: break;
388 case wxCURSOR_WATCH: break;
389 case wxCURSOR_BLANK: return kwxCursorBlank;
390 case wxCURSOR_ARROWWAIT: break;
391 default: break;
392 }
393 return -1;
394}
395
32660a06
DE
396// Keep an array of stock cursors so they can share wxCursorRefData and thus
397// wxObject::IsSameAs will return true.
398// They will obviously be destroyed at static destruction time which should
399// theoretically be fine.
400static wxCursor s_stockCursors[wxCURSOR_MAX];
401
69659fd7
DE
402// Cursors by stock number (enum wxStockCursor)
403wxCursor::wxCursor(int stock_cursor_id)
404{
32660a06
DE
405 // We default-constructed wxObject so our m_refData == NULL
406 if(stock_cursor_id >= 0 && stock_cursor_id < wxCURSOR_MAX)
407 {
408 // Attempt to reference an existing stock cursor
409 Ref(s_stockCursors[stock_cursor_id]);
410 }
411 // If we succeeded in getting an existing stock cursor, we're done.
412 if(m_refData != NULL)
413 return;
414
69659fd7
DE
415 m_refData = new wxCursorRefData;
416
417 M_CURSORDATA->m_hCursor = nil;
418
419 wxCHECK_RET( stock_cursor_id > wxCURSOR_NONE && stock_cursor_id < wxCURSOR_MAX,
420 wxT("invalid cursor id in wxCursor() ctor") );
421
422 // Stage 1: Try a system cursor
423 SEL cursorSelector;
424 if( (cursorSelector = GetCursorSelectorForStockCursor(stock_cursor_id)) != NULL)
425 {
426 M_CURSORDATA->m_hCursor = [GetSystemCursorWithSelector(cursorSelector) retain];
427 }
428
429 // TODO: Provide a pointing hand for OS X < 10.3 if desired
430
431 // Stage 2: Try one of the 'CURS'-style cursors
432 if(M_CURSORDATA->m_hCursor == nil)
433 {
434 int privateId;
435 if( (privateId = GetPrivateCursorIdForStockCursor(stock_cursor_id)) >= 0)
e2948f17 436 {
69659fd7 437 M_CURSORDATA->m_hCursor = NSCursorCreateWithPrivateId(privateId);
06386448 438 }
06386448 439 }
69659fd7
DE
440
441 // Stage 3: Give up, complain, and use a normal arrow
442 if(M_CURSORDATA->m_hCursor == nil)
443 {
148af7c5 444 wxLogDebug(wxT("Could not find suitable cursor for wxStockCursor = %d. Using normal pointer."), stock_cursor_id);
69659fd7
DE
445 M_CURSORDATA->m_hCursor = [[NSCursor arrowCursor] retain];
446 }
447
448 // This should never happen as the arrowCursor should always exist.
449 wxASSERT(M_CURSORDATA->m_hCursor != nil);
32660a06
DE
450
451 // Store ourself as the new stock cursor for this ID so that future
452 // calls will share the same ref data.
453 if(stock_cursor_id >= 0 && stock_cursor_id < wxCURSOR_MAX)
454 {
455 s_stockCursors[stock_cursor_id] = *this;
456 }
a24aff65
DE
457}
458
459wxCursor::~wxCursor()
460{
461}
462
463// Global cursor setting
464void wxSetCursor(const wxCursor& cursor)
465{
5558135c
RN
466 if (cursor.GetNSCursor())
467 [cursor.GetNSCursor() push];
a24aff65
DE
468}
469
470static int wxBusyCursorCount = 0;
471
472// Set the cursor to the busy cursor for all windows
f516d986 473void wxBeginBusyCursor(const wxCursor *cursor)
a24aff65 474{
c8326d64
WS
475 wxBusyCursorCount ++;
476 if (wxBusyCursorCount == 1)
477 {
a24aff65 478 // TODO
c8326d64
WS
479 }
480 else
481 {
a24aff65 482 // TODO
c8326d64 483 }
a24aff65
DE
484}
485
486// Restore cursor to normal
487void wxEndBusyCursor()
488{
c8326d64
WS
489 if (wxBusyCursorCount == 0)
490 return;
491
492 wxBusyCursorCount --;
493 if (wxBusyCursorCount == 0)
494 {
495 // TODO
496 }
a24aff65
DE
497}
498
c8326d64 499// true if we're between the above two calls
a24aff65
DE
500bool wxIsBusy()
501{
502 return (wxBusyCursorCount > 0);
c8326d64 503}