wxToolBar(3erl)

πŸ’– wxToolBar β€” the Erlang module def, bestie edition πŸ’–

okay so this is wxToolBar from the 3erl manuals, and honestly? it's giving "toolbar supremacy" and i'm obsessed. let's get into it πŸ’…


✨ NAME ✨

wxToolBar β€” literally just the functions for the wxToolBar class, no cap 🫢


🌸 DESCRIPTION 🌸

A toolbar is a bar of buttons and/or other controls, usually placed below the menu bar in a wxFrame. iconic placement, we love to see it ✨

You may create a toolbar that is managed by a frame by calling wxFrame:createToolBar/2. Under Pocket PC, you should always use this function for creating the toolbar that's managed by the frame, so that wxWidgets can use a combined menubar and toolbar. Where you manage your own toolbars, just create wxToolBar as usual, bestie πŸ’–

There are several different types of tools you can add to a toolbar. These types are controlled by the ?wxItemKind enumeration. yes queen, enumeration πŸŽ€

⚠️ Heads up: many methods in wxToolBar β€” like addTool/6 β€” return a wxToolBarToolBase* object. Treat that as an opaque handle representing the newly added toolbar item, giving you access to its id and its position within the toolbar. Any changes to the item's state should go through calls to wxToolBar methods, like enableTool/3. Calls to wxToolBarToolBase methods (not implemented in wx) β€” which are undocumented on purpose β€” will not change the visible state of the item within the toolbar. so don't come crying to me when it doesn't work, i warned you 😭

After you've added all the tools you need, you must call realize/1 to actually construct and display the toolbar. like, it's not optional. periodt πŸ”₯

wxMSW note, and this one matters: under wxMSW the toolbar paints tools to reflect system-wide colours. If you use more than 16 colours in your tool bitmaps, you may wish to suppress this behaviour β€” otherwise system colours in your bitmaps will inadvertently be mapped to system colours. To do this, set the msw.remap system option before creating the toolbar. If you wish to use 32-bit images (which include an alpha channel for transparency), use that too. Then colour remapping is switched off, and a transparent background is used. But only use this option under Windows XP with true colour. i'm not kidding around about this one πŸ’€

πŸ¦‹ Styles πŸ¦‹

This class supports the following styles: (that's it, that's the list, the original says the same thing and i refuse to invent styles for you bestie πŸ™ˆ)

See: Overview toolbar

This class is derived (and can use functions) from: wxControl wxWindow wxEvtHandler β€” three parents, main character energy fr fr πŸ‘‘

wxWidgets docs: wxToolBar


πŸŽ€ EVENTS πŸŽ€

Event types emitted from this class: command_tool_rclicked, command_tool_enter, tool_dropdown 🌈


πŸ’œ DATA TYPES πŸ’œ

wxToolBar() = wx:wx_object()

⭐ EXPORTS ⭐

🌸 addControl(This, Control) -> wx:wx_object()

Types:

This = wxToolBar()
Control = wxControl:wxControl()

🌸 addControl(This, Control, Options :: [Option]) -> wx:wx_object()

Types:

This = wxToolBar()
Control = wxControl:wxControl()
Option = {label, unicode:chardata()}

Adds any control to the toolbar β€” typically e.g. a wxComboBox. versatile icon ✨

Remark: wxMac: labels are only displayed if wxWidgets is built with wxMAC_USE_NATIVE_TOOLBAR set to 1. that's the rule, don't shoot the messenger 😭

πŸŽ€ addSeparator(This) -> wx:wx_object()

Types:

This = wxToolBar()

Adds a separator for spacing groups of tools.

Notice that the separator uses the look appropriate for the current platform, so it can be a vertical line (MSW, some versions of GTK) or just an empty space or something else. it's giving "platform agnostic aesthetic" πŸ’…

See: addTool/6, setToolSeparation/2, addStretchableSpace/1


πŸ¦‹ addTool(This, Tool) -> wx:wx_object()

Types:

