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> 
  63 #  include <ToolUtils.h> 
  64 #  include <DiskInit.h> 
  68 extern char *wxBuffer
; 
  69 extern wxList wxPendingDelete
; 
  70 extern wxList 
*wxWinMacWindowList
; 
  71 extern wxList 
*wxWinMacControlList
; 
  73 wxApp 
*wxTheApp 
= NULL
; 
  75 #if !USE_SHARED_LIBRARY 
  76 IMPLEMENT_DYNAMIC_CLASS(wxApp
, wxEvtHandler
) 
  77 BEGIN_EVENT_TABLE(wxApp
, wxEvtHandler
) 
  78     EVT_IDLE(wxApp::OnIdle
) 
  79         EVT_END_SESSION(wxApp::OnEndSession
) 
  80         EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession
) 
  85 const short    kMacMinHeap 
= (29 * 1024) ; 
  86 // platform specific static variables 
  88 const short kwxMacMenuBarResource 
= 1 ; 
  89 const short kwxMacAppleMenuId 
= 1 ; 
  91 WXHRGN            
wxApp::s_macCursorRgn 
= NULL
; 
  92 wxWindow
*            wxApp::s_captureWindow 
= NULL 
; 
  93 int                    wxApp::s_lastMouseDown 
= 0 ; 
  94 long                     wxApp::sm_lastMessageTime 
= 0; 
  96 bool    wxApp::s_macDefaultEncodingIsPC 
= true ; 
  97 bool wxApp::s_macSupportPCMenuShortcuts 
= true ; 
  98 long wxApp::s_macAboutMenuItemId 
= wxID_ABOUT 
; 
  99 wxString 
wxApp::s_macHelpMenuTitleName 
= "&Help" ; 
 101 pascal OSErr 
AEHandleODoc( const AppleEvent 
*event 
, AppleEvent 
*reply 
, long refcon 
) ; 
 102 pascal OSErr 
AEHandleOApp( const AppleEvent 
*event 
, AppleEvent 
*reply 
, long refcon 
) ; 
 103 pascal OSErr 
AEHandlePDoc( const AppleEvent 
*event 
, AppleEvent 
*reply 
, long refcon 
) ; 
 104 pascal OSErr 
AEHandleQuit( const AppleEvent 
*event 
, AppleEvent 
*reply 
, long refcon 
) ; 
 107 pascal OSErr 
AEHandleODoc( const AppleEvent 
*event 
, AppleEvent 
*reply 
, long refcon 
) 
 109     wxApp
* app 
= (wxApp
*) refcon 
; 
 110     return wxTheApp
->MacHandleAEODoc( (AppleEvent
*) event 
, reply
) ; 
 113 pascal OSErr 
AEHandleOApp( const AppleEvent 
*event 
, AppleEvent 
*reply 
, long refcon 
) 
 115     wxApp
* app 
= (wxApp
*) refcon 
; 
 116     return wxTheApp
->MacHandleAEOApp( (AppleEvent
*) event 
, reply 
) ; 
 119 pascal OSErr 
AEHandlePDoc( const AppleEvent 
*event 
, AppleEvent 
*reply 
, long refcon 
) 
 121     wxApp
* app 
= (wxApp
*) refcon 
; 
 122     return wxTheApp
->MacHandleAEPDoc( (AppleEvent
*) event 
, reply 
) ; 
 125 pascal OSErr 
AEHandleQuit( const AppleEvent 
*event 
, AppleEvent 
*reply 
, long refcon 
) 
 127     wxApp
* app 
= (wxApp
*) refcon 
; 
 128     return wxTheApp
->MacHandleAEQuit( (AppleEvent
*) event 
, reply
) ; 
 131 short wxApp::MacHandleAEODoc(const WXEVENTREF event 
, WXEVENTREF reply
) 
 134     ProcessSerialNumber PSN 
; 
 135     PSN
.highLongOfPSN 
= 0 ; 
 136     PSN
.lowLongOfPSN 
= kCurrentProcess 
; 
 137     SetFrontProcess( &PSN 
) ; 
 141 short wxApp::MacHandleAEPDoc(const WXEVENTREF event 
, WXEVENTREF reply
) 
 146 short wxApp::MacHandleAEOApp(const WXEVENTREF event 
, WXEVENTREF reply
) 
 151 short wxApp::MacHandleAEQuit(const WXEVENTREF event 
, WXEVENTREF reply
) 
 153     wxWindow
* win 
= GetTopWindow() ; 
 165 char StringMac
[] =  "\x0d\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" 
 166                     "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" 
 167                     "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf" 
 168                     "\xb1\xb4\xb5\xb6\xbb\xbc\xbe\xbf" 
 169                     "\xc0\xc1\xc2\xc4\xc7\xc8\xc9\xcb\xcc\xcd\xce\xcf" 
 170                     "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd8\xca\xdb" ; 
 172 char StringANSI
[] = "\x0a\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8" 
 173                     "\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC" 
 174                     "\x86\xBA\xA2\xA3\xA7\x95\xB6\xDF\xAE\xA9\x99\xB4\xA8\xC6\xD8" 
 175                     "\xB1\xA5\xB5\xF0\xAA\xBA\xE6\xF8" 
 176                     "\xBF\xA1\xAC\x83\xAB\xBB\x85\xC0\xC3\xD5\x8C\x9C" 
 177                     "\x96\x97\x93\x94\x91\x92\xF7\xFF\xA0\x80" ; 
 179 void wxMacConvertFromPC( const char *from 
, char *to 
, int len 
) 
 184         for( int i 
= 0 ; i 
< len 
; ++ i 
) 
 186             c 
= strchr( StringANSI 
, *from 
) ; 
 189                 *to 
= StringMac
[ c 
- StringANSI
] ; 
 197         for( int i 
= 0 ; i 
< len 
; ++ i 
) 
 199             c 
= strchr( StringANSI 
, *from 
) ; 
 202                 *to 
= StringMac
[ c 
- StringANSI
] ; 
 214 void wxMacConvertToPC( const char *from 
, char *to 
, int len 
) 
 219         for( int i 
= 0 ; i 
< len 
; ++ i 
) 
 221             c 
= strchr( StringMac 
, *from 
) ; 
 224                 *to 
= StringANSI
[ c 
- StringMac
] ; 
 232         for( int i 
= 0 ; i 
< len 
; ++ i 
) 
 234             c 
= strchr( StringMac 
, *from 
) ; 
 237                 *to 
= StringANSI
[ c 
- StringMac
] ; 
 249 void wxMacConvertFromPC( char * p 
) 
 252     int len 
= strlen ( p 
) ; 
 254     wxMacConvertFromPC( ptr 
, ptr 
, len 
) ; 
 257 void wxMacConvertFromPCForControls( char * p 
) 
 260     int len 
= strlen ( p 
) ; 
 262     wxMacConvertFromPC( ptr 
, ptr 
, len 
) ; 
 263     for ( int i 
= 0 ; i 
< strlen ( ptr 
) ; i
++ ) 
 265         if ( ptr
[i
] == '&' && ptr
[i
]+1 != ' ' ) 
 267             memmove( &ptr
[i
] , &ptr
[i
+1] , strlen( &ptr
[i
+1] ) + 1) ; 
 272 void wxMacConvertFromPC( unsigned char *p 
) 
 274     char *ptr 
= (char*) p 
+ 1 ; 
 277     wxMacConvertFromPC( ptr 
, ptr 
, len 
) ; 
 280 extern char *wxBuffer 
; 
 282 wxString 
wxMacMakeMacStringFromPC( const char * p 
) 
 284     const char *ptr 
= p 
; 
 285     int len 
= strlen ( p 
) ; 
 286     char *buf 
= wxBuffer 
; 
 288     if ( len 
>= BUFSIZ 
+ 512 ) 
 290         buf 
= new char [len
+1] ; 
 293     wxMacConvertFromPC( ptr 
, buf 
, len 
) ; 
 295     wxString 
result( buf 
) ; 
 296     if ( buf 
!= wxBuffer 
) 
 302 void wxMacConvertToPC( char * p 
) 
 305     int len 
= strlen ( p 
) ; 
 307     wxMacConvertToPC( ptr 
, ptr 
, len 
) ; 
 310 void wxMacConvertToPC( unsigned char *p 
) 
 312     char *ptr 
= (char*) p 
+ 1 ; 
 315     wxMacConvertToPC( ptr 
, ptr 
, len 
) ; 
 318 wxString 
wxMacMakePCStringFromMac( const char * p 
) 
 320     const char *ptr 
= p 
; 
 321     int len 
= strlen ( p 
) ; 
 322     char *buf 
= wxBuffer 
; 
 324     if ( len 
>= BUFSIZ 
+ 512 ) 
 326         buf 
= new char [len
+1] ; 
 329     wxMacConvertToPC( ptr 
, buf 
, len 
) ; 
 332     wxString 
result( buf 
) ; 
 333     if ( buf 
!= wxBuffer 
) 
 338 wxString 
wxMacMakeStringFromMacString( const char* from 
, bool mac2pcEncoding 
) 
 342       return wxMacMakePCStringFromMac( from 
) ; 
 346       return wxString( from 
) ; 
 350 wxString 
wxMacMakeStringFromPascal( StringPtr from 
, bool mac2pcEncoding 
) 
 352   // this is safe since a pascal string can never be larger than 256 bytes 
 354   CopyPascalStringToC( from 
, s 
) ; 
 357       return wxMacMakePCStringFromMac( s 
) ; 
 361       return wxString( s 
) ; 
 365 void wxMacStringToPascal( const char * from 
, StringPtr to 
, bool pc2macEncoding 
) 
 369       CopyCStringToPascal( wxMacMakeMacStringFromPC( from 
) , to 
) ; 
 373       CopyCStringToPascal( from 
, to 
) ; 
 378 // we know it's there ;-) 
 379 WXIMPORT 
char std::__throws_bad_alloc 
; 
 382 bool wxApp::Initialize() 
 388   UMAInitToolbox( 4 ) ; 
 389   SetEventMask( everyEvent 
) ; 
 390     UMAShowWatchCursor() ; 
 392 #if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) 
 393     AEInstallEventHandler( kCoreEventClass 
, kAEOpenDocuments 
,   NewAEEventHandlerUPP(AEHandleODoc
) , 
 394                            (long) wxTheApp 
, FALSE 
) ; 
 395     AEInstallEventHandler( kCoreEventClass 
, kAEOpenApplication 
, NewAEEventHandlerUPP(AEHandleOApp
) , 
 396                            (long) wxTheApp 
, FALSE 
) ; 
 397     AEInstallEventHandler( kCoreEventClass 
, kAEPrintDocuments 
,  NewAEEventHandlerUPP(AEHandlePDoc
) , 
 398                            (long) wxTheApp 
, FALSE 
) ; 
 399     AEInstallEventHandler( kCoreEventClass 
, kAEQuitApplication 
, NewAEEventHandlerUPP(AEHandleQuit
) , 
 400                            (long) wxTheApp 
, FALSE 
) ; 
 402     AEInstallEventHandler( kCoreEventClass 
, kAEOpenDocuments 
,   NewAEEventHandlerProc(AEHandleODoc
) , 
 403                    (long) wxTheApp 
, FALSE 
) ; 
 404     AEInstallEventHandler( kCoreEventClass 
, kAEOpenApplication 
, NewAEEventHandlerProc(AEHandleOApp
) , 
 405                    (long) wxTheApp 
, FALSE 
) ; 
 406     AEInstallEventHandler( kCoreEventClass 
, kAEPrintDocuments 
,  NewAEEventHandlerProc(AEHandlePDoc
) , 
 407                    (long) wxTheApp 
, FALSE 
) ; 
 408     AEInstallEventHandler( kCoreEventClass 
, kAEQuitApplication 
, NewAEEventHandlerProc(AEHandleQuit
) , 
 409                    (long) wxTheApp 
, FALSE 
) ; 
 414   // test the minimal configuration necessary 
 420     if (Gestalt(gestaltMachineType
, &theMachine
) != noErr
) 
 422         error 
= kMacSTRWrongMachine
; 
 424     else if (theMachine 
< gestaltMacPlus
) 
 426         error 
= kMacSTRWrongMachine
; 
 428     else if (Gestalt(gestaltSystemVersion
, &theSystem
) != noErr 
) 
 430         error 
= kMacSTROldSystem  
; 
 432     else if ( theSystem 
< 0x0860 ) 
 434         error 
= kMacSTROldSystem  
; 
 436     else if ((long)GetApplLimit() - (long)ApplicationZone() < kMacMinHeap
) 
 438         error 
