1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/sizer.cpp
3 // Purpose: provide new wxSizer class for layout
4 // Author: Robert Roebling and Robin Dunn, contributions by
5 // Dirk Holtwick, Ron Lee
6 // Modified by: Ron Lee
9 // Copyright: (c) Robin Dunn, Robert Roebling
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 // For compilers that support precompilation, includes "wx.h".
14 #include "wx/wxprec.h"
21 #include "wx/string.h"
28 #include "wx/statbox.h"
29 #include "wx/settings.h"
30 #include "wx/listimpl.cpp"
32 #if WXWIN_COMPATIBILITY_2_4
33 #include "wx/notebook.h"
36 //---------------------------------------------------------------------------
38 IMPLEMENT_CLASS(wxSizerItem
, wxObject
)
39 IMPLEMENT_CLASS(wxSizer
, wxObject
)
40 IMPLEMENT_CLASS(wxGridSizer
, wxSizer
)
41 IMPLEMENT_CLASS(wxFlexGridSizer
, wxGridSizer
)
42 IMPLEMENT_CLASS(wxBoxSizer
, wxSizer
)
44 IMPLEMENT_CLASS(wxStaticBoxSizer
, wxBoxSizer
)
47 IMPLEMENT_CLASS(wxStdDialogButtonSizer
, wxBoxSizer
)
50 WX_DEFINE_EXPORTED_LIST( wxSizerItemList
)
85 // ----------------------------------------------------------------------------
87 // ----------------------------------------------------------------------------
89 void wxSizerItem::Init(const wxSizerFlags
& flags
)
93 m_proportion
= flags
.GetProportion();
94 m_flag
= flags
.GetFlags();
95 m_border
= flags
.GetBorderInPixels();
98 wxSizerItem::wxSizerItem()
110 void wxSizerItem::SetWindow(wxWindow
*window
)
112 wxCHECK_RET( window
, _T("NULL window in wxSizerItem::SetWindow()") );
114 m_kind
= Item_Window
;
117 // window doesn't become smaller than its initial size, whatever happens
118 m_minSize
= window
->GetSize();
120 if ( m_flag
& wxFIXED_MINSIZE
)
121 window
->SetMinSize(m_minSize
);
123 // aspect ratio calculated from initial size
127 wxSizerItem::wxSizerItem(wxWindow
*window
,
132 : m_proportion(proportion
),
141 void wxSizerItem::SetSizer(wxSizer
*sizer
)
147 wxSizerItem::wxSizerItem(wxSizer
*sizer
,
152 : m_proportion(proportion
),
160 // m_minSize is set later
164 void wxSizerItem::SetSpacer(const wxSize
& size
)
166 m_kind
= Item_Spacer
;
167 m_spacer
= new wxSizerSpacer(size
);
172 wxSizerItem::wxSizerItem(int width
,
178 : m_minSize(width
, height
), // minimal size is the initial size
179 m_proportion(proportion
),
184 SetSpacer(width
, height
);
187 wxSizerItem::~wxSizerItem()
197 m_window
->SetContainingSizer(NULL
);
210 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
214 wxSize
wxSizerItem::GetSpacer() const
217 if ( m_kind
== Item_Spacer
)
218 size
= m_spacer
->GetSize();
224 wxSize
wxSizerItem::GetSize() const
233 ret
= m_window
->GetSize();
237 ret
= m_sizer
->GetSize();
241 ret
= m_spacer
->GetSize();
246 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
253 if (m_flag
& wxNORTH
)
255 if (m_flag
& wxSOUTH
)
261 wxSize
wxSizerItem::CalcMin()
265 m_minSize
= m_sizer
->GetMinSize();
267 // if we have to preserve aspect ratio _AND_ this is
268 // the first-time calculation, consider ret to be initial size
269 if ( (m_flag
& wxSHAPED
) && wxIsNullDouble(m_ratio
) )
272 else if ( IsWindow() )
274 // Since the size of the window may change during runtime, we
275 // should use the current minimal/best size.
276 m_minSize
= m_window
->GetBestFittingSize();
279 return GetMinSizeWithBorder();
282 wxSize
wxSizerItem::GetMinSizeWithBorder() const
284 wxSize ret
= m_minSize
;
290 if (m_flag
& wxNORTH
)
292 if (m_flag
& wxSOUTH
)
299 void wxSizerItem::SetDimension( const wxPoint
& pos_
, const wxSize
& size_
)
303 if (m_flag
& wxSHAPED
)
305 // adjust aspect ratio
306 int rwidth
= (int) (size
.y
* m_ratio
);
310 int rheight
= (int) (size
.x
/ m_ratio
);
311 // add vertical space
312 if (m_flag
& wxALIGN_CENTER_VERTICAL
)
313 pos
.y
+= (size
.y
- rheight
) / 2;
314 else if (m_flag
& wxALIGN_BOTTOM
)
315 pos
.y
+= (size
.y
- rheight
);
316 // use reduced dimensions
319 else if (rwidth
< size
.x
)
321 // add horizontal space
322 if (m_flag
& wxALIGN_CENTER_HORIZONTAL
)
323 pos
.x
+= (size
.x
- rwidth
) / 2;
324 else if (m_flag
& wxALIGN_RIGHT
)
325 pos
.x
+= (size
.x
- rwidth
);
330 // This is what GetPosition() returns. Since we calculate
331 // borders afterwards, GetPosition() will be the left/top
332 // corner of the surrounding border.
344 if (m_flag
& wxNORTH
)
349 if (m_flag
& wxSOUTH
)
354 m_rect
= wxRect(pos
, size
);
359 wxFAIL_MSG( _T("can't set size of uninitialized sizer item") );
363 m_window
->SetSize(pos
.x
, pos
.y
, size
.x
, size
.y
,
364 wxSIZE_ALLOW_MINUS_ONE
);
368 m_sizer
->SetDimension(pos
.x
, pos
.y
, size
.x
, size
.y
);
372 m_spacer
->SetSize(size
);
377 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
381 void wxSizerItem::DeleteWindows()
390 //We are deleting the window from this sizer - normally
391 //the window destroys the sizer associated with it,
392 //which might destroy this, which we don't want
393 m_window
->SetContainingSizer(NULL
);
395 //Putting this after the switch will result in a spacer
396 //not being deleted properly on destruction
401 m_sizer
->DeleteWindows();
406 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
411 void wxSizerItem::Show( bool show
)
416 wxFAIL_MSG( _T("can't show uninitialized sizer item") );
420 m_window
->Show(show
);
428 m_spacer
->Show(show
);
433 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
437 bool wxSizerItem::IsShown() const
442 // we may be called from CalcMin(), just return false so that we're
447 return m_window
->IsShown();
450 // arbitrarily decide that if at least one of our elements is
451 // shown, so are we (this arbitrariness is the reason for
452 // deprecating this function)
454 for ( wxSizerItemList::compatibility_iterator
455 node
= m_sizer
->GetChildren().GetFirst();
457 node
= node
->GetNext() )
459 if ( node
->GetData()->IsShown() )
466 return m_spacer
->IsShown();
470 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
476 #if WXWIN_COMPATIBILITY_2_6
477 void wxSizerItem::SetOption( int option
)
479 SetProportion( option
);
482 int wxSizerItem::GetOption() const
484 return GetProportion();
486 #endif // WXWIN_COMPATIBILITY_2_6
489 //---------------------------------------------------------------------------
491 //---------------------------------------------------------------------------
495 WX_CLEAR_LIST(wxSizerItemList
, m_children
);
498 wxSizerItem
* wxSizer::Insert( size_t index
, wxSizerItem
*item
)
500 m_children
.Insert( index
, item
);
502 if ( item
->GetWindow() )
503 item
->GetWindow()->SetContainingSizer( this );
508 #if WXWIN_COMPATIBILITY_2_6
509 bool wxSizer::Remove( wxWindow
*window
)
511 return Detach( window
);
513 #endif // WXWIN_COMPATIBILITY_2_6
515 bool wxSizer::Remove( wxSizer
*sizer
)
517 wxASSERT_MSG( sizer
, _T("Removing NULL sizer") );
519 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
522 wxSizerItem
*item
= node
->GetData();
524 if (item
->GetSizer() == sizer
)
527 m_children
.Erase( node
);
531 node
= node
->GetNext();
537 bool wxSizer::Remove( int index
)
539 wxCHECK_MSG( index
>= 0 && (size_t)index
< m_children
.GetCount(),
541 _T("Remove index is out of range") );
543 wxSizerItemList::compatibility_iterator node
= m_children
.Item( index
);
545 wxCHECK_MSG( node
, false, _T("Failed to find child node") );
547 wxSizerItem
*item
= node
->GetData();
549 if ( item
->IsWindow() )
550 item
->GetWindow()->SetContainingSizer( NULL
);
553 m_children
.Erase( node
);
557 bool wxSizer::Detach( wxSizer
*sizer
)
559 wxASSERT_MSG( sizer
, _T("Detaching NULL sizer") );
561 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
564 wxSizerItem
*item
= node
->GetData();
566 if (item
->GetSizer() == sizer
)
570 m_children
.Erase( node
);
573 node
= node
->GetNext();
579 bool wxSizer::Detach( wxWindow
*window
)
581 wxASSERT_MSG( window
, _T("Detaching NULL window") );
583 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
586 wxSizerItem
*item
= node
->GetData();
588 if (item
->GetWindow() == window
)
590 item
->GetWindow()->SetContainingSizer( NULL
);
592 m_children
.Erase( node
);
595 node
= node
->GetNext();
601 bool wxSizer::Detach( int index
)
603 wxCHECK_MSG( index
>= 0 && (size_t)index
< m_children
.GetCount(),
605 _T("Detach index is out of range") );
607 wxSizerItemList::compatibility_iterator node
= m_children
.Item( index
);
609 wxCHECK_MSG( node
, false, _T("Failed to find child node") );
611 wxSizerItem
*item
= node
->GetData();
613 if ( item
->IsSizer() )
615 else if ( item
->IsWindow() )
616 item
->GetWindow()->SetContainingSizer( NULL
);
619 m_children
.Erase( node
);
623 void wxSizer::Clear( bool delete_windows
)
625 // First clear the ContainingSizer pointers
626 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
629 wxSizerItem
*item
= node
->GetData();
631 if (item
->IsWindow())
632 item
->GetWindow()->SetContainingSizer( NULL
);
633 node
= node
->GetNext();
636 // Destroy the windows if needed
640 // Now empty the list
641 WX_CLEAR_LIST(wxSizerItemList
, m_children
);
644 void wxSizer::DeleteWindows()
646 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
649 wxSizerItem
*item
= node
->GetData();
651 item
->DeleteWindows();
652 node
= node
->GetNext();
656 wxSize
wxSizer::Fit( wxWindow
*window
)
658 wxSize
size(window
->IsTopLevel() ? FitSize(window
)
659 : GetMinWindowSize(window
));
661 window
->SetSize( size
);
666 void wxSizer::FitInside( wxWindow
*window
)
669 if (window
->IsTopLevel())
670 size
= VirtualFitSize( window
);
672 size
= GetMinClientSize( window
);
674 window
->SetVirtualSize( size
);
677 void wxSizer::Layout()
679 // (re)calculates minimums needed for each item and other preparations
683 // Applies the layout and repositions/resizes the items
687 void wxSizer::SetSizeHints( wxWindow
*window
)
689 // Preserve the window's max size hints, but set the
690 // lower bound according to the sizer calculations.
692 wxSize size
= Fit( window
);
694 window
->SetSizeHints( size
.x
,
696 window
->GetMaxWidth(),
697 window
->GetMaxHeight() );
700 void wxSizer::SetVirtualSizeHints( wxWindow
*window
)
702 // Preserve the window's max size hints, but set the
703 // lower bound according to the sizer calculations.
706 wxSize
size( window
->GetVirtualSize() );
707 window
->SetVirtualSizeHints( size
.x
,
709 window
->GetMaxWidth(),
710 window
->GetMaxHeight() );
713 wxSize
wxSizer::GetMaxWindowSize( wxWindow
*window
) const
715 return window
->GetMaxSize();
718 wxSize
wxSizer::GetMinWindowSize( wxWindow
*window
)
720 wxSize
minSize( GetMinSize() );
721 wxSize
size( window
->GetSize() );
722 wxSize
client_size( window
->GetClientSize() );
724 return wxSize( minSize
.x
+size
.x
-client_size
.x
,
725 minSize
.y
+size
.y
-client_size
.y
);
728 // TODO on mac we need a function that determines how much free space this
729 // min size contains, in order to make sure that we have 20 pixels of free
730 // space around the controls
732 // Return a window size that will fit within the screens dimensions
733 wxSize
wxSizer::FitSize( wxWindow
*window
)
735 wxSize size
= GetMinWindowSize( window
);
736 wxSize sizeMax
= GetMaxWindowSize( window
);
738 // Limit the size if sizeMax != wxDefaultSize
740 if ( size
.x
> sizeMax
.x
&& sizeMax
.x
!= wxDefaultCoord
)
742 if ( size
.y
> sizeMax
.y
&& sizeMax
.y
!= wxDefaultCoord
)
748 wxSize
wxSizer::GetMaxClientSize( wxWindow
*window
) const
750 wxSize
maxSize( window
->GetMaxSize() );
752 if ( maxSize
!= wxDefaultSize
)
754 wxSize
size( window
->GetSize() );
755 wxSize
client_size( window
->GetClientSize() );
757 return wxSize( maxSize
.x
+ client_size
.x
- size
.x
,
758 maxSize
.y
+ client_size
.y
- size
.y
);
761 return wxDefaultSize
;
764 wxSize
wxSizer::GetMinClientSize( wxWindow
*WXUNUSED(window
) )
766 return GetMinSize(); // Already returns client size.
769 wxSize
wxSizer::VirtualFitSize( wxWindow
*window
)
771 wxSize size
= GetMinClientSize( window
);
772 wxSize sizeMax
= GetMaxClientSize( window
);
774 // Limit the size if sizeMax != wxDefaultSize
776 if ( size
.x
> sizeMax
.x
&& sizeMax
.x
!= wxDefaultCoord
)
778 if ( size
.y
> sizeMax
.y
&& sizeMax
.y
!= wxDefaultCoord
)
784 void wxSizer::SetDimension( int x
, int y
, int width
, int height
)
793 wxSize
wxSizer::GetMinSize()
795 wxSize
ret( CalcMin() );
796 if (ret
.x
< m_minSize
.x
) ret
.x
= m_minSize
.x
;
797 if (ret
.y
< m_minSize
.y
) ret
.y
= m_minSize
.y
;
801 void wxSizer::DoSetMinSize( int width
, int height
)
804 m_minSize
.y
= height
;
807 bool wxSizer::DoSetItemMinSize( wxWindow
*window
, int width
, int height
)
809 wxASSERT_MSG( window
, _T("SetMinSize for NULL window") );
811 // Is it our immediate child?
813 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
816 wxSizerItem
*item
= node
->GetData();
818 if (item
->GetWindow() == window
)
820 item
->SetMinSize( width
, height
);
823 node
= node
->GetNext();
826 // No? Search any subsizers we own then
828 node
= m_children
.GetFirst();
831 wxSizerItem
*item
= node
->GetData();
833 if ( item
->GetSizer() &&
834 item
->GetSizer()->DoSetItemMinSize( window
, width
, height
) )
836 // A child sizer found the requested windw, exit.
839 node
= node
->GetNext();
845 bool wxSizer::DoSetItemMinSize( wxSizer
*sizer
, int width
, int height
)
847 wxASSERT_MSG( sizer
, _T("SetMinSize for NULL sizer") );
849 // Is it our immediate child?
851 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
854 wxSizerItem
*item
= node
->GetData();
856 if (item
->GetSizer() == sizer
)
858 item
->GetSizer()->DoSetMinSize( width
, height
);
861 node
= node
->GetNext();
864 // No? Search any subsizers we own then
866 node
= m_children
.GetFirst();
869 wxSizerItem
*item
= node
->GetData();
871 if ( item
->GetSizer() &&
872 item
->GetSizer()->DoSetItemMinSize( sizer
, width
, height
) )
874 // A child found the requested sizer, exit.
877 node
= node
->GetNext();
883 bool wxSizer::DoSetItemMinSize( size_t index
, int width
, int height
)
885 wxSizerItemList::compatibility_iterator node
= m_children
.Item( index
);
887 wxCHECK_MSG( node
, false, _T("Failed to find child node") );
889 wxSizerItem
*item
= node
->GetData();
891 if (item
->GetSizer())
893 // Sizers contains the minimal size in them, if not calculated ...
894 item
->GetSizer()->DoSetMinSize( width
, height
);
898 // ... but the minimal size of spacers and windows is stored via the item
899 item
->SetMinSize( width
, height
);
905 wxSizerItem
* wxSizer::GetItem( wxWindow
*window
, bool recursive
)
907 wxASSERT_MSG( window
, _T("GetItem for NULL window") );
909 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
912 wxSizerItem
*item
= node
->GetData();
914 if (item
->GetWindow() == window
)
918 else if (recursive
&& item
->IsSizer())
920 wxSizerItem
*subitem
= item
->GetSizer()->GetItem( window
, true );
925 node
= node
->GetNext();
931 wxSizerItem
* wxSizer::GetItem( wxSizer
*sizer
, bool recursive
)
933 wxASSERT_MSG( sizer
, _T("GetItem for NULL sizer") );
935 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
938 wxSizerItem
*item
= node
->GetData();
940 if (item
->GetSizer() == sizer
)
944 else if (recursive
&& item
->IsSizer())
946 wxSizerItem
*subitem
= item
->GetSizer()->GetItem( sizer
, true );
951 node
= node
->GetNext();
957 wxSizerItem
* wxSizer::GetItem( size_t index
)
959 wxCHECK_MSG( index
< m_children
.GetCount(),
961 _T("GetItem index is out of range") );
963 return m_children
.Item( index
)->GetData();
966 bool wxSizer::Show( wxWindow
*window
, bool show
, bool recursive
)
968 wxSizerItem
*item
= GetItem( window
, recursive
);
979 bool wxSizer::Show( wxSizer
*sizer
, bool show
, bool recursive
)
981 wxSizerItem
*item
= GetItem( sizer
, recursive
);
992 bool wxSizer::Show( size_t index
, bool show
)
994 wxSizerItem
*item
= GetItem( index
);
1005 void wxSizer::ShowItems( bool show
)
1007 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1010 node
->GetData()->Show( show
);
1011 node
= node
->GetNext();
1015 bool wxSizer::IsShown( wxWindow
*window
) const
1017 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1020 wxSizerItem
*item
= node
->GetData();
1022 if (item
->GetWindow() == window
)
1024 return item
->IsShown();
1026 node
= node
->GetNext();
1029 wxFAIL_MSG( _T("IsShown failed to find sizer item") );
1034 bool wxSizer::IsShown( wxSizer
*sizer
) const
1036 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1039 wxSizerItem
*item
= node
->GetData();
1041 if (item
->GetSizer() == sizer
)
1043 return item
->IsShown();
1045 node
= node
->GetNext();
1048 wxFAIL_MSG( _T("IsShown failed to find sizer item") );
1053 bool wxSizer::IsShown( size_t index
) const
1055 wxCHECK_MSG( index
< m_children
.GetCount(),
1057 _T("IsShown index is out of range") );
1059 return m_children
.Item( index
)->GetData()->IsShown();
1063 //---------------------------------------------------------------------------
1065 //---------------------------------------------------------------------------
1067 wxGridSizer::wxGridSizer( int rows
, int cols
, int vgap
, int hgap
)
1068 : m_rows( ( cols
== 0 && rows
== 0 ) ? 1 : rows
)
1075 wxGridSizer::wxGridSizer( int cols
, int vgap
, int hgap
)
1076 : m_rows( cols
== 0 ? 1 : 0 )
1083 int wxGridSizer::CalcRowsCols(int& nrows
, int& ncols
) const
1085 int nitems
= m_children
.GetCount();
1091 nrows
= (nitems
+ m_cols
- 1) / m_cols
;
1095 ncols
= (nitems
+ m_rows
- 1) / m_rows
;
1098 else // 0 columns, 0 rows?
1100 wxFAIL_MSG( _T("grid sizer must have either rows or columns fixed") );
1109 void wxGridSizer::RecalcSizes()
1111 int nitems
, nrows
, ncols
;
1112 if ( (nitems
= CalcRowsCols(nrows
, ncols
)) == 0 )
1115 wxSize
sz( GetSize() );
1116 wxPoint
pt( GetPosition() );
1118 int w
= (sz
.x
- (ncols
- 1) * m_hgap
) / ncols
;
1119 int h
= (sz
.y
- (nrows
- 1) * m_vgap
) / nrows
;
1122 for (int c
= 0; c
< ncols
; c
++)
1125 for (int r
= 0; r
< nrows
; r
++)
1127 int i
= r
* ncols
+ c
;
1130 wxSizerItemList::compatibility_iterator node
= m_children
.Item( i
);
1132 wxASSERT_MSG( node
, _T("Failed to find SizerItemList node") );
1134 SetItemBounds( node
->GetData(), x
, y
, w
, h
);
1142 wxSize
wxGridSizer::CalcMin()
1145 if ( CalcRowsCols(nrows
, ncols
) == 0 )
1146 return wxSize(10, 10);
1148 // Find the max width and height for any component
1152 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1155 wxSizerItem
*item
= node
->GetData();
1156 wxSize
sz( item
->CalcMin() );
1158 w
= wxMax( w
, sz
.x
);
1159 h
= wxMax( h
, sz
.y
);
1161 node
= node
->GetNext();
1164 return wxSize( ncols
* w
+ (ncols
-1) * m_hgap
,
1165 nrows
* h
+ (nrows
-1) * m_vgap
);
1168 void wxGridSizer::SetItemBounds( wxSizerItem
*item
, int x
, int y
, int w
, int h
)
1171 wxSize
sz( item
->GetMinSizeWithBorder() );
1172 int flag
= item
->GetFlag();
1174 if ((flag
& wxEXPAND
) || (flag
& wxSHAPED
))
1180 if (flag
& wxALIGN_CENTER_HORIZONTAL
)
1182 pt
.x
= x
+ (w
- sz
.x
) / 2;
1184 else if (flag
& wxALIGN_RIGHT
)
1186 pt
.x
= x
+ (w
- sz
.x
);
1189 if (flag
& wxALIGN_CENTER_VERTICAL
)
1191 pt
.y
= y
+ (h
- sz
.y
) / 2;
1193 else if (flag
& wxALIGN_BOTTOM
)
1195 pt
.y
= y
+ (h
- sz
.y
);
1199 item
->SetDimension(pt
, sz
);
1202 //---------------------------------------------------------------------------
1204 //---------------------------------------------------------------------------
1206 wxFlexGridSizer::wxFlexGridSizer( int rows
, int cols
, int vgap
, int hgap
)
1207 : wxGridSizer( rows
, cols
, vgap
, hgap
),
1208 m_flexDirection(wxBOTH
),
1209 m_growMode(wxFLEX_GROWMODE_SPECIFIED
)
1213 wxFlexGridSizer::wxFlexGridSizer( int cols
, int vgap
, int hgap
)
1214 : wxGridSizer( cols
, vgap
, hgap
),
1215 m_flexDirection(wxBOTH
),
1216 m_growMode(wxFLEX_GROWMODE_SPECIFIED
)
1220 wxFlexGridSizer::~wxFlexGridSizer()
1224 void wxFlexGridSizer::RecalcSizes()
1226 int nitems
, nrows
, ncols
;
1227 if ( (nitems
= CalcRowsCols(nrows
, ncols
)) == 0 )
1230 wxPoint
pt( GetPosition() );
1231 wxSize
sz( GetSize() );
1233 AdjustForGrowables(sz
, m_calculatedMinSize
, nrows
, ncols
);
1235 sz
= wxSize( pt
.x
+ sz
.x
, pt
.y
+ sz
.y
);
1238 for (int c
= 0; c
< ncols
; c
++)
1241 for (int r
= 0; r
< nrows
; r
++)
1243 int i
= r
* ncols
+ c
;
1246 wxSizerItemList::compatibility_iterator node
= m_children
.Item( i
);
1248 wxASSERT_MSG( node
, _T("Failed to find node") );
1250 int w
= wxMax( 0, wxMin( m_colWidths
[c
], sz
.x
- x
) );
1251 int h
= wxMax( 0, wxMin( m_rowHeights
[r
], sz
.y
- y
) );
1253 SetItemBounds( node
->GetData(), x
, y
, w
, h
);
1255 if (m_rowHeights
[r
] != -1)
1256 y
= y
+ m_rowHeights
[r
] + m_vgap
;
1258 if (m_colWidths
[c
] != -1)
1259 x
= x
+ m_colWidths
[c
] + m_hgap
;
1263 wxSize
wxFlexGridSizer::CalcMin()
1269 // Number of rows/columns can change as items are added or removed.
1270 if ( !CalcRowsCols(nrows
, ncols
) )
1271 return wxSize(10, 10);
1273 m_rowHeights
.SetCount(nrows
);
1274 m_colWidths
.SetCount(ncols
);
1276 // We have to recalcuate the sizes in case the item minimum size has
1277 // changed since the previous layout, or the item has been hidden using
1278 // wxSizer::Show(). If all the items in a row/column are hidden, the final
1279 // dimension of the row/column will be -1, indicating that the column
1280 // itself is hidden.
1281 for( s
= m_rowHeights
.GetCount(), i
= 0; i
< s
; ++i
)
1282 m_rowHeights
[ i
] = -1;
1283 for( s
= m_colWidths
.GetCount(), i
= 0; i
< s
; ++i
)
1284 m_colWidths
[ i
] = -1;
1286 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1291 wxSizerItem
*item
= node
->GetData();
1292 if ( item
->IsShown() )
1294 wxSize
sz( item
->CalcMin() );
1295 int row
= i
/ ncols
;
1296 int col
= i
% ncols
;
1298 m_rowHeights
[ row
] = wxMax( wxMax( 0, sz
.y
), m_rowHeights
[ row
] );
1299 m_colWidths
[ col
] = wxMax( wxMax( 0, sz
.x
), m_colWidths
[ col
] );
1302 node
= node
->GetNext();
1306 AdjustForFlexDirection();
1308 // Sum total minimum size, including gaps between rows/columns.
1309 // -1 is used as a magic number meaning empty column.
1311 for (int col
= 0; col
< ncols
; col
++)
1312 if ( m_colWidths
[ col
] != -1 )
1313 width
+= m_colWidths
[ col
] + m_hgap
;
1318 for (int row
= 0; row
< nrows
; row
++)
1319 if ( m_rowHeights
[ row
] != -1 )
1320 height
+= m_rowHeights
[ row
] + m_vgap
;
1324 m_calculatedMinSize
= wxSize( width
, height
);
1325 return m_calculatedMinSize
;
1328 void wxFlexGridSizer::AdjustForFlexDirection()
1330 // the logic in CalcMin works when we resize flexibly in both directions
1331 // but maybe this is not the case
1332 if ( m_flexDirection
!= wxBOTH
)
1334 // select the array corresponding to the direction in which we do *not*
1336 wxArrayInt
& array
= m_flexDirection
== wxVERTICAL
? m_colWidths
1339 const size_t count
= array
.GetCount();
1341 // find the largest value in this array
1345 for ( n
= 0; n
< count
; ++n
)
1347 if ( array
[n
] > largest
)
1351 // and now fill it with the largest value
1352 for ( n
= 0; n
< count
; ++n
)
1360 void wxFlexGridSizer::AdjustForGrowables(const wxSize
& sz
, const wxSize
& minsz
,
1361 int nrows
, int ncols
)
1363 // what to do with the rows? by default, resize them proportionally
1364 if ( sz
.y
> minsz
.y
&& ( (m_flexDirection
& wxVERTICAL
) || (m_growMode
== wxFLEX_GROWMODE_SPECIFIED
) ) )
1366 int sum_proportions
= 0;
1367 int growable_space
= 0;
1370 for (idx
= 0; idx
< m_growableRows
.GetCount(); idx
++)
1372 // Since the number of rows/columns can change as items are
1373 // inserted/deleted, we need to verify at runtime that the
1374 // requested growable rows/columns are still valid.
1375 if (m_growableRows
[idx
] >= nrows
)
1378 // If all items in a row/column are hidden, that row/column will
1379 // have a dimension of -1. This causes the row/column to be
1380 // hidden completely.
1381 if (m_rowHeights
[ m_growableRows
[idx
] ] == -1)
1383 sum_proportions
+= m_growableRowsProportions
[idx
];
1384 growable_space
+= m_rowHeights
[ m_growableRows
[idx
] ];
1390 for (idx
= 0; idx
< m_growableRows
.GetCount(); idx
++)
1392 if (m_growableRows
[idx
] >= nrows
)
1394 if (m_rowHeights
[ m_growableRows
[idx
] ] == -1)
1395 m_rowHeights
[ m_growableRows
[idx
] ] = 0;
1398 int delta
= (sz
.y
- minsz
.y
);
1399 if (sum_proportions
== 0)
1400 delta
= (delta
/num
) + m_rowHeights
[ m_growableRows
[idx
] ];
1402 delta
= ((delta
+growable_space
)*m_growableRowsProportions
[idx
]) / sum_proportions
;
1403 m_rowHeights
[ m_growableRows
[idx
] ] = delta
;
1408 else if ( (m_growMode
== wxFLEX_GROWMODE_ALL
) && (sz
.y
> minsz
.y
) )
1410 // rounding problem?
1411 for ( int row
= 0; row
< nrows
; ++row
)
1412 m_rowHeights
[ row
] = sz
.y
/ nrows
;
1415 // the same logic as above but for the columns
1416 if ( sz
.x
> minsz
.x
&& ( (m_flexDirection
& wxHORIZONTAL
) || (m_growMode
== wxFLEX_GROWMODE_SPECIFIED
) ) )
1418 int sum_proportions
= 0;
1419 int growable_space
= 0;
1422 for (idx
= 0; idx
< m_growableCols
.GetCount(); idx
++)
1424 // Since the number of rows/columns can change as items are
1425 // inserted/deleted, we need to verify at runtime that the
1426 // requested growable rows/columns are still valid.
1427 if (m_growableCols
[idx
] >= ncols
)
1430 // If all items in a row/column are hidden, that row/column will
1431 // have a dimension of -1. This causes the column to be hidden
1433 if (m_colWidths
[ m_growableCols
[idx
] ] == -1)
1435 sum_proportions
+= m_growableColsProportions
[idx
];
1436 growable_space
+= m_colWidths
[ m_growableCols
[idx
] ];
1442 for (idx
= 0; idx
< m_growableCols
.GetCount(); idx
++)
1444 if (m_growableCols
[idx
] >= ncols
)
1446 if (m_colWidths
[ m_growableCols
[idx
] ] == -1)
1447 m_colWidths
[ m_growableCols
[idx
] ] = 0;
1450 int delta
= (sz
.x
- minsz
.x
);
1451 if (sum_proportions
== 0)
1452 delta
= (delta
/num
) + m_colWidths
[ m_growableCols
[idx
] ];
1454 delta
= ((delta
+growable_space
)*m_growableColsProportions
[idx
])/sum_proportions
;
1455 m_colWidths
[ m_growableCols
[idx
] ] = delta
;
1460 else if ( (m_growMode
== wxFLEX_GROWMODE_ALL
) && (sz
.x
> minsz
.x
) )
1462 for ( int col
=0; col
< ncols
; ++col
)
1463 m_colWidths
[ col
] = sz
.x
/ ncols
;
1468 void wxFlexGridSizer::AddGrowableRow( size_t idx
, int proportion
)
1470 m_growableRows
.Add( idx
);
1471 m_growableRowsProportions
.Add( proportion
);
1474 void wxFlexGridSizer::RemoveGrowableRow( size_t idx
)
1476 m_growableRows
.Remove( idx
);
1479 void wxFlexGridSizer::AddGrowableCol( size_t idx
, int proportion
)
1481 m_growableCols
.Add( idx
);
1482 m_growableColsProportions
.Add( proportion
);
1485 void wxFlexGridSizer::RemoveGrowableCol( size_t idx
)
1487 m_growableCols
.Remove( idx
);
1490 //---------------------------------------------------------------------------
1492 //---------------------------------------------------------------------------
1494 wxBoxSizer::wxBoxSizer( int orient
)
1495 : m_orient( orient
)
1499 void wxBoxSizer::RecalcSizes()
1501 if (m_children
.GetCount() == 0)
1507 if (m_orient
== wxHORIZONTAL
)
1508 delta
= m_size
.x
- m_fixedWidth
;
1510 delta
= m_size
.y
- m_fixedHeight
;
1513 wxPoint
pt( m_position
);
1515 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1518 wxSizerItem
*item
= node
->GetData();
1520 if (item
->IsShown())
1522 wxSize
size( item
->GetMinSizeWithBorder() );
1524 if (m_orient
== wxVERTICAL
)
1526 wxCoord height
= size
.y
;
1527 if (item
->GetProportion())
1529 // Because of at least one visible item has non-zero
1530 // proportion then m_stretchable is not zero
1531 height
= (delta
* item
->GetProportion()) / m_stretchable
;
1534 wxPoint
child_pos( pt
);
1535 wxSize
child_size( size
.x
, height
);
1537 if (item
->GetFlag() & (wxEXPAND
| wxSHAPED
))
1538 child_size
.x
= m_size
.x
;
1539 else if (item
->GetFlag() & wxALIGN_RIGHT
)
1540 child_pos
.x
+= m_size
.x
- size
.x
;
1541 else if (item
->GetFlag() & (wxCENTER
| wxALIGN_CENTER_HORIZONTAL
))
1542 // XXX wxCENTER is added for backward compatibility;
1543 // wxALIGN_CENTER should be used in new code
1544 child_pos
.x
+= (m_size
.x
- size
.x
) / 2;
1546 item
->SetDimension( child_pos
, child_size
);
1552 wxCoord width
= size
.x
;
1553 if (item
->GetProportion())
1555 // Because of at least one visible item has non-zero
1556 // proportion then m_stretchable is not zero
1557 width
= (delta
* item
->GetProportion()) / m_stretchable
;
1560 wxPoint
child_pos( pt
);
1561 wxSize
child_size( width
, size
.y
);
1563 if (item
->GetFlag() & (wxEXPAND
| wxSHAPED
))
1564 child_size
.y
= m_size
.y
;
1565 else if (item
->GetFlag() & wxALIGN_BOTTOM
)
1566 child_pos
.y
+= m_size
.y
- size
.y
;
1567 else if (item
->GetFlag() & (wxCENTER
| wxALIGN_CENTER_VERTICAL
))
1568 // XXX wxCENTER is added for backward compatibility;
1569 // wxALIGN_CENTER should be used in new code
1570 child_pos
.y
+= (m_size
.y
- size
.y
) / 2;
1572 item
->SetDimension( child_pos
, child_size
);
1578 node
= node
->GetNext();
1582 wxSize
wxBoxSizer::CalcMin()
1584 if (m_children
.GetCount() == 0)
1585 return wxSize(10,10);
1593 // precalc item minsizes and count proportions
1594 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1597 wxSizerItem
*item
= node
->GetData();
1599 if ( item
->IsShown() )
1601 item
->CalcMin(); // result is stored in the item
1603 m_stretchable
+= item
->GetProportion();
1606 node
= node
->GetNext();
1609 // Total minimum size (width or height) of sizer
1612 node
= m_children
.GetFirst();
1615 wxSizerItem
*item
= node
->GetData();
1617 if (item
->IsShown() && item
->GetProportion() != 0)
1619 int stretch
= item
->GetProportion();
1620 wxSize
size( item
->GetMinSizeWithBorder() );
1623 // Integer division rounded up is (a + b - 1) / b
1624 // Round up needed in order to guarantee that all
1625 // all items will have size not less then their min size
1626 if (m_orient
== wxHORIZONTAL
)
1627 minSize
= ( size
.x
*m_stretchable
+ stretch
- 1)/stretch
;
1629 minSize
= ( size
.y
*m_stretchable
+ stretch
- 1)/stretch
;
1631 if (minSize
> maxMinSize
)
1632 maxMinSize
= minSize
;
1634 node
= node
->GetNext();
1637 // Calculate overall minimum size
1638 node
= m_children
.GetFirst();
1641 wxSizerItem
*item
= node
->GetData();
1643 if (item
->IsShown())
1645 wxSize
size( item
->GetMinSizeWithBorder() );
1646 if (item
->GetProportion() != 0)
1648 if (m_orient
== wxHORIZONTAL
)
1649 size
.x
= (maxMinSize
*item
->GetProportion())/m_stretchable
;
1651 size
.y
= (maxMinSize
*item
->GetProportion())/m_stretchable
;
1655 if (m_orient
== wxVERTICAL
)
1657 m_fixedHeight
+= size
.y
;
1658 m_fixedWidth
= wxMax( m_fixedWidth
, size
.x
);
1662 m_fixedWidth
+= size
.x
;
1663 m_fixedHeight
= wxMax( m_fixedHeight
, size
.y
);
1667 if (m_orient
== wxHORIZONTAL
)
1669 m_minWidth
+= size
.x
;
1670 m_minHeight
= wxMax( m_minHeight
, size
.y
);
1674 m_minHeight
+= size
.y
;
1675 m_minWidth
= wxMax( m_minWidth
, size
.x
);
1678 node
= node
->GetNext();
1681 return wxSize( m_minWidth
, m_minHeight
);
1684 //---------------------------------------------------------------------------
1686 //---------------------------------------------------------------------------
1690 wxStaticBoxSizer::wxStaticBoxSizer( wxStaticBox
*box
, int orient
)
1691 : wxBoxSizer( orient
)
1692 , m_staticBox( box
)
1694 wxASSERT_MSG( box
, wxT("wxStaticBoxSizer needs a static box") );
1697 wxStaticBoxSizer::wxStaticBoxSizer(int orient
, wxWindow
*win
, const wxString
& s
)
1698 : wxBoxSizer(orient
),
1699 m_staticBox(new wxStaticBox(win
, wxID_ANY
, s
))
1703 static void GetStaticBoxBorders( wxStaticBox
*box
,
1707 // this has to be done platform by platform as there is no way to
1708 // guess the thickness of a wxStaticBox border
1709 box
->GetBordersForSizer(borderTop
, borderOther
);
1712 void wxStaticBoxSizer::RecalcSizes()
1714 int top_border
, other_border
;
1715 GetStaticBoxBorders(m_staticBox
, &top_border
, &other_border
);
1717 m_staticBox
->SetSize( m_position
.x
, m_position
.y
, m_size
.x
, m_size
.y
);
1719 wxPoint
old_pos( m_position
);
1720 m_position
.x
+= other_border
;
1721 m_position
.y
+= top_border
;
1722 wxSize
old_size( m_size
);
1723 m_size
.x
-= 2*other_border
;
1724 m_size
.y
-= top_border
+ other_border
;
1726 wxBoxSizer::RecalcSizes();
1728 m_position
= old_pos
;
1732 wxSize
wxStaticBoxSizer::CalcMin()
1734 int top_border
, other_border
;
1735 GetStaticBoxBorders(m_staticBox
, &top_border
, &other_border
);
1737 wxSize
ret( wxBoxSizer::CalcMin() );
1738 ret
.x
+= 2*other_border
;
1739 ret
.y
+= other_border
+ top_border
;
1744 void wxStaticBoxSizer::ShowItems( bool show
)
1746 m_staticBox
->Show( show
);
1747 wxBoxSizer::ShowItems( show
);
1750 #endif // wxUSE_STATBOX
1754 wxStdDialogButtonSizer::wxStdDialogButtonSizer()
1755 : wxBoxSizer(wxHORIZONTAL
)
1757 // Vertical buttons with lots of space on either side
1758 // looks rubbish on WinCE, so let's not do this for now.
1759 // If we are going to use vertical buttons, we should
1760 // put the sizer to the right of other controls in the dialog,
1761 // and that's beyond the scope of this sizer.
1763 bool is_pda
= (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA
);
1764 // If we have a PDA screen, put yes/no button over
1765 // all other buttons, otherwise on the left side.
1767 m_orient
= wxVERTICAL
;
1770 m_buttonAffirmative
= NULL
;
1771 m_buttonApply
= NULL
;
1772 m_buttonNegative
= NULL
;
1773 m_buttonCancel
= NULL
;
1774 m_buttonHelp
= NULL
;
1777 void wxStdDialogButtonSizer::AddButton(wxButton
*mybutton
)
1779 switch (mybutton
->GetId())
1784 m_buttonAffirmative
= mybutton
;
1787 m_buttonApply
= mybutton
;
1790 m_buttonNegative
= mybutton
;
1793 m_buttonCancel
= mybutton
;
1796 case wxID_CONTEXT_HELP
:
1797 m_buttonHelp
= mybutton
;
1804 void wxStdDialogButtonSizer::SetAffirmativeButton( wxButton
*button
)
1806 m_buttonAffirmative
= button
;
1809 void wxStdDialogButtonSizer::SetNegativeButton( wxButton
*button
)
1811 m_buttonNegative
= button
;
1814 void wxStdDialogButtonSizer::SetCancelButton( wxButton
*button
)
1816 m_buttonCancel
= button
;
1819 void wxStdDialogButtonSizer::Realize()
1822 Add(0, 0, 0, wxLEFT
, 6);
1824 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 6);
1826 if (m_buttonNegative
){
1827 // HIG POLICE BULLETIN - destructive buttons need extra padding
1828 // 24 pixels on either side
1829 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 12);
1832 // extra whitespace between help/negative and cancel/ok buttons
1833 Add(0, 0, 1, wxEXPAND
, 0);
1835 if (m_buttonCancel
){
1836 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 6);
1837 // Cancel or help should be default
1838 // m_buttonCancel->SetDefaultButton();
1841 // Ugh, Mac doesn't really have apply dialogs, so I'll just
1842 // figure the best place is between Cancel and OK
1844 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 6);
1846 if (m_buttonAffirmative
){
1847 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
, 6);
1849 if (m_buttonAffirmative
->GetId() == wxID_SAVE
){
1850 // these buttons have set labels under Mac so we should use them
1851 m_buttonAffirmative
->SetLabel(_("Save"));
1852 m_buttonNegative
->SetLabel(_("Don't Save"));
1856 // Extra space around and at the right
1858 #elif defined(__WXGTK20__)
1859 Add(0, 0, 0, wxLEFT
, 9);
1861 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
1863 // extra whitespace between help and cancel/ok buttons
1864 Add(0, 0, 1, wxEXPAND
, 0);
1866 if (m_buttonNegative
){
1867 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
1870 if (m_buttonCancel
){
1871 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
1872 // Cancel or help should be default
1873 // m_buttonCancel->SetDefaultButton();
1877 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
1879 if (m_buttonAffirmative
)
1880 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
, 6);
1881 #elif defined(__WXMSW__)
1884 // right-justify buttons
1885 Add(0, 0, 1, wxEXPAND
, 0);
1887 if (m_buttonAffirmative
){
1888 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonAffirmative
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1891 if (m_buttonNegative
){
1892 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonNegative
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1895 if (m_buttonCancel
){
1896 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonCancel
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1899 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonApply
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1902 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonHelp
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1904 // GTK+1 and any other platform
1906 // Add(0, 0, 0, wxLEFT, 5); // Not sure what this was for but it unbalances the dialog
1908 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonHelp
->ConvertDialogToPixels(wxSize(4, 0)).x
);
1910 // extra whitespace between help and cancel/ok buttons
1911 Add(0, 0, 1, wxEXPAND
, 0);
1914 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonApply
->ConvertDialogToPixels(wxSize(4, 0)).x
);
1916 if (m_buttonAffirmative
){
1917 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonAffirmative
->ConvertDialogToPixels(wxSize(4, 0)).x
);
1920 if (m_buttonNegative
){
1921 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonNegative
->ConvertDialogToPixels(wxSize(4, 0)).x
);
1924 if (m_buttonCancel
){
1925 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonCancel
->ConvertDialogToPixels(wxSize(4, 0)).x
);
1926 // Cancel or help should be default
1927 // m_buttonCancel->SetDefaultButton();
1933 #endif // wxUSE_BUTTON
1935 #if WXWIN_COMPATIBILITY_2_4
1937 // ----------------------------------------------------------------------------
1939 // ----------------------------------------------------------------------------
1942 IMPLEMENT_CLASS(wxBookCtrlSizer
, wxSizer
)
1944 IMPLEMENT_CLASS(wxNotebookSizer
, wxBookCtrlSizer
)
1945 #endif // wxUSE_NOTEBOOK
1946 #endif // wxUSE_BOOKCTRL
1950 #if WXWIN_COMPATIBILITY_2_6
1952 wxBookCtrlSizer::wxBookCtrlSizer(wxBookCtrlBase
*bookctrl
)
1953 : m_bookctrl(bookctrl
)
1955 wxASSERT_MSG( bookctrl
, wxT("wxBookCtrlSizer needs a control") );
1958 #endif // WXWIN_COMPATIBILITY_2_6
1960 void wxBookCtrlSizer::RecalcSizes()
1962 m_bookctrl
->SetSize( m_position
.x
, m_position
.y
, m_size
.x
, m_size
.y
);
1965 wxSize
wxBookCtrlSizer::CalcMin()
1967 wxSize sizeBorder
= m_bookctrl
->CalcSizeFromPage(wxSize(0,0));
1972 if ( m_bookctrl
->GetPageCount() == 0 )
1974 return wxSize(sizeBorder
.x
+ 10, sizeBorder
.y
+ 10);
1980 wxWindowList::compatibility_iterator
1981 node
= m_bookctrl
->GetChildren().GetFirst();
1984 wxWindow
*item
= node
->GetData();
1985 wxSizer
*itemsizer
= item
->GetSizer();
1989 wxSize
subsize( itemsizer
->CalcMin() );
1991 if (subsize
.x
> maxX
)
1993 if (subsize
.y
> maxY
)
1997 node
= node
->GetNext();
2000 return wxSize( maxX
, maxY
) + sizeBorder
;
2005 #if WXWIN_COMPATIBILITY_2_6
2007 wxNotebookSizer::wxNotebookSizer(wxNotebook
*nb
)
2009 wxASSERT_MSG( nb
, wxT("wxNotebookSizer needs a control") );
2013 #endif // WXWIN_COMPATIBILITY_2_6
2015 #endif // wxUSE_NOTEBOOOK
2016 #endif // wxUSE_BOOKCTRL
2018 #endif // WXWIN_COMPATIBILITY_2_4