]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/sizer.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxStdDialogButtonSizer
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
11 A generic orientation value.
15 /* don't change the values of these elements, they are used elsewhere */
16 wxHORIZONTAL
= 0x0004,
19 wxBOTH
= wxVERTICAL
| wxHORIZONTAL
,
21 /* a mask to extract orientation from the combination of flags */
22 wxORIENTATION_MASK
= wxBOTH
27 @class wxStdDialogButtonSizer
29 This class creates button layouts which conform to the standard button spacing
30 and ordering defined by the platform or toolkit's user interface guidelines
31 (if such things exist). By using this class, you can ensure that all your
32 standard dialogs look correct on all major platforms. Currently it conforms to
33 the Windows, GTK+ and Mac OS X human interface guidelines.
35 When there aren't interface guidelines defined for a particular platform or
36 toolkit, wxStdDialogButtonSizer reverts to the Windows implementation.
38 To use this class, first add buttons to the sizer by calling
39 wxStdDialogButtonSizer::AddButton (or wxStdDialogButtonSizer::SetAffirmativeButton,
40 wxStdDialogButtonSizer::SetNegativeButton or wxStdDialogButtonSizer::SetCancelButton)
41 and then call Realize in order to create the actual button layout used.
42 Other than these special operations, this sizer works like any other sizer.
44 If you add a button with wxID_SAVE, on Mac OS X the button will be renamed to
45 "Save" and the wxID_NO button will be renamed to "Don't Save" in accordance
46 with the Mac OS X Human Interface Guidelines.
51 @see wxSizer, @ref overview_sizer, wxDialog::CreateButtonSizer
53 class wxStdDialogButtonSizer
: public wxBoxSizer
57 Constructor for a wxStdDialogButtonSizer.
59 wxStdDialogButtonSizer();
62 Adds a button to the wxStdDialogButtonSizer. The @a button must have
63 one of the following identifiers:
74 void AddButton(wxButton
* button
);
77 Rearranges the buttons and applies proper spacing between buttons to make
78 them match the platform or toolkit's interface guidelines.
83 Sets the affirmative button for the sizer.
85 This allows you to use identifiers other than the standard identifiers
88 void SetAffirmativeButton(wxButton
* button
);
91 Sets the cancel button for the sizer.
93 This allows you to use identifiers other than the standard identifiers
96 void SetCancelButton(wxButton
* button
);
99 Sets the negative button for the sizer.
101 This allows you to use identifiers other than the standard identifiers
104 void SetNegativeButton(wxButton
* button
);
112 The wxSizerItem class is used to track the position, size and other
113 attributes of each item managed by a wxSizer.
115 It is not usually necessary to use this class because the sizer elements can
116 also be identified by their positions or window or sizer pointers but sometimes
117 it may be more convenient to use it directly.
122 class wxSizerItem
: public wxObject
126 Construct a sizer item for tracking a spacer.
128 wxSizerItem(int width
, int height
, int proportion
, int flag
,
129 int border
, wxObject
* userData
);
133 Construct a sizer item for tracking a window.
135 wxSizerItem(wxWindow
* window
, const wxSizerFlags
& flags
);
136 wxSizerItem(wxWindow
* window
, int proportion
, int flag
,
143 Construct a sizer item for tracking a subsizer.
145 wxSizerItem(wxSizer
* window
, const wxSizerFlags
& flags
);
146 wxSizerItem(wxSizer
* sizer
, int proportion
, int flag
,
152 Deletes the user data and subsizer, if any.
154 virtual ~wxSizerItem();
157 Calculates the minimum desired size for the item, including any space
160 virtual wxSize
CalcMin();
163 Destroy the window or the windows in a subsizer, depending on the type
166 virtual void DeleteWindows();
169 Enable deleting the SizerItem without destroying the contained sizer.
174 Return the border attribute.
176 int GetBorder() const;
179 Return the flags attribute.
181 See @ref wxsizer_flags "wxSizer flags list" for details.
186 Return the numeric id of wxSizerItem, or @c wxID_NONE if the id has
192 Get the minimum size needed for the item.
194 wxSize
GetMinSize() const;
197 Sets the minimum size to be allocated for this item.
199 If this item is a window, the @a size is also passed to
200 wxWindow::SetMinSize().
202 void SetMinSize(const wxSize
& size
);
207 void SetMinSize(int x
, int y
);
210 What is the current position of the item, as set in the last Layout.
212 wxPoint
GetPosition() const;
215 Get the proportion item attribute.
217 int GetProportion() const;
220 Get the ration item attribute.
222 float GetRatio() const;
225 Get the rectangle of the item on the parent window, excluding borders.
227 virtual wxRect
GetRect();
230 Get the current size of the item, as set in the last Layout.
232 virtual wxSize
GetSize() const;
235 If this item is tracking a sizer, return it. @NULL otherwise.
237 wxSizer
* GetSizer() const;
240 If this item is tracking a spacer, return its size.
242 wxSize
GetSpacer() const;
245 Get the userData item attribute.
247 wxObject
* GetUserData() const;
250 If this item is tracking a window then return it. @NULL otherwise.
252 wxWindow
* GetWindow() const;
255 Returns @true if this item is a window or a spacer and it is shown or
256 if this item is a sizer and not all of its elements are hidden.
258 In other words, for sizer items, all of the child elements must be
259 hidden for the sizer itself to be considered hidden.
261 As an exception, if the @c wxRESERVE_SPACE_EVEN_IF_HIDDEN flag was
262 used for this sizer item, then IsShown() always returns @true for it
263 (see wxSizerFlags::ReserveSpaceEvenIfHidden()).
265 bool IsShown() const;
268 Is this item a sizer?
270 bool IsSizer() const;
273 Is this item a spacer?
275 bool IsSpacer() const;
278 Is this item a window?
280 bool IsWindow() const;
283 Set the border item attribute.
285 void SetBorder(int border
);
288 Set the position and size of the space allocated to the sizer, and
289 adjust the position and size of the item to be within that space
290 taking alignment and borders into account.
292 virtual void SetDimension(const wxPoint
& pos
, const wxSize
& size
);
295 Set the flag item attribute.
297 void SetFlag(int flag
);
300 Sets the numeric id of the wxSizerItem to @e id.
307 void SetInitSize(int x
, int y
);
310 Set the proportion item attribute.
312 void SetProportion(int proportion
);
316 Set the ratio item attribute.
318 void SetRatio(int width
, int height
);
319 void SetRatio(wxSize size
);
320 void SetRatio(float ratio
);
324 Set the sizer tracked by this item.
325 @deprecated @todo provide deprecation description
327 void SetSizer(wxSizer
* sizer
);
330 Set the size of the spacer tracked by this item.
331 @deprecated @todo provide deprecation description
333 void SetSpacer(const wxSize
& size
);
336 Set the window to be tracked by this item.
337 @deprecated @todo provide deprecation description
339 void SetWindow(wxWindow
* window
);
342 Set the show item attribute, which sizers use to determine if the item
343 is to be made part of the layout or not. If the item is tracking a
344 window then it is shown or hidden as needed.
346 void Show(bool show
);
354 Container for sizer items flags providing readable names for them.
356 Normally, when you add an item to a sizer via wxSizer::Add, you have to
357 specify a lot of flags and parameters which can be unwieldy. This is where
358 wxSizerFlags comes in: it allows you to specify all parameters using the
359 named methods instead. For example, instead of
362 sizer->Add(ctrl, 0, wxEXPAND | wxALL, 10);
368 sizer->Add(ctrl, wxSizerFlags().Expand().Border(wxALL, 10));
371 This is more readable and also allows you to create wxSizerFlags objects which
372 can be reused for several sizer items.
375 wxSizerFlags flagsExpand(1);
376 flagsExpand.Expand().Border(wxALL, 10);
378 sizer->Add(ctrl1, flagsExpand);
379 sizer->Add(ctrl2, flagsExpand);
382 Note that by specification, all methods of wxSizerFlags return the wxSizerFlags
383 object itself to allowing chaining multiple methods calls like in the examples
395 Creates the wxSizer with the proportion specified by @a proportion.
397 wxSizerFlags(int proportion
= 0);
400 Sets the alignment of this wxSizerFlags to @a align.
402 This method replaces the previously set alignment with the specified one.
405 Combination of @c wxALIGN_XXX bit masks.
407 @see Top(), Left(), Right(), Bottom(), Centre()
409 wxSizerFlags
& Align(int alignment
);
412 Sets the wxSizerFlags to have a border of a number of pixels specified
413 by @a borderinpixels with the directions specified by @a direction.
415 wxSizerFlags
& Border(int direction
, int borderinpixels
);
418 Sets the wxSizerFlags to have a border with size as returned by
422 Direction(s) to apply the border in.
424 wxSizerFlags
& Border(int direction
= wxALL
);
427 Aligns the object to the bottom, similar for @c Align(wxALIGN_BOTTOM).
429 Unlike Align(), this method doesn't change the horizontal alignment of
432 wxSizerFlags
& Bottom();
435 Sets the object of the wxSizerFlags to center itself in the area it is
438 wxSizerFlags
& Center();
441 Center() for people with the other dialect of English.
443 wxSizerFlags
& Centre();
446 Sets the border in the given @a direction having twice the default
449 wxSizerFlags
& DoubleBorder(int direction
= wxALL
);
452 Sets the border in left and right directions having twice the default
455 wxSizerFlags
& DoubleHorzBorder();
458 Sets the object of the wxSizerFlags to expand to fill as much area as
461 wxSizerFlags
& Expand();
464 Set the @c wxFIXED_MINSIZE flag which indicates that the initial size
465 of the window should be also set as its minimal size.
467 wxSizerFlags
& FixedMinSize();
470 Set the @c wxRESERVE_SPACE_EVEN_IF_HIDDEN flag. Normally wxSizers
471 don't allocate space for hidden windows or other items. This flag
472 overrides this behavior so that sufficient space is allocated for the
473 window even if it isn't visible. This makes it possible to dynamically
474 show and hide controls without resizing parent dialog, for example.
478 wxSizerFlags
& ReserveSpaceEvenIfHidden();
481 Returns the border used by default in Border() method.
483 static int GetDefaultBorder();
486 Aligns the object to the left, similar for @c Align(wxALIGN_LEFT).
488 Unlike Align(), this method doesn't change the vertical alignment of
491 wxSizerFlags
& Left();
494 Sets the proportion of this wxSizerFlags to @e proportion
496 wxSizerFlags
& Proportion(int proportion
);
499 Aligns the object to the right, similar for @c Align(wxALIGN_RIGHT).
501 Unlike Align(), this method doesn't change the vertical alignment of
504 wxSizerFlags
& Right();
507 Set the @c wx_SHAPED flag which indicates that the elements should
508 always keep the fixed width to height ratio equal to its original value.
510 wxSizerFlags
& Shaped();
513 Aligns the object to the top, similar for @c Align(wxALIGN_TOP).
515 Unlike Align(), this method doesn't change the horizontal alignment of
521 Sets the border in the given @a direction having thrice the default
524 wxSizerFlags
& TripleBorder(int direction
= wxALL
);
530 @class wxFlexGridSizer
532 A flex grid sizer is a sizer which lays out its children in a two-dimensional
533 table with all table fields in one row having the same height and all fields
534 in one column having the same width, but all rows or all columns are not
535 necessarily the same height or width as in the wxGridSizer.
537 Since wxWidgets 2.5.0, wxFlexGridSizer can also size items equally in one
538 direction but unequally ("flexibly") in the other. If the sizer is only
539 flexible in one direction (this can be changed using wxFlexGridSizer::SetFlexibleDirection),
540 it needs to be decided how the sizer should grow in the other ("non-flexible")
541 direction in order to fill the available space.
542 The wxFlexGridSizer::SetNonFlexibleGrowMode() method serves this purpose.
547 @see wxSizer, @ref overview_sizer
549 class wxFlexGridSizer
: public wxGridSizer
554 Constructor for a wxFlexGridSizer.
556 @a rows and @a cols determine the number of columns and rows in the sizer -
557 if either of the parameters is zero, it will be calculated to form the
558 total number of children in the sizer, thus making the sizer grow
561 @a vgap and @a hgap define extra space between all children.
563 wxFlexGridSizer(int rows
, int cols
, int vgap
, int hgap
);
564 wxFlexGridSizer(int cols
, int vgap
= 0, int hgap
= 0);
568 Specifies that column @a idx (starting from zero) should be grown if
569 there is extra space available to the sizer.
571 The @a proportion parameter has the same meaning as the stretch factor
572 for the sizers() except that if all proportions are 0, then all columns
573 are resized equally (instead of not being resized at all).
575 Notice that the row must not be already growable, if you need to change
576 the proportion you must call RemoveGrowableCol() first and then make it
577 growable (with a different proportion) again. You can use IsColGrowable()
578 to check whether a column is already growable.
580 void AddGrowableCol(size_t idx
, int proportion
= 0);
583 Specifies that row idx (starting from zero) should be grown if there
584 is extra space available to the sizer.
586 This is identical to AddGrowableCol() except that it works with rows
589 void AddGrowableRow(size_t idx
, int proportion
= 0);
592 Returns a wxOrientation value that specifies whether the sizer flexibly
593 resizes its columns, rows, or both (default).
596 One of the following values:
597 - wxVERTICAL: Rows are flexibly sized.
598 - wxHORIZONTAL: Columns are flexibly sized.
599 - wxBOTH: Both rows and columns are flexibly sized (this is the default value).
601 @see SetFlexibleDirection()
603 int GetFlexibleDirection() const;
606 Returns the value that specifies how the sizer grows in the "non-flexible"
607 direction if there is one.
610 One of the following values:
611 - wxFLEX_GROWMODE_NONE: Sizer doesn't grow in the non-flexible direction.
612 - wxFLEX_GROWMODE_SPECIFIED: Sizer honors growable columns/rows set with
613 AddGrowableCol() and AddGrowableRow(). In this case equal sizing applies
614 to minimum sizes of columns or rows (this is the default value).
615 - wxFLEX_GROWMODE_ALL: Sizer equally stretches all columns or rows in
616 the non-flexible direction, whether they are growable or not in the
619 @see SetFlexibleDirection(), SetNonFlexibleGrowMode()
621 wxFlexSizerGrowMode
GetNonFlexibleGrowMode() const;
624 Returns @true if column @a idx is growable.
628 bool IsColGrowable(size_t idx
);
631 Returns @true if row @a idx is growable.
635 bool IsRowGrowable(size_t idx
);
638 Specifies that column idx is no longer growable.
640 void RemoveGrowableCol(size_t idx
);
643 Specifies that row idx is no longer growable.
645 void RemoveGrowableRow(size_t idx
);
648 Specifies whether the sizer should flexibly resize its columns, rows, or both.
650 Argument @a direction can be @c wxVERTICAL, @c wxHORIZONTAL or @c wxBOTH
651 (which is the default value). Any other value is ignored.
652 See GetFlexibleDirection() for the explanation of these values.
653 Note that this method does not trigger relayout.
655 void SetFlexibleDirection(int direction
);
658 Specifies how the sizer should grow in the non-flexible direction if
659 there is one (so SetFlexibleDirection() must have been called previously).
661 Argument @a mode can be one of those documented in GetNonFlexibleGrowMode(),
662 please see there for their explanation.
663 Note that this method does not trigger relayout.
665 void SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode
);
673 wxSizer is the abstract base class used for laying out subwindows in a window.
674 You cannot use wxSizer directly; instead, you will have to use one of the sizer
675 classes derived from it. Currently there are wxBoxSizer, wxStaticBoxSizer,
676 wxGridSizer, wxFlexGridSizer, wxWrapSizer and wxGridBagSizer.
678 The layout algorithm used by sizers in wxWidgets is closely related to layout
679 in other GUI toolkits, such as Java's AWT, the GTK toolkit or the Qt toolkit.
680 It is based upon the idea of the individual subwindows reporting their minimal
681 required size and their ability to get stretched if the size of the parent window
684 This will most often mean that the programmer does not set the original size of
685 a dialog in the beginning, rather the dialog will be assigned a sizer and this
686 sizer will be queried about the recommended size. The sizer in turn will query
687 its children, which can be normal windows, empty space or other sizers, so that
688 a hierarchy of sizers can be constructed. Note that wxSizer does not derive
689 from wxWindow and thus does not interfere with tab ordering and requires very little
690 resources compared to a real window on screen.
692 What makes sizers so well fitted for use in wxWidgets is the fact that every
693 control reports its own minimal size and the algorithm can handle differences in
694 font sizes or different window (dialog item) sizes on different platforms without
695 problems. If e.g. the standard font as well as the overall design of Motif widgets
696 requires more space than on Windows, the initial dialog size will automatically
697 be bigger on Motif than on Windows.
699 Sizers may also be used to control the layout of custom drawn items on the
700 window. The wxSizer::Add(), wxSizer::Insert(), and wxSizer::Prepend() functions
701 return a pointer to the newly added wxSizerItem.
702 Just add empty space of the desired size and attributes, and then use the
703 wxSizerItem::GetRect() method to determine where the drawing operations
706 Please notice that sizers, like child windows, are owned by the library and
707 will be deleted by it which implies that they must be allocated on the heap.
708 However if you create a sizer and do not add it to another sizer or
709 window, the library wouldn't be able to delete such an orphan sizer and in
710 this, and only this, case it should be deleted explicitly.
713 If you wish to create a sizer class in wxPython you should
714 derive the class from @c wxPySizer in order to get Python-aware
715 capabilities for the various virtual methods.
718 @anchor wxsizer_flags
721 The "flag" argument accepted by wxSizeItem constructors and other
722 functions, e.g. wxSizer::Add(), is OR-combination of the following flags.
723 Two main behaviours are defined using these flags. One is the border around
724 a window: the border parameter determines the border width whereas the
725 flags given here determine which side(s) of the item that the border will
726 be added. The other flags determine how the sizer item behaves when the
727 space allotted to the sizer changes, and is somewhat dependent on the
728 specific kind of sizer used.
736 These flags are used to specify which side(s) of the sizer item
737 the border width will apply to.}
739 The item will be expanded to fill the space assigned to the item.}
741 The item will be expanded as much as possible while also
742 maintaining its aspect ratio.}
743 @itemdef{wxFIXED_MINSIZE,
744 Normally wxSizers will use GetAdjustedBestSize() to determine what
745 the minimal size of window items should be, and will use that size
746 to calculate the layout. This allows layouts to adjust when an
747 item changes and its best size becomes different. If you would
748 rather have a window item stay the size it started with then use
750 @itemdef{wxRESERVE_SPACE_EVEN_IF_HIDDEN,
751 Normally wxSizers don't allocate space for hidden windows or other
752 items. This flag overrides this behavior so that sufficient space
753 is allocated for the window even if it isn't visible. This makes
754 it possible to dynamically show and hide controls without resizing
755 parent dialog, for example. (Available since 2.8.8.)
757 @itemdef{wxALIGN_CENTER<br>
763 wxALIGN_CENTER_VERTICAL<br>
764 wxALIGN_CENTRE_VERTICAL<br>
765 wxALIGN_CENTER_HORIZONTAL<br>
766 wxALIGN_CENTRE_HORIZONTAL,
767 The wxALIGN flags allow you to specify the alignment of the item
768 within the space allotted to it by the sizer, adjusted for the
775 @see @ref overview_sizer
777 class wxSizer
: public wxObject
782 Note that wxSizer is an abstract base class and may not be instantiated.
792 Appends a child to the sizer.
794 wxSizer itself is an abstract class, but the parameters are equivalent
795 in the derived classes that you will instantiate to use it so they are
799 The window to be added to the sizer. Its initial size (either set
800 explicitly by the user or calculated internally when using
801 wxDefaultSize) is interpreted as the minimal and in many cases also
804 A wxSizerFlags object that enables you to specify most of the above
805 parameters more conveniently.
807 wxSizerItem
* Add(wxWindow
* window
, const wxSizerFlags
& flags
);
810 Appends a child to the sizer.
812 wxSizer itself is an abstract class, but the parameters are equivalent
813 in the derived classes that you will instantiate to use it so they are
817 The window to be added to the sizer. Its initial size (either set
818 explicitly by the user or calculated internally when using
819 wxDefaultSize) is interpreted as the minimal and in many cases also
822 Although the meaning of this parameter is undefined in wxSizer, it
823 is used in wxBoxSizer to indicate if a child of a sizer can change
824 its size in the main orientation of the wxBoxSizer - where 0 stands
825 for not changeable and a value of more than zero is interpreted
826 relative to the value of other children of the same wxBoxSizer. For
827 example, you might have a horizontal wxBoxSizer with three
828 children, two of which are supposed to change their size with the
829 sizer. Then the two stretchable windows would get a value of 1 each
830 to make them grow and shrink equally with the sizer's horizontal
833 OR-combination of flags affecting sizer's behavior. See
834 @ref wxsizer_flags "wxSizer flags list" for details.
836 Determines the border width, if the flag parameter is set to
837 include any border flag.
839 Allows an extra object to be attached to the sizer item, for use in
840 derived classes when sizing information is more complex than the
841 proportion and flag will allow for.
843 wxSizerItem
* Add(wxWindow
* window
,
847 wxObject
* userData
= NULL
);
850 Appends a child to the sizer.
852 wxSizer itself is an abstract class, but the parameters are equivalent
853 in the derived classes that you will instantiate to use it so they are
857 The (child-)sizer to be added to the sizer. This allows placing a
858 child sizer in a sizer and thus to create hierarchies of sizers
859 (typically a vertical box as the top sizer and several horizontal
860 boxes on the level beneath).
862 A wxSizerFlags object that enables you to specify most of the above
863 parameters more conveniently.
865 wxSizerItem
* Add(wxSizer
* sizer
, const wxSizerFlags
& flags
);
868 Appends a child to the sizer.
870 wxSizer itself is an abstract class, but the parameters are equivalent
871 in the derived classes that you will instantiate to use it so they are
875 The (child-)sizer to be added to the sizer. This allows placing a
876 child sizer in a sizer and thus to create hierarchies of sizers
877 (typically a vertical box as the top sizer and several horizontal
878 boxes on the level beneath).
880 Although the meaning of this parameter is undefined in wxSizer, it
881 is used in wxBoxSizer to indicate if a child of a sizer can change
882 its size in the main orientation of the wxBoxSizer - where 0 stands
883 for not changeable and a value of more than zero is interpreted
884 relative to the value of other children of the same wxBoxSizer. For
885 example, you might have a horizontal wxBoxSizer with three
886 children, two of which are supposed to change their size with the
887 sizer. Then the two stretchable windows would get a value of 1 each
888 to make them grow and shrink equally with the sizer's horizontal
891 OR-combination of flags affecting sizer's behavior. See
892 @ref wxsizer_flags "wxSizer flags list" for details.
894 Determines the border width, if the flag parameter is set to
895 include any border flag.
897 Allows an extra object to be attached to the sizer item, for use in
898 derived classes when sizing information is more complex than the
899 proportion and flag will allow for.
901 wxSizerItem
* Add(wxSizer
* sizer
,
905 wxObject
* userData
= NULL
);
908 Appends a spacer child to the sizer.
910 wxSizer itself is an abstract class, but the parameters are equivalent
911 in the derived classes that you will instantiate to use it so they are
914 @a width and @a height specify the dimension of a spacer to be added to
915 the sizer. Adding spacers to sizers gives more flexibility in the
916 design of dialogs; imagine for example a horizontal box with two
917 buttons at the bottom of a dialog: you might want to insert a space
918 between the two buttons and make that space stretchable using the
919 proportion flag and the result will be that the left button will be
920 aligned with the left side of the dialog and the right button with the
921 right side - the space in between will shrink and grow with the dialog.
926 Height of the spacer.
928 Although the meaning of this parameter is undefined in wxSizer, it
929 is used in wxBoxSizer to indicate if a child of a sizer can change
930 its size in the main orientation of the wxBoxSizer - where 0 stands
931 for not changeable and a value of more than zero is interpreted
932 relative to the value of other children of the same wxBoxSizer. For
933 example, you might have a horizontal wxBoxSizer with three
934 children, two of which are supposed to change their size with the
935 sizer. Then the two stretchable windows would get a value of 1 each
936 to make them grow and shrink equally with the sizer's horizontal
939 OR-combination of flags affecting sizer's behavior. See
940 @ref wxsizer_flags "wxSizer flags list" for details.
942 Determines the border width, if the flag parameter is set to
943 include any border flag.
945 Allows an extra object to be attached to the sizer item, for use in
946 derived classes when sizing information is more complex than the
947 proportion and flag will allow for.
949 wxSizerItem
* Add(int width
, int height
,
953 wxObject
* userData
= NULL
);
956 Adds non-stretchable space to the sizer.
957 More readable way of calling:
959 wxSizer::Add(size, size, 0).
962 wxSizerItem
* AddSpacer(int size
);
965 Adds stretchable space to the sizer.
966 More readable way of calling:
968 wxSizer::Add(0, 0, prop).
971 wxSizerItem
* AddStretchSpacer(int prop
= 1);
974 This method is abstract and has to be overwritten by any derived class.
975 Here, the sizer will do the actual calculation of its children's minimal sizes.
977 virtual wxSize
CalcMin() = 0;
980 Detaches all children from the sizer.
981 If @a delete_windows is @true then child windows will also be deleted.
983 virtual void Clear(bool delete_windows
= false);
986 Computes client area size for @a window so that it matches the sizer's
987 minimal size. Unlike GetMinSize(), this method accounts for other
988 constraints imposed on @e window, namely display's size (returned size
989 will never be too large for the display) and maximum window size if
990 previously set by wxWindow::SetMaxSize().
992 The returned value is suitable for passing to wxWindow::SetClientSize() or
993 wxWindow::SetMinClientSize().
997 @see ComputeFittingWindowSize(), Fit()
999 wxSize
ComputeFittingClientSize(wxWindow
* window
);
1002 Like ComputeFittingClientSize(), but converts the result into window
1003 size. The returned value is suitable for passing to wxWindow::SetSize()
1004 or wxWindow::SetMinSize().
1008 @see ComputeFittingClientSize(), Fit()
1010 wxSize
ComputeFittingWindowSize(wxWindow
* window
);
1013 Detach the child @a window from the sizer without destroying it.
1015 This method does not cause any layout or resizing to take place, call Layout()
1016 to update the layout "on screen" after detaching a child from the sizer.
1018 Returns @true if the child item was found and detached, @false otherwise.
1022 virtual bool Detach(wxWindow
* window
);
1025 Detach the child @a sizer from the sizer without destroying it.
1027 This method does not cause any layout or resizing to take place, call Layout()
1028 to update the layout "on screen" after detaching a child from the sizer.
1030 Returns @true if the child item was found and detached, @false otherwise.
1034 virtual bool Detach(wxSizer
* sizer
);
1037 Detach a item at position @a index from the sizer without destroying it.
1039 This method does not cause any layout or resizing to take place, call Layout()
1040 to update the layout "on screen" after detaching a child from the sizer.
1041 Returns @true if the child item was found and detached, @false otherwise.
1045 virtual bool Detach(int index
);
1048 Tell the sizer to resize the @a window so that its client area matches the
1049 sizer's minimal size (ComputeFittingClientSize() is called to determine it).
1050 This is commonly done in the constructor of the window itself, see sample
1051 in the description of wxBoxSizer.
1053 @return The new window size.
1055 @see ComputeFittingClientSize(), ComputeFittingWindowSize()
1057 wxSize
Fit(wxWindow
* window
);
1060 Tell the sizer to resize the virtual size of the @a window to match the sizer's
1061 minimal size. This will not alter the on screen size of the window, but may
1062 cause the addition/removal/alteration of scrollbars required to view the virtual
1063 area in windows which manage it.
1065 @see wxScrolled::SetScrollbars(), SetVirtualSizeHints()
1067 void FitInside(wxWindow
* window
);
1071 Returns the list of the items in this sizer.
1073 The elements of type-safe wxList @c wxSizerItemList are pointers to
1074 objects of type wxSizerItem.
1076 wxSizerItemList
& GetChildren();
1077 const wxSizerItemList
& GetChildren() const;
1081 Returns the window this sizer is used in or @NULL if none.
1083 wxWindow
* GetContainingWindow() const;
1086 Finds wxSizerItem which holds the given @a window.
1087 Use parameter @a recursive to search in subsizers too.
1088 Returns pointer to item or @NULL.
1090 wxSizerItem
* GetItem(wxWindow
* window
, bool recursive
= false);
1093 Finds wxSizerItem which holds the given @a sizer.
1094 Use parameter @a recursive to search in subsizers too.
1095 Returns pointer to item or @NULL.
1098 wxSizerItem
* GetItem(wxSizer
* sizer
, bool recursive
= false);
1101 Finds wxSizerItem which is located in the sizer at position @a index.
1102 Use parameter @a recursive to search in subsizers too.
1103 Returns pointer to item or @NULL.
1105 wxSizerItem
* GetItem(size_t index
);
1108 Finds item of the sizer which has the given @e id.
1109 This @a id is not the window id but the id of the wxSizerItem itself.
1110 This is mainly useful for retrieving the sizers created from XRC resources.
1111 Use parameter @a recursive to search in subsizers too.
1112 Returns pointer to item or @NULL.
1114 wxSizerItem
* GetItemById(int id
, bool recursive
= false);
1117 Returns the minimal size of the sizer.
1119 This is either the combined minimal size of all the children and their
1120 borders or the minimal size set by SetMinSize(), depending on which is bigger.
1121 Note that the returned value is client size, not window size.
1122 In particular, if you use the value to set toplevel window's minimal or
1123 actual size, use wxWindow::SetMinClientSize() or wxWindow::SetClientSize(),
1124 not wxWindow::SetMinSize() or wxWindow::SetSize().
1126 wxSize
GetMinSize();
1129 Returns the current position of the sizer.
1131 wxPoint
GetPosition() const;
1134 Returns the current size of the sizer.
1136 wxSize
GetSize() const;
1139 Hides the child @a window.
1141 To make a sizer item disappear, use Hide() followed by Layout().
1143 Use parameter @a recursive to hide elements found in subsizers.
1144 Returns @true if the child item was found, @false otherwise.
1146 @see IsShown(), Show()
1148 bool Hide(wxWindow
* window
, bool recursive
= false);
1151 Hides the child @a sizer.
1153 To make a sizer item disappear, use Hide() followed by Layout().
1155 Use parameter @a recursive to hide elements found in subsizers.
1156 Returns @true if the child item was found, @false otherwise.
1158 @see IsShown(), Show()
1160 bool Hide(wxSizer
* sizer
, bool recursive
= false);
1163 Hides the item at position @a index.
1165 To make a sizer item disappear, use Hide() followed by Layout().
1167 Use parameter @a recursive to hide elements found in subsizers.
1168 Returns @true if the child item was found, @false otherwise.
1170 @see IsShown(), Show()
1172 bool Hide(size_t index
);
1175 Insert a child into the sizer before any existing item at @a index.
1177 See Add() for the meaning of the other parameters.
1179 wxSizerItem
* Insert(size_t index
, wxWindow
* window
,
1180 const wxSizerFlags
& flags
);
1183 Insert a child into the sizer before any existing item at @a index.
1185 See Add() for the meaning of the other parameters.
1187 wxSizerItem
* Insert(size_t index
, wxWindow
* window
,
1191 wxObject
* userData
= NULL
);
1194 Insert a child into the sizer before any existing item at @a index.
1196 See Add() for the meaning of the other parameters.
1198 wxSizerItem
* Insert(size_t index
, wxSizer
* sizer
,
1199 const wxSizerFlags
& flags
);
1202 Insert a child into the sizer before any existing item at @a index.
1204 See Add() for the meaning of the other parameters.
1206 wxSizerItem
* Insert(size_t index
, wxSizer
* sizer
,
1210 wxObject
* userData
= NULL
);
1213 Insert a child into the sizer before any existing item at @a index.
1215 See Add() for the meaning of the other parameters.
1217 wxSizerItem
* Insert(size_t index
, int width
, int height
,
1221 wxObject
* userData
= NULL
);
1224 Inserts non-stretchable space to the sizer.
1225 More readable way of calling wxSizer::Insert(size, size, 0).
1227 wxSizerItem
* InsertSpacer(size_t index
, int size
);
1230 Inserts stretchable space to the sizer.
1231 More readable way of calling wxSizer::Insert(0, 0, prop).
1233 wxSizerItem
* InsertStretchSpacer(size_t index
, int prop
= 1);
1236 Returns @true if the @a window is shown.
1238 @see Hide(), Show(), wxSizerItem::IsShown()
1240 bool IsShown(wxWindow
* window
) const;
1243 Returns @true if the @a sizer is shown.
1245 @see Hide(), Show(), wxSizerItem::IsShown()
1247 bool IsShown(wxSizer
* sizer
) const;
1250 Returns @true if the item at @a index is shown.
1252 @see Hide(), Show(), wxSizerItem::IsShown()
1254 bool IsShown(size_t index
) const;
1257 Call this to force layout of the children anew, e.g. after having added a child
1258 to or removed a child (window, other sizer or space) from the sizer while
1259 keeping the current dimension.
1261 virtual void Layout();
1264 Same as Add(), but prepends the items to the beginning of the
1265 list of items (windows, subsizers or spaces) owned by this sizer.
1267 wxSizerItem
* Prepend(wxWindow
* window
, const wxSizerFlags
& flags
);
1270 Same as Add(), but prepends the items to the beginning of the
1271 list of items (windows, subsizers or spaces) owned by this sizer.
1273 wxSizerItem
* Prepend(wxWindow
* window
, int proportion
= 0,
1276 wxObject
* userData
= NULL
);
1279 Same as Add(), but prepends the items to the beginning of the
1280 list of items (windows, subsizers or spaces) owned by this sizer.
1282 wxSizerItem
* Prepend(wxSizer
* sizer
,
1283 const wxSizerFlags
& flags
);
1286 Same as Add(), but prepends the items to the beginning of the
1287 list of items (windows, subsizers or spaces) owned by this sizer.
1289 wxSizerItem
* Prepend(wxSizer
* sizer
, int proportion
= 0,
1292 wxObject
* userData
= NULL
);
1295 Same as Add(), but prepends the items to the beginning of the
1296 list of items (windows, subsizers or spaces) owned by this sizer.
1298 wxSizerItem
* Prepend(int width
, int height
,
1302 wxObject
* userData
= NULL
);
1305 Prepends non-stretchable space to the sizer.
1306 More readable way of calling wxSizer::Prepend(size, size, 0).
1308 wxSizerItem
* PrependSpacer(int size
);
1311 Prepends stretchable space to the sizer.
1312 More readable way of calling wxSizer::Prepend(0, 0, prop).
1314 wxSizerItem
* PrependStretchSpacer(int prop
= 1);
1317 This method is abstract and has to be overwritten by any derived class.
1318 Here, the sizer will do the actual calculation of its children's
1319 positions and sizes.
1321 virtual void RecalcSizes() = 0;
1324 Removes a child window from the sizer, but does @b not destroy it
1325 (because windows are owned by their parent window, not the sizer).
1328 The overload of this method taking a wxWindow* parameter
1329 is deprecated as it does not destroy the window as would usually be
1330 expected from Remove(). You should use Detach() in new code instead.
1331 There is currently no wxSizer method that will both detach and destroy
1334 @note This method does not cause any layout or resizing to take
1335 place, call Layout() to update the layout "on screen" after
1336 removing a child from the sizer.
1338 @return @true if the child item was found and removed, @false otherwise.
1340 virtual bool Remove(wxWindow
* window
);
1343 Removes a sizer child from the sizer and destroys it.
1345 @note This method does not cause any layout or resizing to take
1346 place, call Layout() to update the layout "on screen" after
1347 removing a child from the sizer.
1349 @param sizer The wxSizer to be removed.
1351 @return @true if the child item was found and removed, @false otherwise.
1353 virtual bool Remove(wxSizer
* sizer
);
1356 Removes a child from the sizer and destroys it if it is a sizer or a
1357 spacer, but not if it is a window (because windows are owned by their
1358 parent window, not the sizer).
1360 @note This method does not cause any layout or resizing to take
1361 place, call Layout() to update the layout "on screen" after
1362 removing a child from the sizer.
1365 The position of the child in the sizer, e.g. 0 for the first item.
1367 @return @true if the child item was found and removed, @false otherwise.
1369 virtual bool Remove(int index
);
1372 Detaches the given @a oldwin from the sizer and replaces it with the
1373 given @a newwin. The detached child window is @b not deleted (because
1374 windows are owned by their parent window, not the sizer).
1376 Use parameter @a recursive to search the given element recursively in subsizers.
1378 This method does not cause any layout or resizing to take place,
1379 call Layout() to update the layout "on screen" after replacing a
1380 child from the sizer.
1382 Returns @true if the child item was found and removed, @false otherwise.
1384 virtual bool Replace(wxWindow
* oldwin
, wxWindow
* newwin
,
1385 bool recursive
= false);
1388 Detaches the given @a oldsz from the sizer and replaces it with the
1389 given @a newsz. The detached child sizer is deleted.
1391 Use parameter @a recursive to search the given element recursively in subsizers.
1393 This method does not cause any layout or resizing to take place,
1394 call Layout() to update the layout "on screen" after replacing a
1395 child from the sizer.
1397 Returns @true if the child item was found and removed, @false otherwise.
1399 virtual bool Replace(wxSizer
* oldsz
, wxSizer
* newsz
,
1400 bool recursive
= false);
1403 Detaches the given item at position @a index from the sizer and
1404 replaces it with the given wxSizerItem @a newitem.
1406 The detached child is deleted @b only if it is a sizer or a spacer
1407 (but not if it is a wxWindow because windows are owned by their
1408 parent window, not the sizer).
1410 This method does not cause any layout or resizing to take place,
1411 call Layout() to update the layout "on screen" after replacing a
1412 child from the sizer.
1414 Returns @true if the child item was found and removed, @false otherwise.
1416 virtual bool Replace(size_t index
, wxSizerItem
* newitem
);
1419 Call this to force the sizer to take the given dimension and thus force
1420 the items owned by the sizer to resize themselves according to the
1421 rules defined by the parameter in the Add() and Prepend() methods.
1423 void SetDimension(int x
, int y
, int width
, int height
);
1428 void SetDimension(const wxPoint
& pos
, const wxSize
& size
);
1431 Set an item's minimum size by window, sizer, or position.
1433 The item will be found recursively in the sizer's descendants.
1434 This function enables an application to set the size of an item after
1437 @see wxSizerItem::SetMinSize()
1439 bool SetItemMinSize(wxWindow
* window
, int width
, int height
);
1442 Set an item's minimum size by window, sizer, or position.
1444 The item will be found recursively in the sizer's descendants.
1445 This function enables an application to set the size of an item after
1448 @see wxSizerItem::SetMinSize()
1450 bool SetItemMinSize(wxSizer
* sizer
, int width
, int height
);
1453 Set an item's minimum size by window, sizer, or position.
1455 The item will be found recursively in the sizer's descendants.
1456 This function enables an application to set the size of an item after
1459 @see wxSizerItem::SetMinSize()
1461 bool SetItemMinSize(size_t index
, int width
, int height
);
1464 Call this to give the sizer a minimal size.
1466 Normally, the sizer will calculate its minimal size based purely on how
1467 much space its children need. After calling this method GetMinSize()
1468 will return either the minimal size as requested by its children or the
1469 minimal size set here, depending on which is bigger.
1471 void SetMinSize(const wxSize
& size
);
1476 void SetMinSize(int width
, int height
);
1479 This method first calls Fit() and then wxTopLevelWindow::SetSizeHints()
1480 on the @a window passed to it.
1482 This only makes sense when @a window is actually a wxTopLevelWindow such
1483 as a wxFrame or a wxDialog, since SetSizeHints only has any effect in these classes.
1484 It does nothing in normal windows or controls.
1486 This method is implicitly used by wxWindow::SetSizerAndFit() which is
1487 commonly invoked in the constructor of a toplevel window itself (see
1488 the sample in the description of wxBoxSizer) if the toplevel window is
1491 void SetSizeHints(wxWindow
* window
);
1494 Tell the sizer to set the minimal size of the @a window virtual area to match
1495 the sizer's minimal size. For windows with managed scrollbars this will set them
1498 @deprecated @todo provide deprecation description
1500 @see wxScrolled::SetScrollbars()
1502 void SetVirtualSizeHints(wxWindow
* window
);
1505 Shows or hides the @a window.
1506 To make a sizer item disappear or reappear, use Show() followed by Layout().
1508 Use parameter @a recursive to show or hide elements found in subsizers.
1510 Returns @true if the child item was found, @false otherwise.
1512 @see Hide(), IsShown()
1514 bool Show(wxWindow
* window
, bool show
= true,
1515 bool recursive
= false);
1518 Shows or hides @a sizer.
1519 To make a sizer item disappear or reappear, use Show() followed by Layout().
1521 Use parameter @a recursive to show or hide elements found in subsizers.
1523 Returns @true if the child item was found, @false otherwise.
1525 @see Hide(), IsShown()
1527 bool Show(wxSizer
* sizer
, bool show
= true,
1528 bool recursive
= false);
1531 Shows the item at @a index.
1532 To make a sizer item disappear or reappear, use Show() followed by Layout().
1534 Returns @true if the child item was found, @false otherwise.
1536 @see Hide(), IsShown()
1538 bool Show(size_t index
, bool show
= true);
1546 A grid sizer is a sizer which lays out its children in a two-dimensional
1547 table with all table fields having the same size, i.e. the width of each
1548 field is the width of the widest child, the height of each field is the
1549 height of the tallest child.
1552 @category{winlayout}
1554 @see wxSizer, @ref overview_sizer
1556 class wxGridSizer
: public wxSizer
1561 Constructor for a wxGridSizer.
1563 @a rows and @a cols determine the number of columns and rows in the sizer -
1564 if either of the parameters is zero, it will be calculated to form the
1565 total number of children in the sizer, thus making the sizer grow dynamically.
1567 @a vgap and @a hgap define extra space between all children.
1569 wxGridSizer(int rows
, int cols
, int vgap
, int hgap
);
1570 wxGridSizer(int cols
, int vgap
= 0, int hgap
= 0);
1574 Returns the number of columns in the sizer.
1576 int GetCols() const;
1579 Returns the horizontal gap (in pixels) between cells in the sizer.
1581 int GetHGap() const;
1584 Returns the number of rows in the sizer.
1586 int GetRows() const;
1589 Returns the vertical gap (in pixels) between the cells in the sizer.
1591 int GetVGap() const;
1594 Sets the number of columns in the sizer.
1596 void SetCols(int cols
);
1599 Sets the horizontal gap (in pixels) between cells in the sizer.
1601 void SetHGap(int gap
);
1604 Sets the number of rows in the sizer.
1606 void SetRows(int rows
);
1609 Sets the vertical gap (in pixels) between the cells in the sizer.
1611 void SetVGap(int gap
);
1617 @class wxStaticBoxSizer
1619 wxStaticBoxSizer is a sizer derived from wxBoxSizer but adds a static
1620 box around the sizer.
1621 This static box may be either created independently or the sizer may create
1622 it itself as a convenience. In any case, the sizer owns the wxStaticBox control
1623 and will delete it, if it is deleted.
1626 @category{winlayout}
1628 @see wxSizer, wxStaticBox, wxBoxSizer, @ref overview_sizer
1630 class wxStaticBoxSizer
: public wxBoxSizer
1634 This constructor uses an already existing static box.
1636 It takes the associated static box and the orientation @a orient, which
1637 can be either @c wxVERTICAL or @c wxHORIZONTAL as parameters.
1639 wxStaticBoxSizer(wxStaticBox
* box
, int orient
);
1642 This constructor creates a new static box with the given label and parent window.
1644 wxStaticBoxSizer(int orient
, wxWindow
*parent
,
1645 const wxString
& label
= wxEmptyString
);
1648 Returns the static box associated with the sizer.
1650 wxStaticBox
* GetStaticBox() const;
1658 The basic idea behind a box sizer is that windows will most often be laid out
1659 in rather simple basic geometry, typically in a row or a column or several
1660 hierarchies of either.
1662 For more information, please see @ref overview_sizer_box.
1665 @category{winlayout}
1667 @see wxSizer, @ref overview_sizer
1669 class wxBoxSizer
: public wxSizer
1673 Constructor for a wxBoxSizer. @a orient may be either of wxVERTICAL
1674 or wxHORIZONTAL for creating either a column sizer or a row sizer.
1676 wxBoxSizer(int orient
);
1679 Implements the calculation of a box sizer's minimal.
1681 It is used internally only and must not be called by the user.
1682 Documented for information.
1684 virtual wxSize
CalcMin();
1687 Returns the orientation of the box sizer, either wxVERTICAL
1690 int GetOrientation() const;
1693 Implements the calculation of a box sizer's dimensions and then sets
1694 the size of its children (calling wxWindow::SetSize if the child is a window).
1696 It is used internally only and must not be called by the user
1697 (call Layout() if you want to resize). Documented for information.