The layout algorithm used by sizers in wxWidgets is closely related to layout in other GUI toolkits, such as Java's AWT, the GTK toolkit or the Qt toolkit. It is based upon the idea of the individual subwindows reporting their minimal required size and their ability to get stretched if the size of the parent window has changed.
This will most often mean that the programmer does not set the original size of a dialog in the beginning, rather the dialog will be assigned a sizer and this sizer will be queried about the recommended size. The sizer in turn will query its children, which can be normal windows, empty space or other sizers, so that a hierarchy of sizers can be constructed. Note that
What makes sizers so well fitted for use in wxWidgets is the fact that every control reports its own minimal size and the algorithm can handle differences in font sizes or different window (dialog item) sizes on different platforms without problems. If e.g. the standard font as well as the overall design of Motif widgets requires more space than on Windows, the initial dialog size will automatically be bigger on Motif than on Windows.
Sizers may also be used to control the layout of custom drawn items on the window. The
Please notice that sizers, like child windows, are owned by the library and will be deleted by it which implies that they must be allocated on the heap. However if you create a sizer and do not add it to another sizer or window, the library wouldn't be able to delete such an orphan sizer and in this, and only this, case it should be deleted explicitly.
wxSizer flags
The "flag" argument accepted by
See:
wxWidgets docs:
Appends a child to the sizer.
Appends a spacer child to the sizer.
This base function adds non-stretchable space to both the horizontal and vertical orientation of the sizer.
More readable way of calling:
See:
Adds stretchable space to the sizer.
More readable way of calling:
This method is abstract and has to be overwritten by any derived class.
Here, the sizer will do the actual calculation of its children's minimal sizes.
Detaches all children from the sizer.
If
Notice that child sizers are always deleted, as a general consequence of the principle that sizers own their sizer children, but don't own their window children (because they are already owned by their parent windows).
Detach a item at position
This method does not cause any layout or resizing to take place, call
See:
Tell the sizer to resize the
This is commonly done in the constructor of the window itself, see sample in the description of
Return: The new window size.
See:
See:
Tell the sizer to resize the virtual size of the
This will not alter the on screen size of the window, but may cause the addition/removal/alteration of scrollbars required to view the virtual area in windows which manage it.
See:
Finds
Use parameter
Finds
Use parameter
Returns the current size of the sizer.
Returns the current position of the sizer.
Returns the minimal size of the sizer.
This is either the combined minimal size of all the children and their borders or the minimal size set by
Hides the item at position
To make a sizer item disappear, use
Use parameter
See:
Hides the child
To make a sizer item disappear, use
Use parameter
See:
Insert a child into the sizer before any existing item at
See
Insert a child into the sizer before any existing item at
See
Inserts non-stretchable space to the sizer.
More readable way of calling wxSizer::Insert(index, size, size).
Inserts stretchable space to the sizer.
More readable way of calling wxSizer::Insert(0, 0, prop).
Returns true if the item at
See:
See:
Call this to force layout of the children anew, e.g. after having added a child to or removed a child (window, other sizer or space) from the sizer while keeping the current dimension.
Same as
Same as
Prepends non-stretchable space to the sizer.
More readable way of calling wxSizer::Prepend(size, size, 0).
Prepends stretchable space to the sizer.
More readable way of calling wxSizer::Prepend(0, 0, prop).
Removes a sizer child from the sizer and destroys it.
Note: This method does not cause any layout or resizing to take place, call
Return: true if the child item was found and removed, false otherwise.
Detaches the given item at position
The detached child is deleted
This method does not cause any layout or resizing to take place, call
Returns true if the child item was found and removed, false otherwise.
Detaches the given
The detached child window is
Use parameter
This method does not cause any layout or resizing to take place, call
Returns true if the child item was found and removed, false otherwise.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Call this to force the sizer to take the given dimension and thus force the items owned by the sizer to resize themselves according to the rules defined by the parameter in the
Call this to give the sizer a minimal size.
Normally, the sizer will calculate its minimal size based purely on how much space its children need. After calling this method
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This method first calls
This only makes sense when
This method is implicitly used by
Shows the item at
To make a sizer item disappear or reappear, use
Returns true if the child item was found, false otherwise.
See:
Show or hide all items managed by the sizer.