wxToolBar(3)
π wxToolBar π β Erlang Module Definition, bestie
okay so we're doing wxToolBar from the Erlang module definitions, and this is part ONE of three, so don't go anywhere π It's a big one and it's lowkey iconic.
β¨ NAME β¨
wxToolBar β a toolbar is a bar of buttons and/or other controls, usually chilling right below the menu bar in a wxFrame. π«Ά
πΈ DESCRIPTION πΈ
You may create a toolbar that's managed by a frame by calling wxFrame:createToolBar/2. And listen β under Pocket PC you should always use this function for creating the toolbar that the frame manages, so that wxWidgets can use a combined menubar and toolbar. Where you're out here managing your own toolbars yourself, create wxToolBar as usual. no cap.
There are several different types of tools you can add to a toolbar. These types are controlled by the ?wxItemKind enumeration. β¨
Note that many methods in wxToolBar β like addTool/6 β return a wxToolBarToolBase* object. Treat this as an opaque handle representing the newly added toolbar item, and it's your little key to that item's id and its position within the toolbar. If you wanna change the item's state, do it through calls to wxToolBar methods, for example enableTool/3. Calls to wxToolBarToolBase methods (which aren't implemented in wx) and which are undocumented on purpose will not change the visible state of the item inside the toolbar. so don't @ them, they won't do anything π
After you've added all the tools you need, you must call realize/1 to actually construct and display the toolbar. That's the moment it becomes visible. periodt.
wxMSW note: Under wxMSW, the toolbar paints tools to reflect system-wide colours. So if you use more than 16 colours in your tool bitmaps, you might wanna suppress this behaviour β otherwise system colours in your bitmaps will inadvertently get mapped to system colours. π To do this, set the msw.remap system option before creating the toolbar. And if you wish to use 32-bit images (which include an alpha channel for transparency), that's another option to reach for. Then colour remapping is switched off, and a transparent background is used. But β οΈ only use this option under Windows XP with true colour.
π¦ Styles
This class supports the following styles:
wxTB_FLATβ gives the toolbar a flat look (Windows and GTK only).wxTB_DOCKABLEβ makes the toolbar floatable and dockable (GTK only).wxTB_HORIZONTALβ specifies horizontal layout (this is the default).wxTB_VERTICALβ specifies vertical layout.wxTB_TEXTβ shows the text in the toolbar buttons; by default only icons are shown.wxTB_NOICONSβ specifies no icons in the toolbar buttons; by default they are shown.wxTB_NODIVIDERβ specifies no divider (border) above the toolbar (Windows only).wxTB_NOALIGNβ specifies no alignment with the parent window (Windows only, not very useful, ngl).wxTB_HORZ_LAYOUTβ shows the text and the icons alongside each other, not vertically stacked (Windows and GTK 2 only). This style must be used withwxTB_TEXT.wxTB_HORZ_TEXTβ combination ofwxTB_HORZ_LAYOUTandwxTB_TEXT.wxTB_NO_TOOLTIPSβ don't show the short help tooltips for the tools when the mouse hovers over them.wxTB_BOTTOMβ align the toolbar at the bottom of the parent window.wxTB_RIGHTβ align the toolbar at the right side of the parent window.wxTB_DEFAULT_STYLEβ combination ofwxTB_HORIZONTALandwxTB_FLAT. This style is new since wxWidgets 2.9.5. See alsooverview_windowstyles. Note that the wxMSW native toolbar ignores thewxTB_NOICONSstyle. Also, toggling thewxTB_TEXTworks only if the style was initially on. π
See: Overview toolbar
This class is derived, and can use functions, from:
wxControlwxWindowwxEvtHandler
wxWidgets docs: wxToolBar
π Events
Event types emitted from this class:
command_tool_rclickedcommand_tool_entertool_dropdown
π DATA TYPES π
wxToolBar() :: wx:wx_object().
π₯ FUNCTIONS π₯
π
addCheckTool/5
addCheckTool(This, ToolId, Label, Bitmap1, [Option]) ->
wx:wx_object()
when
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. β
The parameters are the same as in addTool/6.
See: addTool/6
π addControl/3
addControl(This, Control, [Option]) -> wx:wx_object()
when
This :: wxToolBar(),
Control :: wxControl:wxControl(),
Option :: {label, unicode:chardata()}.
Adds any control to the toolbar β typically, like, a wxComboBox. it's giving versatile π«Ά
Remark: wxMac: labels are only displayed if wxWidgets is built withwxMAC_USE_NATIVE_TOOLBARset to1.
β addRadioTool/5
addRadioTool(This, ToolId, Label, Bitmap1, [Option]) ->
wx:wx_object()
when
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 such that exactly one button in the group is pressed at any moment β in other words, whenever a button in the group gets pressed, the previously pressed button is automatically released. And bestie, you should avoid having radio groups of only one element, because it would be impossible for the user to use such a button. π don't do that to them.
By default, the first button in the radio group is initially pressed, and the others are not.
See: addTool/6
π addSeparator/1
addSeparator(This) -> wx:wx_object() when 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 entirely. it's giving "we'll see" π
See:
addTool/6setToolSeparation/2addStretchableSpace/1
π§ addStretchableSpace/1
addStretchableSpace(This) -> wx:wx_object()
when This :: wxToolBar().
Adds a stretchable space to the toolbar.
Any space not taken up by the fixed items (all items except for stretchable spaces) gets 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, e.g. a stretchable space may be added in the beginning and the end of the toolbar to centre all the toolbar items. main character centring energy π
See:
addTool/6addSeparator/1insertStretchableSpace/2
Since: 2.9.1
π addTool/2
addTool(This, Tool) -> wx:wx_object()
when This :: wxToolBar(), Tool :: wx:wx_object().
Adds a tool to the toolbar.
Remark: After you have added tools to a toolbar, you must call realize/1 in order to have the tools appear.
See:
addSeparator/1addCheckTool/5addRadioTool/5insertTool/6deleteTool/2realize/1
πΈ addTool/5
addTool(This, ToolId, Label, Bitmap, BmpDisabled) ->
wx:wx_object()
when
This :: wxToolBar(),
ToolId :: integer(),
Label :: unicode:chardata(),
Bitmap :: wxBitmap:wxBitmap(),
BmpDisabled :: wxBitmap:wxBitmap();
(This, ToolId, Label, Bitmap, [Option]) -> wx:wx_object()
when
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, the one that specifies the more rarely used button features. β¨
Remark: After you have added tools to a toolbar, you must call realize/1 in order to have the tools appear.
See:
addSeparator/1addCheckTool/5addRadioTool/5insertTool/6deleteTool/2realize/1
π¦ addTool/6
addTool(This, ToolId, Label, Bitmap, BmpDisabled, [Option]) ->
wx:wx_object()
when
This :: wxToolBar(),
ToolId :: integer(),
Label :: unicode:chardata(),
Bitmap :: wxBitmap:wxBitmap(),
BmpDisabled :: wxBitmap:wxBitmap(),
Option ::
{kind, wx:wx_enum()} |
{shortHelp, unicode:chardata()} |
{longHelp, unicode:chardata()} |
{data, wx:wx_object()}.
Adds a tool to the toolbar.
Remark: After you have added tools to a toolbar, you must call realize/1 in order to have the tools appear.
See:
addSeparator/1addCheckTool/5addRadioTool/5insertTool/6deleteTool/2realize/1
π deleteTool/2
deleteTool(This, ToolId) -> boolean()
when This :: wxToolBar(), ToolId :: integer().
Removes the specified tool from the toolbar and deletes it. bye bestie π
If you don't want to delete the tool, but just to remove it from the toolbar (so you can possibly add it back later), you may use removeTool/2 instead. That's the gentler option, fr fr.
Note: It is unnecessary to call realize/1 for the change to take place β it will happen immediately.
Return: true if the tool was deleted, false otherwise.
See: deleteToolByPos/2
π deleteToolByPos/2
deleteToolByPos(This, Pos) -> boolean()
when This :: wxToolBar(), Pos :: integer().
(part 1 stops right here, and part 2 picks it up β don't go nowhere, bestie π«Ά)
okay bestie, this next one is literally deleteTool/2 energy but it deletes the tool at the specified position, not the one with the given id. same chaos, different coordinates, no cap π
π enableTool
enableTool(This, ToolId, Enable) -> ok
when
This :: wxToolBar(),
ToolId :: integer(),
Enable :: boolean().
Enables or disables the tool. that's it, that's the whole job β¨
Remark: some implementations will actually change the visible state of the tool to show it's disabled. so the UI snitches on itself, iconic.
See:
getToolEnabled/2toggleTool/3
π¦ findById
findById(This, Id) -> wx:wx_object()
when This :: wxToolBar(), Id :: integer().
Hands you back a pointer to the tool identified by id, or NULL if there's no matching tool. lowkey just a lookup, but make it fashion.
πΈ findControl
findControl(This, Id) -> wxControl:wxControl()
when This :: wxToolBar(), Id :: integer().
Same deal, but for controls: pointer to the control identified by id, or NULL if nothing matches. bestie went looking, bestie came back empty-handed π
π§ findToolForPosition
findToolForPosition(This, X, Y) -> wx:wx_object()
when
This :: wxToolBar(),
X :: integer(),
Y :: integer().
Finds a tool for the given mouse position. point at a thing, get the thing.
Return: a pointer to a tool if a tool is found, or NULL otherwise.
Remark: currently not implemented in wxGTK (it always returns NULL there). so on GTK it's giving "I don't know her" π
π getMargins
getMargins(This) -> {W :: integer(), H :: integer()}
when This :: wxToolBar().
Returns the left/right and top/bottom margins β which are also the ones used for inter-toolspacing. so it's margins and personal space, one function, two jobs, main character energy π
See: setMargins/3
β getToolBitmapSize
getToolBitmapSize(This) -> {W :: integer(), H :: integer()}
when This :: wxToolBar().
Returns the size of bitmap that the toolbar expects to have.
The default bitmap size is platform-dependent: for example, it's 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, as the bitmap size is deduced automatically from the size of the bitmaps associated with the tools added to the toolbar, it's usually unnecessary to call setToolBitmapSize/2 explicitly. so likeβ¦ relax, it figures itself out π
Remark: note that this is the size of the bitmap you pass to addTool/6, and not the eventual size of the tool button. two different girls entirely.
See:
setToolBitmapSize/2getToolSize/1
π«Ά getToolEnabled
getToolEnabled(This, ToolId) -> boolean()
when This :: wxToolBar(), ToolId :: integer().
Called to determine whether a tool is enabled (aka whether it responds to user input at all).
Return: true if the tool is enabled, false otherwise.
See: enableTool/3
π getToolLongHelp
getToolLongHelp(This, ToolId) -> unicode:charlist()
when This :: wxToolBar(), ToolId :: integer().
Returns the long help for the given tool. the whole essay version π
See:
setToolLongHelp/3setToolShortHelp/3
β¨ getToolPacking
getToolPacking(This) -> integer() when This :: wxToolBar().
Returns the value used for packing tools. yes, packing. it's a whole thing.
See: setToolPacking/2
π getToolPos
getToolPos(This, ToolId) -> integer()
when This :: wxToolBar(), ToolId :: integer().
Returns the tool position in the toolbar β or wxNOT_FOUND if the tool is not found. and honestly same, king π
π getToolSeparation
getToolSeparation(This) -> integer() when This :: wxToolBar().
Returns the default separator size.
See: setToolSeparation/2
πΈ getToolShortHelp
getToolShortHelp(This, ToolId) -> unicode:charlist()
when This :: wxToolBar(), ToolId :: integer().
Returns the short help for the given tool. the TL;DR version, we love her.
See:
getToolLongHelp/2setToolShortHelp/3
π getToolSize
getToolSize(This) -> {W :: integer(), H :: integer()}
when This :: wxToolBar().
Returns the size of a whole button β which is usually larger than a tool bitmap because of the added 3D effects. it's the bitmap but with β¨accessoriesβ¨
See:
setToolBitmapSize/2getToolBitmapSize/1
β getToolState
getToolState(This, ToolId) -> boolean()
when This :: wxToolBar(), ToolId :: integer().
Gets the on/off state of a toggle tool. is she toggled or is she not.
Return: true if the tool is toggled on, false otherwise.
See: toggleTool/3
π§ insertControl
insertControl(This, Pos, Control, [Option]) -> wx:wx_object()
when
This :: wxToolBar(),
Pos :: integer(),
Control :: wxControl:wxControl(),
Option :: {label, unicode:chardata()}.
Inserts the control into the toolbar at the given position. slipping her in at exactly slot Pos, no queue-jumping π
Important: you must call realize/1 for the change to actually take place. nothing happens until you do, periodt.
See:
addControl/3insertTool/6
π insertSeparator
insertSeparator(This, Pos) -> wx:wx_object()
when This :: wxToolBar(), Pos :: integer().
Inserts the separator into the toolbar at the given position. a little visual break, a little breathe, she serves looks.
Important: you must call realize/1 for the change to take place.
See:
addSeparator/1insertTool/6
π¦ insertStretchableSpace
insertStretchableSpace(This, Pos) -> wx:wx_object()
when
This :: wxToolBar(),
Pos :: integer().
Inserts a stretchable space at the given position. it stretches. it spaces. she's flexible, she's booked, she's busy.
See addStretchableSpace/1 for details about stretchable spaces β the lore is over there.
See:
insertTool/6insertSeparator/2
Since: 2.9.1 π
π§ insertTool (overload one: This, Pos, Tool)
insertTool(This, Pos, Tool) -> wx:wx_object()
when
This :: wxToolBar(),
Pos :: integer(),
Tool :: wx:wx_object().
π§ insertTool (overload two: This, Pos, ToolId, Label, Bitmap, [Option])
insertTool(This, Pos, ToolId, Label, Bitmap, [Option]) ->
wx:wx_object()
when
This :: wxToolBar(),
Pos :: integer(),
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. all the little details, all the little options, glued in at slot Pos π
Important: you must call realize/1 for the change to take place.
See:
addTool/6insertControl/4insertSeparator/2
Return: the newly inserted tool, or NULL on failure. β οΈ notice that with the overload taking the tool parameter, the caller is responsible for deleting the tool in the latter case. yes, that means you. don't leave her stranded.
π realize
realize(This) -> boolean() when This :: wxToolBar().
This function should be called after you have added tools. like, that's the whole instruction. add tools, then say realize, then the toolbar wakes up and serves π«Ά
π removeTool
removeTool(This, Id) -> wx:wx_object()
when This :: wxToolBar(), Id :: integer().
Removes the given tool from the toolbar but doesn't delete it. she's not gone, she's just not on stage right now.
This allows inserting/adding this tool back to this (or another) toolbar later. so she can come back. redemption arc available. π
Note: it is unnecessary to call realize/1 for the change to take place β it will happen immediately. no waiting, she's fast.
See: deleteTool/2
πΈ setMargins
setMargins(This, X, Y) -> ok
when
This :: wxToolBar(),
X :: integer(),
Y :: integer().
Set the values to be used as margins for the toolbar. boundaries, bestie. she has them.
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, do not test her.
See: getMargins/1
β setToolBitmapSize
setToolBitmapSize(This, Size) -> ok
when
This :: wxToolBar(),
Size :: {W :: integer(), H :: integer()}.
Sets the default size of each tool bitmap.
The default bitmap size is 16 by 15 pixels. (that's W = 16, H = 15, in case the math was mathing too hard.)
Remark: this should be called to tell the toolbar what the tool bitmap size is. call it before you add tools. she needs to know in advance, she likes to be prepared.
See:
getToolBitmapSize/1getToolSize/1
π setToolLongHelp
setToolLongHelp(This, ToolId, HelpString) -> ok
when
This :: wxToolBar(),
ToolId :: integer(),
HelpString :: unicode:chardata().
Sets the long help for the given tool. the full paragraph, the director's cut.
Remark: you might use the long help for displaying the tool purpose on the status line. very demure, very status-bar.
See:
getToolLongHelp/2setToolShortHelp/3
β¨ setToolPacking
setToolPacking(This, Packing) -> ok
when This :: wxToolBar(), Packing :: integer().
Sets the value used for spacing tools.
The default value is 1. precious little number.
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. yes, it flips. yes, that's on purpose, iykyk.
See: getToolPacking/1
π setToolSeparation
setToolSeparation(This, Separation) -> ok
when
This :: wxToolBar(),
Separation :: integer().
Sets the default separator size.
The default value is 5. and that's canon.
See: addSeparator/1
π«Ά setToolShortHelp
setToolShortHelp(This, ToolId, HelpString) -> ok
when
This :: wxToolBar(),
ToolId :: integer(),
HelpString :: unicode:chardata().
Sets the short help for the given tool. short, sweet, to the point β her texting style fr.
Remark: an application might use short help for identifying the tool purpose in a tooltip. hover and be served.
See:
getToolShortHelp/2setToolLongHelp/3
π toggleTool
toggleTool(This, ToolId, Toggle) -> ok
when
This :: wxToolBar(),
ToolId :: integer(),
Toggle :: boolean().
Toggles a tool on or off. on. off. on. off. she contains multitudes π
okay so quick lil heads up before you go calling this everywhere: it does not cause any event to get emitted. like β no event. nada. nothing gets fired. the vibe stays completely silent π β¨
Remark: this one only applies to a tool that has been specified as a toggle tool. that's the whole club. if your tool isn't a toggle tool, this note isn't about you, bestie π
and that's the page, fr fr π«Ά go forth and toolbar, you icon π
<div align="left">
source: Ericsson AB Β· version wx 2.6 Β· page wxToolBar(3) β mwah, stan this manpage, bye ππ
</div>
π¦ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms