WX_DEFINE_EXPORTED_LIST( wxSizerItemList );
/*
- TODO PROPERTIES
- sizeritem
- object
- object_ref
- minsize
- option
- flag
- border
+ TODO PROPERTIES
+ sizeritem
+ object
+ object_ref
+ minsize
+ option
+ flag
+ border
spacer
- option
- flag
- borfder
- boxsizer
- orient
+ option
+ flag
+ borfder
+ boxsizer
+ orient
staticboxsizer
- orient
- label
- gridsizer
- rows
- cols
- vgap
- hgap
- flexgridsizer
- rows
- cols
- vgap
- hgap
- growablerows
- growablecols
+ orient
+ label
+ gridsizer
+ rows
+ cols
+ vgap
+ hgap
+ flexgridsizer
+ rows
+ cols
+ vgap
+ hgap
+ growablerows
+ growablecols
minsize
*/
+
//---------------------------------------------------------------------------
// wxSizerItem
//---------------------------------------------------------------------------
+void wxSizerItem::Init()
+{
+ m_window = NULL;
+ m_sizer = NULL;
+ m_show = true;
+ m_userData = NULL;
+}
+
+void wxSizerItem::Init(const wxSizerFlags& flags)
+{
+ Init();
+
+ m_proportion = flags.GetProportion();
+ m_flag = flags.GetFlags();
+ m_border = flags.GetBorderInPixels();
+}
+
wxSizerItem::wxSizerItem( int width, int height, int proportion, int flag, int border, wxObject* userData )
: m_window( NULL )
, m_sizer( NULL )
, m_show( true )
, m_userData( userData )
{
- // aspect ratio calculated from initial size
- SetRatio( m_minSize );
-
if (flag & wxFIXED_MINSIZE)
window->SetMinSize(window->GetSize());
m_minSize = window->GetSize();
-
+
+ // aspect ratio calculated from initial size
+ SetRatio( m_minSize );
+
// m_size is calculated later
}
}
wxSizerItem::wxSizerItem()
- : m_window( NULL )
- , m_sizer( NULL )
- , m_proportion( 0 )
- , m_border( 0 )
- , m_flag( 0 )
- , m_show( true )
- , m_ratio( 0.0 )
- , m_userData( NULL )
{
+ Init();
+
+ m_proportion = 0;
+ m_border = 0;
+ m_flag = 0;
}
wxSizerItem::~wxSizerItem()
wxSize wxSizerItem::CalcMin()
{
- wxSize ret;
-
if (IsSizer())
{
m_minSize = m_sizer->GetMinSize();
// if we have to preserve aspect ratio _AND_ this is
// the first-time calculation, consider ret to be initial size
if ((m_flag & wxSHAPED) && !m_ratio)
- SetRatio(ret);
+ SetRatio(m_minSize);
}
else if ( IsWindow() )
{
ret.y += m_border;
if (m_flag & wxSOUTH)
ret.y += m_border;
-
+
return ret;
}
WX_CLEAR_LIST(wxSizerItemList, m_children);
}
-void wxSizer::Add( wxWindow *window, int proportion, int flag, int border, wxObject* userData )
-{
- m_children.Append( new wxSizerItem( window, proportion, flag, border, userData ) );
- window->SetContainingSizer( this );
-}
-
-void wxSizer::Add( wxSizer *sizer, int proportion, int flag, int border, wxObject* userData )
-{
- m_children.Append( new wxSizerItem( sizer, proportion, flag, border, userData ) );
-}
-
-void wxSizer::Add( int width, int height, int proportion, int flag, int border, wxObject* userData )
-{
- m_children.Append( new wxSizerItem( width, height, proportion, flag, border, userData ) );
-}
-
-void wxSizer::Add( wxSizerItem *item )
-{
- m_children.Append( item );
-
- if( item->GetWindow() )
- item->GetWindow()->SetContainingSizer( this );
-}
-
-void wxSizer::Prepend( wxWindow *window, int proportion, int flag, int border, wxObject* userData )
-{
- m_children.Insert( new wxSizerItem( window, proportion, flag, border, userData ) );
- window->SetContainingSizer( this );
-}
-
-void wxSizer::Prepend( wxSizer *sizer, int proportion, int flag, int border, wxObject* userData )
-{
- m_children.Insert( new wxSizerItem( sizer, proportion, flag, border, userData ) );
-}
-
-void wxSizer::Prepend( int width, int height, int proportion, int flag, int border, wxObject* userData )
-{
- m_children.Insert( new wxSizerItem( width, height, proportion, flag, border, userData ) );
-}
-
-void wxSizer::Prepend( wxSizerItem *item )
-{
- m_children.Insert( item );
-
- if( item->GetWindow() )
- item->GetWindow()->SetContainingSizer( this );
-}
-
-void wxSizer::Insert( size_t index,
- wxWindow *window,
- int proportion,
- int flag,
- int border,
- wxObject* userData )
-{
- m_children.Insert( index,
- new wxSizerItem( window, proportion, flag, border, userData ) );
- window->SetContainingSizer( this );
-}
-
-void wxSizer::Insert( size_t index,
- wxSizer *sizer,
- int proportion,
- int flag,
- int border,
- wxObject* userData )
-{
- m_children.Insert( index,
- new wxSizerItem( sizer, proportion, flag, border, userData ) );
-}
-
-void wxSizer::Insert( size_t index,
- int width,
- int height,
- int proportion,
- int flag,
- int border,
- wxObject* userData )
-{
- m_children.Insert( index,
- new wxSizerItem( width, height, proportion, flag, border, userData ) );
-}
-
void wxSizer::Insert( size_t index, wxSizerItem *item )
{
m_children.Insert( index, item );
// Limit the size if sizeMax != wxDefaultSize
- if ( size.x > sizeMax.x && sizeMax.x != -1 )
+ if ( size.x > sizeMax.x && sizeMax.x != wxDefaultCoord )
size.x = sizeMax.x;
- if ( size.y > sizeMax.y && sizeMax.y != -1 )
+ if ( size.y > sizeMax.y && sizeMax.y != wxDefaultCoord )
size.y = sizeMax.y;
return size;
// Limit the size if sizeMax != wxDefaultSize
- if ( size.x > sizeMax.x && sizeMax.x != -1 )
+ if ( size.x > sizeMax.x && sizeMax.x != wxDefaultCoord )
size.x = sizeMax.x;
- if ( size.y > sizeMax.y && sizeMax.y != -1 )
+ if ( size.y > sizeMax.y && sizeMax.y != wxDefaultCoord )
size.y = sizeMax.y;
return size;
return true;
}
-void wxSizer::Show( wxWindow *window, bool show )
+bool wxSizer::Show( wxWindow *window, bool show, bool recursive )
{
wxASSERT_MSG( window, _T("Show for NULL window") );
if (item->GetWindow() == window)
{
item->Show( show );
- break;
+
+ return true;
+ }
+ else if (recursive && item->IsSizer())
+ {
+ if (item->GetSizer()->Show(window, show, recursive))
+ return true;
}
+
node = node->GetNext();
}
+
+ return false;
}
-void wxSizer::Show( wxSizer *sizer, bool show )
+bool wxSizer::Show( wxSizer *sizer, bool show, bool recursive )
{
wxASSERT_MSG( sizer, _T("Show for NULL sizer") );
if (item->GetSizer() == sizer)
{
item->Show( show );
- break;
+
+ return true;
}
+ else if (recursive && item->IsSizer())
+ {
+ if (item->GetSizer()->Show(sizer, show, recursive))
+ return true;
+ }
+
node = node->GetNext();
}
+
+ return false;
}
-void wxSizer::Show( size_t index, bool show )
+bool wxSizer::Show( size_t index, bool show)
{
- wxCHECK_RET( index < m_children.GetCount(),
+ wxCHECK_MSG( index < m_children.GetCount(),
+ false,
_T("Show index is out of range") );
m_children.Item( index )->GetData()->Show( show );
+
+ return true;
}
void wxSizer::ShowItems( bool show )
void wxGridSizer::SetItemBounds( wxSizerItem *item, int x, int y, int w, int h )
{
wxPoint pt( x,y );
- wxSize sz( item->GetMinSizeWithBorder() );
+ wxSize sz( item->GetMinSizeWithBorder() );
int flag = item->GetFlag();
if ((flag & wxEXPAND) || (flag & wxSHAPED))
}
AdjustForFlexDirection();
-
+
// Sum total minimum size, including gaps between rows/columns.
// -1 is used as a magic number meaning empty column.
int width = 0;
array[n] = largest;
}
}
-}
+}
void wxFlexGridSizer::AdjustForGrowables(const wxSize& sz, const wxSize& minsz,
// requested growable rows/columns are still valid.
if (m_growableRows[idx] >= nrows)
continue;
-
+
// If all items in a row/column are hidden, that row/column will
// have a dimension of -1. This causes the row/column to be
// hidden completely.
// requested growable rows/columns are still valid.
if (m_growableCols[idx] >= ncols)
continue;
-
+
// If all items in a row/column are hidden, that row/column will
// have a dimension of -1. This causes the column to be hidden
// completely.
if (item->IsShown())
item->CalcMin(); // result is stored in the item
-
+
if (item->IsShown() && item->GetProportion() != 0)
m_stretchable += item->GetProportion();
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
minSize = ( size.x*m_stretchable + stretch - 1)/stretch;
else
minSize = ( size.y*m_stretchable + stretch - 1)/stretch;
-
+
if (minSize > maxMinSize)
maxMinSize = minSize;
}
// pixels (otherwise overlapping occurs at the top). The "other"
// border has to be 11.
extraTop = 11;
- other = 11;
+ other = 11;
}
}