added wxWindow::GetWindowBorderSize()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43639 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-11-25 14:52:52 +00:00
parent 9653ac08a5
commit 333d70525c
3 changed files with 83 additions and 0 deletions

View File

@@ -1373,6 +1373,14 @@ that size.
\helpref{GetClientSize}{wxwindowgetclientsize} \helpref{GetClientSize}{wxwindowgetclientsize}
\membersection{wxWindow::GetWindowBorderSize}\label{wxwindowgetwindowbordersize}
\constfunc{wxSize}{GetWindowBorderSize}{\void}
Returns the size of the left/right and top/bottom borders of this window in x
and y components of the result respectively.
\membersection{wxWindow::GetWindowStyleFlag}\label{wxwindowgetwindowstyleflag} \membersection{wxWindow::GetWindowStyleFlag}\label{wxwindowgetwindowstyleflag}
\constfunc{long}{GetWindowStyleFlag}{\void} \constfunc{long}{GetWindowStyleFlag}{\void}

View File

@@ -473,6 +473,11 @@ public:
return wxSize( wxMax( client.x, best.x ), wxMax( client.y, best.y ) ); return wxSize( wxMax( client.x, best.x ), wxMax( client.y, best.y ) );
} }
// return the size of the left/right and top/bottom borders in x and y
// components of the result respectively
virtual wxSize GetWindowBorderSize() const;
// window state // window state
// ------------ // ------------

View File

@@ -587,6 +587,76 @@ wxSize wxWindowBase::DoGetBestSize() const
return best; return best;
} }
// helper of GetWindowBorderSize(): as many ports don't implement support for
// wxSYS_BORDER/EDGE_X/Y metrics in their wxSystemSettings, use hard coded
// fallbacks in this case
static wxGetMetricOrDefault(wxSystemMetric what)
{
int rc = wxSystemSettings::GetMetric(what);
if ( rc == -1 )
{
switch ( what )
{
case wxSYS_BORDER_X:
case wxSYS_BORDER_Y:
// 2D border is by default 1 pixel wide
rc = 1;
break;
case wxSYS_EDGE_X:
case wxSYS_EDGE_Y:
// 3D borders are by default 2 pixels
rc = 2;
break;
default:
wxFAIL_MSG( _T("unexpected wxGetMetricOrDefault() argument") );
rc = 0;
}
}
return rc;
}
wxSize wxWindowBase::GetWindowBorderSize() const
{
wxSize size;
switch ( GetBorder() )
{
case wxBORDER_NONE:
// nothing to do, size is already (0, 0)
break;
case wxBORDER_SIMPLE:
case wxBORDER_STATIC:
size.x = wxGetMetricOrDefault(wxSYS_BORDER_X);
size.y = wxGetMetricOrDefault(wxSYS_BORDER_Y);
break;
case wxBORDER_SUNKEN:
case wxBORDER_RAISED:
size.x = wxMax(wxGetMetricOrDefault(wxSYS_EDGE_X),
wxGetMetricOrDefault(wxSYS_BORDER_X));
size.y = wxMax(wxGetMetricOrDefault(wxSYS_EDGE_Y),
wxGetMetricOrDefault(wxSYS_BORDER_Y));
break;
case wxBORDER_DOUBLE:
size.x = wxGetMetricOrDefault(wxSYS_EDGE_X) +
wxGetMetricOrDefault(wxSYS_BORDER_X);
size.y = wxGetMetricOrDefault(wxSYS_EDGE_Y) +
wxGetMetricOrDefault(wxSYS_BORDER_Y);
break;
default:
wxFAIL_MSG(_T("Unknown border style."));
break;
}
// we have borders on both sides
return size*2;
}
wxSize wxWindowBase::GetEffectiveMinSize() const wxSize wxWindowBase::GetEffectiveMinSize() const
{ {