]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/carbon/app.cpp
Compilation fixes for Cairo-based wxGraphicsContext code under MSW.
[wxWidgets.git] / src / osx / carbon / app.cpp
index 722f9cc2f899f7c3bf024da32a3d0521e90765ac..1505a9883e126e123061212fae55ee9105137a55 100644 (file)
@@ -710,22 +710,7 @@ pascal OSStatus wxMacAppEventHandler( EventHandlerCallRef handler , EventRef eve
             break ;
 #endif
         case kEventClassAppleEvent :
-            {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-                if ( AEProcessEvent != NULL )
-                {
-                    result = AEProcessEvent(event);
-                }
-#endif
-#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
-                {
-                    EventRecord rec ;
-
-                    wxMacConvertEventToRecord( event , &rec ) ;
-                    result = AEProcessAppleEvent( &rec ) ;
-                }
-#endif
-            }
+            result = AEProcessEvent(event);
             break ;
 
         default :
@@ -807,7 +792,37 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
         {
             // remove this argument
             --argc;
-            memmove(argv + 1, argv + 2, argc * sizeof(char *));
+            memmove(argv + 1, argv + 2, argc * sizeof(wxChar*));
+        }
+    }
+
+    /*
+     Cocoa supports -Key value options which set the user defaults key "Key"
+     to the value "value"  Some of them are very handy for debugging like
+     -NSShowAllViews YES.  Cocoa picks these up from the real argv so
+     our removal of them from the wx copy of it does not affect Cocoa's
+     ability to see them.
+     
+     We basically just assume that any "-NS" option and its following
+     argument needs to be removed from argv.  We hope that user code does
+     not expect to see -NS options and indeed it's probably a safe bet
+     since most user code accepting options is probably using the
+     double-dash GNU-style syntax.
+     */
+    for(int i=1; i < argc; ++i)
+    {
+        static const wxChar *ARG_NS = wxT("-NS");
+        if( wxStrncmp(argv[i], ARG_NS, wxStrlen(ARG_NS)) == 0 )
+        {
+            // Only eat this option if it has an argument
+            if( (i + 1) < argc )
+            {
+                memmove(argv + i, argv + i + 2, (argc-i-1)*sizeof(wxChar*));
+                argc -= 2;
+                // drop back one position so the next run through the loop
+                // reprocesses the argument at our current index.
+                --i;
+            }
         }
     }
 
@@ -952,98 +967,6 @@ void wxApp::CleanUp()
 // misc initialization stuff
 //----------------------------------------------------------------------
 
