1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     provide new wxSizer class for layout 
   4 // Author:      Robert Roebling and Robin Dunn 
   8 // Copyright:   (c) Robin Dunn, Dirk Holtwick and Robert Roebling 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  13 #pragma implementation "sizer.h" 
  16 // For compilers that support precompilation, includes "wx.h". 
  17 #include "wx/wxprec.h" 
  25 #include "wx/statbox.h" 
  26 #include "wx/notebook.h" 
  28 //--------------------------------------------------------------------------- 
  30 IMPLEMENT_ABSTRACT_CLASS(wxSizerItem
, wxObject
); 
  31 IMPLEMENT_ABSTRACT_CLASS(wxSizer
, wxObject
); 
  32 IMPLEMENT_ABSTRACT_CLASS(wxGridSizer
, wxSizer
); 
  33 IMPLEMENT_ABSTRACT_CLASS(wxFlexGridSizer
, wxGridSizer
); 
  34 IMPLEMENT_ABSTRACT_CLASS(wxBoxSizer
, wxSizer
); 
  35 IMPLEMENT_ABSTRACT_CLASS(wxStaticBoxSizer
, wxBoxSizer
); 
  37 IMPLEMENT_ABSTRACT_CLASS(wxNotebookSizer
, wxSizer
); 
  40 //--------------------------------------------------------------------------- 
  42 //--------------------------------------------------------------------------- 
  44 wxSizerItem::wxSizerItem( int width
, int height
, int option
, int flag
, int border
, wxObject
* userData 
) 
  46     m_window 
= (wxWindow 
*) NULL
; 
  47     m_sizer 
= (wxSizer 
*) NULL
; 
  51     m_userData 
= userData
; 
  53     // minimal size is the initial size 
  57     SetRatio(width
, height
); 
  59     // size is set directly 
  63 wxSizerItem::wxSizerItem( wxWindow 
*window
, int option
, int flag
, int border
, wxObject
* userData 
) 
  66     m_sizer 
= (wxSizer 
*) NULL
; 
  70     m_userData 
= userData
; 
  72     // minimal size is the initial size 
  73     m_minSize 
= window
->GetSize(); 
  75     // aspect ratio calculated from initial size 
  78     // size is calculated later 
  82 wxSizerItem::wxSizerItem( wxSizer 
*sizer
, int option
, int flag
, int border
, wxObject
* userData 
) 
  84     m_window 
= (wxWindow 
*) NULL
; 
  89     m_userData 
= userData
; 
  91     // minimal size is calculated later 
  95     // size is calculated later 
  99 wxSizerItem::~wxSizerItem() 
 108 wxSize 
wxSizerItem::GetSize() 
 112         ret 
= m_sizer
->GetSize(); 
 115         ret 
= m_window
->GetSize(); 
 122     if (m_flag 
& wxNORTH
) 
 124     if (m_flag 
& wxSOUTH
) 
 130 wxSize 
wxSizerItem::CalcMin() 
 135         ret 
= m_sizer
->GetMinSize(); 
 136         // if we have to preserve aspect ratio _AND_ this is 
 137         // the first-time calculation, consider ret to be initial size 
 138         if ((m_flag 
& wxSHAPED
) && !m_ratio
) SetRatio(ret
); 
 142     The minimum size of a window should be the 
 143     initial size, as saved in m_minSize, not the 
 148         ret = m_window->GetSize(); 
 150     else ret 
= m_minSize
; 
 156     if (m_flag 
& wxNORTH
) 
 158     if (m_flag 
& wxSOUTH
) 
 164 void wxSizerItem::SetDimension( wxPoint pos
, wxSize size 
) 
 177     if (m_flag 
& wxNORTH
) 
 182     if (m_flag 
& wxSOUTH
) 
 186     if (m_flag 
& wxSHAPED
) { 
 187         // adjust aspect ratio 
 188         int rwidth 
= (int) (size
.y 
* m_ratio
); 
 189         if (rwidth 
> size
.x
) { 
 191             int rheight 
= (int) (size
.x 
/ m_ratio
); 
 192             // add vertical space 
 193             if (m_flag 
& wxALIGN_CENTER_VERTICAL
) 
 194                 pos
.y 
+= (size
.y 
- rheight
) / 2; 
 195             else if (m_flag 
& wxALIGN_BOTTOM
) 
 196                 pos
.y 
+= (size
.y 
- rheight
); 
 197             // use reduced dimensions 
 199         } else if (rwidth 
< size
.x
) { 
 200             // add horizontal space 
 201             if (m_flag 
& wxALIGN_CENTER_HORIZONTAL
) 
 202                 pos
.x 
+= (size
.x 
- rwidth
) / 2; 
 203             else if (m_flag 
& wxALIGN_RIGHT
) 
 204                 pos
.x 
+= (size
.x 
- rwidth
); 
 210         m_sizer
->SetDimension( pos
.x
, pos
.y
, size
.x
, size
.y 
); 
 213         m_window
->SetSize( pos
.x
, pos
.y
, size
.x
, size
.y
, wxSIZE_ALLOW_MINUS_ONE 
); 
 218 bool wxSizerItem::IsWindow() 
 220     return (m_window 
!= NULL
); 
 223 bool wxSizerItem::IsSizer() 
 225     return (m_sizer 
!= NULL
); 
 228 bool wxSizerItem::IsSpacer() 
 230     return (m_window 
== NULL
) && (m_sizer 
== NULL
); 
 233 //--------------------------------------------------------------------------- 
 235 //--------------------------------------------------------------------------- 
 239     m_children
.DeleteContents( TRUE 
); 
 248 void wxSizer::Add( wxWindow 
*window
, int option
, int flag
, int border
, wxObject
* userData 
) 
 250     m_children
.Append( new wxSizerItem( window
, option
, flag
, border
, userData 
) ); 
 253 void wxSizer::Add( wxSizer 
*sizer
, int option
, int flag
, int border
, wxObject
* userData 
) 
 255     m_children
.Append( new wxSizerItem( sizer
, option
, flag
, border
, userData 
) ); 
 258 void wxSizer::Add( int width
, int height
, int option
, int flag
, int border
, wxObject
* userData 
) 
 260     m_children
.Append( new wxSizerItem( width
, height
, option
, flag
, border
, userData 
) ); 
 263 void wxSizer::Prepend( wxWindow 
*window
, int option
, int flag
, int border
, wxObject
* userData 
) 
 265     m_children
.Insert( new wxSizerItem( window
, option
, flag
, border
, userData 
) ); 
 268 void wxSizer::Prepend( wxSizer 
*sizer
, int option
, int flag
, int border
, wxObject
* userData 
) 
 270     m_children
.Insert( new wxSizerItem( sizer
, option
, flag
, border
, userData 
) ); 
 273 void wxSizer::Prepend( int width
, int height
, int option
, int flag
, int border
, wxObject
* userData 
) 
 275     m_children
.Insert( new wxSizerItem( width
, height
, option
, flag
, border
, userData 
) ); 
 278 void wxSizer::Insert( int before
, wxWindow 
*window
, int option
, int flag
, int border
, wxObject
* userData 
) 
 280     m_children
.Insert( before
, new wxSizerItem( window
, option
, flag
, border
, userData 
) ); 
 283 void wxSizer::Insert( int before
, wxSizer 
*sizer
, int option
, int flag
, int border
, wxObject
* userData 
) 
 285     m_children
.Insert( before
, new wxSizerItem( sizer
, option
, flag
, border
, userData 
) ); 
 288 void wxSizer::Insert( int before
, int width
, int height
, int option
, int flag
, int border
, wxObject
* userData 
) 
 290     m_children
.Insert( before
, new wxSizerItem( width
, height
, option
, flag
, border
, userData 
) ); 
 293 bool wxSizer::Remove( wxWindow 
*window 
) 
 297     wxNode 
*node 
= m_children
.First(); 
 300         wxSizerItem 
*item 
= (wxSizerItem
*)node
->Data(); 
 301             if (item
->GetWindow() == window
) 
 303             m_children
.DeleteNode( node 
); 
 312 bool wxSizer::Remove( wxSizer 
*sizer 
) 
 316     wxNode 
*node 
= m_children
.First(); 
 319         wxSizerItem 
*item 
= (wxSizerItem
*)node
->Data(); 
 320             if (item
->GetSizer() == sizer
) 
 322             m_children
.DeleteNode( node 
); 
 331 bool wxSizer::Remove( int pos 
) 
 333     wxNode 
*node 
= m_children
.Nth( pos 
); 
 334     if (!node
) return FALSE
; 
 336     m_children
.DeleteNode( node 
); 
 341 void wxSizer::Fit( wxWindow 
*window 
) 
 343     window
->SetSize( GetMinWindowSize( window 
) ); 
 346 void wxSizer::Layout() 
 352 void wxSizer::SetSizeHints( wxWindow 
*window 
) 
 354     wxSize 
size( GetMinWindowSize( window 
) ); 
 355     window
->SetSizeHints( size
.x
, size
.y 
); 
 358 wxSize 
wxSizer::GetMinWindowSize( wxWindow 
*window 
) 
 360     wxSize 
minSize( GetMinSize() ); 
 361     wxSize 
size( window
->GetSize() ); 
 362     wxSize 
client_size( window
->GetClientSize() ); 
 363     return wxSize( minSize
.x
+size
.x
-client_size
.x
, 
 364                    minSize
.y
+size
.y
-client_size
.y 
); 
 367 void wxSizer::SetDimension( int x
, int y
, int width
, int height 
) 
 377 wxSize 
wxSizer::GetMinSize() 
 379     wxSize 
ret( CalcMin() ); 
 380     if (ret
.x 
< m_minSize
.x
) ret
.x 
= m_minSize
.x
; 
 381     if (ret
.y 
< m_minSize
.y
) ret
.y 
= m_minSize
.y
; 
 385 void wxSizer::DoSetMinSize( int width
, int height 
) 
 388     m_minSize
.y 
= height
; 
 391 bool wxSizer::DoSetItemMinSize( wxWindow 
*window
, int width
, int height 
) 
 395     wxNode 
*node 
= m_children
.First(); 
 398         wxSizerItem 
*item 
= (wxSizerItem
*)node
->Data(); 
 399             if (item
->GetWindow() == window
) 
 401             item
->SetInitSize( width
, height 
); 
 407     node 
= m_children
.First(); 
 410         wxSizerItem 
*item 
= (wxSizerItem
*)node
->Data(); 
 411             if (item
->GetSizer()) 
 413             /* It's a sizer, so lets search recursively. */ 
 414             if (item
->GetSizer()->DoSetItemMinSize( window
, width
, height 
)) 
 416                 /* A child sizer found the requested windw, exit. */ 
 426 bool wxSizer::DoSetItemMinSize( wxSizer 
*sizer
, int width
, int height 
) 
 430     wxNode 
*node 
= m_children
.First(); 
 433         wxSizerItem 
*item 
= (wxSizerItem
*)node
->Data(); 
 434             if (item
->GetSizer() == sizer
) 
 436             item
->GetSizer()->DoSetMinSize( width
, height 
); 
 442     node 
= m_children
.First(); 
 445         wxSizerItem 
*item 
= (wxSizerItem
*)node
->Data(); 
 446             if (item
->GetSizer()) 
 448             /* It's a sizer, so lets search recursively. */ 
 449             if (item
->GetSizer()->DoSetItemMinSize( sizer
, width
, height 
)) 
 451                 /* A child sizer found the requested windw, exit. */ 
 461 bool wxSizer::DoSetItemMinSize( int pos
, int width
, int height 
) 
 463     wxNode 
*node 
= m_children
.Nth( pos 
); 
 464     if (!node
) return FALSE
; 
 466     wxSizerItem 
*item 
= (wxSizerItem
*) node
->Data(); 
 467     if (item
->GetSizer()) 
 469         /* Sizers contains the minimal size in them, if not calculated ... */ 
 470         item
->GetSizer()->DoSetMinSize( width
, height 
); 
 474         /* ... whereas the minimal size of spacers and windows in stored  
 476         item
->SetInitSize( width
, height 
); 
 482 //--------------------------------------------------------------------------- 
 484 //--------------------------------------------------------------------------- 
 486 wxGridSizer::wxGridSizer( int rows
, int cols
, int vgap
, int hgap 
) 
 494 wxGridSizer::wxGridSizer( int cols
, int vgap
, int hgap 
) 
 502 void wxGridSizer::RecalcSizes() 
 504     if (m_children
.GetCount() == 0) 
 507     int nitems 
= m_children
.GetCount(); 
 512         nrows 
= (nitems 
+ ncols
-1) / ncols
; 
 514         ncols 
= (nitems 
+ nrows
-1) / nrows
; 
 516     wxSize 
sz( GetSize() ); 
 517     wxPoint 
pt( GetPosition() ); 
 519         int w 
= (sz
.x 
- (ncols 
- 1) * m_hgap
) / ncols
; 
 520         int h 
= (sz
.y 
- (nrows 
- 1) * m_vgap
) / nrows
; 
 523     for (int c 
= 0; c 
< ncols
; c
++) 
 526         for (int r 
= 0; r 
< nrows
; r
++) 
 528             int i 
= r 
* ncols 
+ c
; 
 531                 wxNode 
*node 
= m_children
.Nth( i 
); 
 534                 SetItemBounds( (wxSizerItem
*) node
->Data(), x
, y
, w
, h
); 
 542 wxSize 
wxGridSizer::CalcMin() 
 544     if (m_children
.GetCount() == 0) 
 545         return wxSize(10,10); 
 547     int nitems 
= m_children
.GetCount(); 
 552         nrows 
= (nitems 
+ ncols
-1) / ncols
; 
 554         ncols 
= (nitems 
+ nrows
-1) / nrows
; 
 556     /* Find the max width and height for any component */ 
 560     wxNode 
*node 
= m_children
.First(); 
 563         wxSizerItem 
*item 
= (wxSizerItem
*)node
->Data(); 
 564         wxSize 
sz( item
->CalcMin() ); 
 565         w 
= wxMax( w
, sz
.x 
); 
 566         h 
= wxMax( h
, sz
.y 
); 
 571     return wxSize(ncols 
* w 
+ (ncols
-1) * m_hgap
, 
 572                   nrows 
* h 
+ (nrows
-1) * m_vgap
); 
 575 void wxGridSizer::SetItemBounds( wxSizerItem 
*item
, int x
, int y
, int w
, int h 
) 
 578     wxSize 
sz( item
->CalcMin() ); 
 579     int flag 
= item
->GetFlag(); 
 581     if ((flag 
& wxEXPAND
) || (flag 
& wxSHAPED
)) 
 587         if (flag 
& wxALIGN_CENTER_HORIZONTAL
) 
 589             pt
.x 
= x 
+ (w 
- sz
.x
) / 2; 
 591         else if (flag 
& wxALIGN_RIGHT
) 
 593             pt
.x 
= x 
+ (w 
- sz
.x
); 
 596         if (flag 
& wxALIGN_CENTER_VERTICAL
) 
 598             pt
.y 
= y 
+ (h 
- sz
.y
) / 2; 
 600         else if (flag 
& wxALIGN_BOTTOM
) 
 602             pt
.y 
= y 
+ (h 
- sz
.y
); 
 606     item
->SetDimension(pt
, sz
); 
 609 //--------------------------------------------------------------------------- 
 611 //--------------------------------------------------------------------------- 
 613 wxFlexGridSizer::wxFlexGridSizer( int rows
, int cols
, int vgap
, int hgap 
) 
 614    : wxGridSizer( rows
, cols
, vgap
, hgap 
) 
 616     m_rowHeights 
= (int*) NULL
; 
 617     m_colWidths 
= (int*) NULL
; 
 620 wxFlexGridSizer::wxFlexGridSizer( int cols
, int vgap
, int hgap 
) 
 621    : wxGridSizer( cols
, vgap
, hgap 
)  
 623     m_rowHeights 
= (int*) NULL
; 
 624     m_colWidths 
= (int*) NULL
; 
 627 wxFlexGridSizer::~wxFlexGridSizer() 
 630         delete[] m_rowHeights
; 
 632         delete[] m_colWidths
; 
 635 void wxFlexGridSizer::CreateArrays() 
 638         delete[] m_rowHeights
; 
 640         delete[] m_colWidths
; 
 642     if (m_children
.GetCount() == 0) 
 645     int nitems 
= m_children
.GetCount(); 
 650         nrows 
= (nitems 
+ ncols
-1) / ncols
; 
 652         ncols 
= (nitems 
+ nrows
-1) / nrows
; 
 654     m_rowHeights 
= new int[nrows
]; 
 655     m_colWidths 
= new int[ncols
]; 
 657     for (int col 
= 0; col 
< ncols
; col
++) 
 658         m_colWidths
[ col 
] = 0; 
 659     for (int row 
= 0; row 
< nrows
; row
++) 
 660         m_rowHeights
[ row 
] = 0; 
 663 void wxFlexGridSizer::RecalcSizes() 
 665     if (m_children
.GetCount() == 0) 
 668     int nitems 
= m_children
.GetCount(); 
 673         nrows 
= (nitems 
+ ncols
-1) / ncols
; 
 675         ncols 
= (nitems 
+ nrows
-1) / nrows
; 
 677     wxSize 
sz( GetSize() ); 
 678     wxSize 
minsz( CalcMin() ); 
 679     wxPoint 
pt( GetPosition() ); 
 683     if ((m_growableRows
.GetCount() > 0) && (sz
.y 
> minsz
.y
)) 
 685         delta 
= (sz
.y 
- minsz
.y
) / m_growableRows
.GetCount(); 
 686         for (idx 
= 0; idx 
< m_growableRows
.GetCount(); idx
++) 
 687             m_rowHeights
[ m_growableRows
[idx
] ] += delta
; 
 690     if ((m_growableCols
.GetCount() > 0) && (sz
.x 
> minsz
.x
)) 
 692         delta 
= (sz
.x 
- minsz
.x
) / m_growableCols
.GetCount(); 
 693         for (idx 
= 0; idx 
< m_growableCols
.GetCount(); idx
++) 
 694             m_colWidths
[ m_growableCols
[idx
] ] += delta
; 
 697     sz 
= wxSize( pt
.x 
+ sz
.x
, pt
.y 
+ sz
.y 
); 
 700     for (int c 
= 0; c 
< ncols
; c
++) 
 703         for (int r 
= 0; r 
< nrows
; r
++) 
 705             int i 
= r 
* ncols 
+ c
; 
 708                 wxNode 
*node 
= m_children
.Nth( i 
); 
 711                 int w 
= wxMax( 0, wxMin( m_colWidths
[c
], sz
.x 
- x 
) ); 
 712                 int h 
= wxMax( 0, wxMin( m_rowHeights
[r
], sz
.y 
- y 
) ); 
 714                 SetItemBounds( (wxSizerItem
*) node
->Data(), x
, y
, w
, h
); 
 716             y 
= y 
+ m_rowHeights
[r
] + m_vgap
; 
 718         x 
= x 
+ m_colWidths
[c
] + m_hgap
; 
 722 wxSize 
wxFlexGridSizer::CalcMin() 
 724     if (m_children
.GetCount() == 0) 
 725         return wxSize(10,10); 
 727     int nitems 
= m_children
.GetCount(); 
 732         nrows 
= (nitems 
+ ncols
-1) / ncols
; 
 734         ncols 
= (nitems 
+ nrows
-1) / nrows
; 
 742     wxNode 
*node 
= m_children
.First(); 
 745         wxSizerItem 
*item 
= (wxSizerItem
*)node
->Data(); 
 746         wxSize 
sz( item
->CalcMin() ); 
 749         m_rowHeights
[ row 
] = wxMax( sz
.y
, m_rowHeights
[ row 
] ); 
 750         m_colWidths
[ col 
] = wxMax( sz
.x
, m_colWidths
[ col 
] ); 
 757     for (col 
= 0; col 
< ncols
; col
++) 
 758         width 
+= m_colWidths
[ col 
]; 
 761     for (row 
= 0; row 
< nrows
; row
++) 
 762         height 
+= m_rowHeights
[ row 
]; 
 764     return wxSize( width 
+  (ncols
-1) * m_hgap
, 
 765                    height 
+ (nrows
-1) * m_vgap
); 
 768 void wxFlexGridSizer::AddGrowableRow( size_t idx 
) 
 770     m_growableRows
.Add( idx 
); 
 773 void wxFlexGridSizer::RemoveGrowableRow( size_t idx 
) 
 777 void wxFlexGridSizer::AddGrowableCol( size_t idx 
) 
 779     m_growableCols
.Add( idx 
); 
 782 void wxFlexGridSizer::RemoveGrowableCol( size_t idx 
) 
 786 //--------------------------------------------------------------------------- 
 788 //--------------------------------------------------------------------------- 
 790 wxBoxSizer::wxBoxSizer( int orient 
) 
 795 void wxBoxSizer::RecalcSizes() 
 797     if (m_children
.GetCount() == 0) 
 804         if (m_orient 
== wxHORIZONTAL
) 
 806             delta 
= (m_size
.x 
- m_fixedWidth
) / m_stretchable
; 
 807             extra 
= (m_size
.x 
- m_fixedWidth
) % m_stretchable
; 
 811             delta 
= (m_size
.y 
- m_fixedHeight
) / m_stretchable
; 
 812             extra 
= (m_size
.y 
- m_fixedHeight
) % m_stretchable
; 
 816     wxPoint 
pt( m_position 
); 
 818     wxNode 
*node 
= m_children
.GetFirst(); 
 821         wxSizerItem 
*item 
= (wxSizerItem
*) node
->Data(); 
 824             if (item
->GetOption()) 
 825                 weight 
= item
->GetOption(); 
 827             wxSize 
size( item
->CalcMin() ); 
 829             if (m_orient 
== wxVERTICAL
) 
 831                 wxCoord height 
= size
.y
; 
 832                 if (item
->GetOption()) 
 834                     height 
= (delta 
* weight
) + extra
; 
 835                         extra 
= 0; // only the first item will get the remainder as extra size 
 838                 wxPoint 
child_pos( pt 
); 
 839                 wxSize  
child_size( wxSize( size
.x
, height
) ); 
 841                 if (item
->GetFlag() & (wxEXPAND 
| wxSHAPED
)) 
 842                     child_size
.x 
= m_size
.x
; 
 843                 else if (item
->GetFlag() & wxALIGN_RIGHT
) 
 844                     child_pos
.x 
+= m_size
.x 
- size
.x
; 
 845                 else if (item
->GetFlag() & (wxCENTER 
| wxALIGN_CENTER_HORIZONTAL
)) 
 846                 // XXX wxCENTER is added for backward compatibility; 
 847                 //     wxALIGN_CENTER should be used in new code 
 848                     child_pos
.x 
+= (m_size
.x 
- size
.x
) / 2; 
 850                 item
->SetDimension( child_pos
, child_size 
); 
 856                 wxCoord width 
= size
.x
; 
 857                 if (item
->GetOption()) 
 859                     width 
= (delta 
* weight
) + extra
; 
 860                         extra 
= 0; // only the first item will get the remainder as extra size 
 863                 wxPoint 
child_pos( pt 
); 
 864                 wxSize  
child_size( wxSize(width
, size
.y
) ); 
 866                 if (item
->GetFlag() & (wxEXPAND 
| wxSHAPED
)) 
 867                     child_size
.y 
= m_size
.y
; 
 868                 else if (item
->GetFlag() & wxALIGN_BOTTOM
) 
 869                     child_pos
.y 
+= m_size
.y 
- size
.y
; 
 870                 else if (item
->GetFlag() & (wxCENTER 
| wxALIGN_CENTER_VERTICAL
)) 
 871                 // XXX wxCENTER is added for backward compatibility; 
 872                 //     wxALIGN_CENTER should be used in new code 
 873                     child_pos
.y 
+= (m_size
.y 
- size
.y
) / 2; 
 875                 item
->SetDimension( child_pos
, child_size 
); 
 884 wxSize 
wxBoxSizer::CalcMin() 
 886     if (m_children
.GetCount() == 0) 
 887         return wxSize(10,10); 
 895     wxNode 
*node 
= m_children
.GetFirst(); 
 898         wxSizerItem 
*item 
= (wxSizerItem
*) node
->Data(); 
 901             if (item
->GetOption()) 
 902                 weight 
= item
->GetOption(); 
 904             wxSize 
size( item
->CalcMin() ); 
 906             if (m_orient 
== wxHORIZONTAL
) 
 908                 m_minWidth 
+= (size
.x 
* weight
); 
 909                 m_minHeight 
= wxMax( m_minHeight
, size
.y 
); 
 913                 m_minHeight 
+= (size
.y 
* weight
); 
 914                 m_minWidth 
= wxMax( m_minWidth
, size
.x 
); 
 917             if (item
->GetOption()) 
 919                 m_stretchable 
+= weight
; 
 923                 if (m_orient 
== wxVERTICAL
) 
 925                         m_fixedHeight 
+= size
.y
; 
 926                         m_fixedWidth 
= wxMax( m_fixedWidth
, size
.x 
); 
 930                         m_fixedWidth 
+= size
.x
; 
 931                         m_fixedHeight 
= wxMax( m_fixedHeight
, size
.y 
); 
 938     return wxSize( m_minWidth
, m_minHeight 
); 
 941 //--------------------------------------------------------------------------- 
 943 //--------------------------------------------------------------------------- 
 945 wxStaticBoxSizer::wxStaticBoxSizer( wxStaticBox 
*box
, int orient 
) 
 946   : wxBoxSizer( orient 
) 
 948     wxASSERT_MSG( box
, wxT("wxStaticBoxSizer needs a static box") ); 
 953 void wxStaticBoxSizer::RecalcSizes() 
 955     // this will have to be done platform by platform 
 956     // as there is no way to guess the thickness of 
 957     // a wxStaticBox border 
 959     if (m_staticBox
->GetLabel().IsEmpty()) top_border 
= 5; 
 960     int other_border 
= 5; 
 962     m_staticBox
->SetSize( m_position
.x
, m_position
.y
, m_size
.x
, m_size
.y 
); 
 964     wxPoint 
old_pos( m_position 
); 
 965     m_position
.x 
+= other_border
; 
 966     m_position
.y 
+= top_border
; 
 967     wxSize 
old_size( m_size 
); 
 968     m_size
.x 
-= 2*other_border
; 
 969     m_size
.y 
-= top_border 
+ other_border
; 
 971     wxBoxSizer::RecalcSizes(); 
 973     m_position 
= old_pos
; 
 977 wxSize 
wxStaticBoxSizer::CalcMin() 
 979     // This will have to be done platform by platform 
 980     // as there is no way to guess the thickness of 
 981     // a wxStaticBox border. 
 984     if (m_staticBox
->GetLabel().IsEmpty()) top_border 
= 5; 
 985     int other_border 
= 5; 
 987     wxSize 
ret( wxBoxSizer::CalcMin() ); 
 988     ret
.x 
+= 2*other_border
; 
 989     ret
.y 
+= other_border 
+ top_border
; 
 994 //--------------------------------------------------------------------------- 
 996 //--------------------------------------------------------------------------- 
1000 wxNotebookSizer::wxNotebookSizer( wxNotebook 
*nb 
) 
1002     wxASSERT_MSG( nb
, wxT("wxNotebookSizer needs a notebook") ); 
1007 void wxNotebookSizer::RecalcSizes() 
1009     m_notebook
->SetSize( m_position
.x
, m_position
.y
, m_size
.x
, m_size
.y 
); 
1012 wxSize 
wxNotebookSizer::CalcMin() 
1014     // This will have to be done platform by platform 
1015     // as there is no way to guess the thickness of 
1016     // the wxNotebook tabs and border. 
1020     if ((m_notebook
->HasFlag(wxNB_RIGHT
)) || 
1021         (m_notebook
->HasFlag(wxNB_LEFT
))) 
1023         borderX 
+= 90; // improvements later.. 
1027         borderY 
+= 40; // improvements later.. 
1030     if (m_notebook
->GetChildren().GetCount() == 0) 
1031         return wxSize(borderX 
+ 10, borderY 
+ 10); 
1036     wxWindowList::Node 
*node 
= m_notebook
->GetChildren().GetFirst(); 
1039         wxWindow 
*item 
= node
->GetData(); 
1040             wxSizer 
*itemsizer 
= item
->GetSizer(); 
1044             wxSize 
subsize( itemsizer
->CalcMin() ); 
1046                 if (subsize
.x 
> maxX
) maxX 
= subsize
.x
; 
1047                 if (subsize
.y 
> maxY
) maxY 
= subsize
.y
; 
1050             node 
= node
->GetNext(); 
1053     return wxSize( borderX 
+ maxX
, borderY 
+ maxY 
); 
1056 #endif // wxUSE_NOTEBOOK