This = wxToolBar()
Tool = wx:wx_object()

Adds a tool to the toolbar.

Remark: After you've added tools to a toolbar, you must call realize/1 in order to have the tools appear. yes, again. it's that important πŸ’–

See: addSeparator/1, addCheckTool/5, addRadioTool/5, insertTool/6, deleteTool/2, realize/1, SetDropdownMenu() (not implemented in wx)


πŸ¦‹ addTool(This, ToolId, Label, Bitmap) -> wx:wx_object()

Types:

This = wxToolBar()
ToolId = integer()
Label = unicode:chardata()
Bitmap = wxBitmap:wxBitmap()

πŸ¦‹ addTool(This, ToolId, Label, Bitmap, BmpDisabled) -> wx:wx_object()

πŸ¦‹ addTool(This, ToolId, Label, Bitmap, BmpDisabled :: [Option]) -> wx:wx_object()

Types:

This = wxToolBar()
ToolId = integer()
Label = unicode:chardata()
Bitmap = wxBitmap:wxBitmap()
Option = {shortHelp, unicode:chardata()} | {kind, wx:wx_enum()}

Adds a tool to the toolbar.

This most commonly used version has fewer parameters than the full version below, which specifies the more rarely used button features. lowkey the "lite" edition 🀏

Remark: After you've added tools to a toolbar, you must call realize/1 in order to have the tools appear.

See: addSeparator/1, addCheckTool/5, addRadioTool/5, insertTool/6, deleteTool/2, realize/1, SetDropdownMenu() (not implemented in wx)


πŸ”₯ addTool(This, ToolId, Label, Bitmap, BmpDisabled, Options :: [Option]) -> wx:wx_object()

Types:

This = wxToolBar()
ToolId = integer()
Label = unicode:chardata()
Bitmap = BmpDisabled = wxBitmap:wxBitmap()
Option =
    {kind, wx:wx_enum()} |
    {shortHelp, unicode:chardata()} |
    {longHelp, unicode:chardata()} |
    {data, wx:wx_object()}

Adds a tool to the toolbar β€” this is the full-feature deluxe version, the one with all the options. main character behaviour honestly ✨

Remark: After you've added tools to a toolbar, you must call realize/1 in order to have the tools appear.

See: addSeparator/1, addCheckTool/5, addRadioTool/5, insertTool/6, deleteTool/2, realize/1, SetDropdownMenu() (not implemented in wx)


🌈 addCheckTool(This, ToolId, Label, Bitmap1) -> wx:wx_object()

Types:

This = wxToolBar()
ToolId = integer()
Label = unicode:chardata()
Bitmap1 = wxBitmap:wxBitmap()

🌈 addCheckTool(This, ToolId, Label, Bitmap1, Options :: [Option]) -> wx:wx_object()

Types:

This = wxToolBar()
ToolId = integer()
Label = unicode:chardata()
Bitmap1 = wxBitmap:wxBitmap()
Option =
    {bmpDisabled, wxBitmap:wxBitmap()} |
    {shortHelp, unicode:chardata()} |
    {longHelp, unicode:chardata()} |
    {data, wx:wx_object()}

Adds a new check (or toggle) tool to the toolbar. check it, toggle it, slay it πŸ’…

The parameters are the same as in addTool/6.

See: addTool/6


🌟 addRadioTool(This, ToolId, Label, Bitmap1) -> wx:wx_object()

Types:

This = wxToolBar()
ToolId = integer()
Label = unicode:chardata()
Bitmap1 = wxBitmap:wxBitmap()

🌟 addRadioTool(This, ToolId, Label, Bitmap1, Options :: [Option]) -> wx:wx_object()

Types:

This = wxToolBar()
ToolId = integer()
Label = unicode:chardata()
Bitmap1 = wxBitmap:wxBitmap()
Option =
    {bmpDisabled, wxBitmap:wxBitmap()} |
    {shortHelp, unicode:chardata()} |
    {longHelp, unicode:chardata()} |
    {data, wx:wx_object()}

