+//---------------------------------------------------------------------------
+// wxBorderNewSizer
+//---------------------------------------------------------------------------
+
+wxBorderNewSizer::wxBorderNewSizer( int sides )
+{
+ m_sides = sides;
+}
+
+void wxBorderNewSizer::Add( wxWindow *window, int option )
+{
+ wxCHECK_RET( m_children.GetCount() == 0, _T("border sizer can only hold one child") );
+
+ wxNewSizer::Add( window, option );
+}
+
+void wxBorderNewSizer::Add( wxNewSizer *sizer, int option )
+{
+ wxCHECK_RET( m_children.GetCount() == 0, _T("border sizer can only hold one child") );
+
+ wxNewSizer::Add( sizer, option );
+}
+
+void wxBorderNewSizer::Add( int width, int height, int option )
+{
+ wxCHECK_RET( m_children.GetCount() == 0, _T("border sizer can only hold one child") );
+
+ wxNewSizer::Add( width, height, option );
+}
+
+void wxBorderNewSizer::RecalcSizes()
+{
+ wxNode *node = m_children.GetFirst();
+
+ if (!node)
+ {
+ SetDimension( m_position.x, m_position.y, 2, 2 );
+ return;
+ }
+
+ wxNewSizerItem *item = (wxNewSizerItem*) node->Data();
+
+ wxSize size( m_size );
+ wxPoint pt( m_position );
+ int borderSize = item->GetOption();
+
+ if (m_sides & wxWEST)
+ {
+ size.x -= borderSize;
+ pt.x += borderSize;
+ }
+ if (m_sides & wxEAST)
+ {
+ size.x -= borderSize;
+ }
+ if (m_sides & wxNORTH)
+ {
+ size.y -= borderSize;
+ pt.y += borderSize;
+ }
+ if (m_sides & wxSOUTH)
+ {
+ size.y -= borderSize;
+ }
+
+ item->SetDimension( pt, size );
+}
+
+wxSize wxBorderNewSizer::CalcMin()
+{
+ wxNode *node = m_children.GetFirst();
+
+ if (!node)
+ return wxSize(2,2);
+
+ wxNewSizerItem *item = (wxNewSizerItem*) node->Data();
+
+ wxSize size( item->CalcMin() );
+
+ int borderSize = item->GetOption();
+
+ if (m_sides & wxWEST)
+ size.x += borderSize;
+ if (m_sides & wxEAST)
+ size.x += borderSize;
+ if (m_sides & wxNORTH)
+ size.y += borderSize;
+ if (m_sides & wxSOUTH)
+ size.y += borderSize;
+
+ return size;
+}
+