- // Total minimum size (width or height) of sizer
- int maxMinSize = 0;
-
- node = m_children.GetFirst();
- while (node)
- {
- wxSizerItem *item = node->GetData();
-
- if (item->IsShown() && item->GetProportion() != 0)
- {
- int stretch = item->GetProportion();
- wxSize size( item->GetMinSizeWithBorder() );
- int minSize;
-
- // Integer division rounded up is (a + b - 1) / b
- // Round up needed in order to guarantee that all
- // all items will have size not less then their min size
- if (m_orient == wxHORIZONTAL)
- minSize = ( size.x*m_stretchable + stretch - 1)/stretch;
- else
- minSize = ( size.y*m_stretchable + stretch - 1)/stretch;
-
- if (minSize > maxMinSize)
- maxMinSize = minSize;
- }
- node = node->GetNext();
- }
-
- // Calculate overall minimum size
- node = m_children.GetFirst();
- while (node)
- {
- wxSizerItem *item = node->GetData();
-
- if (item->IsShown())
- {
- wxSize size( item->GetMinSizeWithBorder() );
- if (item->GetProportion() != 0)
- {
- if (m_orient == wxHORIZONTAL)
- size.x = (maxMinSize*item->GetProportion())/m_stretchable;
- else
- size.y = (maxMinSize*item->GetProportion())/m_stretchable;
- }
- else
- {
- if (m_orient == wxVERTICAL)
- {
- m_fixedHeight += size.y;
- m_fixedWidth = wxMax( m_fixedWidth, size.x );
- }
- else
- {
- m_fixedWidth += size.x;
- m_fixedHeight = wxMax( m_fixedHeight, size.y );
- }
- }
-
- if (m_orient == wxHORIZONTAL)
- {
- m_minWidth += size.x;
- m_minHeight = wxMax( m_minHeight, size.y );
- }
- else
- {
- m_minHeight += size.y;
- m_minWidth = wxMax( m_minWidth, size.x );
- }
- }
- node = node->GetNext();
- }
-
- return wxSize( m_minWidth, m_minHeight );