Adds a new radio tool to the toolbar.

Consecutive radio tools form a radio group, so that exactly one button in the group is pressed at any moment β€” in other words, whenever a button in the group is pressed, the previously pressed button is automatically released. it's giving "only one of us can be the main character at a time" 😀

You should avoid having radio groups of only one element, since it would be impossible for the user to use such a button. a group of one is just a sad little solo act, don't do it πŸ™ˆ

By default, the first button in the radio group is initially pressed, and the others are not.

See: addTool/6


πŸ¦‹ addStretchableSpace(This) -> wx:wx_object()

Types:

This = wxToolBar()

Adds a stretchable space to the toolbar.

Any space not taken up by the fixed items (all items except for stretchable spaces) is distributed in equal measure between the stretchable spaces in the toolbar. The most common use for this method is to add a single stretchable space before the items which should be right-aligned in the toolbar, but more exotic possibilities are possible too β€” e.g. a stretchable space may be added at the beginning and the end of the toolbar to centre all toolbar items. flexible queen behaviour, we stan 🌸

See: addTool/6, addSeparator/1, insertStretchableSpace/2

Since: 2.9.1


πŸŽ€ insertStretchableSpace(This, Pos) -> wx:wx_object()

Types:

This = wxToolBar()
Pos = integer()

Inserts a stretchable space at the given position.

See addStretchableSpace/1 for details about stretchable spaces.

See: insertTool/6, insertSeparator/2

Since: 2.9.1


πŸ’€ deleteTool(This, ToolId) -> boolean()

Types:

This = wxToolBar()
ToolId = integer()

Removes the specified tool from the toolbar and deletes it. gone, deleted, erased, not me crying 😭

If you don't want to delete the tool but just want to remove it from the toolbar (to possibly add it back later), you may use removeTool/2 instead. different vibe entirely, bestie.

Note: It is unnecessary to call realize/1 for the change to take place β€” it will happen immediately. no waiting, instant gratification ✨

Return: true if the tool was deleted, false otherwise.

See: deleteToolByPos/2


πŸ’€ deleteToolByPos(This, Pos) -> boolean()

Types:

This = wxToolBar()
Pos = integer()

This function behaves like deleteTool/2, but it deletes the tool at the specified position and not the one with the given id. subtle but crucial difference, iykyk πŸ’…


⭐ enableTool(This, ToolId, Enable) -> ok

Types:

This = wxToolBar()
ToolId = integer()
Enable = boolean()

Enables or disables the tool. the power to grant and revoke, honestly πŸ‘‘

Remark: Some implementations will change the visible state of the tool to indicate that it's disabled.

See: getToolEnabled/2, toggleTool/3


πŸ” findById(This, Id) -> wx:wx_object()

Types:

This = wxToolBar()
Id = integer()

Returns a pointer to the tool identified by id, or NULL if no corresponding tool is found. it's giving "i looked everywhere and they're not here" πŸ’€


πŸ” findControl(This, Id) -> wxControl:wxControl()

Types:

This = wxToolBar()
Id = integer()

Returns a pointer to the control identified by id, or NULL if no corresponding control is found.


πŸ” findToolForPosition(This, X, Y) -> wx:wx_object()

Types:

This = wxToolBar()
X = Y = integer()

Finds a tool for the given mouse position. detective mode activated πŸ•΅οΈβ€β™€οΈ

Return: A pointer to a tool if a tool is found, or NULL otherwise.

Remark: Currently not implemented in wxGTK (always returns NULL there). πŸ’€

getToolSize(This) -> {W :: integer(), H :: integer()} ✨

Types:

This = wxToolBar()

Okay so this one gives you the size of a whole button β€” and bestie, that’s usually larger than a tool bitmap because of the added 3D effects. It’s giving β€œbutton with extra drama,” periodt. πŸ’…

See: setToolBitmapSize/2, getToolBitmapSize/1


