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
This commit is contained in:
Vadim Zeitlin 2010-07-11 10:43:49 +00:00
parent d67fc8b735
commit b35549525f
4 changed files with 23 additions and 14 deletions

View File

@ -314,6 +314,7 @@ protected:
int width, int height, int width, int height,
int sizeFlags = wxSIZE_AUTO); int sizeFlags = wxSIZE_AUTO);
virtual void DoSetClientSize(int width, int height); virtual void DoSetClientSize(int width, int height);
virtual wxSize DoGetBorderSize() const;
virtual void DoMoveWindow(int x, int y, int width, int height); virtual void DoMoveWindow(int x, int y, int width, int height);
virtual void DoEnable(bool enable); virtual void DoEnable(bool enable);

View File

@ -1679,8 +1679,9 @@ protected:
// of the left and the right border in the x component of the returned size // 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 // 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 // NB: this is currently only implemented properly for wxMSW, wxGTK and
// simply asserts in the other ports // wxUniv and doesn't behave correctly in the presence of scrollbars in
// the other ports
virtual wxSize DoGetBorderSize() const; virtual wxSize DoGetBorderSize() const;
// move the window to the specified location and resize it: this is called // move the window to the specified location and resize it: this is called

View File

@ -736,17 +736,14 @@ wxSize wxWindowBase::GetEffectiveMinSize() const
wxSize wxWindowBase::DoGetBorderSize() const wxSize wxWindowBase::DoGetBorderSize() const
{ {
// there is one case in which we can implement it for all ports easily: // 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)
if ( GetBorder() == wxBORDER_NONE ) if ( GetBorder() == wxBORDER_NONE )
return wxSize(0, 0); return wxSize(0, 0);
wxFAIL_MSG( "must be overridden if called" ); // 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
return wxDefaultSize; // also doesn't take the scrollbars into account
return GetSize() - GetClientSize();
} }
wxSize wxWindowBase::GetBestSize() const wxSize wxWindowBase::GetBestSize() const

View File

@ -2643,10 +2643,9 @@ void wxWindowGTK::DoGetClientSize( int *width, int *height ) const
} }
} }
int border_x, border_y; const wxSize sizeBorders = DoGetBorderSize();
WX_PIZZA(m_wxwindow)->get_border_widths(border_x, border_y); w -= sizeBorders.x;
w -= 2 * border_x; h -= sizeBorders.y;
h -= 2 * border_y;
if (w < 0) if (w < 0)
w = 0; w = 0;
@ -2658,6 +2657,17 @@ void wxWindowGTK::DoGetClientSize( int *width, int *height ) const
if (height) *height = h; 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 void wxWindowGTK::DoGetPosition( int *x, int *y ) const
{ {
wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );