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 WXDLLIMPEXP_FWD_CORE wxButton
;
24 class WXDLLIMPEXP_FWD_CORE wxBoxSizer
;
25 class WXDLLIMPEXP_FWD_CORE wxSizerItem
;
26 class WXDLLIMPEXP_FWD_CORE 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 // set a sizer item id (different from a window id, all sizer items,
302 // including spacers, can have an associated id)
303 void SetId(int id
) { m_id
= id
; }
304 int GetId() const { return m_id
; }
306 bool IsWindow() const { return m_kind
== Item_Window
; }
307 bool IsSizer() const { return m_kind
== Item_Sizer
; }
308 bool IsSpacer() const { return m_kind
== Item_Spacer
; }
310 #if WXWIN_COMPATIBILITY_2_6
311 // Deprecated in 2.6, use {G,S}etProportion instead.
312 wxDEPRECATED( void SetOption( int option
) );
313 wxDEPRECATED( int GetOption() const );
314 #endif // WXWIN_COMPATIBILITY_2_6
316 void SetProportion( int proportion
)
317 { m_proportion
= proportion
; }
318 int GetProportion() const
319 { return m_proportion
; }
320 void SetFlag( int flag
)
324 void SetBorder( int border
)
325 { m_border
= border
; }
326 int GetBorder() const
329 wxWindow
*GetWindow() const
330 { return m_kind
== Item_Window
? m_window
: NULL
; }
331 wxSizer
*GetSizer() const
332 { return m_kind
== Item_Sizer
? m_sizer
: NULL
; }
333 wxSize
GetSpacer() const;
335 // this function behaves obviously for the windows and spacers but for the
336 // sizers it returns true if any sizer element is shown and only returns
337 // false if all of them are hidden
338 bool IsShown() const;
339 void Show(bool show
);
341 void SetUserData(wxObject
* userData
)
342 { delete m_userData
; m_userData
= userData
; }
343 wxObject
* GetUserData() const
344 { return m_userData
; }
345 wxPoint
GetPosition() const
348 // these functions delete the current contents of the item if it's a sizer
349 // or a spacer but not if it is a window
350 void AssignWindow(wxWindow
*window
)
356 void AssignSizer(wxSizer
*sizer
)
362 void AssignSpacer(const wxSize
& size
)
368 void AssignSpacer(int w
, int h
) { AssignSpacer(wxSize(w
, h
)); }
370 #if WXWIN_COMPATIBILITY_2_8
371 // these functions do not free the old sizer/spacer and so can easily
372 // provoke the memory leaks and so shouldn't be used, use Assign() instead
373 wxDEPRECATED( void SetWindow(wxWindow
*window
) );
374 wxDEPRECATED( void SetSizer(wxSizer
*sizer
) );
375 wxDEPRECATED( void SetSpacer(const wxSize
& size
) );
376 wxDEPRECATED( void SetSpacer(int width
, int height
) );
377 #endif // WXWIN_COMPATIBILITY_2_8
380 // common part of several ctors
381 void Init() { m_userData
= NULL
; m_kind
= Item_None
; }
383 // common part of ctors taking wxSizerFlags
384 void Init(const wxSizerFlags
& flags
);
386 // free current contents
389 // common parts of Set/AssignXXX()
390 void DoSetWindow(wxWindow
*window
);
391 void DoSetSizer(wxSizer
*sizer
);
392 void DoSetSpacer(const wxSize
& size
);
394 // discriminated union: depending on m_kind one of the fields is valid
407 wxSizerSpacer
*m_spacer
;
417 // on screen rectangle of this item (not including borders)
420 // Aspect ratio can always be calculated from m_size,
421 // but this would cause precision loss when the window
422 // is shrunk. It is safer to preserve the initial value.
425 wxObject
*m_userData
;
428 DECLARE_CLASS(wxSizerItem
)
429 DECLARE_NO_COPY_CLASS(wxSizerItem
)
432 WX_DECLARE_EXPORTED_LIST( wxSizerItem
, wxSizerItemList
);
435 //---------------------------------------------------------------------------
437 //---------------------------------------------------------------------------
439 class WXDLLEXPORT wxSizer
: public wxObject
, public wxClientDataContainer
442 wxSizer() { m_containingWindow
= NULL
; }
445 // methods for adding elements to the sizer: there are Add/Insert/Prepend
446 // overloads for each of window/sizer/spacer/wxSizerItem
447 wxSizerItem
* Add(wxWindow
*window
,
451 wxObject
* userData
= NULL
);
452 wxSizerItem
* Add(wxSizer
*sizer
,
456 wxObject
* userData
= NULL
);
457 wxSizerItem
* Add(int width
,
462 wxObject
* userData
= NULL
);
463 wxSizerItem
* Add( wxWindow
*window
, const wxSizerFlags
& flags
);
464 wxSizerItem
* Add( wxSizer
*sizer
, const wxSizerFlags
& flags
);
465 wxSizerItem
* Add( int width
, int height
, const wxSizerFlags
& flags
);
466 wxSizerItem
* Add( wxSizerItem
*item
);
468 wxSizerItem
* AddSpacer(int size
);
469 wxSizerItem
* AddStretchSpacer(int prop
= 1);
471 wxSizerItem
* Insert(size_t index
,
476 wxObject
* userData
= NULL
);
477 wxSizerItem
* Insert(size_t index
,
482 wxObject
* userData
= NULL
);
483 wxSizerItem
* Insert(size_t index
,
489 wxObject
* userData
= NULL
);
490 wxSizerItem
* Insert(size_t index
,
492 const wxSizerFlags
& flags
);
493 wxSizerItem
* Insert(size_t index
,
495 const wxSizerFlags
& flags
);
496 wxSizerItem
* Insert(size_t index
,
499 const wxSizerFlags
& flags
);
500 virtual wxSizerItem
* Insert( size_t index
, wxSizerItem
*item
);
502 wxSizerItem
* InsertSpacer(size_t index
, int size
);
503 wxSizerItem
* InsertStretchSpacer(size_t index
, int prop
= 1);
505 wxSizerItem
* Prepend(wxWindow
*window
,
509 wxObject
* userData
= NULL
);
510 wxSizerItem
* Prepend(wxSizer
*sizer
,
514 wxObject
* userData
= NULL
);
515 wxSizerItem
* Prepend(int width
,
520 wxObject
* userData
= NULL
);
521 wxSizerItem
* Prepend(wxWindow
*window
, const wxSizerFlags
& flags
);
522 wxSizerItem
* Prepend(wxSizer
*sizer
, const wxSizerFlags
& flags
);
523 wxSizerItem
* Prepend(int width
, int height
, const wxSizerFlags
& flags
);
524 wxSizerItem
* Prepend(wxSizerItem
*item
);
526 wxSizerItem
* PrependSpacer(int size
);
527 wxSizerItem
* PrependStretchSpacer(int prop
= 1);
529 // set (or possibly unset if window is NULL) or get the window this sizer
531 void SetContainingWindow(wxWindow
*window
);
532 wxWindow
*GetContainingWindow() const { return m_containingWindow
; }
534 #if WXWIN_COMPATIBILITY_2_6
535 // Deprecated in 2.6 since historically it does not delete the window,
536 // use Detach instead.
537 wxDEPRECATED( virtual bool Remove( wxWindow
*window
) );
538 #endif // WXWIN_COMPATIBILITY_2_6
540 virtual bool Remove( wxSizer
*sizer
);
541 virtual bool Remove( int index
);
543 virtual bool Detach( wxWindow
*window
);
544 virtual bool Detach( wxSizer
*sizer
);
545 virtual bool Detach( int index
);
547 virtual bool Replace( wxWindow
*oldwin
, wxWindow
*newwin
, bool recursive
= false );
548 virtual bool Replace( wxSizer
*oldsz
, wxSizer
*newsz
, bool recursive
= false );
549 virtual bool Replace( size_t index
, wxSizerItem
*newitem
);
551 virtual void Clear( bool delete_windows
= false );
552 virtual void DeleteWindows();
554 void SetMinSize( int width
, int height
)
555 { DoSetMinSize( width
, height
); }
556 void SetMinSize( const wxSize
& size
)
557 { DoSetMinSize( size
.x
, size
.y
); }
559 // Searches recursively
560 bool SetItemMinSize( wxWindow
*window
, int width
, int height
)
561 { return DoSetItemMinSize( window
, width
, height
); }
562 bool SetItemMinSize( wxWindow
*window
, const wxSize
& size
)
563 { return DoSetItemMinSize( window
, size
.x
, size
.y
); }
565 // Searches recursively
566 bool SetItemMinSize( wxSizer
*sizer
, int width
, int height
)
567 { return DoSetItemMinSize( sizer
, width
, height
); }
568 bool SetItemMinSize( wxSizer
*sizer
, const wxSize
& size
)
569 { return DoSetItemMinSize( sizer
, size
.x
, size
.y
); }
571 bool SetItemMinSize( size_t index
, int width
, int height
)
572 { return DoSetItemMinSize( index
, width
, height
); }
573 bool SetItemMinSize( size_t index
, const wxSize
& size
)
574 { return DoSetItemMinSize( index
, size
.x
, size
.y
); }
576 wxSize
GetSize() const
578 wxPoint
GetPosition() const
579 { return m_position
; }
581 // Calculate the minimal size or return m_minSize if bigger.
584 // These virtual functions are used by the layout algorithm: first
585 // CalcMin() is called to calculate the minimal size of the sizer and
586 // prepare for laying it out and then RecalcSizes() is called to really
587 // update all the sizer items
588 virtual wxSize
CalcMin() = 0;
589 virtual void RecalcSizes() = 0;
591 virtual void Layout();
593 wxSize
Fit( wxWindow
*window
);
594 void FitInside( wxWindow
*window
);
595 void SetSizeHints( wxWindow
*window
);
596 void SetVirtualSizeHints( wxWindow
*window
);
598 wxSizerItemList
& GetChildren()
599 { return m_children
; }
600 const wxSizerItemList
& GetChildren() const
601 { return m_children
; }
603 void SetDimension( int x
, int y
, int width
, int height
);
605 wxSizerItem
* GetItem( wxWindow
*window
, bool recursive
= false );
606 wxSizerItem
* GetItem( wxSizer
*sizer
, bool recursive
= false );
607 wxSizerItem
* GetItem( size_t index
);
608 wxSizerItem
* GetItemById( int id
, bool recursive
= false );
610 // Manage whether individual scene items are considered
611 // in the layout calculations or not.
612 bool Show( wxWindow
*window
, bool show
= true, bool recursive
= false );
613 bool Show( wxSizer
*sizer
, bool show
= true, bool recursive
= false );
614 bool Show( size_t index
, bool show
= true );
616 bool Hide( wxSizer
*sizer
, bool recursive
= false )
617 { return Show( sizer
, false, recursive
); }
618 bool Hide( wxWindow
*window
, bool recursive
= false )
619 { return Show( window
, false, recursive
); }
620 bool Hide( size_t index
)
621 { return Show( index
, false ); }
623 bool IsShown( wxWindow
*window
) const;
624 bool IsShown( wxSizer
*sizer
) const;
625 bool IsShown( size_t index
) const;
627 // Recursively call wxWindow::Show () on all sizer items.
628 virtual void ShowItems (bool show
);
630 void Show(bool show
) { ShowItems(show
); }
636 wxSizerItemList m_children
;
638 // the window this sizer is used in, can be NULL
639 wxWindow
*m_containingWindow
;
641 wxSize
GetMaxWindowSize( wxWindow
*window
) const;
642 wxSize
GetMinWindowSize( wxWindow
*window
);
643 wxSize
GetMaxClientSize( wxWindow
*window
) const;
644 wxSize
GetMinClientSize( wxWindow
*window
);
645 wxSize
VirtualFitSize( wxWindow
*window
);
647 virtual void DoSetMinSize( int width
, int height
);
648 virtual bool DoSetItemMinSize( wxWindow
*window
, int width
, int height
);
649 virtual bool DoSetItemMinSize( wxSizer
*sizer
, int width
, int height
);
650 virtual bool DoSetItemMinSize( size_t index
, int width
, int height
);
653 DECLARE_CLASS(wxSizer
)
656 //---------------------------------------------------------------------------
658 //---------------------------------------------------------------------------
660 class WXDLLEXPORT wxGridSizer
: public wxSizer
663 wxGridSizer( int rows
, int cols
, int vgap
, int hgap
);
664 wxGridSizer( int cols
, int vgap
= 0, int hgap
= 0 );
666 virtual void RecalcSizes();
667 virtual wxSize
CalcMin();
669 void SetCols( int cols
) { m_cols
= cols
; }
670 void SetRows( int rows
) { m_rows
= rows
; }
671 void SetVGap( int gap
) { m_vgap
= gap
; }
672 void SetHGap( int gap
) { m_hgap
= gap
; }
673 int GetCols() const { return m_cols
; }
674 int GetRows() const { return m_rows
; }
675 int GetVGap() const { return m_vgap
; }
676 int GetHGap() const { return m_hgap
; }
684 // return the number of total items and the number of columns and rows
685 int CalcRowsCols(int& rows
, int& cols
) const;
687 void SetItemBounds( wxSizerItem
*item
, int x
, int y
, int w
, int h
);
690 DECLARE_CLASS(wxGridSizer
)
693 //---------------------------------------------------------------------------
695 //---------------------------------------------------------------------------
697 // the bevaiour for resizing wxFlexGridSizer cells in the "non-flexible"
699 enum wxFlexSizerGrowMode
701 // don't resize the cells in non-flexible direction at all
702 wxFLEX_GROWMODE_NONE
,
704 // uniformly resize only the specified ones (default)
705 wxFLEX_GROWMODE_SPECIFIED
,
707 // uniformly resize all cells
711 class WXDLLEXPORT wxFlexGridSizer
: public wxGridSizer
715 wxFlexGridSizer( int rows
, int cols
, int vgap
, int hgap
);
716 wxFlexGridSizer( int cols
, int vgap
= 0, int hgap
= 0 );
717 virtual ~wxFlexGridSizer();
720 // set the rows/columns which will grow (the others will remain of the
721 // constant initial size)
722 void AddGrowableRow( size_t idx
, int proportion
= 0 );
723 void RemoveGrowableRow( size_t idx
);
724 void AddGrowableCol( size_t idx
, int proportion
= 0 );
725 void RemoveGrowableCol( size_t idx
);
728 // the sizer cells may grow in both directions, not grow at all or only
729 // grow in one direction but not the other
731 // the direction may be wxVERTICAL, wxHORIZONTAL or wxBOTH (default)
732 void SetFlexibleDirection(int direction
) { m_flexDirection
= direction
; }
733 int GetFlexibleDirection() const { return m_flexDirection
; }
735 // note that the grow mode only applies to the direction which is not
737 void SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode
) { m_growMode
= mode
; }
738 wxFlexSizerGrowMode
GetNonFlexibleGrowMode() const { return m_growMode
; }
740 // Read-only access to the row heights and col widths arrays
741 const wxArrayInt
& GetRowHeights() const { return m_rowHeights
; }
742 const wxArrayInt
& GetColWidths() const { return m_colWidths
; }
745 virtual void RecalcSizes();
746 virtual wxSize
CalcMin();
749 void AdjustForFlexDirection();
750 void AdjustForGrowables(const wxSize
& sz
);
752 // the heights/widths of all rows/columns
753 wxArrayInt m_rowHeights
,
756 // indices of the growable columns and rows
757 wxArrayInt m_growableRows
,
760 // proportion values of the corresponding growable rows and columns
761 wxArrayInt m_growableRowsProportions
,
762 m_growableColsProportions
;
764 // parameters describing whether the growable cells should be resized in
765 // both directions or only one
767 wxFlexSizerGrowMode m_growMode
;
769 // saves CalcMin result to optimize RecalcSizes
770 wxSize m_calculatedMinSize
;
773 DECLARE_CLASS(wxFlexGridSizer
)
774 DECLARE_NO_COPY_CLASS(wxFlexGridSizer
)
777 //---------------------------------------------------------------------------
779 //---------------------------------------------------------------------------
781 class WXDLLEXPORT wxBoxSizer
: public wxSizer
784 wxBoxSizer(int orient
)
788 wxASSERT_MSG( m_orient
== wxHORIZONTAL
|| m_orient
== wxVERTICAL
,
789 _T("invalid value for wxBoxSizer orientation") );
792 int GetOrientation() const { return m_orient
; }
794 bool IsVertical() const { return m_orient
== wxVERTICAL
; }
796 void SetOrientation(int orient
) { m_orient
= orient
; }
798 // implementation of our resizing logic
799 virtual wxSize
CalcMin();
800 virtual void RecalcSizes();
803 // helpers for our code: this returns the component of the given wxSize in
804 // the direction of the sizer and in the other direction, respectively
805 int SizeInMajorDir(const wxSize
& sz
) const
807 return m_orient
== wxHORIZONTAL
? sz
.x
: sz
.y
;
810 int& SizeInMajorDir(wxSize
& sz
)
812 return m_orient
== wxHORIZONTAL
? sz
.x
: sz
.y
;
815 int& PosInMajorDir(wxPoint
& pt
)
817 return m_orient
== wxHORIZONTAL
? pt
.x
: pt
.y
;
820 int SizeInMinorDir(const wxSize
& sz
) const
822 return m_orient
== wxHORIZONTAL
? sz
.y
: sz
.x
;
825 int& SizeInMinorDir(wxSize
& sz
)
827 return m_orient
== wxHORIZONTAL
? sz
.y
: sz
.x
;
830 int& PosInMinorDir(wxPoint
& pt
)
832 return m_orient
== wxHORIZONTAL
? pt
.y
: pt
.x
;
835 // another helper: creates wxSize from major and minor components
836 wxSize
SizeFromMajorMinor(int major
, int minor
) const
838 if ( m_orient
== wxHORIZONTAL
)
840 return wxSize(major
, minor
);
844 return wxSize(minor
, major
);
849 // either wxHORIZONTAL or wxVERTICAL
852 // the sum of proportion of all of our elements
853 int m_totalProportion
;
855 // the minimal size needed for this sizer as calculated by the last call to
860 DECLARE_CLASS(wxBoxSizer
)
863 //---------------------------------------------------------------------------
865 //---------------------------------------------------------------------------
869 class WXDLLIMPEXP_FWD_CORE wxStaticBox
;
871 class WXDLLEXPORT wxStaticBoxSizer
: public wxBoxSizer
874 wxStaticBoxSizer(wxStaticBox
*box
, int orient
);
875 wxStaticBoxSizer(int orient
, wxWindow
*win
, const wxString
& label
= wxEmptyString
);
876 virtual ~wxStaticBoxSizer();
881 wxStaticBox
*GetStaticBox() const
882 { return m_staticBox
; }
884 // override to hide/show the static box as well
885 virtual void ShowItems (bool show
);
887 virtual bool Detach( wxWindow
*window
);
888 virtual bool Detach( wxSizer
*sizer
) { return wxBoxSizer::Detach(sizer
); }
889 virtual bool Detach( int index
) { return wxBoxSizer::Detach(index
); }
892 wxStaticBox
*m_staticBox
;
895 DECLARE_CLASS(wxStaticBoxSizer
)
896 DECLARE_NO_COPY_CLASS(wxStaticBoxSizer
)
899 #endif // wxUSE_STATBOX
903 class WXDLLEXPORT wxStdDialogButtonSizer
: public wxBoxSizer
906 // Constructor just creates a new wxBoxSizer, not much else.
907 // Box sizer orientation is automatically determined here:
908 // vertical for PDAs, horizontal for everything else?
909 wxStdDialogButtonSizer();
911 // Checks button ID against system IDs and sets one of the pointers below
912 // to this button. Does not do any sizer-related things here.
913 void AddButton(wxButton
*button
);
915 // Use these if no standard ID can/should be used
916 void SetAffirmativeButton( wxButton
*button
);
917 void SetNegativeButton( wxButton
*button
);
918 void SetCancelButton( wxButton
*button
);
920 // All platform-specific code here, checks which buttons exist and add
921 // them to the sizer accordingly.
922 // Note - one potential hack on Mac we could use here,
923 // if m_buttonAffirmative is wxID_SAVE then ensure wxID_SAVE
924 // is set to _("Save") and m_buttonNegative is set to _("Don't Save")
925 // I wouldn't add any other hacks like that into here,
926 // but this one I can see being useful.
929 wxButton
*GetAffirmativeButton() const { return m_buttonAffirmative
; }
930 wxButton
*GetApplyButton() const { return m_buttonApply
; }
931 wxButton
*GetNegativeButton() const { return m_buttonNegative
; }
932 wxButton
*GetCancelButton() const { return m_buttonCancel
; }
933 wxButton
*GetHelpButton() const { return m_buttonHelp
; }
936 wxButton
*m_buttonAffirmative
; // wxID_OK, wxID_YES, wxID_SAVE go here
937 wxButton
*m_buttonApply
; // wxID_APPLY
938 wxButton
*m_buttonNegative
; // wxID_NO
939 wxButton
*m_buttonCancel
; // wxID_CANCEL, wxID_CLOSE
940 wxButton
*m_buttonHelp
; // wxID_HELP, wxID_CONTEXT_HELP
943 DECLARE_CLASS(wxStdDialogButtonSizer
)
944 DECLARE_NO_COPY_CLASS(wxStdDialogButtonSizer
)
947 #endif // wxUSE_BUTTON
950 // ----------------------------------------------------------------------------
951 // inline functions implementation
952 // ----------------------------------------------------------------------------
954 #if WXWIN_COMPATIBILITY_2_8
956 inline void wxSizerItem::SetWindow(wxWindow
*window
)
961 inline void wxSizerItem::SetSizer(wxSizer
*sizer
)
966 inline void wxSizerItem::SetSpacer(const wxSize
& size
)
971 inline void wxSizerItem::SetSpacer(int width
, int height
)
973 DoSetSpacer(wxSize(width
, height
));
976 #endif // WXWIN_COMPATIBILITY_2_8
980 wxSizer::Add( wxSizerItem
*item
)
982 return Insert( m_children
.GetCount(), item
);
986 wxSizer::Add( wxWindow
*window
, int proportion
, int flag
, int border
, wxObject
* userData
)
988 return Add( new wxSizerItem( window
, proportion
, flag
, border
, userData
) );
992 wxSizer::Add( wxSizer
*sizer
, int proportion
, int flag
, int border
, wxObject
* userData
)
994 return Add( new wxSizerItem( sizer
, proportion
, flag
, border
, userData
) );
998 wxSizer::Add( int width
, int height
, int proportion
, int flag
, int border
, wxObject
* userData
)
1000 return Add( new wxSizerItem( width
, height
, proportion
, flag
, border
, userData
) );
1004 wxSizer::Add( wxWindow
*window
, const wxSizerFlags
& flags
)
1006 return Add( new wxSizerItem(window
, flags
) );
1010 wxSizer::Add( wxSizer
*sizer
, const wxSizerFlags
& flags
)
1012 return Add( new wxSizerItem(sizer
, flags
) );
1016 wxSizer::Add( int width
, int height
, const wxSizerFlags
& flags
)
1018 return Add( new wxSizerItem(width
, height
, flags
) );
1022 wxSizer::AddSpacer(int size
)
1024 return Add(size
, size
);
1028 wxSizer::AddStretchSpacer(int prop
)
1030 return Add(0, 0, prop
);
1034 wxSizer::Prepend( wxSizerItem
*item
)
1036 return Insert( 0, item
);
1040 wxSizer::Prepend( wxWindow
*window
, int proportion
, int flag
, int border
, wxObject
* userData
)
1042 return Prepend( new wxSizerItem( window
, proportion
, flag
, border
, userData
) );
1046 wxSizer::Prepend( wxSizer
*sizer
, int proportion
, int flag
, int border
, wxObject
* userData
)
1048 return Prepend( new wxSizerItem( sizer
, proportion
, flag
, border
, userData
) );
1052 wxSizer::Prepend( int width
, int height
, int proportion
, int flag
, int border
, wxObject
* userData
)
1054 return Prepend( new wxSizerItem( width
, height
, proportion
, flag
, border
, userData
) );
1058 wxSizer::PrependSpacer(int size
)
1060 return Prepend(size
, size
);
1064 wxSizer::PrependStretchSpacer(int prop
)
1066 return Prepend(0, 0, prop
);
1070 wxSizer::Prepend( wxWindow
*window
, const wxSizerFlags
& flags
)
1072 return Prepend( new wxSizerItem(window
, flags
) );
1076 wxSizer::Prepend( wxSizer
*sizer
, const wxSizerFlags
& flags
)
1078 return Prepend( new wxSizerItem(sizer
, flags
) );
1082 wxSizer::Prepend( int width
, int height
, const wxSizerFlags
& flags
)
1084 return Prepend( new wxSizerItem(width
, height
, flags
) );
1088 wxSizer::Insert( size_t index
,
1093 wxObject
* userData
)
1095 return Insert( index
, new wxSizerItem( window
, proportion
, flag
, border
, userData
) );
1099 wxSizer::Insert( size_t index
,
1104 wxObject
* userData
)
1106 return Insert( index
, new wxSizerItem( sizer
, proportion
, flag
, border
, userData
) );
1110 wxSizer::Insert( size_t index
,
1116 wxObject
* userData
)
1118 return Insert( index
, new wxSizerItem( width
, height
, proportion
, flag
, border
, userData
) );
1122 wxSizer::Insert( size_t index
, wxWindow
*window
, const wxSizerFlags
& flags
)
1124 return Insert( index
, new wxSizerItem(window
, flags
) );
1128 wxSizer::Insert( size_t index
, wxSizer
*sizer
, const wxSizerFlags
& flags
)
1130 return Insert( index
, new wxSizerItem(sizer
, flags
) );
1134 wxSizer::Insert( size_t index
, int width
, int height
, const wxSizerFlags
& flags
)
1136 return Insert( index
, new wxSizerItem(width
, height
, flags
) );
1140 wxSizer::InsertSpacer(size_t index
, int size
)
1142 return Insert(index
, size
, size
);
1146 wxSizer::InsertStretchSpacer(size_t index
, int prop
)
1148 return Insert(index
, 0, 0, prop
);
1151 #endif // __WXSIZER_H__