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()
109 void wxSizerItem::DoSetWindow(wxWindow
*window
)
111 wxCHECK_RET( window
, _T("NULL window in wxSizerItem::SetWindow()") );
113 m_kind
= Item_Window
;
116 // window doesn't become smaller than its initial size, whatever happens
117 m_minSize
= window
->GetSize();
119 if ( m_flag
& wxFIXED_MINSIZE
)
120 window
->SetMinSize(m_minSize
);
122 // aspect ratio calculated from initial size
126 wxSizerItem::wxSizerItem(wxWindow
*window
,
132 m_proportion(proportion
),
141 void wxSizerItem::DoSetSizer(wxSizer
*sizer
)
147 wxSizerItem::wxSizerItem(wxSizer
*sizer
,
154 m_proportion(proportion
),
162 // m_minSize is set later
166 void wxSizerItem::DoSetSpacer(const wxSize
& size
)
168 m_kind
= Item_Spacer
;
169 m_spacer
= new wxSizerSpacer(size
);
174 wxSizerItem::wxSizerItem(int width
,
182 m_minSize(width
, height
), // minimal size is the initial size
183 m_proportion(proportion
),
188 DoSetSpacer(wxSize(width
, height
));
191 wxSizerItem::~wxSizerItem()
197 void wxSizerItem::Free()
205 m_window
->SetContainingSizer(NULL
);
218 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
224 wxSize
wxSizerItem::GetSpacer() const
227 if ( m_kind
== Item_Spacer
)
228 size
= m_spacer
->GetSize();
234 wxSize
wxSizerItem::GetSize() const
243 ret
= m_window
->GetSize();
247 ret
= m_sizer
->GetSize();
251 ret
= m_spacer
->GetSize();
256 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
263 if (m_flag
& wxNORTH
)
265 if (m_flag
& wxSOUTH
)
271 wxSize
wxSizerItem::CalcMin()
275 m_minSize
= m_sizer
->GetMinSize();
277 // if we have to preserve aspect ratio _AND_ this is
278 // the first-time calculation, consider ret to be initial size
279 if ( (m_flag
& wxSHAPED
) && wxIsNullDouble(m_ratio
) )
282 else if ( IsWindow() )
284 // Since the size of the window may change during runtime, we
285 // should use the current minimal/best size.
286 m_minSize
= m_window
->GetEffectiveMinSize();
289 return GetMinSizeWithBorder();
292 wxSize
wxSizerItem::GetMinSizeWithBorder() const
294 wxSize ret
= m_minSize
;
300 if (m_flag
& wxNORTH
)
302 if (m_flag
& wxSOUTH
)
309 void wxSizerItem::SetDimension( const wxPoint
& pos_
, const wxSize
& size_
)
313 if (m_flag
& wxSHAPED
)
315 // adjust aspect ratio
316 int rwidth
= (int) (size
.y
* m_ratio
);
320 int rheight
= (int) (size
.x
/ m_ratio
);
321 // add vertical space
322 if (m_flag
& wxALIGN_CENTER_VERTICAL
)
323 pos
.y
+= (size
.y
- rheight
) / 2;
324 else if (m_flag
& wxALIGN_BOTTOM
)
325 pos
.y
+= (size
.y
- rheight
);
326 // use reduced dimensions
329 else if (rwidth
< size
.x
)
331 // add horizontal space
332 if (m_flag
& wxALIGN_CENTER_HORIZONTAL
)
333 pos
.x
+= (size
.x
- rwidth
) / 2;
334 else if (m_flag
& wxALIGN_RIGHT
)
335 pos
.x
+= (size
.x
- rwidth
);
340 // This is what GetPosition() returns. Since we calculate
341 // borders afterwards, GetPosition() will be the left/top
342 // corner of the surrounding border.
354 if (m_flag
& wxNORTH
)
359 if (m_flag
& wxSOUTH
)
369 m_rect
= wxRect(pos
, size
);
374 wxFAIL_MSG( _T("can't set size of uninitialized sizer item") );
378 m_window
->SetSize(pos
.x
, pos
.y
, size
.x
, size
.y
,
379 wxSIZE_ALLOW_MINUS_ONE
);
383 m_sizer
->SetDimension(pos
.x
, pos
.y
, size
.x
, size
.y
);
387 m_spacer
->SetSize(size
);
392 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
396 void wxSizerItem::DeleteWindows()
405 //We are deleting the window from this sizer - normally
406 //the window destroys the sizer associated with it,
407 //which might destroy this, which we don't want
408 m_window
->SetContainingSizer(NULL
);
410 //Putting this after the switch will result in a spacer
411 //not being deleted properly on destruction
416 m_sizer
->DeleteWindows();
421 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
426 void wxSizerItem::Show( bool show
)
431 wxFAIL_MSG( _T("can't show uninitialized sizer item") );
435 m_window
->Show(show
);
443 m_spacer
->Show(show
);
448 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
452 bool wxSizerItem::IsShown() const
457 // we may be called from CalcMin(), just return false so that we're
462 return m_window
->IsShown();
465 // arbitrarily decide that if at least one of our elements is
466 // shown, so are we (this arbitrariness is the reason for
467 // deprecating this function)
469 // Some apps (such as dialog editors) depend on an empty sizer still
470 // being laid out correctly and reporting the correct size and position.
471 if (m_sizer
->GetChildren().GetCount() == 0)
474 for ( wxSizerItemList::compatibility_iterator
475 node
= m_sizer
->GetChildren().GetFirst();
477 node
= node
->GetNext() )
479 if ( node
->GetData()->IsShown() )
486 return m_spacer
->IsShown();
490 wxFAIL_MSG( _T("unexpected wxSizerItem::m_kind") );
496 #if WXWIN_COMPATIBILITY_2_6
497 void wxSizerItem::SetOption( int option
)
499 SetProportion( option
);
502 int wxSizerItem::GetOption() const
504 return GetProportion();
506 #endif // WXWIN_COMPATIBILITY_2_6
509 //---------------------------------------------------------------------------
511 //---------------------------------------------------------------------------
515 WX_CLEAR_LIST(wxSizerItemList
, m_children
);
518 wxSizerItem
* wxSizer::Insert( size_t index
, wxSizerItem
*item
)
520 m_children
.Insert( index
, item
);
522 if ( item
->GetWindow() )
523 item
->GetWindow()->SetContainingSizer( this );
528 void wxSizer::SetContainingWindow(wxWindow
*win
)
530 if ( win
== m_containingWindow
)
533 m_containingWindow
= win
;
535 // set the same window for all nested sizers as well, they also are in the
537 for ( wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
539 node
= node
->GetNext() )
541 wxSizerItem
*const item
= node
->GetData();
542 wxSizer
*const sizer
= item
->GetSizer();
546 sizer
->SetContainingWindow(win
);
551 #if WXWIN_COMPATIBILITY_2_6
552 bool wxSizer::Remove( wxWindow
*window
)
554 return Detach( window
);
556 #endif // WXWIN_COMPATIBILITY_2_6
558 bool wxSizer::Remove( wxSizer
*sizer
)
560 wxASSERT_MSG( sizer
, _T("Removing NULL sizer") );
562 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
565 wxSizerItem
*item
= node
->GetData();
567 if (item
->GetSizer() == sizer
)
570 m_children
.Erase( node
);
574 node
= node
->GetNext();
580 bool wxSizer::Remove( int index
)
582 wxCHECK_MSG( index
>= 0 && (size_t)index
< m_children
.GetCount(),
584 _T("Remove index is out of range") );
586 wxSizerItemList::compatibility_iterator node
= m_children
.Item( index
);
588 wxCHECK_MSG( node
, false, _T("Failed to find child node") );
590 delete node
->GetData();
591 m_children
.Erase( node
);
596 bool wxSizer::Detach( wxSizer
*sizer
)
598 wxASSERT_MSG( sizer
, _T("Detaching NULL sizer") );
600 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
603 wxSizerItem
*item
= node
->GetData();
605 if (item
->GetSizer() == sizer
)
609 m_children
.Erase( node
);
612 node
= node
->GetNext();
618 bool wxSizer::Detach( wxWindow
*window
)
620 wxASSERT_MSG( window
, _T("Detaching NULL window") );
622 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
625 wxSizerItem
*item
= node
->GetData();
627 if (item
->GetWindow() == window
)
630 m_children
.Erase( node
);
633 node
= node
->GetNext();
639 bool wxSizer::Detach( int index
)
641 wxCHECK_MSG( index
>= 0 && (size_t)index
< m_children
.GetCount(),
643 _T("Detach index is out of range") );
645 wxSizerItemList::compatibility_iterator node
= m_children
.Item( index
);
647 wxCHECK_MSG( node
, false, _T("Failed to find child node") );
649 wxSizerItem
*item
= node
->GetData();
651 if ( item
->IsSizer() )
655 m_children
.Erase( node
);
659 bool wxSizer::Replace( wxWindow
*oldwin
, wxWindow
*newwin
, bool recursive
)
661 wxASSERT_MSG( oldwin
, _T("Replacing NULL window") );
662 wxASSERT_MSG( newwin
, _T("Replacing with NULL window") );
664 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
667 wxSizerItem
*item
= node
->GetData();
669 if (item
->GetWindow() == oldwin
)
671 item
->AssignWindow(newwin
);
672 newwin
->SetContainingSizer( this );
675 else if (recursive
&& item
->IsSizer())
677 if (item
->GetSizer()->Replace( oldwin
, newwin
, true ))
681 node
= node
->GetNext();
687 bool wxSizer::Replace( wxSizer
*oldsz
, wxSizer
*newsz
, bool recursive
)
689 wxASSERT_MSG( oldsz
, _T("Replacing NULL sizer") );
690 wxASSERT_MSG( newsz
, _T("Replacing with NULL sizer") );
692 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
695 wxSizerItem
*item
= node
->GetData();
697 if (item
->GetSizer() == oldsz
)
699 item
->AssignSizer(newsz
);
702 else if (recursive
&& item
->IsSizer())
704 if (item
->GetSizer()->Replace( oldsz
, newsz
, true ))
708 node
= node
->GetNext();
714 bool wxSizer::Replace( size_t old
, wxSizerItem
*newitem
)
716 wxCHECK_MSG( old
< m_children
.GetCount(), false, _T("Replace index is out of range") );
717 wxASSERT_MSG( newitem
, _T("Replacing with NULL item") );
719 wxSizerItemList::compatibility_iterator node
= m_children
.Item( old
);
721 wxCHECK_MSG( node
, false, _T("Failed to find child node") );
723 wxSizerItem
*item
= node
->GetData();
724 node
->SetData(newitem
);
730 void wxSizer::Clear( bool delete_windows
)
732 // First clear the ContainingSizer pointers
733 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
736 wxSizerItem
*item
= node
->GetData();
738 if (item
->IsWindow())
739 item
->GetWindow()->SetContainingSizer( NULL
);
740 node
= node
->GetNext();
743 // Destroy the windows if needed
747 // Now empty the list
748 WX_CLEAR_LIST(wxSizerItemList
, m_children
);
751 void wxSizer::DeleteWindows()
753 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
756 wxSizerItem
*item
= node
->GetData();
758 item
->DeleteWindows();
759 node
= node
->GetNext();
763 wxSize
wxSizer::Fit( wxWindow
*window
)
765 // take the min size by default and limit it by max size
766 wxSize size
= GetMinWindowSize(window
);
767 wxSize sizeMax
= GetMaxWindowSize(window
);
769 wxTopLevelWindow
*tlw
= wxDynamicCast(window
, wxTopLevelWindow
);
772 // hack for small screen devices where TLWs are always full screen
773 if ( tlw
->IsAlwaysMaximized() )
775 size
= tlw
->GetSize();
777 else // normal situation
779 // limit the window to the size of the display it is on
780 int disp
= wxDisplay::GetFromWindow(window
);
781 if ( disp
== wxNOT_FOUND
)
783 // or, if we don't know which one it is, of the main one
787 sizeMax
= wxDisplay(disp
).GetClientArea().GetSize();
791 if ( sizeMax
.x
!= wxDefaultCoord
&& size
.x
> sizeMax
.x
)
793 if ( sizeMax
.y
!= wxDefaultCoord
&& size
.y
> sizeMax
.y
)
797 window
->SetSize( size
);
802 void wxSizer::FitInside( wxWindow
*window
)
805 if (window
->IsTopLevel())
806 size
= VirtualFitSize( window
);
808 size
= GetMinClientSize( window
);
810 window
->SetVirtualSize( size
);
813 void wxSizer::Layout()
815 // (re)calculates minimums needed for each item and other preparations
819 // Applies the layout and repositions/resizes the items
823 void wxSizer::SetSizeHints( wxWindow
*window
)
825 // Preserve the window's max size hints, but set the
826 // lower bound according to the sizer calculations.
828 wxSize size
= Fit( window
);
830 window
->SetSizeHints( size
.x
,
832 window
->GetMaxWidth(),
833 window
->GetMaxHeight() );
836 void wxSizer::SetVirtualSizeHints( wxWindow
*window
)
838 // Preserve the window's max size hints, but set the
839 // lower bound according to the sizer calculations.
842 wxSize
size( window
->GetVirtualSize() );
843 window
->SetVirtualSizeHints( size
.x
,
845 window
->GetMaxWidth(),
846 window
->GetMaxHeight() );
849 wxSize
wxSizer::GetMaxWindowSize( wxWindow
*window
) const
851 return window
->GetMaxSize();
854 wxSize
wxSizer::GetMinWindowSize( wxWindow
*window
)
856 wxSize
minSize( GetMinSize() );
857 wxSize
size( window
->GetSize() );
858 wxSize
client_size( window
->GetClientSize() );
860 return wxSize( minSize
.x
+size
.x
-client_size
.x
,
861 minSize
.y
+size
.y
-client_size
.y
);
864 // TODO on mac we need a function that determines how much free space this
865 // min size contains, in order to make sure that we have 20 pixels of free
866 // space around the controls
867 wxSize
wxSizer::GetMaxClientSize( wxWindow
*window
) const
869 wxSize
maxSize( window
->GetMaxSize() );
871 if ( maxSize
!= wxDefaultSize
)
873 wxSize
size( window
->GetSize() );
874 wxSize
client_size( window
->GetClientSize() );
876 return wxSize( maxSize
.x
+ client_size
.x
- size
.x
,
877 maxSize
.y
+ client_size
.y
- size
.y
);
880 return wxDefaultSize
;
883 wxSize
wxSizer::GetMinClientSize( wxWindow
*WXUNUSED(window
) )
885 return GetMinSize(); // Already returns client size.
888 wxSize
wxSizer::VirtualFitSize( wxWindow
*window
)
890 wxSize size
= GetMinClientSize( window
);
891 wxSize sizeMax
= GetMaxClientSize( window
);
893 // Limit the size if sizeMax != wxDefaultSize
895 if ( size
.x
> sizeMax
.x
&& sizeMax
.x
!= wxDefaultCoord
)
897 if ( size
.y
> sizeMax
.y
&& sizeMax
.y
!= wxDefaultCoord
)
903 void wxSizer::SetDimension( int x
, int y
, int width
, int height
)
912 wxSize
wxSizer::GetMinSize()
914 wxSize
ret( CalcMin() );
915 if (ret
.x
< m_minSize
.x
) ret
.x
= m_minSize
.x
;
916 if (ret
.y
< m_minSize
.y
) ret
.y
= m_minSize
.y
;
920 void wxSizer::DoSetMinSize( int width
, int height
)
923 m_minSize
.y
= height
;
926 bool wxSizer::DoSetItemMinSize( wxWindow
*window
, int width
, int height
)
928 wxASSERT_MSG( window
, _T("SetMinSize for NULL window") );
930 // Is it our immediate child?
932 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
935 wxSizerItem
*item
= node
->GetData();
937 if (item
->GetWindow() == window
)
939 item
->SetMinSize( width
, height
);
942 node
= node
->GetNext();
945 // No? Search any subsizers we own then
947 node
= m_children
.GetFirst();
950 wxSizerItem
*item
= node
->GetData();
952 if ( item
->GetSizer() &&
953 item
->GetSizer()->DoSetItemMinSize( window
, width
, height
) )
955 // A child sizer found the requested windw, exit.
958 node
= node
->GetNext();
964 bool wxSizer::DoSetItemMinSize( wxSizer
*sizer
, int width
, int height
)
966 wxASSERT_MSG( sizer
, _T("SetMinSize for NULL sizer") );
968 // Is it our immediate child?
970 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
973 wxSizerItem
*item
= node
->GetData();
975 if (item
->GetSizer() == sizer
)
977 item
->GetSizer()->DoSetMinSize( width
, height
);
980 node
= node
->GetNext();
983 // No? Search any subsizers we own then
985 node
= m_children
.GetFirst();
988 wxSizerItem
*item
= node
->GetData();
990 if ( item
->GetSizer() &&
991 item
->GetSizer()->DoSetItemMinSize( sizer
, width
, height
) )
993 // A child found the requested sizer, exit.
996 node
= node
->GetNext();
1002 bool wxSizer::DoSetItemMinSize( size_t index
, int width
, int height
)
1004 wxSizerItemList::compatibility_iterator node
= m_children
.Item( index
);
1006 wxCHECK_MSG( node
, false, _T("Failed to find child node") );
1008 wxSizerItem
*item
= node
->GetData();
1010 if (item
->GetSizer())
1012 // Sizers contains the minimal size in them, if not calculated ...
1013 item
->GetSizer()->DoSetMinSize( width
, height
);
1017 // ... but the minimal size of spacers and windows is stored via the item
1018 item
->SetMinSize( width
, height
);
1024 wxSizerItem
* wxSizer::GetItem( wxWindow
*window
, bool recursive
)
1026 wxASSERT_MSG( window
, _T("GetItem for NULL window") );
1028 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1031 wxSizerItem
*item
= node
->GetData();
1033 if (item
->GetWindow() == window
)
1037 else if (recursive
&& item
->IsSizer())
1039 wxSizerItem
*subitem
= item
->GetSizer()->GetItem( window
, true );
1044 node
= node
->GetNext();
1050 wxSizerItem
* wxSizer::GetItem( wxSizer
*sizer
, bool recursive
)
1052 wxASSERT_MSG( sizer
, _T("GetItem for NULL sizer") );
1054 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1057 wxSizerItem
*item
= node
->GetData();
1059 if (item
->GetSizer() == sizer
)
1063 else if (recursive
&& item
->IsSizer())
1065 wxSizerItem
*subitem
= item
->GetSizer()->GetItem( sizer
, true );
1070 node
= node
->GetNext();
1076 wxSizerItem
* wxSizer::GetItem( size_t index
)
1078 wxCHECK_MSG( index
< m_children
.GetCount(),
1080 _T("GetItem index is out of range") );
1082 return m_children
.Item( index
)->GetData();
1085 bool wxSizer::Show( wxWindow
*window
, bool show
, bool recursive
)
1087 wxSizerItem
*item
= GetItem( window
, recursive
);
1098 bool wxSizer::Show( wxSizer
*sizer
, bool show
, bool recursive
)
1100 wxSizerItem
*item
= GetItem( sizer
, recursive
);
1111 bool wxSizer::Show( size_t index
, bool show
)
1113 wxSizerItem
*item
= GetItem( index
);
1124 void wxSizer::ShowItems( bool show
)
1126 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1129 node
->GetData()->Show( show
);
1130 node
= node
->GetNext();
1134 bool wxSizer::IsShown( wxWindow
*window
) const
1136 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1139 wxSizerItem
*item
= node
->GetData();
1141 if (item
->GetWindow() == window
)
1143 return item
->IsShown();
1145 node
= node
->GetNext();
1148 wxFAIL_MSG( _T("IsShown failed to find sizer item") );
1153 bool wxSizer::IsShown( wxSizer
*sizer
) const
1155 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1158 wxSizerItem
*item
= node
->GetData();
1160 if (item
->GetSizer() == sizer
)
1162 return item
->IsShown();
1164 node
= node
->GetNext();
1167 wxFAIL_MSG( _T("IsShown failed to find sizer item") );
1172 bool wxSizer::IsShown( size_t index
) const
1174 wxCHECK_MSG( index
< m_children
.GetCount(),
1176 _T("IsShown index is out of range") );
1178 return m_children
.Item( index
)->GetData()->IsShown();
1182 //---------------------------------------------------------------------------
1184 //---------------------------------------------------------------------------
1186 wxGridSizer::wxGridSizer( int rows
, int cols
, int vgap
, int hgap
)
1187 : m_rows( ( cols
== 0 && rows
== 0 ) ? 1 : rows
)
1194 wxGridSizer::wxGridSizer( int cols
, int vgap
, int hgap
)
1195 : m_rows( cols
== 0 ? 1 : 0 )
1202 int wxGridSizer::CalcRowsCols(int& nrows
, int& ncols
) const
1204 int nitems
= m_children
.GetCount();
1210 nrows
= (nitems
+ m_cols
- 1) / m_cols
;
1214 ncols
= (nitems
+ m_rows
- 1) / m_rows
;
1217 else // 0 columns, 0 rows?
1219 wxFAIL_MSG( _T("grid sizer must have either rows or columns fixed") );
1228 void wxGridSizer::RecalcSizes()
1230 int nitems
, nrows
, ncols
;
1231 if ( (nitems
= CalcRowsCols(nrows
, ncols
)) == 0 )
1234 wxSize
sz( GetSize() );
1235 wxPoint
pt( GetPosition() );
1237 int w
= (sz
.x
- (ncols
- 1) * m_hgap
) / ncols
;
1238 int h
= (sz
.y
- (nrows
- 1) * m_vgap
) / nrows
;
1241 for (int c
= 0; c
< ncols
; c
++)
1244 for (int r
= 0; r
< nrows
; r
++)
1246 int i
= r
* ncols
+ c
;
1249 wxSizerItemList::compatibility_iterator node
= m_children
.Item( i
);
1251 wxASSERT_MSG( node
, _T("Failed to find SizerItemList node") );
1253 SetItemBounds( node
->GetData(), x
, y
, w
, h
);
1261 wxSize
wxGridSizer::CalcMin()
1264 if ( CalcRowsCols(nrows
, ncols
) == 0 )
1267 // Find the max width and height for any component
1271 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1274 wxSizerItem
*item
= node
->GetData();
1275 wxSize
sz( item
->CalcMin() );
1277 w
= wxMax( w
, sz
.x
);
1278 h
= wxMax( h
, sz
.y
);
1280 node
= node
->GetNext();
1283 return wxSize( ncols
* w
+ (ncols
-1) * m_hgap
,
1284 nrows
* h
+ (nrows
-1) * m_vgap
);
1287 void wxGridSizer::SetItemBounds( wxSizerItem
*item
, int x
, int y
, int w
, int h
)
1290 wxSize
sz( item
->GetMinSizeWithBorder() );
1291 int flag
= item
->GetFlag();
1293 if ((flag
& wxEXPAND
) || (flag
& wxSHAPED
))
1299 if (flag
& wxALIGN_CENTER_HORIZONTAL
)
1301 pt
.x
= x
+ (w
- sz
.x
) / 2;
1303 else if (flag
& wxALIGN_RIGHT
)
1305 pt
.x
= x
+ (w
- sz
.x
);
1308 if (flag
& wxALIGN_CENTER_VERTICAL
)
1310 pt
.y
= y
+ (h
- sz
.y
) / 2;
1312 else if (flag
& wxALIGN_BOTTOM
)
1314 pt
.y
= y
+ (h
- sz
.y
);
1318 item
->SetDimension(pt
, sz
);
1321 //---------------------------------------------------------------------------
1323 //---------------------------------------------------------------------------
1325 wxFlexGridSizer::wxFlexGridSizer( int rows
, int cols
, int vgap
, int hgap
)
1326 : wxGridSizer( rows
, cols
, vgap
, hgap
),
1327 m_flexDirection(wxBOTH
),
1328 m_growMode(wxFLEX_GROWMODE_SPECIFIED
)
1332 wxFlexGridSizer::wxFlexGridSizer( int cols
, int vgap
, int hgap
)
1333 : wxGridSizer( cols
, vgap
, hgap
),
1334 m_flexDirection(wxBOTH
),
1335 m_growMode(wxFLEX_GROWMODE_SPECIFIED
)
1339 wxFlexGridSizer::~wxFlexGridSizer()
1343 void wxFlexGridSizer::RecalcSizes()
1345 int nitems
, nrows
, ncols
;
1346 if ( (nitems
= CalcRowsCols(nrows
, ncols
)) == 0 )
1349 wxPoint
pt( GetPosition() );
1350 wxSize
sz( GetSize() );
1352 AdjustForGrowables(sz
, m_calculatedMinSize
, nrows
, ncols
);
1354 sz
= wxSize( pt
.x
+ sz
.x
, pt
.y
+ sz
.y
);
1357 for (int c
= 0; c
< ncols
; c
++)
1360 for (int r
= 0; r
< nrows
; r
++)
1362 int i
= r
* ncols
+ c
;
1365 wxSizerItemList::compatibility_iterator node
= m_children
.Item( i
);
1367 wxASSERT_MSG( node
, _T("Failed to find node") );
1369 int w
= wxMax( 0, wxMin( m_colWidths
[c
], sz
.x
- x
) );
1370 int h
= wxMax( 0, wxMin( m_rowHeights
[r
], sz
.y
- y
) );
1372 SetItemBounds( node
->GetData(), x
, y
, w
, h
);
1374 if (m_rowHeights
[r
] != -1)
1375 y
= y
+ m_rowHeights
[r
] + m_vgap
;
1377 if (m_colWidths
[c
] != -1)
1378 x
= x
+ m_colWidths
[c
] + m_hgap
;
1382 wxSize
wxFlexGridSizer::CalcMin()
1388 // Number of rows/columns can change as items are added or removed.
1389 if ( !CalcRowsCols(nrows
, ncols
) )
1392 m_rowHeights
.SetCount(nrows
);
1393 m_colWidths
.SetCount(ncols
);
1395 // We have to recalcuate the sizes in case the item minimum size has
1396 // changed since the previous layout, or the item has been hidden using
1397 // wxSizer::Show(). If all the items in a row/column are hidden, the final
1398 // dimension of the row/column will be -1, indicating that the column
1399 // itself is hidden.
1400 for( s
= m_rowHeights
.GetCount(), i
= 0; i
< s
; ++i
)
1401 m_rowHeights
[ i
] = -1;
1402 for( s
= m_colWidths
.GetCount(), i
= 0; i
< s
; ++i
)
1403 m_colWidths
[ i
] = -1;
1405 wxSizerItemList::compatibility_iterator node
= m_children
.GetFirst();
1410 wxSizerItem
*item
= node
->GetData();
1411 if ( item
->IsShown() )
1413 wxSize
sz( item
->CalcMin() );
1414 int row
= i
/ ncols
;
1415 int col
= i
% ncols
;
1417 m_rowHeights
[ row
] = wxMax( wxMax( 0, sz
.y
), m_rowHeights
[ row
] );
1418 m_colWidths
[ col
] = wxMax( wxMax( 0, sz
.x
), m_colWidths
[ col
] );
1421 node
= node
->GetNext();
1425 AdjustForFlexDirection();
1427 // Sum total minimum size, including gaps between rows/columns.
1428 // -1 is used as a magic number meaning empty column.
1430 for (int col
= 0; col
< ncols
; col
++)
1431 if ( m_colWidths
[ col
] != -1 )
1432 width
+= m_colWidths
[ col
] + m_hgap
;
1437 for (int row
= 0; row
< nrows
; row
++)
1438 if ( m_rowHeights
[ row
] != -1 )
1439 height
+= m_rowHeights
[ row
] + m_vgap
;
1443 m_calculatedMinSize
= wxSize( width
, height
);
1444 return m_calculatedMinSize
;
1447 void wxFlexGridSizer::AdjustForFlexDirection()
1449 // the logic in CalcMin works when we resize flexibly in both directions
1450 // but maybe this is not the case
1451 if ( m_flexDirection
!= wxBOTH
)
1453 // select the array corresponding to the direction in which we do *not*
1455 wxArrayInt
& array
= m_flexDirection
== wxVERTICAL
? m_colWidths
1458 const size_t count
= array
.GetCount();
1460 // find the largest value in this array
1464 for ( n
= 0; n
< count
; ++n
)
1466 if ( array
[n
] > largest
)
1470 // and now fill it with the largest value
1471 for ( n
= 0; n
< count
; ++n
)
1473 // don't touch hidden rows
1474 if ( array
[n
] != -1 )
1481 void wxFlexGridSizer::AdjustForGrowables(const wxSize
& sz
, const wxSize
& minsz
,
1482 int nrows
, int ncols
)
1484 // what to do with the rows? by default, resize them proportionally
1485 if ( sz
.y
> minsz
.y
&& ( (m_flexDirection
& wxVERTICAL
) || (m_growMode
== wxFLEX_GROWMODE_SPECIFIED
) ) )
1487 int sum_proportions
= 0;
1488 int growable_space
= 0;
1491 for (idx
= 0; idx
< m_growableRows
.GetCount(); idx
++)
1493 // Since the number of rows/columns can change as items are
1494 // inserted/deleted, we need to verify at runtime that the
1495 // requested growable rows/columns are still valid.
1496 if (m_growableRows
[idx
] >= nrows
)
1499 // If all items in a row/column are hidden, that row/column will
1500 // have a dimension of -1. This causes the row/column to be
1501 // hidden completely.
1502 if (m_rowHeights
[ m_growableRows
[idx
] ] == -1)
1504 sum_proportions
+= m_growableRowsProportions
[idx
];
1505 growable_space
+= m_rowHeights
[ m_growableRows
[idx
] ];
1511 for (idx
= 0; idx
< m_growableRows
.GetCount(); idx
++)
1513 if (m_growableRows
[idx
] >= nrows
)
1515 if (m_rowHeights
[ m_growableRows
[idx
] ] != -1)
1517 int delta
= (sz
.y
- minsz
.y
);
1518 if (sum_proportions
== 0)
1519 delta
= (delta
/num
) + m_rowHeights
[ m_growableRows
[idx
] ];
1521 delta
= ((delta
+growable_space
)*m_growableRowsProportions
[idx
]) / sum_proportions
;
1522 m_rowHeights
[ m_growableRows
[idx
] ] = delta
;
1527 else if ( (m_growMode
== wxFLEX_GROWMODE_ALL
) && (sz
.y
> minsz
.y
) )
1529 // rounding problem?
1530 for ( int row
= 0; row
< nrows
; ++row
)
1531 m_rowHeights
[ row
] = sz
.y
/ nrows
;
1534 // the same logic as above but for the columns
1535 if ( sz
.x
> minsz
.x
&& ( (m_flexDirection
& wxHORIZONTAL
) || (m_growMode
== wxFLEX_GROWMODE_SPECIFIED
) ) )
1537 int sum_proportions
= 0;
1538 int growable_space
= 0;
1541 for (idx
= 0; idx
< m_growableCols
.GetCount(); idx
++)
1543 // Since the number of rows/columns can change as items are
1544 // inserted/deleted, we need to verify at runtime that the
1545 // requested growable rows/columns are still valid.
1546 if (m_growableCols
[idx
] >= ncols
)
1549 // If all items in a row/column are hidden, that row/column will
1550 // have a dimension of -1. This causes the column to be hidden
1552 if (m_colWidths
[ m_growableCols
[idx
] ] == -1)
1554 sum_proportions
+= m_growableColsProportions
[idx
];
1555 growable_space
+= m_colWidths
[ m_growableCols
[idx
] ];
1561 for (idx
= 0; idx
< m_growableCols
.GetCount(); idx
++)
1563 if (m_growableCols
[idx
] >= ncols
)
1565 if (m_colWidths
[ m_growableCols
[idx
] ] != -1)
1567 int delta
= (sz
.x
- minsz
.x
);
1568 if (sum_proportions
== 0)
1569 delta
= (delta
/num
) + m_colWidths
[ m_growableCols
[idx
] ];
1571 delta
= ((delta
+growable_space
)*m_growableColsProportions
[idx
])/sum_proportions
;
1572 m_colWidths
[ m_growableCols
[idx
] ] = delta
;
1577 else if ( (m_growMode
== wxFLEX_GROWMODE_ALL
) && (sz
.x
> minsz
.x
) )
1579 for ( int col
=0; col
< ncols
; ++col
)
1580 m_colWidths
[ col
] = sz
.x
/ ncols
;
1585 void wxFlexGridSizer::AddGrowableRow( size_t idx
, int proportion
)
1587 m_growableRows
.Add( idx
);
1588 m_growableRowsProportions
.Add( proportion
);
1591 void wxFlexGridSizer::AddGrowableCol( size_t idx
, int proportion
)
1593 m_growableCols
.Add( idx
);
1594 m_growableColsProportions
.Add( proportion
);
1597 // helper function for RemoveGrowableCol/Row()
1599 DoRemoveFromArrays(size_t idx
, wxArrayInt
& items
, wxArrayInt
& proportions
)
1601 const size_t count
= items
.size();
1602 for ( size_t n
= 0; n
< count
; n
++ )
1604 if ( (size_t)items
[n
] == idx
)
1607 proportions
.RemoveAt(n
);
1612 wxFAIL_MSG( _T("column/row is already not growable") );
1615 void wxFlexGridSizer::RemoveGrowableCol( size_t idx
)
1617 DoRemoveFromArrays(idx
, m_growableCols
, m_growableColsProportions
);
1620 void wxFlexGridSizer::RemoveGrowableRow( size_t idx
)
1622 DoRemoveFromArrays(idx
, m_growableRows
, m_growableRowsProportions
);
1625 //---------------------------------------------------------------------------
1627 //---------------------------------------------------------------------------
1629 void wxBoxSizer::RecalcSizes()
1631 if ( m_children
.empty() )
1634 // the amount of free space which we should redistribute among the
1635 // stretchable items (i.e. those with non zero proportion)
1636 const int delta
= SizeInMajorDir(m_size
) - SizeInMajorDir(m_minSize
);
1638 // the position at which we put the next child
1639 wxPoint
pt(m_position
);
1641 const wxCoord totalMinorSize
= SizeInMinorDir(m_size
);
1643 for ( wxSizerItemList::const_iterator i
= m_children
.begin();
1644 i
!= m_children
.end();
1647 wxSizerItem
* const item
= *i
;
1649 if ( !item
->IsShown() )
1652 const wxSize
sizeThis(item
->GetMinSizeWithBorder());
1655 // adjust the size in the major direction using the proportion
1656 wxCoord majorSize
= SizeInMajorDir(sizeThis
);
1657 if ( item
->GetProportion() )
1659 // as at least one visible item has non-zero proportion the total
1660 // proportion must be non zero
1661 majorSize
+= (delta
* item
->GetProportion()) / m_totalProportion
;
1665 // apply the alignment in the minor direction
1666 wxPoint
posChild(pt
);
1668 wxCoord minorSize
= SizeInMinorDir(sizeThis
);
1669 const int flag
= item
->GetFlag();
1670 if ( flag
& (wxEXPAND
| wxSHAPED
) )
1672 minorSize
= totalMinorSize
;
1674 else if ( flag
& (IsVertical() ? wxALIGN_RIGHT
: wxALIGN_BOTTOM
) )
1676 PosInMinorDir(posChild
) += totalMinorSize
- minorSize
;
1678 // NB: wxCENTRE is used here only for backwards compatibility,
1679 // wxALIGN_CENTRE should be used in new code
1680 else if ( flag
& (wxCENTER
| wxALIGN_CENTRE
) )
1682 PosInMinorDir(posChild
) += (totalMinorSize
- minorSize
) / 2;
1686 // apply RTL adjustment for horizontal sizers:
1687 if ( !IsVertical() && m_containingWindow
)
1689 posChild
.x
= m_containingWindow
->AdjustForLayoutDirection
1697 // finally set size of this child and advance to the next one
1698 item
->SetDimension(posChild
, SizeFromMajorMinor(majorSize
, minorSize
));
1700 PosInMajorDir(pt
) += majorSize
;
1704 wxSize
wxBoxSizer::CalcMin()
1706 m_totalProportion
= 0;
1707 m_minSize
= wxSize(0, 0);
1709 // calculate the minimal sizes for all items and count sum of proportions
1710 for ( wxSizerItemList::const_iterator i
= m_children
.begin();
1711 i
!= m_children
.end();
1714 wxSizerItem
* const item
= *i
;
1716 if ( !item
->IsShown() )
1719 const wxSize sizeMinThis
= item
->CalcMin();
1721 SizeInMajorDir(m_minSize
) += SizeInMajorDir(sizeMinThis
);
1722 if ( SizeInMinorDir(sizeMinThis
) > SizeInMinorDir(m_minSize
) )
1723 SizeInMinorDir(m_minSize
) = SizeInMinorDir(sizeMinThis
);
1725 m_totalProportion
+= item
->GetProportion();
1731 //---------------------------------------------------------------------------
1733 //---------------------------------------------------------------------------
1737 wxStaticBoxSizer::wxStaticBoxSizer( wxStaticBox
*box
, int orient
)
1738 : wxBoxSizer( orient
),
1741 wxASSERT_MSG( box
, wxT("wxStaticBoxSizer needs a static box") );
1743 // do this so that our Detach() is called if the static box is destroyed
1745 m_staticBox
->SetContainingSizer(this);
1748 wxStaticBoxSizer::wxStaticBoxSizer(int orient
, wxWindow
*win
, const wxString
& s
)
1749 : wxBoxSizer(orient
),
1750 m_staticBox(new wxStaticBox(win
, wxID_ANY
, s
))
1753 m_staticBox
->SetContainingSizer(this);
1756 wxStaticBoxSizer::~wxStaticBoxSizer()
1761 static void GetStaticBoxBorders( wxStaticBox
*box
,
1765 // this has to be done platform by platform as there is no way to
1766 // guess the thickness of a wxStaticBox border
1767 box
->GetBordersForSizer(borderTop
, borderOther
);
1770 void wxStaticBoxSizer::RecalcSizes()
1772 int top_border
, other_border
;
1773 GetStaticBoxBorders(m_staticBox
, &top_border
, &other_border
);
1775 m_staticBox
->SetSize( m_position
.x
, m_position
.y
, m_size
.x
, m_size
.y
);
1777 wxPoint
old_pos( m_position
);
1778 m_position
.x
+= other_border
;
1779 m_position
.y
+= top_border
;
1780 wxSize
old_size( m_size
);
1781 m_size
.x
-= 2*other_border
;
1782 m_size
.y
-= top_border
+ other_border
;
1784 wxBoxSizer::RecalcSizes();
1786 m_position
= old_pos
;
1790 wxSize
wxStaticBoxSizer::CalcMin()
1792 int top_border
, other_border
;
1793 GetStaticBoxBorders(m_staticBox
, &top_border
, &other_border
);
1795 wxSize
ret( wxBoxSizer::CalcMin() );
1796 ret
.x
+= 2*other_border
;
1797 ret
.y
+= other_border
+ top_border
;
1802 void wxStaticBoxSizer::ShowItems( bool show
)
1804 m_staticBox
->Show( show
);
1805 wxBoxSizer::ShowItems( show
);
1808 bool wxStaticBoxSizer::Detach( wxWindow
*window
)
1810 // avoid deleting m_staticBox in our dtor if it's being detached from the
1811 // sizer (which can happen because it's being already destroyed for
1813 if ( window
== m_staticBox
)
1819 return wxSizer::Detach( window
);
1822 #endif // wxUSE_STATBOX
1826 wxStdDialogButtonSizer::wxStdDialogButtonSizer()
1827 : wxBoxSizer(wxHORIZONTAL
)
1829 // Vertical buttons with lots of space on either side
1830 // looks rubbish on WinCE, so let's not do this for now.
1831 // If we are going to use vertical buttons, we should
1832 // put the sizer to the right of other controls in the dialog,
1833 // and that's beyond the scope of this sizer.
1835 bool is_pda
= (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA
);
1836 // If we have a PDA screen, put yes/no button over
1837 // all other buttons, otherwise on the left side.
1839 m_orient
= wxVERTICAL
;
1842 m_buttonAffirmative
= NULL
;
1843 m_buttonApply
= NULL
;
1844 m_buttonNegative
= NULL
;
1845 m_buttonCancel
= NULL
;
1846 m_buttonHelp
= NULL
;
1849 void wxStdDialogButtonSizer::AddButton(wxButton
*mybutton
)
1851 switch (mybutton
->GetId())
1856 m_buttonAffirmative
= mybutton
;
1859 m_buttonApply
= mybutton
;
1862 m_buttonNegative
= mybutton
;
1866 m_buttonCancel
= mybutton
;
1869 case wxID_CONTEXT_HELP
:
1870 m_buttonHelp
= mybutton
;
1877 void wxStdDialogButtonSizer::SetAffirmativeButton( wxButton
*button
)
1879 m_buttonAffirmative
= button
;
1882 void wxStdDialogButtonSizer::SetNegativeButton( wxButton
*button
)
1884 m_buttonNegative
= button
;
1887 void wxStdDialogButtonSizer::SetCancelButton( wxButton
*button
)
1889 m_buttonCancel
= button
;
1892 void wxStdDialogButtonSizer::Realize()
1895 Add(0, 0, 0, wxLEFT
, 6);
1897 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 6);
1899 if (m_buttonNegative
){
1900 // HIG POLICE BULLETIN - destructive buttons need extra padding
1901 // 24 pixels on either side
1902 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 12);
1905 // extra whitespace between help/negative and cancel/ok buttons
1906 Add(0, 0, 1, wxEXPAND
, 0);
1908 if (m_buttonCancel
){
1909 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 6);
1910 // Cancel or help should be default
1911 // m_buttonCancel->SetDefaultButton();
1914 // Ugh, Mac doesn't really have apply dialogs, so I'll just
1915 // figure the best place is between Cancel and OK
1917 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 6);
1919 if (m_buttonAffirmative
){
1920 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
, 6);
1922 if (m_buttonAffirmative
->GetId() == wxID_SAVE
){
1923 // these buttons have set labels under Mac so we should use them
1924 m_buttonAffirmative
->SetLabel(_("Save"));
1925 if (m_buttonNegative
)
1926 m_buttonNegative
->SetLabel(_("Don't Save"));
1930 // Extra space around and at the right
1932 #elif defined(__WXGTK20__)
1933 Add(0, 0, 0, wxLEFT
, 9);
1935 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
1937 // extra whitespace between help and cancel/ok buttons
1938 Add(0, 0, 1, wxEXPAND
, 0);
1940 if (m_buttonNegative
){
1941 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
1944 // according to HIG, in explicit apply windows the order is:
1945 // [ Help Apply Cancel OK ]
1947 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
1949 if (m_buttonCancel
){
1950 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, 3);
1951 // Cancel or help should be default
1952 // m_buttonCancel->SetDefaultButton();
1955 if (m_buttonAffirmative
)
1956 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
, 6);
1957 #elif defined(__WXMSW__)
1960 // right-justify buttons
1961 Add(0, 0, 1, wxEXPAND
, 0);
1963 if (m_buttonAffirmative
){
1964 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonAffirmative
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1967 if (m_buttonNegative
){
1968 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonNegative
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1971 if (m_buttonCancel
){
1972 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonCancel
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1975 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonApply
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1978 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonHelp
->ConvertDialogToPixels(wxSize(2, 0)).x
);
1980 // GTK+1 and any other platform
1982 // Add(0, 0, 0, wxLEFT, 5); // Not sure what this was for but it unbalances the dialog
1984 Add((wxWindow
*)m_buttonHelp
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonHelp
->ConvertDialogToPixels(wxSize(4, 0)).x
);
1986 // extra whitespace between help and cancel/ok buttons
1987 Add(0, 0, 1, wxEXPAND
, 0);
1990 Add((wxWindow
*)m_buttonApply
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonApply
->ConvertDialogToPixels(wxSize(4, 0)).x
);
1992 if (m_buttonAffirmative
){
1993 Add((wxWindow
*)m_buttonAffirmative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonAffirmative
->ConvertDialogToPixels(wxSize(4, 0)).x
);
1996 if (m_buttonNegative
){
1997 Add((wxWindow
*)m_buttonNegative
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonNegative
->ConvertDialogToPixels(wxSize(4, 0)).x
);
2000 if (m_buttonCancel
){
2001 Add((wxWindow
*)m_buttonCancel
, 0, wxALIGN_CENTRE
| wxLEFT
| wxRIGHT
, m_buttonCancel
->ConvertDialogToPixels(wxSize(4, 0)).x
);
2002 // Cancel or help should be default
2003 // m_buttonCancel->SetDefaultButton();
2009 #endif // wxUSE_BUTTON