wxSizer(3erl)
๐ธ NAME ๐ธ
wxSizer(3erl) โ Erlang Module Definition โ wxSizer - Functions for wxSizer class ๐
โจ
๐ฆ DESCRIPTION ๐ฆ
Okay bestie, gather round: wxSizer is the abstract base class used for laying out subwindows in a window. You cannot use wxSizer directly โ instead, you will have to use one of the sizer classes derived from it. Currently there are wxBoxSizer, wxStaticBoxSizer, wxGridSizer, wxFlexGridSizer, wxWrapSizer (not implemented in wx) and wxGridBagSizer. Itโs giving sizer family reunion ๐.
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. Lowkey iconic behavior fr fr ๐ซ.
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 wxSizer does not derive from wxWindow and thus does not interfere with tab ordering and requires very little resources compared to a real window on screen. Main character energy: all the layout, barely any window overhead ๐.
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. No cap, it just adapts ๐ .
Sizers may also be used to control the layout of custom drawn items on the window. The add/4, insert/5, and prepend/4 functions return a pointer to the newly added wxSizerItem. Just add empty space of the desired size and attributes, and then use the wxSizerItem:getRect/1 method to determine where the drawing operations should take place. Custom-draw bestie behavior, obsessed ๐๏ธโจ.
๐จ Ownership warning, bestie: 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. Periodt ๐.
๐ wxSizer flags ๐
The flag argument accepted by wxSizerItem constructors and other functions, e.g. add/4, is an OR-combination of the following flags. Two main behaviours are defined using these flags. One is the border around a window: the border parameter determines the border width whereas the flags given here determine which side(s) of the item that the border will be added. The other flags determine how the sizer item behaves when the space allotted to the sizer changes, and is somewhat dependent on the specific kind of sizer used. Flags: lowkey the vibe controls ๐.
See: Overview sizer
wxWidgets docs: wxSizer
๐ง DATA TYPES ๐ง
wxSizer() = wx:wx_object()โ thatโs the type, bestie ๐ซถ
๐ EXPORTS ๐
๐ add โ appending children & spacers
add(This, Window) -> wxSizerItem:wxSizerItem()- Types:
This = wxSizer()Window = wxWindow:wxWindow() | wxSizer:wxSizer()
- Types:
add(This, Width, Height) -> wxSizerItem:wxSizerItem()add(This, Window, Flags) -> wxSizerItem:wxSizerItem()add(This, Window, Height :: [Option]) -> wxSizerItem:wxSizerItem()- Types:
This = wxSizer()Window = wxWindow:wxWindow() | wxSizer:wxSizer()Option = {proportion, integer()} | {flag, integer()} | {border, integer()} | {userData, wx:wx_object()}
- Appends a child to the sizer.
wxSizeritself is an abstract class, but the parameters are equivalent in the derived classes that you will instantiate to use it so they are described here: ๐
- Types:
add(This, Width, Height, Options :: [Option]) -> wxSizerItem:wxSizerItem()add(This, Width, Height, Flags) -> wxSizerItem:wxSizerItem()- Types:
This = wxSizer()Width = Height = integer()Flags = wxSizerFlags:wxSizerFlags()
- Appends a spacer child to the sizer. spacer moment ๐
- Types:
๐ฆ addSpacer
addSpacer(This, Size) -> wxSizerItem:wxSizerItem()- Types:
This = wxSizer()Size = integer()
- This base function adds non-stretchable space to both the horizontal and vertical orientation of the sizer.
- More readable way of calling:
- See:
addSpacer/2
- Types:
๐ addStretchSpacer
addStretchSpacer(This) -> wxSizerItem:wxSizerItem()- Types:
This = wxSizer()
- Types:
addStretchSpacer(This, Options :: [Option]) -> wxSizerItem:wxSizerItem()- Types:
This = wxSizer()Option = {prop, integer()}
- Adds stretchable space to the sizer.
- More readable way of calling:
- Types:
โญ calcMin
calcMin(This) -> {W :: integer(), H :: integer()}- Types:
This = wxSizer()
- 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. Math but make it layout โจ
- Types:
๐ clear
clear(This) -> ok- Types:
This = wxSizer()
- Types:
clear(This, Options :: [Option]) -> ok- Types:
This = wxSizer()Option = {delete_windows, boolean()}
- Detaches all children from the sizer.
- If
delete_windowsistruethen child windows will also be deleted. - 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). Ownership tea โ๐
- Types:
๐ง detach
detach(This, Window) -> boolean()detach(This, Index) -> boolean()- Types:
This = wxSizer()Index = integer()
- Detach a item at position
indexfrom the sizer without destroying it. - This method does not cause any layout or resizing to take place, call
layout/1to update the layout "on screen" after detaching a child from the sizer. Returnstrueif the child item was found and detached,falseotherwise. - See:
remove/2
- Types:
๐ซถ fit
fit(This, Window) -> {W :: integer(), H :: integer()}- Types:
This = wxSizer()Window = wxWindow:wxWindow()
- Tell the sizer to resize the window so that its client area matches the sizer's minimal size (
ComputeFittingClientSize()(not implemented in wx) is called to determine it). - This is commonly done in the constructor of the window itself, see sample in the description of
wxBoxSizer. - Return: The new window size.
- See:
ComputeFittingClientSize()(not implemented in wx),ComputeFittingWindowSize()(not implemented in wx)
- Types:
๐ธ setVirtualSizeHints
setVirtualSizeHints(This, Window) -> ok- Types:
This = wxSizer()Window = wxWindow:wxWindow()
- See:
fitInside/2.
- Types:
๐ฆ fitInside
fitInside(This, Window) -> ok- Types:
This = wxSizer()Window = wxWindow:wxWindow()
- Tell the sizer to resize the virtual size of the window to match the sizer's minimal size.
- 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:
wxScrolledWindow:setScrollbars/6,setVirtualSizeHints/2
- Types:
๐ getChildren
getChildren(This) -> [wxSizerItem:wxSizerItem()]- Types:
This = wxSizer()
- No extra prose in the original โ just this return list, bestie ๐ซถ
- Types:
๐ getItem
getItem(This, Window) -> wxSizerItem:wxSizerItem()getItem(This, Index) -> wxSizerItem:wxSizerItem()- Types:
This = wxSizer()Index = integer()
- Finds
wxSizerItemwhich is located in the sizer at positionindex. - Use parameter
recursiveto search in subsizers too. Returns pointer to item orNULL.
- Types:
getItem(This, Window, Options :: [Option]) -> wxSizerItem:wxSizerItem()- Types:
This = wxSizer()Window = wxWindow:wxWindow() | wxSizer:wxSizer()Option = {recursive, boolean()}
- Finds
wxSizerItemwhich holds the given window. - Use parameter
recursiveto search in subsizers too. Returns pointer to item orNULL. Search party, but make it sizer ๐โจ
- Types:
๐ getSize
getSize(This) -> {W :: integer(), H :: integer()}- Types:
This = wxSizer()
- Returns the current size of the sizer.
- Types:
๐ getPosition
getPosition(This) -> {X :: integer(), Y :: integer()}- Types:
This = wxSizer()
- Returns the current position of the sizer.
- Types:
โญ getMinSize
getMinSize(This) -> {W :: integer(), H :: integer()}- Types:
This = wxSizer()
- 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
setMinSize/3, depending on which is bigger. Note that the returned value is client size, not window size. In particular, if you use the value to set toplevel window's minimal or actual size, usewxWindow::SetMinClientSize()(not implemented in wx) orwxWindow:setClientSize/3, notwxWindow:setMinSize/2orwxWindow:setSize/6. Client size vs window size: important distinction, bestie ๐
- Types:
๐ hide
hide(This, Window) -> boolean()hide(This, Index) -> boolean()- Types:
This = wxSizer()Index = integer()
- Hides the item at position
index. - To make a sizer item disappear, use
hide/3followed bylayout/1. - Use parameter
recursiveto hide elements found in subsizers. Returnstrueif the child item was found,falseotherwise. - See:
isShown/2,show/3
- Types:
hide(This, Window, Options :: [Option]) -> boolean()- Types:
This = wxSizer()Window = wxWindow:wxWindow() | wxSizer:wxSizer()Option = {recursive, boolean()}
- Hides the child window.
- To make a sizer item disappear, use
hide/3followed bylayout/1. - Use parameter
recursiveto hide elements found in subsizers. Returnstrueif the child item was found,falseotherwise. - See:
isShown/2,show/3
- Types:
๐ง insert
insert(This, Index, Item) -> wxSizerItem:wxSizerItem()- Types:
This = wxSizer()Index = integer()Item = wxSizerItem:wxSizerItem()
- Types:
insert(This, Index, Width, Height) -> wxSizerItem:wxSizerItem()insert(This, Index, Window, Flags) -> wxSizerItem:wxSizerItem()
insert ๐
insert(This, Index, Window, Height :: [Option]) ->
wxSizerItem:wxSizerItem()
Types:
This = wxSizer()
Index = integer()
Window = wxWindow:wxWindow() | wxSizer:wxSizer()
Option =
{proportion, integer()} |
{flag, integer()} |
{border, integer()} |
{userData, wx:wx_object()}
Okay so this one slides a child into the sizer before whatever item is already chilling at Index โ like cutting the line but make it fashion โจ. And for what all the other params actually mean, go peek at add/4, bestie, it's all explained there ๐ซถ.
insert(This, Index, Width, Height, Options :: [Option]) ->
wxSizerItem:wxSizerItem()
insert(This, Index, Width, Height, Flags) ->
wxSizerItem:wxSizerItem()
Types:
This = wxSizer()
Index = Width = Height = integer()
Flags = wxSizerFlags:wxSizerFlags()
Same energy, same job: insert a child into the sizer before any existing item at Index ๐. Again, add/4 has the lore on all the other parameters ๐ฅ.
insertSpacer ๐
insertSpacer(This, Index, Size) -> wxSizerItem:wxSizerItem()
Types:
This = wxSizer()
Index = Size = integer()
Inserts non-stretchable space into the sizer โ so it stays exactly the size it is, no growing, no drama ๐
โโ๏ธ. It's just the more readable way of calling wxSizer::Insert(index, size, size) โจ.
insertStretchSpacer ๐ธ
insertStretchSpacer(This, Index) -> wxSizerItem:wxSizerItem()
Types:
This = wxSizer()
Index = integer()
insertStretchSpacer(This, Index, Options :: [Option]) ->
wxSizerItem:wxSizerItem()
Types:
This = wxSizer()
Index = integer()
Option = {prop, integer()}
Now this spacer stretches, okay, it's flexible, it's adaptable, it's giving main character energy ๐ฆ. It's the readable-girl way of calling wxSizer::Insert(0, 0, prop) ๐.
isShown ๐
isShown(This, Window) -> boolean()
isShown(This, Index) -> boolean()
Types:
This = wxSizer()
Index = integer()
Returns true if the item at Index is shown, false if it's hiding ๐.
See: hide/3, show/3, wxSizerItem:isShown/1 ๐
recalcSizes ๐งฎ
recalcSizes(This) -> ok
Types:
This = wxSizer()
See: layout/1 โจ
layout ๐
layout(This) -> ok
Types:
This = wxSizer()
Call this to force the children to lay out all over again โ like a glow-up reset ๐ . Perfect when you added a child or yeeted a child (window, other sizer or space) while keeping the current dimension. Slay, refresh, reposition ๐ฅ.
prepend ๐
prepend(This, Item) -> wxSizerItem:wxSizerItem()
Types:
This = wxSizer()
Item = wxSizerItem:wxSizerItem()
prepend(This, Width, Height) -> wxSizerItem:wxSizerItem()
prepend(This, Window, Flags) -> wxSizerItem:wxSizerItem()
prepend(This, Window, Height :: [Option]) ->
wxSizerItem:wxSizerItem()
Types:
This = wxSizer()
Window = wxWindow:wxWindow() | wxSizer:wxSizer()
Option =
{proportion, integer()} |
{flag, integer()} |
{border, integer()} |
{userData, wx:wx_object()}
Literally add/4 but it goes to the front of the line instead of the back โ the items (windows, subsizers or spaces) owned by this sizer get a VIP entrance ๐โจ.
prepend(This, Width, Height, Options :: [Option]) ->
wxSizerItem:wxSizerItem()
prepend(This, Width, Height, Flags) -> wxSizerItem:wxSizerItem()
Types:
This = wxSizer()
Width = Height = integer()
Flags = wxSizerFlags:wxSizerFlags()
Yep, same again: add/4 behaviour, but the items (windows, subsizers or spaces) owned by this sizer get prepended to the beginning of the list ๐.
prependSpacer ๐
prependSpacer(This, Size) -> wxSizerItem:wxSizerItem()
Types:
This = wxSizer()
Size = integer()
Prepends non-stretchable space to the sizer โ it does not grow, no cap, it just sits there looking cute ๐ธ. The readable way of calling wxSizer::Prepend(size, size, 0) โจ.
prependStretchSpacer ๐ฆ
prependStretchSpacer(This) -> wxSizerItem:wxSizerItem()
Types:
This = wxSizer()
prependStretchSpacer(This, Options :: [Option]) ->
wxSizerItem:wxSizerItem()
Types:
This = wxSizer()
Option = {prop, integer()}
Prepends stretchable space โ flexible, accommodating, lowkey iconic ๐. The readable way of calling wxSizer::Prepend(0, 0, prop) ๐.
remove ๐
remove(This, Index) -> boolean()
remove(This, Sizer) -> boolean()
Types:
This = Sizer = wxSizer()
Removes a sizer child from the sizer and destroys it โ gone, deleted, no thoughts head empty ๐ซถ.
โ ๏ธ Note: This method does not cause any layout or resizing to take place. Call layout/1 to update the layout "on screen" after removing a child from the sizer โ otherwise you're just staring at a ghost ๐ป.
Returns: true if the child item was found and removed, false otherwise ๐.
replace ๐
replace(This, Oldwin, Newwin) -> boolean()
replace(This, Index, Newitem) -> boolean()
Types:
This = wxSizer()
Index = integer()
Newitem = wxSizerItem:wxSizerItem()
Detaches the item at position Index from the sizer and swaps in the given wxSizerItem Newitem โ it's giving makeover montage ๐
โจ.
The detached child is deleted only if it is a sizer or a spacer โ but not if it's a wxWindow, because windows are owned by their parent window, not the sizer ๐.
This method does not cause any layout or resizing to take place, so call layout/1 to update the layout "on screen" after replacing a child from the sizer ๐ญ.
Returns true if the child item was found and removed, false otherwise ๐.
replace(This, Oldwin, Newwin, Options :: [Option]) -> boolean()
Types:
This = wxSizer()
Oldwin = Newwin = wxWindow:wxWindow() | wxSizer:wxSizer()
Option = {recursive, boolean()}
Detaches the given Oldwin from the sizer and replaces it with Newwin ๐ฆ.
The detached child window is not deleted (because windows are owned by their parent window, not the sizer) โ respect the ownership chain, bestie ๐ซถ.
Use the parameter recursive to search the given element recursively in subsizers โ deep dive energy ๐.
Again: no layout, no resizing. Call layout/1 to update the layout "on screen" after replacing a child from the sizer ๐.
Returns true if the child item was found and removed, false otherwise โจ.
setDimension ๐
setDimension(This, Pos, Size) -> ok
Types:
This = wxSizer()
Pos = {X :: integer(), Y :: integer()}
Size = {W :: integer(), H :: integer()}
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts ๐ .
setDimension(This, X, Y, Width, Height) -> ok
Types:
This = wxSizer()
X = Y = Width = Height = integer()
Call this to force the sizer to take the given dimension, which in turn forces the items owned by the sizer to resize themselves according to the rules defined by the parameter in the add/4 and prepend/4 methods ๐ฅ. Basically you set the vibe and everything else falls in line, periodt ๐.
setMinSize ๐
setMinSize(This, Size) -> ok
Types:
This = wxSizer()
Size = {W :: integer(), H :: integer()}
Call this to give the sizer a minimal size โ a little floor, a lil "you shall not shrink past this" ๐ธ.
Normally the sizer calculates its minimal size based purely on how much space its children need. After calling this method, getMinSize/1 will return either the minimal size as requested by its children or the minimal size set here โ whichever is bigger โจ.
setMinSize(This, Width, Height) -> ok
Types:
This = wxSizer()
Width = Height = integer()
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts ๐.
setItemMinSize ๐
setItemMinSize(This, Window, Size) -> boolean()
setItemMinSize(This, Index, Size) -> boolean()
Types:
This = wxSizer()
Index = integer()
Size = {W :: integer(), H :: integer()}
setItemMinSize(This, Window, Width, Height) -> boolean()
setItemMinSize(This, Index, Width, Height) -> boolean()
Types:
This = wxSizer()
Index = Width = Height = integer()
setSizeHints ๐ช
setSizeHints(This, Window) -> ok
Types:
This = wxSizer()
Window = wxWindow:wxWindow()
This method first calls fit/2 and then calls setSizeHints/2 on the window passed to it ๐ซถ.
This only makes sense when Window is actually a wxTopLevelWindow such as a wxFrame or a wxDialog, since SetSizeHints only has any effect in these classes. It does nothing in normal windows or controls โ like talking to a wall, ngl ๐ญ.
This method is implicitly used by wxWindow:setSizerAndFit/3, which is commonly invoked in the constructor of a toplevel window itself (see the sample in the description of wxBoxSizer) if the toplevel window is resizable โจ.
show ๐๏ธ
show(This, Window) -> boolean()
show(This, Index) -> boolean()
show(This, Show) -> ok
Types:
This = wxSizer()
Show = boolean()
show(This, Window, Options :: [Option]) -> boolean()
show(This, Index, Options :: [Option]) -> boolean()
Types:
This = wxSizer()
Index = integer()
Option = {show, boolean()}
Shows the item at Index โ come back to the light, bestie ๐.
To make a sizer item disappear or reappear, use show/3 followed by layout/1 โ the two-step combo, iykyk ๐
.
Returns true if the child item was found, false otherwise ๐.
See: hide/3, isShown/2 ๐ฆ
showItems ๐
showItems(This, Show) -> ok
Types:
This = wxSizer()
Show = boolean()
Show or hide all the items managed by the sizer in one go โ mass reveal, mass vanish, chaotic but efficient ๐ญโจ.
and that's the whole page, bestie!! ๐โจ every flag, every type, every warning, all of it, no skips, no cap ๐
this lil masterpiece was served up by the wxWidgets team ๐ โ version wx 2.2.2.1 โ and it's filed under wxSizer(3erl), so you'll always know where to find it ๐ซถ๐
๐ฆ where this page comes from
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4 ยท Apache-2.0
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4.8 ยท Apache-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms