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