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"
23 #include "wx/string.h"
27 #include "wx/settings.h"
28 #include "wx/statbox.h"
31 #include "wx/listimpl.cpp"
33 #if WXWIN_COMPATIBILITY_2_4
34 #include "wx/notebook.h"
37 //---------------------------------------------------------------------------
39 IMPLEMENT_CLASS(wxSizerItem
, wxObject
)
40 IMPLEMENT_CLASS(wxSizer
, wxObject
)
41 IMPLEMENT_CLASS(wxGridSizer
, wxSizer
)
42 IMPLEMENT_CLASS(wxFlexGridSizer
, wxGridSizer
)
43 IMPLEMENT_CLASS(wxBoxSizer
, wxSizer
)
45 IMPLEMENT_CLASS(wxStaticBoxSizer
, wxBoxSizer
)
48 IMPLEMENT_CLASS(wxStdDialogButtonSizer
, wxBoxSizer
)
51 WX_DEFINE_EXPORTED_LIST( wxSizerItemList
)
86 // ----------------------------------------------------------------------------
88 // ----------------------------------------------------------------------------
90 void wxSizerItem::Init(const wxSizerFlags
& flags
)
94 m_proportion
= flags
.GetProportion();
95 m_flag
= flags
.GetFlags();
96 m_border
= flags
.GetBorderInPixels();
99 wxSizerItem::wxSizerItem()
111 void wxSizerItem::SetWindow(wxWindow
*window
)
113 wxCHECK_RET( window
, _T("NULL window in wxSizerItem::SetWindow()") );
115 m_kind
= Item_Window
;
118 // window doesn't become smaller than its initial size, whatever happens
119 m_minSize
= window
->GetSize();
121 if ( m_flag
& wxFIXED_MINSIZE
)
122 window
->SetMinSize(m_minSize
);
124 // aspect ratio calculated from initial size
128 wxSizerItem::wxSizerItem(wxWindow
*window
,
133 : m_proportion(proportion
),
142 void wxSizerItem::SetSizer(wxSizer
*sizer
)
148 wxSizerItem::wxSizerItem(wxSizer
*sizer
,
153 : m_proportion(proportion
),
161 // m_minSize is set later
165 void wxSizerItem::SetSpacer(const wxSize
& size
)
167 m_kind
= Item_Spacer
;
168 m_spacer
= new wxSizerSpacer(size
);
173 wxSizerItem::wxSizerItem(int width
,
179 : m_minSize(width
, height
), // minimal size is the initial size
180 m_proportion(proportion
),
185 SetSpacer(width
, height
);
188 wxSizerItem::~wxSizerItem()
198 m_window
->SetContainingSizer(NULL
);
211 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
215 wxSize
wxSizerItem::GetSpacer() const
218 if ( m_kind
== Item_Spacer
)
219 size
= m_spacer
->GetSize();
225 wxSize
wxSizerItem::GetSize() const
234 ret
= m_window
->GetSize();
238 ret
= m_sizer
->GetSize();
242 ret
= m_spacer
->GetSize();
247 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
254 if (m_flag
& wxNORTH
)
256 if (m_flag
& wxSOUTH
)
262 wxSize
wxSizerItem::CalcMin()
266 m_minSize
= m_sizer
->GetMinSize();
268 // if we have to preserve aspect ratio _AND_ this is
269 // the first-time calculation, consider ret to be initial size
270 if ( (m_flag
& wxSHAPED
) && wxIsNullDouble(m_ratio
) )
273 else if ( IsWindow() )
275 // Since the size of the window may change during runtime, we
276 // should use the current minimal/best size.
277 m_minSize
= m_window
->GetBestFittingSize();
280 return GetMinSizeWithBorder();
283 wxSize
wxSizerItem::GetMinSizeWithBorder() const
285 wxSize ret
= m_minSize
;
291 if (m_flag
& wxNORTH
)
293 if (m_flag
& wxSOUTH
)
300 void wxSizerItem::SetDimension( const wxPoint
& pos_
, const wxSize
& size_
)
304 if (m_flag
& wxSHAPED
)
306 // adjust aspect ratio
307 int rwidth
= (int) (size
.y
* m_ratio
);
311 int rheight
= (int) (size
.x
/ m_ratio
);
312 // add vertical space
313 if (m_flag
& wxALIGN_CENTER_VERTICAL
)
314 pos
.y
+= (size
.y
- rheight
) / 2;
315 else if (m_flag
& wxALIGN_BOTTOM
)
316 pos
.y
+= (size
.y
- rheight
);
317 // use reduced dimensions
320 else if (rwidth
< size
.x
)
322 // add horizontal space
323 if (m_flag
& wxALIGN_CENTER_HORIZONTAL
)
324 pos
.x
+= (size
.x
- rwidth
) / 2;
325 else if (m_flag
& wxALIGN_RIGHT
)
326 pos
.x
+= (size
.x
- rwidth
);
331 // This is what GetPosition() returns. Since we calculate
332 // borders afterwards, GetPosition() will be the left/top
333 // corner of the surrounding border.
345 if (m_flag
& wxNORTH
)
350 if (m_flag
& wxSOUTH
)
355 m_rect
= wxRect(pos
, size
);
360 wxFAIL_MSG( _T("can't set size of uninitialized sizer item") );
364 m_window
->SetSize(pos
.x
, pos
.y
, size
.x
, size
.y
,
365 wxSIZE_ALLOW_MINUS_ONE
);
369 m_sizer
->SetDimension(pos
.x
, pos
.y
, size
.x
, size
.y
);
373 m_spacer
->SetSize(size
);
378 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
382 void wxSizerItem::DeleteWindows()
391 //We are deleting the window from this sizer - normally
392 //the window destroys the sizer associated with it,
393 //which might destroy this, which we don't want
394 m_window
->SetContainingSizer(NULL
);
396 //Putting this after the switch will result in a spacer
397 //not being deleted properly on destruction
402 m_sizer
->DeleteWindows();
407 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
412 void wxSizerItem::Show( bool show
)
417 wxFAIL_MSG( _T("can't show uninitialized sizer item") );
421 m_window
->Show(show
);
429 m_spacer
->Show(show
);
434 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
438 bool wxSizerItem::IsShown() const
443 // we may be called from CalcMin(), just return false so that we're
448 return m_window
->IsShown();
451 // arbitrarily decide that if at least one of our elements is
452 // shown, so are we (this arbitrariness is the reason for
453 // deprecating this function)
455 for ( wxSizerItemList::compatibility_iterator
456 node
= m_sizer
->GetChildren().GetFirst();
458 node
= node
->GetNext() )
460 if ( node
->GetData()->IsShown() )
467 return m_spacer
->IsShown();
471 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
477 #if WXWIN_COMPATIBILITY_2_6
478 void wxSizerItem::SetOption( int option
)
480 SetProportion( option
);
483 int wxSizerItem::GetOption() const
485 return GetProportion();
487 #endif // WXWIN_COMPATIBILITY_2_6
490 //---------------------------------------------------------------------------
492 //---------------------------------------------------------------------------
496 WX_CLEAR_LIST(wxSizerItemList
, m_children
);
499 wxSizerItem
* wxSizer::Insert( size_t index
, wxSizerItem
*item
)
501 m_children
.Insert( index
, item
);
503 if ( item
->GetWindow() )
504 item
->GetWindow()->SetContainingSizer( this );
509 #if WXWIN_COMPATIBILITY_2_6
510 bool wxSizer::Remove( wxWindow
*window
)
512 return Detach( window
);
514 #endif // WXWIN_COMPATIBILITY_2_6
516 bool wxSizer::Remove( wxSizer
*sizer
)
518 wxASSERT_MSG( sizer
, _T("Removing NULL sizer") );
520 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
523 wxSizerItem
*item
= node
->GetData();
525 if (item
->GetSizer() == sizer
)
528 m_children
.Erase( node
);
532 node
= node
->GetNext();
538 bool wxSizer::Remove( int index
)
540 wxCHECK_MSG( index
>= 0 && (size_t)index
< m_children
.GetCount(),
542 _T("Remove index is out of range") );
544 wxSizerItemList::compatibility_iterator node
= m_children
.Item( index
);
546 wxCHECK_MSG( node
, false, _T("Failed to find child node") );
548 wxSizerItem
*item
= node
->GetData();
550 if ( item
->IsWindow() )
551 item
->GetWindow()->SetContainingSizer( NULL
);
554 m_children
.Erase( node
);
558 bool wxSizer::Detach( wxSizer
*sizer
)
560 wxASSERT_MSG( sizer
, _T("Detaching NULL sizer") );
562 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
565 wxSizerItem
*item
= node
->GetData();
567 if (item
->GetSizer() == sizer
)
571 m_children
.Erase( node
);
574 node
= node
->GetNext();
580 bool wxSizer::Detach( wxWindow
*window
)
582 wxASSERT_MSG( window
, _T("Detaching NULL window") );
584 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
587 wxSizerItem
*item
= node
->GetData();
589 if (item
->GetWindow() == window
)
591 item
->GetWindow()->SetContainingSizer( NULL
);
593 m_children
.Erase( node
);
596 node
= node
->GetNext();
602 bool wxSizer::Detach( int index
)
604 wxCHECK_MSG( index
>= 0 && (size_t)index
< m_children
.GetCount(),
606 _T("Detach index is out of range") );
608 wxSizerItemList::compatibility_iterator node
= m_children
.Item( index
);
610 wxCHECK_MSG( node
, false, _T("Failed to find child node") );
612 wxSizerItem
*item
= node
->GetData();
614 if ( item
->IsSizer() )
616 else if ( item
->IsWindow() )
617 item
->GetWindow()->SetContainingSizer( NULL
);
620 m_children
.Erase( node
);
624 void wxSizer::Clear( bool delete_windows
)
626 // First clear the ContainingSizer pointers
627 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
630 wxSizerItem
*item
= node
->GetData();
632 if (item
->IsWindow())
633 item
->GetWindow()->SetContainingSizer( NULL
);
634 node
= node
->GetNext();
637 // Destroy the windows if needed
641 // Now empty the list
642 WX_CLEAR_LIST(wxSizerItemList
, m_children
);
645 void wxSizer::DeleteWindows()
647 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
650 wxSizerItem
*item
= node
->GetData();
652 item
->DeleteWindows();
653 node
= node
->GetNext();
657 wxSize
wxSizer::Fit( wxWindow
*window
)
659 wxSize
size(window
->IsTopLevel() ? FitSize(window
)
660 : GetMinWindowSize(window
));
662 window
->SetSize( size
);
667 void wxSizer::FitInside( wxWindow
*window
)
670 if (window
->IsTopLevel())
671 size
= VirtualFitSize( window
);
673 size
= GetMinClientSize( window
);
675 window
->SetVirtualSize( size
);
678 void wxSizer::Layout()
680 // (re)calculates minimums needed for each item and other preparations
684 // Applies the layout and repositions/resizes the items
688 void wxSizer::SetSizeHints( wxWindow
*window
)
690 // Preserve the window's max size hints, but set the
691 // lower bound according to the sizer calculations.
693 wxSize size
= Fit( window
);
695 window
->SetSizeHints( size
.x
,
697 window
->GetMaxWidth(),
698 window
->GetMaxHeight() );
701 void wxSizer::SetVirtualSizeHints( wxWindow
*window
)
703 // Preserve the window's max size hints, but set the
704 // lower bound according to the sizer calculations.
707 wxSize
size( window
->GetVirtualSize() );
708 window
->SetVirtualSizeHints( size
.x
,
710 window
->GetMaxWidth(),
711 window
->GetMaxHeight() );
714 wxSize
wxSizer::GetMaxWindowSize( wxWindow
*window
) const
716 return window
->GetMaxSize();
719 wxSize
wxSizer::GetMinWindowSize( wxWindow
*window
)
721 wxSize
minSize( GetMinSize() );
722 wxSize
size( window
->GetSize() );
723 wxSize
client_size( window
->GetClientSize() );
725 return wxSize( minSize
.x
+size
.x
-client_size
.x
,
726 minSize
.y
+size
.y
-client_size
.y
);
729 // TODO on mac we need a function that determines how much free space this
730 // min size contains, in order to make sure that we have 20 pixels of free
731 // space around the controls
733 // Return a window size that will fit within the screens dimensions
734 wxSize
wxSizer::FitSize( wxWindow
*window
)
736 if ( window
->IsTopLevel() )
738 wxTopLevelWindow
*tlw
= wxDynamicCast(window
, wxTopLevelWindow
);
739 if ( tlw
&& tlw
->IsAlwaysMaximized() )
741 return tlw
->GetClientSize();
745 wxSize size
= GetMinWindowSize( window
);
746 wxSize sizeMax
= GetMaxWindowSize( window
);
748 // Limit the size if sizeMax != wxDefaultSize
750 if ( size
.x
> sizeMax
.x
&& sizeMax
.x
!= wxDefaultCoord
)
752 if ( size
.y
> sizeMax
.y
&& sizeMax
.y
!= wxDefaultCoord
)
758 wxSize
wxSizer::GetMaxClientSize( wxWindow
*window
) const
760 wxSize
maxSize( window
->GetMaxSize() );
762 if ( maxSize
!= wxDefaultSize
)
764 wxSize
size( window
->GetSize() );
765 wxSize
client_size( window
->GetClientSize() );
767 return wxSize( maxSize
.x
+ client_size
.x
- size
.x
,
768 maxSize
.y
+ client_size
.y
- size
.y
);
771 return wxDefaultSize
;
774 wxSize
wxSizer::GetMinClientSize( wxWindow
*WXUNUSED(window
) )
776 return GetMinSize(); // Already returns client size.
779 wxSize
wxSizer::VirtualFitSize( wxWindow
*window
)
781 wxSize size
= GetMinClientSize( window
);
782 wxSize sizeMax
= GetMaxClientSize( window
);
784 // Limit the size if sizeMax != wxDefaultSize
786 if ( size
.x
> sizeMax
.x
&& sizeMax
.x
!= wxDefaultCoord
)
788 if ( size
.y
> sizeMax
.y
&& sizeMax
.y
!= wxDefaultCoord
)
794 void wxSizer::SetDimension( int x
, int y
, int width
, int height
)
803 wxSize
wxSizer::GetMinSize()
805 wxSize
ret( CalcMin() );
806 if (ret
.x
< m_minSize
.x
) ret
.x
= m_minSize
.x
;
807 if (ret
.y
< m_minSize
.y
) ret
.y
= m_minSize
.y
;
811 void wxSizer::DoSetMinSize( int width
, int height
)
814 m_minSize
.y
= height
;
817 bool wxSizer::DoSetItemMinSize( wxWindow
*window
, int width
, int height
)
819 wxASSERT_MSG( window
, _T("SetMinSize for NULL window") );
821 // Is it our immediate child?
823 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
826 wxSizerItem
*item
= node
->GetData();
828 if (item
->GetWindow() == window
)
830 item
->SetMinSize( width
, height
);
833 node
= node
->GetNext();
836 // No? Search any subsizers we own then
838 node
= m_children
.GetFirst();
841 wxSizerItem
*item
= node
->GetData();
843 if ( item
->GetSizer() &&
844 item
->GetSizer()->DoSetItemMinSize( window
, width
, height
) )
846 // A child sizer found the requested windw, exit.
849 node
= node
->GetNext();
855 bool wxSizer::DoSetItemMinSize( wxSizer
*sizer
, int width
, int height
)
857 wxASSERT_MSG( sizer
, _T("SetMinSize for NULL sizer") );
859 // Is it our immediate child?
861 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
864 wxSizerItem
*item
= node
->GetData();
866 if (item
->GetSizer() == sizer
)
868 item
->GetSizer()->DoSetMinSize( width
, height
);
871 node
= node
->GetNext();
874 // No? Search any subsizers we own then
876 node
= m_children
.GetFirst();
879 wxSizerItem
*item
= node
->GetData();
881 if ( item
->GetSizer() &&
882 item
->GetSizer()->DoSetItemMinSize( sizer
, width
, height
) )
884 // A child found the requested sizer, exit.
887 node
= node
->GetNext();
893 bool wxSizer::DoSetItemMinSize( size_t index
, int width
, int height
)
895 wxSizerItemList::compatibility_iterator node
= m_children
.Item( index
);
897 wxCHECK_MSG( node
, false, _T("Failed to find child node") );
899 wxSizerItem
*item
= node
->GetData();
901 if (item
->GetSizer())
903 // Sizers contains the minimal size in them, if not calculated ...
904 item
->GetSizer()->DoSetMinSize( width
, height
);
908 // ... but the minimal size of spacers and windows is stored via the item
909 item
->SetMinSize( width
, height
);
915 wxSizerItem
* wxSizer::GetItem( wxWindow
*window
, bool recursive
)
917 wxASSERT_MSG( window
, _T("GetItem for NULL window") );
919 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
922 wxSizerItem
*item
= node
->GetData();
924 if (item
->GetWindow() == window
)
928 else if (recursive
&& item
->IsSizer())
930 wxSizerItem
*subitem
= item
->GetSizer()->GetItem( window
, true );
935 node
= node
->GetNext();
941 wxSizerItem
* wxSizer::GetItem( wxSizer
*sizer
, bool recursive
)
943 wxASSERT_MSG( sizer
, _T("GetItem for NULL sizer") );
945 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
948 wxSizerItem
*item
= node
->GetData();
950 if (item
->GetSizer() == sizer
)
954 else if (recursive
&& item
->IsSizer())
956 wxSizerItem
*subitem
= item
->GetSizer()->GetItem( sizer
, true );
961 node
= node
->GetNext();
967 wxSizerItem
* wxSizer::GetItem( size_t index
)
969 wxCHECK_MSG( index
< m_children
.GetCount(),
971 _T("GetItem index is out of range") );
973 return m_children
.Item( index
)->GetData();
976 bool wxSizer::Show( wxWindow
*window
, bool show
, bool recursive
)
978 wxSizerItem
*item
= GetItem( window
, recursive
);
989 bool wxSizer::Show( wxSizer
*sizer
, bool show
, bool recursive
)
991 wxSizerItem
*item
= GetItem( sizer
, recursive
);
1002 bool wxSizer::Show( size_t index
, bool show
)
1004 wxSizerItem
*item
= GetItem( index
);
1015 void wxSizer::ShowItems( bool show
)
1017 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1020 node
->GetData()->Show( show
);
1021 node
= node
->GetNext();
1025 bool wxSizer::IsShown( wxWindow
*window
) const
1027 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1030 wxSizerItem
*item
= node
->GetData();
1032 if (item
->GetWindow() == window
)
1034 return item
->IsShown();
1036 node
= node
->GetNext();
1039 wxFAIL_MSG( _T("IsShown failed to find sizer item") );
1044 bool wxSizer::IsShown( wxSizer
*sizer
) const
1046 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1049 wxSizerItem
*item
= node
->GetData();
1051 if (item
->GetSizer() == sizer
)
1053 return item
->IsShown();
1055 node
= node
->GetNext();
1058 wxFAIL_MSG( _T("IsShown failed to find sizer item") );
1063 bool wxSizer::IsShown( size_t index
) const
1065 wxCHECK_MSG( index
< m_children
.GetCount(),
1067 _T("IsShown index is out of range") );
1069 return m_children
.Item( index
)->GetData()->IsShown();
1073 //---------------------------------------------------------------------------
1075 //---------------------------------------------------------------------------
1077 wxGridSizer::wxGridSizer( int rows
, int cols
, int vgap
, int hgap
)
1078 : m_rows( ( cols
== 0 && rows
== 0 ) ? 1 : rows
)
1085 wxGridSizer::wxGridSizer( int cols
, int vgap
, int hgap
)
1086 : m_rows( cols
== 0 ? 1 : 0 )
1093 int wxGridSizer::CalcRowsCols(int& nrows
, int& ncols
) const
1095 int nitems
= m_children
.GetCount();
1101 nrows
= (nitems
+ m_cols
- 1) / m_cols
;
1105 ncols
= (nitems
+ m_rows
- 1) / m_rows
;
1108 else // 0 columns, 0 rows?
1110 wxFAIL_MSG( _T("grid sizer must have either rows or columns fixed") );
1119 void wxGridSizer::RecalcSizes()
1121 int nitems
, nrows
, ncols
;
1122 if ( (nitems
= CalcRowsCols(nrows
, ncols
)) == 0 )
1125 wxSize
sz( GetSize() );
1126 wxPoint
pt( GetPosition() );
1128 int w
= (sz
.x
- (ncols
- 1) * m_hgap
) / ncols
;
1129 int h
= (sz
.y
- (nrows
- 1) * m_vgap
) / nrows
;
1132 for (int c
= 0; c
< ncols
; c
++)
1135 for (int r
= 0; r
< nrows
; r
++)
1137 int i
= r
* ncols
+ c
;
1140 wxSizerItemList::compatibility_iterator node
= m_children
.Item( i
);
1142 wxASSERT_MSG( node
, _T("Failed to find SizerItemList node") );
1144 SetItemBounds( node
->GetData(), x
, y
, w
, h
);
1152 wxSize
wxGridSizer::CalcMin()
1155 if ( CalcRowsCols(nrows
, ncols
) == 0 )
1156 return wxSize(10, 10);
1158 // Find the max width and height for any component
1162 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1165 wxSizerItem
*item
= node
->GetData();
1166 wxSize
sz( item
->CalcMin() );
1168 w
= wxMax( w
, sz
.x
);
1169 h
= wxMax( h
, sz
.y
);
1171 node
= node
->GetNext();
1174 return wxSize( ncols
* w
+ (ncols
-1) * m_hgap
,
1175 nrows
* h
+ (nrows
-1) * m_vgap
);
1178 void wxGridSizer::SetItemBounds( wxSizerItem
*item
, int x
, int y
, int w
, int h
)
1181 wxSize
sz( item
->GetMinSizeWithBorder() );
1182 int flag
= item
->GetFlag();
1184 if ((flag
& wxEXPAND
) || (flag
& wxSHAPED
))
1190 if (flag
& wxALIGN_CENTER_HORIZONTAL
)
1192 pt
.x
= x
+ (w
- sz
.x
) / 2;
1194 else if (flag
& wxALIGN_RIGHT
)
1196 pt
.x
= x
+ (w
- sz
.x
);
1199 if (flag
& wxALIGN_CENTER_VERTICAL
)
1201 pt
.y
= y
+ (h
- sz
.y
) / 2;
1203 else if (flag
& wxALIGN_BOTTOM
)
1205 pt
.y
= y
+ (h
- sz
.y
);
1209 item
->SetDimension(pt
, sz
);
1212 //---------------------------------------------------------------------------
1214 //---------------------------------------------------------------------------
1216 wxFlexGridSizer::wxFlexGridSizer( int rows
, int cols
, int vgap
, int hgap
)
1217 : wxGridSizer( rows
, cols
, vgap
, hgap
),
1218 m_flexDirection(wxBOTH
),
1219 m_growMode(wxFLEX_GROWMODE_SPECIFIED
)
1223 wxFlexGridSizer::wxFlexGridSizer( int cols
, int vgap
, int hgap
)
1224 : wxGridSizer( cols
, vgap
, hgap
),
1225 m_flexDirection(wxBOTH
),
1226 m_growMode(wxFLEX_GROWMODE_SPECIFIED
)
1230 wxFlexGridSizer::~wxFlexGridSizer()
1234 void wxFlexGridSizer::RecalcSizes()
1236 int nitems
, nrows
, ncols
;
1237 if ( (nitems
= CalcRowsCols(nrows
, ncols
)) == 0 )
1240 wxPoint
pt( GetPosition() );
1241 wxSize
sz( GetSize() );
1243 AdjustForGrowables(sz
, m_calculatedMinSize
, nrows
, ncols
);
1245 sz
= wxSize( pt
.x
+ sz
.x
, pt
.y
+ sz
.y
);
1248 for (int c
= 0; c
< ncols
; c
++)
1251 for (int r
= 0; r
< nrows
; r
++)
1253 int i
= r
* ncols
+ c
;
1256 wxSizerItemList::compatibility_iterator node
= m_children
.Item( i
);
1258 wxASSERT_MSG( node
, _T("Failed to find node") );
1260 int w
= wxMax( 0, wxMin( m_colWidths
[c
], sz
.x
- x
) );
1261 int h
= wxMax( 0, wxMin( m_rowHeights
[r
], sz
.y
- y
) );
1263 SetItemBounds( node
->GetData(), x
, y
, w
, h
);
1265 if (m_rowHeights
[r
] != -1)
1266 y
= y
+ m_rowHeights
[r
] + m_vgap
;
1268 if (m_colWidths
[c
] != -1)
1269 x
= x
+ m_colWidths
[c
] + m_hgap
;
1273 wxSize
wxFlexGridSizer::CalcMin()
1279 // Number of rows/columns can change as items are added or removed.
1280 if ( !CalcRowsCols(nrows
, ncols
) )
1281 return wxSize(10, 10);
1283 m_rowHeights
.SetCount(nrows
);
1284 m_colWidths
.SetCount(ncols
);
1286 // We have to recalcuate the sizes in case the item minimum size has
1287 // changed since the previous layout, or the item has been hidden using
1288 // wxSizer::Show(). If all the items in a row/column are hidden, the final
1289 // dimension of the row/column will be -1, indicating that the column
1290 // itself is hidden.
1291 for( s
= m_rowHeights
.GetCount(), i
= 0; i
< s
; ++i
)
1292 m_rowHeights
[ i
] = -1;
1293 for( s
= m_colWidths
.GetCount(), i
= 0; i
< s
; ++i
)
1294 m_colWidths
[ i
] = -1;
1296 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1301 wxSizerItem
*item
= node
->GetData();
1302 if ( item
->IsShown() )
1304 wxSize
sz( item
->CalcMin() );
1305 int row
= i
/ ncols
;
1306 int col
= i
% ncols
;
1308 m_rowHeights
[ row
] = wxMax( wxMax( 0, sz
.y
), m_rowHeights
[ row
] );
1309 m_colWidths
[ col
] = wxMax( wxMax( 0, sz
.x
), m_colWidths
[ col
] );
1312 node
= node
->GetNext();
1316 AdjustForFlexDirection();
1318 // Sum total minimum size, including gaps between rows/columns.
1319 // -1 is used as a magic number meaning empty column.
1321 for (int col
= 0; col
< ncols
; col
++)
1322 if ( m_colWidths
[ col
] != -1 )
1323 width
+= m_colWidths
[ col
] + m_hgap
;
1328 for (int row
= 0; row
< nrows
; row
++)
1329 if ( m_rowHeights
[ row
] != -1 )
1330 height
+= m_rowHeights
[ row
] + m_vgap
;
1334 m_calculatedMinSize
= wxSize( width
, height
);
1335 return m_calculatedMinSize
;
1338 void wxFlexGridSizer::AdjustForFlexDirection()
1340 // the logic in CalcMin works when we resize flexibly in both directions
1341 // but maybe this is not the case
1342 if ( m_flexDirection
!= wxBOTH
)
1344 // select the array corresponding to the direction in which we do *not*
1346 wxArrayInt
& array
= m_flexDirection
== wxVERTICAL
? m_colWidths
1349 const size_t count
= array
.GetCount();
1351 // find the largest value in this array
1355 for ( n
= 0; n
< count
; ++n
)
1357 if ( array
[n
] > largest
)
1361 // and now fill it with the largest value
1362 for ( n
= 0; n
< count
; ++n
)
1370 void wxFlexGridSizer::AdjustForGrowables(const wxSize
& sz
, const wxSize
& minsz
,
1371 int nrows
, int ncols
)
1373 // what to do with the rows? by default, resize them proportionally
1374 if ( sz
.y
> minsz
.y
&& ( (m_flexDirection
& wxVERTICAL
) || (m_growMode
== wxFLEX_GROWMODE_SPECIFIED
) ) )
1376 int sum_proportions
= 0;
1377 int growable_space
= 0;
1380 for (idx
= 0; idx
< m_growableRows
.GetCount(); idx
++)
1382 // Since the number of rows/columns can change as items are
1383 // inserted/deleted, we need to verify at runtime that the
1384 // requested growable rows/columns are still valid.
1385 if (m_growableRows
[idx
] >= nrows
)
1388 // If all items in a row/column are hidden, that row/column will
1389 // have a dimension of -1. This causes the row/column to be
1390 // hidden completely.
1391 if (m_rowHeights
[ m_growableRows
[idx
] ] == -1)
1393 sum_proportions
+= m_growableRowsProportions
[idx
];
1394 growable_space
+= m_rowHeights
[ m_growableRows
[idx
] ];
1400 for (idx
= 0; idx
< m_growableRows
.GetCount(); idx
++)
1402 if (m_growableRows
[idx
] >= nrows
)
1404 if (m_rowHeights
[ m_growableRows
[idx
] ] == -1)
1405 m_rowHeights
[ m_growableRows
[idx
] ] = 0;
1408 int delta
= (sz
.y
- minsz
.y
);
1409 if (sum_proportions
== 0)
1410 delta
= (delta
/num
) + m_rowHeights
[ m_growableRows
[idx
] ];
1412 delta
= ((delta
+growable_space
)*m_growableRowsProportions
[idx
]) / sum_proportions
;
1413 m_rowHeights
[ m_growableRows
[idx
] ] = delta
;
1418 else if ( (m_growMode
== wxFLEX_GROWMODE_ALL
) && (sz
.y
> minsz
.y
) )
1420 // rounding problem?
1421 for ( int row
= 0; row
< nrows
; ++row
)
1422 m_rowHeights
[ row
] = sz
.y
/ nrows
;
1425 // the same logic as above but for the columns
1426 if ( sz
.x
> minsz
.x
&& ( (m_flexDirection
& wxHORIZONTAL
) || (m_growMode
== wxFLEX_GROWMODE_SPECIFIED
) ) )
1428 int sum_proportions
= 0;
1429 int growable_space
= 0;
1432 for (idx
= 0; idx
< m_growableCols
.GetCount(); idx
++)
1434 // Since the number of rows/columns can change as items are
1435 // inserted/deleted, we need to verify at runtime that the
1436 // requested growable rows/columns are still valid.
1437 if (m_growableCols
[idx
] >= ncols
)
1440 // If all items in a row/column are hidden, that row/column will
1441 // have a dimension of -1. This causes the column to be hidden
1443 if (m_colWidths
[ m_growableCols
[idx
] ] == -1)
1445 sum_proportions
+= m_growableColsProportions
[idx
];
1446 growable_space
+= m_colWidths
[ m_growableCols
[idx
] ];
1452 for (idx
= 0; idx
< m_growableCols
.GetCount(); idx
++)
1454 if (m_growableCols
[idx
] >= ncols
)
1456 if (m_colWidths
[ m_growableCols
[idx
] ] == -1)
1457 m_colWidths
[ m_growableCols
[idx
] ] = 0;
1460 int delta
= (sz
.x
- minsz
.x
);
1461 if (sum_proportions
== 0)
1462 delta
= (delta
/num
) + m_colWidths
[ m_growableCols
[idx
] ];
1464 delta
= ((delta
+growable_space
)*m_growableColsProportions
[idx
])/sum_proportions
;
1465 m_colWidths
[ m_growableCols
[idx
] ] = delta
;
1470 else if ( (m_growMode
== wxFLEX_GROWMODE_ALL
) && (sz
.x
> minsz
.x
) )
1472 for ( int col
=0; col
< ncols
; ++col
)
1473 m_colWidths
[ col
] = sz
.x
/ ncols
;
1478 void wxFlexGridSizer::AddGrowableRow( size_t idx
, int proportion
)
1480 m_growableRows
.Add( idx
);
1481 m_growableRowsProportions
.Add( proportion
);
1484 void wxFlexGridSizer::AddGrowableCol( size_t idx
, int proportion
)
1486 m_growableCols
.Add( idx
);
1487 m_growableColsProportions
.Add( proportion
);
1490 // helper function for RemoveGrowableCol/Row()
1492 DoRemoveFromArrays(size_t idx
, wxArrayInt
& items
, wxArrayInt
& proportions
)
1494 const size_t count
= items
.size();
1495 for ( size_t n
= 0; n
< count
; n
++ )
1497 if ( (size_t)items
[n
] == idx
)
1500 proportions
.RemoveAt(n
);
1505 wxFAIL_MSG( _T("column/row is already not growable") );
1508 void wxFlexGridSizer::RemoveGrowableCol( size_t idx
)
1510 DoRemoveFromArrays(idx
, m_growableCols
, m_growableColsProportions
);
1513 void wxFlexGridSizer::RemoveGrowableRow( size_t idx
)
1515 DoRemoveFromArrays(idx
, m_growableRows
, m_growableRowsProportions
);
1518 //---------------------------------------------------------------------------
1520 //---------------------------------------------------------------------------
1522 wxBoxSizer::wxBoxSizer( int orient
)
1523 : m_orient( orient
)
1527 void wxBoxSizer::RecalcSizes()
1529 if (m_children
.GetCount() == 0)
1535 if (m_orient
== wxHORIZONTAL
)
1536 delta
= m_size
.x
- m_fixedWidth
;
1538 delta
= m_size
.y
- m_fixedHeight
;
1541 wxPoint
pt( m_position
);
1543 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1546 wxSizerItem
*item
= node
->GetData();
1548 if (item
->IsShown())
1550 wxSize
size( item
->GetMinSizeWithBorder() );
1552 if (m_orient
== wxVERTICAL
)
1554 wxCoord height
= size
.y
;
1555 if (item
->GetProportion())
1557 // Because of at least one visible item has non-zero
1558 // proportion then m_stretchable is not zero
1559 height
= (delta
* item
->GetProportion()) / m_stretchable
;
1562 wxPoint
child_pos( pt
);
1563 wxSize
child_size( size
.x
, height
);
1565 if (item
->GetFlag() & (wxEXPAND
| wxSHAPED
))
1566 child_size
.x
= m_size
.x
;
1567 else if (item
->GetFlag() & wxALIGN_RIGHT
)
1568 child_pos
.x
+= m_size
.x
- size
.x
;
1569 else if (item
->GetFlag() & (wxCENTER
| wxALIGN_CENTER_HORIZONTAL
))
1570 // XXX wxCENTER is added for backward compatibility;
1571 // wxALIGN_CENTER should be used in new code
1572 child_pos
.x
+= (m_size
.x
- size
.x
) / 2;
1574 item
->SetDimension( child_pos
, child_size
);
1580 wxCoord width
= size
.x
;
1581 if (item
->GetProportion())
1583 // Because of at least one visible item has non-zero
1584 // proportion then m_stretchable is not zero
1585 width
= (delta
* item
->GetProportion()) / m_stretchable
;
1588 wxPoint
child_pos( pt
);
1589 wxSize
child_size( width
, size
.y
);
1591 if (item
->GetFlag() & (wxEXPAND
| wxSHAPED
))
1592 child_size
.y
= m_size
.y
;
1593 else if (item
->GetFlag() & wxALIGN_BOTTOM
)
1594 child_pos
.y
+= m_size
.y
- size
.y
;
1595 else if (item
->GetFlag() & (wxCENTER
| wxALIGN_CENTER_VERTICAL
))
1596 // XXX wxCENTER is added for backward compatibility;
1597 // wxALIGN_CENTER should be used in new code
1598 child_pos
.y
+= (m_size
.y
- size
.y
) / 2;
1600 item
->SetDimension( child_pos
, child_size
);
1606 node
= node
->GetNext();
1610 wxSize
wxBoxSizer::CalcMin()
1612 if (m_children
.GetCount() == 0)
1613 return wxSize(10,10);
1621 // precalc item minsizes and count proportions
1622 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1625 wxSizerItem
*item
= node
->GetData();
1627 if ( item
->IsShown() )
1629 item
->CalcMin(); // result is stored in the item
1631 m_stretchable
+= item
->GetProportion();
1634 node
= node
->GetNext();
1637 // Total minimum size (width or height) of sizer
1640 node
= m_children
.GetFirst();
1643 wxSizerItem
*item
= node
->GetData();
1645 if (item
->IsShown() && item
->GetProportion() != 0)
1647 int stretch
= item
->GetProportion();
1648 wxSize
size( item
->GetMinSizeWithBorder() );
1651 // Integer division rounded up is (a + b - 1) / b
1652 // Round up needed in order to guarantee that all
1653 // all items will have size not less then their min size
1654 if (m_orient
== wxHORIZONTAL
)
1655 minSize
= ( size
.x
*m_stretchable
+ stretch
- 1)/stretch
;
1657 minSize
= ( size
.y
*m_stretchable
+ stretch
- 1)/stretch
;
1659 if (minSize
> maxMinSize
)
1660 maxMinSize
= minSize
;
1662 node
= node
->GetNext();
1665 // Calculate overall minimum size
1666 node
= m_children
.GetFirst();
1669 wxSizerItem
*item
= node
->GetData();
1671 if (item
->IsShown())
1673 wxSize
size( item
->GetMinSizeWithBorder() );
1674 if (item
->GetProportion() != 0)
1676 if (m_orient
== wxHORIZONTAL
)
1677 size
.x
= (maxMinSize
*item
->GetProportion())/m_stretchable
;
1679 size
.y
= (maxMinSize
*item
->GetProportion())/m_stretchable
;
1683 if (m_orient
== wxVERTICAL
)
1685 m_fixedHeight
+= size
.y
;
1686 m_fixedWidth
= wxMax( m_fixedWidth
, size
.x
);
1690 m_fixedWidth
+= size
.x
;
1691 m_fixedHeight
= wxMax( m_fixedHeight
, size
.y
);
1695 if (m_orient
== wxHORIZONTAL
)
1697 m_minWidth
+= size
.x
;
1698 m_minHeight
= wxMax( m_minHeight
, size
.y
);
1702 m_minHeight
+= size
.y
;
1703 m_minWidth
= wxMax( m_minWidth
, size
.x
);
1706 node
= node
->GetNext();
1709 return wxSize( m_minWidth
, m_minHeight
);
1712 //---------------------------------------------------------------------------
1714 //---------------------------------------------------------------------------
1718 wxStaticBoxSizer::wxStaticBoxSizer( wxStaticBox
*box
, int orient
)
1719 : wxBoxSizer( orient
),
1722 wxASSERT_MSG( box
, wxT("wxStaticBoxSizer needs a static box") );
1724 // do this so that our Detach() is called if the static box is destroyed
1726 m_staticBox
->SetContainingSizer(this);
1729 wxStaticBoxSizer::wxStaticBoxSizer(int orient
, wxWindow
*win
, const wxString
& s
)
1730 : wxBoxSizer(orient
),
1731 m_staticBox(new wxStaticBox(win
, wxID_ANY
, s
))
1734 m_staticBox
->SetContainingSizer(this);
1737 wxStaticBoxSizer::~wxStaticBoxSizer()
1742 static void GetStaticBoxBorders( wxStaticBox
*box
,
1746 // this has to be done platform by platform as there is no way to
1747 // guess the thickness of a wxStaticBox border
1748 box
->GetBordersForSizer(borderTop
, borderOther
);
1751 void wxStaticBoxSizer::RecalcSizes()
1753 int top_border
, other_border
;
1754 GetStaticBoxBorders(m_staticBox
, &top_border
, &other_border
);
1756 m_staticBox
->SetSize( m_position
.x
, m_position
.y
, m_size
.x
, m_size
.y
);
1758 wxPoint
old_pos( m_position
);
1759 m_position
.x
+= other_border
;
1760 m_position
.y
+= top_border
;
1761 wxSize
old_size( m_size
);
1762 m_size
.x
-= 2*other_border
;
1763 m_size
.y
-= top_border
+ other_border
;
1765 wxBoxSizer::RecalcSizes();
1767 m_position
= old_pos
;
1771 wxSize
wxStaticBoxSizer::CalcMin()
1773 int top_border
, other_border
;
1774 GetStaticBoxBorders(m_staticBox
, &top_border
, &other_border
);
1776 wxSize
ret( wxBoxSizer::CalcMin() );
1777 ret
.x
+= 2*other_border
;
1778 ret
.y
+= other_border
+ top_border
;
1783 void wxStaticBoxSizer::ShowItems( bool show
)
1785 m_staticBox
->Show( show
);
1786 wxBoxSizer::ShowItems( show
);
1789 bool wxStaticBoxSizer::Detach( wxWindow
*window
)
1791 // avoid deleting m_staticBox in our dtor if it's being detached from the
1792 // sizer (which can happen because it's being already destroyed for
1794 if ( window
== m_staticBox
)
1800 return wxSizer::Detach( window
);
1803 #endif // wxUSE_STATBOX
1807 wxStdDialogButtonSizer::wxStdDialogButtonSizer()
1808 : wxBoxSizer(wxHORIZONTAL
)
1810 // Vertical buttons with lots of space on either side
1811 // looks rubbish on WinCE, so let's not do this for now.
1812 // If we are going to use vertical buttons, we should
1813 // put the sizer to the right of other controls in the dialog,
1814 // and that's beyond the scope of this sizer.
1816 bool is_pda
= (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA
);
1817 // If we have a PDA screen, put yes/no button over
1818 // all other buttons, otherwise on the left side.
1820 m_orient
= wxVERTICAL
;
1823 m_buttonAffirmative
= NULL
;
1824 m_buttonApply
= NULL
;
1825 m_buttonNegative
= NULL
;
1826 m_buttonCancel
= NULL
;
1827 m_buttonHelp
= NULL
;
1830 void wxStdDialogButtonSizer::AddButton(wxButton
*mybutton
)
1832 switch (mybutton
->GetId())
1837 m_buttonAffirmative
= mybutton
;
1840 m_buttonApply
= mybutton
;
1843 m_buttonNegative
= mybutton
;
1846 m_buttonCancel
= mybutton
;
1849 case wxID_CONTEXT_HELP
:
1850 m_buttonHelp
= mybutton
;
1857 void wxStdDialogButtonSizer::SetAffirmativeButton( wxButton
*button
)
1859 m_buttonAffirmative
= button
;
1862 void wxStdDialogButtonSizer::SetNegativeButton( wxButton
*button
)
1864 m_buttonNegative
= button
;
1867 void wxStdDialogButtonSizer::SetCancelButton( wxButton
*button
)
1869 m_buttonCancel
= button
;
1872 void wxStdDialogButtonSizer::Realize()
1875 Add(0, 0, 0, wxLEFT
, 6);
1877 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 6);
1879 if (m_buttonNegative
){
1880 // HIG POLICE BULLETIN - destructive buttons need extra padding
1881 // 24 pixels on either side
1882 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 12);
1885 // extra whitespace between help/negative and cancel/ok buttons
1886 Add(0, 0, 1, wxEXPAND
, 0);
1888 if (m_buttonCancel
){
1889 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 6);
1890 // Cancel or help should be default
1891 // m_buttonCancel->SetDefaultButton();
1894 // Ugh, Mac doesn't really have apply dialogs, so I'll just
1895 // figure the best place is between Cancel and OK
1897 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 6);
1899 if (m_buttonAffirmative
){
1900 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
, 6);
1902 if (m_buttonAffirmative
->GetId() == wxID_SAVE
){
1903 // these buttons have set labels under Mac so we should use them
1904 m_buttonAffirmative
->SetLabel(_("Save"));
1905 m_buttonNegative
->SetLabel(_("Don't Save"));
1909 // Extra space around and at the right
1911 #elif defined(__WXGTK20__)
1912 Add(0, 0, 0, wxLEFT
, 9);
1914 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
1916 // extra whitespace between help and cancel/ok buttons
1917 Add(0, 0, 1, wxEXPAND
, 0);
1919 if (m_buttonNegative
){
1920 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
1923 if (m_buttonCancel
){
1924 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
1925 // Cancel or help should be default
1926 // m_buttonCancel->SetDefaultButton();
1930 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
1932 if (m_buttonAffirmative
)
1933 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
, 6);
1934 #elif defined(__WXMSW__)
1937 // right-justify buttons
1938 Add(0, 0, 1, wxEXPAND
, 0);
1940 if (m_buttonAffirmative
){
1941 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonAffirmative
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1944 if (m_buttonNegative
){
1945 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonNegative
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1948 if (m_buttonCancel
){
1949 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonCancel
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1952 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonApply
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1955 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonHelp
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1957 // GTK+1 and any other platform
1959 // Add(0, 0, 0, wxLEFT, 5); // Not sure what this was for but it unbalances the dialog
1961 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonHelp
->ConvertDialogToPixels(wxSize(4, 0)).x
);
1963 // extra whitespace between help and cancel/ok buttons
1964 Add(0, 0, 1, wxEXPAND
, 0);
1967 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonApply
->ConvertDialogToPixels(wxSize(4, 0)).x
);
1969 if (m_buttonAffirmative
){
1970 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonAffirmative
->ConvertDialogToPixels(wxSize(4, 0)).x
);
1973 if (m_buttonNegative
){
1974 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonNegative
->ConvertDialogToPixels(wxSize(4, 0)).x
);
1977 if (m_buttonCancel
){
1978 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonCancel
->ConvertDialogToPixels(wxSize(4, 0)).x
);
1979 // Cancel or help should be default
1980 // m_buttonCancel->SetDefaultButton();
1986 #endif // wxUSE_BUTTON
1988 #if WXWIN_COMPATIBILITY_2_4
1990 // ----------------------------------------------------------------------------
1992 // ----------------------------------------------------------------------------
1995 IMPLEMENT_CLASS(wxBookCtrlSizer
, wxSizer
)
1997 IMPLEMENT_CLASS(wxNotebookSizer
, wxBookCtrlSizer
)
1998 #endif // wxUSE_NOTEBOOK
1999 #endif // wxUSE_BOOKCTRL
2003 #if WXWIN_COMPATIBILITY_2_6
2005 wxBookCtrlSizer::wxBookCtrlSizer(wxBookCtrlBase
*bookctrl
)
2006 : m_bookctrl(bookctrl
)
2008 wxASSERT_MSG( bookctrl
, wxT("wxBookCtrlSizer needs a control") );
2011 #endif // WXWIN_COMPATIBILITY_2_6
2013 void wxBookCtrlSizer::RecalcSizes()
2015 m_bookctrl
->SetSize( m_position
.x
, m_position
.y
, m_size
.x
, m_size
.y
);
2018 wxSize
wxBookCtrlSizer::CalcMin()
2020 wxSize sizeBorder
= m_bookctrl
->CalcSizeFromPage(wxSize(0,0));
2025 if ( m_bookctrl
->GetPageCount() == 0 )
2027 return wxSize(sizeBorder
.x
+ 10, sizeBorder
.y
+ 10);
2033 wxWindowList::compatibility_iterator
2034 node
= m_bookctrl
->GetChildren().GetFirst();
2037 wxWindow
*item
= node
->GetData();
2038 wxSizer
*itemsizer
= item
->GetSizer();
2042 wxSize
subsize( itemsizer
->CalcMin() );
2044 if (subsize
.x
> maxX
)
2046 if (subsize
.y
> maxY
)
2050 node
= node
->GetNext();
2053 return wxSize( maxX
, maxY
) + sizeBorder
;
2058 #if WXWIN_COMPATIBILITY_2_6
2060 wxNotebookSizer::wxNotebookSizer(wxNotebook
*nb
)
2062 wxASSERT_MSG( nb
, wxT("wxNotebookSizer needs a control") );
2066 #endif // WXWIN_COMPATIBILITY_2_6
2068 #endif // wxUSE_NOTEBOOOK
2069 #endif // wxUSE_BOOKCTRL
2071 #endif // WXWIN_COMPATIBILITY_2_4