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
)
358 wxSize size
= FitSize( window
);
359 window
->SetSize( size
);
362 void wxSizer::Layout()
368 void wxSizer::SetSizeHints( wxWindow
*window
)
370 wxSize size
= FitSize( window
);
371 window
->SetSizeHints( size
.x
, size
.y
);
374 wxSize
wxSizer::GetMaxWindowSize( wxWindow
*window
)
376 wxSize sizeMax
= wxGetDisplaySize();
377 // make the max size a bit smaller than the screen, a window which takes
378 // the entire screen doesn't look very nice neither
388 wxSize
wxSizer::GetMinWindowSize( wxWindow
*window
)
390 wxSize
minSize( GetMinSize() );
391 wxSize
size( window
->GetSize() );
392 wxSize
client_size( window
->GetClientSize() );
393 return wxSize( minSize
.x
+size
.x
-client_size
.x
,
394 minSize
.y
+size
.y
-client_size
.y
);
397 // Return a window size that will fit within the screens dimensions
398 wxSize
wxSizer::FitSize( wxWindow
*window
)
400 wxSize size
= GetMinWindowSize( window
);
401 wxSize sizeMax
= GetMaxWindowSize( window
);
403 if ( size
.x
> sizeMax
.x
)
405 if ( size
.y
> sizeMax
.y
)
411 void wxSizer::SetDimension( int x
, int y
, int width
, int height
)
421 wxSize
wxSizer::GetMinSize()
423 wxSize
ret( CalcMin() );
424 if (ret
.x
< m_minSize
.x
) ret
.x
= m_minSize
.x
;
425 if (ret
.y
< m_minSize
.y
) ret
.y
= m_minSize
.y
;
429 void wxSizer::DoSetMinSize( int width
, int height
)
432 m_minSize
.y
= height
;
435 bool wxSizer::DoSetItemMinSize( wxWindow
*window
, int width
, int height
)
439 wxNode
*node
= m_children
.First();
442 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
443 if (item
->GetWindow() == window
)
445 item
->SetInitSize( width
, height
);
451 node
= m_children
.First();
454 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
455 if (item
->GetSizer())
457 /* It's a sizer, so lets search recursively. */
458 if (item
->GetSizer()->DoSetItemMinSize( window
, width
, height
))
460 /* A child sizer found the requested windw, exit. */
470 bool wxSizer::DoSetItemMinSize( wxSizer
*sizer
, int width
, int height
)
474 wxNode
*node
= m_children
.First();
477 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
478 if (item
->GetSizer() == sizer
)
480 item
->GetSizer()->DoSetMinSize( width
, height
);
486 node
= m_children
.First();
489 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
490 if (item
->GetSizer())
492 /* It's a sizer, so lets search recursively. */
493 if (item
->GetSizer()->DoSetItemMinSize( sizer
, width
, height
))
495 /* A child sizer found the requested windw, exit. */
505 bool wxSizer::DoSetItemMinSize( int pos
, int width
, int height
)
507 wxNode
*node
= m_children
.Nth( pos
);
508 if (!node
) return FALSE
;
510 wxSizerItem
*item
= (wxSizerItem
*) node
->Data();
511 if (item
->GetSizer())
513 /* Sizers contains the minimal size in them, if not calculated ... */
514 item
->GetSizer()->DoSetMinSize( width
, height
);
518 /* ... whereas the minimal size of spacers and windows in stored
520 item
->SetInitSize( width
, height
);
526 //---------------------------------------------------------------------------
528 //---------------------------------------------------------------------------
530 wxGridSizer::wxGridSizer( int rows
, int cols
, int vgap
, int hgap
)
538 wxGridSizer::wxGridSizer( int cols
, int vgap
, int hgap
)
546 void wxGridSizer::RecalcSizes()
548 if (m_children
.GetCount() == 0)
551 int nitems
= m_children
.GetCount();
556 nrows
= (nitems
+ ncols
-1) / ncols
;
558 ncols
= (nitems
+ nrows
-1) / nrows
;
560 wxSize
sz( GetSize() );
561 wxPoint
pt( GetPosition() );
563 int w
= (sz
.x
- (ncols
- 1) * m_hgap
) / ncols
;
564 int h
= (sz
.y
- (nrows
- 1) * m_vgap
) / nrows
;
567 for (int c
= 0; c
< ncols
; c
++)
570 for (int r
= 0; r
< nrows
; r
++)
572 int i
= r
* ncols
+ c
;
575 wxNode
*node
= m_children
.Nth( i
);
578 SetItemBounds( (wxSizerItem
*) node
->Data(), x
, y
, w
, h
);
586 wxSize
wxGridSizer::CalcMin()
588 if (m_children
.GetCount() == 0)
589 return wxSize(10,10);
591 int nitems
= m_children
.GetCount();
596 nrows
= (nitems
+ ncols
-1) / ncols
;
598 ncols
= (nitems
+ nrows
-1) / nrows
;
600 /* Find the max width and height for any component */
604 wxNode
*node
= m_children
.First();
607 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
608 wxSize
sz( item
->CalcMin() );
609 w
= wxMax( w
, sz
.x
);
610 h
= wxMax( h
, sz
.y
);
615 return wxSize(ncols
* w
+ (ncols
-1) * m_hgap
,
616 nrows
* h
+ (nrows
-1) * m_vgap
);
619 void wxGridSizer::SetItemBounds( wxSizerItem
*item
, int x
, int y
, int w
, int h
)
622 wxSize
sz( item
->CalcMin() );
623 int flag
= item
->GetFlag();
625 if ((flag
& wxEXPAND
) || (flag
& wxSHAPED
))
631 if (flag
& wxALIGN_CENTER_HORIZONTAL
)
633 pt
.x
= x
+ (w
- sz
.x
) / 2;
635 else if (flag
& wxALIGN_RIGHT
)
637 pt
.x
= x
+ (w
- sz
.x
);
640 if (flag
& wxALIGN_CENTER_VERTICAL
)
642 pt
.y
= y
+ (h
- sz
.y
) / 2;
644 else if (flag
& wxALIGN_BOTTOM
)
646 pt
.y
= y
+ (h
- sz
.y
);
650 item
->SetDimension(pt
, sz
);
653 //---------------------------------------------------------------------------
655 //---------------------------------------------------------------------------
657 wxFlexGridSizer::wxFlexGridSizer( int rows
, int cols
, int vgap
, int hgap
)
658 : wxGridSizer( rows
, cols
, vgap
, hgap
)
660 m_rowHeights
= (int*) NULL
;
661 m_colWidths
= (int*) NULL
;
664 wxFlexGridSizer::wxFlexGridSizer( int cols
, int vgap
, int hgap
)
665 : wxGridSizer( cols
, vgap
, hgap
)
667 m_rowHeights
= (int*) NULL
;
668 m_colWidths
= (int*) NULL
;
671 wxFlexGridSizer::~wxFlexGridSizer()
674 delete[] m_rowHeights
;
676 delete[] m_colWidths
;
679 void wxFlexGridSizer::CreateArrays()
682 delete[] m_rowHeights
;
684 delete[] m_colWidths
;
686 if (m_children
.GetCount() == 0)
689 int nitems
= m_children
.GetCount();
694 nrows
= (nitems
+ ncols
-1) / ncols
;
696 ncols
= (nitems
+ nrows
-1) / nrows
;
698 m_rowHeights
= new int[nrows
];
699 m_colWidths
= new int[ncols
];
701 for (int col
= 0; col
< ncols
; col
++)
702 m_colWidths
[ col
] = 0;
703 for (int row
= 0; row
< nrows
; row
++)
704 m_rowHeights
[ row
] = 0;
707 void wxFlexGridSizer::RecalcSizes()
709 if (m_children
.GetCount() == 0)
712 int nitems
= m_children
.GetCount();
717 nrows
= (nitems
+ ncols
-1) / ncols
;
719 ncols
= (nitems
+ nrows
-1) / nrows
;
721 wxSize
sz( GetSize() );
722 wxSize
minsz( CalcMin() );
723 wxPoint
pt( GetPosition() );
727 if ((m_growableRows
.GetCount() > 0) && (sz
.y
> minsz
.y
))
729 delta
= (sz
.y
- minsz
.y
) / m_growableRows
.GetCount();
730 for (idx
= 0; idx
< m_growableRows
.GetCount(); idx
++)
731 m_rowHeights
[ m_growableRows
[idx
] ] += delta
;
734 if ((m_growableCols
.GetCount() > 0) && (sz
.x
> minsz
.x
))
736 delta
= (sz
.x
- minsz
.x
) / m_growableCols
.GetCount();
737 for (idx
= 0; idx
< m_growableCols
.GetCount(); idx
++)
738 m_colWidths
[ m_growableCols
[idx
] ] += delta
;
741 sz
= wxSize( pt
.x
+ sz
.x
, pt
.y
+ sz
.y
);
744 for (int c
= 0; c
< ncols
; c
++)
747 for (int r
= 0; r
< nrows
; r
++)
749 int i
= r
* ncols
+ c
;
752 wxNode
*node
= m_children
.Nth( i
);
755 int w
= wxMax( 0, wxMin( m_colWidths
[c
], sz
.x
- x
) );
756 int h
= wxMax( 0, wxMin( m_rowHeights
[r
], sz
.y
- y
) );
758 SetItemBounds( (wxSizerItem
*) node
->Data(), x
, y
, w
, h
);
760 y
= y
+ m_rowHeights
[r
] + m_vgap
;
762 x
= x
+ m_colWidths
[c
] + m_hgap
;
766 wxSize
wxFlexGridSizer::CalcMin()
768 if (m_children
.GetCount() == 0)
769 return wxSize(10,10);
771 int nitems
= m_children
.GetCount();
776 nrows
= (nitems
+ ncols
-1) / ncols
;
778 ncols
= (nitems
+ nrows
-1) / nrows
;
786 wxNode
*node
= m_children
.First();
789 wxSizerItem
*item
= (wxSizerItem
*)node
->Data();
790 wxSize
sz( item
->CalcMin() );
793 m_rowHeights
[ row
] = wxMax( sz
.y
, m_rowHeights
[ row
] );
794 m_colWidths
[ col
] = wxMax( sz
.x
, m_colWidths
[ col
] );
801 for (col
= 0; col
< ncols
; col
++)
802 width
+= m_colWidths
[ col
];
805 for (row
= 0; row
< nrows
; row
++)
806 height
+= m_rowHeights
[ row
];
808 return wxSize( width
+ (ncols
-1) * m_hgap
,
809 height
+ (nrows
-1) * m_vgap
);
812 void wxFlexGridSizer::AddGrowableRow( size_t idx
)
814 m_growableRows
.Add( idx
);
817 void wxFlexGridSizer::RemoveGrowableRow( size_t WXUNUSED(idx
) )
821 void wxFlexGridSizer::AddGrowableCol( size_t idx
)
823 m_growableCols
.Add( idx
);
826 void wxFlexGridSizer::RemoveGrowableCol( size_t WXUNUSED(idx
) )
830 //---------------------------------------------------------------------------
832 //---------------------------------------------------------------------------
834 wxBoxSizer::wxBoxSizer( int orient
)
839 void wxBoxSizer::RecalcSizes()
841 if (m_children
.GetCount() == 0)
848 if (m_orient
== wxHORIZONTAL
)
850 delta
= (m_size
.x
- m_fixedWidth
) / m_stretchable
;
851 extra
= (m_size
.x
- m_fixedWidth
) % m_stretchable
;
855 delta
= (m_size
.y
- m_fixedHeight
) / m_stretchable
;
856 extra
= (m_size
.y
- m_fixedHeight
) % m_stretchable
;
860 wxPoint
pt( m_position
);
862 wxNode
*node
= m_children
.GetFirst();
865 wxSizerItem
*item
= (wxSizerItem
*) node
->Data();
868 if (item
->GetOption())
869 weight
= item
->GetOption();
871 wxSize
size( item
->CalcMin() );
873 if (m_orient
== wxVERTICAL
)
875 wxCoord height
= size
.y
;
876 if (item
->GetOption())
878 height
= (delta
* weight
) + extra
;
879 extra
= 0; // only the first item will get the remainder as extra size
882 wxPoint
child_pos( pt
);
883 wxSize
child_size( wxSize( size
.x
, height
) );
885 if (item
->GetFlag() & (wxEXPAND
| wxSHAPED
))
886 child_size
.x
= m_size
.x
;
887 else if (item
->GetFlag() & wxALIGN_RIGHT
)
888 child_pos
.x
+= m_size
.x
- size
.x
;
889 else if (item
->GetFlag() & (wxCENTER
| wxALIGN_CENTER_HORIZONTAL
))
890 // XXX wxCENTER is added for backward compatibility;
891 // wxALIGN_CENTER should be used in new code
892 child_pos
.x
+= (m_size
.x
- size
.x
) / 2;
894 item
->SetDimension( child_pos
, child_size
);
900 wxCoord width
= size
.x
;
901 if (item
->GetOption())
903 width
= (delta
* weight
) + extra
;
904 extra
= 0; // only the first item will get the remainder as extra size
907 wxPoint
child_pos( pt
);
908 wxSize
child_size( wxSize(width
, size
.y
) );
910 if (item
->GetFlag() & (wxEXPAND
| wxSHAPED
))
911 child_size
.y
= m_size
.y
;
912 else if (item
->GetFlag() & wxALIGN_BOTTOM
)
913 child_pos
.y
+= m_size
.y
- size
.y
;
914 else if (item
->GetFlag() & (wxCENTER
| wxALIGN_CENTER_VERTICAL
))
915 // XXX wxCENTER is added for backward compatibility;
916 // wxALIGN_CENTER should be used in new code
917 child_pos
.y
+= (m_size
.y
- size
.y
) / 2;
919 item
->SetDimension( child_pos
, child_size
);
928 wxSize
wxBoxSizer::CalcMin()
930 if (m_children
.GetCount() == 0)
931 return wxSize(10,10);
939 wxNode
*node
= m_children
.GetFirst();
942 wxSizerItem
*item
= (wxSizerItem
*) node
->Data();
944 m_stretchable
+= item
->GetOption();
946 wxSize
size( item
->CalcMin() );
948 if (m_orient
== wxHORIZONTAL
)
950 m_minWidth
+= size
.x
;
951 m_minHeight
= wxMax( m_minHeight
, size
.y
);
955 m_minHeight
+= size
.y
;
956 m_minWidth
= wxMax( m_minWidth
, size
.x
);
959 if (item
->GetOption() == 0)
961 if (m_orient
== wxVERTICAL
)
963 m_fixedHeight
+= size
.y
;
964 m_fixedWidth
= wxMax( m_fixedWidth
, size
.x
);
968 m_fixedWidth
+= size
.x
;
969 m_fixedHeight
= wxMax( m_fixedHeight
, size
.y
);
976 return wxSize( m_minWidth
, m_minHeight
);
979 //---------------------------------------------------------------------------
981 //---------------------------------------------------------------------------
983 wxStaticBoxSizer::wxStaticBoxSizer( wxStaticBox
*box
, int orient
)
984 : wxBoxSizer( orient
)
986 wxASSERT_MSG( box
, wxT("wxStaticBoxSizer needs a static box") );
991 static void GetStaticBoxBorders(wxStaticBox
*box
,
992 int *borderTop
, int *borderOther
)
994 // this has to be done platform by platform as there is no way to
995 // guess the thickness of a wxStaticBox border
997 if ( box
->GetLabel().IsEmpty() )
1006 void wxStaticBoxSizer::RecalcSizes()
1008 int top_border
, other_border
;
1009 GetStaticBoxBorders(m_staticBox
, &top_border
, &other_border
);
1011 m_staticBox
->SetSize( m_position
.x
, m_position
.y
, m_size
.x
, m_size
.y
);
1013 wxPoint
old_pos( m_position
);
1014 m_position
.x
+= other_border
;
1015 m_position
.y
+= top_border
;
1016 wxSize
old_size( m_size
);
1017 m_size
.x
-= 2*other_border
;
1018 m_size
.y
-= top_border
+ other_border
;
1020 wxBoxSizer::RecalcSizes();
1022 m_position
= old_pos
;
1026 wxSize
wxStaticBoxSizer::CalcMin()
1028 int top_border
, other_border
;
1029 GetStaticBoxBorders(m_staticBox
, &top_border
, &other_border
);
1031 wxSize
ret( wxBoxSizer::CalcMin() );
1032 ret
.x
+= 2*other_border
;
1033 ret
.y
+= other_border
+ top_border
;
1038 //---------------------------------------------------------------------------
1040 //---------------------------------------------------------------------------
1044 wxNotebookSizer::wxNotebookSizer( wxNotebook
*nb
)
1046 wxASSERT_MSG( nb
, wxT("wxNotebookSizer needs a notebook") );
1051 void wxNotebookSizer::RecalcSizes()
1053 m_notebook
->SetSize( m_position
.x
, m_position
.y
, m_size
.x
, m_size
.y
);
1056 wxSize
wxNotebookSizer::CalcMin()
1058 // This will have to be done platform by platform
1059 // as there is no way to guess the thickness of
1060 // the wxNotebook tabs and border.
1064 if ((m_notebook
->HasFlag(wxNB_RIGHT
)) ||
1065 (m_notebook
->HasFlag(wxNB_LEFT
)))
1067 borderX
+= 90; // improvements later..
1071 borderY
+= 40; // improvements later..
1074 if (m_notebook
->GetChildren().GetCount() == 0)
1075 return wxSize(borderX
+ 10, borderY
+ 10);
1080 wxWindowList::Node
*node
= m_notebook
->GetChildren().GetFirst();
1083 wxWindow
*item
= node
->GetData();
1084 wxSizer
*itemsizer
= item
->GetSizer();
1088 wxSize
subsize( itemsizer
->CalcMin() );
1090 if (subsize
.x
> maxX
) maxX
= subsize
.x
;
1091 if (subsize
.y
> maxY
) maxY
= subsize
.y
;
1094 node
= node
->GetNext();
1097 return wxSize( borderX
+ maxX
, borderY
+ maxY
);
1100 #endif // wxUSE_NOTEBOOK