X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f944aec0cf131c1be0b8c127ba1ecdbc8410c9b2..2eafd712f13ebf2567d65c8ba5c78ef7006ff023:/src/common/sizer.cpp diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index a358717876..6030fd9f20 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -837,8 +837,8 @@ void wxSizer::DeleteWindows() wxSize wxSizer::Fit( wxWindow *window ) { // take the min size by default and limit it by max size - wxSize size = GetMinWindowSize(window); - wxSize sizeMax = GetMaxWindowSize(window); + wxSize size = GetMinClientSize(window); + wxSize sizeMax; wxTopLevelWindow *tlw = wxDynamicCast(window, wxTopLevelWindow); if ( tlw ) @@ -846,31 +846,41 @@ wxSize wxSizer::Fit( wxWindow *window ) // hack for small screen devices where TLWs are always full screen if ( tlw->IsAlwaysMaximized() ) { - size = tlw->GetSize(); + // do nothing + return tlw->GetSize(); } - else // normal situation - { - // limit the window to the size of the display it is on - int disp = wxDisplay::GetFromWindow(window); - if ( disp == wxNOT_FOUND ) - { - // or, if we don't know which one it is, of the main one - disp = 0; - } - sizeMax = wxDisplay(disp).GetClientArea().GetSize(); + // limit the window to the size of the display it is on + int disp = wxDisplay::GetFromWindow(window); + if ( disp == wxNOT_FOUND ) + { + // or, if we don't know which one it is, of the main one + disp = 0; } + + sizeMax = wxDisplay(disp).GetClientArea().GetSize(); + + // space for decorations and toolbars etc. + wxSize tlw_client_size = tlw->GetClientSize(); + wxSize tlw_size = tlw->GetSize(); + sizeMax.x -= tlw_size.x - tlw_client_size.x; + sizeMax.y -= tlw_size.y - tlw_client_size.y; + } + else + { + sizeMax = GetMaxClientSize(window); } if ( sizeMax.x != wxDefaultCoord && size.x > sizeMax.x ) - size.x = sizeMax.x; + size.x = sizeMax.x; if ( sizeMax.y != wxDefaultCoord && size.y > sizeMax.y ) - size.y = sizeMax.y; - + size.y = sizeMax.y; - window->SetSize( size ); + // set client size + window->SetClientSize( size ); - return size; + // return entire size + return window->GetSize(); } void wxSizer::FitInside( wxWindow *window )