Implement wxWindow::DoGetBorderSize() for all ports.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 11 Jul 2010 10:43:49 +0000 (10:43 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 11 Jul 2010 10:43:49 +0000 (10:43 +0000)
Implement DoGetBorderSize() properly for wxGTK and use the difference between
the full window size and the client size for all the ports not implementing
this method. The latter is incorrect in the presence of the scrollbars but is
the best we can do in general.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64880 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/window.h
include/wx/window.h
src/common/wincmn.cpp
src/gtk/window.cpp

index 20aa4c181b0f801e64cbc3929ff92eed7b7ab81e..4fc6ea6f9efc10cf7c5c16202c14a7416ccc33db 100644 (file)
@@ -314,6 +314,7 @@ protected:
                            int width, int height,
                            int sizeFlags = wxSIZE_AUTO);
     virtual void DoSetClientSize(int width, int height);
+    virtual wxSize DoGetBorderSize() const;
     virtual void DoMoveWindow(int x, int y, int width, int height);
     virtual void DoEnable(bool enable);
 
index 52b6daafc29b9224123bbd18f60c9ee803f9df29..6c7930a209a225264de6e15555ada29b070cb60b 100644 (file)
@@ -1679,8 +1679,9 @@ protected:
     // of the left and the right border in the x component of the returned size
     // and the sum of the heights of the top and bottom borders in the y one
     //
-    // NB: this is currently only implemented by wxMSW and wxUniv so far and
-    //     simply asserts in the other ports
+    // NB: this is currently only implemented properly for wxMSW, wxGTK and
+    //     wxUniv and doesn't behave correctly in the presence of scrollbars in
+    //     the other ports
     virtual wxSize DoGetBorderSize() const;
 
     // move the window to the specified location and resize it: this is called
index de643e10503b412285592be61659faabd3fa0a5e..ac1fbb2f402a04d0194ab109b5ea171d1f5fd422 100644 (file)
@@ -736,17 +736,14 @@ wxSize wxWindowBase::GetEffectiveMinSize() const
 
 wxSize wxWindowBase::DoGetBorderSize() const
 {
-    // there is one case in which we can implement it for all ports easily:
-    // do it as some classes used by both wxUniv and native ports (e.g.
-    // wxGenericStaticText) do override DoGetBestClientSize() and so this
-    // method must work for them and that ensures that it does, at least in
-    // the default case)
+    // there is one case in which we can implement it for all ports easily
     if ( GetBorder() == wxBORDER_NONE )
         return wxSize(0, 0);
 
-    wxFAIL_MSG( "must be overridden if called" );
-
-    return wxDefaultSize;
+    // otherwise use the difference between the real size and the client size
+    // as a fallback: notice that this is incorrect in general as client size
+    // also doesn't take the scrollbars into account
+    return GetSize() - GetClientSize();
 }
 
 wxSize wxWindowBase::GetBestSize() const
index e44324e21054be33d3432bc0bfed81034590949d..209f7be8199b849cc28eaabd1f9389e324fbd67e 100644 (file)
@@ -2643,10 +2643,9 @@ void wxWindowGTK::DoGetClientSize( int *width, int *height ) const
             }
         }
 
-        int border_x, border_y;
-        WX_PIZZA(m_wxwindow)->get_border_widths(border_x, border_y);
-        w -= 2 * border_x;
-        h -= 2 * border_y;
+        const wxSize sizeBorders = DoGetBorderSize();
+        w -= sizeBorders.x;
+        h -= sizeBorders.y;
 
         if (w < 0)
             w = 0;
@@ -2658,6 +2657,17 @@ void wxWindowGTK::DoGetClientSize( int *width, int *height ) const
     if (height) *height = h;
 }
 
+wxSize wxWindowGTK::DoGetBorderSize() const
+{
+    if ( !m_wxwindow )
+        return wxWindowBase::DoGetBorderSize();
+
+    int x, y;
+    WX_PIZZA(m_wxwindow)->get_border_widths(x, y);
+
+    return 2*wxSize(x, y);
+}
+
 void wxWindowGTK::DoGetPosition( int *x, int *y ) const
 {
     wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );