]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/app.cpp
thread support for mac finished
[wxWidgets.git] / src / mac / carbon / app.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: app.cpp
3 // Purpose: wxApp
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "app.h"
14 #endif
15
16 #include "wx/frame.h"
17 #include "wx/app.h"
18 #include "wx/utils.h"
19 #include "wx/gdicmn.h"
20 #include "wx/pen.h"
21 #include "wx/brush.h"
22 #include "wx/cursor.h"
23 #include "wx/icon.h"
24 #include "wx/palette.h"
25 #include "wx/dc.h"
26 #include "wx/dialog.h"
27 #include "wx/msgdlg.h"
28 #include "wx/log.h"
29 #include "wx/module.h"
30 #include "wx/memory.h"
31 #include "wx/tooltip.h"
32 #if wxUSE_WX_RESOURCES
33 #include "wx/resource.h"
34 #endif
35
36 #include <string.h>
37
38 // mac
39
40 #if __option(profile)
41 #include <profiler.h>
42 #endif
43
44 #include "apprsrc.h"
45
46 #include <wx/mac/uma.h>
47 #include <wx/mac/macnotfy.h>
48
49 #if wxUSE_SOCKETS
50 #include <OpenTransport.h>
51 #include <OpenTptInternet.h>
52 #endif
53
54 extern char *wxBuffer;
55 extern wxList wxPendingDelete;
56 extern wxList *wxWinMacWindowList;
57 extern wxList *wxWinMacControlList;
58
59 wxApp *wxTheApp = NULL;
60
61 #if !USE_SHARED_LIBRARY
62 IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
63 BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
64 EVT_IDLE(wxApp::OnIdle)
65 EVT_END_SESSION(wxApp::OnEndSession)
66 EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession)
67 END_EVENT_TABLE()
68 #endif
69
70
71 const short kMacMinHeap = (29 * 1024) ;
72 // platform specific static variables
73
74 const short kwxMacMenuBarResource = 1 ;
75 const short kwxMacAppleMenuId = 1 ;
76
77 RgnHandle wxApp::s_macCursorRgn = NULL;
78 wxWindow* wxApp::s_captureWindow = NULL ;
79 int wxApp::s_lastMouseDown = 0 ;
80 long wxApp::sm_lastMessageTime = 0;
81
82 #ifdef __WXMAC__
83
84 bool wxApp::s_macDefaultEncodingIsPC = true ;
85 bool wxApp::s_macSupportPCMenuShortcuts = true ;
86 long wxApp::s_macAboutMenuItemId = wxID_ABOUT ;
87 wxString wxApp::s_macHelpMenuTitleName = "&Help" ;
88
89 pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
90 {
91 wxApp* app = (wxApp*) refcon ;
92 return wxTheApp->MacHandleAEODoc( event , reply) ;
93 }
94
95 pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
96 {
97 wxApp* app = (wxApp*) refcon ;
98 return wxTheApp->MacHandleAEOApp( event , reply ) ;
99 }
100
101 pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
102 {
103 wxApp* app = (wxApp*) refcon ;
104 return wxTheApp->MacHandleAEPDoc( event , reply ) ;
105 }
106
107 pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
108 {
109 wxApp* app = (wxApp*) refcon ;
110 return wxTheApp->MacHandleAEQuit( event , reply) ;
111 }
112
113 OSErr wxApp::MacHandleAEODoc(AppleEvent *event , AppleEvent *reply)
114 {
115 ProcessSerialNumber PSN ;
116 PSN.highLongOfPSN = 0 ;
117 PSN.lowLongOfPSN = kCurrentProcess ;
118 SetFrontProcess( &PSN ) ;
119 return noErr ;
120 }
121
122 OSErr wxApp::MacHandleAEPDoc(AppleEvent *event , AppleEvent *reply)
123 {
124 return noErr ;
125 }
126
127 OSErr wxApp::MacHandleAEOApp(AppleEvent *event , AppleEvent *reply)
128 {
129 return noErr ;
130 }
131
132 OSErr wxApp::MacHandleAEQuit(AppleEvent *event , AppleEvent *reply)
133 {
134 wxWindow* win = GetTopWindow() ;
135 if ( win )
136 {
137 win->Close(TRUE ) ;
138 }
139 else
140 {
141 ExitMainLoop() ;
142 }
143 return noErr ;
144 }
145
146 char StringMac[] = "\x0d\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
147 "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
148 "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf"
149 "\xb1\xb4\xb5\xb6\xbb\xbc\xbe\xbf"
150 "\xc0\xc1\xc2\xc4\xc7\xc8\xc9\xcb\xcc\xcd\xce\xcf"
151 "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd8\xca\xdb" ;
152
153 char StringANSI[] = "\x0a\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8"
154 "\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC"
155 "\x86\xBA\xA2\xA3\xA7\x95\xB6\xDF\xAE\xA9\x99\xB4\xA8\xC6\xD8"
156 "\xB1\xA5\xB5\xF0\xAA\xBA\xE6\xF8"
157 "\xBF\xA1\xAC\x83\xAB\xBB\x85\xC0\xC3\xD5\x8C\x9C"
158 "\x96\x97\x93\x94\x91\x92\xF7\xFF\xA0\x80" ;
159
160 void wxMacConvertFromPC( const char *from , char *to , int len )
161 {
162 char *c ;
163 if ( from == to )
164 {
165 for( int i = 0 ; i < len ; ++ i )
166 {
167 c = strchr( StringANSI , *from ) ;
168 if ( c != NULL )
169 {
170 *to = StringMac[ c - StringANSI] ;
171 }
172 ++to ;
173 ++from ;
174 }
175 }
176 else
177 {
178 for( int i = 0 ; i < len ; ++ i )
179 {
180 c = strchr( StringANSI , *from ) ;
181 if ( c != NULL )
182 {
183 *to = StringMac[ c - StringANSI] ;
184 }
185 else
186 {
187 *to = *from ;
188 }
189 ++to ;
190 ++from ;
191 }
192 }
193 }
194
195 void wxMacConvertToPC( const char *from , char *to , int len )
196 {
197 char *c ;
198 if ( from == to )
199 {
200 for( int i = 0 ; i < len ; ++ i )
201 {
202 c = strchr( StringMac , *from ) ;
203 if ( c != NULL )
204 {
205 *to = StringANSI[ c - StringMac] ;
206 }
207 ++to ;
208 ++from ;
209 }
210 }
211 else
212 {
213 for( int i = 0 ; i < len ; ++ i )
214 {
215 c = strchr( StringMac , *from ) ;
216 if ( c != NULL )
217 {
218 *to = StringANSI[ c - StringMac] ;
219 }
220 else
221 {
222 *to = *from ;
223 }
224 ++to ;
225 ++from ;
226 }
227 }
228 }
229
230 void wxMacConvertFromPC( char * p )
231 {
232 char *ptr = p ;
233 int len = strlen ( p ) ;
234
235 wxMacConvertFromPC( ptr , ptr , len ) ;
236 }
237
238 void wxMacConvertFromPCForControls( char * p )
239 {
240 char *ptr = p ;
241 int len = strlen ( p ) ;
242
243 wxMacConvertFromPC( ptr , ptr , len ) ;
244 for ( int i = 0 ; i < strlen ( ptr ) ; i++ )
245 {
246 if ( ptr[i] == '&' && ptr[i]+1 != ' ' )
247 {
248 memmove( &ptr[i] , &ptr[i+1] , strlen( &ptr[i+1] ) + 1) ;
249 }
250 }
251 }
252
253 void wxMacConvertFromPC( unsigned char *p )
254 {
255 char *ptr = (char*) p + 1 ;
256 int len = p[0] ;
257
258 wxMacConvertFromPC( ptr , ptr , len ) ;
259 }
260
261 extern char *wxBuffer ;
262
263 wxString wxMacMakeMacStringFromPC( const char * p )
264 {
265 const char *ptr = p ;
266 int len = strlen ( p ) ;
267 char *buf = wxBuffer ;
268
269 if ( len >= BUFSIZ + 512 )
270 {
271 buf = new char [len+1] ;
272 }
273
274 wxMacConvertFromPC( ptr , buf , len ) ;
275 buf[len] = 0 ;
276 wxString result( buf ) ;
277 if ( buf != wxBuffer )
278 delete buf ;
279 return result ;
280 }
281
282
283 void wxMacConvertToPC( char * p )
284 {
285 char *ptr = p ;
286 int len = strlen ( p ) ;
287
288 wxMacConvertToPC( ptr , ptr , len ) ;
289 }
290
291 void wxMacConvertToPC( unsigned char *p )
292 {
293 char *ptr = (char*) p + 1 ;
294 int len = p[0] ;
295
296 wxMacConvertToPC( ptr , ptr , len ) ;
297 }
298
299 wxString wxMacMakePCStringFromMac( const char * p )
300 {
301 const char *ptr = p ;
302 int len = strlen ( p ) ;
303 char *buf = wxBuffer ;
304
305 if ( len >= BUFSIZ + 512 )
306 {
307 buf = new char [len+1] ;
308 }
309
310 wxMacConvertToPC( ptr , buf , len ) ;
311 buf[len] = 0 ;
312
313 wxString result( buf ) ;
314 if ( buf != wxBuffer )
315 delete buf ;
316 return result ;
317 }
318
319 #endif
320
321 bool wxApp::Initialize()
322 {
323 int error = 0 ;
324
325 // Mac-specific
326
327 UMAInitToolbox( 4 ) ;
328 UMAShowWatchCursor() ;
329
330 AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments , NewAEEventHandlerProc(AEHandleODoc) , (long) wxTheApp , FALSE ) ;
331 AEInstallEventHandler( kCoreEventClass , kAEOpenApplication , NewAEEventHandlerProc(AEHandleOApp) , (long) wxTheApp , FALSE ) ;
332 AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments , NewAEEventHandlerProc(AEHandlePDoc) , (long) wxTheApp , FALSE ) ;
333 AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerProc(AEHandleQuit) , (long) wxTheApp , FALSE ) ;
334
335
336 // test the minimal configuration necessary
337
338 long theSystem ;
339 long theMachine;
340
341 if (Gestalt(gestaltMachineType, &theMachine) != noErr)
342 {
343 error = kMacSTRWrongMachine;
344 }
345 else if (theMachine < gestaltMacPlus)
346 {
347 error = kMacSTRWrongMachine;
348 }
349 else if (Gestalt(gestaltSystemVersion, &theSystem) != noErr )
350 {
351 error = kMacSTROldSystem ;
352 }
353 else if ( theSystem < 0x0750 )
354 {
355 error = kMacSTROldSystem ;
356 }
357 #if !TARGET_CARBON
358 else if ((long)GetApplLimit() - (long)ApplicationZone() < kMacMinHeap)
359 {
360 error = kMacSTRSmallSize;
361 }
362 #endif
363 /*
364 else
365 {
366 if ( !UMAHasAppearance() )
367 {
368 error = kMacSTRNoPre8Yet ;
369 }
370 }
371 */
372
373 // if we encountered any problems so far, give the error code and exit immediately
374
375 if ( error )
376 {
377 short itemHit;
378 Str255 message;
379
380 GetIndString(message, 128, error);
381 UMAShowArrowCursor() ;
382 ParamText("\pFatal Error", message, (ConstStr255Param)"\p", (ConstStr255Param)"\p");
383 itemHit = Alert(128, nil);
384 return FALSE ;
385 }
386
387 #if __option(profile)
388 ProfilerInit( collectDetailed, bestTimeBase , 20000 , 40 ) ;
389 #endif
390
391 // now avoid exceptions thrown for new (bad_alloc)
392
393 std::__throws_bad_alloc = FALSE ;
394
395 s_macCursorRgn = ::NewRgn() ;
396
397 #ifdef __WXMSW__
398 wxBuffer = new char[1500];
399 #else
400 wxBuffer = new char[BUFSIZ + 512];
401 #endif
402
403 wxClassInfo::InitializeClasses();
404
405 #if wxUSE_RESOURCES
406 // wxGetResource(wxT("wxWindows"), wxT("OsVersion"), &wxOsVersion);
407 #endif
408
409 #if wxUSE_THREADS
410 wxPendingEventsLocker = new wxCriticalSection;
411 #endif
412 wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
413 wxTheColourDatabase->Initialize();
414
415 wxInitializeStockLists();
416 wxInitializeStockObjects();
417
418 #if wxUSE_WX_RESOURCES
419 wxInitializeResourceSystem();
420 #endif
421
422 wxBitmap::InitStandardHandlers();
423
424 wxModule::RegisterModules();
425 if (!wxModule::InitializeModules())
426 return FALSE;
427
428 wxWinMacWindowList = new wxList(wxKEY_INTEGER);
429 wxWinMacControlList = new wxList(wxKEY_INTEGER);
430
431 wxMacCreateNotifierTable() ;
432
433 UMAShowArrowCursor() ;
434
435 return TRUE;
436 }
437
438 void wxApp::CleanUp()
439 {
440 #if wxUSE_LOG
441 // flush the logged messages if any and install a 'safer' log target: the
442 // default one (wxLogGui) can't be used after the resources are freed just
443 // below and the user suppliedo ne might be even more unsafe (using any
444 // wxWindows GUI function is unsafe starting from now)
445 wxLog::DontCreateOnDemand();
446
447 // this will flush the old messages if any
448 delete wxLog::SetActiveTarget(new wxLogStderr);
449 #endif // wxUSE_LOG
450
451 // One last chance for pending objects to be cleaned up
452 wxTheApp->DeletePendingObjects();
453
454 wxModule::CleanUpModules();
455
456 #if wxUSE_WX_RESOURCES
457 wxCleanUpResourceSystem();
458 #endif
459
460 wxDeleteStockObjects() ;
461
462 // Destroy all GDI lists, etc.
463 wxDeleteStockLists();
464
465 delete wxTheColourDatabase;
466 wxTheColourDatabase = NULL;
467
468 wxBitmap::CleanUpHandlers();
469
470 delete[] wxBuffer;
471 wxBuffer = NULL;
472
473 wxMacDestroyNotifierTable() ;
474 if (wxWinMacWindowList)
475 delete wxWinMacWindowList ;
476
477 delete wxPendingEvents;
478 #if wxUSE_THREADS
479 delete wxPendingEventsLocker;
480 // If we don't do the following, we get an apparent memory leak.
481 ((wxEvtHandler&) wxDefaultValidator).ClearEventLocker();
482 #endif
483
484 wxClassInfo::CleanUpClasses();
485
486 #if __option(profile)
487 ProfilerDump( "\papp.prof" ) ;
488 ProfilerTerm() ;
489 #endif
490
491 delete wxTheApp;
492 wxTheApp = NULL;
493
494 #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
495 // At this point we want to check if there are any memory
496 // blocks that aren't part of the wxDebugContext itself,
497 // as a special case. Then when dumping we need to ignore
498 // wxDebugContext, too.
499 if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
500 {
501 wxLogDebug(wxT("There were memory leaks."));
502 wxDebugContext::Dump();
503 wxDebugContext::PrintStatistics();
504 }
505 // wxDebugContext::SetStream(NULL, NULL);
506 #endif
507
508 #if wxUSE_LOG
509 // do it as the very last thing because everything else can log messages
510 delete wxLog::SetActiveTarget(NULL);
511 #endif // wxUSE_LOG
512
513 if (s_macCursorRgn)
514 ::DisposeRgn(s_macCursorRgn);
515
516 #if 0
517 TerminateAE() ;
518 #endif
519 }
520
521 int wxEntry( int argc, char *argv[] , bool enterLoop )
522 {
523 #ifdef __MWERKS__
524 #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
525 // This seems to be necessary since there are 'rogue'
526 // objects present at this point (perhaps global objects?)
527 // Setting a checkpoint will ignore them as far as the
528 // memory checking facility is concerned.
529 // Of course you may argue that memory allocated in globals should be
530 // checked, but this is a reasonable compromise.
531 wxDebugContext::SetCheckpoint();
532 #endif
533 #endif
534 if (!wxApp::Initialize())
535 return 0;
536 // create the application object or ensure that one already exists
537 if (!wxTheApp)
538 {
539 // The app may have declared a global application object, but we recommend
540 // the IMPLEMENT_APP macro is used instead, which sets an initializer
541 // function for delayed, dynamic app object construction.
542 wxCHECK_MSG( wxApp::GetInitializerFunction(), 0,
543 wxT("No initializer - use IMPLEMENT_APP macro.") );
544
545 wxTheApp = (wxApp*) (*wxApp::GetInitializerFunction()) ();
546 }
547
548 wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") );
549
550 #ifdef __WXMAC__
551 argc = 0 ; // currently we don't support files as parameters
552 #endif
553
554 wxTheApp->argc = argc;
555 wxTheApp->argv = argv;
556
557 // GUI-specific initialization, such as creating an app context.
558 wxTheApp->OnInitGui();
559
560 // we could try to get the open apple events here to adjust argc and argv better
561
562
563 // Here frames insert themselves automatically
564 // into wxTopLevelWindows by getting created
565 // in OnInit().
566
567 int retValue = 0;
568
569 if ( wxTheApp->OnInit() )
570 {
571 if ( enterLoop )
572 {
573 retValue = wxTheApp->OnRun();
574 }
575 else
576 // We want to initialize, but not run or exit immediately.
577 return 1;
578 }
579 //else: app initialization failed, so we skipped OnRun()
580
581 wxWindow *topWindow = wxTheApp->GetTopWindow();
582 if ( topWindow )
583 {
584 // Forcibly delete the window.
585 if ( topWindow->IsKindOf(CLASSINFO(wxFrame)) ||
586 topWindow->IsKindOf(CLASSINFO(wxDialog)) )
587 {
588 topWindow->Close(TRUE);
589 wxTheApp->DeletePendingObjects();
590 }
591 else
592 {
593 delete topWindow;
594 wxTheApp->SetTopWindow(NULL);
595 }
596 }
597
598 wxTheApp->OnExit();
599
600 wxApp::CleanUp();
601
602 return retValue;
603 };
604
605 // Static member initialization
606 wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
607
608 wxApp::wxApp()
609 {
610 m_topWindow = NULL;
611 wxTheApp = this;
612
613 m_wantDebugOutput = TRUE ;
614
615 argc = 0;
616 argv = NULL;
617
618 m_printMode = wxPRINT_WINDOWS;
619 m_exitOnFrameDelete = TRUE;
620 m_auto3D = TRUE;
621 }
622
623 bool wxApp::Initialized()
624 {
625 if (GetTopWindow())
626 return TRUE;
627 else
628 return FALSE;
629 }
630
631 int wxApp::MainLoop()
632 {
633 m_keepGoing = TRUE;
634
635 while (m_keepGoing)
636 {
637 MacDoOneEvent() ;
638 }
639
640 return 0;
641 }
642
643 // Returns TRUE if more time is needed.
644 bool wxApp::ProcessIdle()
645 {
646 wxIdleEvent event;
647 event.SetEventObject(this);
648 ProcessEvent(event);
649
650 return event.MoreRequested();
651 }
652
653 void wxApp::ExitMainLoop()
654 {
655 m_keepGoing = FALSE;
656 }
657
658 // Is a message/event pending?
659 bool wxApp::Pending()
660 {
661 EventRecord event ;
662
663 return EventAvail( everyEvent , &event ) ;
664 }
665
666 // Dispatch a message.
667 void wxApp::Dispatch()
668 {
669 MacDoOneEvent() ;
670 }
671
672 void wxApp::OnIdle(wxIdleEvent& event)
673 {
674 static bool s_inOnIdle = FALSE;
675
676 // Avoid recursion (via ProcessEvent default case)
677 if ( s_inOnIdle )
678 return;
679
680
681 s_inOnIdle = TRUE;
682
683 // 'Garbage' collection of windows deleted with Close().
684 DeletePendingObjects();
685
686 // flush the logged messages if any
687 wxLog *pLog = wxLog::GetActiveTarget();
688 if ( pLog != NULL && pLog->HasPendingMessages() )
689 pLog->Flush();
690
691 // Send OnIdle events to all windows
692 bool needMore = SendIdleEvents();
693
694 if (needMore)
695 event.RequestMore(TRUE);
696
697 // If they are pending events, we must process them: pending events are
698 // either events to the threads other than main or events posted with
699 // wxPostEvent() functions
700 wxMacProcessNotifierAndPendingEvents();
701
702 s_inOnIdle = FALSE;
703 }
704
705 void wxWakeUpIdle()
706 {
707 wxMacWakeUp() ;
708 }
709
710 // Send idle event to all top-level windows
711 bool wxApp::SendIdleEvents()
712 {
713 bool needMore = FALSE;
714 wxNode* node = wxTopLevelWindows.First();
715 while (node)
716 {
717 wxWindow* win = (wxWindow*) node->Data();
718 if (SendIdleEvents(win))
719 needMore = TRUE;
720
721 node = node->Next();
722 }
723 return needMore;
724 }
725
726 // Send idle event to window and all subwindows
727 bool wxApp::SendIdleEvents(wxWindow* win)
728 {
729 bool needMore = FALSE;
730
731 wxIdleEvent event;
732 event.SetEventObject(win);
733 win->ProcessEvent(event);
734
735 if (event.MoreRequested())
736 needMore = TRUE;
737
738 wxNode* node = win->GetChildren().First();
739 while (node)
740 {
741 wxWindow* win = (wxWindow*) node->Data();
742 if (SendIdleEvents(win))
743 needMore = TRUE;
744
745 node = node->Next();
746 }
747 return needMore ;
748 }
749
750 void wxApp::DeletePendingObjects()
751 {
752 wxNode *node = wxPendingDelete.First();
753 while (node)
754 {
755 wxObject *obj = (wxObject *)node->Data();
756
757 delete obj;
758
759 if (wxPendingDelete.Member(obj))
760 delete node;
761
762 // Deleting one object may have deleted other pending
763 // objects, so start from beginning of list again.
764 node = wxPendingDelete.First();
765 }
766 }
767
768 wxIcon
769 wxApp::GetStdIcon(int which) const
770 {
771 switch(which)
772 {
773 case wxICON_INFORMATION:
774 return wxIcon("wxICON_INFO");
775
776 case wxICON_QUESTION:
777 return wxIcon("wxICON_QUESTION");
778
779 case wxICON_EXCLAMATION:
780 return wxIcon("wxICON_WARNING");
781
782 default:
783 wxFAIL_MSG(wxT("requested non existent standard icon"));
784 // still fall through
785
786 case wxICON_HAND:
787 return wxIcon("wxICON_ERROR");
788 }
789 }
790
791 void wxExit()
792 {
793 wxLogError(_("Fatal error: exiting"));
794
795 wxApp::CleanUp();
796 ::ExitToShell() ;
797 }
798
799 void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
800 {
801 if (GetTopWindow())
802 GetTopWindow()->Close(TRUE);
803 }
804
805 // Default behaviour: close the application with prompts. The
806 // user can veto the close, and therefore the end session.
807 void wxApp::OnQueryEndSession(wxCloseEvent& event)
808 {
809 if (GetTopWindow())
810 {
811 if (!GetTopWindow()->Close(!event.CanVeto()))
812 event.Veto(TRUE);
813 }
814 }
815
816 extern "C" void wxCYield() ;
817 void wxCYield()
818 {
819 wxYield() ;
820 }
821
822 // Yield to other processes
823 bool wxYield()
824 {
825 #if wxUSE_THREADS
826 YieldToAnyThread() ;
827 #endif
828 EventRecord event ;
829
830 long sleepTime = 0 ; //::GetCaretTime();
831
832 while ( !wxTheApp->IsExiting() && WaitNextEvent(everyEvent, &event,sleepTime, wxApp::s_macCursorRgn))
833 {
834 wxTheApp->MacHandleOneEvent( &event );
835 }
836
837 wxMacProcessNotifierAndPendingEvents() ;
838 return TRUE;
839 }
840
841 // platform specifics
842
843 void wxApp::MacSuspend( bool convertClipboard )
844 {
845 // we have to deactive the window manually
846
847 wxWindow* window = GetTopWindow() ;
848 if ( window )
849 window->MacActivate( MacGetCurrentEvent() , false ) ;
850
851 s_lastMouseDown = 0 ;
852 if( convertClipboard )
853 {
854 MacConvertPrivateToPublicScrap() ;
855 }
856
857 UMAHideFloatingWindows() ;
858 }
859
860 void wxApp::MacResume( bool convertClipboard )
861 {
862 s_lastMouseDown = 0 ;
863 if( convertClipboard )
864 {
865 MacConvertPublicToPrivateScrap() ;
866 }
867
868 UMAShowFloatingWindows() ;
869 }
870
871 void wxApp::MacConvertPrivateToPublicScrap()
872 {
873 }
874
875 void wxApp::MacConvertPublicToPrivateScrap()
876 {
877 }
878
879 void wxApp::MacDoOneEvent()
880 {
881 EventRecord event ;
882
883 long sleepTime = ::GetCaretTime();
884
885 if (WaitNextEvent(everyEvent, &event,sleepTime, s_macCursorRgn))
886 {
887 MacHandleOneEvent( &event );
888 }
889 else
890 {
891 // idlers
892 WindowPtr window = UMAFrontWindow() ;
893 if ( window )
894 UMAIdleControls( window ) ;
895
896 wxTheApp->ProcessIdle() ;
897 }
898 if ( event.what != kHighLevelEvent )
899 SetRectRgn( s_macCursorRgn , event.where.h - 1 , event.where.v - 1, event.where.h + 1 , event.where.v + 1 ) ;
900
901 // repeaters
902
903 wxMacProcessNotifierAndPendingEvents() ;
904 }
905
906 void wxApp::MacHandleOneEvent( EventRecord *ev )
907 {
908 m_macCurrentEvent = ev ;
909
910 wxApp::sm_lastMessageTime = ev->when ;
911
912 switch (ev->what)
913 {
914 case mouseDown:
915 MacHandleMouseDownEvent( ev ) ;
916 if ( ev->modifiers & controlKey )
917 s_lastMouseDown = 2;
918 else
919 s_lastMouseDown = 1;
920 break;
921 case mouseUp:
922 if ( s_lastMouseDown == 2 )
923 {
924 ev->modifiers |= controlKey ;
925 }
926 else
927 {
928 ev->modifiers &= ~controlKey ;
929 }
930 MacHandleMouseUpEvent( ev ) ;
931 s_lastMouseDown = 0;
932 break;
933 case activateEvt:
934 MacHandleActivateEvent( ev ) ;
935 break;
936 case updateEvt:
937 MacHandleUpdateEvent( ev ) ;
938 break;
939 case keyDown:
940 case autoKey:
941 MacHandleKeyDownEvent( ev ) ;
942 break;
943 case keyUp:
944 MacHandleKeyUpEvent( ev ) ;
945 break;
946 case diskEvt:
947 MacHandleDiskEvent( ev ) ;
948 break;
949 case osEvt:
950 MacHandleOSEvent( ev ) ;
951 break;
952 case kHighLevelEvent:
953 MacHandleHighLevelEvent( ev ) ;
954 break;
955 default:
956 break;
957 }
958 wxMacProcessNotifierAndPendingEvents() ;
959 }
960
961 void wxApp::MacHandleHighLevelEvent( EventRecord *ev )
962 {
963 ::AEProcessAppleEvent( ev ) ;
964 }
965
966 bool s_macIsInModalLoop = false ;
967
968 void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
969 {
970 wxToolTip::RemoveToolTips() ;
971
972 WindowRef window;
973 WindowRef frontWindow = UMAFrontNonFloatingWindow() ;
974 WindowAttributes frontWindowAttributes = NULL ;
975 if ( frontWindow )
976 UMAGetWindowAttributes( frontWindow , &frontWindowAttributes ) ;
977
978 short windowPart = ::FindWindow(ev->where, &window);
979 wxWindow* win = wxFindWinFromMacWindow( window ) ;
980
981 BitMap screenBits;
982 GetQDGlobalsScreenBits( &screenBits );
983
984 switch (windowPart)
985 {
986 case inMenuBar :
987 if ( s_macIsInModalLoop )
988 {
989 SysBeep ( 30 ) ;
990 }
991 else
992 {
993 UInt32 menuresult = MenuSelect(ev->where) ;
994 MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) );
995 s_lastMouseDown = 0;
996 }
997 break ;
998 #if !TARGET_CARBON
999 case inSysWindow :
1000 SystemClick( ev , window ) ;
1001 s_lastMouseDown = 0;
1002 break ;
1003 #endif
1004 case inDrag :
1005 if ( window != frontWindow && s_macIsInModalLoop && !(ev->modifiers & cmdKey ) )
1006 {
1007 SysBeep ( 30 ) ;
1008 }
1009 else
1010 {
1011 DragWindow(window, ev->where, &screenBits.bounds);
1012 if (win)
1013 {
1014 GrafPtr port ;
1015 GetPort( &port ) ;
1016 Point pt = { 0, 0 } ;
1017 #if TARGET_CARBON
1018 SetPort( GetWindowPort(window) ) ;
1019 #else
1020 SetPort( (window) ) ;
1021 #endif
1022 SetOrigin( 0 , 0 ) ;
1023 LocalToGlobal( &pt ) ;
1024 SetPort( port ) ;
1025 win->SetSize( pt.h , pt.v , -1 ,
1026 -1 , wxSIZE_USE_EXISTING);
1027 }
1028 s_lastMouseDown = 0;
1029 }
1030 break ;
1031 case inGoAway:
1032 if (TrackGoAway(window, ev->where))
1033 {
1034 if ( win )
1035 win->Close() ;
1036 }
1037 s_lastMouseDown = 0;
1038 break;
1039 case inGrow:
1040 int growResult = GrowWindow(window , ev->where, &screenBits.bounds);
1041 if (growResult != 0)
1042 {
1043 int newWidth = LoWord(growResult);
1044 int newHeight = HiWord(growResult);
1045 int oldWidth, oldHeight;
1046
1047 win->GetSize(&oldWidth, &oldHeight);
1048 if (newWidth == 0)
1049 newWidth = oldWidth;
1050 if (newHeight == 0)
1051 newHeight = oldHeight;
1052
1053 if (win)
1054 win->SetSize( -1, -1, newWidth, newHeight, wxSIZE_USE_EXISTING);
1055 }
1056 s_lastMouseDown = 0;
1057 break;
1058 case inZoomIn:
1059 case inZoomOut:
1060 if (TrackBox(window, ev->where, windowPart))
1061 {
1062 // TODO setup size event
1063 ZoomWindow( window , windowPart , false ) ;
1064 if (win)
1065 {
1066 Rect tempRect ;
1067
1068 GetWindowPortBounds(window, &tempRect ) ;
1069 win->SetSize( -1, -1, tempRect.right-tempRect.left ,
1070 tempRect.bottom-tempRect.top, wxSIZE_USE_EXISTING);
1071 }
1072 }
1073 s_lastMouseDown = 0;
1074 break;
1075 case inCollapseBox :
1076 // TODO setup size event
1077 s_lastMouseDown = 0;
1078 break ;
1079
1080 case inContent :
1081 {
1082 GrafPtr port ;
1083 GetPort( &port ) ;
1084 #if TARGET_CARBON
1085 SetPort( GetWindowPort(window) ) ;
1086 #else
1087 SetPort( (window) ) ;
1088 #endif
1089 SetOrigin( 0 , 0 ) ;
1090 SetPort( port ) ;
1091 }
1092 if ( window != frontWindow )
1093 {
1094 if ( s_macIsInModalLoop )
1095 {
1096 SysBeep ( 30 ) ;
1097 }
1098 else if ( UMAIsWindowFloating( window ) )
1099 {
1100 if ( win )
1101 win->MacMouseDown( ev , windowPart ) ;
1102 }
1103 else
1104 {
1105 UMASelectWindow( window ) ;
1106 }
1107 }
1108 else
1109 {
1110 if ( win )
1111 win->MacMouseDown( ev , windowPart ) ;
1112 }
1113 break ;
1114
1115 default:
1116 break;
1117 }
1118 }
1119
1120 void wxApp::MacHandleMouseUpEvent( EventRecord *ev )
1121 {
1122 WindowRef window;
1123
1124 short windowPart = ::FindWindow(ev->where, &window);
1125
1126 switch (windowPart)
1127 {
1128 case inMenuBar :
1129 break ;
1130 case inSysWindow :
1131 break ;
1132 default:
1133 {
1134 wxWindow* win = wxFindWinFromMacWindow( window ) ;
1135 if ( win )
1136 win->MacMouseUp( ev , windowPart ) ;
1137 }
1138 break;
1139 }
1140 }
1141
1142 long wxMacTranslateKey(unsigned char key, unsigned char code)
1143 {
1144 long retval = key ;
1145 switch (key)
1146 {
1147 case 0x01 :
1148 retval = WXK_HOME;
1149 break;
1150 case 0x03 :
1151 retval = WXK_RETURN;
1152 break;
1153 case 0x04 :
1154 retval = WXK_END;
1155 break;
1156 case 0x05 :
1157 retval = WXK_HELP;
1158 break;
1159 case 0x08 :
1160 retval = WXK_BACK;
1161 break;
1162 case 0x09 :
1163 retval = WXK_TAB;
1164 break;
1165 case 0x0b :
1166 retval = WXK_PAGEUP;
1167 break;
1168 case 0x0c :
1169 retval = WXK_PAGEDOWN;
1170 break;
1171 case 0x0d :
1172 retval = WXK_RETURN;
1173 break;
1174 case 0x10 :
1175 {
1176 switch( code )
1177 {
1178 case 0x7a :
1179 retval = WXK_F1 ;
1180 break;
1181 case 0x78 :
1182 retval = WXK_F2 ;
1183 break;
1184 case 0x63 :
1185 retval = WXK_F3 ;
1186 break;
1187 case 0x76 :
1188 retval = WXK_F4 ;
1189 break;
1190 case 0x60 :
1191 retval = WXK_F5 ;
1192 break;
1193 case 0x61 :
1194 retval = WXK_F6 ;
1195 break;
1196 case 0x62:
1197 retval = WXK_F7 ;
1198 break;
1199 case 0x64 :
1200 retval = WXK_F8 ;
1201 break;
1202 case 0x65 :
1203 retval = WXK_F9 ;
1204 break;
1205 case 0x6D :
1206 retval = WXK_F10 ;
1207 break;
1208 case 0x67 :
1209 retval = WXK_F11 ;
1210 break;
1211 case 0x6F :
1212 retval = WXK_F12 ;
1213 break;
1214 case 0x69 :
1215 retval = WXK_F13 ;
1216 break;
1217 case 0x6B :
1218 retval = WXK_F14 ;
1219 break;
1220 case 0x71 :
1221 retval = WXK_F15 ;
1222 break;
1223 }
1224 }
1225 break ;
1226 case 0x1b :
1227 retval = WXK_ESCAPE ;
1228 break ;
1229 case 0x1c :
1230 retval = WXK_LEFT ;
1231 break ;
1232 case 0x1d :
1233 retval = WXK_RIGHT ;
1234 break ;
1235 case 0x1e :
1236 retval = WXK_UP ;
1237 break ;
1238 case 0x1f :
1239 retval = WXK_DOWN ;
1240 break ;
1241 case 0x7F :
1242 retval = WXK_DELETE ;
1243 default:
1244 break ;
1245 } // end switch
1246
1247 return retval;
1248 }
1249
1250 void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
1251 {
1252 wxToolTip::RemoveToolTips() ;
1253
1254 UInt32 menuresult = UMAMenuEvent(ev) ;
1255 if ( HiWord( menuresult ) )
1256 MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ;
1257 else
1258 {
1259 short keycode ;
1260 short keychar ;
1261 keychar = short(ev->message & charCodeMask);
1262 keycode = short(ev->message & keyCodeMask) >> 8 ;
1263
1264 wxWindow* focus = wxWindow::FindFocus() ;
1265 if ( focus )
1266 {
1267 long keyval = wxMacTranslateKey(keychar, keycode) ;
1268
1269 wxKeyEvent event(wxEVT_KEY_DOWN);
1270 event.m_shiftDown = ev->modifiers & shiftKey;
1271 event.m_controlDown = ev->modifiers & controlKey;
1272 event.m_altDown = ev->modifiers & optionKey;
1273 event.m_metaDown = ev->modifiers & cmdKey;
1274 event.m_keyCode = keyval;
1275 event.m_x = ev->where.h;
1276 event.m_y = ev->where.v;
1277 event.m_timeStamp = ev->when;
1278 event.SetEventObject(focus);
1279 bool handled = focus->GetEventHandler()->ProcessEvent( event ) ;
1280 if ( !handled )
1281 {
1282 #if wxUSE_ACCEL
1283 if (!handled)
1284 {
1285 wxWindow *ancestor = focus;
1286 /*
1287 while (ancestor)
1288 {
1289 int command = ancestor->GetAcceleratorTable()->GetCommand( event );
1290 if (command != -1)
1291 {
1292 wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
1293 handled = ancestor->GetEventHandler()->ProcessEvent( command_event );
1294 break;
1295 }
1296 if (ancestor->m_isFrame)
1297 break;
1298 ancestor = ancestor->GetParent();
1299 }
1300 */
1301 }
1302 #endif // wxUSE_ACCEL
1303 }
1304 if (!handled)
1305 {
1306 wxKeyEvent event(wxEVT_CHAR);
1307 event.m_shiftDown = ev->modifiers & shiftKey;
1308 event.m_controlDown = ev->modifiers & controlKey;
1309 event.m_altDown = ev->modifiers & optionKey;
1310 event.m_metaDown = ev->modifiers & cmdKey;
1311 event.m_keyCode = keyval;
1312 event.m_x = ev->where.h;
1313 event.m_y = ev->where.v;
1314 event.m_timeStamp = ev->when;
1315 event.SetEventObject(focus);
1316 handled = focus->GetEventHandler()->ProcessEvent( event ) ;
1317 }
1318 if ( !handled &&
1319 (keyval == WXK_TAB) &&
1320 (!focus->HasFlag(wxTE_PROCESS_TAB)) &&
1321 (focus->GetParent()) &&
1322 (focus->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
1323 {
1324 wxNavigationKeyEvent new_event;
1325 new_event.SetEventObject( focus );
1326 new_event.SetDirection( !event.ShiftDown() );
1327 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
1328 new_event.SetWindowChange( event.ControlDown() );
1329 new_event.SetCurrentFocus( focus );
1330 handled = focus->GetEventHandler()->ProcessEvent( new_event );
1331 }
1332 /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
1333 if ( (!handled) &&
1334 (keyval == '.' && event.ControlDown() ) )
1335 {
1336 wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
1337 new_event.SetEventObject( focus );
1338 handled = focus->GetEventHandler()->ProcessEvent( new_event );
1339 }
1340 }
1341 }
1342 }
1343
1344 void wxApp::MacHandleKeyUpEvent( EventRecord *ev )
1345 {
1346 // nothing to do
1347 }
1348
1349 void wxApp::MacHandleActivateEvent( EventRecord *ev )
1350 {
1351 WindowRef window = (WindowRef) ev->message ;
1352 if ( window )
1353 {
1354 bool activate = (ev->modifiers & activeFlag ) ;
1355 WindowClass wclass ;
1356 UMAGetWindowClass ( window , &wclass ) ;
1357 if ( wclass == kFloatingWindowClass )
1358 {
1359 // if it is a floater we activate/deactivate the front non-floating window instead
1360 window = UMAFrontNonFloatingWindow() ;
1361 }
1362 wxWindow* win = wxFindWinFromMacWindow( window ) ;
1363 if ( win )
1364 win->MacActivate( ev , activate ) ;
1365 }
1366 }
1367
1368 void wxApp::MacHandleUpdateEvent( EventRecord *ev )
1369 {
1370 WindowRef window = (WindowRef) ev->message ;
1371 wxWindow * win = wxFindWinFromMacWindow( window ) ;
1372 if ( win )
1373 {
1374 win->MacUpdate( ev ) ;
1375 }
1376 }
1377
1378 void wxApp::MacHandleDiskEvent( EventRecord *ev )
1379 {
1380 if ( HiWord( ev->message ) != noErr )
1381 {
1382 #if !TARGET_CARBON
1383 OSErr err ;
1384 Point point ;
1385 SetPt( &point , 100 , 100 ) ;
1386
1387 err = DIBadMount( point , ev->message ) ;
1388 wxASSERT( err == noErr ) ;
1389 #endif
1390 }
1391 }
1392
1393 void wxApp::MacHandleOSEvent( EventRecord *ev )
1394 {
1395 switch( ( ev->message & osEvtMessageMask ) >> 24 )
1396 {
1397 case suspendResumeMessage :
1398 {
1399 bool isResuming = ev->message & resumeFlag ;
1400 bool convertClipboard = ev->message & convertClipboardFlag ;
1401 bool doesActivate = UMAGetProcessModeDoesActivateOnFGSwitch() ;
1402 if ( isResuming )
1403 {
1404 WindowRef oldFrontWindow = NULL ;
1405 WindowRef newFrontWindow = NULL ;
1406
1407 // in case we don't take care of activating ourselves, we have to synchronize
1408 // our idea of the active window with the process manager's - which it already activated
1409
1410 if ( !doesActivate )
1411 oldFrontWindow = UMAFrontNonFloatingWindow() ;
1412
1413 MacResume( convertClipboard ) ;
1414
1415 newFrontWindow = UMAFrontNonFloatingWindow() ;
1416
1417 if ( oldFrontWindow )
1418 {
1419 wxWindow* win = wxFindWinFromMacWindow( oldFrontWindow ) ;
1420 if ( win )
1421 win->MacActivate( ev , false ) ;
1422 }
1423 if ( newFrontWindow )
1424 {
1425 wxWindow* win = wxFindWinFromMacWindow( newFrontWindow ) ;
1426 if ( win )
1427 win->MacActivate( ev , true ) ;
1428 }
1429 }
1430 else
1431 {
1432 MacSuspend( convertClipboard ) ;
1433
1434 // in case this suspending did close an active window, another one might
1435 // have surfaced -> lets deactivate that one
1436
1437 WindowRef newActiveWindow = UMAGetActiveNonFloatingWindow() ;
1438 if ( newActiveWindow )
1439 {
1440 wxWindow* win = wxFindWinFromMacWindow( newActiveWindow ) ;
1441 if ( win )
1442 win->MacActivate( ev , false ) ;
1443 }
1444 }
1445 }
1446 break ;
1447 case mouseMovedMessage :
1448 {
1449 WindowRef window;
1450
1451 wxWindow* currentMouseWindow = NULL ;
1452
1453 MacGetWindowFromPoint( wxPoint( ev->where.h , ev->where.v ) , &currentMouseWindow ) ;
1454
1455 if ( currentMouseWindow != wxWindow::s_lastMouseWindow )
1456 {
1457 wxMouseEvent event ;
1458
1459 bool isDown = !(ev->modifiers & btnState) ; // 1 is for up
1460 bool controlDown = ev->modifiers & controlKey ; // for simulating right mouse
1461
1462 event.m_leftDown = isDown && !controlDown;
1463 event.m_middleDown = FALSE;
1464 event.m_rightDown = isDown && controlDown;
1465 event.m_shiftDown = ev->modifiers & shiftKey;
1466 event.m_controlDown = ev->modifiers & controlKey;
1467 event.m_altDown = ev->modifiers & optionKey;
1468 event.m_metaDown = ev->modifiers & cmdKey;
1469 event.m_x = ev->where.h;
1470 event.m_y = ev->where.v;
1471 event.m_timeStamp = ev->when;
1472 event.SetEventObject(this);
1473
1474 if ( wxWindow::s_lastMouseWindow )
1475 {
1476 wxMouseEvent eventleave(event ) ;
1477 eventleave.SetEventType( wxEVT_LEAVE_WINDOW ) ;
1478 wxWindow::s_lastMouseWindow->GetEventHandler()->ProcessEvent(eventleave);
1479 }
1480 if ( currentMouseWindow )
1481 {
1482 wxMouseEvent evententer(event ) ;
1483 evententer.SetEventType( wxEVT_ENTER_WINDOW ) ;
1484 currentMouseWindow->GetEventHandler()->ProcessEvent(evententer);
1485 }
1486 wxWindow::s_lastMouseWindow = currentMouseWindow ;
1487 }
1488
1489 short windowPart = ::FindWindow(ev->where, &window);
1490
1491 switch (windowPart)
1492 {
1493 case inMenuBar :
1494 break ;
1495 case inSysWindow :
1496 break ;
1497 default:
1498 {
1499 if ( s_lastMouseDown == 0 )
1500 ev->modifiers |= btnState ;
1501
1502 wxWindow* win = wxFindWinFromMacWindow( window ) ;
1503 if ( win )
1504 win->MacMouseMoved( ev , windowPart ) ;
1505 }
1506 break;
1507 }
1508 }
1509 break ;
1510
1511 }
1512 }
1513
1514 void wxApp::MacHandleMenuSelect( int macMenuId , int macMenuItemNum )
1515 {
1516 if (macMenuId == 0)
1517 return; // no menu item selected
1518
1519 if (macMenuId == kwxMacAppleMenuId && macMenuItemNum > 1)
1520 {
1521 #if ! TARGET_CARBON
1522 Str255 deskAccessoryName ;
1523 GrafPtr savedPort ;
1524
1525 GetMenuItemText(GetMenuHandle(kwxMacAppleMenuId), macMenuItemNum, deskAccessoryName);
1526 GetPort(&savedPort);
1527 OpenDeskAcc(deskAccessoryName);
1528 SetPort(savedPort);
1529 #endif
1530 }
1531 else
1532 {
1533 wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
1534 if ( frontwindow && wxMenuBar::MacGetInstalledMenuBar() )
1535 wxMenuBar::MacGetInstalledMenuBar()->MacMenuSelect( frontwindow->GetEventHandler() , 0 , macMenuId , macMenuItemNum ) ;
1536 }
1537 HiliteMenu(0);
1538 }
1539
1540 /*
1541 long wxApp::MacTranslateKey(char key, int mods)
1542 {
1543 }
1544
1545 void wxApp::MacAdjustCursor()
1546 {
1547 }
1548
1549 */
1550 /*
1551 void
1552 wxApp::macAdjustCursor()
1553 {
1554 if (ev->what != kHighLevelEvent)
1555 {
1556 wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow());
1557 if (theMacWxFrame)
1558 {
1559 if (!theMacWxFrame->MacAdjustCursor(ev->where))
1560 ::SetCursor(&(qd.arrow));
1561 }
1562 }
1563 }
1564 */