From 5ab6aab8801b509282f5faa1718b5586fcf915ae Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Thu, 16 Jan 2003 06:54:47 +0000 Subject: [PATCH] preferences menu implementation git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18766 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/app.cpp | 41 +++++++++++++++++++++++++++++++++++------ src/mac/carbon/app.cpp | 41 +++++++++++++++++++++++++++++++++++------ 2 files changed, 70 insertions(+), 12 deletions(-) diff --git a/src/mac/app.cpp b/src/mac/app.cpp index 29dc8af328..cb46018f47 100644 --- a/src/mac/app.cpp +++ b/src/mac/app.cpp @@ -113,6 +113,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) ) @@ -139,6 +140,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 & fileName ) { @@ -1183,14 +1200,26 @@ bool wxApp::Initialized() int wxApp::MainLoop() { - m_keepGoing = TRUE; + m_keepGoing = TRUE; - while (m_keepGoing) - { - MacDoOneEvent() ; - } +#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() ; + } - return 0; + return 0; } // Returns TRUE if more time is needed. diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index 29dc8af328..cb46018f47 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -113,6 +113,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) ) @@ -139,6 +140,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 & fileName ) { @@ -1183,14 +1200,26 @@ bool wxApp::Initialized() int wxApp::MainLoop() { - m_keepGoing = TRUE; + m_keepGoing = TRUE; - while (m_keepGoing) - { - MacDoOneEvent() ; - } +#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() ; + } - return 0; + return 0; } // Returns TRUE if more time is needed. -- 2.45.2