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();
137 // if we have to preserve aspect ratio _AND_ this is
138 // the first-time calculation, consider ret to be initial size
139 if ((m_flag
& wxSHAPED
) && !m_ratio
)
144 if ( IsWindow() && (m_flag
& wxADJUST_MINSIZE
) )
146 // check if the best (minimal, in fact) window size hadn't changed
147 // by chance: this may happen for, e.g. static text if its label
149 wxSize size
= m_window
->GetBestSize();
150 if ( size
.x
> m_minSize
.x
)
151 m_minSize
.x
= size
.x
;
152 if ( size
.y
> m_minSize
.y
)
153 m_minSize
.y
= size
.y
;
163 if (m_flag
& wxNORTH
)
165 if (m_flag
& wxSOUTH
)
171 void wxSizerItem::SetDimension( wxPoint pos
, wxSize size
)
173 if (m_flag
& wxSHAPED
)
175 // adjust aspect ratio
176 int rwidth
= (int) (size
.y
* m_ratio
);
180 int rheight
= (int) (size
.x
/ m_ratio
);
181 // add vertical space
182 if (m_flag
& wxALIGN_CENTER_VERTICAL
)
183 pos
.y
+= (size
.y
- rheight
) / 2;
184 else if (m_flag
& wxALIGN_BOTTOM
)
185 pos
.y
+= (size
.y
- rheight
);
186 // use reduced dimensions
189 else if (rwidth
< size
.x
)
191 // add horizontal space
192 if (m_flag
& wxALIGN_CENTER_HORIZONTAL
)
193 pos
.x
+= (size
.x
- rwidth
) / 2;
194 else if (m_flag
& wxALIGN_RIGHT
)
195 pos
.x
+= (size
.x
- rwidth
);
200 // This is what GetPosition() returns. Since we calculate
201 // borders afterwards, GetPosition() will be the left/top
202 // corner of the surrounding border.
214 if (m_flag
& wxNORTH
)
219 if (m_flag
& wxSOUTH
)
225 m_sizer
->SetDimension( pos
.x
, pos
.y
, size
.x
, size
.y
);
228 m_window
->SetSize( pos
.x
, pos
.y
, size
.x
, size
.y
, wxSIZE_ALLOW_MINUS_ONE
);
233 bool wxSizerItem::IsWindow()
235 return (m_window
!= NULL
);
238 bool wxSizerItem::IsSizer()
240 return (m_sizer
!= NULL
);
243 bool wxSizerItem::IsSpacer()
245 return (m_window
== NULL
) && (m_sizer
== NULL
);
248 //---------------------------------------------------------------------------
250 //---------------------------------------------------------------------------
254 m_children
.DeleteContents( TRUE
);
263 void wxSizer::Add( wxWindow
*window
, int option
, int flag
, int border
, wxObject
* userData
)
265 m_children
.Append( new wxSizerItem( window
, option
, flag
, border
, userData
) );
268 void wxSizer::Add( wxSizer
*sizer
, int option
, int flag
, int border
, wxObject
* userData
)
270 m_children
.Append( new wxSizerItem( sizer
, option
, flag
, border
, userData
) );
273 void wxSizer::Add( int width
, int height
, int option
, int flag
, int border
, wxObject
* userData
)
275 m_children
.Append( new wxSizerItem( width
, height
, option
, flag
, border
, userData
) );
278 void wxSizer::Prepend( wxWindow
*window
, int option
, int flag
, int border
, wxObject
* userData
)
280 m_children
.Insert( new wxSizerItem( window
, option
, flag
, border
, userData
) );
283 void wxSizer::Prepend( wxSizer
*sizer
, int option
, int flag
, int border
, wxObject
* userData
)
285 m_children
.Insert( new wxSizerItem( sizer
, option
, flag
, border
, userData
) );
288 void wxSizer::Prepend( int width
, int height
, int option
, int flag
, int border
, wxObject
* userData
)
290 m_children
.Insert( new wxSizerItem( width
, height
, option
, flag
, border
, userData
) );
293 void wxSizer::Insert( int before
, wxWindow
*window
, int option
, int flag
, int border
, wxObject
* userData
)
295 m_children
.Insert( before
, new wxSizerItem( window
, option
, flag
, border
, userData
) );
298 void wxSizer::Insert( int before
, wxSizer
*sizer
, int option
, int flag
, int border
, wxObject
* userData
)
300 m_children
.Insert( before
, new wxSizerItem( sizer
, option
, flag
, border
, userData
) );
303 void wxSizer::Insert( int before
, int width
, int height
, int option
, int flag
, int border
, wxObject
* userData
)
305 m_children
.Insert( before
, new wxSizerItem( width
, height
, option
, flag
, border
, userData
) );
308 bool wxSizer::Remove( wxWindow
*window
)
312 wxNode
*node
= m_children
.First();
315 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
316 if (item
->GetWindow() == window
)
318 m_children
.DeleteNode( node
);
327 bool wxSizer::Remove( wxSizer
*sizer
)
331 wxNode
*node
= m_children
.First();
334 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
335 if (item
->GetSizer() == sizer
)
337 m_children
.DeleteNode( node
);
346 bool wxSizer::Remove( int pos
)
348 wxNode
*node
= m_children
.Nth( pos
);
349 if (!node
) return FALSE
;
351 m_children
.DeleteNode( node
);
356 void wxSizer::Fit( wxWindow
*window
)
359 if (window
->IsTopLevel())
360 size
= FitSize( window
);
362 size
= GetMinWindowSize( window
);
364 window
->SetSize( size
);
367 void wxSizer::Layout()
373 void wxSizer::SetSizeHints( wxWindow
*window
)
375 wxSize size
= FitSize( window
);
376 window
->SetSizeHints( size
.x
, size
.y
);
379 wxSize
wxSizer::GetMaxWindowSize( wxWindow
*window
)
381 wxSize sizeMax
= wxGetDisplaySize();
382 // make the max size a bit smaller than the screen, a window which takes
383 // the entire screen doesn't look very nice neither
393 wxSize
wxSizer::GetMinWindowSize( wxWindow
*window
)
395 wxSize
minSize( GetMinSize() );
396 wxSize
size( window
->GetSize() );
397 wxSize
client_size( window
->GetClientSize() );
398 return wxSize( minSize
.x
+size
.x
-client_size
.x
,
399 minSize
.y
+size
.y
-client_size
.y
);
402 // Return a window size that will fit within the screens dimensions
403 wxSize
wxSizer::FitSize( wxWindow
*window
)
405 wxSize size
= GetMinWindowSize( window
);
406 wxSize sizeMax
= GetMaxWindowSize( window
);
408 if ( size
.x
> sizeMax
.x
)
410 if ( size
.y
> sizeMax
.y
)
416 void wxSizer::SetDimension( int x
, int y
, int width
, int height
)
426 wxSize
wxSizer::GetMinSize()
428 wxSize
ret( CalcMin() );
429 if (ret
.x
< m_minSize
.x
) ret
.x
= m_minSize
.x
;
430 if (ret
.y
< m_minSize
.y
) ret
.y
= m_minSize
.y
;
434 void wxSizer::DoSetMinSize( int width
, int height
)
437 m_minSize
.y
= height
;
440 bool wxSizer::DoSetItemMinSize( wxWindow
*window
, int width
, int height
)
444 wxNode
*node
= m_children
.First();
447 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
448 if (item
->GetWindow() == window
)
450 item
->SetInitSize( width
, height
);
456 node
= m_children
.First();
459 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
460 if (item
->GetSizer())
462 /* It's a sizer, so lets search recursively. */
463 if (item
->GetSizer()->DoSetItemMinSize( window
, width
, height
))
465 /* A child sizer found the requested windw, exit. */
475 bool wxSizer::DoSetItemMinSize( wxSizer
*sizer
, int width
, int height
)
479 wxNode
*node
= m_children
.First();
482 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
483 if (item
->GetSizer() == sizer
)
485 item
->GetSizer()->DoSetMinSize( width
, height
);
491 node
= m_children
.First();
494 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
495 if (item
->GetSizer())
497 /* It's a sizer, so lets search recursively. */
498 if (item
->GetSizer()->DoSetItemMinSize( sizer
, width
, height
))
500 /* A child sizer found the requested windw, exit. */
510 bool wxSizer::DoSetItemMinSize( int pos
, int width
, int height
)
512 wxNode
*node
= m_children
.Nth( pos
);
513 if (!node
) return FALSE
;
515 wxSizerItem
*item
= (wxSizerItem
*) node
->Data();
516 if (item
->GetSizer())
518 /* Sizers contains the minimal size in them, if not calculated ... */
519 item
->GetSizer()->DoSetMinSize( width
, height
);
523 /* ... whereas the minimal size of spacers and windows in stored
525 item
->SetInitSize( width
, height
);
531 //---------------------------------------------------------------------------
533 //---------------------------------------------------------------------------
535 wxGridSizer::wxGridSizer( int rows
, int cols
, int vgap
, int hgap
)
543 wxGridSizer::wxGridSizer( int cols
, int vgap
, int hgap
)
551 void wxGridSizer::RecalcSizes()
553 if (m_children
.GetCount() == 0)
556 int nitems
= m_children
.GetCount();
561 nrows
= (nitems
+ ncols
-1) / ncols
;
563 ncols
= (nitems
+ nrows
-1) / nrows
;
565 wxSize
sz( GetSize() );
566 wxPoint
pt( GetPosition() );
568 int w
= (sz
.x
- (ncols
- 1) * m_hgap
) / ncols
;
569 int h
= (sz
.y
- (nrows
- 1) * m_vgap
) / nrows
;
572 for (int c
= 0; c
< ncols
; c
++)
575 for (int r
= 0; r
< nrows
; r
++)
577 int i
= r
* ncols
+ c
;
580 wxNode
*node
= m_children
.Nth( i
);
583 SetItemBounds( (wxSizerItem
*) node
->Data(), x
, y
, w
, h
);
591 wxSize
wxGridSizer::CalcMin()
593 if (m_children
.GetCount() == 0)
594 return wxSize(10,10);
596 int nitems
= m_children
.GetCount();
601 nrows
= (nitems
+ ncols
-1) / ncols
;
603 ncols
= (nitems
+ nrows
-1) / nrows
;
605 /* Find the max width and height for any component */
609 wxNode
*node
= m_children
.First();
612 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
613 wxSize
sz( item
->CalcMin() );
614 w
= wxMax( w
, sz
.x
);
615 h
= wxMax( h
, sz
.y
);
620 return wxSize(ncols
* w
+ (ncols
-1) * m_hgap
,
621 nrows
* h
+ (nrows
-1) * m_vgap
);
624 void wxGridSizer::SetItemBounds( wxSizerItem
*item
, int x
, int y
, int w
, int h
)
627 wxSize
sz( item
->CalcMin() );
628 int flag
= item
->GetFlag();
630 if ((flag
& wxEXPAND
) || (flag
& wxSHAPED
))
636 if (flag
& wxALIGN_CENTER_HORIZONTAL
)
638 pt
.x
= x
+ (w
- sz
.x
) / 2;
640 else if (flag
& wxALIGN_RIGHT
)
642 pt
.x
= x
+ (w
- sz
.x
);
645 if (flag
& wxALIGN_CENTER_VERTICAL
)
647 pt
.y
= y
+ (h
- sz
.y
) / 2;
649 else if (flag
& wxALIGN_BOTTOM
)
651 pt
.y
= y
+ (h
- sz
.y
);
655 item
->SetDimension(pt
, sz
);
658 //---------------------------------------------------------------------------
660 //---------------------------------------------------------------------------
662 wxFlexGridSizer::wxFlexGridSizer( int rows
, int cols
, int vgap
, int hgap
)
663 : wxGridSizer( rows
, cols
, vgap
, hgap
)
665 m_rowHeights
= (int*) NULL
;
666 m_colWidths
= (int*) NULL
;
669 wxFlexGridSizer::wxFlexGridSizer( int cols
, int vgap
, int hgap
)
670 : wxGridSizer( cols
, vgap
, hgap
)
672 m_rowHeights
= (int*) NULL
;
673 m_colWidths
= (int*) NULL
;
676 wxFlexGridSizer::~wxFlexGridSizer()
679 delete[] m_rowHeights
;
681 delete[] m_colWidths
;
684 void wxFlexGridSizer::CreateArrays()
687 delete[] m_rowHeights
;
689 delete[] m_colWidths
;
691 if (m_children
.GetCount() == 0)
694 int nitems
= m_children
.GetCount();
699 nrows
= (nitems
+ ncols
-1) / ncols
;
701 ncols
= (nitems
+ nrows
-1) / nrows
;
703 m_rowHeights
= new int[nrows
];
704 m_colWidths
= new int[ncols
];
706 for (int col
= 0; col
< ncols
; col
++)
707 m_colWidths
[ col
] = 0;
708 for (int row
= 0; row
< nrows
; row
++)
709 m_rowHeights
[ row
] = 0;
712 void wxFlexGridSizer::RecalcSizes()
714 if (m_children
.GetCount() == 0)
717 int nitems
= m_children
.GetCount();
722 nrows
= (nitems
+ ncols
-1) / ncols
;
724 ncols
= (nitems
+ nrows
-1) / nrows
;
726 wxSize
sz( GetSize() );
727 wxSize
minsz( CalcMin() );
728 wxPoint
pt( GetPosition() );
732 if ((m_growableRows
.GetCount() > 0) && (sz
.y
> minsz
.y
))
734 delta
= (sz
.y
- minsz
.y
) / m_growableRows
.GetCount();
735 for (idx
= 0; idx
< m_growableRows
.GetCount(); idx
++)
736 m_rowHeights
[ m_growableRows
[idx
] ] += delta
;
739 if ((m_growableCols
.GetCount() > 0) && (sz
.x
> minsz
.x
))
741 delta
= (sz
.x
- minsz
.x
) / m_growableCols
.GetCount();
742 for (idx
= 0; idx
< m_growableCols
.GetCount(); idx
++)
743 m_colWidths
[ m_growableCols
[idx
] ] += delta
;
746 sz
= wxSize( pt
.x
+ sz
.x
, pt
.y
+ sz
.y
);
749 for (int c
= 0; c
< ncols
; c
++)
752 for (int r
= 0; r
< nrows
; r
++)
754 int i
= r
* ncols
+ c
;
757 wxNode
*node
= m_children
.Nth( i
);
760 int w
= wxMax( 0, wxMin( m_colWidths
[c
], sz
.x
- x
) );
761 int h
= wxMax( 0, wxMin( m_rowHeights
[r
], sz
.y
- y
) );
763 SetItemBounds( (wxSizerItem
*) node
->Data(), x
, y
, w
, h
);
765 y
= y
+ m_rowHeights
[r
] + m_vgap
;
767 x
= x
+ m_colWidths
[c
] + m_hgap
;
771 wxSize
wxFlexGridSizer::CalcMin()
773 if (m_children
.GetCount() == 0)
774 return wxSize(10,10);
776 int nitems
= m_children
.GetCount();
781 nrows
= (nitems
+ ncols
-1) / ncols
;
783 ncols
= (nitems
+ nrows
-1) / nrows
;
791 wxNode
*node
= m_children
.First();
794 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
795 wxSize
sz( item
->CalcMin() );
798 m_rowHeights
[ row
] = wxMax( sz
.y
, m_rowHeights
[ row
] );
799 m_colWidths
[ col
] = wxMax( sz
.x
, m_colWidths
[ col
] );
806 for (col
= 0; col
< ncols
; col
++)
807 width
+= m_colWidths
[ col
];
810 for (row
= 0; row
< nrows
; row
++)
811 height
+= m_rowHeights
[ row
];
813 return wxSize( width
+ (ncols
-1) * m_hgap
,
814 height
+ (nrows
-1) * m_vgap
);
817 void wxFlexGridSizer::AddGrowableRow( size_t idx
)
819 m_growableRows
.Add( idx
);
822 void wxFlexGridSizer::RemoveGrowableRow( size_t WXUNUSED(idx
) )
826 void wxFlexGridSizer::AddGrowableCol( size_t idx
)
828 m_growableCols
.Add( idx
);
831 void wxFlexGridSizer::RemoveGrowableCol( size_t WXUNUSED(idx
) )
835 //---------------------------------------------------------------------------
837 //---------------------------------------------------------------------------
839 wxBoxSizer::wxBoxSizer( int orient
)
844 void wxBoxSizer::RecalcSizes()
846 if (m_children
.GetCount() == 0)
853 if (m_orient
== wxHORIZONTAL
)
855 delta
= (m_size
.x
- m_fixedWidth
) / m_stretchable
;
856 extra
= (m_size
.x
- m_fixedWidth
) % m_stretchable
;
860 delta
= (m_size
.y
- m_fixedHeight
) / m_stretchable
;
861 extra
= (m_size
.y
- m_fixedHeight
) % m_stretchable
;
865 wxPoint
pt( m_position
);
867 wxNode
*node
= m_children
.GetFirst();
870 wxSizerItem
*item
= (wxSizerItem
*) node
->Data();
873 if (item
->GetOption())
874 weight
= item
->GetOption();
876 wxSize
size( item
->CalcMin() );
878 if (m_orient
== wxVERTICAL
)
880 wxCoord height
= size
.y
;
881 if (item
->GetOption())
883 height
= (delta
* weight
) + extra
;
884 extra
= 0; // only the first item will get the remainder as extra size
887 wxPoint
child_pos( pt
);
888 wxSize
child_size( wxSize( size
.x
, height
) );
890 if (item
->GetFlag() & (wxEXPAND
| wxSHAPED
))
891 child_size
.x
= m_size
.x
;
892 else if (item
->GetFlag() & wxALIGN_RIGHT
)
893 child_pos
.x
+= m_size
.x
- size
.x
;
894 else if (item
->GetFlag() & (wxCENTER
| wxALIGN_CENTER_HORIZONTAL
))
895 // XXX wxCENTER is added for backward compatibility;
896 // wxALIGN_CENTER should be used in new code
897 child_pos
.x
+= (m_size
.x
- size
.x
) / 2;
899 item
->SetDimension( child_pos
, child_size
);
905 wxCoord width
= size
.x
;
906 if (item
->GetOption())
908 width
= (delta
* weight
) + extra
;
909 extra
= 0; // only the first item will get the remainder as extra size
912 wxPoint
child_pos( pt
);
913 wxSize
child_size( wxSize(width
, size
.y
) );
915 if (item
->GetFlag() & (wxEXPAND
| wxSHAPED
))
916 child_size
.y
= m_size
.y
;
917 else if (item
->GetFlag() & wxALIGN_BOTTOM
)
918 child_pos
.y
+= m_size
.y
- size
.y
;
919 else if (item
->GetFlag() & (wxCENTER
| wxALIGN_CENTER_VERTICAL
))
920 // XXX wxCENTER is added for backward compatibility;
921 // wxALIGN_CENTER should be used in new code
922 child_pos
.y
+= (m_size
.y
- size
.y
) / 2;
924 item
->SetDimension( child_pos
, child_size
);
933 wxSize
wxBoxSizer::CalcMin()
935 if (m_children
.GetCount() == 0)
936 return wxSize(10,10);
944 wxNode
*node
= m_children
.GetFirst();
947 wxSizerItem
*item
= (wxSizerItem
*) node
->Data();
949 m_stretchable
+= item
->GetOption();
951 wxSize
size( item
->CalcMin() );
953 if (m_orient
== wxHORIZONTAL
)
955 m_minWidth
+= size
.x
;
956 m_minHeight
= wxMax( m_minHeight
, size
.y
);
960 m_minHeight
+= size
.y
;
961 m_minWidth
= wxMax( m_minWidth
, size
.x
);
964 if (item
->GetOption() == 0)
966 if (m_orient
== wxVERTICAL
)
968 m_fixedHeight
+= size
.y
;
969 m_fixedWidth
= wxMax( m_fixedWidth
, size
.x
);
973 m_fixedWidth
+= size
.x
;
974 m_fixedHeight
= wxMax( m_fixedHeight
, size
.y
);
981 return wxSize( m_minWidth
, m_minHeight
);
984 //---------------------------------------------------------------------------
986 //---------------------------------------------------------------------------
988 wxStaticBoxSizer::wxStaticBoxSizer( wxStaticBox
*box
, int orient
)
989 : wxBoxSizer( orient
)
991 wxASSERT_MSG( box
, wxT("wxStaticBoxSizer needs a static box") );
996 static void GetStaticBoxBorders(wxStaticBox
*box
,
997 int *borderTop
, int *borderOther
)
999 // this has to be done platform by platform as there is no way to
1000 // guess the thickness of a wxStaticBox border
1002 if ( box
->GetLabel().IsEmpty() )
1011 void wxStaticBoxSizer::RecalcSizes()
1013 int top_border
, other_border
;
1014 GetStaticBoxBorders(m_staticBox
, &top_border
, &other_border
);
1016 m_staticBox
->SetSize( m_position
.x
, m_position
.y
, m_size
.x
, m_size
.y
);
1018 wxPoint
old_pos( m_position
);
1019 m_position
.x
+= other_border
;
1020 m_position
.y
+= top_border
;
1021 wxSize
old_size( m_size
);
1022 m_size
.x
-= 2*other_border
;
1023 m_size
.y
-= top_border
+ other_border
;
1025 wxBoxSizer::RecalcSizes();
1027 m_position
= old_pos
;
1031 wxSize
wxStaticBoxSizer::CalcMin()
1033 int top_border
, other_border
;
1034 GetStaticBoxBorders(m_staticBox
, &top_border
, &other_border
);
1036 wxSize
ret( wxBoxSizer::CalcMin() );
1037 ret
.x
+= 2*other_border
;
1038 ret
.y
+= other_border
+ top_border
;
1043 //---------------------------------------------------------------------------
1045 //---------------------------------------------------------------------------
1049 wxNotebookSizer::wxNotebookSizer( wxNotebook
*nb
)
1051 wxASSERT_MSG( nb
, wxT("wxNotebookSizer needs a notebook") );
1056 void wxNotebookSizer::RecalcSizes()
1058 m_notebook
->SetSize( m_position
.x
, m_position
.y
, m_size
.x
, m_size
.y
);
1061 wxSize
wxNotebookSizer::CalcMin()
1063 // This will have to be done platform by platform
1064 // as there is no way to guess the thickness of
1065 // the wxNotebook tabs and border.
1069 if ((m_notebook
->HasFlag(wxNB_RIGHT
)) ||
1070 (m_notebook
->HasFlag(wxNB_LEFT
)))
1072 borderX
+= 90; // improvements later..
1076 borderY
+= 40; // improvements later..
1079 if (m_notebook
->GetChildren().GetCount() == 0)
1080 return wxSize(borderX
+ 10, borderY
+ 10);
1085 wxWindowList::Node
*node
= m_notebook
->GetChildren().GetFirst();
1088 wxWindow
*item
= node
->GetData();
1089 wxSizer
*itemsizer
= item
->GetSizer();
1093 wxSize
subsize( itemsizer
->CalcMin() );
1095 if (subsize
.x
> maxX
) maxX
= subsize
.x
;
1096 if (subsize
.y
> maxY
) maxY
= subsize
.y
;
1099 node
= node
->GetNext();
1102 return wxSize( borderX
+ maxX
, borderY
+ maxY
);
1105 #endif // wxUSE_NOTEBOOK