#include "wx/sizer.h"
#include "wx/utils.h"
+#include "wx/statbox.h"
//---------------------------------------------------------------------------
// wxSizerItem
m_children.Append( new wxSizerItem( width, height, option, flag, border ) );
}
+void wxSizer::Prepend( wxWindow *window, int option, int flag, int border )
+{
+ m_children.Insert( new wxSizerItem( window, option, flag, border ) );
+}
+
+void wxSizer::Prepend( wxSizer *sizer, int option, int flag, int border )
+{
+ m_children.Insert( new wxSizerItem( sizer, option, flag, border ) );
+}
+
+void wxSizer::Prepend( int width, int height, int option, int flag, int border )
+{
+ m_children.Insert( new wxSizerItem( width, height, option, flag, border ) );
+}
+
+bool wxSizer::Remove( wxWindow *window )
+{
+ wxASSERT( window );
+
+ wxNode *node = m_children.First();
+ while (node)
+ {
+ wxSizerItem *item = (wxSizerItem*)node->Data();
+ if (item->GetWindow() == window)
+ {
+ m_children.DeleteNode( node );
+ return TRUE;
+ }
+ node = node->Next();
+ }
+
+ return FALSE;
+}
+
+bool wxSizer::Remove( wxSizer *sizer )
+{
+ wxASSERT( sizer );
+
+ wxNode *node = m_children.First();
+ while (node)
+ {
+ wxSizerItem *item = (wxSizerItem*)node->Data();
+ if (item->GetSizer() == sizer)
+ {
+ m_children.DeleteNode( node );
+ return TRUE;
+ }
+ node = node->Next();
+ }
+
+ return FALSE;
+}
+
+bool wxSizer::Remove( int pos )
+{
+ wxNode *node = m_children.Nth( pos );
+ if (!node) return FALSE;
+
+ m_children.DeleteNode( node );
+
+ return TRUE;
+}
+
void wxSizer::Fit( wxWindow *window )
{
window->SetSize( GetMinWindowSize( window ) );
void wxSizer::Layout()
{
- m_size = CalcMin();
+ CalcMin();
RecalcSizes();
}
m_position.y = y;
m_size.x = width;
m_size.y = height;
+ CalcMin();
RecalcSizes();
}
void wxBoxSizer::RecalcSizes()
{
if (m_children.GetCount() == 0)
- {
- SetDimension( m_position.x, m_position.y, 2, 2 );
return;
- }
int delta = 0;
int extra = 0;
return wxSize( m_minWidth, m_minHeight );
}
+
+//---------------------------------------------------------------------------
+// wxStaticBoxSizer
+//---------------------------------------------------------------------------
+
+wxStaticBoxSizer::wxStaticBoxSizer( wxStaticBox *box, int orient )
+ : wxBoxSizer( orient )
+{
+ wxASSERT_MSG( box, _T("wxStaticBoxSizer needs a static box") );
+
+ m_staticBox = box;
+}
+
+void wxStaticBoxSizer::RecalcSizes()
+{
+ // this will have to be done platform by platform
+ // as there is no way to guess the thickness of
+ // a wxStaticBox border
+ int top_border = 15;
+ if (m_staticBox->GetLabel().IsEmpty()) top_border = 5;
+ int other_border = 5;
+
+ m_staticBox->SetSize( m_position.x, m_position.y, m_size.x, m_size.y );
+
+ wxPoint old_pos( m_position );
+ m_position.x += other_border;
+ m_position.y += top_border;
+ wxSize old_size( m_size );
+ m_size.x -= 2*other_border;
+ m_size.y -= top_border + other_border;
+
+ wxBoxSizer::RecalcSizes();
+
+ m_position = old_pos;
+ m_size = old_size;
+}
+
+wxSize wxStaticBoxSizer::CalcMin()
+{
+ // this will have to be done platform by platform
+ // as there is no way to guess the thickness of
+ // a wxStaticBox border
+ int top_border = 15;
+ if (m_staticBox->GetLabel().IsEmpty()) top_border = 5;
+ int other_border = 5;
+
+ wxSize ret( wxBoxSizer::CalcMin() );
+ ret.x += 2*top_border;
+ ret.y += other_border + top_border;
+
+ return ret;
+}