]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/classic/app.cpp
replace use of deprecated GtkPixmap
[wxWidgets.git] / src / mac / classic / app.cpp
index bbce9ec7698471df75c539788ce0a756ad190109..80a5cd86da8ff4f325f14900f4ad662d06a250a1 100644 (file)
 #ifndef WX_PRECOMP
     #include "wx/intl.h"
     #include "wx/log.h"
+    #include "wx/utils.h"
+    #include "wx/window.h"
+    #include "wx/frame.h"
+    #include "wx/dc.h"
+    #include "wx/button.h"
+    #include "wx/menu.h"
+    #include "wx/pen.h"
+    #include "wx/brush.h"
+    #include "wx/palette.h"
+    #include "wx/icon.h"
+    #include "wx/cursor.h"
+    #include "wx/dialog.h"
+    #include "wx/msgdlg.h"
+    #include "wx/textctrl.h"
+    #include "wx/memory.h"
+    #include "wx/gdicmn.h"
+    #include "wx/module.h"
 #endif
 
-#include "wx/window.h"
-#include "wx/frame.h"
-#include "wx/button.h"
-#include "wx/utils.h"
-#include "wx/gdicmn.h"
-#include "wx/pen.h"
-#include "wx/brush.h"
-#include "wx/cursor.h"
-#include "wx/icon.h"
-#include "wx/palette.h"
-#include "wx/dc.h"
-#include "wx/dialog.h"
-#include "wx/msgdlg.h"
-#include "wx/module.h"
-#include "wx/memory.h"
 #include "wx/tooltip.h"
-#include "wx/textctrl.h"
-#include "wx/menu.h"
 #include "wx/docview.h"
 #include "wx/filename.h"
 
@@ -48,9 +48,9 @@
 // mac
 
 #ifndef __DARWIN__
-  #if __option(profile)
-    #include <profiler.h>
-  #endif
+    #if __option(profile)
+        #include <profiler.h>
+    #endif
 #endif
 
 #include "apprsrc.h"
@@ -346,7 +346,7 @@ MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
             // VZ: we could find the menu from its handle here by examining all
             //     the menus in the menu bar recursively but knowing that neither
             //     wxMSW nor wxGTK do it why bother...
- #if 0
+#if 0
             MenuRef menuRef;
 
             GetEventParameter(event,
@@ -354,7 +354,7 @@ MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
                               typeMenuRef, NULL,
                               sizeof(menuRef), NULL,
                               &menuRef);
- #endif // 0
+#endif // 0
 
             wxEventType type=0;
             MenuCommand cmd=0;
@@ -2015,31 +2015,34 @@ bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifi
     // backdoor handler for default return and command escape
     if ( !handled && (!focus->IsKindOf(CLASSINFO(wxControl) ) || !focus->MacCanFocus() ) )
     {
-          // if window is not having a focus still testing for default enter or cancel
-          // TODO add the UMA version for ActiveNonFloatingWindow
-          wxWindow* focus = wxFindWinFromMacWindow( (WXWindow) FrontWindow() ) ;
-          if ( focus )
-          {
+        // if window is not having a focus still testing for default enter or cancel
+        // TODO add the UMA version for ActiveNonFloatingWindow
+        wxWindow* focus = wxFindWinFromMacWindow( (WXWindow) FrontWindow() ) ;
+        if ( focus )
+        {
             if ( keyval == WXK_RETURN )
             {
-                 wxButton *def = wxDynamicCast(focus->GetDefaultItem(),
-                                                       wxButton);
-                 if ( def && def->IsEnabled() )
-                 {
-                     wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
-                     event.SetEventObject(def);
-                     def->Command(event);
-                     return true ;
+                wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
+                if ( tlw && tlw->GetDefaultItem() )
+                {
+                    wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton);
+                    if ( def && def->IsEnabled() )
+                    {
+                        wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
+                        event.SetEventObject(def);
+                        def->Command(event);
+                        return true ;
+                    }
                 }
             }
             /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
             else if (keyval == WXK_ESCAPE || (keyval == '.' && modifiers & cmdKey ) )
             {
-                  wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
-                  new_event.SetEventObject( focus );
-                  handled = focus->GetEventHandler()->ProcessEvent( new_event );
+                wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
+                new_event.SetEventObject( focus );
+                handled = focus->GetEventHandler()->ProcessEvent( new_event );
             }
-          }
+        }
     }
     return handled ;
 }