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
);
36 IMPLEMENT_ABSTRACT_CLASS(wxStaticBoxSizer
, wxBoxSizer
);
39 IMPLEMENT_ABSTRACT_CLASS(wxNotebookSizer
, wxSizer
);
42 //---------------------------------------------------------------------------
44 //---------------------------------------------------------------------------
46 wxSizerItem::wxSizerItem( int width
, int height
, int option
, int flag
, int border
, wxObject
* userData
)
48 m_window
= (wxWindow
*) NULL
;
49 m_sizer
= (wxSizer
*) NULL
;
53 m_userData
= userData
;
55 // minimal size is the initial size
59 SetRatio(width
, height
);
61 // size is set directly
65 wxSizerItem::wxSizerItem( wxWindow
*window
, int option
, int flag
, int border
, wxObject
* userData
)
68 m_sizer
= (wxSizer
*) NULL
;
72 m_userData
= userData
;
74 // minimal size is the initial size
75 m_minSize
= window
->GetSize();
77 // aspect ratio calculated from initial size
80 // size is calculated later
84 wxSizerItem::wxSizerItem( wxSizer
*sizer
, int option
, int flag
, int border
, wxObject
* userData
)
86 m_window
= (wxWindow
*) NULL
;
91 m_userData
= userData
;
93 // minimal size is calculated later
97 // size is calculated later
101 wxSizerItem::~wxSizerItem()
110 wxSize
wxSizerItem::GetSize()
114 ret
= m_sizer
->GetSize();
117 ret
= m_window
->GetSize();
124 if (m_flag
& wxNORTH
)
126 if (m_flag
& wxSOUTH
)
132 wxSize
wxSizerItem::CalcMin()
137 ret
= m_sizer
->GetMinSize();
139 // if we have to preserve aspect ratio _AND_ this is
140 // the first-time calculation, consider ret to be initial size
141 if ((m_flag
& wxSHAPED
) && !m_ratio
)
146 if ( IsWindow() && (m_flag
& wxADJUST_MINSIZE
) )
148 // check if the best (minimal, in fact) window size hadn't changed
149 // by chance: this may happen for, e.g. static text if its label
151 wxSize size
= m_window
->GetBestSize();
152 if ( size
.x
> m_minSize
.x
)
153 m_minSize
.x
= size
.x
;
154 if ( size
.y
> m_minSize
.y
)
155 m_minSize
.y
= size
.y
;
165 if (m_flag
& wxNORTH
)
167 if (m_flag
& wxSOUTH
)
173 void wxSizerItem::SetDimension( wxPoint pos
, wxSize size
)
175 if (m_flag
& wxSHAPED
)
177 // adjust aspect ratio
178 int rwidth
= (int) (size
.y
* m_ratio
);
182 int rheight
= (int) (size
.x
/ m_ratio
);
183 // add vertical space
184 if (m_flag
& wxALIGN_CENTER_VERTICAL
)
185 pos
.y
+= (size
.y
- rheight
) / 2;
186 else if (m_flag
& wxALIGN_BOTTOM
)
187 pos
.y
+= (size
.y
- rheight
);
188 // use reduced dimensions
191 else if (rwidth
< size
.x
)
193 // add horizontal space
194 if (m_flag
& wxALIGN_CENTER_HORIZONTAL
)
195 pos
.x
+= (size
.x
- rwidth
) / 2;
196 else if (m_flag
& wxALIGN_RIGHT
)
197 pos
.x
+= (size
.x
- rwidth
);
202 // This is what GetPosition() returns. Since we calculate
203 // borders afterwards, GetPosition() will be the left/top
204 // corner of the surrounding border.
216 if (m_flag
& wxNORTH
)
221 if (m_flag
& wxSOUTH
)
227 m_sizer
->SetDimension( pos
.x
, pos
.y
, size
.x
, size
.y
);
230 m_window
->SetSize( pos
.x
, pos
.y
, size
.x
, size
.y
, wxSIZE_ALLOW_MINUS_ONE
);
235 bool wxSizerItem::IsWindow()
237 return (m_window
!= NULL
);
240 bool wxSizerItem::IsSizer()
242 return (m_sizer
!= NULL
);
245 bool wxSizerItem::IsSpacer()
247 return (m_window
== NULL
) && (m_sizer
== NULL
);
250 //---------------------------------------------------------------------------
252 //---------------------------------------------------------------------------
256 m_children
.DeleteContents( TRUE
);
265 void wxSizer::Add( wxWindow
*window
, int option
, int flag
, int border
, wxObject
* userData
)
267 m_children
.Append( new wxSizerItem( window
, option
, flag
, border
, userData
) );
270 void wxSizer::Add( wxSizer
*sizer
, int option
, int flag
, int border
, wxObject
* userData
)
272 m_children
.Append( new wxSizerItem( sizer
, option
, flag
, border
, userData
) );
275 void wxSizer::Add( int width
, int height
, int option
, int flag
, int border
, wxObject
* userData
)
277 m_children
.Append( new wxSizerItem( width
, height
, option
, flag
, border
, userData
) );
280 void wxSizer::Prepend( wxWindow
*window
, int option
, int flag
, int border
, wxObject
* userData
)
282 m_children
.Insert( new wxSizerItem( window
, option
, flag
, border
, userData
) );
285 void wxSizer::Prepend( wxSizer
*sizer
, int option
, int flag
, int border
, wxObject
* userData
)
287 m_children
.Insert( new wxSizerItem( sizer
, option
, flag
, border
, userData
) );
290 void wxSizer::Prepend( int width
, int height
, int option
, int flag
, int border
, wxObject
* userData
)
292 m_children
.Insert( new wxSizerItem( width
, height
, option
, flag
, border
, userData
) );
295 void wxSizer::Insert( int before
, wxWindow
*window
, int option
, int flag
, int border
, wxObject
* userData
)
297 m_children
.Insert( before
, new wxSizerItem( window
, option
, flag
, border
, userData
) );
300 void wxSizer::Insert( int before
, wxSizer
*sizer
, int option
, int flag
, int border
, wxObject
* userData
)
302 m_children
.Insert( before
, new wxSizerItem( sizer
, option
, flag
, border
, userData
) );
305 void wxSizer::Insert( int before
, int width
, int height
, int option
, int flag
, int border
, wxObject
* userData
)
307 m_children
.Insert( before
, new wxSizerItem( width
, height
, option
, flag
, border
, userData
) );
310 bool wxSizer::Remove( wxWindow
*window
)
314 wxNode
*node
= m_children
.First();
317 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
318 if (item
->GetWindow() == window
)
320 m_children
.DeleteNode( node
);
329 bool wxSizer::Remove( wxSizer
*sizer
)
333 wxNode
*node
= m_children
.First();
336 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
337 if (item
->GetSizer() == sizer
)
339 m_children
.DeleteNode( node
);
348 bool wxSizer::Remove( int pos
)
350 wxNode
*node
= m_children
.Nth( pos
);
351 if (!node
) return FALSE
;
353 m_children
.DeleteNode( node
);
358 void wxSizer::Fit( wxWindow
*window
)
361 if (window
->IsTopLevel())
362 size
= FitSize( window
);
364 size
= GetMinWindowSize( window
);
366 window
->SetSize( size
);
369 void wxSizer::Layout()
375 void wxSizer::SetSizeHints( wxWindow
*window
)
377 wxSize size
= FitSize( window
);
378 window
->SetSizeHints( size
.x
, size
.y
);
381 wxSize
wxSizer::GetMaxWindowSize( wxWindow
*WXUNUSED(window
) )
383 wxRect rect
= wxGetClientDisplayRect();
384 wxSize
sizeMax (rect
.width
,rect
.height
);
386 // Make the max size a bit smaller than the visible portion of
387 // the screen. A window which takes the entire screen doesn't
388 // look very nice either
398 wxSize
wxSizer::GetMinWindowSize( wxWindow
*window
)
400 wxSize
minSize( GetMinSize() );
401 wxSize
size( window
->GetSize() );
402 wxSize
client_size( window
->GetClientSize() );
403 return wxSize( minSize
.x
+size
.x
-client_size
.x
,
404 minSize
.y
+size
.y
-client_size
.y
);
407 // Return a window size that will fit within the screens dimensions
408 wxSize
wxSizer::FitSize( wxWindow
*window
)
410 wxSize size
= GetMinWindowSize( window
);
411 wxSize sizeMax
= GetMaxWindowSize( window
);
413 if ( size
.x
> sizeMax
.x
)
415 if ( size
.y
> sizeMax
.y
)
421 void wxSizer::SetDimension( int x
, int y
, int width
, int height
)
431 wxSize
wxSizer::GetMinSize()
433 wxSize
ret( CalcMin() );
434 if (ret
.x
< m_minSize
.x
) ret
.x
= m_minSize
.x
;
435 if (ret
.y
< m_minSize
.y
) ret
.y
= m_minSize
.y
;
439 void wxSizer::DoSetMinSize( int width
, int height
)
442 m_minSize
.y
= height
;
445 bool wxSizer::DoSetItemMinSize( wxWindow
*window
, int width
, int height
)
449 wxNode
*node
= m_children
.First();
452 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
453 if (item
->GetWindow() == window
)
455 item
->SetInitSize( width
, height
);
461 node
= m_children
.First();
464 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
465 if (item
->GetSizer())
467 /* It's a sizer, so lets search recursively. */
468 if (item
->GetSizer()->DoSetItemMinSize( window
, width
, height
))
470 /* A child sizer found the requested windw, exit. */
480 bool wxSizer::DoSetItemMinSize( wxSizer
*sizer
, int width
, int height
)
484 wxNode
*node
= m_children
.First();
487 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
488 if (item
->GetSizer() == sizer
)
490 item
->GetSizer()->DoSetMinSize( width
, height
);
496 node
= m_children
.First();
499 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
500 if (item
->GetSizer())
502 /* It's a sizer, so lets search recursively. */
503 if (item
->GetSizer()->DoSetItemMinSize( sizer
, width
, height
))
505 /* A child sizer found the requested windw, exit. */
515 bool wxSizer::DoSetItemMinSize( int pos
, int width
, int height
)
517 wxNode
*node
= m_children
.Nth( pos
);
518 if (!node
) return FALSE
;
520 wxSizerItem
*item
= (wxSizerItem
*) node
->Data();
521 if (item
->GetSizer())
523 /* Sizers contains the minimal size in them, if not calculated ... */
524 item
->GetSizer()->DoSetMinSize( width
, height
);
528 /* ... whereas the minimal size of spacers and windows in stored
530 item
->SetInitSize( width
, height
);
536 //---------------------------------------------------------------------------
538 //---------------------------------------------------------------------------
540 wxGridSizer::wxGridSizer( int rows
, int cols
, int vgap
, int hgap
)
548 wxGridSizer::wxGridSizer( int cols
, int vgap
, int hgap
)
556 void wxGridSizer::RecalcSizes()
558 if (m_children
.GetCount() == 0)
561 int nitems
= m_children
.GetCount();
566 nrows
= (nitems
+ ncols
-1) / ncols
;
568 ncols
= (nitems
+ nrows
-1) / nrows
;
570 wxSize
sz( GetSize() );
571 wxPoint
pt( GetPosition() );
573 int w
= (sz
.x
- (ncols
- 1) * m_hgap
) / ncols
;
574 int h
= (sz
.y
- (nrows
- 1) * m_vgap
) / nrows
;
577 for (int c
= 0; c
< ncols
; c
++)
580 for (int r
= 0; r
< nrows
; r
++)
582 int i
= r
* ncols
+ c
;
585 wxNode
*node
= m_children
.Nth( i
);
588 SetItemBounds( (wxSizerItem
*) node
->Data(), x
, y
, w
, h
);
596 wxSize
wxGridSizer::CalcMin()
598 if (m_children
.GetCount() == 0)
599 return wxSize(10,10);
601 int nitems
= m_children
.GetCount();
606 nrows
= (nitems
+ ncols
-1) / ncols
;
608 ncols
= (nitems
+ nrows
-1) / nrows
;
610 /* Find the max width and height for any component */
614 wxNode
*node
= m_children
.First();
617 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
618 wxSize
sz( item
->CalcMin() );
619 w
= wxMax( w
, sz
.x
);
620 h
= wxMax( h
, sz
.y
);
625 return wxSize(ncols
* w
+ (ncols
-1) * m_hgap
,
626 nrows
* h
+ (nrows
-1) * m_vgap
);
629 void wxGridSizer::SetItemBounds( wxSizerItem
*item
, int x
, int y
, int w
, int h
)
632 wxSize
sz( item
->CalcMin() );
633 int flag
= item
->GetFlag();
635 if ((flag
& wxEXPAND
) || (flag
& wxSHAPED
))
641 if (flag
& wxALIGN_CENTER_HORIZONTAL
)
643 pt
.x
= x
+ (w
- sz
.x
) / 2;
645 else if (flag
& wxALIGN_RIGHT
)
647 pt
.x
= x
+ (w
- sz
.x
);
650 if (flag
& wxALIGN_CENTER_VERTICAL
)
652 pt
.y
= y
+ (h
- sz
.y
) / 2;
654 else if (flag
& wxALIGN_BOTTOM
)
656 pt
.y
= y
+ (h
- sz
.y
);
660 item
->SetDimension(pt
, sz
);
663 //---------------------------------------------------------------------------
665 //---------------------------------------------------------------------------
667 wxFlexGridSizer::wxFlexGridSizer( int rows
, int cols
, int vgap
, int hgap
)
668 : wxGridSizer( rows
, cols
, vgap
, hgap
)
670 m_rowHeights
= (int*) NULL
;
671 m_colWidths
= (int*) NULL
;
674 wxFlexGridSizer::wxFlexGridSizer( int cols
, int vgap
, int hgap
)
675 : wxGridSizer( cols
, vgap
, hgap
)
677 m_rowHeights
= (int*) NULL
;
678 m_colWidths
= (int*) NULL
;
681 wxFlexGridSizer::~wxFlexGridSizer()
684 delete[] m_rowHeights
;
686 delete[] m_colWidths
;
689 void wxFlexGridSizer::CreateArrays()
692 delete[] m_rowHeights
;
694 delete[] m_colWidths
;
696 if (m_children
.GetCount() == 0)
699 int nitems
= m_children
.GetCount();
704 nrows
= (nitems
+ ncols
-1) / ncols
;
706 ncols
= (nitems
+ nrows
-1) / nrows
;
708 m_rowHeights
= new int[nrows
];
709 m_colWidths
= new int[ncols
];
711 for (int col
= 0; col
< ncols
; col
++)
712 m_colWidths
[ col
] = 0;
713 for (int row
= 0; row
< nrows
; row
++)
714 m_rowHeights
[ row
] = 0;
717 void wxFlexGridSizer::RecalcSizes()
719 if (m_children
.GetCount() == 0)
722 int nitems
= m_children
.GetCount();
727 nrows
= (nitems
+ ncols
-1) / ncols
;
729 ncols
= (nitems
+ nrows
-1) / nrows
;
731 wxSize
sz( GetSize() );
732 wxSize
minsz( CalcMin() );
733 wxPoint
pt( GetPosition() );
737 if ((m_growableRows
.GetCount() > 0) && (sz
.y
> minsz
.y
))
739 delta
= (sz
.y
- minsz
.y
) / m_growableRows
.GetCount();
740 for (idx
= 0; idx
< m_growableRows
.GetCount(); idx
++)
741 m_rowHeights
[ m_growableRows
[idx
] ] += delta
;
744 if ((m_growableCols
.GetCount() > 0) && (sz
.x
> minsz
.x
))
746 delta
= (sz
.x
- minsz
.x
) / m_growableCols
.GetCount();
747 for (idx
= 0; idx
< m_growableCols
.GetCount(); idx
++)
748 m_colWidths
[ m_growableCols
[idx
] ] += delta
;
751 sz
= wxSize( pt
.x
+ sz
.x
, pt
.y
+ sz
.y
);
754 for (int c
= 0; c
< ncols
; c
++)
757 for (int r
= 0; r
< nrows
; r
++)
759 int i
= r
* ncols
+ c
;
762 wxNode
*node
= m_children
.Nth( i
);
765 int w
= wxMax( 0, wxMin( m_colWidths
[c
], sz
.x
- x
) );
766 int h
= wxMax( 0, wxMin( m_rowHeights
[r
], sz
.y
- y
) );
768 SetItemBounds( (wxSizerItem
*) node
->Data(), x
, y
, w
, h
);
770 y
= y
+ m_rowHeights
[r
] + m_vgap
;
772 x
= x
+ m_colWidths
[c
] + m_hgap
;
776 wxSize
wxFlexGridSizer::CalcMin()
778 if (m_children
.GetCount() == 0)
779 return wxSize(10,10);
781 int nitems
= m_children
.GetCount();
786 nrows
= (nitems
+ ncols
-1) / ncols
;
788 ncols
= (nitems
+ nrows
-1) / nrows
;
796 wxNode
*node
= m_children
.First();
799 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
800 wxSize
sz( item
->CalcMin() );
803 m_rowHeights
[ row
] = wxMax( sz
.y
, m_rowHeights
[ row
] );
804 m_colWidths
[ col
] = wxMax( sz
.x
, m_colWidths
[ col
] );
811 for (col
= 0; col
< ncols
; col
++)
812 width
+= m_colWidths
[ col
];
815 for (row
= 0; row
< nrows
; row
++)
816 height
+= m_rowHeights
[ row
];
818 return wxSize( width
+ (ncols
-1) * m_hgap
,
819 height
+ (nrows
-1) * m_vgap
);
822 void wxFlexGridSizer::AddGrowableRow( size_t idx
)
824 m_growableRows
.Add( idx
);
827 void wxFlexGridSizer::RemoveGrowableRow( size_t WXUNUSED(idx
) )
831 void wxFlexGridSizer::AddGrowableCol( size_t idx
)
833 m_growableCols
.Add( idx
);
836 void wxFlexGridSizer::RemoveGrowableCol( size_t WXUNUSED(idx
) )
840 //---------------------------------------------------------------------------
842 //---------------------------------------------------------------------------
844 wxBoxSizer::wxBoxSizer( int orient
)
849 void wxBoxSizer::RecalcSizes()
851 if (m_children
.GetCount() == 0)
858 if (m_orient
== wxHORIZONTAL
)
860 delta
= (m_size
.x
- m_fixedWidth
) / m_stretchable
;
861 extra
= (m_size
.x
- m_fixedWidth
) % m_stretchable
;
865 delta
= (m_size
.y
- m_fixedHeight
) / m_stretchable
;
866 extra
= (m_size
.y
- m_fixedHeight
) % m_stretchable
;
870 wxPoint
pt( m_position
);
872 wxNode
*node
= m_children
.GetFirst();
875 wxSizerItem
*item
= (wxSizerItem
*) node
->Data();
878 if (item
->GetOption())
879 weight
= item
->GetOption();
881 wxSize
size( item
->CalcMin() );
883 if (m_orient
== wxVERTICAL
)
885 wxCoord height
= size
.y
;
886 if (item
->GetOption())
888 height
= (delta
* weight
) + extra
;
889 extra
= 0; // only the first item will get the remainder as extra size
892 wxPoint
child_pos( pt
);
893 wxSize
child_size( wxSize( size
.x
, height
) );
895 if (item
->GetFlag() & (wxEXPAND
| wxSHAPED
))
896 child_size
.x
= m_size
.x
;
897 else if (item
->GetFlag() & wxALIGN_RIGHT
)
898 child_pos
.x
+= m_size
.x
- size
.x
;
899 else if (item
->GetFlag() & (wxCENTER
| wxALIGN_CENTER_HORIZONTAL
))
900 // XXX wxCENTER is added for backward compatibility;
901 // wxALIGN_CENTER should be used in new code
902 child_pos
.x
+= (m_size
.x
- size
.x
) / 2;
904 item
->SetDimension( child_pos
, child_size
);
910 wxCoord width
= size
.x
;
911 if (item
->GetOption())
913 width
= (delta
* weight
) + extra
;
914 extra
= 0; // only the first item will get the remainder as extra size
917 wxPoint
child_pos( pt
);
918 wxSize
child_size( wxSize(width
, size
.y
) );
920 if (item
->GetFlag() & (wxEXPAND
| wxSHAPED
))
921 child_size
.y
= m_size
.y
;
922 else if (item
->GetFlag() & wxALIGN_BOTTOM
)
923 child_pos
.y
+= m_size
.y
- size
.y
;
924 else if (item
->GetFlag() & (wxCENTER
| wxALIGN_CENTER_VERTICAL
))
925 // XXX wxCENTER is added for backward compatibility;
926 // wxALIGN_CENTER should be used in new code
927 child_pos
.y
+= (m_size
.y
- size
.y
) / 2;
929 item
->SetDimension( child_pos
, child_size
);
938 wxSize
wxBoxSizer::CalcMin()
940 if (m_children
.GetCount() == 0)
941 return wxSize(10,10);
949 // Find how long each stretch unit needs to be
951 wxNode
*node
= m_children
.GetFirst();
954 wxSizerItem
*item
= (wxSizerItem
*) node
->Data();
955 if (item
->GetOption() != 0)
957 int stretch
= item
->GetOption();
958 wxSize
size( item
->CalcMin() );
960 // Integer division rounded up is (a + b - 1) / b
961 if (m_orient
== wxHORIZONTAL
)
962 sizePerStretch
= ( size
.x
+ stretch
- 1 ) / stretch
;
964 sizePerStretch
= ( size
.y
+ stretch
- 1 ) / stretch
;
965 if (sizePerStretch
> stretchSize
)
966 stretchSize
= sizePerStretch
;
970 // Calculate overall minimum size
971 node
= m_children
.GetFirst();
974 wxSizerItem
*item
= (wxSizerItem
*) node
->Data();
976 m_stretchable
+= item
->GetOption();
978 wxSize
size( item
->CalcMin() );
979 if (item
->GetOption() != 0)
981 if (m_orient
== wxHORIZONTAL
)
982 size
.x
= stretchSize
* item
->GetOption();
984 size
.y
= stretchSize
* item
->GetOption();
987 if (m_orient
== wxHORIZONTAL
)
989 m_minWidth
+= size
.x
;
990 m_minHeight
= wxMax( m_minHeight
, size
.y
);
994 m_minHeight
+= size
.y
;
995 m_minWidth
= wxMax( m_minWidth
, size
.x
);
998 if (item
->GetOption() == 0)
1000 if (m_orient
== wxVERTICAL
)
1002 m_fixedHeight
+= size
.y
;
1003 m_fixedWidth
= wxMax( m_fixedWidth
, size
.x
);
1007 m_fixedWidth
+= size
.x
;
1008 m_fixedHeight
= wxMax( m_fixedHeight
, size
.y
);
1012 node
= node
->Next();
1015 return wxSize( m_minWidth
, m_minHeight
);
1018 //---------------------------------------------------------------------------
1020 //---------------------------------------------------------------------------
1024 wxStaticBoxSizer::wxStaticBoxSizer( wxStaticBox
*box
, int orient
)
1025 : wxBoxSizer( orient
)
1027 wxASSERT_MSG( box
, wxT("wxStaticBoxSizer needs a static box") );
1032 static void GetStaticBoxBorders(wxStaticBox
*box
,
1033 int *borderTop
, int *borderOther
)
1035 // this has to be done platform by platform as there is no way to
1036 // guess the thickness of a wxStaticBox border
1038 if ( box
->GetLabel().IsEmpty() )
1047 void wxStaticBoxSizer::RecalcSizes()
1049 int top_border
, other_border
;
1050 GetStaticBoxBorders(m_staticBox
, &top_border
, &other_border
);
1052 m_staticBox
->SetSize( m_position
.x
, m_position
.y
, m_size
.x
, m_size
.y
);
1054 wxPoint
old_pos( m_position
);
1055 m_position
.x
+= other_border
;
1056 m_position
.y
+= top_border
;
1057 wxSize
old_size( m_size
);
1058 m_size
.x
-= 2*other_border
;
1059 m_size
.y
-= top_border
+ other_border
;
1061 wxBoxSizer::RecalcSizes();
1063 m_position
= old_pos
;
1067 wxSize
wxStaticBoxSizer::CalcMin()
1069 int top_border
, other_border
;
1070 GetStaticBoxBorders(m_staticBox
, &top_border
, &other_border
);
1072 wxSize
ret( wxBoxSizer::CalcMin() );
1073 ret
.x
+= 2*other_border
;
1074 ret
.y
+= other_border
+ top_border
;
1079 #endif // wxUSE_STATBOX
1081 //---------------------------------------------------------------------------
1083 //---------------------------------------------------------------------------
1087 wxNotebookSizer::wxNotebookSizer( wxNotebook
*nb
)
1089 wxASSERT_MSG( nb
, wxT("wxNotebookSizer needs a notebook") );
1094 void wxNotebookSizer::RecalcSizes()
1096 m_notebook
->SetSize( m_position
.x
, m_position
.y
, m_size
.x
, m_size
.y
);
1099 wxSize
wxNotebookSizer::CalcMin()
1101 wxSize sizeBorder
= m_notebook
->CalcSizeFromPage(wxSize(0, 0));
1106 if (m_notebook
->GetChildren().GetCount() == 0)
1108 return wxSize(sizeBorder
.x
+ 10, sizeBorder
.y
+ 10);
1114 wxWindowList::Node
*node
= m_notebook
->GetChildren().GetFirst();
1117 wxWindow
*item
= node
->GetData();
1118 wxSizer
*itemsizer
= item
->GetSizer();
1122 wxSize
subsize( itemsizer
->CalcMin() );
1124 if (subsize
.x
> maxX
)
1126 if (subsize
.y
> maxY
)
1130 node
= node
->GetNext();
1133 return wxSize( maxX
, maxY
) + sizeBorder
;
1136 #endif // wxUSE_NOTEBOOK