diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index ad0abd60ed..a5a68e5c07 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -2087,8 +2087,12 @@ void wxBoxSizer::RecalcSizes() wxCoord minorSize = GetSizeInMinorDir(sizeThis); const int flag = item->GetFlag(); - if ( flag & (wxEXPAND | wxSHAPED) ) + if ( (flag & (wxEXPAND | wxSHAPED)) || (minorSize > totalMinorSize) ) { + // occupy all the available space if wxEXPAND was given and also if + // the item is too big to fit -- in this case we truncate it below + // its minimal size which is bad but better than not showing parts + // of the window at all minorSize = totalMinorSize; } else if ( flag & (IsVertical() ? wxALIGN_RIGHT : wxALIGN_BOTTOM) ) @@ -2097,7 +2101,8 @@ void wxBoxSizer::RecalcSizes() } // NB: wxCENTRE is used here only for backwards compatibility, // wxALIGN_CENTRE should be used in new code - else if ( flag & (wxCENTER | (IsVertical() ? wxALIGN_CENTRE_HORIZONTAL : wxALIGN_CENTRE_VERTICAL))) + else if ( flag & (wxCENTER | (IsVertical() ? wxALIGN_CENTRE_HORIZONTAL + : wxALIGN_CENTRE_VERTICAL)) ) { PosInMinorDir(posChild) += (totalMinorSize - minorSize) / 2; } diff --git a/tests/sizers/boxsizer.cpp b/tests/sizers/boxsizer.cpp index e7916a1841..c86e319549 100644 --- a/tests/sizers/boxsizer.cpp +++ b/tests/sizers/boxsizer.cpp @@ -104,6 +104,12 @@ void BoxSizerTestCase::Size1() m_win->Layout(); CPPUNIT_ASSERT_EQUAL( sizeTotal, child->GetSize() ); + m_sizer->Clear(); + m_sizer->Add(child, wxSizerFlags()); + m_sizer->SetItemMinSize(child, sizeTotal*2); + m_win->Layout(); + CPPUNIT_ASSERT_EQUAL( sizeTotal, child->GetSize() ); + m_sizer->Clear(); m_sizer->Add(child, wxSizerFlags().Expand()); m_sizer->SetItemMinSize(child, sizeTotal*2);