X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/12e049f6f09a7589e5f761ac50bfc1594785ef88..243116066d1877a29f559bb04a5c913ddc8e4d28:/src/mac/app.cpp diff --git a/src/mac/app.cpp b/src/mac/app.cpp index 864237148c..587cdeb344 100644 --- a/src/mac/app.cpp +++ b/src/mac/app.cpp @@ -133,23 +133,88 @@ pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long WX return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ; } -short wxApp::MacHandleAEODoc(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply)) +// new virtual public method in wxApp +void wxApp::MacOpenFile(const wxString & WXUNUSED(fileName) ) { - SysBeep(40) ; +} + +void wxApp::MacPrintFile(const wxString & WXUNUSED(fileName) ) +{ +} + +void wxApp::MacNewFile() +{ +} + +// new implementation, which parses the event and calls +// MacOpenFile on each of the files it's passed +short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply)) +{ + AEDescList docList; + AEKeyword keywd; + DescType returnedType; + Size actualSize; + long itemsInList; + FSSpec theSpec; + OSErr err; + short i; + err = AEGetParamDesc((AppleEvent *)event, keyDirectObject, typeAEList,&docList); + if (err != noErr) + return err; + + err = AECountItems(&docList, &itemsInList); + if (err != noErr) + return err; + ProcessSerialNumber PSN ; PSN.highLongOfPSN = 0 ; PSN.lowLongOfPSN = kCurrentProcess ; SetFrontProcess( &PSN ) ; - return noErr ; -} - -short wxApp::MacHandleAEPDoc(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply)) -{ - return noErr ; + + for (i = 1; i <= itemsInList; i++) { + AEGetNthPtr(&docList, i, typeFSS, &keywd, &returnedType, + (Ptr) & theSpec, sizeof(theSpec), &actualSize); + wxString fName = wxMacFSSpec2MacFilename(&theSpec); + MacOpenFile(fName); + } + return noErr; +} + +short wxApp::MacHandleAEPDoc(const WXEVENTREF event , WXEVENTREF WXUNUSED(reply)) +{ + AEDescList docList; + AEKeyword keywd; + DescType returnedType; + Size actualSize; + long itemsInList; + FSSpec theSpec; + OSErr err; + short i; + err = AEGetParamDesc((AppleEvent *)event, keyDirectObject, typeAEList,&docList); + if (err != noErr) + return err; + + err = AECountItems(&docList, &itemsInList); + if (err != noErr) + return err; + + ProcessSerialNumber PSN ; + PSN.highLongOfPSN = 0 ; + PSN.lowLongOfPSN = kCurrentProcess ; + SetFrontProcess( &PSN ) ; + + for (i = 1; i <= itemsInList; i++) { + AEGetNthPtr(&docList, i, typeFSS, &keywd, &returnedType, + (Ptr) & theSpec, sizeof(theSpec), &actualSize); + wxString fName = wxMacFSSpec2MacFilename(&theSpec); + MacPrintFile(fName); + } + return noErr; } short wxApp::MacHandleAEOApp(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply)) { + MacNewFile() ; return noErr ; } @@ -1823,29 +1888,39 @@ void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr ) bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey ) { + if ( !focus ) + return false ; + short keycode ; short keychar ; keychar = short(keymessage & charCodeMask); keycode = short(keymessage & keyCodeMask) >> 8 ; - if ( (modifiers & controlKey) ) + if ( modifiers & ( controlKey|shiftKey|optionKey ) ) { // control interferes with some built-in keys like pgdown, return etc. therefore we remove the controlKey modifier // and look at the character after UInt32 state = 0; - UInt32 keyInfo = KeyTranslate((Ptr)GetScriptManagerVariable(smKCHRCache), ( modifiers & (~controlKey)) | keycode, &state); + UInt32 keyInfo = KeyTranslate((Ptr)GetScriptManagerVariable(smKCHRCache), ( modifiers & (~(controlKey|shiftKey|optionKey))) | keycode, &state); keychar = short(keyInfo & charCodeMask); keycode = short(keyInfo & keyCodeMask) >> 8 ; } long keyval = wxMacTranslateKey(keychar, keycode) ; - + long realkeyval = keyval ; + if ( keyval == keychar ) + { + // we are not on a special character combo -> pass the real os event-value to EVT_CHAR, but not to EVT_KEY (make upper first) + realkeyval = short(keymessage & charCodeMask) ; + keyval = wxToupper( keyval ) ; + } + wxKeyEvent event(wxEVT_KEY_DOWN); bool handled = false ; event.m_shiftDown = modifiers & shiftKey; event.m_controlDown = modifiers & controlKey; event.m_altDown = modifiers & optionKey; event.m_metaDown = modifiers & cmdKey; - event.m_keyCode = wxToupper(keyval ); + event.m_keyCode = keyval ; event.m_x = wherex; event.m_y = wherey; @@ -1881,7 +1956,7 @@ bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifi event.Skip( FALSE ) ; event.SetEventType( wxEVT_CHAR ) ; // raw value again - event.m_keyCode = keyval ; + event.m_keyCode = realkeyval ; handled = focus->GetEventHandler()->ProcessEvent( event ) ; if ( handled && event.GetSkipped() ) @@ -1959,40 +2034,43 @@ void wxApp::MacHandleKeyUpEvent( WXEVENTREF evr ) bool wxApp::MacSendKeyUpEvent( wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey ) { + if ( !focus ) + return false ; + short keycode ; short keychar ; keychar = short(keymessage & charCodeMask); keycode = short(keymessage & keyCodeMask) >> 8 ; - if ( (modifiers & controlKey) ) + if ( modifiers & ( controlKey|shiftKey|optionKey ) ) { // control interferes with some built-in keys like pgdown, return etc. therefore we remove the controlKey modifier // and look at the character after UInt32 state = 0; - UInt32 keyInfo = KeyTranslate((Ptr)GetScriptManagerVariable(smKCHRCache), ( modifiers & (~controlKey)) | keycode, &state); + UInt32 keyInfo = KeyTranslate((Ptr)GetScriptManagerVariable(smKCHRCache), ( modifiers & (~(controlKey|shiftKey|optionKey))) | keycode, &state); keychar = short(keyInfo & charCodeMask); keycode = short(keyInfo & keyCodeMask) >> 8 ; } long keyval = wxMacTranslateKey(keychar, keycode) ; + if ( keyval == keychar ) + { + keyval = wxToupper( keyval ) ; + } bool handled = false ; - if ( focus ) - { - wxKeyEvent event(wxEVT_KEY_UP); - event.m_shiftDown = modifiers & shiftKey; - event.m_controlDown = modifiers & controlKey; - event.m_altDown = modifiers & optionKey; - event.m_metaDown = modifiers & cmdKey; - if ( event.m_controlDown ) - { - } - event.m_keyCode = wxToupper(keyval ); - event.m_x = wherex; - event.m_y = wherey; - event.m_timeStamp = when; - event.SetEventObject(focus); - handled = focus->GetEventHandler()->ProcessEvent( event ) ; - } + wxKeyEvent event(wxEVT_KEY_UP); + event.m_shiftDown = modifiers & shiftKey; + event.m_controlDown = modifiers & controlKey; + event.m_altDown = modifiers & optionKey; + event.m_metaDown = modifiers & cmdKey; + event.m_keyCode = keyval ; + + event.m_x = wherex; + event.m_y = wherey; + event.m_timeStamp = when; + event.SetEventObject(focus); + handled = focus->GetEventHandler()->ProcessEvent( event ) ; + return handled ; } void wxApp::MacHandleActivateEvent( WXEVENTREF evr )