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