Rename wxBoxSizer::m_minSize to avoid clash with the base class
wxSizer already has m_minSize field, use m_calculatedMinSize for the field of the derived wxBoxSizer class to avoid confusion, just as wxFlexGridSizer already did. Also add a new unit test checking that GetMinSize() still works after this change.
This commit is contained in:
@@ -1016,7 +1016,7 @@ protected:
|
||||
|
||||
// the minimal size needed for this sizer as calculated by the last call to
|
||||
// our CalcMin()
|
||||
wxSize m_minSize;
|
||||
wxSize m_calculatedMinSize;
|
||||
|
||||
private:
|
||||
wxDECLARE_CLASS(wxBoxSizer);
|
||||
|
@@ -2179,7 +2179,7 @@ void wxBoxSizer::RecalcSizes()
|
||||
|
||||
// the amount of free space which we should redistribute among the
|
||||
// stretchable items (i.e. those with non zero proportion)
|
||||
int delta = totalMajorSize - GetSizeInMajorDir(m_minSize);
|
||||
int delta = totalMajorSize - GetSizeInMajorDir(m_calculatedMinSize);
|
||||
|
||||
// declare loop variables used below:
|
||||
wxSizerItemList::const_iterator i; // iterator in m_children list
|
||||
@@ -2498,7 +2498,7 @@ void wxBoxSizer::RecalcSizes()
|
||||
wxSize wxBoxSizer::CalcMin()
|
||||
{
|
||||
m_totalProportion = 0;
|
||||
m_minSize = wxSize(0, 0);
|
||||
m_calculatedMinSize = wxSize(0, 0);
|
||||
|
||||
// The minimal size for the sizer should be big enough to allocate its
|
||||
// element at least its minimal size but also, and this is the non trivial
|
||||
@@ -2529,19 +2529,19 @@ wxSize wxBoxSizer::CalcMin()
|
||||
else // fixed size item
|
||||
{
|
||||
// Just account for its size directly
|
||||
SizeInMajorDir(m_minSize) += GetSizeInMajorDir(sizeMinThis);
|
||||
SizeInMajorDir(m_calculatedMinSize) += GetSizeInMajorDir(sizeMinThis);
|
||||
}
|
||||
|
||||
// In the transversal direction we just need to find the maximum.
|
||||
if ( GetSizeInMinorDir(sizeMinThis) > GetSizeInMinorDir(m_minSize) )
|
||||
SizeInMinorDir(m_minSize) = GetSizeInMinorDir(sizeMinThis);
|
||||
if ( GetSizeInMinorDir(sizeMinThis) > GetSizeInMinorDir(m_calculatedMinSize) )
|
||||
SizeInMinorDir(m_calculatedMinSize) = GetSizeInMinorDir(sizeMinThis);
|
||||
}
|
||||
|
||||
// Using the max ratio ensures that the min size is big enough for all
|
||||
// items to have their min size and satisfy the proportions among them.
|
||||
SizeInMajorDir(m_minSize) += (int)(maxMinSizeToProp*m_totalProportion);
|
||||
SizeInMajorDir(m_calculatedMinSize) += (int)(maxMinSizeToProp*m_totalProportion);
|
||||
|
||||
return m_minSize;
|
||||
return m_calculatedMinSize;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@@ -141,8 +141,8 @@ bool wxWrapSizer::InformFirstDirection(int direction,
|
||||
// Store the values for later use
|
||||
m_availSize = size;
|
||||
m_availableOtherDir = availableOtherDir +
|
||||
(direction == wxHORIZONTAL ? m_minSize.y
|
||||
: m_minSize.x);
|
||||
(direction == wxHORIZONTAL ? m_calculatedMinSize.y
|
||||
: m_calculatedMinSize.x);
|
||||
m_dirInform = direction;
|
||||
m_lastUsed = false;
|
||||
return true;
|
||||
@@ -208,7 +208,7 @@ wxSize wxWrapSizer::CalcMin()
|
||||
}
|
||||
}
|
||||
|
||||
return m_minSize;
|
||||
return m_calculatedMinSize;
|
||||
}
|
||||
|
||||
void wxWrapSizer::CalcMinFittingSize(const wxSize& szBoundary)
|
||||
@@ -220,7 +220,7 @@ void wxWrapSizer::CalcMinFittingSize(const wxSize& szBoundary)
|
||||
if ( m_minSizeMinor < SizeInMinorDir(m_size) &&
|
||||
m_maxSizeMajor < SizeInMajorDir(m_size) )
|
||||
{
|
||||
m_minSize = sizeMin;
|
||||
m_calculatedMinSize = sizeMin;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -231,9 +231,9 @@ void wxWrapSizer::CalcMinFittingSize(const wxSize& szBoundary)
|
||||
// We try to present a lower min value by removing an item in
|
||||
// the major direction (and preserving current minor min size).
|
||||
CalcMinFromMajor(m_maxSizeMajor - m_minItemMajor);
|
||||
if ( m_minSize.x <= szBoundary.x && m_minSize.y <= szBoundary.y )
|
||||
if ( m_calculatedMinSize.x <= szBoundary.x && m_calculatedMinSize.y <= szBoundary.y )
|
||||
{
|
||||
SizeInMinorDir(m_minSize) = SizeInMinorDir(sizeMin);
|
||||
SizeInMinorDir(m_calculatedMinSize) = SizeInMinorDir(sizeMin);
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
@@ -241,7 +241,7 @@ void wxWrapSizer::CalcMinFittingSize(const wxSize& szBoundary)
|
||||
if ( !done )
|
||||
{
|
||||
// If failed finding little smaller area, go back to what we had
|
||||
m_minSize = sizeMin;
|
||||
m_calculatedMinSize = sizeMin;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -269,7 +269,7 @@ void wxWrapSizer::CalcMaxSingleItemSize()
|
||||
// This is, of course, not our real minimal size but if we return more
|
||||
// than this it would be impossible to shrink us to one row/column so
|
||||
// we have to pretend that this is all we need for now.
|
||||
m_minSize = SizeFromMajorMinor(maxMajor, maxMinor);
|
||||
m_calculatedMinSize = SizeFromMajorMinor(maxMajor, maxMinor);
|
||||
}
|
||||
|
||||
void wxWrapSizer::CalcMinFromMajor(int totMajor)
|
||||
@@ -325,7 +325,7 @@ void wxWrapSizer::CalcMinFromMajor(int totMajor)
|
||||
if ( rowTotalMajor > maxTotalMajor )
|
||||
maxTotalMajor = rowTotalMajor;
|
||||
|
||||
m_minSize = SizeFromMajorMinor(maxTotalMajor, minorSum);
|
||||
m_calculatedMinSize = SizeFromMajorMinor(maxTotalMajor, minorSum);
|
||||
}
|
||||
|
||||
// Helper struct for CalcMinFromMinor
|
||||
@@ -370,7 +370,7 @@ void wxWrapSizer::CalcMinFromMinor(int totMinor)
|
||||
// The trivial case
|
||||
if ( !itemCount || totMajor==0 || maxMinor==0 )
|
||||
{
|
||||
m_minSize = wxSize(0,0);
|
||||
m_calculatedMinSize = wxSize(0,0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ void wxWrapSizer::CalcMinFromMinor(int totMinor)
|
||||
if ( nrLines<=1 )
|
||||
{
|
||||
// Another simple case, everything fits on one line
|
||||
m_minSize = SizeFromMajorMinor(totMajor,maxMinor);
|
||||
m_calculatedMinSize = SizeFromMajorMinor(totMajor,maxMinor);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -469,7 +469,7 @@ void wxWrapSizer::CalcMinFromMinor(int totMinor)
|
||||
}
|
||||
|
||||
// Now have min size in the opposite direction
|
||||
m_minSize = SizeFromMajorMinor(lineSize,sumMinor);
|
||||
m_calculatedMinSize = SizeFromMajorMinor(lineSize,sumMinor);
|
||||
}
|
||||
|
||||
void wxWrapSizer::FinishRow(size_t n,
|
||||
|
@@ -41,6 +41,7 @@ private:
|
||||
CPPUNIT_TEST( Size1 );
|
||||
CPPUNIT_TEST( Size3 );
|
||||
CPPUNIT_TEST( CalcMin );
|
||||
CPPUNIT_TEST( SetMinSize );
|
||||
CPPUNIT_TEST( BestSizeRespectsMaxSize );
|
||||
CPPUNIT_TEST( RecalcSizesRespectsMaxSize1 );
|
||||
CPPUNIT_TEST( RecalcSizesRespectsMaxSize2 );
|
||||
@@ -50,6 +51,7 @@ private:
|
||||
void Size1();
|
||||
void Size3();
|
||||
void CalcMin();
|
||||
void SetMinSize();
|
||||
void BestSizeRespectsMaxSize();
|
||||
void RecalcSizesRespectsMaxSize1();
|
||||
void RecalcSizesRespectsMaxSize2();
|
||||
@@ -307,6 +309,21 @@ void BoxSizerTestCase::CalcMin()
|
||||
}
|
||||
}
|
||||
|
||||
void BoxSizerTestCase::SetMinSize()
|
||||
{
|
||||
wxWindow* const child = new wxWindow(m_win, wxID_ANY);
|
||||
child->SetInitialSize(wxSize(10, -1));
|
||||
m_sizer->Add(child);
|
||||
|
||||
// Setting minimal size explicitly must make GetMinSize() return at least
|
||||
// this size even if it needs a much smaller one.
|
||||
m_sizer->SetMinSize(100, 0);
|
||||
CPPUNIT_ASSERT_EQUAL( 100, m_sizer->GetMinSize().x );
|
||||
|
||||
m_sizer->Layout();
|
||||
CPPUNIT_ASSERT_EQUAL( 100, m_sizer->GetMinSize().x );
|
||||
}
|
||||
|
||||
void BoxSizerTestCase::BestSizeRespectsMaxSize()
|
||||
{
|
||||
m_sizer->Clear();
|
||||
|
Reference in New Issue
Block a user