From 863dc042daf50d6a4eff0320208617f226ef92f0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 22 Sep 2012 16:16:52 +0000 Subject: [PATCH] Allow wxWrapSizer to request more size than it used previously. The code in wxWrapSizer::CalcMin() ensured that the sizer never requested more space than what it had been already given which, while clearly done intentionally, seems to be wrong because it can never end up with enough space for all its rows/columns unless it is set to up to expand in the containing sizer. In other words, the old code could return the size which was not enough to show the sizer contents fully which is against CalcMin() contract. Change this by simply removing the check for the new minimal size being less than the old one. This allows the wrap sizer demo in the layout sample to work correctly whereas before the sizer contents was completely invisible initially. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72537 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/wrapsizer.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/common/wrapsizer.cpp b/src/common/wrapsizer.cpp index ff7b0310ec..9f2261e67c 100644 --- a/src/common/wrapsizer.cpp +++ b/src/common/wrapsizer.cpp @@ -177,15 +177,6 @@ wxSize wxWrapSizer::CalcMin() // layout, trying to maintain the possibility to re-arrange lines by // sizing - wxSize szBoundary; // Keep track of boundary so we don't overflow - if ( m_availSize > 0 ) - { - if ( m_dirInform == m_orient ) - szBoundary = SizeFromMajorMinor(m_availSize, m_availableOtherDir); - else - szBoundary = SizeFromMajorMinor(m_availableOtherDir, m_availSize); - } - if ( !m_lastUsed ) { // Case 1 above: InformFirstDirection() has just been called @@ -195,21 +186,22 @@ wxSize wxWrapSizer::CalcMin() // a wrap sizer, depending on whether the first reported size component // is the opposite as our own orientation (the simpler case) or the same // one (more complicated). - wxSize szMinPrev = m_minSize; if ( m_dirInform == m_orient ) CalcMinFromMajor(m_availSize); else CalcMinFromMinor(m_availSize); - - // If overflowing given boundary, go back to previous min size - if ( m_minSize.x > szBoundary.x || m_minSize.y>szBoundary.y ) - m_minSize = szMinPrev; } else // Case 2 above: not immediately after InformFirstDirection() { if ( m_availSize > 0 ) { - CalcMinFittingSize(szBoundary); + wxSize szAvail; // Keep track of boundary so we don't overflow + if ( m_dirInform == m_orient ) + szAvail = SizeFromMajorMinor(m_availSize, m_availableOtherDir); + else + szAvail = SizeFromMajorMinor(m_availableOtherDir, m_availSize); + + CalcMinFittingSize(szAvail); } else // Initial calculation, before we have size available to us { -- 2.45.2