m_proportion = 0;
m_border = 0;
m_flag = 0;
+ m_id = wxID_NONE;
}
// window item
m_proportion(proportion),
m_border(border),
m_flag(flag),
+ m_id(wxID_NONE),
m_userData(userData)
{
DoSetWindow(window);
m_proportion(proportion),
m_border(border),
m_flag(flag),
+ m_id(wxID_NONE),
m_ratio(0.0),
m_userData(userData)
{
m_proportion(proportion),
m_border(border),
m_flag(flag),
+ m_id(wxID_NONE),
m_userData(userData)
{
DoSetSpacer(wxSize(width, height));
if ( item->GetWindow() )
item->GetWindow()->SetContainingSizer( this );
+ if ( item->GetSizer() )
+ item->GetSizer()->SetContainingWindow( m_containingWindow );
+
return item;
}
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 );
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());
AdjustForGrowables(sz);
wxSizerItemList::const_iterator i = m_children.begin();
+ const wxSizerItemList::const_iterator end = m_children.end();
+
int y = 0;
for ( int r = 0; r < nrows; r++ )
{
{
// this row is entirely hidden, skip it
for ( int c = 0; c < ncols; c++ )
+ {
+ if ( i == end )
+ return;
+
++i;
+ }
continue;
}
h = hrow;
int x = 0;
- for ( int c = 0; c < ncols; c++, ++i )
+ for ( int c = 0; c < ncols && i != end; c++, ++i )
{
const int wcol = m_colWidths[c];
if ( wcol == -1 )
continue;
- // check if there are any remaining children: it may happen that
- // the last row is incomplete
- if ( i == m_children.end() )
- {
- wxASSERT_MSG( r == nrows - 1, _T("too few items") );
-
- return;
- }
-
int w = sz.x - x; // max possible value, ensure we don't overflow
if ( wcol < w )
w = wcol;
x += wcol + m_hgap;
}
+ if ( i == end )
+ return;
+
y += hrow + m_vgap;
}
}
// the amount of free space which we should redistribute among the
// stretchable items (i.e. those with non zero proportion)
- const int delta = SizeInMajorDir(m_size) - SizeInMajorDir(m_minSize);
+ int delta = SizeInMajorDir(m_size) - SizeInMajorDir(m_minSize);
// the position at which we put the next child
wxPoint pt(m_position);
const wxCoord totalMinorSize = SizeInMinorDir(m_size);
+ int totalProportion = m_totalProportion;
for ( wxSizerItemList::const_iterator i = m_children.begin();
i != m_children.end();
++i )
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
wxCoord majorSize = SizeInMajorDir(sizeThis);
- if ( item->GetProportion() )
+ const int propItem = item->GetProportion();
+ if ( propItem )
{
- // as at least one visible item has non-zero proportion the total
- // proportion must be non zero
- majorSize += (delta * item->GetProportion()) / m_totalProportion;
+ const int deltaItem = (delta * propItem) / totalProportion;
+
+ majorSize += deltaItem;
+
+ delta -= deltaItem;
+ totalProportion -= propItem;
}
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) )
Add((wxWindow*)m_buttonNegative, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 3);
}
- // according to HIG, in explicit apply windows the order is:
+ // according to HIG, in explicit apply windows the order is:
// [ Help Apply Cancel OK ]
if (m_buttonApply)
Add((wxWindow*)m_buttonApply, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 3);