From b35549525f2a8dd584fdda158829e8406da0541e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 11 Jul 2010 10:43:49 +0000 Subject: [PATCH] Implement wxWindow::DoGetBorderSize() for all ports. 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 | 1 + include/wx/window.h | 5 +++-- src/common/wincmn.cpp | 13 +++++-------- src/gtk/window.cpp | 18 ++++++++++++++---- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 20aa4c1..4fc6ea6 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -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); diff --git a/include/wx/window.h b/include/wx/window.h index 52b6daa..6c7930a 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -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 diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index de643e1..ac1fbb2 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -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 diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index e44324e..209f7be 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -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") ); -- 2.7.4