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 // Sorry, but this bit is wrong -- it makes a window that should just be
387 // able to fit onto the screen, not fit on the screen. -- JACS
389 // Make the max size a bit smaller than the visible portion of
390 // the screen. A window which takes the entire screen doesn't
391 // look very nice either
402 wxSize
wxSizer::GetMinWindowSize( wxWindow
*window
)
404 wxSize
minSize( GetMinSize() );
405 wxSize
size( window
->GetSize() );
406 wxSize
client_size( window
->GetClientSize() );
407 return wxSize( minSize
.x
+size
.x
-client_size
.x
,
408 minSize
.y
+size
.y
-client_size
.y
);
411 // Return a window size that will fit within the screens dimensions
412 wxSize
wxSizer::FitSize( wxWindow
*window
)
414 wxSize size
= GetMinWindowSize( window
);
415 wxSize sizeMax
= GetMaxWindowSize( window
);
417 if ( size
.x
> sizeMax
.x
)
419 if ( size
.y
> sizeMax
.y
)
425 void wxSizer::SetDimension( int x
, int y
, int width
, int height
)
435 wxSize
wxSizer::GetMinSize()
437 wxSize
ret( CalcMin() );
438 if (ret
.x
< m_minSize
.x
) ret
.x
= m_minSize
.x
;
439 if (ret
.y
< m_minSize
.y
) ret
.y
= m_minSize
.y
;
443 void wxSizer::DoSetMinSize( int width
, int height
)
446 m_minSize
.y
= height
;
449 bool wxSizer::DoSetItemMinSize( wxWindow
*window
, int width
, int height
)
453 wxNode
*node
= m_children
.First();
456 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
457 if (item
->GetWindow() == window
)
459 item
->SetInitSize( width
, height
);
465 node
= m_children
.First();
468 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
469 if (item
->GetSizer())
471 /* It's a sizer, so lets search recursively. */
472 if (item
->GetSizer()->DoSetItemMinSize( window
, width
, height
))
474 /* A child sizer found the requested windw, exit. */
484 bool wxSizer::DoSetItemMinSize( wxSizer
*sizer
, int width
, int height
)
488 wxNode
*node
= m_children
.First();
491 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
492 if (item
->GetSizer() == sizer
)
494 item
->GetSizer()->DoSetMinSize( width
, height
);
500 node
= m_children
.First();
503 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
504 if (item
->GetSizer())
506 /* It's a sizer, so lets search recursively. */
507 if (item
->GetSizer()->DoSetItemMinSize( sizer
, width
, height
))
509 /* A child sizer found the requested windw, exit. */
519 bool wxSizer::DoSetItemMinSize( int pos
, int width
, int height
)
521 wxNode
*node
= m_children
.Nth( pos
);
522 if (!node
) return FALSE
;
524 wxSizerItem
*item
= (wxSizerItem
*) node
->Data();
525 if (item
->GetSizer())
527 /* Sizers contains the minimal size in them, if not calculated ... */
528 item
->GetSizer()->DoSetMinSize( width
, height
);
532 /* ... whereas the minimal size of spacers and windows in stored
534 item
->SetInitSize( width
, height
);
540 //---------------------------------------------------------------------------
542 //---------------------------------------------------------------------------
544 wxGridSizer::wxGridSizer( int rows
, int cols
, int vgap
, int hgap
)
552 wxGridSizer::wxGridSizer( int cols
, int vgap
, int hgap
)
560 void wxGridSizer::RecalcSizes()
562 if (m_children
.GetCount() == 0)
565 int nitems
= m_children
.GetCount();
570 nrows
= (nitems
+ ncols
-1) / ncols
;
572 ncols
= (nitems
+ nrows
-1) / nrows
;
574 wxSize
sz( GetSize() );
575 wxPoint
pt( GetPosition() );
577 int w
= (sz
.x
- (ncols
- 1) * m_hgap
) / ncols
;
578 int h
= (sz
.y
- (nrows
- 1) * m_vgap
) / nrows
;
581 for (int c
= 0; c
< ncols
; c
++)
584 for (int r
= 0; r
< nrows
; r
++)
586 int i
= r
* ncols
+ c
;
589 wxNode
*node
= m_children
.Nth( i
);
592 SetItemBounds( (wxSizerItem
*) node
->Data(), x
, y
, w
, h
);
600 wxSize
wxGridSizer::CalcMin()
602 if (m_children
.GetCount() == 0)
603 return wxSize(10,10);
605 int nitems
= m_children
.GetCount();
610 nrows
= (nitems
+ ncols
-1) / ncols
;
612 ncols
= (nitems
+ nrows
-1) / nrows
;
614 /* Find the max width and height for any component */
618 wxNode
*node
= m_children
.First();
621 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
622 wxSize
sz( item
->CalcMin() );
623 w
= wxMax( w
, sz
.x
);
624 h
= wxMax( h
, sz
.y
);
629 return wxSize(ncols
* w
+ (ncols
-1) * m_hgap
,
630 nrows
* h
+ (nrows
-1) * m_vgap
);
633 void wxGridSizer::SetItemBounds( wxSizerItem
*item
, int x
, int y
, int w
, int h
)
636 wxSize
sz( item
->CalcMin() );
637 int flag
= item
->GetFlag();
639 if ((flag
& wxEXPAND
) || (flag
& wxSHAPED
))
645 if (flag
& wxALIGN_CENTER_HORIZONTAL
)
647 pt
.x
= x
+ (w
- sz
.x
) / 2;
649 else if (flag
& wxALIGN_RIGHT
)
651 pt
.x
= x
+ (w
- sz
.x
);
654 if (flag
& wxALIGN_CENTER_VERTICAL
)
656 pt
.y
= y
+ (h
- sz
.y
) / 2;
658 else if (flag
& wxALIGN_BOTTOM
)
660 pt
.y
= y
+ (h
- sz
.y
);
664 item
->SetDimension(pt
, sz
);
667 //---------------------------------------------------------------------------
669 //---------------------------------------------------------------------------
671 wxFlexGridSizer::wxFlexGridSizer( int rows
, int cols
, int vgap
, int hgap
)
672 : wxGridSizer( rows
, cols
, vgap
, hgap
)
674 m_rowHeights
= (int*) NULL
;
675 m_colWidths
= (int*) NULL
;
678 wxFlexGridSizer::wxFlexGridSizer( int cols
, int vgap
, int hgap
)
679 : wxGridSizer( cols
, vgap
, hgap
)
681 m_rowHeights
= (int*) NULL
;
682 m_colWidths
= (int*) NULL
;
685 wxFlexGridSizer::~wxFlexGridSizer()
688 delete[] m_rowHeights
;
690 delete[] m_colWidths
;
693 void wxFlexGridSizer::CreateArrays()
696 delete[] m_rowHeights
;
698 delete[] m_colWidths
;
700 if (m_children
.GetCount() == 0)
703 int nitems
= m_children
.GetCount();
708 nrows
= (nitems
+ ncols
-1) / ncols
;
710 ncols
= (nitems
+ nrows
-1) / nrows
;
712 m_rowHeights
= new int[nrows
];
713 m_colWidths
= new int[ncols
];
715 for (int col
= 0; col
< ncols
; col
++)
716 m_colWidths
[ col
] = 0;
717 for (int row
= 0; row
< nrows
; row
++)
718 m_rowHeights
[ row
] = 0;
721 void wxFlexGridSizer::RecalcSizes()
723 if (m_children
.GetCount() == 0)
726 int nitems
= m_children
.GetCount();
731 nrows
= (nitems
+ ncols
-1) / ncols
;
733 ncols
= (nitems
+ nrows
-1) / nrows
;
735 wxSize
sz( GetSize() );
736 wxSize
minsz( CalcMin() );
737 wxPoint
pt( GetPosition() );
741 if ((m_growableRows
.GetCount() > 0) && (sz
.y
> minsz
.y
))
743 delta
= (sz
.y
- minsz
.y
) / m_growableRows
.GetCount();
744 for (idx
= 0; idx
< m_growableRows
.GetCount(); idx
++)
745 m_rowHeights
[ m_growableRows
[idx
] ] += delta
;
748 if ((m_growableCols
.GetCount() > 0) && (sz
.x
> minsz
.x
))
750 delta
= (sz
.x
- minsz
.x
) / m_growableCols
.GetCount();
751 for (idx
= 0; idx
< m_growableCols
.GetCount(); idx
++)
752 m_colWidths
[ m_growableCols
[idx
] ] += delta
;
755 sz
= wxSize( pt
.x
+ sz
.x
, pt
.y
+ sz
.y
);
758 for (int c
= 0; c
< ncols
; c
++)
761 for (int r
= 0; r
< nrows
; r
++)
763 int i
= r
* ncols
+ c
;
766 wxNode
*node
= m_children
.Nth( i
);
769 int w
= wxMax( 0, wxMin( m_colWidths
[c
], sz
.x
- x
) );
770 int h
= wxMax( 0, wxMin( m_rowHeights
[r
], sz
.y
- y
) );
772 SetItemBounds( (wxSizerItem
*) node
->Data(), x
, y
, w
, h
);
774 y
= y
+ m_rowHeights
[r
] + m_vgap
;
776 x
= x
+ m_colWidths
[c
] + m_hgap
;
780 wxSize
wxFlexGridSizer::CalcMin()
782 if (m_children
.GetCount() == 0)
783 return wxSize(10,10);
785 int nitems
= m_children
.GetCount();
790 nrows
= (nitems
+ ncols
-1) / ncols
;
792 ncols
= (nitems
+ nrows
-1) / nrows
;
800 wxNode
*node
= m_children
.First();
803 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
804 wxSize
sz( item
->CalcMin() );
807 m_rowHeights
[ row
] = wxMax( sz
.y
, m_rowHeights
[ row
] );
808 m_colWidths
[ col
] = wxMax( sz
.x
, m_colWidths
[ col
] );
815 for (col
= 0; col
< ncols
; col
++)
816 width
+= m_colWidths
[ col
];
819 for (row
= 0; row
< nrows
; row
++)
820 height
+= m_rowHeights
[ row
];
822 return wxSize( width
+ (ncols
-1) * m_hgap
,
823 height
+ (nrows
-1) * m_vgap
);
826 void wxFlexGridSizer::AddGrowableRow( size_t idx
)
828 m_growableRows
.Add( idx
);
831 void wxFlexGridSizer::RemoveGrowableRow( size_t WXUNUSED(idx
) )
835 void wxFlexGridSizer::AddGrowableCol( size_t idx
)
837 m_growableCols
.Add( idx
);
840 void wxFlexGridSizer::RemoveGrowableCol( size_t WXUNUSED(idx
) )
844 //---------------------------------------------------------------------------
846 //---------------------------------------------------------------------------
848 wxBoxSizer::wxBoxSizer( int orient
)
853 void wxBoxSizer::RecalcSizes()
855 if (m_children
.GetCount() == 0)
862 if (m_orient
== wxHORIZONTAL
)
864 delta
= (m_size
.x
- m_fixedWidth
) / m_stretchable
;
865 extra
= (m_size
.x
- m_fixedWidth
) % m_stretchable
;
869 delta
= (m_size
.y
- m_fixedHeight
) / m_stretchable
;
870 extra
= (m_size
.y
- m_fixedHeight
) % m_stretchable
;
874 wxPoint
pt( m_position
);
876 wxNode
*node
= m_children
.GetFirst();
879 wxSizerItem
*item
= (wxSizerItem
*) node
->Data();
882 if (item
->GetOption())
883 weight
= item
->GetOption();
885 wxSize
size( item
->CalcMin() );
887 if (m_orient
== wxVERTICAL
)
889 wxCoord height
= size
.y
;
890 if (item
->GetOption())
892 height
= (delta
* weight
) + extra
;
893 extra
= 0; // only the first item will get the remainder as extra size
896 wxPoint
child_pos( pt
);
897 wxSize
child_size( wxSize( size
.x
, height
) );
899 if (item
->GetFlag() & (wxEXPAND
| wxSHAPED
))
900 child_size
.x
= m_size
.x
;
901 else if (item
->GetFlag() & wxALIGN_RIGHT
)
902 child_pos
.x
+= m_size
.x
- size
.x
;
903 else if (item
->GetFlag() & (wxCENTER
| wxALIGN_CENTER_HORIZONTAL
))
904 // XXX wxCENTER is added for backward compatibility;
905 // wxALIGN_CENTER should be used in new code
906 child_pos
.x
+= (m_size
.x
- size
.x
) / 2;
908 item
->SetDimension( child_pos
, child_size
);
914 wxCoord width
= size
.x
;
915 if (item
->GetOption())
917 width
= (delta
* weight
) + extra
;
918 extra
= 0; // only the first item will get the remainder as extra size
921 wxPoint
child_pos( pt
);
922 wxSize
child_size( wxSize(width
, size
.y
) );
924 if (item
->GetFlag() & (wxEXPAND
| wxSHAPED
))
925 child_size
.y
= m_size
.y
;
926 else if (item
->GetFlag() & wxALIGN_BOTTOM
)
927 child_pos
.y
+= m_size
.y
- size
.y
;
928 else if (item
->GetFlag() & (wxCENTER
| wxALIGN_CENTER_VERTICAL
))
929 // XXX wxCENTER is added for backward compatibility;
930 // wxALIGN_CENTER should be used in new code
931 child_pos
.y
+= (m_size
.y
- size
.y
) / 2;
933 item
->SetDimension( child_pos
, child_size
);
942 wxSize
wxBoxSizer::CalcMin()
944 if (m_children
.GetCount() == 0)
945 return wxSize(10,10);
953 // Find how long each stretch unit needs to be
955 wxNode
*node
= m_children
.GetFirst();
958 wxSizerItem
*item
= (wxSizerItem
*) node
->Data();
959 if (item
->GetOption() != 0)
961 int stretch
= item
->GetOption();
962 wxSize
size( item
->CalcMin() );
964 // Integer division rounded up is (a + b - 1) / b
965 if (m_orient
== wxHORIZONTAL
)
966 sizePerStretch
= ( size
.x
+ stretch
- 1 ) / stretch
;
968 sizePerStretch
= ( size
.y
+ stretch
- 1 ) / stretch
;
969 if (sizePerStretch
> stretchSize
)
970 stretchSize
= sizePerStretch
;
974 // Calculate overall minimum size
975 node
= m_children
.GetFirst();
978 wxSizerItem
*item
= (wxSizerItem
*) node
->Data();
980 m_stretchable
+= item
->GetOption();
982 wxSize
size( item
->CalcMin() );
983 if (item
->GetOption() != 0)
985 if (m_orient
== wxHORIZONTAL
)
986 size
.x
= stretchSize
* item
->GetOption();
988 size
.y
= stretchSize
* item
->GetOption();
991 if (m_orient
== wxHORIZONTAL
)
993 m_minWidth
+= size
.x
;
994 m_minHeight
= wxMax( m_minHeight
, size
.y
);
998 m_minHeight
+= size
.y
;
999 m_minWidth
= wxMax( m_minWidth
, size
.x
);
1002 if (item
->GetOption() == 0)
1004 if (m_orient
== wxVERTICAL
)
1006 m_fixedHeight
+= size
.y
;
1007 m_fixedWidth
= wxMax( m_fixedWidth
, size
.x
);
1011 m_fixedWidth
+= size
.x
;
1012 m_fixedHeight
= wxMax( m_fixedHeight
, size
.y
);
1016 node
= node
->Next();
1019 return wxSize( m_minWidth
, m_minHeight
);
1022 //---------------------------------------------------------------------------
1024 //---------------------------------------------------------------------------
1028 wxStaticBoxSizer::wxStaticBoxSizer( wxStaticBox
*box
, int orient
)
1029 : wxBoxSizer( orient
)
1031 wxASSERT_MSG( box
, wxT("wxStaticBoxSizer needs a static box") );
1036 static void GetStaticBoxBorders(wxStaticBox
*box
,
1037 int *borderTop
, int *borderOther
)
1039 // this has to be done platform by platform as there is no way to
1040 // guess the thickness of a wxStaticBox border
1042 if ( box
->GetLabel().IsEmpty() )
1051 void wxStaticBoxSizer::RecalcSizes()
1053 int top_border
, other_border
;
1054 GetStaticBoxBorders(m_staticBox
, &top_border
, &other_border
);
1056 m_staticBox
->SetSize( m_position
.x
, m_position
.y
, m_size
.x
, m_size
.y
);
1058 wxPoint
old_pos( m_position
);
1059 m_position
.x
+= other_border
;
1060 m_position
.y
+= top_border
;
1061 wxSize
old_size( m_size
);
1062 m_size
.x
-= 2*other_border
;
1063 m_size
.y
-= top_border
+ other_border
;
1065 wxBoxSizer::RecalcSizes();
1067 m_position
= old_pos
;
1071 wxSize
wxStaticBoxSizer::CalcMin()
1073 int top_border
, other_border
;
1074 GetStaticBoxBorders(m_staticBox
, &top_border
, &other_border
);
1076 wxSize
ret( wxBoxSizer::CalcMin() );
1077 ret
.x
+= 2*other_border
;
1078 ret
.y
+= other_border
+ top_border
;
1083 #endif // wxUSE_STATBOX
1085 //---------------------------------------------------------------------------
1087 //---------------------------------------------------------------------------
1091 wxNotebookSizer::wxNotebookSizer( wxNotebook
*nb
)
1093 wxASSERT_MSG( nb
, wxT("wxNotebookSizer needs a notebook") );
1098 void wxNotebookSizer::RecalcSizes()
1100 m_notebook
->SetSize( m_position
.x
, m_position
.y
, m_size
.x
, m_size
.y
);
1103 wxSize
wxNotebookSizer::CalcMin()
1105 wxSize sizeBorder
= m_notebook
->CalcSizeFromPage(wxSize(0, 0));
1110 if (m_notebook
->GetChildren().GetCount() == 0)
1112 return wxSize(sizeBorder
.x
+ 10, sizeBorder
.y
+ 10);
1118 wxWindowList::Node
*node
= m_notebook
->GetChildren().GetFirst();
1121 wxWindow
*item
= node
->GetData();
1122 wxSizer
*itemsizer
= item
->GetSizer();
1126 wxSize
subsize( itemsizer
->CalcMin() );
1128 if (subsize
.x
> maxX
)
1130 if (subsize
.y
> maxY
)
1134 node
= node
->GetNext();
1137 return wxSize( maxX
, maxY
) + sizeBorder
;
1140 #endif // wxUSE_NOTEBOOK