wxToolBar(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

πŸŽ€ 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 with wxTB_TEXT.
  • wxTB_HORZ_TEXT β€” combination of wxTB_HORZ_LAYOUT and wxTB_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 of wxTB_HORIZONTAL and wxTB_FLAT. This style is new since wxWidgets 2.9.5. See also overview_windowstyles. Note that the wxMSW native toolbar ignores the wxTB_NOICONS style. Also, toggling the wxTB_TEXT works only if the style was initially on. πŸ™ˆ

See: Overview toolbar

This class is derived, and can use functions, from:

  • wxControl
  • wxWindow
  • wxEvtHandler

wxWidgets docs: wxToolBar

πŸ’œ Events

Event types emitted from this class:

  • command_tool_rclicked
  • command_tool_enter
  • tool_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 with wxMAC_USE_NATIVE_TOOLBAR set to 1.

⭐ 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/6
  • setToolSeparation/2
  • addStretchableSpace/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/6
  • addSeparator/1
  • insertStretchableSpace/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/1
  • addCheckTool/5
  • addRadioTool/5
  • insertTool/6
  • deleteTool/2
  • realize/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/1
  • addCheckTool/5
  • addRadioTool/5
  • insertTool/6
  • deleteTool/2
  • realize/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/1
  • addCheckTool/5
  • addRadioTool/5
  • insertTool/6
  • deleteTool/2
  • realize/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/2
  • toggleTool/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/2
  • getToolSize/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/3
  • setToolShortHelp/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/2
  • setToolShortHelp/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/2
  • getToolBitmapSize/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/3
  • insertTool/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/1
  • insertTool/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/6
  • insertSeparator/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/6
  • insertControl/4
  • insertSeparator/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/1
  • getToolSize/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/2
  • setToolShortHelp/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/2
  • setToolLongHelp/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