]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/window.cpp
added FreeBSD
[wxWidgets.git] / src / gtk / window.cpp
index ac31501f9b192c24df14ca48a3efa478b6fa7c53..f60a748ecf99d1f1e0c8c99f077372eaddb15d94 100644 (file)
@@ -24,7 +24,9 @@
 #if wxUSE_DRAG_AND_DROP
 #include "wx/dnd.h"
 #endif
+#if wxUSE_TOOLTIPS
 #include "wx/tooltip.h"
+#endif
 #include "wx/menu.h"
 #include "wx/statusbr.h"
 #include "wx/intl.h"
@@ -1508,6 +1510,14 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
 
 wxWindow::~wxWindow()
 {
+    // Remove potential dangling pointer
+    if (GetParent() && GetParent()->IsKindOf(CLASSINFO(wxPanel)))
+    {
+        wxPanel* panel = (wxPanel*) GetParent();
+        if (panel->GetLastFocus() == this)
+            panel->SetLastFocus((wxWindow*) NULL);
+    }
+
     m_hasVMT = FALSE;
 
 #if wxUSE_DRAG_AND_DROP
@@ -1818,11 +1828,24 @@ void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags )
         if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
         if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
 
-        wxPoint pt( m_parent->GetClientAreaOrigin() );
-        gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y );
+        if (GTK_WIDGET_HAS_DEFAULT(m_widget))
+       {
+           /* the default button has a border around it */
+           int border = 5;
+       
+            wxPoint pt( m_parent->GetClientAreaOrigin() );
+            gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x-border, m_y+pt.y-border );
 
-        if ((old_width != m_width) || (old_height != m_height))
-             gtk_widget_set_usize( m_widget, m_width, m_height );
+            gtk_widget_set_usize( m_widget, m_width+2*border, m_height+2*border );
+       }
+       else
+       {
+            wxPoint pt( m_parent->GetClientAreaOrigin() );
+            gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y );
+
+            if ((old_width != m_width) || (old_height != m_height))
+              gtk_widget_set_usize( m_widget, m_width, m_height );
+       }
     }
 
     m_sizeSet = TRUE;
@@ -2414,12 +2437,11 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
         {
             gdk_window_clear_area( m_wxwindow->window,
                                    rect->x, rect->y,
-                                   rect->width,
-                                   rect->height );
+                                   rect->width, rect->height );
         }
         else
         {
-            Clear();
+            gdk_window_clear( m_wxwindow->window );
         }
     }
 
@@ -2474,7 +2496,10 @@ void wxWindow::Clear()
 {
     wxCHECK_RET( m_widget != NULL, "invalid window" );
 
-    if (m_wxwindow && m_wxwindow->window) gdk_window_clear( m_wxwindow->window );
+    if (m_wxwindow && m_wxwindow->window)
+    {
+        gdk_window_clear( m_wxwindow->window );
+    }
 }
 
 #if wxUSE_TOOLTIPS
@@ -2527,14 +2552,18 @@ void wxWindow::SetBackgroundColour( const wxColour &colour )
     m_backgroundColour = colour;
     if (!m_backgroundColour.Ok()) return;
 
-    if (m_wxwindow)
+    if (m_wxwindow && m_wxwindow->window)
     {
-        GdkWindow *window = m_wxwindow->window;
-        m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
-        gdk_window_set_background( window, m_backgroundColour.GetColor() );
+       /* wxMSW doesn't clear the window here. I don't do that
+          either to provide compatibility. call Clear() to do 
+          the job. */
+          
+        m_backgroundColour.CalcPixel( gdk_window_get_colormap( m_wxwindow->window ) );
+        gdk_window_set_background( m_wxwindow->window, m_backgroundColour.GetColor() );
     }
 
     wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
+    
     if (sysbg.Red() == colour.Red() &&
         sysbg.Green() == colour.Green() &&
         sysbg.Blue() == colour.Blue())
@@ -2727,6 +2756,8 @@ bool wxWindow::PopupMenu( wxMenu *menu, int x, int y )
 
     SetInvokingWindow( menu, this );
 
+    menu->UpdateUI();
+
     gs_pop_x = x;
     gs_pop_y = y;