getToolBitmapSize(This) -> {W :: integer(), H :: integer()} πŸ¦‹

Types:

This = wxToolBar()

Returns the size of bitmap that the toolbar expects to have. The default bitmap size is platform-dependent: for example, it is 16*15 for MSW and 24*24 for GTK. This size does not necessarily indicate the best size to use for the toolbars on the given platform β€” for that you should use wxArtProvider::GetNativeSizeHint(wxART_TOOLBAR) β€” but in any case, since the bitmap size is deduced automatically from the size of the bitmaps associated with the tools added to the toolbar, it is usually unnecessary to call setToolBitmapSize/2 explicitly. πŸŽ€

Remark: Note that this is the size of the bitmap you pass to addTool/6, and not the eventual size of the tool button. 😭

See: setToolBitmapSize/2, getToolSize/1


getMargins(This) -> {W :: integer(), H :: integer()} 🌸

Types:

This = wxToolBar()

Returns the left/right and top/bottom margins, which are also used for inter-toolspacing. Cute little spacing math, no cap. ✨

See: setMargins/3


getToolEnabled(This, ToolId) -> boolean() πŸ’–

Types:

This = wxToolBar()
ToolId = integer()

Called to determine whether a tool is enabled (responds to user input). Return: true if the tool is enabled, false otherwise. Vibe check for tools, basically. 🫢

See: enableTool/3


getToolLongHelp(This, ToolId) -> unicode:charlist() πŸ“

Types:

This = wxToolBar()
ToolId = integer()

Returns the long help for the given tool.

See: setToolLongHelp/3, setToolShortHelp/3


getToolPacking(This) -> integer() 🎁

Types:

This = wxToolBar()

Returns the value used for packing tools.

See: setToolPacking/2


getToolPos(This, ToolId) -> integer() πŸ”Ž

Types:

This = wxToolBar()
ToolId = integer()

Returns the tool position in the toolbar, or wxNOT_FOUND if the tool is not found. The β€œwhere is it bestie” function. πŸ’…


getToolSeparation(This) -> integer() πŸ“

Types:

This = wxToolBar()

Returns the default separator size.

See: setToolSeparation/2


getToolShortHelp(This, ToolId) -> unicode:charlist() πŸŽ€

Types:

This = wxToolBar()
ToolId = integer()

Returns the short help for the given tool.

See: getToolLongHelp/2, setToolShortHelp/3


getToolState(This, ToolId) -> boolean() πŸ‘‘

Types:

This = wxToolBar()
ToolId = integer()

Gets the on/off state of a toggle tool. Return: true if the tool is toggled on, false otherwise. Toggle girlies stay winning. ✨

See: toggleTool/3


insertControl πŸ’«

Overload 1:

insertControl(This, Pos, Control) -> wx:wx_object()

Types:

This = wxToolBar()
Pos = integer()
Control = wxControl:wxControl()

Overload 2:

insertControl(This, Pos, Control, Options :: [Option]) ->
                 wx:wx_object()

Types:

This = wxToolBar()
Pos = integer()
Control = wxControl:wxControl()
Option = {label, unicode:chardata()}

Inserts the control into the toolbar at the given position.

You must call realize/1 for the change to take place. Don’t skip that step, bestie β€” it’s the β€œactually apply it” moment. πŸͺ„

See: addControl/3, insertTool/6


insertSeparator(This, Pos) -> wx:wx_object() 🎯

Types:

This = wxToolBar()
Pos = integer()

Inserts the separator into the toolbar at the given position.

You must call realize/1 for the change to take place.

See: addSeparator/1, insertTool/6


insertTool πŸ”₯

Overload 1:

insertTool(This, Pos, Tool) -> wx:wx_object()

Types:

This = wxToolBar()
Pos = integer()
Tool = wx:wx_object()

Overload 2:

insertTool(This, Pos, ToolId, Label, Bitmap) -> wx:wx_object()

Types:

This = wxToolBar()
Pos = ToolId = integer()
Label = unicode:chardata()
Bitmap = wxBitmap:wxBitmap()