= kMacSTRSmallSize
; 
 444         if ( !UMAHasAppearance() ) 
 446             error = kMacSTRNoPre8Yet ; 
 452     // if we encountered any problems so far, give the error code and exit immediately 
 456         wxStAppResource resload 
; 
 460         GetIndString(message
, 128, error
); 
 461         UMAShowArrowCursor() ; 
 462         ParamText("\pFatal Error", message
, (ConstStr255Param
)"\p", (ConstStr255Param
)"\p"); 
 463         itemHit 
= Alert(128, nil
); 
 468   #if __option(profile) 
 469     ProfilerInit( collectDetailed
, bestTimeBase 
, 20000 , 40 ) ; 
 473   // now avoid exceptions thrown for new (bad_alloc) 
 476   std::__throws_bad_alloc 
= FALSE 
; 
 479     s_macCursorRgn 
= ::NewRgn() ; 
 482   wxBuffer 
= new char[1500]; 
 484   wxBuffer 
= new char[BUFSIZ 
+ 512]; 
 487   wxClassInfo::InitializeClasses(); 
 490 //    wxGetResource(wxT("wxWindows"), wxT("OsVersion"), &wxOsVersion); 
 494     wxPendingEventsLocker 
= new wxCriticalSection
; 
 496   wxTheColourDatabase 
= new wxColourDatabase(wxKEY_STRING
); 
 497   wxTheColourDatabase
