+
+ // the position at which we put the next child
+ wxPoint pt(m_position);
+
+
+ // Final pass: finally do position the items correctly using their sizes as
+ // determined above.
+ for ( i = m_children.begin(), n = 0; i != m_children.end(); ++i, ++n )
+ {
+ wxSizerItem * const item = *i;
+
+ if ( !item->IsShown() )
+ continue;
+
+ const int majorSize = majorSizes[n];
+
+ const wxSize sizeThis(item->GetMinSizeWithBorder());
+
+ // apply the alignment in the minor direction
+ wxPoint posChild(pt);
+
+ wxCoord minorSize = GetSizeInMinorDir(sizeThis);
+ const int flag = item->GetFlag();
+ 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) )
+ {
+ PosInMinorDir(posChild) += totalMinorSize - minorSize;
+ }
+ // 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)) )
+ {
+ PosInMinorDir(posChild) += (totalMinorSize - minorSize) / 2;
+ }
+
+
+ // apply RTL adjustment for horizontal sizers:
+ if ( !IsVertical() && m_containingWindow )
+ {
+ posChild.x = m_containingWindow->AdjustForLayoutDirection
+ (
+ posChild.x,
+ majorSize,
+ m_size.x
+ );
+ }
+
+ // finally set size of this child and advance to the next one
+ item->SetDimension(posChild, SizeFromMajorMinor(majorSize, minorSize));
+
+ PosInMajorDir(pt) += majorSize;
+ }
+}
+
+wxSize wxBoxSizer::CalcMin()
+{
+ m_totalProportion = 0;
+ m_minSize = wxSize(0, 0);
+
+ // calculate the minimal sizes for all items and count sum of proportions
+ for ( wxSizerItemList::const_iterator i = m_children.begin();
+ i != m_children.end();
+ ++i )
+ {
+ wxSizerItem * const item = *i;
+
+ if ( !item->IsShown() )
+ continue;
+
+ const wxSize sizeMinThis = item->CalcMin();
+ SizeInMajorDir(m_minSize) += GetSizeInMajorDir(sizeMinThis);
+ if ( GetSizeInMinorDir(sizeMinThis) > GetSizeInMinorDir(m_minSize) )
+ SizeInMinorDir(m_minSize) = GetSizeInMinorDir(sizeMinThis);
+
+ m_totalProportion += item->GetProportion();
+ }
+
+ return m_minSize;