]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/app.cpp
d904e133cb88b3c3fe2b58c5dcbacfab38b62f8f
[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( (AppleEvent*) 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( (AppleEvent*) 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( (AppleEvent*) 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( (AppleEvent*) event , reply) ;
111 }
112
113 OSErr wxApp::MacHandleAEODoc(const 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(const AppleEvent *event , AppleEvent *reply)
123 {
124 return noErr ;
125 }
126
127 OSErr wxApp::MacHandleAEOApp(const AppleEvent *event , AppleEvent *reply)
128 {
129 return noErr ;
130 }
131
132 OSErr wxApp::MacHandleAEQuit(const 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 UMACleanupToolbox() ;
514 if (s_macCursorRgn)
515 ::DisposeRgn(s_macCursorRgn);
516
517 #if 0
518 TerminateAE() ;
519 #endif
520 }
521
522 int wxEntry( int argc, char *argv[] , bool enterLoop )
523 {
524 #ifdef __MWERKS__
525 #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
526 // This seems to be necessary since there are 'rogue'
527 // objects present at this point (perhaps global objects?)
528 // Setting a checkpoint will ignore them as far as the
529 // memory checking facility is concerned.
530 // Of course you may argue that memory allocated in globals should be
531 // checked, but this is a reasonable compromise.
532 wxDebugContext::SetCheckpoint();
533 #endif
534 #endif
535 if (!wxApp::Initialize())
536 return 0;
537 // create the application object or ensure that one already exists
538 if (!wxTheApp)
539 {
540 // The app may have declared a global application object, but we recommend
541 // the IMPLEMENT_APP macro is used instead, which sets an initializer
542 // function for delayed, dynamic app object construction.
543 wxCHECK_MSG( wxApp::GetInitializerFunction(), 0,
544 wxT("No initializer - use IMPLEMENT_APP macro.") );
545
546 wxTheApp = (wxApp*) (*wxApp::GetInitializerFunction()) ();
547 }
548
549 wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") );
550
551 #ifdef __WXMAC__
552 argc = 0 ; // currently we don't support files as parameters
553 #endif
554
555 wxTheApp->argc = argc;
556 wxTheApp->argv = argv;
557
558 // GUI-specific initialization, such as creating an app context.
559 wxTheApp->OnInitGui();
560
561 // we could try to get the open apple events here to adjust argc and argv better
562
563
564 // Here frames insert themselves automatically
565 // into wxTopLevelWindows by getting created
566 // in OnInit().
567
568 int retValue = 0;
569
570 if ( wxTheApp->OnInit() )
571 {
572 if ( enterLoop )
573 {
574 retValue = wxTheApp->OnRun();
575 }
576 else
577 // We want to initialize, but not run or exit immediately.
578 return 1;
579 }
580 //else: app initialization failed, so we skipped OnRun()
581
582 wxWindow *topWindow = wxTheApp->GetTopWindow();
583 if ( topWindow )
584 {
585 // Forcibly delete the window.
586 if ( topWindow->IsKindOf(CLASSINFO(wxFrame)) ||
587 topWindow->IsKindOf(CLASSINFO(wxDialog)) )
588 {
589 topWindow->Close(TRUE);
590 wxTheApp->DeletePendingObjects();
591 }
592 else
593 {
594 delete topWindow;
595 wxTheApp->SetTopWindow(NULL);
596 }
597 }
598
599 wxTheApp->OnExit();
600
601 wxApp::CleanUp();
602
603 return retValue;
604 };
605
606 // Static member initialization
607 wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
608
609 wxApp::wxApp()
610 {
611 m_topWindow = NULL;
612 wxTheApp = this;
613
614 m_wantDebugOutput = TRUE ;
615
616 argc = 0;
617 argv = NULL;
618
619 m_printMode = wxPRINT_WINDOWS;
620 m_exitOnFrameDelete = TRUE;
621 m_auto3D = TRUE;
622 }
623
624 bool wxApp::Initialized()
625 {
626 if (GetTopWindow())
627 return TRUE;
628 else
629 return FALSE;
630 }
631
632 int wxApp::MainLoop()
633 {
634 m_keepGoing = TRUE;
635
636 while (m_keepGoing)
637 {
638 MacDoOneEvent() ;
639 }
640
641 return 0;
642 }
643
644 // Returns TRUE if more time is needed.
645 bool wxApp::ProcessIdle()
646 {
647 wxIdleEvent event;
648 event.SetEventObject(this);
649 ProcessEvent(event);
650
651 return event.MoreRequested();
652 }
653
654 void wxApp::ExitMainLoop()
655 {
656 m_keepGoing = FALSE;
657 }
658
659 // Is a message/event pending?
660 bool wxApp::Pending()
661 {
662 EventRecord event ;
663
664 return EventAvail( everyEvent , &event ) ;
665 }
666
667 // Dispatch a message.
668 void wxApp::Dispatch()
669 {
670 MacDoOneEvent() ;
671 }
672
673 void wxApp::OnIdle(wxIdleEvent& event)
674 {
675 static bool s_inOnIdle = FALSE;
676
677 // Avoid recursion (via ProcessEvent default case)
678 if ( s_inOnIdle )
679 return;
680
681
682 s_inOnIdle = TRUE;
683
684 // 'Garbage' collection of windows deleted with Close().
685 DeletePendingObjects();
686
687 // flush the logged messages if any
688 wxLog *pLog = wxLog::GetActiveTarget();
689 if ( pLog != NULL && pLog->HasPendingMessages() )
690 pLog->Flush();
691
692 // Send OnIdle events to all windows
693 bool needMore = SendIdleEvents();
694
695 if (needMore)
696 event.RequestMore(TRUE);
697
698 // If they are pending events, we must process them: pending events are
699 // either events to the threads other than main or events posted with
700 // wxPostEvent() functions
701 wxMacProcessNotifierAndPendingEvents();
702
703 s_inOnIdle = FALSE;
704 }
705
706 void wxWakeUpIdle()
707 {
708 wxMacWakeUp() ;
709 }
710
711 // Send idle event to all top-level windows
712 bool wxApp::SendIdleEvents()
713 {
714 bool needMore = FALSE;
715 wxNode* node = wxTopLevelWindows.First();
716 while (node)
717 {
718 wxWindow* win = (wxWindow*) node->Data();
719 if (SendIdleEvents(win))
720 needMore = TRUE;
721
722 node = node->Next();
723 }
724 return needMore;
725 }
726
727 // Send idle event to window and all subwindows
728 bool wxApp::SendIdleEvents(wxWindow* win)
729 {
730 bool needMore = FALSE;
731
732 wxIdleEvent event;
733 event.SetEventObject(win);
734 win->ProcessEvent(event);
735
736 if (event.MoreRequested())
737 needMore = TRUE;
738
739 wxNode* node = win->GetChildren().First();
740 while (node)
741 {
742 wxWindow* win = (wxWindow*) node->Data();
743 if (SendIdleEvents(win))
744 needMore = TRUE;
745
746 node = node->Next();
747 }
748 return needMore ;
749 }
750
751 void wxApp::DeletePendingObjects()
752 {
753 wxNode *node = wxPendingDelete.First();
754 while (node)
755 {
756 wxObject *obj = (wxObject *)node->Data();
757
758 delete obj;
759
760 if (wxPendingDelete.Member(obj))
761 delete node;
762
763 // Deleting one object may have deleted other pending
764 // objects, so start from beginning of list again.
765 node = wxPendingDelete.First();
766 }
767 }
768
769 wxIcon
770 wxApp::GetStdIcon(int which) const
771 {
772 switch(which)
773 {
774 case wxICON_INFORMATION:
775 return wxIcon("wxICON_INFO");
776
777 case wxICON_QUESTION:
778 return wxIcon("wxICON_QUESTION");
779
780 case wxICON_EXCLAMATION:
781 return wxIcon("wxICON_WARNING");
782
783 default:
784 wxFAIL_MSG(wxT("requested non existent standard icon"));
785 // still fall through
786
787 case wxICON_HAND:
788 return wxIcon("wxICON_ERROR");
789 }
790 }
791
792 void wxExit()
793 {
794 wxLogError(_("Fatal error: exiting"));
795
796 wxApp::CleanUp();
797 ::ExitToShell() ;
798 }
799
800 void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
801 {
802 if (GetTopWindow())
803 GetTopWindow()->Close(TRUE);
804 }
805
806 // Default behaviour: close the application with prompts. The
807 // user can veto the close, and therefore the end session.
808 void wxApp::OnQueryEndSession(wxCloseEvent& event)
809 {
810 if (GetTopWindow())
811 {
812 if (!GetTopWindow()->Close(!event.CanVeto()))
813 event.Veto(TRUE);
814 }
815 }
816
817 extern "C" void wxCYield() ;
818 void wxCYield()
819 {
820 wxYield() ;
821 }
822
823 // Yield to other processes
824 bool wxYield()
825 {
826 #if wxUSE_THREADS
827 YieldToAnyThread() ;
828 #endif
829 EventRecord event ;
830
831 long sleepTime = 0 ; //::GetCaretTime();
832
833 while ( !wxTheApp->IsExiting() && WaitNextEvent(everyEvent, &event,sleepTime, wxApp::s_macCursorRgn))
834 {
835 wxTheApp->MacHandleOneEvent( &event );
836 }
837
838 wxMacProcessNotifierAndPendingEvents() ;
839 return TRUE;
840 }
841
842 // platform specifics
843
844 void wxApp::MacSuspend( bool convertClipboard )
845 {
846 // we have to deactive the window manually
847
848 wxWindow* window = GetTopWindow() ;
849 if ( window )
850 window->MacActivate( MacGetCurrentEvent() , false ) ;
851
852 s_lastMouseDown = 0 ;
853 if( convertClipboard )
854 {
855 MacConvertPrivateToPublicScrap() ;
856 }
857
858 UMAHideFloatingWindows() ;
859 }
860
861 void wxApp::MacResume( bool convertClipboard )
862 {
863 s_lastMouseDown = 0 ;
864 if( convertClipboard )
865 {
866 MacConvertPublicToPrivateScrap() ;
867 }
868
869 UMAShowFloatingWindows() ;
870 }
871
872 void wxApp::MacConvertPrivateToPublicScrap()
873 {
874 }
875
876 void wxApp::MacConvertPublicToPrivateScrap()
877 {
878 }
879
880 void wxApp::MacDoOneEvent()
881 {
882 EventRecord event ;
883
884 long sleepTime = ::GetCaretTime();
885
886 if (WaitNextEvent(everyEvent, &event,sleepTime, s_macCursorRgn))
887 {
888 MacHandleOneEvent( &event );
889 }
890 else
891 {
892 // idlers
893 WindowPtr window = UMAFrontWindow() ;
894 if ( window )
895 UMAIdleControls( window ) ;
896
897 wxTheApp->ProcessIdle() ;
898 }
899 if ( event.what != kHighLevelEvent )
900 SetRectRgn( s_macCursorRgn , event.where.h - 1 , event.where.v - 1, event.where.h + 1 , event.where.v + 1 ) ;
901
902 // repeaters
903
904 wxMacProcessNotifierAndPendingEvents() ;
905 }
906
907 void wxApp::MacHandleOneEvent( EventRecord *ev )
908 {
909 m_macCurrentEvent = ev ;
910
911 wxApp::sm_lastMessageTime = ev->when ;
912
913 switch (ev->what)
914 {
915 case mouseDown:
916 MacHandleMouseDownEvent( ev ) ;
917 if ( ev->modifiers & controlKey )
918 s_lastMouseDown = 2;
919 else
920 s_lastMouseDown = 1;
921 break;
922 case mouseUp:
923 if ( s_lastMouseDown == 2 )
924 {
925 ev->modifiers |= controlKey ;
926 }
927 else
928 {
929 ev->modifiers &= ~controlKey ;
930 }
931 MacHandleMouseUpEvent( ev ) ;
932 s_lastMouseDown = 0;
933 break;
934 case activateEvt:
935 MacHandleActivateEvent( ev ) ;
936 break;
937 case updateEvt:
938 MacHandleUpdateEvent( ev ) ;
939 break;
940 case keyDown:
941 case autoKey:
942 MacHandleKeyDownEvent( ev ) ;
943 break;
944 case keyUp:
945 MacHandleKeyUpEvent( ev ) ;
946 break;
947 case diskEvt:
948 MacHandleDiskEvent( ev ) ;
949 break;
950 case osEvt:
951 MacHandleOSEvent( ev ) ;
952 break;
953 case kHighLevelEvent:
954 MacHandleHighLevelEvent( ev ) ;
955 break;
956 default:
957 break;
958 }
959 wxMacProcessNotifierAndPendingEvents() ;
960 }
961
962 void wxApp::MacHandleHighLevelEvent( EventRecord *ev )
963 {
964 ::AEProcessAppleEvent( ev ) ;
965 }
966
967 bool s_macIsInModalLoop = false ;
968
969 void wxApp::MacHandleMouseDownEvent( EventRecord *ev )
970 {
971 wxToolTip::RemoveToolTips() ;
972
973 WindowRef window;
974 WindowRef frontWindow = UMAFrontNonFloatingWindow() ;
975 WindowAttributes frontWindowAttributes = NULL ;
976 if ( frontWindow )
977 UMAGetWindowAttributes( frontWindow , &frontWindowAttributes ) ;
978
979 short windowPart = ::FindWindow(ev->where, &window);
980 wxWindow* win = wxFindWinFromMacWindow( window ) ;
981
982 BitMap screenBits;
983 GetQDGlobalsScreenBits( &screenBits );
984
985 switch (windowPart)
986 {
987 case inMenuBar :
988 if ( s_macIsInModalLoop )
989 {
990 SysBeep ( 30 ) ;
991 }
992 else
993 {
994 UInt32 menuresult = MenuSelect(ev->where) ;
995 MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) );
996 s_lastMouseDown = 0;
997 }
998 break ;
999 #if !TARGET_CARBON
1000 case inSysWindow :
1001 SystemClick( ev , window ) ;
1002 s_lastMouseDown = 0;
1003 break ;
1004 #endif
1005 case inDrag :
1006 if ( window != frontWindow && s_macIsInModalLoop && !(ev->modifiers & cmdKey ) )
1007 {
1008 SysBeep ( 30 ) ;
1009 }
1010 else
1011 {
1012 DragWindow(window, ev->where, &screenBits.bounds);
1013 if (win)
1014 {
1015 GrafPtr port ;
1016 GetPort( &port ) ;
1017 Point pt = { 0, 0 } ;
1018 #if TARGET_CARBON
1019 SetPort( GetWindowPort(window) ) ;
1020 #else
1021 SetPort( (window) ) ;
1022 #endif
1023 SetOrigin( 0 , 0 ) ;
1024 LocalToGlobal( &pt ) ;
1025 SetPort( port ) ;
1026 win->SetSize( pt.h , pt.v , -1 ,
1027 -1 , wxSIZE_USE_EXISTING);
1028 }
1029 s_lastMouseDown = 0;
1030 }
1031 break ;
1032 case inGoAway:
1033 if (TrackGoAway(window, ev->where))
1034 {
1035 if ( win )
1036 win->Close() ;
1037 }
1038 s_lastMouseDown = 0;
1039 break;
1040 case inGrow:
1041 int growResult = GrowWindow(window , ev->where, &screenBits.bounds);
1042 if (growResult != 0)
1043 {
1044 int newWidth = LoWord(growResult);
1045 int newHeight = HiWord(growResult);
1046 int oldWidth, oldHeight;
1047
1048
1049 if (win)
1050 {
1051 win->GetSize(&oldWidth, &oldHeight);
1052 if (newWidth == 0)
1053 newWidth = oldWidth;
1054 if (newHeight == 0)
1055 newHeight = oldHeight;
1056 win->SetSize( -1, -1, newWidth, newHeight, wxSIZE_USE_EXISTING);
1057 }
1058 }
1059 s_lastMouseDown = 0;
1060 break;
1061 case inZoomIn:
1062 case inZoomOut:
1063 if (TrackBox(window, ev->where, windowPart))
1064 {
1065 // TODO setup size event
1066 ZoomWindow( window , windowPart , false ) ;
1067 if (win)
1068 {
1069 Rect tempRect ;
1070
1071 GetWindowPortBounds(window, &tempRect ) ;
1072 win->SetSize( -1, -1, tempRect.right-tempRect.left ,
1073 tempRect.bottom-tempRect.top, wxSIZE_USE_EXISTING);
1074 }
1075 }
1076 s_lastMouseDown = 0;
1077 break;
1078 case inCollapseBox :
1079 // TODO setup size event
1080 s_lastMouseDown = 0;
1081 break ;
1082
1083 case inContent :
1084 {
1085 GrafPtr port ;
1086 GetPort( &port ) ;
1087 #if TARGET_CARBON
1088 SetPort( GetWindowPort(window) ) ;
1089 #else
1090 SetPort( (window) ) ;
1091 #endif
1092 SetOrigin( 0 , 0 ) ;
1093 SetPort( port ) ;
1094 }
1095 if ( window != frontWindow )
1096 {
1097 if ( s_macIsInModalLoop )
1098 {
1099 SysBeep ( 30 ) ;
1100 }
1101 else if ( UMAIsWindowFloating( window ) )
1102 {
1103 if ( win )
1104 win->MacMouseDown( ev , windowPart ) ;
1105 }
1106 else
1107 {
1108 UMASelectWindow( window ) ;
1109 }
1110 }
1111 else
1112 {
1113 if ( win )
1114 win->MacMouseDown( ev , windowPart ) ;
1115 }
1116 break ;
1117
1118 default:
1119 break;
1120 }
1121 }
1122
1123 void wxApp::MacHandleMouseUpEvent( EventRecord *ev )
1124 {
1125 WindowRef window;
1126
1127 short windowPart = ::FindWindow(ev->where, &window);
1128
1129 switch (windowPart)
1130 {
1131 case inMenuBar :
1132 break ;
1133 case inSysWindow :
1134 break ;
1135 default:
1136 {
1137 wxWindow* win = wxFindWinFromMacWindow( window ) ;
1138 if ( win )
1139 win->MacMouseUp( ev , windowPart ) ;
1140 }
1141 break;
1142 }
1143 }
1144
1145 long wxMacTranslateKey(unsigned char key, unsigned char code)
1146 {
1147 long retval = key ;
1148 switch (key)
1149 {
1150 case 0x01 :
1151 retval = WXK_HOME;
1152 break;
1153 case 0x03 :
1154 retval = WXK_RETURN;
1155 break;
1156 case 0x04 :
1157 retval = WXK_END;
1158 break;
1159 case 0x05 :
1160 retval = WXK_HELP;
1161 break;
1162 case 0x08 :
1163 retval = WXK_BACK;
1164 break;
1165 case 0x09 :
1166 retval = WXK_TAB;
1167 break;
1168 case 0x0b :
1169 retval = WXK_PAGEUP;
1170 break;
1171 case 0x0c :
1172 retval = WXK_PAGEDOWN;
1173 break;
1174 case 0x0d :
1175 retval = WXK_RETURN;
1176 break;
1177 case 0x10 :
1178 {
1179 switch( code )
1180 {
1181 case 0x7a :
1182 retval = WXK_F1 ;
1183 break;
1184 case 0x78 :
1185 retval = WXK_F2 ;
1186 break;
1187 case 0x63 :
1188 retval = WXK_F3 ;
1189 break;
1190 case 0x76 :
1191 retval = WXK_F4 ;
1192 break;
1193 case 0x60 :
1194 retval = WXK_F5 ;
1195 break;
1196 case 0x61 :
1197 retval = WXK_F6 ;
1198 break;
1199 case 0x62:
1200 retval = WXK_F7 ;
1201 break;
1202 case 0x64 :
1203 retval = WXK_F8 ;
1204 break;
1205 case 0x65 :
1206 retval = WXK_F9 ;
1207 break;
1208 case 0x6D :
1209 retval = WXK_F10 ;
1210 break;
1211 case 0x67 :
1212 retval = WXK_F11 ;
1213 break;
1214 case 0x6F :
1215 retval = WXK_F12 ;
1216 break;
1217 case 0x69 :
1218 retval = WXK_F13 ;
1219 break;
1220 case 0x6B :
1221 retval = WXK_F14 ;
1222 break;
1223 case 0x71 :
1224 retval = WXK_F15 ;
1225 break;
1226 }
1227 }
1228 break ;
1229 case 0x1b :
1230 retval = WXK_ESCAPE ;
1231 break ;
1232 case 0x1c :
1233 retval = WXK_LEFT ;
1234 break ;
1235 case 0x1d :
1236 retval = WXK_RIGHT ;
1237 break ;
1238 case 0x1e :
1239 retval = WXK_UP ;
1240 break ;
1241 case 0x1f :
1242 retval = WXK_DOWN ;
1243 break ;
1244 case 0x7F :
1245 retval = WXK_DELETE ;
1246 default:
1247 break ;
1248 } // end switch
1249
1250 return retval;
1251 }
1252
1253 void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
1254 {
1255 wxToolTip::RemoveToolTips() ;
1256
1257 UInt32 menuresult = UMAMenuEvent(ev) ;
1258 if ( HiWord( menuresult ) )
1259 {
1260 if ( !s_macIsInModalLoop )
1261 MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ;
1262 }
1263 else
1264 {
1265 short keycode ;
1266 short keychar ;
1267 keychar = short(ev->message & charCodeMask);
1268 keycode = short(ev->message & keyCodeMask) >> 8 ;
1269
1270 wxWindow* focus = wxWindow::FindFocus() ;
1271 if ( focus )
1272 {
1273 long keyval = wxMacTranslateKey(keychar, keycode) ;
1274
1275 wxKeyEvent event(wxEVT_KEY_DOWN);
1276 event.m_shiftDown = ev->modifiers & shiftKey;
1277 event.m_controlDown = ev->modifiers & controlKey;
1278 event.m_altDown = ev->modifiers & optionKey;
1279 event.m_metaDown = ev->modifiers & cmdKey;
1280 event.m_keyCode = keyval;
1281 event.m_x = ev->where.h;
1282 event.m_y = ev->where.v;
1283 event.m_timeStamp = ev->when;
1284 event.SetEventObject(focus);
1285 bool handled = focus->GetEventHandler()->ProcessEvent( event ) ;
1286 if ( !handled )
1287 {
1288 #if wxUSE_ACCEL
1289 if (!handled)
1290 {
1291 wxWindow *ancestor = focus;
1292 /*
1293 while (ancestor)
1294 {
1295 int command = ancestor->GetAcceleratorTable()->GetCommand( event );
1296 if (command != -1)
1297 {
1298 wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
1299 handled = ancestor->GetEventHandler()->ProcessEvent( command_event );
1300 break;
1301 }
1302 if (ancestor->m_isFrame)
1303 break;
1304 ancestor = ancestor->GetParent();
1305 }
1306 */
1307 }
1308 #endif // wxUSE_ACCEL
1309 }
1310 if (!handled)
1311 {
1312 wxKeyEvent event(wxEVT_CHAR);
1313 event.m_shiftDown = ev->modifiers & shiftKey;
1314 event.m_controlDown = ev->modifiers & controlKey;
1315 event.m_altDown = ev->modifiers & optionKey;
1316 event.m_metaDown = ev->modifiers & cmdKey;
1317 event.m_keyCode = keyval;
1318 event.m_x = ev->where.h;
1319 event.m_y = ev->where.v;
1320 event.m_timeStamp = ev->when;
1321 event.SetEventObject(focus);
1322 handled = focus->GetEventHandler()->ProcessEvent( event ) ;
1323 }
1324 if ( !handled &&
1325 (keyval == WXK_TAB) &&
1326 (!focus->HasFlag(wxTE_PROCESS_TAB)) &&
1327 (focus->GetParent()) &&
1328 (focus->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
1329 {
1330 wxNavigationKeyEvent new_event;
1331 new_event.SetEventObject( focus );
1332 new_event.SetDirection( !event.ShiftDown() );
1333 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
1334 new_event.SetWindowChange( event.ControlDown() );
1335 new_event.SetCurrentFocus( focus );
1336 handled = focus->GetEventHandler()->ProcessEvent( new_event );
1337 }
1338 /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
1339 if ( (!handled) &&
1340 (keyval == '.' && event.ControlDown() ) )
1341 {
1342 wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
1343 new_event.SetEventObject( focus );
1344 handled = focus->GetEventHandler()->ProcessEvent( new_event );
1345 }
1346 }
1347 }
1348 }
1349
1350 void wxApp::MacHandleKeyUpEvent( EventRecord *ev )
1351 {
1352 // nothing to do
1353 }
1354
1355 void wxApp::MacHandleActivateEvent( EventRecord *ev )
1356 {
1357 WindowRef window = (WindowRef) ev->message ;
1358 if ( window )
1359 {
1360 bool activate = (ev->modifiers & activeFlag ) ;
1361 WindowClass wclass ;
1362 UMAGetWindowClass ( window , &wclass ) ;
1363 if ( wclass == kFloatingWindowClass )
1364 {
1365 // if it is a floater we activate/deactivate the front non-floating window instead
1366 window = UMAFrontNonFloatingWindow() ;
1367 }
1368 wxWindow* win = wxFindWinFromMacWindow( window ) ;
1369 if ( win )
1370 win->MacActivate( ev , activate ) ;
1371 }
1372 }
1373
1374 void wxApp::MacHandleUpdateEvent( EventRecord *ev )
1375 {
1376 WindowRef window = (WindowRef) ev->message ;
1377 wxWindow * win = wxFindWinFromMacWindow( window ) ;
1378 if ( win )
1379 {
1380 win->MacUpdate( ev ) ;
1381 }
1382 else
1383 {
1384 // since there is no way of telling this foreign window to update itself
1385 // we have to invalidate the update region otherwise we keep getting the same
1386 // event over and over again
1387 BeginUpdate( window ) ;
1388 EndUpdate( window ) ;
1389 }
1390 }
1391
1392 void wxApp::MacHandleDiskEvent( EventRecord *ev )
1393 {
1394 if ( HiWord( ev->message ) != noErr )
1395 {
1396 #if !TARGET_CARBON
1397 OSErr err ;
1398 Point point ;
1399 SetPt( &point , 100 , 100 ) ;
1400
1401 err = DIBadMount( point , ev->message ) ;
1402 wxASSERT( err == noErr ) ;
1403 #endif
1404 }
1405 }
1406
1407 void wxApp::MacHandleOSEvent( EventRecord *ev )
1408 {
1409 switch( ( ev->message & osEvtMessageMask ) >> 24 )
1410 {
1411 case suspendResumeMessage :
1412 {
1413 bool isResuming = ev->message & resumeFlag ;
1414 bool convertClipboard = ev->message & convertClipboardFlag ;
1415 bool doesActivate = UMAGetProcessModeDoesActivateOnFGSwitch() ;
1416 if ( isResuming )
1417 {
1418 WindowRef oldFrontWindow = NULL ;
1419 WindowRef newFrontWindow = NULL ;
1420
1421 // in case we don't take care of activating ourselves, we have to synchronize
1422 // our idea of the active window with the process manager's - which it already activated
1423
1424 if ( !doesActivate )
1425 oldFrontWindow = UMAFrontNonFloatingWindow() ;
1426
1427 MacResume( convertClipboard ) ;
1428
1429 newFrontWindow = UMAFrontNonFloatingWindow() ;
1430
1431 if ( oldFrontWindow )
1432 {
1433 wxWindow* win = wxFindWinFromMacWindow( oldFrontWindow ) ;
1434 if ( win )
1435 win->MacActivate( ev , false ) ;
1436 }
1437 if ( newFrontWindow )
1438 {
1439 wxWindow* win = wxFindWinFromMacWindow( newFrontWindow ) ;
1440 if ( win )
1441 win->MacActivate( ev , true ) ;
1442 }
1443 }
1444 else
1445 {
1446 MacSuspend( convertClipboard ) ;
1447
1448 // in case this suspending did close an active window, another one might
1449 // have surfaced -> lets deactivate that one
1450
1451 WindowRef newActiveWindow = UMAGetActiveNonFloatingWindow() ;
1452 if ( newActiveWindow )
1453 {
1454 wxWindow* win = wxFindWinFromMacWindow( newActiveWindow ) ;
1455 if ( win )
1456 win->MacActivate( ev , false ) ;
1457 }
1458 }
1459 }
1460 break ;
1461 case mouseMovedMessage :
1462 {
1463 WindowRef window;
1464
1465 wxWindow* currentMouseWindow = NULL ;
1466
1467 MacGetWindowFromPoint( wxPoint( ev->where.h , ev->where.v ) , &currentMouseWindow ) ;
1468
1469 if ( currentMouseWindow != wxWindow::s_lastMouseWindow )
1470 {
1471 wxMouseEvent event ;
1472
1473 bool isDown = !(ev->modifiers & btnState) ; // 1 is for up
1474 bool controlDown = ev->modifiers & controlKey ; // for simulating right mouse
1475
1476 event.m_leftDown = isDown && !controlDown;
1477 event.m_middleDown = FALSE;
1478 event.m_rightDown = isDown && controlDown;
1479 event.m_shiftDown = ev->modifiers & shiftKey;
1480 event.m_controlDown = ev->modifiers & controlKey;
1481 event.m_altDown = ev->modifiers & optionKey;
1482 event.m_metaDown = ev->modifiers & cmdKey;
1483 event.m_x = ev->where.h;
1484 event.m_y = ev->where.v;
1485 event.m_timeStamp = ev->when;
1486 event.SetEventObject(this);
1487
1488 if ( wxWindow::s_lastMouseWindow )
1489 {
1490 wxMouseEvent eventleave(event ) ;
1491 eventleave.SetEventType( wxEVT_LEAVE_WINDOW ) ;
1492 wxWindow::s_lastMouseWindow->GetEventHandler()->ProcessEvent(eventleave);
1493 }
1494 if ( currentMouseWindow )
1495 {
1496 wxMouseEvent evententer(event ) ;
1497 evententer.SetEventType( wxEVT_ENTER_WINDOW ) ;
1498 currentMouseWindow->GetEventHandler()->ProcessEvent(evententer);
1499 }
1500 wxWindow::s_lastMouseWindow = currentMouseWindow ;
1501 }
1502
1503 short windowPart = ::FindWindow(ev->where, &window);
1504
1505 switch (windowPart)
1506 {
1507 // fixes for setting the cursor back from dominic mazzoni
1508 case inMenuBar :
1509 UMAShowArrowCursor();
1510 break ;
1511 case inSysWindow :
1512 UMAShowArrowCursor();
1513 break ;
1514 default:
1515 {
1516 if ( s_lastMouseDown == 0 )
1517 ev->modifiers |= btnState ;
1518
1519 wxWindow* win = wxFindWinFromMacWindow( window ) ;
1520 if ( win )
1521 win->MacMouseMoved( ev , windowPart ) ;
1522 else
1523 UMAShowArrowCursor();
1524
1525 }
1526 break;
1527 }
1528 }
1529 break ;
1530
1531 }
1532 }
1533
1534 void wxApp::MacHandleMenuSelect( int macMenuId , int macMenuItemNum )
1535 {
1536 if (macMenuId == 0)
1537 return; // no menu item selected
1538
1539 if (macMenuId == kwxMacAppleMenuId && macMenuItemNum > 1)
1540 {
1541 #if ! TARGET_CARBON
1542 Str255 deskAccessoryName ;
1543 GrafPtr savedPort ;
1544
1545 GetMenuItemText(GetMenuHandle(kwxMacAppleMenuId), macMenuItemNum, deskAccessoryName);
1546 GetPort(&savedPort);
1547 OpenDeskAcc(deskAccessoryName);
1548 SetPort(savedPort);
1549 #endif
1550 }
1551 else
1552 {
1553 wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
1554 if ( frontwindow && wxMenuBar::MacGetInstalledMenuBar() )
1555 wxMenuBar::MacGetInstalledMenuBar()->MacMenuSelect( frontwindow->GetEventHandler() , 0 , macMenuId , macMenuItemNum ) ;
1556 }
1557 HiliteMenu(0);
1558 }
1559
1560 /*
1561 long wxApp::MacTranslateKey(char key, int mods)
1562 {
1563 }
1564
1565 void wxApp::MacAdjustCursor()
1566 {
1567 }
1568
1569 */
1570 /*
1571 void
1572 wxApp::macAdjustCursor()
1573 {
1574 if (ev->what != kHighLevelEvent)
1575 {
1576 wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow());
1577 if (theMacWxFrame)
1578 {
1579 if (!theMacWxFrame->MacAdjustCursor(ev->where))
1580 ::SetCursor(&(qd.arrow));
1581 }
1582 }
1583 }
1584 */