Overload 3:

insertTool(This, Pos, ToolId, Label, Bitmap, Options :: [Option]) ->
             wx:wx_object()

Types:

This = wxToolBar()
Pos = ToolId = integer()
Label = unicode:chardata()
Bitmap = wxBitmap:wxBitmap()
Option =
    {bmpDisabled, wxBitmap:wxBitmap()} |
    {kind, wx:wx_enum()} |
    {shortHelp, unicode:chardata()} |
    {longHelp, unicode:chardata()} |
    {clientData, wx:wx_object()}

Inserts the tool with the specified attributes into the toolbar at the given position.

You must call realize/1 for the change to take place. It’s giving β€œadd it, then make it real.” πŸ’…

See: addTool/6, insertControl/4, insertSeparator/2

Return: The newly inserted tool or NULL on failure. Notice that with the overload taking tool parameter the caller is responsible for deleting the tool in the latter case.


realize(This) -> boolean() ✨

Types:

This = wxToolBar()

This function should be called after you have added tools. It’s the final β€œgo live” button, basically. 🎬


removeTool(This, Id) -> wx:wx_object() 🧚

Types:

This = wxToolBar()
Id = integer()

Removes the given tool from the toolbar but doesn’t delete it.

This allows inserting/adding this tool back to this (or another) toolbar later. Reuse era! πŸŽ€

Note: It is unnecessary to call realize/1 for the change to take place, it will happen immediately.

See: deleteTool/2


setMargins(This, X, Y) -> ok 🌈

Types:

This = wxToolBar()
X = Y = integer()

Set the values to be used as margins for the toolbar.

Remark: This must be called before the tools are added if absolute positioning is to be used, and the default (zero-size) margins are to be overridden. Order matters, bestie. 😭

See: getMargins/1


setToolBitmapSize(This, Size) -> ok 🎨

Types:

This = wxToolBar()
Size = {W :: integer(), H :: integer()}

Sets the default size of each tool bitmap.

The default bitmap size is 16 by 15 pixels.

Remark: This should be called to tell the toolbar what the tool bitmap size is. Call it before you add tools.

See: getToolBitmapSize/1, getToolSize/1


setToolLongHelp(This, ToolId, HelpString) -> ok πŸ“–

Types:

This = wxToolBar()
ToolId = integer()
HelpString = unicode:chardata()

Sets the long help for the given tool.

Remark: You might use the long help for displaying the tool purpose on the status line.

See: getToolLongHelp/2, setToolShortHelp/3


setToolPacking(This, Packing) -> ok 🎁

Types:

This = wxToolBar()
Packing = integer()

Sets the value used for spacing tools.

The default value is 1.

Remark: The packing is used for spacing in the vertical direction if the toolbar is horizontal, and for spacing in the horizontal direction if the toolbar is vertical.

See: getToolPacking/1


setToolShortHelp(This, ToolId, HelpString) -> ok πŸ’¬

Types:

This = wxToolBar()
ToolId = integer()
HelpString = unicode:chardata()

Sets the short help for the given tool.

Remark: An application might use short help for identifying the tool purpose in a tooltip.

See: getToolShortHelp/2, setToolLongHelp/3


setToolSeparation(This, Separation) -> ok πŸ“

Types:

This = wxToolBar()
Separation = integer()

Sets the default separator size.

The default value is 5.

See: addSeparator/1


toggleTool(This, ToolId, Toggle) -> ok πŸ¦‹

Types:

This = wxToolBar()
ToolId = integer()
Toggle = boolean()

Toggles a tool on or off.

This does not cause any event to get emitted. Silent but iconic. 🀫

Remark: Only applies to a tool that has been specified as a toggle tool.

Okay that’s the whole page, bestie! Footer says wxWidgets team Β· wx 2.2.2.1 Β· wxToolBar(3erl) β€” slay. πŸ’–βœ¨

πŸ“¦ where this page comes from