diff --git a/src/mac/app.cpp b/src/mac/app.cpp index 51980c7564..eb0e9ede10 100644 --- a/src/mac/app.cpp +++ b/src/mac/app.cpp @@ -109,6 +109,7 @@ pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , long re pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , long refcon ) ; pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , long refcon ) ; pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long refcon ) ; +pascal OSErr AEHandlePreferences( const AppleEvent *event , AppleEvent *reply , long refcon ) ; pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , long WXUNUSED(refcon) ) @@ -135,6 +136,22 @@ pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long WX return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ; } +pascal OSErr AEHandlePreferences( const AppleEvent *event , AppleEvent *reply , long WXUNUSED(refcon) ) +{ + // GD: UNUSED wxApp* app = (wxApp*) refcon ; + + wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ; + wxMenu* menu = NULL ; + wxMenuItem* item = NULL ; + if ( mbar ) + { + item = mbar->FindItem( wxApp::s_macPreferencesMenuItemId , &menu ) ; + } + if ( item != NULL && menu != NULL && mbar != NULL ) + menu->SendEvent( wxApp::s_macPreferencesMenuItemId , -1 ) ; + return noErr ; +} + // new virtual public method in wxApp void wxApp::MacOpenFile(const wxString & WXUNUSED(fileName) ) { @@ -1154,6 +1171,18 @@ int wxApp::MainLoop() { m_keepGoing = TRUE; +#if TARGET_CARBON + if ( UMAGetSystemVersion() >= 0x1000 ) + { + if ( s_macPreferencesMenuItemId ) + { + EnableMenuCommand( NULL , kHICommandPreferences ) ; + AEInstallEventHandler( kCoreEventClass , kAEShowPreferences , + NewAEEventHandlerUPP(AEHandlePreferences) , + (long) wxTheApp , FALSE ) ; + } + } +#endif while (m_keepGoing) { MacDoOneEvent() ; @@ -1696,31 +1725,32 @@ void wxApp::MacHandleMouseDownEvent( WXEVENTREF evr ) GrafPtr port ; GetPort( &port ) ; SetPortWindowPort(window) ; + + if ( window != frontWindow && wxTheApp->s_captureWindow == NULL ) + { + if ( s_macIsInModalLoop ) + { + SysBeep ( 30 ) ; + } + else if ( UMAIsWindowFloating( window ) ) + { + if ( win ) + win->MacMouseDown( ev , windowPart ) ; + } + else + { + if ( win ) + win->MacMouseDown( ev , windowPart ) ; + ::SelectWindow( window ) ; + } + } + else + { + if ( win ) + win->MacMouseDown( ev , windowPart ) ; + } SetPort( port ) ; } - if ( window != frontWindow && wxTheApp->s_captureWindow == NULL ) - { - if ( s_macIsInModalLoop ) - { - SysBeep ( 30 ) ; - } - else if ( UMAIsWindowFloating( window ) ) - { - if ( win ) - win->MacMouseDown( ev , windowPart ) ; - } - else - { - if ( win ) - win->MacMouseDown( ev , windowPart ) ; - ::SelectWindow( window ) ; - } - } - else - { - if ( win ) - win->MacMouseDown( ev , windowPart ) ; - } break ; default: diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index 51980c7564..eb0e9ede10 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -109,6 +109,7 @@ pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , long re pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , long refcon ) ; pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , long refcon ) ; pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long refcon ) ; +pascal OSErr AEHandlePreferences( const AppleEvent *event , AppleEvent *reply , long refcon ) ; pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , long WXUNUSED(refcon) ) @@ -135,6 +136,22 @@ pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long WX return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ; } +pascal OSErr AEHandlePreferences( const AppleEvent *event , AppleEvent *reply , long WXUNUSED(refcon) ) +{ + // GD: UNUSED wxApp* app = (wxApp*) refcon ; + + wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ; + wxMenu* menu = NULL ; + wxMenuItem* item = NULL ; + if ( mbar ) + { + item = mbar->FindItem( wxApp::s_macPreferencesMenuItemId , &menu ) ; + } + if ( item != NULL && menu != NULL && mbar != NULL ) + menu->SendEvent( wxApp::s_macPreferencesMenuItemId , -1 ) ; + return noErr ; +} + // new virtual public method in wxApp void wxApp::MacOpenFile(const wxString & WXUNUSED(fileName) ) { @@ -1154,6 +1171,18 @@ int wxApp::MainLoop() { m_keepGoing = TRUE; +#if TARGET_CARBON + if ( UMAGetSystemVersion() >= 0x1000 ) + { + if ( s_macPreferencesMenuItemId ) + { + EnableMenuCommand( NULL , kHICommandPreferences ) ; + AEInstallEventHandler( kCoreEventClass , kAEShowPreferences , + NewAEEventHandlerUPP(AEHandlePreferences) , + (long) wxTheApp , FALSE ) ; + } + } +#endif while (m_keepGoing) { MacDoOneEvent() ; @@ -1696,31 +1725,32 @@ void wxApp::MacHandleMouseDownEvent( WXEVENTREF evr ) GrafPtr port ; GetPort( &port ) ; SetPortWindowPort(window) ; + + if ( window != frontWindow && wxTheApp->s_captureWindow == NULL ) + { + if ( s_macIsInModalLoop ) + { + SysBeep ( 30 ) ; + } + else if ( UMAIsWindowFloating( window ) ) + { + if ( win ) + win->MacMouseDown( ev , windowPart ) ; + } + else + { + if ( win ) + win->MacMouseDown( ev , windowPart ) ; + ::SelectWindow( window ) ; + } + } + else + { + if ( win ) + win->MacMouseDown( ev , windowPart ) ; + } SetPort( port ) ; } - if ( window != frontWindow && wxTheApp->s_captureWindow == NULL ) - { - if ( s_macIsInModalLoop ) - { - SysBeep ( 30 ) ; - } - else if ( UMAIsWindowFloating( window ) ) - { - if ( win ) - win->MacMouseDown( ev , windowPart ) ; - } - else - { - if ( win ) - win->MacMouseDown( ev , windowPart ) ; - ::SelectWindow( window ) ; - } - } - else - { - if ( win ) - win->MacMouseDown( ev , windowPart ) ; - } break ; default: