X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e8566d35384f83d88ac5f14b6209136377535c14..34885a147bdca70749ac22737b55cbc6e0558b4a:/src/mac/app.cpp diff --git a/src/mac/app.cpp b/src/mac/app.cpp index 864e760185..0f813f16ab 100644 --- a/src/mac/app.cpp +++ b/src/mac/app.cpp @@ -56,9 +56,6 @@ #if wxUSE_SOCKETS #ifdef __DARWIN__ #include - #else - #include - #include #endif #endif @@ -85,7 +82,7 @@ const short kMacMinHeap = (29 * 1024) ; const short kwxMacMenuBarResource = 1 ; const short kwxMacAppleMenuId = 1 ; -RgnHandle wxApp::s_macCursorRgn = NULL; +WXHRGN wxApp::s_macCursorRgn = NULL; wxWindow* wxApp::s_captureWindow = NULL ; int wxApp::s_lastMouseDown = 0 ; long wxApp::sm_lastMessageTime = 0; @@ -125,7 +122,7 @@ pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long re return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ; } -OSErr wxApp::MacHandleAEODoc(const AppleEvent *event , AppleEvent *reply) +short wxApp::MacHandleAEODoc(const WXEVENTREF event , WXEVENTREF reply) { SysBeep(40) ; ProcessSerialNumber PSN ; @@ -135,17 +132,17 @@ OSErr wxApp::MacHandleAEODoc(const AppleEvent *event , AppleEvent *reply) return noErr ; } -OSErr wxApp::MacHandleAEPDoc(const AppleEvent *event , AppleEvent *reply) +short wxApp::MacHandleAEPDoc(const WXEVENTREF event , WXEVENTREF reply) { return noErr ; } -OSErr wxApp::MacHandleAEOApp(const AppleEvent *event , AppleEvent *reply) +short wxApp::MacHandleAEOApp(const WXEVENTREF event , WXEVENTREF reply) { return noErr ; } -OSErr wxApp::MacHandleAEQuit(const AppleEvent *event , AppleEvent *reply) +short wxApp::MacHandleAEQuit(const WXEVENTREF event , WXEVENTREF reply) { wxWindow* win = GetTopWindow() ; if ( win ) @@ -526,6 +523,7 @@ bool wxApp::Initialize() void wxApp::CleanUp() { + wxToolTip::RemoveToolTips() ; #if wxUSE_LOG // flush the logged messages if any and install a 'safer' log target: the // default one (wxLogGui) can't be used after the resources are freed just @@ -563,6 +561,9 @@ void wxApp::CleanUp() if (wxWinMacWindowList) delete wxWinMacWindowList ; + if (wxWinMacControlList) + delete wxWinMacControlList ; + delete wxPendingEvents; #if wxUSE_THREADS delete wxPendingEventsLocker; @@ -603,7 +604,7 @@ void wxApp::CleanUp() UMACleanupToolbox() ; if (s_macCursorRgn) - ::DisposeRgn(s_macCursorRgn); + ::DisposeRgn((RgnHandle)s_macCursorRgn); #if 0 TerminateAE() ; @@ -958,11 +959,11 @@ bool wxApp::Yield(bool onlyIfNeeded) long sleepTime = 1 ; //::GetCaretTime(); - while ( !wxTheApp->IsExiting() && WaitNextEvent(everyEvent, &event,sleepTime, wxApp::s_macCursorRgn)) + while ( !wxTheApp->IsExiting() && WaitNextEvent(everyEvent, &event,sleepTime, (RgnHandle) wxApp::s_macCursorRgn)) { wxTheApp->MacHandleOneEvent( &event ); if ( event.what != kHighLevelEvent ) - SetRectRgn( wxApp::s_macCursorRgn , event.where.h , event.where.v , event.where.h + 1 , event.where.v + 1 ) ; + SetRectRgn( (RgnHandle) wxApp::s_macCursorRgn , event.where.h , event.where.v , event.where.h + 1 , event.where.v + 1 ) ; } wxMacProcessNotifierAndPendingEvents() ; @@ -976,19 +977,24 @@ bool wxApp::Yield(bool onlyIfNeeded) void wxApp::MacSuspend( bool convertClipboard ) { - // we have to deactive the window manually + // we have to deactive the top level windows manually - wxWindow* window = GetTopWindow() ; - if ( window ) - window->MacActivate( MacGetCurrentEvent() , false ) ; + wxNode* node = wxTopLevelWindows.First(); + while (node) + { + wxTopLevelWindow* win = (wxTopLevelWindow*) node->Data(); + win->MacActivate( MacGetCurrentEvent() , false ) ; - s_lastMouseDown = 0 ; - if( convertClipboard ) - { - MacConvertPrivateToPublicScrap() ; - } + node = node->Next(); + } + + s_lastMouseDown = 0 ; + if( convertClipboard ) + { + MacConvertPrivateToPublicScrap() ; + } - ::HideFloatingWindows() ; + ::HideFloatingWindows() ; } void wxApp::MacResume( bool convertClipboard ) @@ -1016,7 +1022,7 @@ void wxApp::MacDoOneEvent() long sleepTime = 1; // GetCaretTime() / 4 ; - if (WaitNextEvent(everyEvent, &event, sleepTime, s_macCursorRgn)) + if (WaitNextEvent(everyEvent, &event, sleepTime, (RgnHandle) s_macCursorRgn)) { MacHandleOneEvent( &event ); } @@ -1030,7 +1036,7 @@ void wxApp::MacDoOneEvent() wxTheApp->ProcessIdle() ; } if ( event.what != kHighLevelEvent ) - SetRectRgn( s_macCursorRgn , event.where.h , event.where.v , event.where.h + 1 , event.where.v + 1 ) ; + SetRectRgn( (RgnHandle) s_macCursorRgn , event.where.h , event.where.v , event.where.h + 1 , event.where.v + 1 ) ; // repeaters @@ -1038,8 +1044,9 @@ void wxApp::MacDoOneEvent() wxMacProcessNotifierAndPendingEvents() ; } -void wxApp::MacHandleOneEvent( EventRecord *ev ) +void wxApp::MacHandleOneEvent( WXEVENTREF evr ) { + EventRecord* ev = (EventRecord*) evr ; m_macCurrentEvent = ev ; wxApp::sm_lastMessageTime = ev->when ; @@ -1093,15 +1100,17 @@ void wxApp::MacHandleOneEvent( EventRecord *ev ) wxMacProcessNotifierAndPendingEvents() ; } -void wxApp::MacHandleHighLevelEvent( EventRecord *ev ) +void wxApp::MacHandleHighLevelEvent( WXEVENTREF evr ) { + EventRecord* ev = (EventRecord*) evr ; ::AEProcessAppleEvent( ev ) ; } bool s_macIsInModalLoop = false ; -void wxApp::MacHandleMouseDownEvent( EventRecord *ev ) +void wxApp::MacHandleMouseDownEvent( WXEVENTREF evr ) { + EventRecord* ev = (EventRecord*) evr ; wxToolTip::RemoveToolTips() ; WindowRef window; @@ -1111,7 +1120,7 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev ) ::GetWindowAttributes( frontWindow , &frontWindowAttributes ) ; short windowPart = ::FindWindow(ev->where, &window); - wxWindow* win = wxFindWinFromMacWindow( window ) ; + wxTopLevelWindowMac* win = wxFindWinFromMacWindow( window ) ; if ( wxPendingDelete.Member(win) ) return ; @@ -1151,12 +1160,7 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev ) GrafPtr port ; GetPort( &port ) ; Point pt = { 0, 0 } ; - #if TARGET_CARBON SetPort( GetWindowPort(window) ) ; - #else - SetPort( (window) ) ; - #endif - SetOrigin( 0 , 0 ) ; LocalToGlobal( &pt ) ; SetPort( port ) ; win->SetSize( pt.h , pt.v , -1 , @@ -1222,12 +1226,7 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev ) { GrafPtr port ; GetPort( &port ) ; - #if TARGET_CARBON SetPort( GetWindowPort(window) ) ; - #else - SetPort( (window) ) ; - #endif - SetOrigin( 0 , 0 ) ; SetPort( port ) ; } if ( window != frontWindow && wxTheApp->s_captureWindow == NULL ) @@ -1260,8 +1259,9 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev ) } } -void wxApp::MacHandleMouseUpEvent( EventRecord *ev ) +void wxApp::MacHandleMouseUpEvent( WXEVENTREF evr ) { + EventRecord* ev = (EventRecord*) evr ; WindowRef window; short windowPart = ::FindWindow(ev->where, &window); @@ -1274,7 +1274,7 @@ void wxApp::MacHandleMouseUpEvent( EventRecord *ev ) break ; default: { - wxWindow* win = wxFindWinFromMacWindow( window ) ; + wxTopLevelWindowMac* win = wxFindWinFromMacWindow( window ) ; if ( win ) win->MacMouseUp( ev , windowPart ) ; } @@ -1391,8 +1391,9 @@ long wxMacTranslateKey(unsigned char key, unsigned char code) return retval; } -void wxApp::MacHandleKeyDownEvent( EventRecord *ev ) +void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr ) { + EventRecord* ev = (EventRecord*) evr ; wxToolTip::RemoveToolTips() ; UInt32 menuresult = UMAMenuEvent(ev) ; @@ -1508,8 +1509,9 @@ void wxApp::MacHandleKeyDownEvent( EventRecord *ev ) } } -void wxApp::MacHandleKeyUpEvent( EventRecord *ev ) +void wxApp::MacHandleKeyUpEvent( WXEVENTREF evr ) { + EventRecord* ev = (EventRecord*) evr ; wxToolTip::RemoveToolTips() ; UInt32 menuresult = UMAMenuEvent(ev) ; @@ -1543,8 +1545,9 @@ void wxApp::MacHandleKeyUpEvent( EventRecord *ev ) } } -void wxApp::MacHandleActivateEvent( EventRecord *ev ) +void wxApp::MacHandleActivateEvent( WXEVENTREF evr ) { + EventRecord* ev = (EventRecord*) evr ; WindowRef window = (WindowRef) ev->message ; if ( window ) { @@ -1556,20 +1559,21 @@ void wxApp::MacHandleActivateEvent( EventRecord *ev ) // if it is a floater we activate/deactivate the front non-floating window instead window = ::FrontNonFloatingWindow() ; } - wxWindow* win = wxFindWinFromMacWindow( window ) ; + wxTopLevelWindowMac* win = wxFindWinFromMacWindow( window ) ; if ( win ) win->MacActivate( ev , activate ) ; } } -void wxApp::MacHandleUpdateEvent( EventRecord *ev ) +void wxApp::MacHandleUpdateEvent( WXEVENTREF evr ) { + EventRecord* ev = (EventRecord*) evr ; WindowRef window = (WindowRef) ev->message ; - wxWindow * win = wxFindWinFromMacWindow( window ) ; + wxTopLevelWindowMac * win = wxFindWinFromMacWindow( window ) ; if ( win ) { if ( !wxPendingDelete.Member(win) ) - win->MacUpdate( ev ) ; + win->MacUpdate( ev->when ) ; } else { @@ -1581,8 +1585,9 @@ void wxApp::MacHandleUpdateEvent( EventRecord *ev ) } } -void wxApp::MacHandleDiskEvent( EventRecord *ev ) +void wxApp::MacHandleDiskEvent( WXEVENTREF evr ) { + EventRecord* ev = (EventRecord*) evr ; if ( HiWord( ev->message ) != noErr ) { #if !TARGET_CARBON @@ -1596,8 +1601,9 @@ void wxApp::MacHandleDiskEvent( EventRecord *ev ) } } -void wxApp::MacHandleOSEvent( EventRecord *ev ) +void wxApp::MacHandleOSEvent( WXEVENTREF evr ) { + EventRecord* ev = (EventRecord*) evr ; switch( ( ev->message & osEvtMessageMask ) >> 24 ) { case suspendResumeMessage : @@ -1626,13 +1632,13 @@ void wxApp::MacHandleOSEvent( EventRecord *ev ) if ( oldFrontWindow ) { - wxWindow* win = wxFindWinFromMacWindow( oldFrontWindow ) ; + wxTopLevelWindowMac* win = wxFindWinFromMacWindow( oldFrontWindow ) ; if ( win ) win->MacActivate( ev , false ) ; } if ( newFrontWindow ) { - wxWindow* win = wxFindWinFromMacWindow( newFrontWindow ) ; + wxTopLevelWindowMac* win = wxFindWinFromMacWindow( newFrontWindow ) ; if ( win ) win->MacActivate( ev , true ) ; } @@ -1726,7 +1732,7 @@ void wxApp::MacHandleOSEvent( EventRecord *ev ) ::GetNextEvent(0, &tmp); ev->modifiers = tmp.modifiers; - wxWindow* win = wxFindWinFromMacWindow( window ) ; + wxTopLevelWindowMac* win = wxFindWinFromMacWindow( window ) ; if ( win ) win->MacMouseMoved( ev , windowPart ) ; else