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"
20 #include "wx/display.h"
24 #include "wx/string.h"
28 #include "wx/settings.h"
29 #include "wx/button.h"
30 #include "wx/statbox.h"
31 #include "wx/toplevel.h"
34 #include "wx/listimpl.cpp"
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()
110 void wxSizerItem::DoSetWindow(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
,
133 m_proportion(proportion
),
143 void wxSizerItem::DoSetSizer(wxSizer
*sizer
)
149 wxSizerItem::wxSizerItem(wxSizer
*sizer
,
156 m_proportion(proportion
),
165 // m_minSize is set later
169 void wxSizerItem::DoSetSpacer(const wxSize
& size
)
171 m_kind
= Item_Spacer
;
172 m_spacer
= new wxSizerSpacer(size
);
177 wxSizerItem::wxSizerItem(int width
,
185 m_minSize(width
, height
), // minimal size is the initial size
186 m_proportion(proportion
),
192 DoSetSpacer(wxSize(width
, height
));
195 wxSizerItem::~wxSizerItem()
201 void wxSizerItem::Free()
209 m_window
->SetContainingSizer(NULL
);
222 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
228 wxSize
wxSizerItem::GetSpacer() const
231 if ( m_kind
== Item_Spacer
)
232 size
= m_spacer
->GetSize();
238 wxSize
wxSizerItem::GetSize() const
247 ret
= m_window
->GetSize();
251 ret
= m_sizer
->GetSize();
255 ret
= m_spacer
->GetSize();
260 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
267 if (m_flag
& wxNORTH
)
269 if (m_flag
& wxSOUTH
)
275 wxSize
wxSizerItem::CalcMin()
279 m_minSize
= m_sizer
->GetMinSize();
281 // if we have to preserve aspect ratio _AND_ this is
282 // the first-time calculation, consider ret to be initial size
283 if ( (m_flag
& wxSHAPED
) && wxIsNullDouble(m_ratio
) )
286 else if ( IsWindow() )
288 // Since the size of the window may change during runtime, we
289 // should use the current minimal/best size.
290 m_minSize
= m_window
->GetEffectiveMinSize();
293 return GetMinSizeWithBorder();
296 wxSize
wxSizerItem::GetMinSizeWithBorder() const
298 wxSize ret
= m_minSize
;
304 if (m_flag
& wxNORTH
)
306 if (m_flag
& wxSOUTH
)
313 void wxSizerItem::SetDimension( const wxPoint
& pos_
, const wxSize
& size_
)
317 if (m_flag
& wxSHAPED
)
319 // adjust aspect ratio
320 int rwidth
= (int) (size
.y
* m_ratio
);
324 int rheight
= (int) (size
.x
/ m_ratio
);
325 // add vertical space
326 if (m_flag
& wxALIGN_CENTER_VERTICAL
)
327 pos
.y
+= (size
.y
- rheight
) / 2;
328 else if (m_flag
& wxALIGN_BOTTOM
)
329 pos
.y
+= (size
.y
- rheight
);
330 // use reduced dimensions
333 else if (rwidth
< size
.x
)
335 // add horizontal space
336 if (m_flag
& wxALIGN_CENTER_HORIZONTAL
)
337 pos
.x
+= (size
.x
- rwidth
) / 2;
338 else if (m_flag
& wxALIGN_RIGHT
)
339 pos
.x
+= (size
.x
- rwidth
);
344 // This is what GetPosition() returns. Since we calculate
345 // borders afterwards, GetPosition() will be the left/top
346 // corner of the surrounding border.
358 if (m_flag
& wxNORTH
)
363 if (m_flag
& wxSOUTH
)
373 m_rect
= wxRect(pos
, size
);
378 wxFAIL_MSG( _T("can't set size of uninitialized sizer item") );
382 m_window
->SetSize(pos
.x
, pos
.y
, size
.x
, size
.y
,
383 wxSIZE_ALLOW_MINUS_ONE
);
387 m_sizer
->SetDimension(pos
.x
, pos
.y
, size
.x
, size
.y
);
391 m_spacer
->SetSize(size
);
396 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
400 void wxSizerItem::DeleteWindows()
409 //We are deleting the window from this sizer - normally
410 //the window destroys the sizer associated with it,
411 //which might destroy this, which we don't want
412 m_window
->SetContainingSizer(NULL
);
414 //Putting this after the switch will result in a spacer
415 //not being deleted properly on destruction
420 m_sizer
->DeleteWindows();
425 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
430 void wxSizerItem::Show( bool show
)
435 wxFAIL_MSG( _T("can't show uninitialized sizer item") );
439 m_window
->Show(show
);
447 m_spacer
->Show(show
);
452 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
456 bool wxSizerItem::IsShown() const
461 // we may be called from CalcMin(), just return false so that we're
466 return m_window
->IsShown();
469 // arbitrarily decide that if at least one of our elements is
470 // shown, so are we (this arbitrariness is the reason for
471 // deprecating this function)
473 // Some apps (such as dialog editors) depend on an empty sizer still
474 // being laid out correctly and reporting the correct size and position.
475 if (m_sizer
->GetChildren().GetCount() == 0)
478 for ( wxSizerItemList::compatibility_iterator
479 node
= m_sizer
->GetChildren().GetFirst();
481 node
= node
->GetNext() )
483 if ( node
->GetData()->IsShown() )
490 return m_spacer
->IsShown();
494 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
500 #if WXWIN_COMPATIBILITY_2_6
501 void wxSizerItem::SetOption( int option
)
503 SetProportion( option
);
506 int wxSizerItem::GetOption() const
508 return GetProportion();
510 #endif // WXWIN_COMPATIBILITY_2_6
513 //---------------------------------------------------------------------------
515 //---------------------------------------------------------------------------
519 WX_CLEAR_LIST(wxSizerItemList
, m_children
);
522 wxSizerItem
* wxSizer::Insert( size_t index
, wxSizerItem
*item
)
524 m_children
.Insert( index
, item
);
526 if ( item
->GetWindow() )
527 item
->GetWindow()->SetContainingSizer( this );
529 if ( item
->GetSizer() )
530 item
->GetSizer()->SetContainingWindow( m_containingWindow
);
535 void wxSizer::SetContainingWindow(wxWindow
*win
)
537 if ( win
== m_containingWindow
)
540 m_containingWindow
= win
;
542 // set the same window for all nested sizers as well, they also are in the
544 for ( wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
546 node
= node
->GetNext() )
548 wxSizerItem
*const item
= node
->GetData();
549 wxSizer
*const sizer
= item
->GetSizer();
553 sizer
->SetContainingWindow(win
);
558 #if WXWIN_COMPATIBILITY_2_6
559 bool wxSizer::Remove( wxWindow
*window
)
561 return Detach( window
);
563 #endif // WXWIN_COMPATIBILITY_2_6
565 bool wxSizer::Remove( wxSizer
*sizer
)
567 wxASSERT_MSG( sizer
, _T("Removing NULL sizer") );
569 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
572 wxSizerItem
*item
= node
->GetData();
574 if (item
->GetSizer() == sizer
)
577 m_children
.Erase( node
);
581 node
= node
->GetNext();
587 bool wxSizer::Remove( int index
)
589 wxCHECK_MSG( index
>= 0 && (size_t)index
< m_children
.GetCount(),
591 _T("Remove index is out of range") );
593 wxSizerItemList::compatibility_iterator node
= m_children
.Item( index
);
595 wxCHECK_MSG( node
, false, _T("Failed to find child node") );
597 delete node
->GetData();
598 m_children
.Erase( node
);
603 bool wxSizer::Detach( wxSizer
*sizer
)
605 wxASSERT_MSG( sizer
, _T("Detaching NULL sizer") );
607 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
610 wxSizerItem
*item
= node
->GetData();
612 if (item
->GetSizer() == sizer
)
616 m_children
.Erase( node
);
619 node
= node
->GetNext();
625 bool wxSizer::Detach( wxWindow
*window
)
627 wxASSERT_MSG( window
, _T("Detaching NULL window") );
629 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
632 wxSizerItem
*item
= node
->GetData();
634 if (item
->GetWindow() == window
)
637 m_children
.Erase( node
);
640 node
= node
->GetNext();
646 bool wxSizer::Detach( int index
)
648 wxCHECK_MSG( index
>= 0 && (size_t)index
< m_children
.GetCount(),
650 _T("Detach index is out of range") );
652 wxSizerItemList::compatibility_iterator node
= m_children
.Item( index
);
654 wxCHECK_MSG( node
, false, _T("Failed to find child node") );
656 wxSizerItem
*item
= node
->GetData();
658 if ( item
->IsSizer() )
662 m_children
.Erase( node
);
666 bool wxSizer::Replace( wxWindow
*oldwin
, wxWindow
*newwin
, bool recursive
)
668 wxASSERT_MSG( oldwin
, _T("Replacing NULL window") );
669 wxASSERT_MSG( newwin
, _T("Replacing with NULL window") );
671 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
674 wxSizerItem
*item
= node
->GetData();
676 if (item
->GetWindow() == oldwin
)
678 item
->AssignWindow(newwin
);
679 newwin
->SetContainingSizer( this );
682 else if (recursive
&& item
->IsSizer())
684 if (item
->GetSizer()->Replace( oldwin
, newwin
, true ))
688 node
= node
->GetNext();
694 bool wxSizer::Replace( wxSizer
*oldsz
, wxSizer
*newsz
, bool recursive
)
696 wxASSERT_MSG( oldsz
, _T("Replacing NULL sizer") );
697 wxASSERT_MSG( newsz
, _T("Replacing with NULL sizer") );
699 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
702 wxSizerItem
*item
= node
->GetData();
704 if (item
->GetSizer() == oldsz
)
706 item
->AssignSizer(newsz
);
709 else if (recursive
&& item
->IsSizer())
711 if (item
->GetSizer()->Replace( oldsz
, newsz
, true ))
715 node
= node
->GetNext();
721 bool wxSizer::Replace( size_t old
, wxSizerItem
*newitem
)
723 wxCHECK_MSG( old
< m_children
.GetCount(), false, _T("Replace index is out of range") );
724 wxASSERT_MSG( newitem
, _T("Replacing with NULL item") );
726 wxSizerItemList::compatibility_iterator node
= m_children
.Item( old
);
728 wxCHECK_MSG( node
, false, _T("Failed to find child node") );
730 wxSizerItem
*item
= node
->GetData();
731 node
->SetData(newitem
);
737 void wxSizer::Clear( bool delete_windows
)
739 // First clear the ContainingSizer pointers
740 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
743 wxSizerItem
*item
= node
->GetData();
745 if (item
->IsWindow())
746 item
->GetWindow()->SetContainingSizer( NULL
);
747 node
= node
->GetNext();
750 // Destroy the windows if needed
754 // Now empty the list
755 WX_CLEAR_LIST(wxSizerItemList
, m_children
);
758 void wxSizer::DeleteWindows()
760 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
763 wxSizerItem
*item
= node
->GetData();
765 item
->DeleteWindows();
766 node
= node
->GetNext();
770 wxSize
wxSizer::Fit( wxWindow
*window
)
772 // take the min size by default and limit it by max size
773 wxSize size
= GetMinWindowSize(window
);
774 wxSize sizeMax
= GetMaxWindowSize(window
);
776 wxTopLevelWindow
*tlw
= wxDynamicCast(window
, wxTopLevelWindow
);
779 // hack for small screen devices where TLWs are always full screen
780 if ( tlw
->IsAlwaysMaximized() )
782 size
= tlw
->GetSize();
784 else // normal situation
786 // limit the window to the size of the display it is on
787 int disp
= wxDisplay::GetFromWindow(window
);
788 if ( disp
== wxNOT_FOUND
)
790 // or, if we don't know which one it is, of the main one
794 sizeMax
= wxDisplay(disp
).GetClientArea().GetSize();
798 if ( sizeMax
.x
!= wxDefaultCoord
&& size
.x
> sizeMax
.x
)
800 if ( sizeMax
.y
!= wxDefaultCoord
&& size
.y
> sizeMax
.y
)
804 window
->SetSize( size
);
809 void wxSizer::FitInside( wxWindow
*window
)
812 if (window
->IsTopLevel())
813 size
= VirtualFitSize( window
);
815 size
= GetMinClientSize( window
);
817 window
->SetVirtualSize( size
);
820 void wxSizer::Layout()
822 // (re)calculates minimums needed for each item and other preparations
826 // Applies the layout and repositions/resizes the items
830 void wxSizer::SetSizeHints( wxWindow
*window
)
832 // Preserve the window's max size hints, but set the
833 // lower bound according to the sizer calculations.
835 wxSize size
= Fit( window
);
837 window
->SetSizeHints( size
.x
,
839 window
->GetMaxWidth(),
840 window
->GetMaxHeight() );
843 void wxSizer::SetVirtualSizeHints( wxWindow
*window
)
845 // Preserve the window's max size hints, but set the
846 // lower bound according to the sizer calculations.
849 wxSize
size( window
->GetVirtualSize() );
850 window
->SetVirtualSizeHints( size
.x
,
852 window
->GetMaxWidth(),
853 window
->GetMaxHeight() );
856 wxSize
wxSizer::GetMaxWindowSize( wxWindow
*window
) const
858 return window
->GetMaxSize();
861 wxSize
wxSizer::GetMinWindowSize( wxWindow
*window
)
863 wxSize
minSize( GetMinSize() );
864 wxSize
size( window
->GetSize() );
865 wxSize
client_size( window
->GetClientSize() );
867 return wxSize( minSize
.x
+size
.x
-client_size
.x
,
868 minSize
.y
+size
.y
-client_size
.y
);
871 // TODO on mac we need a function that determines how much free space this
872 // min size contains, in order to make sure that we have 20 pixels of free
873 // space around the controls
874 wxSize
wxSizer::GetMaxClientSize( wxWindow
*window
) const
876 wxSize
maxSize( window
->GetMaxSize() );
878 if ( maxSize
!= wxDefaultSize
)
880 wxSize
size( window
->GetSize() );
881 wxSize
client_size( window
->GetClientSize() );
883 return wxSize( maxSize
.x
+ client_size
.x
- size
.x
,
884 maxSize
.y
+ client_size
.y
- size
.y
);
887 return wxDefaultSize
;
890 wxSize
wxSizer::GetMinClientSize( wxWindow
*WXUNUSED(window
) )
892 return GetMinSize(); // Already returns client size.
895 wxSize
wxSizer::VirtualFitSize( wxWindow
*window
)
897 wxSize size
= GetMinClientSize( window
);
898 wxSize sizeMax
= GetMaxClientSize( window
);
900 // Limit the size if sizeMax != wxDefaultSize
902 if ( size
.x
> sizeMax
.x
&& sizeMax
.x
!= wxDefaultCoord
)
904 if ( size
.y
> sizeMax
.y
&& sizeMax
.y
!= wxDefaultCoord
)
910 void wxSizer::SetDimension( int x
, int y
, int width
, int height
)
919 wxSize
wxSizer::GetMinSize()
921 wxSize
ret( CalcMin() );
922 if (ret
.x
< m_minSize
.x
) ret
.x
= m_minSize
.x
;
923 if (ret
.y
< m_minSize
.y
) ret
.y
= m_minSize
.y
;
927 void wxSizer::DoSetMinSize( int width
, int height
)
930 m_minSize
.y
= height
;
933 bool wxSizer::DoSetItemMinSize( wxWindow
*window
, int width
, int height
)
935 wxASSERT_MSG( window
, _T("SetMinSize for NULL window") );
937 // Is it our immediate child?
939 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
942 wxSizerItem
*item
= node
->GetData();
944 if (item
->GetWindow() == window
)
946 item
->SetMinSize( width
, height
);
949 node
= node
->GetNext();
952 // No? Search any subsizers we own then
954 node
= m_children
.GetFirst();
957 wxSizerItem
*item
= node
->GetData();
959 if ( item
->GetSizer() &&
960 item
->GetSizer()->DoSetItemMinSize( window
, width
, height
) )
962 // A child sizer found the requested windw, exit.
965 node
= node
->GetNext();
971 bool wxSizer::DoSetItemMinSize( wxSizer
*sizer
, int width
, int height
)
973 wxASSERT_MSG( sizer
, _T("SetMinSize for NULL sizer") );
975 // Is it our immediate child?
977 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
980 wxSizerItem
*item
= node
->GetData();
982 if (item
->GetSizer() == sizer
)
984 item
->GetSizer()->DoSetMinSize( width
, height
);
987 node
= node
->GetNext();
990 // No? Search any subsizers we own then
992 node
= m_children
.GetFirst();
995 wxSizerItem
*item
= node
->GetData();
997 if ( item
->GetSizer() &&
998 item
->GetSizer()->DoSetItemMinSize( sizer
, width
, height
) )
1000 // A child found the requested sizer, exit.
1003 node
= node
->GetNext();
1009 bool wxSizer::DoSetItemMinSize( size_t index
, int width
, int height
)
1011 wxSizerItemList::compatibility_iterator node
= m_children
.Item( index
);
1013 wxCHECK_MSG( node
, false, _T("Failed to find child node") );
1015 wxSizerItem
*item
= node
->GetData();
1017 if (item
->GetSizer())
1019 // Sizers contains the minimal size in them, if not calculated ...
1020 item
->GetSizer()->DoSetMinSize( width
, height
);
1024 // ... but the minimal size of spacers and windows is stored via the item
1025 item
->SetMinSize( width
, height
);
1031 wxSizerItem
* wxSizer::GetItem( wxWindow
*window
, bool recursive
)
1033 wxASSERT_MSG( window
, _T("GetItem for NULL window") );
1035 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1038 wxSizerItem
*item
= node
->GetData();
1040 if (item
->GetWindow() == window
)
1044 else if (recursive
&& item
->IsSizer())
1046 wxSizerItem
*subitem
= item
->GetSizer()->GetItem( window
, true );
1051 node
= node
->GetNext();
1057 wxSizerItem
* wxSizer::GetItem( wxSizer
*sizer
, bool recursive
)
1059 wxASSERT_MSG( sizer
, _T("GetItem for NULL sizer") );
1061 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1064 wxSizerItem
*item
= node
->GetData();
1066 if (item
->GetSizer() == sizer
)
1070 else if (recursive
&& item
->IsSizer())
1072 wxSizerItem
*subitem
= item
->GetSizer()->GetItem( sizer
, true );
1077 node
= node
->GetNext();
1083 wxSizerItem
* wxSizer::GetItem( size_t index
)
1085 wxCHECK_MSG( index
< m_children
.GetCount(),
1087 _T("GetItem index is out of range") );
1089 return m_children
.Item( index
)->GetData();
1092 wxSizerItem
* wxSizer::GetItemById( int id
, bool recursive
)
1094 // This gets a sizer item by the id of the sizer item
1095 // and NOT the id of a window if the item is a window.
1097 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1100 wxSizerItem
*item
= node
->GetData();
1102 if (item
->GetId() == id
)
1106 else if (recursive
&& item
->IsSizer())
1108 wxSizerItem
*subitem
= item
->GetSizer()->GetItemById( id
, true );
1113 node
= node
->GetNext();
1119 bool wxSizer::Show( wxWindow
*window
, bool show
, bool recursive
)
1121 wxSizerItem
*item
= GetItem( window
, recursive
);
1132 bool wxSizer::Show( wxSizer
*sizer
, bool show
, bool recursive
)
1134 wxSizerItem
*item
= GetItem( sizer
, recursive
);
1145 bool wxSizer::Show( size_t index
, bool show
)
1147 wxSizerItem
*item
= GetItem( index
);
1158 void wxSizer::ShowItems( bool show
)
1160 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1163 node
->GetData()->Show( show
);
1164 node
= node
->GetNext();
1168 bool wxSizer::IsShown( wxWindow
*window
) const
1170 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1173 wxSizerItem
*item
= node
->GetData();
1175 if (item
->GetWindow() == window
)
1177 return item
->IsShown();
1179 node
= node
->GetNext();
1182 wxFAIL_MSG( _T("IsShown failed to find sizer item") );
1187 bool wxSizer::IsShown( wxSizer
*sizer
) const
1189 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1192 wxSizerItem
*item
= node
->GetData();
1194 if (item
->GetSizer() == sizer
)
1196 return item
->IsShown();
1198 node
= node
->GetNext();
1201 wxFAIL_MSG( _T("IsShown failed to find sizer item") );
1206 bool wxSizer::IsShown( size_t index
) const
1208 wxCHECK_MSG( index
< m_children
.GetCount(),
1210 _T("IsShown index is out of range") );
1212 return m_children
.Item( index
)->GetData()->IsShown();
1216 //---------------------------------------------------------------------------
1218 //---------------------------------------------------------------------------
1220 wxGridSizer::wxGridSizer( int rows
, int cols
, int vgap
, int hgap
)
1221 : m_rows( ( cols
== 0 && rows
== 0 ) ? 1 : rows
)
1228 wxGridSizer::wxGridSizer( int cols
, int vgap
, int hgap
)
1229 : m_rows( cols
== 0 ? 1 : 0 )
1236 int wxGridSizer::CalcRowsCols(int& nrows
, int& ncols
) const
1238 int nitems
= m_children
.GetCount();
1244 nrows
= (nitems
+ m_cols
- 1) / m_cols
;
1248 ncols
= (nitems
+ m_rows
- 1) / m_rows
;
1251 else // 0 columns, 0 rows?
1253 wxFAIL_MSG( _T("grid sizer must have either rows or columns fixed") );
1262 void wxGridSizer::RecalcSizes()
1264 int nitems
, nrows
, ncols
;
1265 if ( (nitems
= CalcRowsCols(nrows
, ncols
)) == 0 )
1268 wxSize
sz( GetSize() );
1269 wxPoint
pt( GetPosition() );
1271 int w
= (sz
.x
- (ncols
- 1) * m_hgap
) / ncols
;
1272 int h
= (sz
.y
- (nrows
- 1) * m_vgap
) / nrows
;
1275 for (int c
= 0; c
< ncols
; c
++)
1278 for (int r
= 0; r
< nrows
; r
++)
1280 int i
= r
* ncols
+ c
;
1283 wxSizerItemList::compatibility_iterator node
= m_children
.Item( i
);
1285 wxASSERT_MSG( node
, _T("Failed to find SizerItemList node") );
1287 SetItemBounds( node
->GetData(), x
, y
, w
, h
);
1295 wxSize
wxGridSizer::CalcMin()
1298 if ( CalcRowsCols(nrows
, ncols
) == 0 )
1301 // Find the max width and height for any component
1305 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1308 wxSizerItem
*item
= node
->GetData();
1309 wxSize
sz( item
->CalcMin() );
1311 w
= wxMax( w
, sz
.x
);
1312 h
= wxMax( h
, sz
.y
);
1314 node
= node
->GetNext();
1317 return wxSize( ncols
* w
+ (ncols
-1) * m_hgap
,
1318 nrows
* h
+ (nrows
-1) * m_vgap
);
1321 void wxGridSizer::SetItemBounds( wxSizerItem
*item
, int x
, int y
, int w
, int h
)
1324 wxSize
sz( item
->GetMinSizeWithBorder() );
1325 int flag
= item
->GetFlag();
1327 if ((flag
& wxEXPAND
) || (flag
& wxSHAPED
))
1333 if (flag
& wxALIGN_CENTER_HORIZONTAL
)
1335 pt
.x
= x
+ (w
- sz
.x
) / 2;
1337 else if (flag
& wxALIGN_RIGHT
)
1339 pt
.x
= x
+ (w
- sz
.x
);
1342 if (flag
& wxALIGN_CENTER_VERTICAL
)
1344 pt
.y
= y
+ (h
- sz
.y
) / 2;
1346 else if (flag
& wxALIGN_BOTTOM
)
1348 pt
.y
= y
+ (h
- sz
.y
);
1352 item
->SetDimension(pt
, sz
);
1355 //---------------------------------------------------------------------------
1357 //---------------------------------------------------------------------------
1359 wxFlexGridSizer::wxFlexGridSizer( int rows
, int cols
, int vgap
, int hgap
)
1360 : wxGridSizer( rows
, cols
, vgap
, hgap
),
1361 m_flexDirection(wxBOTH
),
1362 m_growMode(wxFLEX_GROWMODE_SPECIFIED
)
1366 wxFlexGridSizer::wxFlexGridSizer( int cols
, int vgap
, int hgap
)
1367 : wxGridSizer( cols
, vgap
, hgap
),
1368 m_flexDirection(wxBOTH
),
1369 m_growMode(wxFLEX_GROWMODE_SPECIFIED
)
1373 wxFlexGridSizer::~wxFlexGridSizer()
1377 void wxFlexGridSizer::RecalcSizes()
1380 if ( !CalcRowsCols(nrows
, ncols
) )
1383 const wxPoint
pt(GetPosition());
1384 const wxSize
sz(GetSize());
1386 AdjustForGrowables(sz
);
1388 wxSizerItemList::const_iterator i
= m_children
.begin();
1389 const wxSizerItemList::const_iterator end
= m_children
.end();
1392 for ( int r
= 0; r
< nrows
; r
++ )
1394 if ( m_rowHeights
[r
] == -1 )
1396 // this row is entirely hidden, skip it
1397 for ( int c
= 0; c
< ncols
; c
++ )
1408 const int hrow
= m_rowHeights
[r
];
1409 int h
= sz
.y
- y
; // max remaining height, don't overflow it
1414 for ( int c
= 0; c
< ncols
&& i
!= end
; c
++, ++i
)
1416 const int wcol
= m_colWidths
[c
];
1421 int w
= sz
.x
- x
; // max possible value, ensure we don't overflow
1425 SetItemBounds(*i
, pt
.x
+ x
, pt
.y
+ y
, w
, h
);
1437 // helper function used in CalcMin() to sum up the sizes of non-hidden items
1438 static int SumArraySizes(const wxArrayInt
& sizes
, int gap
)
1440 // Sum total minimum size, including gaps between rows/columns.
1441 // -1 is used as a magic number meaning empty row/column.
1444 const size_t count
= sizes
.size();
1445 for ( size_t n
= 0; n
< count
; n
++ )
1447 if ( sizes
[n
] != -1 )
1450 total
+= gap
; // separate from the previous column
1459 wxSize
wxFlexGridSizer::CalcMin()
1464 // Number of rows/columns can change as items are added or removed.
1465 if ( !CalcRowsCols(nrows
, ncols
) )
1469 // We have to recalculate the sizes in case the item minimum size has
1470 // changed since the previous layout, or the item has been hidden using
1471 // wxSizer::Show(). If all the items in a row/column are hidden, the final
1472 // dimension of the row/column will be -1, indicating that the column
1473 // itself is hidden.
1474 m_rowHeights
.assign(nrows
, -1);
1475 m_colWidths
.assign(ncols
, -1);
1477 // n is the index of the item in left-to-right top-to-bottom order
1479 for ( wxSizerItemList::iterator i
= m_children
.begin();
1480 i
!= m_children
.end();
1483 wxSizerItem
* const item
= *i
;
1484 if ( item
->IsShown() )
1486 const wxSize
sz(item
->CalcMin());
1488 const int row
= n
/ ncols
;
1489 const int col
= n
% ncols
;
1491 if ( sz
.y
> m_rowHeights
[row
] )
1492 m_rowHeights
[row
] = sz
.y
;
1493 if ( sz
.x
> m_colWidths
[col
] )
1494 m_colWidths
[col
] = sz
.x
;
1498 AdjustForFlexDirection();
1500 m_calculatedMinSize
= wxSize(SumArraySizes(m_colWidths
, m_hgap
),
1501 SumArraySizes(m_rowHeights
, m_vgap
));
1503 return m_calculatedMinSize
;
1506 void wxFlexGridSizer::AdjustForFlexDirection()
1508 // the logic in CalcMin works when we resize flexibly in both directions
1509 // but maybe this is not the case
1510 if ( m_flexDirection
!= wxBOTH
)
1512 // select the array corresponding to the direction in which we do *not*
1514 wxArrayInt
& array
= m_flexDirection
== wxVERTICAL
? m_colWidths
1517 const size_t count
= array
.GetCount();
1519 // find the largest value in this array
1523 for ( n
= 0; n
< count
; ++n
)
1525 if ( array
[n
] > largest
)
1529 // and now fill it with the largest value
1530 for ( n
= 0; n
< count
; ++n
)
1532 // don't touch hidden rows
1533 if ( array
[n
] != -1 )
1539 // helper of AdjustForGrowables() which is called for rows/columns separately
1542 // delta: the extra space, we do nothing unless it's positive
1543 // growable: indices or growable rows/cols in sizes array
1544 // sizes: the height/widths of rows/cols to adjust
1545 // proportions: proportions of the growable rows/cols or NULL if they all
1546 // should be assumed to have proportion of 1
1548 DoAdjustForGrowables(int delta
,
1549 const wxArrayInt
& growable
,
1551 const wxArrayInt
*proportions
)
1556 // total sum of proportions of all non-hidden rows
1557 int sum_proportions
= 0;
1559 // number of currently shown growable rows
1562 const int max_idx
= sizes
.size();
1564 const size_t count
= growable
.size();
1566 for ( idx
= 0; idx
< count
; idx
++ )
1568 // Since the number of rows/columns can change as items are
1569 // inserted/deleted, we need to verify at runtime that the
1570 // requested growable rows/columns are still valid.
1571 if ( growable
[idx
] >= max_idx
)
1574 // If all items in a row/column are hidden, that row/column will
1575 // have a dimension of -1. This causes the row/column to be
1576 // hidden completely.
1577 if ( sizes
[growable
[idx
]] == -1 )
1581 sum_proportions
+= (*proportions
)[idx
];
1589 // the remaining extra free space, adjusted during each iteration
1590 for ( idx
= 0; idx
< count
; idx
++ )
1592 if ( growable
[idx
] >= max_idx
)
1595 if ( sizes
[ growable
[idx
] ] == -1 )
1599 if ( sum_proportions
== 0 )
1601 // no growable rows -- divide extra space evenly among all
1602 cur_delta
= delta
/num
;
1605 else // allocate extra space proportionally
1607 const int cur_prop
= (*proportions
)[idx
];
1608 cur_delta
= (delta
*cur_prop
)/sum_proportions
;
1609 sum_proportions
-= cur_prop
;
1612 sizes
[growable
[idx
]] += cur_delta
;
1617 void wxFlexGridSizer::AdjustForGrowables(const wxSize
& sz
)
1619 if ( (m_flexDirection
& wxVERTICAL
) || (m_growMode
!= wxFLEX_GROWMODE_NONE
) )
1621 // pass NULL instead of proportions if the grow mode is ALL as we
1622 // should treat all rows as having proportion of 1 then
1623 DoAdjustForGrowables
1625 sz
.y
- m_calculatedMinSize
.y
,
1628 m_growMode
== wxFLEX_GROWMODE_SPECIFIED
? &m_growableRowsProportions
1633 if ( (m_flexDirection
& wxHORIZONTAL
) || (m_growMode
!= wxFLEX_GROWMODE_NONE
) )
1635 DoAdjustForGrowables
1637 sz
.x
- m_calculatedMinSize
.x
,
1640 m_growMode
== wxFLEX_GROWMODE_SPECIFIED
? &m_growableColsProportions
1647 void wxFlexGridSizer::AddGrowableRow( size_t idx
, int proportion
)
1649 m_growableRows
.Add( idx
);
1650 m_growableRowsProportions
.Add( proportion
);
1653 void wxFlexGridSizer::AddGrowableCol( size_t idx
, int proportion
)
1655 m_growableCols
.Add( idx
);
1656 m_growableColsProportions
.Add( proportion
);
1659 // helper function for RemoveGrowableCol/Row()
1661 DoRemoveFromArrays(size_t idx
, wxArrayInt
& items
, wxArrayInt
& proportions
)
1663 const size_t count
= items
.size();
1664 for ( size_t n
= 0; n
< count
; n
++ )
1666 if ( (size_t)items
[n
] == idx
)
1669 proportions
.RemoveAt(n
);
1674 wxFAIL_MSG( _T("column/row is already not growable") );
1677 void wxFlexGridSizer::RemoveGrowableCol( size_t idx
)
1679 DoRemoveFromArrays(idx
, m_growableCols
, m_growableColsProportions
);
1682 void wxFlexGridSizer::RemoveGrowableRow( size_t idx
)
1684 DoRemoveFromArrays(idx
, m_growableRows
, m_growableRowsProportions
);
1687 //---------------------------------------------------------------------------
1689 //---------------------------------------------------------------------------
1691 void wxBoxSizer::RecalcSizes()
1693 if ( m_children
.empty() )
1696 // the amount of free space which we should redistribute among the
1697 // stretchable items (i.e. those with non zero proportion)
1698 int delta
= SizeInMajorDir(m_size
) - SizeInMajorDir(m_minSize
);
1700 // the position at which we put the next child
1701 wxPoint
pt(m_position
);
1703 const wxCoord totalMinorSize
= SizeInMinorDir(m_size
);
1705 int totalProportion
= m_totalProportion
;
1706 for ( wxSizerItemList::const_iterator i
= m_children
.begin();
1707 i
!= m_children
.end();
1710 wxSizerItem
* const item
= *i
;
1712 if ( !item
->IsShown() )
1715 // DMC doesn't distinguish between
1716 // int SizeInMajorDir(const wxSize& sz) const
1717 // and int& SizeInMajorDir(wxSize& sz)
1720 wxSize
sizeThis(item
->GetMinSizeWithBorder());
1723 // adjust the size in the major direction using the proportion
1724 wxCoord majorSize
= SizeInMajorDir(sizeThis
);
1725 const int propItem
= item
->GetProportion();
1728 const int deltaItem
= (delta
* propItem
) / totalProportion
;
1730 majorSize
+= deltaItem
;
1733 totalProportion
-= propItem
;
1737 // apply the alignment in the minor direction
1738 wxPoint
posChild(pt
);
1740 wxCoord minorSize
= SizeInMinorDir(sizeThis
);
1741 const int flag
= item
->GetFlag();
1742 if ( flag
& (wxEXPAND
| wxSHAPED
) )
1744 minorSize
= totalMinorSize
;
1746 else if ( flag
& (IsVertical() ? wxALIGN_RIGHT
: wxALIGN_BOTTOM
) )
1748 PosInMinorDir(posChild
) += totalMinorSize
- minorSize
;
1750 // NB: wxCENTRE is used here only for backwards compatibility,
1751 // wxALIGN_CENTRE should be used in new code
1752 else if ( flag
& (wxCENTER
| wxALIGN_CENTRE
) )
1754 PosInMinorDir(posChild
) += (totalMinorSize
- minorSize
) / 2;
1758 // apply RTL adjustment for horizontal sizers:
1759 if ( !IsVertical() && m_containingWindow
)
1761 posChild
.x
= m_containingWindow
->AdjustForLayoutDirection
1769 // finally set size of this child and advance to the next one
1770 item
->SetDimension(posChild
, SizeFromMajorMinor(majorSize
, minorSize
));
1772 PosInMajorDir(pt
) += majorSize
;
1776 wxSize
wxBoxSizer::CalcMin()
1778 m_totalProportion
= 0;
1779 m_minSize
= wxSize(0, 0);
1781 // calculate the minimal sizes for all items and count sum of proportions
1782 for ( wxSizerItemList::const_iterator i
= m_children
.begin();
1783 i
!= m_children
.end();
1786 wxSizerItem
* const item
= *i
;
1788 if ( !item
->IsShown() )
1791 const // see __DMC__ above
1793 wxSize sizeMinThis
= item
->CalcMin();
1795 SizeInMajorDir(m_minSize
) += SizeInMajorDir(sizeMinThis
);
1796 if ( SizeInMinorDir(sizeMinThis
) > SizeInMinorDir(m_minSize
) )
1797 SizeInMinorDir(m_minSize
) = SizeInMinorDir(sizeMinThis
);
1799 m_totalProportion
+= item
->GetProportion();
1805 //---------------------------------------------------------------------------
1807 //---------------------------------------------------------------------------
1811 wxStaticBoxSizer::wxStaticBoxSizer( wxStaticBox
*box
, int orient
)
1812 : wxBoxSizer( orient
),
1815 wxASSERT_MSG( box
, wxT("wxStaticBoxSizer needs a static box") );
1817 // do this so that our Detach() is called if the static box is destroyed
1819 m_staticBox
->SetContainingSizer(this);
1822 wxStaticBoxSizer::wxStaticBoxSizer(int orient
, wxWindow
*win
, const wxString
& s
)
1823 : wxBoxSizer(orient
),
1824 m_staticBox(new wxStaticBox(win
, wxID_ANY
, s
))
1827 m_staticBox
->SetContainingSizer(this);
1830 wxStaticBoxSizer::~wxStaticBoxSizer()
1835 static void GetStaticBoxBorders( wxStaticBox
*box
,
1839 // this has to be done platform by platform as there is no way to
1840 // guess the thickness of a wxStaticBox border
1841 box
->GetBordersForSizer(borderTop
, borderOther
);
1844 void wxStaticBoxSizer::RecalcSizes()
1846 int top_border
, other_border
;
1847 GetStaticBoxBorders(m_staticBox
, &top_border
, &other_border
);
1849 m_staticBox
->SetSize( m_position
.x
, m_position
.y
, m_size
.x
, m_size
.y
);
1851 wxPoint
old_pos( m_position
);
1852 m_position
.x
+= other_border
;
1853 m_position
.y
+= top_border
;
1854 wxSize
old_size( m_size
);
1855 m_size
.x
-= 2*other_border
;
1856 m_size
.y
-= top_border
+ other_border
;
1858 wxBoxSizer::RecalcSizes();
1860 m_position
= old_pos
;
1864 wxSize
wxStaticBoxSizer::CalcMin()
1866 int top_border
, other_border
;
1867 GetStaticBoxBorders(m_staticBox
, &top_border
, &other_border
);
1869 wxSize
ret( wxBoxSizer::CalcMin() );
1870 ret
.x
+= 2*other_border
;
1871 ret
.y
+= other_border
+ top_border
;
1876 void wxStaticBoxSizer::ShowItems( bool show
)
1878 m_staticBox
->Show( show
);
1879 wxBoxSizer::ShowItems( show
);
1882 bool wxStaticBoxSizer::Detach( wxWindow
*window
)
1884 // avoid deleting m_staticBox in our dtor if it's being detached from the
1885 // sizer (which can happen because it's being already destroyed for
1887 if ( window
== m_staticBox
)
1893 return wxSizer::Detach( window
);
1896 #endif // wxUSE_STATBOX
1900 wxStdDialogButtonSizer::wxStdDialogButtonSizer()
1901 : wxBoxSizer(wxHORIZONTAL
)
1903 // Vertical buttons with lots of space on either side
1904 // looks rubbish on WinCE, so let's not do this for now.
1905 // If we are going to use vertical buttons, we should
1906 // put the sizer to the right of other controls in the dialog,
1907 // and that's beyond the scope of this sizer.
1909 bool is_pda
= (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA
);
1910 // If we have a PDA screen, put yes/no button over
1911 // all other buttons, otherwise on the left side.
1913 m_orient
= wxVERTICAL
;
1916 m_buttonAffirmative
= NULL
;
1917 m_buttonApply
= NULL
;
1918 m_buttonNegative
= NULL
;
1919 m_buttonCancel
= NULL
;
1920 m_buttonHelp
= NULL
;
1923 void wxStdDialogButtonSizer::AddButton(wxButton
*mybutton
)
1925 switch (mybutton
->GetId())
1930 m_buttonAffirmative
= mybutton
;
1933 m_buttonApply
= mybutton
;
1936 m_buttonNegative
= mybutton
;
1940 m_buttonCancel
= mybutton
;
1943 case wxID_CONTEXT_HELP
:
1944 m_buttonHelp
= mybutton
;
1951 void wxStdDialogButtonSizer::SetAffirmativeButton( wxButton
*button
)
1953 m_buttonAffirmative
= button
;
1956 void wxStdDialogButtonSizer::SetNegativeButton( wxButton
*button
)
1958 m_buttonNegative
= button
;
1961 void wxStdDialogButtonSizer::SetCancelButton( wxButton
*button
)
1963 m_buttonCancel
= button
;
1966 void wxStdDialogButtonSizer::Realize()
1969 Add(0, 0, 0, wxLEFT
, 6);
1971 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 6);
1973 if (m_buttonNegative
){
1974 // HIG POLICE BULLETIN - destructive buttons need extra padding
1975 // 24 pixels on either side
1976 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 12);
1979 // extra whitespace between help/negative and cancel/ok buttons
1980 Add(0, 0, 1, wxEXPAND
, 0);
1982 if (m_buttonCancel
){
1983 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 6);
1984 // Cancel or help should be default
1985 // m_buttonCancel->SetDefaultButton();
1988 // Ugh, Mac doesn't really have apply dialogs, so I'll just
1989 // figure the best place is between Cancel and OK
1991 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 6);
1993 if (m_buttonAffirmative
){
1994 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
, 6);
1996 if (m_buttonAffirmative
->GetId() == wxID_SAVE
){
1997 // these buttons have set labels under Mac so we should use them
1998 m_buttonAffirmative
->SetLabel(_("Save"));
1999 if (m_buttonNegative
)
2000 m_buttonNegative
->SetLabel(_("Don't Save"));
2004 // Extra space around and at the right
2006 #elif defined(__WXGTK20__)
2007 Add(0, 0, 0, wxLEFT
, 9);
2009 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
2011 // extra whitespace between help and cancel/ok buttons
2012 Add(0, 0, 1, wxEXPAND
, 0);
2014 if (m_buttonNegative
){
2015 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
2018 // according to HIG, in explicit apply windows the order is:
2019 // [ Help Apply Cancel OK ]
2021 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
2023 if (m_buttonCancel
){
2024 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
2025 // Cancel or help should be default
2026 // m_buttonCancel->SetDefaultButton();
2029 if (m_buttonAffirmative
)
2030 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
, 6);
2031 #elif defined(__WXMSW__)
2034 // right-justify buttons
2035 Add(0, 0, 1, wxEXPAND
, 0);
2037 if (m_buttonAffirmative
){
2038 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonAffirmative
->ConvertDialogToPixels(wxSize(2, 0)).x
);
2041 if (m_buttonNegative
){
2042 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonNegative
->ConvertDialogToPixels(wxSize(2, 0)).x
);
2045 if (m_buttonCancel
){
2046 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonCancel
->ConvertDialogToPixels(wxSize(2, 0)).x
);
2049 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonApply
->ConvertDialogToPixels(wxSize(2, 0)).x
);
2052 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonHelp
->ConvertDialogToPixels(wxSize(2, 0)).x
);
2054 // GTK+1 and any other platform
2056 // Add(0, 0, 0, wxLEFT, 5); // Not sure what this was for but it unbalances the dialog
2058 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonHelp
->ConvertDialogToPixels(wxSize(4, 0)).x
);
2060 // extra whitespace between help and cancel/ok buttons
2061 Add(0, 0, 1, wxEXPAND
, 0);
2064 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonApply
->ConvertDialogToPixels(wxSize(4, 0)).x
);
2066 if (m_buttonAffirmative
){
2067 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonAffirmative
->ConvertDialogToPixels(wxSize(4, 0)).x
);
2070 if (m_buttonNegative
){
2071 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonNegative
->ConvertDialogToPixels(wxSize(4, 0)).x
);
2074 if (m_buttonCancel
){
2075 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonCancel
->ConvertDialogToPixels(wxSize(4, 0)).x
);
2076 // Cancel or help should be default
2077 // m_buttonCancel->SetDefaultButton();
2083 #endif // wxUSE_BUTTON