eliminate code duplication in wxSizer::Fit()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51498 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2008-02-01 23:14:45 +00:00
parent 02dc0099cb
commit 7e7bc14b51

View File

@@ -838,6 +838,7 @@ wxSize wxSizer::Fit( wxWindow *window )
{ {
// take the min size by default and limit it by max size // take the min size by default and limit it by max size
wxSize size = GetMinClientSize(window); wxSize size = GetMinClientSize(window);
wxSize sizeMax;
wxTopLevelWindow *tlw = wxDynamicCast(window, wxTopLevelWindow); wxTopLevelWindow *tlw = wxDynamicCast(window, wxTopLevelWindow);
if ( tlw ) if ( tlw )
@@ -857,28 +858,18 @@ wxSize wxSizer::Fit( wxWindow *window )
disp = 0; disp = 0;
} }
wxSize sizeMax = wxDisplay(disp).GetClientArea().GetSize(); sizeMax = wxDisplay(disp).GetClientArea().GetSize();
// space for decorations and toolbars etc. // space for decorations and toolbars etc.
wxSize tlw_client_size = tlw->GetClientSize(); wxSize tlw_client_size = tlw->GetClientSize();
wxSize tlw_size = tlw->GetSize(); wxSize tlw_size = tlw->GetSize();
sizeMax.x -= tlw_size.x - tlw_client_size.x; sizeMax.x -= tlw_size.x - tlw_client_size.x;
sizeMax.y -= tlw_size.y - tlw_client_size.y; sizeMax.y -= tlw_size.y - tlw_client_size.y;
if ( sizeMax.x != wxDefaultCoord && size.x > sizeMax.x )
size.x = sizeMax.x;
if ( sizeMax.y != wxDefaultCoord && size.y > sizeMax.y )
size.y = sizeMax.y;
// set client size
tlw->SetClientSize( size );
// return entire size
return tlw->GetSize();
} }
else else
{ {
wxSize sizeMax = GetMaxClientSize(window); sizeMax = GetMaxClientSize(window);
}
if ( sizeMax.x != wxDefaultCoord && size.x > sizeMax.x ) if ( sizeMax.x != wxDefaultCoord && size.x > sizeMax.x )
size.x = sizeMax.x; size.x = sizeMax.x;
@@ -891,7 +882,6 @@ wxSize wxSizer::Fit( wxWindow *window )
// return entire size // return entire size
return window->GetSize(); return window->GetSize();
} }
}
void wxSizer::FitInside( wxWindow *window ) void wxSizer::FitInside( wxWindow *window )
{ {