-#if wxOSX_USE_CARBON && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
-bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec)
-{
-    OSStatus err = noErr ;
-    bool converted = ConvertEventRefToEventRecord( event, rec) ;
-
-    if ( !converted )
-    {
-        switch ( GetEventClass( event ) )
-        {
-            case kEventClassKeyboard :
-            {
-                converted = true ;
-                switch ( GetEventKind(event) )
-                {
-                    case kEventRawKeyDown :
-                        rec->what = keyDown ;
-                        break ;
-
-                    case kEventRawKeyRepeat :
-                        rec->what = autoKey ;
-                        break ;
-
-                    case kEventRawKeyUp :
-                        rec->what = keyUp ;
-                        break ;
-
-                    case kEventRawKeyModifiersChanged :
-                        rec->what = nullEvent ;
-                        break ;
-
-                    default :
-                        converted = false ;
-                        break ;
-                }
-
-                if ( converted )
-                {
-                    UInt32 keyCode ;
-                    unsigned char charCode ;
-                    UInt32 modifiers ;
-                    GetMouse( &rec->where) ;
-                    err = GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, 4, NULL, &modifiers);
-                    err = GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, 4, NULL, &keyCode);
-                    err = GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, 1, NULL, &charCode);
-                    rec->modifiers = modifiers ;
-                    rec->message = (keyCode << 8 ) + charCode ;
-                }
-            }
-            break ;
-
-            case kEventClassTextInput :
-            {
-                switch ( GetEventKind( event ) )
-                {
-                    case kEventTextInputUnicodeForKeyEvent :
-                        {
-                            EventRef rawEvent ;
-                            err = GetEventParameter(
-                                event, kEventParamTextInputSendKeyboardEvent, typeEventRef, NULL,
-                                sizeof(rawEvent), NULL, &rawEvent ) ;
-                            converted = true ;
-
-                            {
-                                UInt32 keyCode, modifiers;
-                                unsigned char charCode ;
-                                GetMouse( &rec->where) ;
-                                rec->what = keyDown ;
-                                err = GetEventParameter(rawEvent, kEventParamKeyModifiers, typeUInt32, NULL, 4, NULL, &modifiers);
-                                err = GetEventParameter(rawEvent, kEventParamKeyCode, typeUInt32, NULL, 4, NULL, &keyCode);
-                                err = GetEventParameter(rawEvent, kEventParamKeyMacCharCodes, typeChar, NULL, 1, NULL, &charCode);
-                                rec->modifiers = modifiers ;
-                                rec->message = (keyCode << 8 ) + charCode ;
-                            }
-                       }
-                       break ;
-
-                    default :
-                        break ;
-                }
-            }
-            break ;
-
-            default :
-                break ;
-        }
-    }
-
-    return converted ;
-}
-#endif
-
 wxApp::wxApp()
 {
     m_printMode = wxPRINT_WINDOWS;
@@ -1319,8 +1242,8 @@ CGKeyCode wxCharCodeWXToOSX(wxKeyCode code)
             
         case WXK_SHIFT:       keycode = kVK_Shift; break;
         case WXK_ALT:         keycode = kVK_Option; break;
-        case WXK_CONTROL:     keycode = kVK_Control; break;
-        case WXK_COMMAND:     keycode = kVK_Command; break;
+        case WXK_RAW_CONTROL: keycode = kVK_Control; break;
+        case WXK_CONTROL:     keycode = kVK_Command; break;
             
         case WXK_CAPITAL:     keycode = kVK_CapsLock; break;
         case WXK_END:         keycode = kVK_End; break;
@@ -1530,6 +1453,7 @@ int wxMacKeyCodeToModifier(wxKeyCode key)
     {
     case WXK_START:
     case WXK_MENU:
+    case WXK_COMMAND:
         return cmdKey;
 
     case WXK_SHIFT:
@@ -1541,7 +1465,7 @@ int wxMacKeyCodeToModifier(wxKeyCode key)
     case WXK_ALT:
         return optionKey;
 
-    case WXK_CONTROL:
+    case WXK_RAW_CONTROL:
         return controlKey;
 
     default:
@@ -1570,10 +1494,10 @@ wxMouseState wxGetMouseState()
     ms.SetRightDown( (buttons & 0x02) != 0 );
 
     UInt32 modifiers = GetCurrentKeyModifiers();
-    ms.SetControlDown(modifiers & controlKey);
+    ms.SetRawControlDown(modifiers & controlKey);
     ms.SetShiftDown(modifiers & shiftKey);
     ms.SetAltDown(modifiers & optionKey);
-    ms.SetMetaDown(modifiers & cmdKey);
+    ms.SetControlDown(modifiers & cmdKey);
 
     return ms;
 }
@@ -1615,20 +1539,16 @@ bool wxApp::MacSendCharEvent( wxWindow* focus , long keymessage , long modifiers
 
 #if wxOSX_USE_CARBON
     long keyval = event.m_keyCode ;
-    wxNonOwnedWindow *tlw = focus->MacGetTopLevelWindow() ;
 
-    if (tlw)
     {
-        event.SetEventType( wxEVT_CHAR_HOOK );
-        handled = tlw->HandleWindowEvent( event );
-        if ( handled && event.GetSkipped() )
+        wxKeyEvent eventCharHook(wxEVT_CHAR_HOOK, event);
+        handled = focus->HandleWindowEvent( eventCharHook );
+        if ( handled && eventCharHook.IsNextEventAllowed() )
             handled = false ;
     }
 
     if ( !handled )
     {
-        event.SetEventType( wxEVT_CHAR );
-        event.Skip( false ) ;
         handled = focus->HandleWindowEvent( event ) ;
     }
 
@@ -1766,9 +1686,9 @@ void wxApp::MacCreateKeyEvent( wxKeyEvent& event, wxWindow* focus , long keymess
     }
 
     event.m_shiftDown = modifiers & shiftKey;
-    event.m_controlDown = modifiers & controlKey;
+    event.m_rawControlDown = modifiers & controlKey;
     event.m_altDown = modifiers & optionKey;
-    event.m_metaDown = modifiers & cmdKey;
+    event.m_controlDown = modifiers & cmdKey;
     event.m_keyCode = keyval ;
 #if wxUSE_UNICODE
     event.m_uniChar = uniChar ;