X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c944ce357363980e712aea76a1e570f042449955..ee658398812ab334b39a2632cd99e2ffe6d4bc79:/src/mac/app.cpp diff --git a/src/mac/app.cpp b/src/mac/app.cpp index 3c0a395135..0b4b57cc2f 100644 --- a/src/mac/app.cpp +++ b/src/mac/app.cpp @@ -37,6 +37,7 @@ #include "wx/textctrl.h" #include "wx/menu.h" #include "wx/docview.h" +#include "wx/filename.h" #include @@ -123,6 +124,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 AEHandleRApp( const AppleEvent *event , AppleEvent *reply , long refcon ) ; pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , long WXUNUSED(refcon) ) { @@ -144,6 +146,11 @@ pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long WX return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ; } +pascal OSErr AEHandleRApp( const AppleEvent *event , AppleEvent *reply , long WXUNUSED(refcon) ) +{ + return wxTheApp->MacHandleAERApp( (AppleEvent*) event , reply) ; +} + // AEODoc Calls MacOpenFile on each of the files passed short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply)) @@ -224,18 +231,29 @@ short wxApp::MacHandleAEOApp(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNU short wxApp::MacHandleAEQuit(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply)) { - wxWindow* win = GetTopWindow() ; + wxWindow* win = GetTopWindow() ; if ( win ) { - win->Close(TRUE ) ; + wxCommandEvent exitEvent(wxEVT_COMMAND_MENU_SELECTED, s_macExitMenuItemId); + if (!win->ProcessEvent(exitEvent)) + win->Close(TRUE ) ; } - else + else { ExitMainLoop() ; } return noErr ; } +// AEROApp calls MacReopenApp + +short wxApp::MacHandleAERApp(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply)) +{ + MacReopenApp() ; + return noErr ; +} + + //---------------------------------------------------------------------- // Support Routines linking the Mac...File Calls to the Document Manager //---------------------------------------------------------------------- @@ -279,6 +297,11 @@ void wxApp::MacNewFile() { } +void wxApp::MacReopenApp() +{ + // eventually check for open docs, if none, call MacNewFile +} + //---------------------------------------------------------------------- // Carbon Event Handler //---------------------------------------------------------------------- @@ -647,6 +670,11 @@ bool wxApp::Initialize(int& argc, wxChar **argv) if ( !wxAppBase::Initialize(argc, argv) ) return false; +#if wxUSE_INTL + wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding()); +#endif + + wxWinMacWindowList = new wxList(wxKEY_INTEGER); wxWinMacControlList = new wxList(wxKEY_INTEGER); @@ -685,6 +713,9 @@ bool wxApp::OnInitGui() AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments , NewAEEventHandlerUPP(AEHandlePDoc) , 0 , FALSE ) ; + AEInstallEventHandler( kCoreEventClass , kAEReopenApplication , + NewAEEventHandlerUPP(AEHandleRApp) , + 0 , FALSE ) ; AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerUPP(AEHandleQuit) , 0 , FALSE ) ; @@ -698,6 +729,9 @@ bool wxApp::OnInitGui() AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments , NewAEEventHandlerProc(AEHandlePDoc) , 0 , FALSE ) ; + AEInstallEventHandler( kCoreEventClass , kAEReopenApplication , + NewAEEventHandlerProc(AEHandleRApp) , + 0 , FALSE ) ; AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerProc(AEHandleQuit) , 0 , FALSE ) ; @@ -1812,6 +1846,10 @@ int wxKeyCodeToMacModifier(wxKeyCode key) bool wxGetKeyState(wxKeyCode key) //virtual key code if < 10.2.x, else see below { +//#ifdef __DARWIN__ +// wxHIDKeyboard keyboard; +// return keyboard.IsActive(key); +//#else // TODO: Have it use HID Manager on OSX... //if OS X > 10.2 (i.e. 10.2.x) //a known apple bug prevents the system from determining led @@ -1821,6 +1859,7 @@ bool wxGetKeyState(wxKeyCode key) //virtual key code if < 10.2.x, else see below // KeyMapByteArray keymap; // GetKeys((BigEndianLong*)keymap); // return !!(BitTst(keymap, (sizeof(KeyMapByteArray)*8) - iKey)); +//#endif } #if !TARGET_CARBON