1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: provide wxSizer class for layout
4 // Author: Robert Roebling and Robin Dunn
5 // Modified by: Ron Lee, Vadim Zeitlin (wxSizerFlags)
8 // Copyright: (c) Robin Dunn, Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
17 #include "wx/window.h"
19 //---------------------------------------------------------------------------
21 //---------------------------------------------------------------------------
23 class WXDLLEXPORT wxButton
;
24 class WXDLLEXPORT wxBoxSizer
;
25 class WXDLLEXPORT wxSizerItem
;
26 class WXDLLEXPORT wxSizer
;
28 #ifndef wxUSE_BORDER_BY_DEFAULT
30 // no borders by default on limited size screen
31 #define wxUSE_BORDER_BY_DEFAULT 0
33 #define wxUSE_BORDER_BY_DEFAULT 1
37 // ----------------------------------------------------------------------------
38 // wxSizerFlags: flags used for an item in the sizer
39 // ----------------------------------------------------------------------------
41 class WXDLLEXPORT wxSizerFlags
44 // construct the flags object initialized with the given proportion (0 by
46 wxSizerFlags(int proportion
= 0) : m_proportion(proportion
)
52 // setters for all sizer flags, they all return the object itself so that
53 // calls to them can be chained
55 wxSizerFlags
& Proportion(int proportion
)
57 m_proportion
= proportion
;
61 wxSizerFlags
& Align(int alignment
) // combination of wxAlignment values
63 m_flags
&= ~wxALIGN_MASK
;
69 wxSizerFlags
& Expand()
75 // some shortcuts for Align()
76 wxSizerFlags
& Centre() { return Align(wxALIGN_CENTRE
); }
77 wxSizerFlags
& Center() { return Centre(); }
78 wxSizerFlags
& Top() { return Align(wxALIGN_TOP
); }
79 wxSizerFlags
& Left() { return Align(wxALIGN_LEFT
); }
80 wxSizerFlags
& Right() { return Align(wxALIGN_RIGHT
); }
81 wxSizerFlags
& Bottom() { return Align(wxALIGN_BOTTOM
); }
83 // default border size used by Border() below
84 static int GetDefaultBorder()
86 #if wxUSE_BORDER_BY_DEFAULT
87 // FIXME: default border size shouldn't be hardcoded and at the very
88 // least they should depend on the current font size
96 wxSizerFlags
& Border(int direction
, int borderInPixels
)
101 m_borderInPixels
= borderInPixels
;
106 wxSizerFlags
& Border(int direction
= wxALL
)
108 #if wxUSE_BORDER_BY_DEFAULT
109 return Border(direction
, GetDefaultBorder());
111 // no borders by default on limited size screen
112 wxUnusedVar(direction
);
118 wxSizerFlags
& DoubleBorder(int direction
= wxALL
)
120 #if wxUSE_BORDER_BY_DEFAULT
121 return Border(direction
, 2*GetDefaultBorder());
123 wxUnusedVar(direction
);
129 wxSizerFlags
& TripleBorder(int direction
= wxALL
)
131 #if wxUSE_BORDER_BY_DEFAULT
132 return Border(direction
, 3*GetDefaultBorder());
134 wxUnusedVar(direction
);
140 wxSizerFlags
& HorzBorder()
142 #if wxUSE_BORDER_BY_DEFAULT
143 return Border(wxLEFT
| wxRIGHT
, GetDefaultBorder());
149 wxSizerFlags
& DoubleHorzBorder()
151 #if wxUSE_BORDER_BY_DEFAULT
152 return Border(wxLEFT
| wxRIGHT
, 2*GetDefaultBorder());
158 // setters for the others flags
159 wxSizerFlags
& Shaped()
166 wxSizerFlags
& FixedMinSize()
168 m_flags
|= wxFIXED_MINSIZE
;
173 // accessors for wxSizer only
174 int GetProportion() const { return m_proportion
; }
175 int GetFlags() const { return m_flags
; }
176 int GetBorderInPixels() const { return m_borderInPixels
; }
181 int m_borderInPixels
;
185 // ----------------------------------------------------------------------------
186 // wxSizerSpacer: used by wxSizerItem to represent a spacer
187 // ----------------------------------------------------------------------------
189 class WXDLLEXPORT wxSizerSpacer
192 wxSizerSpacer(const wxSize
& size
) : m_size(size
), m_isShown(true) { }
194 void SetSize(const wxSize
& size
) { m_size
= size
; }
195 const wxSize
& GetSize() const { return m_size
; }
197 void Show(bool show
) { m_isShown
= show
; }
198 bool IsShown() const { return m_isShown
; }
201 // the size, in pixel
204 // is the spacer currently shown?
208 // ----------------------------------------------------------------------------
210 // ----------------------------------------------------------------------------
212 class WXDLLEXPORT wxSizerItem
: public wxObject
216 wxSizerItem( wxWindow
*window
,
220 wxObject
* userData
);
223 wxSizerItem(wxWindow
*window
, const wxSizerFlags
& flags
)
231 wxSizerItem( wxSizer
*sizer
,
235 wxObject
* userData
);
238 wxSizerItem(wxSizer
*sizer
, const wxSizerFlags
& flags
)
246 wxSizerItem( int width
,
254 wxSizerItem(int width
, int height
, const wxSizerFlags
& flags
)
258 DoSetSpacer(wxSize(width
, height
));
262 virtual ~wxSizerItem();
264 virtual void DeleteWindows();
266 // Enable deleting the SizerItem without destroying the contained sizer.
267 void DetachSizer() { m_sizer
= NULL
; }
269 virtual wxSize
GetSize() const;
270 virtual wxSize
CalcMin();
271 virtual void SetDimension( const wxPoint
& pos
, const wxSize
& size
);
273 wxSize
GetMinSize() const
274 { return m_minSize
; }
275 wxSize
GetMinSizeWithBorder() const;
277 void SetMinSize(const wxSize
& size
)
280 m_window
->SetMinSize(size
);
283 void SetMinSize( int x
, int y
)
284 { SetMinSize(wxSize(x
, y
)); }
285 void SetInitSize( int x
, int y
)
286 { SetMinSize(wxSize(x
, y
)); }
288 // if either of dimensions is zero, ratio is assumed to be 1
289 // to avoid "divide by zero" errors
290 void SetRatio(int width
, int height
)
291 { m_ratio
= (width
&& height
) ? ((float) width
/ (float) height
) : 1; }
292 void SetRatio(const wxSize
& size
)
293 { SetRatio(size
.x
, size
.y
); }
294 void SetRatio(float ratio
)
296 float GetRatio() const
299 virtual wxRect
GetRect() { return m_rect
; }
301 bool IsWindow() const { return m_kind
== Item_Window
; }
302 bool IsSizer() const { return m_kind
== Item_Sizer
; }
303 bool IsSpacer() const { return m_kind
== Item_Spacer
; }
305 #if WXWIN_COMPATIBILITY_2_6
306 // Deprecated in 2.6, use {G,S}etProportion instead.
307 wxDEPRECATED( void SetOption( int option
) );
308 wxDEPRECATED( int GetOption() const );
309 #endif // WXWIN_COMPATIBILITY_2_6
311 void SetProportion( int proportion
)
312 { m_proportion
= proportion
; }
313 int GetProportion() const
314 { return m_proportion
; }
315 void SetFlag( int flag
)
319 void SetBorder( int border
)
320 { m_border
= border
; }
321 int GetBorder() const
324 wxWindow
*GetWindow() const
325 { return m_kind
== Item_Window
? m_window
: NULL
; }
326 wxSizer
*GetSizer() const
327 { return m_kind
== Item_Sizer
? m_sizer
: NULL
; }
328 wxSize
GetSpacer() const;
330 // this function behaves obviously for the windows and spacers but for the
331 // sizers it returns true if any sizer element is shown and only returns
332 // false if all of them are hidden
333 bool IsShown() const;
334 void Show(bool show
);
336 void SetUserData(wxObject
* userData
)
337 { delete m_userData
; m_userData
= userData
; }
338 wxObject
* GetUserData() const
339 { return m_userData
; }
340 wxPoint
GetPosition() const
343 // these functions delete the current contents of the item if it's a sizer
344 // or a spacer but not if it is a window
345 void AssignWindow(wxWindow
*window
)
351 void AssignSizer(wxSizer
*sizer
)
357 void AssignSpacer(const wxSize
& size
)
363 void AssignSpacer(int w
, int h
) { AssignSpacer(wxSize(w
, h
)); }
365 #if WXWIN_COMPATIBILITY_2_8
366 // these functions do not free the old sizer/spacer and so can easily
367 // provoke the memory leaks and so shouldn't be used, use Assign() instead
368 wxDEPRECATED( void SetWindow(wxWindow
*window
) );
369 wxDEPRECATED( void SetSizer(wxSizer
*sizer
) );
370 wxDEPRECATED( void SetSpacer(const wxSize
& size
) );
371 wxDEPRECATED( void SetSpacer(int width
, int height
) );
372 #endif // WXWIN_COMPATIBILITY_2_8
375 // common part of several ctors
376 void Init() { m_userData
= NULL
; m_kind
= Item_None
; }
378 // common part of ctors taking wxSizerFlags
379 void Init(const wxSizerFlags
& flags
);
381 // free current contents
384 // common parts of Set/AssignXXX()
385 void DoSetWindow(wxWindow
*window
);
386 void DoSetSizer(wxSizer
*sizer
);
387 void DoSetSpacer(const wxSize
& size
);
389 // discriminated union: depending on m_kind one of the fields is valid
402 wxSizerSpacer
*m_spacer
;
411 // on screen rectangle of this item (not including borders)
414 // Aspect ratio can always be calculated from m_size,
415 // but this would cause precision loss when the window
416 // is shrunk. It is safer to preserve the initial value.
419 wxObject
*m_userData
;
422 DECLARE_CLASS(wxSizerItem
)
423 DECLARE_NO_COPY_CLASS(wxSizerItem
)
426 WX_DECLARE_EXPORTED_LIST( wxSizerItem
, wxSizerItemList
);
429 //---------------------------------------------------------------------------
431 //---------------------------------------------------------------------------
433 class WXDLLEXPORT wxSizer
: public wxObject
, public wxClientDataContainer
436 wxSizer() { m_containingWindow
= NULL
; }
439 // methods for adding elements to the sizer: there are Add/Insert/Prepend
440 // overloads for each of window/sizer/spacer/wxSizerItem
441 wxSizerItem
* Add(wxWindow
*window
,
445 wxObject
* userData
= NULL
);
446 wxSizerItem
* Add(wxSizer
*sizer
,
450 wxObject
* userData
= NULL
);
451 wxSizerItem
* Add(int width
,
456 wxObject
* userData
= NULL
);
457 wxSizerItem
* Add( wxWindow
*window
, const wxSizerFlags
& flags
);
458 wxSizerItem
* Add( wxSizer
*sizer
, const wxSizerFlags
& flags
);
459 wxSizerItem
* Add( wxSizerItem
*item
);
461 wxSizerItem
* AddSpacer(int size
);
462 wxSizerItem
* AddStretchSpacer(int prop
= 1);
464 wxSizerItem
* Insert(size_t index
,
469 wxObject
* userData
= NULL
);
470 wxSizerItem
* Insert(size_t index
,
475 wxObject
* userData
= NULL
);
476 wxSizerItem
* Insert(size_t index
,
482 wxObject
* userData
= NULL
);
483 wxSizerItem
* Insert(size_t index
,
485 const wxSizerFlags
& flags
);
486 wxSizerItem
* Insert(size_t index
,
488 const wxSizerFlags
& flags
);
489 virtual wxSizerItem
* Insert( size_t index
, wxSizerItem
*item
);
491 wxSizerItem
* InsertSpacer(size_t index
, int size
);
492 wxSizerItem
* InsertStretchSpacer(size_t index
, int prop
= 1);
494 wxSizerItem
* Prepend(wxWindow
*window
,
498 wxObject
* userData
= NULL
);
499 wxSizerItem
* Prepend(wxSizer
*sizer
,
503 wxObject
* userData
= NULL
);
504 wxSizerItem
* Prepend(int width
,
509 wxObject
* userData
= NULL
);
510 wxSizerItem
* Prepend(wxWindow
*window
, const wxSizerFlags
& flags
);
511 wxSizerItem
* Prepend(wxSizer
*sizer
, const wxSizerFlags
& flags
);
512 wxSizerItem
* Prepend(wxSizerItem
*item
);
514 wxSizerItem
* PrependSpacer(int size
);
515 wxSizerItem
* PrependStretchSpacer(int prop
= 1);
517 // set (or possibly unset if window is NULL) or get the window this sizer
519 void SetContainingWindow(wxWindow
*window
);
520 wxWindow
*GetContainingWindow() const { return m_containingWindow
; }
522 #if WXWIN_COMPATIBILITY_2_6
523 // Deprecated in 2.6 since historically it does not delete the window,
524 // use Detach instead.
525 wxDEPRECATED( virtual bool Remove( wxWindow
*window
) );
526 #endif // WXWIN_COMPATIBILITY_2_6
528 virtual bool Remove( wxSizer
*sizer
);
529 virtual bool Remove( int index
);
531 virtual bool Detach( wxWindow
*window
);
532 virtual bool Detach( wxSizer
*sizer
);
533 virtual bool Detach( int index
);
535 virtual bool Replace( wxWindow
*oldwin
, wxWindow
*newwin
, bool recursive
= false );
536 virtual bool Replace( wxSizer
*oldsz
, wxSizer
*newsz
, bool recursive
= false );
537 virtual bool Replace( size_t index
, wxSizerItem
*newitem
);
539 virtual void Clear( bool delete_windows
= false );
540 virtual void DeleteWindows();
542 void SetMinSize( int width
, int height
)
543 { DoSetMinSize( width
, height
); }
544 void SetMinSize( const wxSize
& size
)
545 { DoSetMinSize( size
.x
, size
.y
); }
547 // Searches recursively
548 bool SetItemMinSize( wxWindow
*window
, int width
, int height
)
549 { return DoSetItemMinSize( window
, width
, height
); }
550 bool SetItemMinSize( wxWindow
*window
, const wxSize
& size
)
551 { return DoSetItemMinSize( window
, size
.x
, size
.y
); }
553 // Searches recursively
554 bool SetItemMinSize( wxSizer
*sizer
, int width
, int height
)
555 { return DoSetItemMinSize( sizer
, width
, height
); }
556 bool SetItemMinSize( wxSizer
*sizer
, const wxSize
& size
)
557 { return DoSetItemMinSize( sizer
, size
.x
, size
.y
); }
559 bool SetItemMinSize( size_t index
, int width
, int height
)
560 { return DoSetItemMinSize( index
, width
, height
); }
561 bool SetItemMinSize( size_t index
, const wxSize
& size
)
562 { return DoSetItemMinSize( index
, size
.x
, size
.y
); }
564 wxSize
GetSize() const
566 wxPoint
GetPosition() const
567 { return m_position
; }
569 // Calculate the minimal size or return m_minSize if bigger.
572 // These virtual functions are used by the layout algorithm: first
573 // CalcMin() is called to calculate the minimal size of the sizer and
574 // prepare for laying it out and then RecalcSizes() is called to really
575 // update all the sizer items
576 virtual wxSize
CalcMin() = 0;
577 virtual void RecalcSizes() = 0;
579 virtual void Layout();
581 wxSize
Fit( wxWindow
*window
);
582 void FitInside( wxWindow
*window
);
583 void SetSizeHints( wxWindow
*window
);
584 void SetVirtualSizeHints( wxWindow
*window
);
586 wxSizerItemList
& GetChildren()
587 { return m_children
; }
588 const wxSizerItemList
& GetChildren() const
589 { return m_children
; }
591 void SetDimension( int x
, int y
, int width
, int height
);
593 wxSizerItem
* GetItem( wxWindow
*window
, bool recursive
= false );
594 wxSizerItem
* GetItem( wxSizer
*sizer
, bool recursive
= false );
595 wxSizerItem
* GetItem( size_t index
);
597 // Manage whether individual scene items are considered
598 // in the layout calculations or not.
599 bool Show( wxWindow
*window
, bool show
= true, bool recursive
= false );
600 bool Show( wxSizer
*sizer
, bool show
= true, bool recursive
= false );
601 bool Show( size_t index
, bool show
= true );
603 bool Hide( wxSizer
*sizer
, bool recursive
= false )
604 { return Show( sizer
, false, recursive
); }
605 bool Hide( wxWindow
*window
, bool recursive
= false )
606 { return Show( window
, false, recursive
); }
607 bool Hide( size_t index
)
608 { return Show( index
, false ); }
610 bool IsShown( wxWindow
*window
) const;
611 bool IsShown( wxSizer
*sizer
) const;
612 bool IsShown( size_t index
) const;
614 // Recursively call wxWindow::Show () on all sizer items.
615 virtual void ShowItems (bool show
);
617 void Show(bool show
) { ShowItems(show
); }
623 wxSizerItemList m_children
;
625 // the window this sizer is used in, can be NULL
626 wxWindow
*m_containingWindow
;
628 wxSize
GetMaxWindowSize( wxWindow
*window
) const;
629 wxSize
GetMinWindowSize( wxWindow
*window
);
630 wxSize
GetMaxClientSize( wxWindow
*window
) const;
631 wxSize
GetMinClientSize( wxWindow
*window
);
632 wxSize
VirtualFitSize( wxWindow
*window
);
634 virtual void DoSetMinSize( int width
, int height
);
635 virtual bool DoSetItemMinSize( wxWindow
*window
, int width
, int height
);
636 virtual bool DoSetItemMinSize( wxSizer
*sizer
, int width
, int height
);
637 virtual bool DoSetItemMinSize( size_t index
, int width
, int height
);
640 DECLARE_CLASS(wxSizer
)
643 //---------------------------------------------------------------------------
645 //---------------------------------------------------------------------------
647 class WXDLLEXPORT wxGridSizer
: public wxSizer
650 wxGridSizer( int rows
, int cols
, int vgap
, int hgap
);
651 wxGridSizer( int cols
, int vgap
= 0, int hgap
= 0 );
653 virtual void RecalcSizes();
654 virtual wxSize
CalcMin();
656 void SetCols( int cols
) { m_cols
= cols
; }
657 void SetRows( int rows
) { m_rows
= rows
; }
658 void SetVGap( int gap
) { m_vgap
= gap
; }
659 void SetHGap( int gap
) { m_hgap
= gap
; }
660 int GetCols() const { return m_cols
; }
661 int GetRows() const { return m_rows
; }
662 int GetVGap() const { return m_vgap
; }
663 int GetHGap() const { return m_hgap
; }
671 // return the number of total items and the number of columns and rows
672 int CalcRowsCols(int& rows
, int& cols
) const;
674 void SetItemBounds( wxSizerItem
*item
, int x
, int y
, int w
, int h
);
677 DECLARE_CLASS(wxGridSizer
)
680 //---------------------------------------------------------------------------
682 //---------------------------------------------------------------------------
684 // the bevaiour for resizing wxFlexGridSizer cells in the "non-flexible"
686 enum wxFlexSizerGrowMode
688 // don't resize the cells in non-flexible direction at all
689 wxFLEX_GROWMODE_NONE
,
691 // uniformly resize only the specified ones (default)
692 wxFLEX_GROWMODE_SPECIFIED
,
694 // uniformly resize all cells
698 class WXDLLEXPORT wxFlexGridSizer
: public wxGridSizer
702 wxFlexGridSizer( int rows
, int cols
, int vgap
, int hgap
);
703 wxFlexGridSizer( int cols
, int vgap
= 0, int hgap
= 0 );
704 virtual ~wxFlexGridSizer();
707 // set the rows/columns which will grow (the others will remain of the
708 // constant initial size)
709 void AddGrowableRow( size_t idx
, int proportion
= 0 );
710 void RemoveGrowableRow( size_t idx
);
711 void AddGrowableCol( size_t idx
, int proportion
= 0 );
712 void RemoveGrowableCol( size_t idx
);
715 // the sizer cells may grow in both directions, not grow at all or only
716 // grow in one direction but not the other
718 // the direction may be wxVERTICAL, wxHORIZONTAL or wxBOTH (default)
719 void SetFlexibleDirection(int direction
) { m_flexDirection
= direction
; }
720 int GetFlexibleDirection() const { return m_flexDirection
; }
722 // note that the grow mode only applies to the direction which is not
724 void SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode
) { m_growMode
= mode
; }
725 wxFlexSizerGrowMode
GetNonFlexibleGrowMode() const { return m_growMode
; }
727 // Read-only access to the row heights and col widths arrays
728 const wxArrayInt
& GetRowHeights() const { return m_rowHeights
; }
729 const wxArrayInt
& GetColWidths() const { return m_colWidths
; }
732 virtual void RecalcSizes();
733 virtual wxSize
CalcMin();
736 void AdjustForFlexDirection();
737 void AdjustForGrowables(const wxSize
& sz
, const wxSize
& minsz
,
738 int nrows
, int ncols
);
740 // the heights/widths of all rows/columns
741 wxArrayInt m_rowHeights
,
744 // indices of the growable columns and rows
745 wxArrayInt m_growableRows
,
748 // proportion values of the corresponding growable rows and columns
749 wxArrayInt m_growableRowsProportions
,
750 m_growableColsProportions
;
752 // parameters describing whether the growable cells should be resized in
753 // both directions or only one
755 wxFlexSizerGrowMode m_growMode
;
757 // saves CalcMin result to optimize RecalcSizes
758 wxSize m_calculatedMinSize
;
761 DECLARE_CLASS(wxFlexGridSizer
)
762 DECLARE_NO_COPY_CLASS(wxFlexGridSizer
)
765 //---------------------------------------------------------------------------
767 //---------------------------------------------------------------------------
769 class WXDLLEXPORT wxBoxSizer
: public wxSizer
772 wxBoxSizer(int orient
)
776 wxASSERT_MSG( m_orient
== wxHORIZONTAL
|| m_orient
== wxVERTICAL
,
777 _T("invalid value for wxBoxSizer orientation") );
780 int GetOrientation() const { return m_orient
; }
782 bool IsVertical() const { return m_orient
== wxVERTICAL
; }
784 void SetOrientation(int orient
) { m_orient
= orient
; }
786 // implementation of our resizing logic
787 virtual wxSize
CalcMin();
788 virtual void RecalcSizes();
791 // helpers for our code: this returns the component of the given wxSize in
792 // the direction of the sizer and in the other direction, respectively
793 int SizeInMajorDir(const wxSize
& sz
) const
795 return m_orient
== wxHORIZONTAL
? sz
.x
: sz
.y
;
798 int& SizeInMajorDir(wxSize
& sz
)
800 return m_orient
== wxHORIZONTAL
? sz
.x
: sz
.y
;
803 int& PosInMajorDir(wxPoint
& pt
)
805 return m_orient
== wxHORIZONTAL
? pt
.x
: pt
.y
;
808 int SizeInMinorDir(const wxSize
& sz
) const
810 return m_orient
== wxHORIZONTAL
? sz
.y
: sz
.x
;
813 int& SizeInMinorDir(wxSize
& sz
)
815 return m_orient
== wxHORIZONTAL
? sz
.y
: sz
.x
;
818 int& PosInMinorDir(wxPoint
& pt
)
820 return m_orient
== wxHORIZONTAL
? pt
.y
: pt
.x
;
823 // another helper: creates wxSize from major and minor components
824 wxSize
SizeFromMajorMinor(int major
, int minor
) const
826 if ( m_orient
== wxHORIZONTAL
)
828 return wxSize(major
, minor
);
832 return wxSize(minor
, major
);
837 // either wxHORIZONTAL or wxVERTICAL
840 // the sum of proportion of all of our elements
841 int m_totalProportion
;
843 // the minimal size needed for this sizer as calculated by the last call to
848 DECLARE_CLASS(wxBoxSizer
)
851 //---------------------------------------------------------------------------
853 //---------------------------------------------------------------------------
857 class WXDLLEXPORT wxStaticBox
;
859 class WXDLLEXPORT wxStaticBoxSizer
: public wxBoxSizer
862 wxStaticBoxSizer(wxStaticBox
*box
, int orient
);
863 wxStaticBoxSizer(int orient
, wxWindow
*win
, const wxString
& label
= wxEmptyString
);
864 virtual ~wxStaticBoxSizer();
869 wxStaticBox
*GetStaticBox() const
870 { return m_staticBox
; }
872 // override to hide/show the static box as well
873 virtual void ShowItems (bool show
);
875 virtual bool Detach( wxWindow
*window
);
876 virtual bool Detach( wxSizer
*sizer
) { return wxBoxSizer::Detach(sizer
); }
877 virtual bool Detach( int index
) { return wxBoxSizer::Detach(index
); }
880 wxStaticBox
*m_staticBox
;
883 DECLARE_CLASS(wxStaticBoxSizer
)
884 DECLARE_NO_COPY_CLASS(wxStaticBoxSizer
)
887 #endif // wxUSE_STATBOX
891 class WXDLLEXPORT wxStdDialogButtonSizer
: public wxBoxSizer
894 // Constructor just creates a new wxBoxSizer, not much else.
895 // Box sizer orientation is automatically determined here:
896 // vertical for PDAs, horizontal for everything else?
897 wxStdDialogButtonSizer();
899 // Checks button ID against system IDs and sets one of the pointers below
900 // to this button. Does not do any sizer-related things here.
901 void AddButton(wxButton
*button
);
903 // Use these if no standard ID can/should be used
904 void SetAffirmativeButton( wxButton
*button
);
905 void SetNegativeButton( wxButton
*button
);
906 void SetCancelButton( wxButton
*button
);
908 // All platform-specific code here, checks which buttons exist and add
909 // them to the sizer accordingly.
910 // Note - one potential hack on Mac we could use here,
911 // if m_buttonAffirmative is wxID_SAVE then ensure wxID_SAVE
912 // is set to _("Save") and m_buttonNegative is set to _("Don't Save")
913 // I wouldn't add any other hacks like that into here,
914 // but this one I can see being useful.
917 wxButton
*GetAffirmativeButton() const { return m_buttonAffirmative
; }
918 wxButton
*GetApplyButton() const { return m_buttonApply
; }
919 wxButton
*GetNegativeButton() const { return m_buttonNegative
; }
920 wxButton
*GetCancelButton() const { return m_buttonCancel
; }
921 wxButton
*GetHelpButton() const { return m_buttonHelp
; }
924 wxButton
*m_buttonAffirmative
; // wxID_OK, wxID_YES, wxID_SAVE go here
925 wxButton
*m_buttonApply
; // wxID_APPLY
926 wxButton
*m_buttonNegative
; // wxID_NO
927 wxButton
*m_buttonCancel
; // wxID_CANCEL, wxID_CLOSE
928 wxButton
*m_buttonHelp
; // wxID_HELP, wxID_CONTEXT_HELP
931 DECLARE_CLASS(wxStdDialogButtonSizer
)
932 DECLARE_NO_COPY_CLASS(wxStdDialogButtonSizer
)
935 #endif // wxUSE_BUTTON
938 // ----------------------------------------------------------------------------
939 // inline functions implementation
940 // ----------------------------------------------------------------------------
942 #if WXWIN_COMPATIBILITY_2_8
944 inline void wxSizerItem::SetWindow(wxWindow
*window
)
949 inline void wxSizerItem::SetSizer(wxSizer
*sizer
)
954 inline void wxSizerItem::SetSpacer(const wxSize
& size
)
959 inline void wxSizerItem::SetSpacer(int width
, int height
)
961 DoSetSpacer(wxSize(width
, height
));
964 #endif // WXWIN_COMPATIBILITY_2_8
968 wxSizer::Add( wxSizerItem
*item
)
970 return Insert( m_children
.GetCount(), item
);
974 wxSizer::Add( wxWindow
*window
, int proportion
, int flag
, int border
, wxObject
* userData
)
976 return Add( new wxSizerItem( window
, proportion
, flag
, border
, userData
) );
980 wxSizer::Add( wxSizer
*sizer
, int proportion
, int flag
, int border
, wxObject
* userData
)
982 return Add( new wxSizerItem( sizer
, proportion
, flag
, border
, userData
) );
986 wxSizer::Add( int width
, int height
, int proportion
, int flag
, int border
, wxObject
* userData
)
988 return Add( new wxSizerItem( width
, height
, proportion
, flag
, border
, userData
) );
992 wxSizer::Add( wxWindow
*window
, const wxSizerFlags
& flags
)
994 return Add( new wxSizerItem(window
, flags
) );
998 wxSizer::Add( wxSizer
*sizer
, const wxSizerFlags
& flags
)
1000 return Add( new wxSizerItem(sizer
, flags
) );
1004 wxSizer::AddSpacer(int size
)
1006 return Add(size
, size
);
1010 wxSizer::AddStretchSpacer(int prop
)
1012 return Add(0, 0, prop
);
1016 wxSizer::Prepend( wxSizerItem
*item
)
1018 return Insert( 0, item
);
1022 wxSizer::Prepend( wxWindow
*window
, int proportion
, int flag
, int border
, wxObject
* userData
)
1024 return Prepend( new wxSizerItem( window
, proportion
, flag
, border
, userData
) );
1028 wxSizer::Prepend( wxSizer
*sizer
, int proportion
, int flag
, int border
, wxObject
* userData
)
1030 return Prepend( new wxSizerItem( sizer
, proportion
, flag
, border
, userData
) );
1034 wxSizer::Prepend( int width
, int height
, int proportion
, int flag
, int border
, wxObject
* userData
)
1036 return Prepend( new wxSizerItem( width
, height
, proportion
, flag
, border
, userData
) );
1040 wxSizer::PrependSpacer(int size
)
1042 return Prepend(size
, size
);
1046 wxSizer::PrependStretchSpacer(int prop
)
1048 return Prepend(0, 0, prop
);
1052 wxSizer::Prepend( wxWindow
*window
, const wxSizerFlags
& flags
)
1054 return Prepend( new wxSizerItem(window
, flags
) );
1058 wxSizer::Prepend( wxSizer
*sizer
, const wxSizerFlags
& flags
)
1060 return Prepend( new wxSizerItem(sizer
, flags
) );
1064 wxSizer::Insert( size_t index
,
1069 wxObject
* userData
)
1071 return Insert( index
, new wxSizerItem( window
, proportion
, flag
, border
, userData
) );
1075 wxSizer::Insert( size_t index
,
1080 wxObject
* userData
)
1082 return Insert( index
, new wxSizerItem( sizer
, proportion
, flag
, border
, userData
) );
1086 wxSizer::Insert( size_t index
,
1092 wxObject
* userData
)
1094 return Insert( index
, new wxSizerItem( width
, height
, proportion
, flag
, border
, userData
) );
1098 wxSizer::Insert( size_t index
, wxWindow
*window
, const wxSizerFlags
& flags
)
1100 return Insert( index
, new wxSizerItem(window
, flags
) );
1104 wxSizer::Insert( size_t index
, wxSizer
*sizer
, const wxSizerFlags
& flags
)
1106 return Insert( index
, new wxSizerItem(sizer
, flags
) );
1110 wxSizer::InsertSpacer(size_t index
, int size
)
1112 return Insert(index
, size
, size
);
1116 wxSizer::InsertStretchSpacer(size_t index
, int prop
)
1118 return Insert(index
, 0, 0, prop
);
1121 #endif // __WXSIZER_H__