->Initialize(); 
 501     // flush the logged messages if any and install a 'safer' log target: the 
 502     // default one (wxLogGui) can't be used after the resources are freed just 
 503     // below and the user suppliedo ne might be even more unsafe (using any 
 504     // wxWindows GUI function is unsafe starting from now) 
 505     wxLog::DontCreateOnDemand(); 
 507     // this will flush the old messages if any 
 508     delete wxLog::SetActiveTarget(new wxLogStderr
); 
 512   wxInitializeStockLists(); 
 513   wxInitializeStockObjects(); 
 515 #if wxUSE_WX_RESOURCES 
 516   wxInitializeResourceSystem(); 
 519   wxBitmap::InitStandardHandlers(); 
 521   wxModule::RegisterModules(); 
 522   if (!wxModule::InitializeModules()) { 
 526   wxWinMacWindowList 
= new wxList(wxKEY_INTEGER
); 
 527   wxWinMacControlList 
= new wxList(wxKEY_INTEGER
); 
 529   wxMacCreateNotifierTable() ; 
 531   UMAShowArrowCursor() ; 
 536 void wxApp::CleanUp() 
 538     wxToolTip::RemoveToolTips() ; 
 540     // flush the logged messages if any and install a 'safer' log target: the 
 541     // default one (wxLogGui) can't be used after the resources are freed just 
 542     // below and the user suppliedo ne might be even more unsafe (using any 
 543     // wxWindows GUI function is unsafe starting from now) 
 544     wxLog::DontCreateOnDemand(); 
 546     // this will flush the old messages if any 
 547     delete wxLog::SetActiveTarget(new wxLogStderr
); 
 550     // One last chance for pending objects to be cleaned up 
 551     wxTheApp
->DeletePendingObjects(); 
 553   wxModule::CleanUpModules(); 
 555 #if wxUSE_WX_RESOURCES 
 556   wxCleanUpResourceSystem(); 
 559   wxDeleteStockObjects() ; 
 561     // Destroy all GDI lists, etc. 
 562     wxDeleteStockLists(); 
 564   delete wxTheColourDatabase
; 
 565   wxTheColourDatabase 
= NULL
; 
 567   wxBitmap::CleanUpHandlers(); 
 572   wxMacDestroyNotifierTable() ; 
 573   if (wxWinMacWindowList
) 
 574     delete wxWinMacWindowList 
; 
 576   if (wxWinMacControlList
) 
 577     delete wxWinMacControlList 
; 
 579     delete wxPendingEvents
; 
 581     delete wxPendingEventsLocker
; 
 582     // If we don't do the following, we get an apparent memory leak. 
 583     ((wxEvtHandler
&) wxDefaultValidator
).ClearEventLocker(); 
 586   wxClassInfo::CleanUpClasses(); 
 589   #if __option(profile) 
 590   ProfilerDump( "\papp.prof" ) ; 
 598 #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT 
 599     // At this point we want to check if there are any memory 
 600     // blocks that aren't part of the wxDebugContext itself, 
 601     // as a special case. Then when dumping we need to ignore 
 602     // wxDebugContext, too. 
 603     if (wxDebugContext::CountObjectsLeft(TRUE
) > 0) 
 605         wxLogDebug(wxT("There were memory leaks.")); 
 606         wxDebugContext::Dump(); 
 607         wxDebugContext::PrintStatistics(); 
 609     //  wxDebugContext::SetStream(NULL, NULL); 
 613     // do it as the very last thing because everything else can log messages 
 614     delete wxLog::SetActiveTarget(NULL
); 
 617     UMACleanupToolbox() ; 
 619         ::DisposeRgn((RgnHandle
)s_macCursorRgn
); 
 626 //---------------------------------------------------------------------- 
 628 //---------------------------------------------------------------------- 
 630 short gCurrentResource 
= -1 ; 
 632 wxStAppResource::wxStAppResource() 
 634     m_currentRefNum 
= CurResFile() ; 
 635     if ( gCurrentResource 
!= -1 ) 
 637         UseResFile( gCurrentResource 
) ; 
 641 wxStAppResource::~wxStAppResource() 
 643     if ( m_currentRefNum 
!= -1 ) 
 645         UseResFile( m_currentRefNum 
) ; 
 651 // for shared libraries we have to manually get the correct resource ref num upon 
 652 // initializing and releasing when terminating, therefore the __wxinitialize and __wxterminate 
 659 void __sinit(void);     /*      (generated by linker)   */ 
 660 pascal OSErr 
__initialize(const CFragInitBlock 
*theInitBlock
); 
 661 pascal void __terminate(void); 
 667 pascal OSErr 
__wxinitialize(const CFragInitBlock 
*theInitBlock
) 
 669    gCurrentResource 
= -1; 
 671    if (theInitBlock
->fragLocator
.where 
== kDataForkCFragLocator
) { 
 673          FSpOpenResFile(theInitBlock
->fragLocator
.u
.onDisk
.fileSpec
,  
 676    return __initialize( theInitBlock 
) ; 
 679 pascal void __wxterminate(void) 
 681     if (gCurrentResource 
!= -1) 
 682       CloseResFile(gCurrentResource
); 
 687 int WXDLLEXPORT 
wxEntryStart( int argc
, char *argv
[] ) 
 689     return wxApp::Initialize(); 
 693 int WXDLLEXPORT 
wxEntryInitGui() 
 695     return wxTheApp
->OnInitGui(); 
 699 void WXDLLEXPORT 
wxEntryCleanup() 
 705 int wxEntry( int argc
, char *argv
[] , bool enterLoop 
) 
 707     gCurrentResource 
= CurResFile() ; 
 709 #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT 
 710     // This seems to be necessary since there are 'rogue' 
 711     // objects present at this point (perhaps global objects?) 
 712     // Setting a checkpoint will ignore them as far as the 
 713     // memory checking facility is concerned. 
 714     // Of course you may argue that memory allocated in globals should be 
 715     // checked, but this is a reasonable compromise. 
 716     wxDebugContext::SetCheckpoint(); 
 719     if (!wxEntryStart(argc
, argv
)) { 
 722    // create the application object or ensure that one already exists 
 725         // The app may have declared a global application object, but we recommend 
 726         // the IMPLEMENT_APP macro is used instead, which sets an initializer 
 727         // function for delayed, dynamic app object construction. 
 728         wxCHECK_MSG( wxApp::GetInitializerFunction(), 0, 
 729                      wxT("No initializer - use IMPLEMENT_APP macro.") ); 
 731         wxTheApp 
= (wxApp
*) (*wxApp::GetInitializerFunction()) (); 
 734     wxCHECK_MSG( wxTheApp
, 0, wxT("You have to define an instance of wxApp!") ); 
 737     argc 
= 0 ; // currently we don't support files as parameters 
 739     // we could try to get the open apple events here to adjust argc and argv better 
 741     wxTheApp
->argc 
= argc
; 
 742     wxTheApp
->argv 
= argv
; 
 744     // GUI-specific initialization, such as creating an app context. 
 748     // Here frames insert themselves automatically 
 749     // into wxTopLevelWindows by getting created 
 754     if ( wxTheApp
->OnInit() ) 
 758             retValue 
= wxTheApp
->OnRun(); 
 761             // We want to initialize, but not run or exit immediately. 
 764     //else: app initialization failed, so we skipped OnRun() 
 766     wxWindow 
*topWindow 
= wxTheApp
->GetTopWindow(); 
 769         // Forcibly delete the window. 
 770         if ( topWindow
->IsKindOf(CLASSINFO(wxFrame
)) || 
 771                 topWindow
->IsKindOf(CLASSINFO(wxDialog
)) ) 
 773             topWindow
->Close(TRUE
); 
 774             wxTheApp
->DeletePendingObjects(); 
 779             wxTheApp
->SetTopWindow(NULL
); 
 790 // Static member initialization 
 791 wxAppInitializerFunction 
wxAppBase::m_appInitFn 
= (wxAppInitializerFunction
) NULL
; 
 798   m_wantDebugOutput 
= TRUE 
; 
 803   m_printMode 
= wxPRINT_WINDOWS
; 
 804   m_exitOnFrameDelete 
= TRUE
; 
 808 bool wxApp::Initialized() 
 816 int wxApp::MainLoop() 
 828 // Returns TRUE if more time is needed. 
 829 bool wxApp::ProcessIdle() 
 832     event
.SetEventObject(this); 
 835     return event
.MoreRequested(); 
 838 void wxApp::ExitMainLoop() 
 843 // Is a message/event pending? 
 844 bool wxApp::Pending() 
 848   return EventAvail( everyEvent 
, &event 
) ; 
 851 // Dispatch a message. 
 852 void wxApp::Dispatch() 
 857 void wxApp::OnIdle(wxIdleEvent
& event
) 
 859    static bool s_inOnIdle 
= FALSE
; 
 861     // Avoid recursion (via ProcessEvent default case) 
 868   // 'Garbage' collection of windows deleted with Close(). 
 869   DeletePendingObjects(); 
 871   // flush the logged messages if any 
 872   wxLog 
*pLog 
= wxLog::GetActiveTarget(); 
 873   if ( pLog 
!= NULL 
&& pLog
->HasPendingMessages() ) 
 876   // Send OnIdle events to all windows 
 877   bool needMore 
= SendIdleEvents(); 
 880     event
.RequestMore(TRUE
); 
 882     // If they are pending events, we must process them: pending events are 
 883     // either events to the threads other than main or events posted with 
 884     // wxPostEvent() functions 
 885     wxMacProcessNotifierAndPendingEvents(); 
 895 // Send idle event to all top-level windows 
 896 bool wxApp::SendIdleEvents() 
 898     bool needMore 
= FALSE
; 
 899     wxNode
* node 
= wxTopLevelWindows
.First(); 
 902         wxWindow
* win 
= (wxWindow
*) node
->Data(); 
 903         if (SendIdleEvents(win
)) 
 911 // Send idle event to window and all subwindows 
 912 bool wxApp::SendIdleEvents(wxWindow
* win
) 
 914     bool needMore 
= FALSE
; 
 917     event
.SetEventObject(win
); 
 918     win
->ProcessEvent(event
); 
 920     if (event
.MoreRequested()) 
 923     wxNode
* node 
= win
->GetChildren().First(); 
 926         wxWindow
* win 
= (wxWindow
*) node
->Data(); 
 927         if (SendIdleEvents(win
)) 
 935 void wxApp::DeletePendingObjects() 
 937   wxNode 
*node 
= wxPendingDelete
.First(); 
 940     wxObject 
*obj 
= (wxObject 
*)node
->Data(); 
 944     if (wxPendingDelete
.Member(obj
)) 
 947     // Deleting one object may have deleted other pending 
 948     // objects, so start from beginning of list again. 
 949     node 
= wxPendingDelete
.First(); 
 954 wxApp::GetStdIcon(int which
) const 
 958         case wxICON_INFORMATION
: 
 959             return wxIcon("wxICON_INFO"); 
 961         case wxICON_QUESTION
: 
 962             return wxIcon("wxICON_QUESTION"); 
 964         case wxICON_EXCLAMATION
: 
 965             return wxIcon("wxICON_WARNING"); 
 968             wxFAIL_MSG(wxT("requested non existent standard icon")); 
 969             // still fall through 
 972             return wxIcon("wxICON_ERROR"); 
 978     wxLogError(_("Fatal error: exiting")); 
 984 void wxApp::OnEndSession(wxCloseEvent
& WXUNUSED(event
)) 
 987         GetTopWindow()->Close(TRUE
); 
 990 // Default behaviour: close the application with prompts. The 
 991 // user can veto the close, and therefore the end session. 
 992 void wxApp::OnQueryEndSession(wxCloseEvent
& event
) 
 996         if (!GetTopWindow()->Close(!event
.CanVeto())) 
1001 extern "C" void wxCYield() ; 
1007 // Yield to other processes 
1009 bool wxApp::Yield(bool onlyIfNeeded
) 
1011     static bool s_inYield 
= FALSE
; 
1015         if ( !onlyIfNeeded 
) 
1017             wxFAIL_MSG( wxT("wxYield called recursively" ) ); 
1026     YieldToAnyThread() ; 
1030     long sleepTime 
= 1 ; //::GetCaretTime(); 
1032     while ( !wxTheApp
->IsExiting() && WaitNextEvent(everyEvent
, &event
,sleepTime
, (RgnHandle
) wxApp::s_macCursorRgn
)) 
1034         wxTheApp
->MacHandleOneEvent( &event 
); 
1035         if ( event
.what 
!= kHighLevelEvent 
) 
1036             SetRectRgn( (RgnHandle
) wxApp::s_macCursorRgn 
, event
.where
.h 
, event
.where
.v 
,  event
.where
.h 
+ 1 , event
.where
.v 
+ 1 ) ; 
1039     wxMacProcessNotifierAndPendingEvents() ; 
1046 // platform specifics 
1048 void wxApp::MacSuspend( bool convertClipboard 
) 
1050     // we have to deactive the top level windows manually 
1052     wxNode
* node 
= wxTopLevelWindows
.First(); 
1055         wxTopLevelWindow
* win 
= (wxTopLevelWindow
*) node
->Data(); 
1056         win
->MacActivate( MacGetCurrentEvent() , false ) ; 
1058         node 
= node
->Next(); 
1061      s_lastMouseDown 
= 0 ; 
1062      if( convertClipboard 
) 
1064          MacConvertPrivateToPublicScrap() ; 
1067      ::HideFloatingWindows() ; 
1070 void wxApp::MacResume( bool convertClipboard 
) 
1072         s_lastMouseDown 
= 0 ; 
1073         if( convertClipboard 
) 
1075             MacConvertPublicToPrivateScrap() ; 
1078         ::ShowFloatingWindows() ; 
1081 void wxApp::MacConvertPrivateToPublicScrap() 
1085 void wxApp::MacConvertPublicToPrivateScrap() 
1089 void wxApp::MacDoOneEvent() 
1093     long sleepTime 
= 1; // GetCaretTime() / 4 ; 
1095     if (WaitNextEvent(everyEvent
, &event
, sleepTime
, (RgnHandle
) s_macCursorRgn
)) 
1097         MacHandleOneEvent( &event 
); 
1102         WindowPtr window 
= ::FrontWindow() ; 
1104             ::IdleControls( window 
) ; 
1106         wxTheApp
->ProcessIdle() ; 
1108     if ( event
.what 
!= kHighLevelEvent 
) 
1109         SetRectRgn( (RgnHandle
) s_macCursorRgn 
, event
.where
.h 
, event
.where
.v 
,  event
.where
.h 
+ 1 , event
.where
.v 
+ 1 ) ; 
1113     DeletePendingObjects() ; 
1114     wxMacProcessNotifierAndPendingEvents() ; 
1117 void wxApp::MacHandleOneEvent( WXEVENTREF evr 
) 
1119     EventRecord
* ev 
= (EventRecord
*) evr 
; 
1120     m_macCurrentEvent 
= ev 
; 
1122     wxApp::sm_lastMessageTime 
= ev
->when 
; 
1127             MacHandleMouseDownEvent( ev 
) ; 
1128             if ( ev
->modifiers 
& controlKey 
) 
1129                 s_lastMouseDown 
= 2; 
1131                 s_lastMouseDown 
= 1; 
1134             if ( s_lastMouseDown 
== 2 ) 
1136                 ev
->modifiers 
|= controlKey 
; 
1140                 ev
->modifiers 
&= ~controlKey 
; 
1142             MacHandleMouseUpEvent( ev 
) ; 
1143             s_lastMouseDown 
= 0; 
1146             MacHandleActivateEvent( ev 
) ; 
1149             MacHandleUpdateEvent( ev 
) ; 
1153             MacHandleKeyDownEvent( ev 
) ; 
1156             MacHandleKeyUpEvent( ev 
) ; 
1159             MacHandleDiskEvent( ev 
) ; 
1162             MacHandleOSEvent( ev 
) ; 
1164         case kHighLevelEvent
: 
1165             MacHandleHighLevelEvent( ev 
) ; 
1170     wxMacProcessNotifierAndPendingEvents() ; 
1173 void wxApp::MacHandleHighLevelEvent( WXEVENTREF evr 
) 
1175     EventRecord
* ev 
= (EventRecord
*) evr 
; 
1176     ::AEProcessAppleEvent( ev 
) ; 
1179 bool s_macIsInModalLoop 
= false ; 
1181 void wxApp::MacHandleMouseDownEvent( WXEVENTREF evr 
) 
1183     EventRecord
* ev 
= (EventRecord
*) evr 
; 
1184     wxToolTip::RemoveToolTips() ; 
1187     WindowRef frontWindow 
= ::FrontNonFloatingWindow() ; 
1188     WindowAttributes frontWindowAttributes 
= NULL 
; 
1190         ::GetWindowAttributes( frontWindow 
, &frontWindowAttributes 
) ; 
1192     short windowPart 
= ::FindWindow(ev
->where
, &window
); 
1193     wxTopLevelWindowMac
* win 
= wxFindWinFromMacWindow( window 
) ; 
1194     if ( wxPendingDelete
.Member(win
) ) 
1198     GetQDGlobalsScreenBits( &screenBits 
); 
1203             if ( s_macIsInModalLoop 
) 
1209                 UInt32 menuresult 
= MenuSelect(ev
->where
) ; 
1210                 MacHandleMenuSelect( HiWord( menuresult 
) , LoWord( menuresult 
) ); 
1211                 s_lastMouseDown 
= 0; 
1216             SystemClick( ev 
, window 
) ; 
1217             s_lastMouseDown 
= 0; 
1221             if ( window 
!= frontWindow 
&& s_macIsInModalLoop 
&& !(ev
->modifiers 
& cmdKey 
) ) 
1227                 DragWindow(window
, ev
->where
, &screenBits
.bounds
); 
1232                     Point pt 
= { 0, 0 } ; 
1233                     SetPortWindowPort(window
) ; 
1234                     LocalToGlobal( &pt 
) ; 
1236                         win
->SetSize( pt
.h 
, pt
.v 
, -1 , 
1237                             -1 , wxSIZE_USE_EXISTING
); 
1239                 s_lastMouseDown 
= 0; 
1243             if (TrackGoAway(window
, ev
->where
)) 
1248             s_lastMouseDown 
= 0; 
1252                 int growResult 
= GrowWindow(window 
, ev
->where
, &screenBits
.bounds
); 
1253                 if (growResult 
!= 0) 
1255                     int newWidth 
= LoWord(growResult
); 
1256                     int newHeight 
= HiWord(growResult
); 
1257                     int oldWidth
, oldHeight
; 
1262                         win
->GetSize(&oldWidth
, &oldHeight
); 
1264                             newWidth 
= oldWidth
; 
1266                             newHeight 
= oldHeight
; 
1267                         win
->SetSize( -1, -1, newWidth
, newHeight
, wxSIZE_USE_EXISTING
); 
1270                 s_lastMouseDown 
= 0; 
1275                 if (TrackBox(window
, ev
->where
, windowPart
)) 
1277                     // TODO setup size event 
1278                     ZoomWindow( window 
, windowPart 
, false ) ; 
1283                         GetWindowPortBounds(window
, &tempRect 
) ; 
1284                         win
->SetSize( -1, -1, tempRect
.right
-tempRect
.left 
, 
1285                             tempRect
.bottom
-tempRect
.top
, wxSIZE_USE_EXISTING
); 
1288             s_lastMouseDown 
= 0; 
1290         case inCollapseBox 
: 
1291                 // TODO setup size event 
1292             s_lastMouseDown 
= 0; 
1299                     SetPortWindowPort(window
) ; 
1302                 if ( window 
!= frontWindow 
&& wxTheApp
->s_captureWindow 
== NULL 
) 
1304                     if ( s_macIsInModalLoop 
) 
1308                     else if ( UMAIsWindowFloating( window 
) ) 
1311                             win
->MacMouseDown( ev 
, windowPart 
) ; 
1316                             win
->MacMouseDown( ev 
, windowPart 
) ; 
1317                         ::SelectWindow( window 
) ; 
1323                         win
->MacMouseDown( ev 
, windowPart 
) ; 
1332 void wxApp::MacHandleMouseUpEvent( WXEVENTREF evr 
) 
1334     EventRecord
* ev 
= (EventRecord
*) evr 
; 
1337     short windowPart 
= inNoWindow 
; 
1338         if ( wxTheApp
->s_captureWindow 
) 
1340                 window 
= (WindowRef
) s_captureWindow
->MacGetRootWindow() ; 
1341                 windowPart 
= inContent 
; 
1345                 windowPart 
= ::FindWindow(ev
->where
, &window
) ; 
1356                 wxTopLevelWindowMac
* win 
= wxFindWinFromMacWindow( window 
) ; 
1358                     win
->MacMouseUp( ev 
, windowPart 
) ; 
1364 long wxMacTranslateKey(unsigned char key
, unsigned char code
) ; 
1365 long wxMacTranslateKey(unsigned char key
, unsigned char code
) 
1374                  retval 
= WXK_RETURN
; 
1389                  retval 
= WXK_PAGEUP
; 
1392                  retval 
= WXK_PAGEDOWN
; 
1395                  retval 
= WXK_RETURN
; 
1450                 retval 
= WXK_ESCAPE 
; 
1456                 retval 
= WXK_RIGHT 
; 
1465                 retval 
= WXK_DELETE 
; 
1473 void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr 
) 
1475     EventRecord
* ev 
= (EventRecord
*) evr 
; 
1476     wxToolTip::RemoveToolTips() ; 
1478     UInt32 menuresult 
= UMAMenuEvent(ev
) ; 
1479     if ( HiWord( menuresult 
) ) 
1481         if ( !s_macIsInModalLoop 
) 
1482         MacHandleMenuSelect( HiWord( menuresult 
) , LoWord( menuresult 
) ) ; 
1488         keychar 
= short(ev
->message 
& charCodeMask
); 
1489         keycode 
= short(ev
->message 
& keyCodeMask
) >> 8 ; 
1490         long keyval 
= wxMacTranslateKey(keychar
, keycode
) ; 
1491         bool handled 
= false ; 
1492         wxWindow
* focus 
= wxWindow::FindFocus() ; 
1496             wxKeyEvent 
event(wxEVT_KEY_DOWN
); 
1497             event
.m_shiftDown 
= ev
->modifiers 
& shiftKey
; 
1498             event
.m_controlDown 
= ev
->modifiers 
& controlKey
; 
1499             event
.m_altDown 
= ev
->modifiers 
& optionKey
; 
1500             event
.m_metaDown 
= ev
->modifiers 
& cmdKey
; 
1501             event
.m_keyCode 
= keyval
; 
1502             event
.m_x 
= ev
->where
.h
; 
1503             event
.m_y 
= ev
->where
.v
; 
1504             event
.m_timeStamp 
= ev
->when
; 
1505             event
.SetEventObject(focus
); 
1506             handled 
= focus
->GetEventHandler()->ProcessEvent( event 
) ; 
1512                     wxWindow 
*ancestor 
= focus
; 
1516                         int command = ancestor->GetAcceleratorTable()->GetCommand( event ); 
1519                             wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command ); 
1520                             handled = ancestor->GetEventHandler()->ProcessEvent( command_event ); 
1523                         if (ancestor->m_isFrame) 
1525                         ancestor = ancestor->GetParent(); 
1529                 #endif // wxUSE_ACCEL 
1533                 wxKeyEvent 
event(wxEVT_CHAR
); 
1534                 event
.m_shiftDown 
= ev
->modifiers 
& shiftKey
; 
1535                 event
.m_controlDown 
= ev
->modifiers 
& controlKey
; 
1536                 event
.m_altDown 
= ev
->modifiers 
& optionKey
; 
1537                 event
.m_metaDown 
= ev
->modifiers 
& cmdKey
; 
1538                 event
.m_keyCode 
= keyval
; 
1539                 event
.m_x 
= ev
->where
.h
; 
1540                 event
.m_y 
= ev
->where
.v
; 
1541                 event
.m_timeStamp 
= ev
->when
; 
1542                 event
.SetEventObject(focus
); 
1543                 handled 
= focus
->GetEventHandler()->ProcessEvent( event 
) ; 
1546                  (keyval 
== WXK_TAB
) && 
1547                  (!focus
->HasFlag(wxTE_PROCESS_TAB
)) && 
1548                  (focus
->GetParent()) && 
1549                  (focus
->GetParent()->HasFlag( wxTAB_TRAVERSAL
)) ) 
1551                 wxNavigationKeyEvent new_event
; 
1552                 new_event
.SetEventObject( focus 
); 
1553                 new_event
.SetDirection( !event
.ShiftDown() ); 
1554                 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */ 
1555                 new_event
.SetWindowChange( event
.ControlDown() ); 
1556                 new_event
.SetCurrentFocus( focus 
); 
1557                 handled 
= focus
->GetEventHandler()->ProcessEvent( new_event 
); 
1562             // if window is not having a focus still testing for default enter or cancel 
1563             // TODO add the UMA version for ActiveNonFloatingWindow 
1564           focus 
= wxFindWinFromMacWindow( FrontWindow() ) ; 
1567             if ( keyval 
== WXK_RETURN 
) 
1569                  wxButton 
*def 
= wxDynamicCast(focus
->GetDefaultItem(), 
1571                  if ( def 
&& def
->IsEnabled() ) 
1573                      wxCommandEvent 
event(wxEVT_COMMAND_BUTTON_CLICKED
, def
->GetId() ); 
1574                      event
.SetEventObject(def
); 
1575                      def
->Command(event
); 
1579             /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */ 
1580             else if (keyval 
== WXK_ESCAPE 
|| (keyval 
== '.' && ev
->modifiers 
& cmdKey 
) ) 
1582                   wxCommandEvent 
new_event(wxEVT_COMMAND_BUTTON_CLICKED
,wxID_CANCEL
); 
1583                   new_event
.SetEventObject( focus 
); 
1584                   handled 
= focus
->GetEventHandler()->ProcessEvent( new_event 
); 
1591 void wxApp::MacHandleKeyUpEvent( WXEVENTREF evr 
) 
1593     EventRecord
* ev 
= (EventRecord
*) evr 
; 
1594     wxToolTip::RemoveToolTips() ; 
1596     UInt32 menuresult 
= UMAMenuEvent(ev
) ; 
1597     if ( HiWord( menuresult 
) ) 
1604         keychar 
= short(ev
->message 
& charCodeMask
); 
1605         keycode 
= short(ev
->message 
& keyCodeMask
) >> 8 ; 
1607         wxWindow
* focus 
= wxWindow::FindFocus() ; 
1610             long keyval 
= wxMacTranslateKey(keychar
, keycode
) ; 
1612             wxKeyEvent 
event(wxEVT_KEY_UP
); 
1613             event
.m_shiftDown 
= ev
->modifiers 
& shiftKey
; 
1614             event
.m_controlDown 
= ev
->modifiers 
& controlKey
; 
1615             event
.m_altDown 
= ev
->modifiers 
& optionKey
; 
1616             event
.m_metaDown 
= ev
->modifiers 
& cmdKey
; 
1617             event
.m_keyCode 
= keyval
; 
1618             event
.m_x 
= ev
->where
.h
; 
1619             event
.m_y 
= ev
->where
.v
; 
1620             event
.m_timeStamp 
= ev
->when
; 
1621             event
.SetEventObject(focus
); 
1622             bool handled 
= focus
->GetEventHandler()->ProcessEvent( event 
) ; 
1627 void wxApp::MacHandleActivateEvent( WXEVENTREF evr 
) 
1629     EventRecord
* ev 
= (EventRecord
*) evr 
; 
1630     WindowRef window 
= (WindowRef
) ev
->message 
; 
1633         bool activate 
= (ev
->modifiers 
& activeFlag 
) ; 
1634         WindowClass wclass 
; 
1635         ::GetWindowClass ( window 
, &wclass 
) ; 
1636         if ( wclass 
== kFloatingWindowClass 
) 
1638             // if it is a floater we activate/deactivate the front non-floating window instead 
1639             window 
= ::FrontNonFloatingWindow() ; 
1641         wxTopLevelWindowMac
* win 
= wxFindWinFromMacWindow( window 
) ; 
1643             win
->MacActivate( ev 
, activate 
) ; 
1647 void wxApp::MacHandleUpdateEvent( WXEVENTREF evr 
) 
1649     EventRecord
* ev 
= (EventRecord
*) evr 
; 
1650     WindowRef window 
= (WindowRef
) ev
->message 
; 
1651     wxTopLevelWindowMac 
* win 
= wxFindWinFromMacWindow( window 
) ; 
1654         if ( !wxPendingDelete
.Member(win
) ) 
1655             win
->MacUpdate( ev
->when 
) ; 
1659         // since there is no way of telling this foreign window to update itself 
1660         // we have to invalidate the update region otherwise we keep getting the same 
1661         // event over and over again 
1662         BeginUpdate( window 
) ; 
1663         EndUpdate( window 
) ; 
1667 void wxApp::MacHandleDiskEvent( WXEVENTREF evr 
) 
1669     EventRecord
* ev 
= (EventRecord
*) evr 
; 
1670     if ( HiWord( ev
->message 
) != noErr 
) 
1675          SetPt( &point 
, 100 , 100 ) ; 
1677           err 
= DIBadMount( point 
, ev
->message 
) ; 
1678         wxASSERT( err 
== noErr 
) ; 
1683 void wxApp::MacHandleOSEvent( WXEVENTREF evr 
) 
1685     EventRecord
* ev 
= (EventRecord
*) evr 
; 
1686     switch( ( ev
->message 
& osEvtMessageMask 
) >> 24 ) 
1688         case suspendResumeMessage 
: 
1690                 bool isResuming 
= ev
->message 
& resumeFlag 
; 
1692                 bool convertClipboard 
= ev
->message 
& convertClipboardFlag 
; 
1694                 bool convertClipboard 
= false; 
1696                 bool doesActivate 
= UMAGetProcessModeDoesActivateOnFGSwitch() ; 
1699                     WindowRef oldFrontWindow 
= NULL 
; 
1700                     WindowRef newFrontWindow 
= NULL 
; 
1702                     // in case we don't take care of activating ourselves, we have to synchronize 
1703                     // our idea of the active window with the process manager's - which it already activated 
1705                     if ( !doesActivate 
) 
1706                         oldFrontWindow 
= ::FrontNonFloatingWindow() ; 
1708                     MacResume( convertClipboard 
) ; 
1710                     newFrontWindow 
= ::FrontNonFloatingWindow() ; 
1712                     if ( oldFrontWindow 
) 
1714                         wxTopLevelWindowMac
* win 
= wxFindWinFromMacWindow( oldFrontWindow 
) ; 
1716                             win
->MacActivate( ev 
, false ) ; 
1718                     if ( newFrontWindow 
) 
1720                         wxTopLevelWindowMac
* win 
= wxFindWinFromMacWindow( newFrontWindow 
) ; 
1722                             win
->MacActivate( ev 
, true ) ; 
1727                     MacSuspend( convertClipboard 
) ; 
1729                     // in case this suspending did close an active window, another one might 
1730                     // have surfaced -> lets deactivate that one 
1732 /* TODO : find out what to do on systems < 10 , perhaps FrontNonFloatingWindow 
1733                     WindowRef newActiveWindow = ::ActiveNonFloatingWindow() ; 
1734                     if ( newActiveWindow ) 
1736                         wxWindow* win = wxFindWinFromMacWindow( newActiveWindow ) ; 
1738                             win->MacActivate( ev , false ) ; 
1744         case mouseMovedMessage 
: 
1748                 wxWindow
* currentMouseWindow 
= NULL 
; 
1750                 wxWindow::MacGetWindowFromPoint( wxPoint( ev
->where
.h 
, ev
->where
.v 
) , 
1751                                                  ¤tMouseWindow 
) ; 
1752                 if ( currentMouseWindow 
!= wxWindow::s_lastMouseWindow 
) 
1754                     wxMouseEvent event 
; 
1756                     bool isDown 
= !(ev
->modifiers 
& btnState
) ; // 1 is for up 
1757                     bool controlDown 
= ev
->modifiers 
& controlKey 
; // for simulating right mouse 
1759                     event
.m_leftDown 
= isDown 
&& !controlDown
; 
1760                     event
.m_middleDown 
= FALSE
; 
1761                     event
.m_rightDown 
= isDown 
&& controlDown
; 
1762                     event
.m_shiftDown 
= ev
->modifiers 
& shiftKey
; 
1763                     event
.m_controlDown 
= ev
->modifiers 
& controlKey
; 
1764                     event
.m_altDown 
= ev
->modifiers 
& optionKey
; 
1765                     event
.m_metaDown 
= ev
->modifiers 
& cmdKey
; 
1766                     event
.m_x 
= ev
->where
.h
; 
1767                     event
.m_y 
= ev
->where
.v
; 
1768                     event
.m_timeStamp 
= ev
->when
; 
1769                     event
.SetEventObject(this); 
1771                     if ( wxWindow::s_lastMouseWindow 
) 
1773                         wxMouseEvent 
eventleave(event
); 
1774                         eventleave
.SetEventType( wxEVT_LEAVE_WINDOW 
); 
1775                         wxWindow::s_lastMouseWindow
->ScreenToClient( &eventleave
.m_x
, &eventleave
.m_y 
); 
1777                         wxWindow::s_lastMouseWindow
->GetEventHandler()->ProcessEvent(eventleave
); 
1779                     if ( currentMouseWindow 
) 
1781                         wxMouseEvent 
evententer(event
); 
1782                         evententer
.SetEventType( wxEVT_ENTER_WINDOW 
); 
1783                         currentMouseWindow
->ScreenToClient( &evententer
.m_x
, &evententer
.m_y 
); 
1785                         currentMouseWindow
->GetEventHandler()->ProcessEvent(evententer
); 
1787                     wxWindow::s_lastMouseWindow 
= currentMouseWindow 
; 
1790                 short windowPart 
= ::FindWindow(ev
->where
, &window
); 
1794                     // fixes for setting the cursor back from dominic mazzoni 
1796                         UMAShowArrowCursor(); 
1799                         UMAShowArrowCursor(); 
1803                             // if ( s_lastMouseDown == 0 ) 
1804                             //     ev->modifiers |= btnState ; 
1806                             // Calling GetNextEvent with a zero event mask will always 
1807                             // pass back a null event. However, it fills the EventRecord 
1808                             // with the state of the modifier keys. This is needed since 
1809                             // the modifier state returned by WaitForNextEvent often is 
1810                             // wrong mouse move events. The attempt above to correct this 
1811                             // didn't always work (under OS X at least). 
1814                             ::GetNextEvent(0, &tmp
); 
1815                             ev
->modifiers 
= tmp
.modifiers
; 
1817                             wxTopLevelWindowMac
* win 
= wxFindWinFromMacWindow( window 
) ; 
1819                                 win
->MacMouseMoved( ev 
, windowPart 
) ; 
1821                                 UMAShowArrowCursor(); 
1832 void wxApp::MacHandleMenuSelect( int macMenuId 
, int macMenuItemNum 
) 
1835          return; // no menu item selected 
1837     if (macMenuId 
== kwxMacAppleMenuId 
&& macMenuItemNum 
> 1) 
1840         Str255        deskAccessoryName 
; 
1843         GetMenuItemText(GetMenuHandle(kwxMacAppleMenuId
), macMenuItemNum
, deskAccessoryName
); 
1844         GetPort(&savedPort
); 
1845         OpenDeskAcc(deskAccessoryName
); 
1851         wxWindow
* frontwindow 
= wxFindWinFromMacWindow( ::FrontWindow() )  ; 
1852         if ( frontwindow 
&& wxMenuBar::MacGetInstalledMenuBar() ) 
1853             wxMenuBar::MacGetInstalledMenuBar()->MacMenuSelect( frontwindow
->GetEventHandler() , 0 , macMenuId 
, macMenuItemNum 
) ; 
1859 long wxApp::MacTranslateKey(char key, int mods) 
1863 void wxApp::MacAdjustCursor() 
1870 wxApp::macAdjustCursor() 
1872   if (ev->what != kHighLevelEvent) 
1874     wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow()); 
1877         if (!theMacWxFrame->MacAdjustCursor(ev->where)) 
1878         ::SetCursor(&(qd.arrow));