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 if ( window
->IsTopLevel() )
737 wxTopLevelWindow
*tlw
= wxDynamicCast(window
, wxTopLevelWindow
);
738 if ( tlw
&& tlw
->IsAlwaysMaximized() )
740 return tlw
->GetClientSize();
744 wxSize size
= GetMinWindowSize( window
);
745 wxSize sizeMax
= GetMaxWindowSize( window
);
747 // Limit the size if sizeMax != wxDefaultSize
749 if ( size
.x
> sizeMax
.x
&& sizeMax
.x
!= wxDefaultCoord
)
751 if ( size
.y
> sizeMax
.y
&& sizeMax
.y
!= wxDefaultCoord
)
757 wxSize
wxSizer::GetMaxClientSize( wxWindow
*window
) const
759 wxSize
maxSize( window
->GetMaxSize() );
761 if ( maxSize
!= wxDefaultSize
)
763 wxSize
size( window
->GetSize() );
764 wxSize
client_size( window
->GetClientSize() );
766 return wxSize( maxSize
.x
+ client_size
.x
- size
.x
,
767 maxSize
.y
+ client_size
.y
- size
.y
);
770 return wxDefaultSize
;
773 wxSize
wxSizer::GetMinClientSize( wxWindow
*WXUNUSED(window
) )
775 return GetMinSize(); // Already returns client size.
778 wxSize
wxSizer::VirtualFitSize( wxWindow
*window
)
780 wxSize size
= GetMinClientSize( window
);
781 wxSize sizeMax
= GetMaxClientSize( window
);
783 // Limit the size if sizeMax != wxDefaultSize
785 if ( size
.x
> sizeMax
.x
&& sizeMax
.x
!= wxDefaultCoord
)
787 if ( size
.y
> sizeMax
.y
&& sizeMax
.y
!= wxDefaultCoord
)
793 void wxSizer::SetDimension( int x
, int y
, int width
, int height
)
802 wxSize
wxSizer::GetMinSize()
804 wxSize
ret( CalcMin() );
805 if (ret
.x
< m_minSize
.x
) ret
.x
= m_minSize
.x
;
806 if (ret
.y
< m_minSize
.y
) ret
.y
= m_minSize
.y
;
810 void wxSizer::DoSetMinSize( int width
, int height
)
813 m_minSize
.y
= height
;
816 bool wxSizer::DoSetItemMinSize( wxWindow
*window
, int width
, int height
)
818 wxASSERT_MSG( window
, _T("SetMinSize for NULL window") );
820 // Is it our immediate child?
822 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
825 wxSizerItem
*item
= node
->GetData();
827 if (item
->GetWindow() == window
)
829 item
->SetMinSize( width
, height
);
832 node
= node
->GetNext();
835 // No? Search any subsizers we own then
837 node
= m_children
.GetFirst();
840 wxSizerItem
*item
= node
->GetData();
842 if ( item
->GetSizer() &&
843 item
->GetSizer()->DoSetItemMinSize( window
, width
, height
) )
845 // A child sizer found the requested windw, exit.
848 node
= node
->GetNext();
854 bool wxSizer::DoSetItemMinSize( wxSizer
*sizer
, int width
, int height
)
856 wxASSERT_MSG( sizer
, _T("SetMinSize for NULL sizer") );
858 // Is it our immediate child?
860 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
863 wxSizerItem
*item
= node
->GetData();
865 if (item
->GetSizer() == sizer
)
867 item
->GetSizer()->DoSetMinSize( width
, height
);
870 node
= node
->GetNext();
873 // No? Search any subsizers we own then
875 node
= m_children
.GetFirst();
878 wxSizerItem
*item
= node
->GetData();
880 if ( item
->GetSizer() &&
881 item
->GetSizer()->DoSetItemMinSize( sizer
, width
, height
) )
883 // A child found the requested sizer, exit.
886 node
= node
->GetNext();
892 bool wxSizer::DoSetItemMinSize( size_t index
, int width
, int height
)
894 wxSizerItemList::compatibility_iterator node
= m_children
.Item( index
);
896 wxCHECK_MSG( node
, false, _T("Failed to find child node") );
898 wxSizerItem
*item
= node
->GetData();
900 if (item
->GetSizer())
902 // Sizers contains the minimal size in them, if not calculated ...
903 item
->GetSizer()->DoSetMinSize( width
, height
);
907 // ... but the minimal size of spacers and windows is stored via the item
908 item
->SetMinSize( width
, height
);
914 wxSizerItem
* wxSizer::GetItem( wxWindow
*window
, bool recursive
)
916 wxASSERT_MSG( window
, _T("GetItem for NULL window") );
918 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
921 wxSizerItem
*item
= node
->GetData();
923 if (item
->GetWindow() == window
)
927 else if (recursive
&& item
->IsSizer())
929 wxSizerItem
*subitem
= item
->GetSizer()->GetItem( window
, true );
934 node
= node
->GetNext();
940 wxSizerItem
* wxSizer::GetItem( wxSizer
*sizer
, bool recursive
)
942 wxASSERT_MSG( sizer
, _T("GetItem for NULL sizer") );
944 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
947 wxSizerItem
*item
= node
->GetData();
949 if (item
->GetSizer() == sizer
)
953 else if (recursive
&& item
->IsSizer())
955 wxSizerItem
*subitem
= item
->GetSizer()->GetItem( sizer
, true );
960 node
= node
->GetNext();
966 wxSizerItem
* wxSizer::GetItem( size_t index
)
968 wxCHECK_MSG( index
< m_children
.GetCount(),
970 _T("GetItem index is out of range") );
972 return m_children
.Item( index
)->GetData();
975 bool wxSizer::Show( wxWindow
*window
, bool show
, bool recursive
)
977 wxSizerItem
*item
= GetItem( window
, recursive
);
988 bool wxSizer::Show( wxSizer
*sizer
, bool show
, bool recursive
)
990 wxSizerItem
*item
= GetItem( sizer
, recursive
);
1001 bool wxSizer::Show( size_t index
, bool show
)
1003 wxSizerItem
*item
= GetItem( index
);
1014 void wxSizer::ShowItems( bool show
)
1016 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1019 node
->GetData()->Show( show
);
1020 node
= node
->GetNext();
1024 bool wxSizer::IsShown( wxWindow
*window
) const
1026 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1029 wxSizerItem
*item
= node
->GetData();
1031 if (item
->GetWindow() == window
)
1033 return item
->IsShown();
1035 node
= node
->GetNext();
1038 wxFAIL_MSG( _T("IsShown failed to find sizer item") );
1043 bool wxSizer::IsShown( wxSizer
*sizer
) const
1045 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1048 wxSizerItem
*item
= node
->GetData();
1050 if (item
->GetSizer() == sizer
)
1052 return item
->IsShown();
1054 node
= node
->GetNext();
1057 wxFAIL_MSG( _T("IsShown failed to find sizer item") );
1062 bool wxSizer::IsShown( size_t index
) const
1064 wxCHECK_MSG( index
< m_children
.GetCount(),
1066 _T("IsShown index is out of range") );
1068 return m_children
.Item( index
)->GetData()->IsShown();
1072 //---------------------------------------------------------------------------
1074 //---------------------------------------------------------------------------
1076 wxGridSizer::wxGridSizer( int rows
, int cols
, int vgap
, int hgap
)
1077 : m_rows( ( cols
== 0 && rows
== 0 ) ? 1 : rows
)
1084 wxGridSizer::wxGridSizer( int cols
, int vgap
, int hgap
)
1085 : m_rows( cols
== 0 ? 1 : 0 )
1092 int wxGridSizer::CalcRowsCols(int& nrows
, int& ncols
) const
1094 int nitems
= m_children
.GetCount();
1100 nrows
= (nitems
+ m_cols
- 1) / m_cols
;
1104 ncols
= (nitems
+ m_rows
- 1) / m_rows
;
1107 else // 0 columns, 0 rows?
1109 wxFAIL_MSG( _T("grid sizer must have either rows or columns fixed") );
1118 void wxGridSizer::RecalcSizes()
1120 int nitems
, nrows
, ncols
;
1121 if ( (nitems
= CalcRowsCols(nrows
, ncols
)) == 0 )
1124 wxSize
sz( GetSize() );
1125 wxPoint
pt( GetPosition() );
1127 int w
= (sz
.x
- (ncols
- 1) * m_hgap
) / ncols
;
1128 int h
= (sz
.y
- (nrows
- 1) * m_vgap
) / nrows
;
1131 for (int c
= 0; c
< ncols
; c
++)
1134 for (int r
= 0; r
< nrows
; r
++)
1136 int i
= r
* ncols
+ c
;
1139 wxSizerItemList::compatibility_iterator node
= m_children
.Item( i
);
1141 wxASSERT_MSG( node
, _T("Failed to find SizerItemList node") );
1143 SetItemBounds( node
->GetData(), x
, y
, w
, h
);
1151 wxSize
wxGridSizer::CalcMin()
1154 if ( CalcRowsCols(nrows
, ncols
) == 0 )
1155 return wxSize(10, 10);
1157 // Find the max width and height for any component
1161 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1164 wxSizerItem
*item
= node
->GetData();
1165 wxSize
sz( item
->CalcMin() );
1167 w
= wxMax( w
, sz
.x
);
1168 h
= wxMax( h
, sz
.y
);
1170 node
= node
->GetNext();
1173 return wxSize( ncols
* w
+ (ncols
-1) * m_hgap
,
1174 nrows
* h
+ (nrows
-1) * m_vgap
);
1177 void wxGridSizer::SetItemBounds( wxSizerItem
*item
, int x
, int y
, int w
, int h
)
1180 wxSize
sz( item
->GetMinSizeWithBorder() );
1181 int flag
= item
->GetFlag();
1183 if ((flag
& wxEXPAND
) || (flag
& wxSHAPED
))
1189 if (flag
& wxALIGN_CENTER_HORIZONTAL
)
1191 pt
.x
= x
+ (w
- sz
.x
) / 2;
1193 else if (flag
& wxALIGN_RIGHT
)
1195 pt
.x
= x
+ (w
- sz
.x
);
1198 if (flag
& wxALIGN_CENTER_VERTICAL
)
1200 pt
.y
= y
+ (h
- sz
.y
) / 2;
1202 else if (flag
& wxALIGN_BOTTOM
)
1204 pt
.y
= y
+ (h
- sz
.y
);
1208 item
->SetDimension(pt
, sz
);
1211 //---------------------------------------------------------------------------
1213 //---------------------------------------------------------------------------
1215 wxFlexGridSizer::wxFlexGridSizer( int rows
, int cols
, int vgap
, int hgap
)
1216 : wxGridSizer( rows
, cols
, vgap
, hgap
),
1217 m_flexDirection(wxBOTH
),
1218 m_growMode(wxFLEX_GROWMODE_SPECIFIED
)
1222 wxFlexGridSizer::wxFlexGridSizer( int cols
, int vgap
, int hgap
)
1223 : wxGridSizer( cols
, vgap
, hgap
),
1224 m_flexDirection(wxBOTH
),
1225 m_growMode(wxFLEX_GROWMODE_SPECIFIED
)
1229 wxFlexGridSizer::~wxFlexGridSizer()
1233 void wxFlexGridSizer::RecalcSizes()
1235 int nitems
, nrows
, ncols
;
1236 if ( (nitems
= CalcRowsCols(nrows
, ncols
)) == 0 )
1239 wxPoint
pt( GetPosition() );
1240 wxSize
sz( GetSize() );
1242 AdjustForGrowables(sz
, m_calculatedMinSize
, nrows
, ncols
);
1244 sz
= wxSize( pt
.x
+ sz
.x
, pt
.y
+ sz
.y
);
1247 for (int c
= 0; c
< ncols
; c
++)
1250 for (int r
= 0; r
< nrows
; r
++)
1252 int i
= r
* ncols
+ c
;
1255 wxSizerItemList::compatibility_iterator node
= m_children
.Item( i
);
1257 wxASSERT_MSG( node
, _T("Failed to find node") );
1259 int w
= wxMax( 0, wxMin( m_colWidths
[c
], sz
.x
- x
) );
1260 int h
= wxMax( 0, wxMin( m_rowHeights
[r
], sz
.y
- y
) );
1262 SetItemBounds( node
->GetData(), x
, y
, w
, h
);
1264 if (m_rowHeights
[r
] != -1)
1265 y
= y
+ m_rowHeights
[r
] + m_vgap
;
1267 if (m_colWidths
[c
] != -1)
1268 x
= x
+ m_colWidths
[c
] + m_hgap
;
1272 wxSize
wxFlexGridSizer::CalcMin()
1278 // Number of rows/columns can change as items are added or removed.
1279 if ( !CalcRowsCols(nrows
, ncols
) )
1280 return wxSize(10, 10);
1282 m_rowHeights
.SetCount(nrows
);
1283 m_colWidths
.SetCount(ncols
);
1285 // We have to recalcuate the sizes in case the item minimum size has
1286 // changed since the previous layout, or the item has been hidden using
1287 // wxSizer::Show(). If all the items in a row/column are hidden, the final
1288 // dimension of the row/column will be -1, indicating that the column
1289 // itself is hidden.
1290 for( s
= m_rowHeights
.GetCount(), i
= 0; i
< s
; ++i
)
1291 m_rowHeights
[ i
] = -1;
1292 for( s
= m_colWidths
.GetCount(), i
= 0; i
< s
; ++i
)
1293 m_colWidths
[ i
] = -1;
1295 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1300 wxSizerItem
*item
= node
->GetData();
1301 if ( item
->IsShown() )
1303 wxSize
sz( item
->CalcMin() );
1304 int row
= i
/ ncols
;
1305 int col
= i
% ncols
;
1307 m_rowHeights
[ row
] = wxMax( wxMax( 0, sz
.y
), m_rowHeights
[ row
] );
1308 m_colWidths
[ col
] = wxMax( wxMax( 0, sz
.x
), m_colWidths
[ col
] );
1311 node
= node
->GetNext();
1315 AdjustForFlexDirection();
1317 // Sum total minimum size, including gaps between rows/columns.
1318 // -1 is used as a magic number meaning empty column.
1320 for (int col
= 0; col
< ncols
; col
++)
1321 if ( m_colWidths
[ col
] != -1 )
1322 width
+= m_colWidths
[ col
] + m_hgap
;
1327 for (int row
= 0; row
< nrows
; row
++)
1328 if ( m_rowHeights
[ row
] != -1 )
1329 height
+= m_rowHeights
[ row
] + m_vgap
;
1333 m_calculatedMinSize
= wxSize( width
, height
);
1334 return m_calculatedMinSize
;
1337 void wxFlexGridSizer::AdjustForFlexDirection()
1339 // the logic in CalcMin works when we resize flexibly in both directions
1340 // but maybe this is not the case
1341 if ( m_flexDirection
!= wxBOTH
)
1343 // select the array corresponding to the direction in which we do *not*
1345 wxArrayInt
& array
= m_flexDirection
== wxVERTICAL
? m_colWidths
1348 const size_t count
= array
.GetCount();
1350 // find the largest value in this array
1354 for ( n
= 0; n
< count
; ++n
)
1356 if ( array
[n
] > largest
)
1360 // and now fill it with the largest value
1361 for ( n
= 0; n
< count
; ++n
)
1369 void wxFlexGridSizer::AdjustForGrowables(const wxSize
& sz
, const wxSize
& minsz
,
1370 int nrows
, int ncols
)
1372 // what to do with the rows? by default, resize them proportionally
1373 if ( sz
.y
> minsz
.y
&& ( (m_flexDirection
& wxVERTICAL
) || (m_growMode
== wxFLEX_GROWMODE_SPECIFIED
) ) )
1375 int sum_proportions
= 0;
1376 int growable_space
= 0;
1379 for (idx
= 0; idx
< m_growableRows
.GetCount(); idx
++)
1381 // Since the number of rows/columns can change as items are
1382 // inserted/deleted, we need to verify at runtime that the
1383 // requested growable rows/columns are still valid.
1384 if (m_growableRows
[idx
] >= nrows
)
1387 // If all items in a row/column are hidden, that row/column will
1388 // have a dimension of -1. This causes the row/column to be
1389 // hidden completely.
1390 if (m_rowHeights
[ m_growableRows
[idx
] ] == -1)
1392 sum_proportions
+= m_growableRowsProportions
[idx
];
1393 growable_space
+= m_rowHeights
[ m_growableRows
[idx
] ];
1399 for (idx
= 0; idx
< m_growableRows
.GetCount(); idx
++)
1401 if (m_growableRows
[idx
] >= nrows
)
1403 if (m_rowHeights
[ m_growableRows
[idx
] ] == -1)
1404 m_rowHeights
[ m_growableRows
[idx
] ] = 0;
1407 int delta
= (sz
.y
- minsz
.y
);
1408 if (sum_proportions
== 0)
1409 delta
= (delta
/num
) + m_rowHeights
[ m_growableRows
[idx
] ];
1411 delta
= ((delta
+growable_space
)*m_growableRowsProportions
[idx
]) / sum_proportions
;
1412 m_rowHeights
[ m_growableRows
[idx
] ] = delta
;
1417 else if ( (m_growMode
== wxFLEX_GROWMODE_ALL
) && (sz
.y
> minsz
.y
) )
1419 // rounding problem?
1420 for ( int row
= 0; row
< nrows
; ++row
)
1421 m_rowHeights
[ row
] = sz
.y
/ nrows
;
1424 // the same logic as above but for the columns
1425 if ( sz
.x
> minsz
.x
&& ( (m_flexDirection
& wxHORIZONTAL
) || (m_growMode
== wxFLEX_GROWMODE_SPECIFIED
) ) )
1427 int sum_proportions
= 0;
1428 int growable_space
= 0;
1431 for (idx
= 0; idx
< m_growableCols
.GetCount(); idx
++)
1433 // Since the number of rows/columns can change as items are
1434 // inserted/deleted, we need to verify at runtime that the
1435 // requested growable rows/columns are still valid.
1436 if (m_growableCols
[idx
] >= ncols
)
1439 // If all items in a row/column are hidden, that row/column will
1440 // have a dimension of -1. This causes the column to be hidden
1442 if (m_colWidths
[ m_growableCols
[idx
] ] == -1)
1444 sum_proportions
+= m_growableColsProportions
[idx
];
1445 growable_space
+= m_colWidths
[ m_growableCols
[idx
] ];
1451 for (idx
= 0; idx
< m_growableCols
.GetCount(); idx
++)
1453 if (m_growableCols
[idx
] >= ncols
)
1455 if (m_colWidths
[ m_growableCols
[idx
] ] == -1)
1456 m_colWidths
[ m_growableCols
[idx
] ] = 0;
1459 int delta
= (sz
.x
- minsz
.x
);
1460 if (sum_proportions
== 0)
1461 delta
= (delta
/num
) + m_colWidths
[ m_growableCols
[idx
] ];
1463 delta
= ((delta
+growable_space
)*m_growableColsProportions
[idx
])/sum_proportions
;
1464 m_colWidths
[ m_growableCols
[idx
] ] = delta
;
1469 else if ( (m_growMode
== wxFLEX_GROWMODE_ALL
) && (sz
.x
> minsz
.x
) )
1471 for ( int col
=0; col
< ncols
; ++col
)
1472 m_colWidths
[ col
] = sz
.x
/ ncols
;
1477 void wxFlexGridSizer::AddGrowableRow( size_t idx
, int proportion
)
1479 m_growableRows
.Add( idx
);
1480 m_growableRowsProportions
.Add( proportion
);
1483 void wxFlexGridSizer::RemoveGrowableRow( size_t idx
)
1485 m_growableRows
.Remove( idx
);
1488 void wxFlexGridSizer::AddGrowableCol( size_t idx
, int proportion
)
1490 m_growableCols
.Add( idx
);
1491 m_growableColsProportions
.Add( proportion
);
1494 void wxFlexGridSizer::RemoveGrowableCol( size_t idx
)
1496 m_growableCols
.Remove( idx
);
1499 //---------------------------------------------------------------------------
1501 //---------------------------------------------------------------------------
1503 wxBoxSizer::wxBoxSizer( int orient
)
1504 : m_orient( orient
)
1508 void wxBoxSizer::RecalcSizes()
1510 if (m_children
.GetCount() == 0)
1516 if (m_orient
== wxHORIZONTAL
)
1517 delta
= m_size
.x
- m_fixedWidth
;
1519 delta
= m_size
.y
- m_fixedHeight
;
1522 wxPoint
pt( m_position
);
1524 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1527 wxSizerItem
*item
= node
->GetData();
1529 if (item
->IsShown())
1531 wxSize
size( item
->GetMinSizeWithBorder() );
1533 if (m_orient
== wxVERTICAL
)
1535 wxCoord height
= size
.y
;
1536 if (item
->GetProportion())
1538 // Because of at least one visible item has non-zero
1539 // proportion then m_stretchable is not zero
1540 height
= (delta
* item
->GetProportion()) / m_stretchable
;
1543 wxPoint
child_pos( pt
);
1544 wxSize
child_size( size
.x
, height
);
1546 if (item
->GetFlag() & (wxEXPAND
| wxSHAPED
))
1547 child_size
.x
= m_size
.x
;
1548 else if (item
->GetFlag() & wxALIGN_RIGHT
)
1549 child_pos
.x
+= m_size
.x
- size
.x
;
1550 else if (item
->GetFlag() & (wxCENTER
| wxALIGN_CENTER_HORIZONTAL
))
1551 // XXX wxCENTER is added for backward compatibility;
1552 // wxALIGN_CENTER should be used in new code
1553 child_pos
.x
+= (m_size
.x
- size
.x
) / 2;
1555 item
->SetDimension( child_pos
, child_size
);
1561 wxCoord width
= size
.x
;
1562 if (item
->GetProportion())
1564 // Because of at least one visible item has non-zero
1565 // proportion then m_stretchable is not zero
1566 width
= (delta
* item
->GetProportion()) / m_stretchable
;
1569 wxPoint
child_pos( pt
);
1570 wxSize
child_size( width
, size
.y
);
1572 if (item
->GetFlag() & (wxEXPAND
| wxSHAPED
))
1573 child_size
.y
= m_size
.y
;
1574 else if (item
->GetFlag() & wxALIGN_BOTTOM
)
1575 child_pos
.y
+= m_size
.y
- size
.y
;
1576 else if (item
->GetFlag() & (wxCENTER
| wxALIGN_CENTER_VERTICAL
))
1577 // XXX wxCENTER is added for backward compatibility;
1578 // wxALIGN_CENTER should be used in new code
1579 child_pos
.y
+= (m_size
.y
- size
.y
) / 2;
1581 item
->SetDimension( child_pos
, child_size
);
1587 node
= node
->GetNext();
1591 wxSize
wxBoxSizer::CalcMin()
1593 if (m_children
.GetCount() == 0)
1594 return wxSize(10,10);
1602 // precalc item minsizes and count proportions
1603 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1606 wxSizerItem
*item
= node
->GetData();
1608 if ( item
->IsShown() )
1610 item
->CalcMin(); // result is stored in the item
1612 m_stretchable
+= item
->GetProportion();
1615 node
= node
->GetNext();
1618 // Total minimum size (width or height) of sizer
1621 node
= m_children
.GetFirst();
1624 wxSizerItem
*item
= node
->GetData();
1626 if (item
->IsShown() && item
->GetProportion() != 0)
1628 int stretch
= item
->GetProportion();
1629 wxSize
size( item
->GetMinSizeWithBorder() );
1632 // Integer division rounded up is (a + b - 1) / b
1633 // Round up needed in order to guarantee that all
1634 // all items will have size not less then their min size
1635 if (m_orient
== wxHORIZONTAL
)
1636 minSize
= ( size
.x
*m_stretchable
+ stretch
- 1)/stretch
;
1638 minSize
= ( size
.y
*m_stretchable
+ stretch
- 1)/stretch
;
1640 if (minSize
> maxMinSize
)
1641 maxMinSize
= minSize
;
1643 node
= node
->GetNext();
1646 // Calculate overall minimum size
1647 node
= m_children
.GetFirst();
1650 wxSizerItem
*item
= node
->GetData();
1652 if (item
->IsShown())
1654 wxSize
size( item
->GetMinSizeWithBorder() );
1655 if (item
->GetProportion() != 0)
1657 if (m_orient
== wxHORIZONTAL
)
1658 size
.x
= (maxMinSize
*item
->GetProportion())/m_stretchable
;
1660 size
.y
= (maxMinSize
*item
->GetProportion())/m_stretchable
;
1664 if (m_orient
== wxVERTICAL
)
1666 m_fixedHeight
+= size
.y
;
1667 m_fixedWidth
= wxMax( m_fixedWidth
, size
.x
);
1671 m_fixedWidth
+= size
.x
;
1672 m_fixedHeight
= wxMax( m_fixedHeight
, size
.y
);
1676 if (m_orient
== wxHORIZONTAL
)
1678 m_minWidth
+= size
.x
;
1679 m_minHeight
= wxMax( m_minHeight
, size
.y
);
1683 m_minHeight
+= size
.y
;
1684 m_minWidth
= wxMax( m_minWidth
, size
.x
);
1687 node
= node
->GetNext();
1690 return wxSize( m_minWidth
, m_minHeight
);
1693 //---------------------------------------------------------------------------
1695 //---------------------------------------------------------------------------
1699 wxStaticBoxSizer::wxStaticBoxSizer( wxStaticBox
*box
, int orient
)
1700 : wxBoxSizer( orient
)
1701 , m_staticBox( box
)
1703 wxASSERT_MSG( box
, wxT("wxStaticBoxSizer needs a static box") );
1706 wxStaticBoxSizer::wxStaticBoxSizer(int orient
, wxWindow
*win
, const wxString
& s
)
1707 : wxBoxSizer(orient
),
1708 m_staticBox(new wxStaticBox(win
, wxID_ANY
, s
))
1712 static void GetStaticBoxBorders( wxStaticBox
*box
,
1716 // this has to be done platform by platform as there is no way to
1717 // guess the thickness of a wxStaticBox border
1718 box
->GetBordersForSizer(borderTop
, borderOther
);
1721 void wxStaticBoxSizer::RecalcSizes()
1723 int top_border
, other_border
;
1724 GetStaticBoxBorders(m_staticBox
, &top_border
, &other_border
);
1726 m_staticBox
->SetSize( m_position
.x
, m_position
.y
, m_size
.x
, m_size
.y
);
1728 wxPoint
old_pos( m_position
);
1729 m_position
.x
+= other_border
;
1730 m_position
.y
+= top_border
;
1731 wxSize
old_size( m_size
);
1732 m_size
.x
-= 2*other_border
;
1733 m_size
.y
-= top_border
+ other_border
;
1735 wxBoxSizer::RecalcSizes();
1737 m_position
= old_pos
;
1741 wxSize
wxStaticBoxSizer::CalcMin()
1743 int top_border
, other_border
;
1744 GetStaticBoxBorders(m_staticBox
, &top_border
, &other_border
);
1746 wxSize
ret( wxBoxSizer::CalcMin() );
1747 ret
.x
+= 2*other_border
;
1748 ret
.y
+= other_border
+ top_border
;
1753 void wxStaticBoxSizer::ShowItems( bool show
)
1755 m_staticBox
->Show( show
);
1756 wxBoxSizer::ShowItems( show
);
1759 #endif // wxUSE_STATBOX
1763 wxStdDialogButtonSizer::wxStdDialogButtonSizer()
1764 : wxBoxSizer(wxHORIZONTAL
)
1766 // Vertical buttons with lots of space on either side
1767 // looks rubbish on WinCE, so let's not do this for now.
1768 // If we are going to use vertical buttons, we should
1769 // put the sizer to the right of other controls in the dialog,
1770 // and that's beyond the scope of this sizer.
1772 bool is_pda
= (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA
);
1773 // If we have a PDA screen, put yes/no button over
1774 // all other buttons, otherwise on the left side.
1776 m_orient
= wxVERTICAL
;
1779 m_buttonAffirmative
= NULL
;
1780 m_buttonApply
= NULL
;
1781 m_buttonNegative
= NULL
;
1782 m_buttonCancel
= NULL
;
1783 m_buttonHelp
= NULL
;
1786 void wxStdDialogButtonSizer::AddButton(wxButton
*mybutton
)
1788 switch (mybutton
->GetId())
1793 m_buttonAffirmative
= mybutton
;
1796 m_buttonApply
= mybutton
;
1799 m_buttonNegative
= mybutton
;
1802 m_buttonCancel
= mybutton
;
1805 case wxID_CONTEXT_HELP
:
1806 m_buttonHelp
= mybutton
;
1813 void wxStdDialogButtonSizer::SetAffirmativeButton( wxButton
*button
)
1815 m_buttonAffirmative
= button
;
1818 void wxStdDialogButtonSizer::SetNegativeButton( wxButton
*button
)
1820 m_buttonNegative
= button
;
1823 void wxStdDialogButtonSizer::SetCancelButton( wxButton
*button
)
1825 m_buttonCancel
= button
;
1828 void wxStdDialogButtonSizer::Realize()
1831 Add(0, 0, 0, wxLEFT
, 6);
1833 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 6);
1835 if (m_buttonNegative
){
1836 // HIG POLICE BULLETIN - destructive buttons need extra padding
1837 // 24 pixels on either side
1838 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 12);
1841 // extra whitespace between help/negative and cancel/ok buttons
1842 Add(0, 0, 1, wxEXPAND
, 0);
1844 if (m_buttonCancel
){
1845 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 6);
1846 // Cancel or help should be default
1847 // m_buttonCancel->SetDefaultButton();
1850 // Ugh, Mac doesn't really have apply dialogs, so I'll just
1851 // figure the best place is between Cancel and OK
1853 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 6);
1855 if (m_buttonAffirmative
){
1856 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
, 6);
1858 if (m_buttonAffirmative
->GetId() == wxID_SAVE
){
1859 // these buttons have set labels under Mac so we should use them
1860 m_buttonAffirmative
->SetLabel(_("Save"));
1861 m_buttonNegative
->SetLabel(_("Don't Save"));
1865 // Extra space around and at the right
1867 #elif defined(__WXGTK20__)
1868 Add(0, 0, 0, wxLEFT
, 9);
1870 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
1872 // extra whitespace between help and cancel/ok buttons
1873 Add(0, 0, 1, wxEXPAND
, 0);
1875 if (m_buttonNegative
){
1876 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
1879 if (m_buttonCancel
){
1880 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
1881 // Cancel or help should be default
1882 // m_buttonCancel->SetDefaultButton();
1886 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
1888 if (m_buttonAffirmative
)
1889 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
, 6);
1890 #elif defined(__WXMSW__)
1893 // right-justify buttons
1894 Add(0, 0, 1, wxEXPAND
, 0);
1896 if (m_buttonAffirmative
){
1897 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonAffirmative
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1900 if (m_buttonNegative
){
1901 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonNegative
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1904 if (m_buttonCancel
){
1905 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonCancel
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1908 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonApply
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1911 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonHelp
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1913 // GTK+1 and any other platform
1915 // Add(0, 0, 0, wxLEFT, 5); // Not sure what this was for but it unbalances the dialog
1917 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonHelp
->ConvertDialogToPixels(wxSize(4, 0)).x
);
1919 // extra whitespace between help and cancel/ok buttons
1920 Add(0, 0, 1, wxEXPAND
, 0);
1923 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonApply
->ConvertDialogToPixels(wxSize(4, 0)).x
);
1925 if (m_buttonAffirmative
){
1926 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonAffirmative
->ConvertDialogToPixels(wxSize(4, 0)).x
);
1929 if (m_buttonNegative
){
1930 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonNegative
->ConvertDialogToPixels(wxSize(4, 0)).x
);
1933 if (m_buttonCancel
){
1934 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonCancel
->ConvertDialogToPixels(wxSize(4, 0)).x
);
1935 // Cancel or help should be default
1936 // m_buttonCancel->SetDefaultButton();
1942 #endif // wxUSE_BUTTON
1944 #if WXWIN_COMPATIBILITY_2_4
1946 // ----------------------------------------------------------------------------
1948 // ----------------------------------------------------------------------------
1951 IMPLEMENT_CLASS(wxBookCtrlSizer
, wxSizer
)
1953 IMPLEMENT_CLASS(wxNotebookSizer
, wxBookCtrlSizer
)
1954 #endif // wxUSE_NOTEBOOK
1955 #endif // wxUSE_BOOKCTRL
1959 #if WXWIN_COMPATIBILITY_2_6
1961 wxBookCtrlSizer::wxBookCtrlSizer(wxBookCtrlBase
*bookctrl
)
1962 : m_bookctrl(bookctrl
)
1964 wxASSERT_MSG( bookctrl
, wxT("wxBookCtrlSizer needs a control") );
1967 #endif // WXWIN_COMPATIBILITY_2_6
1969 void wxBookCtrlSizer::RecalcSizes()
1971 m_bookctrl
->SetSize( m_position
.x
, m_position
.y
, m_size
.x
, m_size
.y
);
1974 wxSize
wxBookCtrlSizer::CalcMin()
1976 wxSize sizeBorder
= m_bookctrl
->CalcSizeFromPage(wxSize(0,0));
1981 if ( m_bookctrl
->GetPageCount() == 0 )
1983 return wxSize(sizeBorder
.x
+ 10, sizeBorder
.y
+ 10);
1989 wxWindowList::compatibility_iterator
1990 node
= m_bookctrl
->GetChildren().GetFirst();
1993 wxWindow
*item
= node
->GetData();
1994 wxSizer
*itemsizer
= item
->GetSizer();
1998 wxSize
subsize( itemsizer
->CalcMin() );
2000 if (subsize
.x
> maxX
)
2002 if (subsize
.y
> maxY
)
2006 node
= node
->GetNext();
2009 return wxSize( maxX
, maxY
) + sizeBorder
;
2014 #if WXWIN_COMPATIBILITY_2_6
2016 wxNotebookSizer::wxNotebookSizer(wxNotebook
*nb
)
2018 wxASSERT_MSG( nb
, wxT("wxNotebookSizer needs a control") );
2022 #endif // WXWIN_COMPATIBILITY_2_6
2024 #endif // wxUSE_NOTEBOOOK
2025 #endif // wxUSE_BOOKCTRL
2027 #endif // WXWIN_COMPATIBILITY_2_4