X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e6cfcc0df2d7ea7a8a584744a699d72612b5443e..1abfa172c547a37751e598084fb8d541071471a3:/src/common/sizer.cpp?ds=sidebyside diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index 1df3fd4885..3b1a77280a 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -103,6 +103,7 @@ wxSizerItem::wxSizerItem() m_proportion = 0; m_border = 0; m_flag = 0; + m_id = wxID_NONE; } // window item @@ -132,6 +133,7 @@ wxSizerItem::wxSizerItem(wxWindow *window, m_proportion(proportion), m_border(border), m_flag(flag), + m_id(wxID_NONE), m_userData(userData) { DoSetWindow(window); @@ -154,6 +156,7 @@ wxSizerItem::wxSizerItem(wxSizer *sizer, m_proportion(proportion), m_border(border), m_flag(flag), + m_id(wxID_NONE), m_ratio(0.0), m_userData(userData) { @@ -183,6 +186,7 @@ wxSizerItem::wxSizerItem(int width, m_proportion(proportion), m_border(border), m_flag(flag), + m_id(wxID_NONE), m_userData(userData) { DoSetSpacer(wxSize(width, height)); @@ -1085,6 +1089,33 @@ wxSizerItem* wxSizer::GetItem( size_t index ) return m_children.Item( index )->GetData(); } +wxSizerItem* wxSizer::GetItemById( int id, bool recursive ) +{ + // This gets a sizer item by the id of the sizer item + // and NOT the id of a window if the item is a window. + + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); + while (node) + { + wxSizerItem *item = node->GetData(); + + if (item->GetId() == id) + { + return item; + } + else if (recursive && item->IsSizer()) + { + wxSizerItem *subitem = item->GetSizer()->GetItemById( id, true ); + if (subitem) + return subitem; + } + + node = node->GetNext(); + } + + return NULL; +} + bool wxSizer::Show( wxWindow *window, bool show, bool recursive ) { wxSizerItem *item = GetItem( window, recursive ); @@ -1345,8 +1376,8 @@ wxFlexGridSizer::~wxFlexGridSizer() void wxFlexGridSizer::RecalcSizes() { - int nitems, nrows, ncols; - if ( (nitems = CalcRowsCols(nrows, ncols)) == 0 ) + int nrows, ncols; + if ( !CalcRowsCols(nrows, ncols) ) return; const wxPoint pt(GetPosition()); @@ -1680,8 +1711,13 @@ void wxBoxSizer::RecalcSizes() if ( !item->IsShown() ) continue; - - const wxSize sizeThis(item->GetMinSizeWithBorder()); +#ifndef __DMC__ + // DMC doesn't distinguish between + // int SizeInMajorDir(const wxSize& sz) const + // and int& SizeInMajorDir(wxSize& sz) + const +#endif + wxSize sizeThis(item->GetMinSizeWithBorder()); // adjust the size in the major direction using the proportion @@ -1751,8 +1787,10 @@ wxSize wxBoxSizer::CalcMin() if ( !item->IsShown() ) continue; - - const wxSize sizeMinThis = item->CalcMin(); +#ifndef __DMC__ + const // see __DMC__ above +#endif + wxSize sizeMinThis = item->CalcMin(); SizeInMajorDir(m_minSize) += SizeInMajorDir(sizeMinThis); if ( SizeInMinorDir(sizeMinThis) > SizeInMinorDir(m_minSize) )