1 /////////////////////////////////////////////////////////////////////////////
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "app.h"
18 #include "wx/window.h"
20 #include "wx/button.h"
23 #include "wx/gdicmn.h"
26 #include "wx/cursor.h"
29 #include "wx/palette.h"
31 #include "wx/dialog.h"
32 #include "wx/msgdlg.h"
34 #include "wx/module.h"
35 #include "wx/memory.h"
36 #include "wx/tooltip.h"
37 #include "wx/textctrl.h"
39 #if wxUSE_WX_RESOURCES
40 # include "wx/resource.h"
55 #include "wx/mac/uma.h"
56 #include "wx/mac/macnotfy.h"
59 # include <CoreServices/CoreServices.h>
60 # if defined(WXMAKINGDLL)
61 # include <mach-o/dyld.h>
66 # include <ToolUtils.h>
67 # include <DiskInit.h>
71 extern char *wxBuffer
;
72 extern wxList wxPendingDelete
;
73 extern wxList
*wxWinMacWindowList
;
74 extern wxList
*wxWinMacControlList
;
76 wxApp
*wxTheApp
= NULL
;
78 #if !USE_SHARED_LIBRARY
79 IMPLEMENT_DYNAMIC_CLASS(wxApp
, wxEvtHandler
)
80 BEGIN_EVENT_TABLE(wxApp
, wxEvtHandler
)
81 EVT_IDLE(wxApp::OnIdle
)
82 EVT_END_SESSION(wxApp::OnEndSession
)
83 EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession
)
88 const short kMacMinHeap
= (29 * 1024) ;
89 // platform specific static variables
91 const short kwxMacMenuBarResource
= 1 ;
92 const short kwxMacAppleMenuId
= 1 ;
94 WXHRGN
wxApp::s_macCursorRgn
= NULL
;
95 wxWindow
* wxApp::s_captureWindow
= NULL
;
96 int wxApp::s_lastMouseDown
= 0 ;
97 long wxApp::sm_lastMessageTime
= 0;
99 bool wxApp::s_macDefaultEncodingIsPC
= true ;
100 bool wxApp::s_macSupportPCMenuShortcuts
= true ;
101 long wxApp::s_macAboutMenuItemId
= wxID_ABOUT
;
102 wxString
wxApp::s_macHelpMenuTitleName
= "&Help" ;
104 pascal OSErr
AEHandleODoc( const AppleEvent
*event
, AppleEvent
*reply
, long refcon
) ;
105 pascal OSErr
AEHandleOApp( const AppleEvent
*event
, AppleEvent
*reply
, long refcon
) ;
106 pascal OSErr
AEHandlePDoc( const AppleEvent
*event
, AppleEvent
*reply
, long refcon
) ;
107 pascal OSErr
AEHandleQuit( const AppleEvent
*event
, AppleEvent
*reply
, long refcon
) ;
110 pascal OSErr
AEHandleODoc( const AppleEvent
*event
, AppleEvent
*reply
, long refcon
)
112 // GD: UNUSED wxApp* app = (wxApp*) refcon ;
113 return wxTheApp
->MacHandleAEODoc( (AppleEvent
*) event
, reply
) ;
116 pascal OSErr
AEHandleOApp( const AppleEvent
*event
, AppleEvent
*reply
, long refcon
)
118 // GD: UNUSED wxApp* app = (wxApp*) refcon ;
119 return wxTheApp
->MacHandleAEOApp( (AppleEvent
*) event
, reply
) ;
122 pascal OSErr
AEHandlePDoc( const AppleEvent
*event
, AppleEvent
*reply
, long refcon
)
124 // GD: UNUSED wxApp* app = (wxApp*) refcon ;
125 return wxTheApp
->MacHandleAEPDoc( (AppleEvent
*) event
, reply
) ;
128 pascal OSErr
AEHandleQuit( const AppleEvent
*event
, AppleEvent
*reply
, long refcon
)
130 // GD: UNUSED wxApp* app = (wxApp*) refcon ;
131 return wxTheApp
->MacHandleAEQuit( (AppleEvent
*) event
, reply
) ;
134 short wxApp::MacHandleAEODoc(const WXEVENTREF event
, WXEVENTREF reply
)
137 ProcessSerialNumber PSN
;
138 PSN
.highLongOfPSN
= 0 ;
139 PSN
.lowLongOfPSN
= kCurrentProcess
;
140 SetFrontProcess( &PSN
) ;
144 short wxApp::MacHandleAEPDoc(const WXEVENTREF event
, WXEVENTREF reply
)
149 short wxApp::MacHandleAEOApp(const WXEVENTREF event
, WXEVENTREF reply
)
154 short wxApp::MacHandleAEQuit(const WXEVENTREF event
, WXEVENTREF reply
)
156 wxWindow
* win
= GetTopWindow() ;
168 char StringMac
[] = "\x0d\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
169 "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
170 "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf"
171 "\xb1\xb4\xb5\xb6\xbb\xbc\xbe\xbf"
172 "\xc0\xc1\xc2\xc4\xc7\xc8\xc9\xcb\xcc\xcd\xce\xcf"
173 "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd8\xca\xdb" ;
175 char StringANSI
[] = "\x0a\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8"
176 "\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC"
177 "\x86\xBA\xA2\xA3\xA7\x95\xB6\xDF\xAE\xA9\x99\xB4\xA8\xC6\xD8"
178 "\xB1\xA5\xB5\xF0\xAA\xBA\xE6\xF8"
179 "\xBF\xA1\xAC\x83\xAB\xBB\x85\xC0\xC3\xD5\x8C\x9C"
180 "\x96\x97\x93\x94\x91\x92\xF7\xFF\xA0\x80" ;
182 void wxMacConvertFromPC( const char *from
, char *to
, int len
)
187 for( int i
= 0 ; i
< len
; ++ i
)
189 c
= strchr( StringANSI
, *from
) ;
192 *to
= StringMac
[ c
- StringANSI
] ;
200 for( int i
= 0 ; i
< len
; ++ i
)
202 c
= strchr( StringANSI
, *from
) ;
205 *to
= StringMac
[ c
- StringANSI
] ;
217 void wxMacConvertToPC( const char *from
, char *to
, int len
)
222 for( int i
= 0 ; i
< len
; ++ i
)
224 c
= strchr( StringMac
, *from
) ;
227 *to
= StringANSI
[ c
- StringMac
] ;
235 for( int i
= 0 ; i
< len
; ++ i
)
237 c
= strchr( StringMac
, *from
) ;
240 *to
= StringANSI
[ c
- StringMac
] ;
252 void wxMacConvertFromPC( char * p
)
255 int len
= strlen ( p
) ;
257 wxMacConvertFromPC( ptr
, ptr
, len
) ;
260 void wxMacConvertFromPCForControls( char * p
)
263 int len
= strlen ( p
) ;
265 wxMacConvertFromPC( ptr
, ptr
, len
) ;
266 for ( unsigned int i
= 0 ; i
< strlen ( ptr
) ; i
++ )
268 if ( ptr
[i
] == '&' && ptr
[i
]+1 != ' ' )
270 memmove( &ptr
[i
] , &ptr
[i
+1] , strlen( &ptr
[i
+1] ) + 1) ;
275 void wxMacConvertFromPC( unsigned char *p
)
277 char *ptr
= (char*) p
+ 1 ;
280 wxMacConvertFromPC( ptr
, ptr
, len
) ;
283 extern char *wxBuffer
;
285 wxString
wxMacMakeMacStringFromPC( const char * p
)
287 const char *ptr
= p
;
288 int len
= strlen ( p
) ;
289 char *buf
= wxBuffer
;
291 if ( len
>= BUFSIZ
+ 512 )
293 buf
= new char [len
+1] ;
296 wxMacConvertFromPC( ptr
, buf
, len
) ;
298 wxString
result( buf
) ;
299 if ( buf
!= wxBuffer
)
305 void wxMacConvertToPC( char * p
)
308 int len
= strlen ( p
) ;
310 wxMacConvertToPC( ptr
, ptr
, len
) ;
313 void wxMacConvertToPC( unsigned char *p
)
315 char *ptr
= (char*) p
+ 1 ;
318 wxMacConvertToPC( ptr
, ptr
, len
) ;
321 wxString
wxMacMakePCStringFromMac( const char * p
)
323 const char *ptr
= p
;
324 int len
= strlen ( p
) ;
325 char *buf
= wxBuffer
;
327 if ( len
>= BUFSIZ
+ 512 )
329 buf
= new char [len
+1] ;
332 wxMacConvertToPC( ptr
, buf
, len
) ;
335 wxString
result( buf
) ;
336 if ( buf
!= wxBuffer
)
341 wxString
wxMacMakeStringFromMacString( const char* from
, bool mac2pcEncoding
)
345 return wxMacMakePCStringFromMac( from
) ;
349 return wxString( from
) ;
353 wxString
wxMacMakeStringFromPascal( StringPtr from
, bool mac2pcEncoding
)
355 // this is safe since a pascal string can never be larger than 256 bytes
357 CopyPascalStringToC( from
, s
) ;
360 return wxMacMakePCStringFromMac( s
) ;
364 return wxString( s
) ;
368 void wxMacStringToPascal( const char * from
, StringPtr to
, bool pc2macEncoding
)
372 CopyCStringToPascal( wxMacMakeMacStringFromPC( from
) , to
) ;
376 CopyCStringToPascal( from
, to
) ;
380 #if defined(WXMAKINGDLL) && !defined(__DARWIN__)
381 // we know it's there ;-)
382 WXIMPORT
char std::__throws_bad_alloc
;
385 bool wxApp::Initialize()
391 UMAInitToolbox( 4 ) ;
392 SetEventMask( everyEvent
) ;
393 UMAShowWatchCursor() ;
395 #if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
396 AEInstallEventHandler( kCoreEventClass
, kAEOpenDocuments
, NewAEEventHandlerUPP(AEHandleODoc
) ,
397 (long) wxTheApp
, FALSE
) ;
398 AEInstallEventHandler( kCoreEventClass
, kAEOpenApplication
, NewAEEventHandlerUPP(AEHandleOApp
) ,
399 (long) wxTheApp
, FALSE
) ;
400 AEInstallEventHandler( kCoreEventClass
, kAEPrintDocuments
, NewAEEventHandlerUPP(AEHandlePDoc
) ,
401 (long) wxTheApp
, FALSE
) ;
402 AEInstallEventHandler( kCoreEventClass
, kAEQuitApplication
, NewAEEventHandlerUPP(AEHandleQuit
) ,
403 (long) wxTheApp
, FALSE
) ;
405 AEInstallEventHandler( kCoreEventClass
, kAEOpenDocuments
, NewAEEventHandlerProc(AEHandleODoc
) ,
406 (long) wxTheApp
, FALSE
) ;
407 AEInstallEventHandler( kCoreEventClass
, kAEOpenApplication
, NewAEEventHandlerProc(AEHandleOApp
) ,
408 (long) wxTheApp
, FALSE
) ;
409 AEInstallEventHandler( kCoreEventClass
, kAEPrintDocuments
, NewAEEventHandlerProc(AEHandlePDoc
) ,
410 (long) wxTheApp
, FALSE
) ;
411 AEInstallEventHandler( kCoreEventClass
, kAEQuitApplication
, NewAEEventHandlerProc(AEHandleQuit
) ,
412 (long) wxTheApp
, FALSE
) ;
417 // test the minimal configuration necessary
423 if (Gestalt(gestaltMachineType
, &theMachine
) != noErr
)
425 error
= kMacSTRWrongMachine
;
427 else if (theMachine
< gestaltMacPlus
)
429 error
= kMacSTRWrongMachine
;
431 else if (Gestalt(gestaltSystemVersion
, &theSystem
) != noErr
)
433 error
= kMacSTROldSystem
;
435 else if ( theSystem
< 0x0860 )
437 error
= kMacSTROldSystem
;
439 else if ((long)GetApplLimit() - (long)ApplicationZone() < kMacMinHeap
)
441 error
= kMacSTRSmallSize
;
447 if ( !UMAHasAppearance() )
449 error = kMacSTRNoPre8Yet ;
455 // if we encountered any problems so far, give the error code and exit immediately
459 wxStAppResource resload
;
463 GetIndString(message
, 128, error
);
464 UMAShowArrowCursor() ;
465 ParamText("\pFatal Error", message
, (ConstStr255Param
)"\p", (ConstStr255Param
)"\p");
466 itemHit
= Alert(128, nil
);
471 #if __option(profile)
472 ProfilerInit( collectDetailed
, bestTimeBase
, 20000 , 40 ) ;
477 // now avoid exceptions thrown for new (bad_alloc)
478 std::__throws_bad_alloc
= FALSE
;
481 s_macCursorRgn
= ::NewRgn() ;
483 wxBuffer
= new char[BUFSIZ
+ 512];
485 wxClassInfo::InitializeClasses();
488 // wxGetResource(wxT("wxWindows"), wxT("OsVersion"), &wxOsVersion);
492 wxPendingEventsLocker
= new wxCriticalSection
;
495 wxTheColourDatabase
= new wxColourDatabase(wxKEY_STRING
);
496 wxTheColourDatabase
->Initialize();
500 // flush the logged messages if any and install a 'safer' log target: the
501 // default one (wxLogGui) can't be used after the resources are freed just
502 // below and the user suppliedo ne might be even more unsafe (using any
503 // wxWindows GUI function is unsafe starting from now)
504 wxLog::DontCreateOnDemand();
506 // this will flush the old messages if any
507 delete wxLog::SetActiveTarget(new wxLogStderr
);
511 wxWinMacWindowList
= new wxList(wxKEY_INTEGER
);
512 wxWinMacControlList
= new wxList(wxKEY_INTEGER
);
514 wxInitializeStockLists();
515 wxInitializeStockObjects();
517 #if wxUSE_WX_RESOURCES
518 wxInitializeResourceSystem();
521 wxBitmap::InitStandardHandlers();
523 wxModule::RegisterModules();
524 if (!wxModule::InitializeModules()) {
528 wxMacCreateNotifierTable() ;
530 UMAShowArrowCursor() ;
535 void wxApp::CleanUp()
537 wxToolTip::RemoveToolTips() ;
539 // flush the logged messages if any and install a 'safer' log target: the
540 // default one (wxLogGui) can't be used after the resources are freed just
541 // below and the user suppliedo ne might be even more unsafe (using any
542 // wxWindows GUI function is unsafe starting from now)
543 wxLog::DontCreateOnDemand();
545 // this will flush the old messages if any
546 delete wxLog::SetActiveTarget(new wxLogStderr
);
549 // One last chance for pending objects to be cleaned up
550 wxTheApp
->DeletePendingObjects();
552 wxModule::CleanUpModules();
554 #if wxUSE_WX_RESOURCES
555 wxCleanUpResourceSystem();
558 wxDeleteStockObjects() ;
560 // Destroy all GDI lists, etc.
561 wxDeleteStockLists();
563 delete wxTheColourDatabase
;
564 wxTheColourDatabase
= NULL
;
566 wxBitmap::CleanUpHandlers();
571 wxMacDestroyNotifierTable() ;
572 if (wxWinMacWindowList
)
573 delete wxWinMacWindowList
;
575 if (wxWinMacControlList
)
576 delete wxWinMacControlList
;
578 delete wxPendingEvents
;
580 delete wxPendingEventsLocker
;
581 // If we don't do the following, we get an apparent memory leak.
582 ((wxEvtHandler
&) wxDefaultValidator
).ClearEventLocker();
585 wxClassInfo::CleanUpClasses();
588 #if __option(profile)
589 ProfilerDump( "\papp.prof" ) ;
597 #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
598 // At this point we want to check if there are any memory
599 // blocks that aren't part of the wxDebugContext itself,
600 // as a special case. Then when dumping we need to ignore
601 // wxDebugContext, too.
602 if (wxDebugContext::CountObjectsLeft(TRUE
) > 0)
604 wxLogDebug(wxT("There were memory leaks."));
605 wxDebugContext::Dump();
606 wxDebugContext::PrintStatistics();
608 // wxDebugContext::SetStream(NULL, NULL);
612 // do it as the very last thing because everything else can log messages
613 delete wxLog::SetActiveTarget(NULL
);
616 UMACleanupToolbox() ;
618 ::DisposeRgn((RgnHandle
)s_macCursorRgn
);
625 //----------------------------------------------------------------------
627 //----------------------------------------------------------------------
629 short gCurrentResource
= -1 ;
630 #if defined(WXMAKINGDLL) && defined(__DARWIN__)
631 CFBundleRef gDylibBundle
= NULL
;
632 #endif /* WXMAKINGDLL && __DARWIN__ */
634 wxStAppResource::wxStAppResource()
636 #if defined(WXMAKINGDLL) && defined(__DARWIN__)
637 // Open the shared library resource file if it is not yet open
638 if (gCurrentResource
== -1) {
641 const char *theLibPath
;
643 gDylibBundle
= CFBundleGetBundleWithIdentifier(CFSTR("com.wxwindows.wxWindows"));
644 if (gDylibBundle
!= NULL
) {
645 // wxWindows has been bundled into a framework
646 // load the framework resources
648 gCurrentResource
= CFBundleOpenBundleResourceMap(gDylibBundle
);
651 // wxWindows is a simple dynamic shared library
652 // load the resources from the data fork of a separate resource file
657 OSErr theErr
= noErr
;
659 // get the library path
660 theSymbol
= NSLookupAndBindSymbol("_gCurrentResource");
661 theModule
= NSModuleForSymbol(theSymbol
);
662 theLibPath
= NSLibraryNameForModule(theModule
);
664 wxLogDebug( theLibPath
);
666 // allocate copy to replace .dylib.* extension with .rsrc
667 theResPath
= strdup(theLibPath
);
668 if (theResPath
!= NULL
) {
669 theName
= strrchr(theResPath
, '/');
670 if (theName
== NULL
) {
671 // no directory elements in path
672 theName
= theResPath
;
674 // find ".dylib" shared library extension
675 theExt
= strstr(theName
, ".dylib");
676 // overwrite extension with ".rsrc"
677 strcpy(theExt
, ".rsrc");
679 wxLogDebug( theResPath
);
681 theErr
= FSPathMakeRef((UInt8
*) theResPath
, &theResRef
, false);
682 if (theErr
!= noErr
) {
683 // try in current directory (using name only)
684 theErr
= FSPathMakeRef((UInt8
*) theName
, &theResRef
, false);
687 // free duplicated resource file path
690 // open the resource file
691 if (theErr
== noErr
) {
692 theErr
= FSOpenResourceFile( &theResRef
, 0, NULL
, fsRdPerm
,
703 len = i + strlen(rPath);
704 path = (char*) malloc(len+1);
707 // try current directory
708 myerr = FSPathMakeRef((UInt8 *) rPath, &myref, false);
712 #endif /* WXMAKINGDLL && __DARWIN__ */
714 m_currentRefNum
= CurResFile() ;
715 if ( gCurrentResource
!= -1 )
717 UseResFile( gCurrentResource
) ;
721 wxStAppResource::~wxStAppResource()
723 if ( m_currentRefNum
!= -1 )
725 UseResFile( m_currentRefNum
) ;
728 #if defined(WXMAKINGDLL) && defined(__DARWIN__)
729 // Close the shared library resource file
730 if (gCurrentResource
!= -1) {
731 if (gDylibBundle
!= NULL
) {
732 CFBundleCloseBundleResourceMap(gDylibBundle
, gCurrentResource
);
736 CloseResFile(gCurrentResource
);
738 gCurrentResource
= -1;
740 #endif /* WXMAKINGDLL && __DARWIN__ */
743 #if defined(WXMAKINGDLL) && !defined(__DARWIN__)
745 // for shared libraries we have to manually get the correct resource
746 // ref num upon initializing and releasing when terminating, therefore
747 // the __wxinitialize and __wxterminate must be used
753 void __sinit(void); /* (generated by linker) */
754 pascal OSErr
__initialize(const CFragInitBlock
*theInitBlock
);
755 pascal void __terminate(void);
761 pascal OSErr
__wxinitialize(const CFragInitBlock
*theInitBlock
)
763 gCurrentResource
= -1;
765 if (theInitBlock
->fragLocator
.where
== kDataForkCFragLocator
) {
767 FSpOpenResFile(theInitBlock
->fragLocator
.u
.onDisk
.fileSpec
,
770 return __initialize( theInitBlock
) ;
773 pascal void __wxterminate(void)
775 if (gCurrentResource
!= -1)
776 CloseResFile(gCurrentResource
);
780 #endif /* WXMAKINGDLL && !__DARWIN__ */
782 int WXDLLEXPORT
wxEntryStart( int argc
, char *argv
[] )
784 return wxApp::Initialize();
787 int WXDLLEXPORT
wxEntryInitGui()
789 return wxTheApp
->OnInitGui();
792 void WXDLLEXPORT
wxEntryCleanup()
797 int wxEntry( int argc
, char *argv
[] , bool enterLoop
)
799 #if !(defined(WXMAKINGDLL) && defined(__DARWIN__))
800 gCurrentResource
= CurResFile() ;
804 #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
805 // This seems to be necessary since there are 'rogue'
806 // objects present at this point (perhaps global objects?)
807 // Setting a checkpoint will ignore them as far as the
808 // memory checking facility is concerned.
809 // Of course you may argue that memory allocated in globals should be
810 // checked, but this is a reasonable compromise.
811 wxDebugContext::SetCheckpoint();
814 if (!wxEntryStart(argc
, argv
)) {
817 // create the application object or ensure that one already exists
820 // The app may have declared a global application object, but we recommend
821 // the IMPLEMENT_APP macro is used instead, which sets an initializer
822 // function for delayed, dynamic app object construction.
823 wxCHECK_MSG( wxApp::GetInitializerFunction(), 0,
824 wxT("No initializer - use IMPLEMENT_APP macro.") );
826 wxTheApp
= (wxApp
*) (*wxApp::GetInitializerFunction()) ();
829 wxCHECK_MSG( wxTheApp
, 0, wxT("You have to define an instance of wxApp!") );
832 // Mac OS X passes a process serial number command line argument when
833 // the application is launched from the Finder. This argument must be
834 // removed from the command line arguments before being handled by the
835 // application (otherwise applications would need to handle it)
839 strncpy(theArg
, argv
[1], 5);
841 if (strcmp(theArg
, "-psn_") == 0) {
842 // assume the argument is always the only one and remove it
847 argc
= 0 ; // currently we don't support files as parameters
849 // we could try to get the open apple events here to adjust argc and argv better
851 wxTheApp
->argc
= argc
;
852 wxTheApp
->argv
= argv
;
854 // GUI-specific initialization, such as creating an app context.
857 // Here frames insert themselves automatically
858 // into wxTopLevelWindows by getting created
863 if ( wxTheApp
->OnInit() )
867 retValue
= wxTheApp
->OnRun();
870 // We want to initialize, but not run or exit immediately.
873 //else: app initialization failed, so we skipped OnRun()
875 wxWindow
*topWindow
= wxTheApp
->GetTopWindow();
878 // Forcibly delete the window.
879 if ( topWindow
->IsKindOf(CLASSINFO(wxFrame
)) ||
880 topWindow
->IsKindOf(CLASSINFO(wxDialog
)) )
882 topWindow
->Close(TRUE
);
883 wxTheApp
->DeletePendingObjects();
888 wxTheApp
->SetTopWindow(NULL
);
899 // Static member initialization
900 wxAppInitializerFunction
wxAppBase::m_appInitFn
= (wxAppInitializerFunction
) NULL
;
907 #if WXWIN_COMPATIBILITY_2_2
908 m_wantDebugOutput
= TRUE
;
914 m_printMode
= wxPRINT_WINDOWS
;
915 m_exitOnFrameDelete
= TRUE
;
919 bool wxApp::Initialized()
927 int wxApp::MainLoop()
939 // Returns TRUE if more time is needed.
940 bool wxApp::ProcessIdle()
943 event
.SetEventObject(this);
946 return event
.MoreRequested();
949 void wxApp::ExitMainLoop()
954 // Is a message/event pending?
955 bool wxApp::Pending()
959 return EventAvail( everyEvent
, &event
) ;
962 // Dispatch a message.
963 void wxApp::Dispatch()
968 void wxApp::OnIdle(wxIdleEvent
& event
)
970 static bool s_inOnIdle
= FALSE
;
972 // Avoid recursion (via ProcessEvent default case)
979 // 'Garbage' collection of windows deleted with Close().
980 DeletePendingObjects();
982 // flush the logged messages if any
983 wxLog
*pLog
= wxLog::GetActiveTarget();
984 if ( pLog
!= NULL
&& pLog
->HasPendingMessages() )
987 // Send OnIdle events to all windows
988 bool needMore
= SendIdleEvents();
991 event
.RequestMore(TRUE
);
993 // If they are pending events, we must process them: pending events are
994 // either events to the threads other than main or events posted with
995 // wxPostEvent() functions
996 wxMacProcessNotifierAndPendingEvents();
1006 // Send idle event to all top-level windows
1007 bool wxApp::SendIdleEvents()
1009 bool needMore
= FALSE
;
1010 wxNode
* node
= wxTopLevelWindows
.First();
1013 wxWindow
* win
= (wxWindow
*) node
->Data();
1014 if (SendIdleEvents(win
))
1017 node
= node
->Next();
1022 // Send idle event to window and all subwindows
1023 bool wxApp::SendIdleEvents(wxWindow
* win
)
1025 bool needMore
= FALSE
;
1028 event
.SetEventObject(win
);
1029 win
->ProcessEvent(event
);
1031 if (event
.MoreRequested())
1034 wxNode
* node
= win
->GetChildren().First();
1037 wxWindow
* win
= (wxWindow
*) node
->Data();
1038 if (SendIdleEvents(win
))
1041 node
= node
->Next();
1046 void wxApp::DeletePendingObjects()
1048 wxNode
*node
= wxPendingDelete
.First();
1051 wxObject
*obj
= (wxObject
*)node
->Data();
1055 if (wxPendingDelete
.Member(obj
))
1058 // Deleting one object may have deleted other pending
1059 // objects, so start from beginning of list again.
1060 node
= wxPendingDelete
.First();
1066 wxLogError(_("Fatal error: exiting"));
1072 void wxApp::OnEndSession(wxCloseEvent
& WXUNUSED(event
))
1075 GetTopWindow()->Close(TRUE
);
1078 // Default behaviour: close the application with prompts. The
1079 // user can veto the close, and therefore the end session.
1080 void wxApp::OnQueryEndSession(wxCloseEvent
& event
)
1084 if (!GetTopWindow()->Close(!event
.CanVeto()))
1089 extern "C" void wxCYield() ;
1095 // Yield to other processes
1097 bool wxApp::Yield(bool onlyIfNeeded
)
1099 static bool s_inYield
= FALSE
;
1103 if ( !onlyIfNeeded
)
1105 wxFAIL_MSG( wxT("wxYield called recursively" ) );
1114 YieldToAnyThread() ;
1118 long sleepTime
= 1 ; //::GetCaretTime();
1120 while ( !wxTheApp
->IsExiting() && WaitNextEvent(everyEvent
, &event
,sleepTime
, (RgnHandle
) wxApp::s_macCursorRgn
))
1122 wxTheApp
->MacHandleOneEvent( &event
);
1123 if ( event
.what
!= kHighLevelEvent
)
1124 SetRectRgn( (RgnHandle
) wxApp::s_macCursorRgn
, event
.where
.h
, event
.where
.v
, event
.where
.h
+ 1 , event
.where
.v
+ 1 ) ;
1127 wxMacProcessNotifierAndPendingEvents() ;
1134 // platform specifics
1136 void wxApp::MacSuspend( bool convertClipboard
)
1138 // we have to deactive the top level windows manually
1140 wxNode
* node
= wxTopLevelWindows
.First();
1143 wxTopLevelWindow
* win
= (wxTopLevelWindow
*) node
->Data();
1144 win
->MacActivate( MacGetCurrentEvent() , false ) ;
1146 node
= node
->Next();
1149 s_lastMouseDown
= 0 ;
1150 if( convertClipboard
)
1152 MacConvertPrivateToPublicScrap() ;
1155 ::HideFloatingWindows() ;
1158 void wxApp::MacResume( bool convertClipboard
)
1160 s_lastMouseDown
= 0 ;
1161 if( convertClipboard
)
1163 MacConvertPublicToPrivateScrap() ;
1166 ::ShowFloatingWindows() ;
1169 void wxApp::MacConvertPrivateToPublicScrap()
1173 void wxApp::MacConvertPublicToPrivateScrap()
1177 void wxApp::MacDoOneEvent()
1181 long sleepTime
= 1; // GetCaretTime() / 4 ;
1183 if (WaitNextEvent(everyEvent
, &event
, sleepTime
, (RgnHandle
) s_macCursorRgn
))
1185 MacHandleOneEvent( &event
);
1190 WindowPtr window
= ::FrontWindow() ;
1192 ::IdleControls( window
) ;
1194 wxTheApp
->ProcessIdle() ;
1196 if ( event
.what
!= kHighLevelEvent
)
1197 SetRectRgn( (RgnHandle
) s_macCursorRgn
, event
.where
.h
, event
.where
.v
, event
.where
.h
+ 1 , event
.where
.v
+ 1 ) ;
1201 DeletePendingObjects() ;
1202 wxMacProcessNotifierAndPendingEvents() ;
1205 void wxApp::MacHandleOneEvent( WXEVENTREF evr
)
1207 EventRecord
* ev
= (EventRecord
*) evr
;
1208 m_macCurrentEvent
= ev
;
1210 wxApp::sm_lastMessageTime
= ev
->when
;
1215 MacHandleMouseDownEvent( ev
) ;
1216 if ( ev
->modifiers
& controlKey
)
1217 s_lastMouseDown
= 2;
1219 s_lastMouseDown
= 1;
1222 if ( s_lastMouseDown
== 2 )
1224 ev
->modifiers
|= controlKey
;
1228 ev
->modifiers
&= ~controlKey
;
1230 MacHandleMouseUpEvent( ev
) ;
1231 s_lastMouseDown
= 0;
1234 MacHandleActivateEvent( ev
) ;
1237 MacHandleUpdateEvent( ev
) ;
1241 MacHandleKeyDownEvent( ev
) ;
1244 MacHandleKeyUpEvent( ev
) ;
1247 MacHandleDiskEvent( ev
) ;
1250 MacHandleOSEvent( ev
) ;
1252 case kHighLevelEvent
:
1253 MacHandleHighLevelEvent( ev
) ;
1258 wxMacProcessNotifierAndPendingEvents() ;
1261 void wxApp::MacHandleHighLevelEvent( WXEVENTREF evr
)
1263 EventRecord
* ev
= (EventRecord
*) evr
;
1264 ::AEProcessAppleEvent( ev
) ;
1267 bool s_macIsInModalLoop
= false ;
1269 void wxApp::MacHandleMouseDownEvent( WXEVENTREF evr
)
1271 EventRecord
* ev
= (EventRecord
*) evr
;
1272 wxToolTip::RemoveToolTips() ;
1275 WindowRef frontWindow
= ::FrontNonFloatingWindow() ;
1276 WindowAttributes frontWindowAttributes
= NULL
;
1278 ::GetWindowAttributes( frontWindow
, &frontWindowAttributes
) ;
1280 short windowPart
= ::FindWindow(ev
->where
, &window
);
1281 wxTopLevelWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
1282 if ( wxPendingDelete
.Member(win
) )
1286 GetQDGlobalsScreenBits( &screenBits
);
1291 if ( s_macIsInModalLoop
)
1297 UInt32 menuresult
= MenuSelect(ev
->where
) ;
1298 MacHandleMenuSelect( HiWord( menuresult
) , LoWord( menuresult
) );
1299 s_lastMouseDown
= 0;
1304 SystemClick( ev
, window
) ;
1305 s_lastMouseDown
= 0;
1309 if ( window
!= frontWindow
&& s_macIsInModalLoop
&& !(ev
->modifiers
& cmdKey
) )
1315 DragWindow(window
, ev
->where
, &screenBits
.bounds
);
1320 Point pt
= { 0, 0 } ;
1321 SetPortWindowPort(window
) ;
1322 LocalToGlobal( &pt
) ;
1324 win
->SetSize( pt
.h
, pt
.v
, -1 ,
1325 -1 , wxSIZE_USE_EXISTING
);
1327 s_lastMouseDown
= 0;
1331 if (TrackGoAway(window
, ev
->where
))
1336 s_lastMouseDown
= 0;
1340 int growResult
= GrowWindow(window
, ev
->where
, &screenBits
.bounds
);
1341 if (growResult
!= 0)
1343 int newWidth
= LoWord(growResult
);
1344 int newHeight
= HiWord(growResult
);
1345 int oldWidth
, oldHeight
;
1350 win
->GetSize(&oldWidth
, &oldHeight
);
1352 newWidth
= oldWidth
;
1354 newHeight
= oldHeight
;
1355 win
->SetSize( -1, -1, newWidth
, newHeight
, wxSIZE_USE_EXISTING
);
1358 s_lastMouseDown
= 0;
1363 if (TrackBox(window
, ev
->where
, windowPart
))
1365 // TODO setup size event
1366 ZoomWindow( window
, windowPart
, false ) ;
1371 GetWindowPortBounds(window
, &tempRect
) ;
1372 win
->SetSize( -1, -1, tempRect
.right
-tempRect
.left
,
1373 tempRect
.bottom
-tempRect
.top
, wxSIZE_USE_EXISTING
);
1376 s_lastMouseDown
= 0;
1378 case inCollapseBox
:
1379 // TODO setup size event
1380 s_lastMouseDown
= 0;
1387 SetPortWindowPort(window
) ;
1390 if ( window
!= frontWindow
&& wxTheApp
->s_captureWindow
== NULL
)
1392 if ( s_macIsInModalLoop
)
1396 else if ( UMAIsWindowFloating( window
) )
1399 win
->MacMouseDown( ev
, windowPart
) ;
1404 win
->MacMouseDown( ev
, windowPart
) ;
1405 ::SelectWindow( window
) ;
1411 win
->MacMouseDown( ev
, windowPart
) ;
1420 void wxApp::MacHandleMouseUpEvent( WXEVENTREF evr
)
1422 EventRecord
* ev
= (EventRecord
*) evr
;
1425 short windowPart
= inNoWindow
;
1426 if ( wxTheApp
->s_captureWindow
)
1428 window
= (WindowRef
) s_captureWindow
->MacGetRootWindow() ;
1429 windowPart
= inContent
;
1433 windowPart
= ::FindWindow(ev
->where
, &window
) ;
1444 wxTopLevelWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
1446 win
->MacMouseUp( ev
, windowPart
) ;
1452 long wxMacTranslateKey(unsigned char key
, unsigned char code
) ;
1453 long wxMacTranslateKey(unsigned char key
, unsigned char code
)
1462 retval
= WXK_RETURN
;
1477 retval
= WXK_PAGEUP
;
1480 retval
= WXK_PAGEDOWN
;
1483 retval
= WXK_RETURN
;
1538 retval
= WXK_ESCAPE
;
1544 retval
= WXK_RIGHT
;
1553 retval
= WXK_DELETE
;
1561 void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr
)
1563 EventRecord
* ev
= (EventRecord
*) evr
;
1564 wxToolTip::RemoveToolTips() ;
1566 UInt32 menuresult
= UMAMenuEvent(ev
) ;
1567 if ( HiWord( menuresult
) )
1569 if ( !s_macIsInModalLoop
)
1570 MacHandleMenuSelect( HiWord( menuresult
) , LoWord( menuresult
) ) ;
1576 keychar
= short(ev
->message
& charCodeMask
);
1577 keycode
= short(ev
->message
& keyCodeMask
) >> 8 ;
1578 long keyval
= wxMacTranslateKey(keychar
, keycode
) ;
1579 bool handled
= false ;
1580 wxWindow
* focus
= wxWindow::FindFocus() ;
1584 wxKeyEvent
event(wxEVT_KEY_DOWN
);
1585 event
.m_shiftDown
= ev
->modifiers
& shiftKey
;
1586 event
.m_controlDown
= ev
->modifiers
& controlKey
;
1587 event
.m_altDown
= ev
->modifiers
& optionKey
;
1588 event
.m_metaDown
= ev
->modifiers
& cmdKey
;
1589 event
.m_keyCode
= keyval
;
1590 event
.m_x
= ev
->where
.h
;
1591 event
.m_y
= ev
->where
.v
;
1592 event
.m_timeStamp
= ev
->when
;
1593 event
.SetEventObject(focus
);
1594 handled
= focus
->GetEventHandler()->ProcessEvent( event
) ;
1601 wxWindow *ancestor = focus;
1604 int command = ancestor->GetAcceleratorTable()->GetCommand( event );
1607 wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
1608 handled = ancestor->GetEventHandler()->ProcessEvent( command_event );
1611 if (ancestor->m_isFrame)
1613 ancestor = ancestor->GetParent();
1617 #endif // wxUSE_ACCEL
1621 wxKeyEvent
event(wxEVT_CHAR
);
1622 event
.m_shiftDown
= ev
->modifiers
& shiftKey
;
1623 event
.m_controlDown
= ev
->modifiers
& controlKey
;
1624 event
.m_altDown
= ev
->modifiers
& optionKey
;
1625 event
.m_metaDown
= ev
->modifiers
& cmdKey
;
1626 event
.m_keyCode
= keyval
;
1627 event
.m_x
= ev
->where
.h
;
1628 event
.m_y
= ev
->where
.v
;
1629 event
.m_timeStamp
= ev
->when
;
1630 event
.SetEventObject(focus
);
1631 handled
= focus
->GetEventHandler()->ProcessEvent( event
) ;
1634 (keyval
== WXK_TAB
) &&
1635 (!focus
->HasFlag(wxTE_PROCESS_TAB
)) &&
1636 (focus
->GetParent()) &&
1637 (focus
->GetParent()->HasFlag( wxTAB_TRAVERSAL
)) )
1639 wxNavigationKeyEvent new_event
;
1640 new_event
.SetEventObject( focus
);
1641 new_event
.SetDirection( !event
.ShiftDown() );
1642 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
1643 new_event
.SetWindowChange( event
.ControlDown() );
1644 new_event
.SetCurrentFocus( focus
);
1645 handled
= focus
->GetEventHandler()->ProcessEvent( new_event
);
1650 // if window is not having a focus still testing for default enter or cancel
1651 // TODO add the UMA version for ActiveNonFloatingWindow
1652 focus
= wxFindWinFromMacWindow( FrontWindow() ) ;
1655 if ( keyval
== WXK_RETURN
)
1657 wxButton
*def
= wxDynamicCast(focus
->GetDefaultItem(),
1659 if ( def
&& def
->IsEnabled() )
1661 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, def
->GetId() );
1662 event
.SetEventObject(def
);
1663 def
->Command(event
);
1667 /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
1668 else if (keyval
== WXK_ESCAPE
|| (keyval
== '.' && ev
->modifiers
& cmdKey
) )
1670 wxCommandEvent
new_event(wxEVT_COMMAND_BUTTON_CLICKED
,wxID_CANCEL
);
1671 new_event
.SetEventObject( focus
);
1672 handled
= focus
->GetEventHandler()->ProcessEvent( new_event
);
1679 void wxApp::MacHandleKeyUpEvent( WXEVENTREF evr
)
1681 EventRecord
* ev
= (EventRecord
*) evr
;
1682 wxToolTip::RemoveToolTips() ;
1684 UInt32 menuresult
= UMAMenuEvent(ev
) ;
1685 if ( HiWord( menuresult
) )
1692 keychar
= short(ev
->message
& charCodeMask
);
1693 keycode
= short(ev
->message
& keyCodeMask
) >> 8 ;
1695 wxWindow
* focus
= wxWindow::FindFocus() ;
1698 long keyval
= wxMacTranslateKey(keychar
, keycode
) ;
1700 wxKeyEvent
event(wxEVT_KEY_UP
);
1701 event
.m_shiftDown
= ev
->modifiers
& shiftKey
;
1702 event
.m_controlDown
= ev
->modifiers
& controlKey
;
1703 event
.m_altDown
= ev
->modifiers
& optionKey
;
1704 event
.m_metaDown
= ev
->modifiers
& cmdKey
;
1705 event
.m_keyCode
= keyval
;
1706 event
.m_x
= ev
->where
.h
;
1707 event
.m_y
= ev
->where
.v
;
1708 event
.m_timeStamp
= ev
->when
;
1709 event
.SetEventObject(focus
);
1710 bool handled
= focus
->GetEventHandler()->ProcessEvent( event
) ;
1715 void wxApp::MacHandleActivateEvent( WXEVENTREF evr
)
1717 EventRecord
* ev
= (EventRecord
*) evr
;
1718 WindowRef window
= (WindowRef
) ev
->message
;
1721 bool activate
= (ev
->modifiers
& activeFlag
) ;
1722 WindowClass wclass
;
1723 ::GetWindowClass ( window
, &wclass
) ;
1724 if ( wclass
== kFloatingWindowClass
)
1726 // if it is a floater we activate/deactivate the front non-floating window instead
1727 window
= ::FrontNonFloatingWindow() ;
1729 wxTopLevelWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
1731 win
->MacActivate( ev
, activate
) ;
1735 void wxApp::MacHandleUpdateEvent( WXEVENTREF evr
)
1737 EventRecord
* ev
= (EventRecord
*) evr
;
1738 WindowRef window
= (WindowRef
) ev
->message
;
1739 wxTopLevelWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
1742 if ( !wxPendingDelete
.Member(win
) )
1743 win
->MacUpdate( ev
->when
) ;
1747 // since there is no way of telling this foreign window to update itself
1748 // we have to invalidate the update region otherwise we keep getting the same
1749 // event over and over again
1750 BeginUpdate( window
) ;
1751 EndUpdate( window
) ;
1755 void wxApp::MacHandleDiskEvent( WXEVENTREF evr
)
1757 EventRecord
* ev
= (EventRecord
*) evr
;
1758 if ( HiWord( ev
->message
) != noErr
)
1763 SetPt( &point
, 100 , 100 ) ;
1765 err
= DIBadMount( point
, ev
->message
) ;
1766 wxASSERT( err
== noErr
) ;
1771 void wxApp::MacHandleOSEvent( WXEVENTREF evr
)
1773 EventRecord
* ev
= (EventRecord
*) evr
;
1774 switch( ( ev
->message
& osEvtMessageMask
) >> 24 )
1776 case suspendResumeMessage
:
1778 bool isResuming
= ev
->message
& resumeFlag
;
1780 bool convertClipboard
= ev
->message
& convertClipboardFlag
;
1782 bool convertClipboard
= false;
1784 bool doesActivate
= UMAGetProcessModeDoesActivateOnFGSwitch() ;
1787 WindowRef oldFrontWindow
= NULL
;
1788 WindowRef newFrontWindow
= NULL
;
1790 // in case we don't take care of activating ourselves, we have to synchronize
1791 // our idea of the active window with the process manager's - which it already activated
1793 if ( !doesActivate
)
1794 oldFrontWindow
= ::FrontNonFloatingWindow() ;
1796 MacResume( convertClipboard
) ;
1798 newFrontWindow
= ::FrontNonFloatingWindow() ;
1800 if ( oldFrontWindow
)
1802 wxTopLevelWindowMac
* win
= wxFindWinFromMacWindow( oldFrontWindow
) ;
1804 win
->MacActivate( ev
, false ) ;
1806 if ( newFrontWindow
)
1808 wxTopLevelWindowMac
* win
= wxFindWinFromMacWindow( newFrontWindow
) ;
1810 win
->MacActivate( ev
, true ) ;
1815 MacSuspend( convertClipboard
) ;
1817 // in case this suspending did close an active window, another one might
1818 // have surfaced -> lets deactivate that one
1820 /* TODO : find out what to do on systems < 10 , perhaps FrontNonFloatingWindow
1821 WindowRef newActiveWindow = ::ActiveNonFloatingWindow() ;
1822 if ( newActiveWindow )
1824 wxWindow* win = wxFindWinFromMacWindow( newActiveWindow ) ;
1826 win->MacActivate( ev , false ) ;
1832 case mouseMovedMessage
:
1836 wxWindow
* currentMouseWindow
= NULL
;
1838 wxWindow::MacGetWindowFromPoint( wxPoint( ev
->where
.h
, ev
->where
.v
) ,
1839 ¤tMouseWindow
) ;
1840 if ( currentMouseWindow
!= wxWindow::s_lastMouseWindow
)
1842 wxMouseEvent event
;
1844 bool isDown
= !(ev
->modifiers
& btnState
) ; // 1 is for up
1845 bool controlDown
= ev
->modifiers
& controlKey
; // for simulating right mouse
1847 event
.m_leftDown
= isDown
&& !controlDown
;
1848 event
.m_middleDown
= FALSE
;
1849 event
.m_rightDown
= isDown
&& controlDown
;
1850 event
.m_shiftDown
= ev
->modifiers
& shiftKey
;
1851 event
.m_controlDown
= ev
->modifiers
& controlKey
;
1852 event
.m_altDown
= ev
->modifiers
& optionKey
;
1853 event
.m_metaDown
= ev
->modifiers
& cmdKey
;
1854 event
.m_x
= ev
->where
.h
;
1855 event
.m_y
= ev
->where
.v
;
1856 event
.m_timeStamp
= ev
->when
;
1857 event
.SetEventObject(this);
1859 if ( wxWindow::s_lastMouseWindow
)
1861 wxMouseEvent
eventleave(event
);
1862 eventleave
.SetEventType( wxEVT_LEAVE_WINDOW
);
1863 wxWindow::s_lastMouseWindow
->ScreenToClient( &eventleave
.m_x
, &eventleave
.m_y
);
1864 eventleave
.SetEventObject( wxWindow::s_lastMouseWindow
) ;
1866 wxWindow::s_lastMouseWindow
->GetEventHandler()->ProcessEvent(eventleave
);
1868 if ( currentMouseWindow
)
1870 wxMouseEvent
evententer(event
);
1871 evententer
.SetEventType( wxEVT_ENTER_WINDOW
);
1872 currentMouseWindow
->ScreenToClient( &evententer
.m_x
, &evententer
.m_y
);
1873 evententer
.SetEventObject( currentMouseWindow
) ;
1874 currentMouseWindow
->GetEventHandler()->ProcessEvent(evententer
);
1876 wxWindow::s_lastMouseWindow
= currentMouseWindow
;
1879 short windowPart
= ::FindWindow(ev
->where
, &window
);
1883 // fixes for setting the cursor back from dominic mazzoni
1885 UMAShowArrowCursor();
1888 UMAShowArrowCursor();
1892 // if ( s_lastMouseDown == 0 )
1893 // ev->modifiers |= btnState ;
1895 // Calling GetNextEvent with a zero event mask will always
1896 // pass back a null event. However, it fills the EventRecord
1897 // with the state of the modifier keys. This is needed since
1898 // the modifier state returned by WaitForNextEvent often is
1899 // wrong mouse move events. The attempt above to correct this
1900 // didn't always work (under OS X at least).
1903 ::GetNextEvent(0, &tmp
);
1904 ev
->modifiers
= tmp
.modifiers
;
1906 wxTopLevelWindowMac
* win
= wxFindWinFromMacWindow( window
) ;
1908 win
->MacMouseMoved( ev
, windowPart
) ;
1910 UMAShowArrowCursor();
1921 void wxApp::MacHandleMenuSelect( int macMenuId
, int macMenuItemNum
)
1924 return; // no menu item selected
1926 if (macMenuId
== kwxMacAppleMenuId
&& macMenuItemNum
> 1)
1929 Str255 deskAccessoryName
;
1932 GetMenuItemText(GetMenuHandle(kwxMacAppleMenuId
), macMenuItemNum
, deskAccessoryName
);
1933 GetPort(&savedPort
);
1934 OpenDeskAcc(deskAccessoryName
);
1940 wxWindow
* frontwindow
= wxFindWinFromMacWindow( ::FrontWindow() ) ;
1941 if ( frontwindow
&& wxMenuBar::MacGetInstalledMenuBar() )
1942 wxMenuBar::MacGetInstalledMenuBar()->MacMenuSelect( frontwindow
->GetEventHandler() , 0 , macMenuId
, macMenuItemNum
) ;
1948 long wxApp::MacTranslateKey(char key, int mods)
1952 void wxApp::MacAdjustCursor()
1959 wxApp::macAdjustCursor()
1961 if (ev->what != kHighLevelEvent)
1963 wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow());
1966 if (!theMacWxFrame->MacAdjustCursor(ev->where))
1967 ::SetCursor(&(qd.arrow));