]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/window.cpp
moving string conversions at one place
[wxWidgets.git] / src / mac / window.cpp
index 2515e88ca54ab28664cb9e03f6d5a70b6c16cee7..cf5a48692c480456b1421e54a56cb7c6fa28f358 100644 (file)
@@ -197,6 +197,17 @@ bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id,
 {
     wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindowMac without parent") );
 
+#if wxUSE_STATBOX
+    // wxGTK doesn't allow to create controls with static box as the parent so
+    // this will result in a crash when the program is ported to wxGTK - warn
+    // about it
+    //
+    // the correct solution is to create the controls as siblings of the
+    // static box
+    wxASSERT_MSG( !wxDynamicCast(parent, wxStaticBox),
+                  _T("wxStaticBox can't be used as a window parent!") );
+#endif // wxUSE_STATBOX
+
     if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
         return FALSE;
 
@@ -227,24 +238,32 @@ void wxWindowMac::SetFocus()
     {
         if (gFocusWindow )
         {
-            #if wxUSE_CARET
+#if wxUSE_CARET
                 // Deal with caret
                 if ( gFocusWindow->m_caret )
                 {
                       gFocusWindow->m_caret->OnKillFocus();
                 }
-            #endif // wxUSE_CARET
-      #ifndef __WXUNIVERSAL__
+#endif // wxUSE_CARET
+#ifndef __WXUNIVERSAL__
             wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ;
             if ( control && control->GetMacControl() )
             {
                 UMASetKeyboardFocus( (WindowRef) gFocusWindow->MacGetRootWindow() , (ControlHandle) control->GetMacControl()  , kControlFocusNoPart ) ;
                 control->MacRedrawControl() ;
             }
-            #endif
-            wxFocusEvent event(wxEVT_KILL_FOCUS, gFocusWindow->m_windowId);
-            event.SetEventObject(gFocusWindow);
-            gFocusWindow->GetEventHandler()->ProcessEvent(event) ;
+#endif
+            // Without testing the window id, for some reason
+            // a kill focus event can still be sent to
+            // the control just being focussed.
+            int thisId = this->m_windowId;
+            int gFocusWindowId = gFocusWindow->m_windowId;
+            if (gFocusWindowId != thisId)
+            {
+                wxFocusEvent event(wxEVT_KILL_FOCUS, gFocusWindow->m_windowId);
+                event.SetEventObject(gFocusWindow);
+                gFocusWindow->GetEventHandler()->ProcessEvent(event) ;
+            }
         }
         gFocusWindow = this ;
         {
@@ -1765,7 +1784,8 @@ void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase)
         if ( erase && !EmptyRgn(ownUpdateRgn) )
         {
           wxWindowDC dc(this);
-          dc.SetClippingRegion(wxRegion(ownUpdateRgn));
+          if (!EmptyRgn(ownUpdateRgn)) 
+              dc.SetClippingRegion(wxRegion(ownUpdateRgn));
           wxEraseEvent eevent( GetId(), &dc );
           eevent.SetEventObject( this );
           GetEventHandler()->ProcessEvent( eevent );