A toolbar is a bar of buttons and/or other controls usually placed below the menu bar in a wxFrame.
You may create a toolbar that is managed by a frame calling wxFrame:createToolBar/2. Under Pocket PC, you should always use this function for creating the toolbar to be managed by the frame, so that wxWidgets can use a combined menubar and toolbar. Where you manage your own toolbars, create wxToolBar as usual.
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 such as addTool/6 return a wxToolBarToolBase* object. This should be regarded as an opaque handle representing the newly added toolbar item, providing access to its id and position within the toolbar. Changes to the item's state should be made through calls to wxToolBar methods, for example enableTool/3. Calls to wxToolBarToolBase (not implemented in wx) methods (undocumented by purpose) will not change the visible state of the item within the tool bar.
After you have added all the tools you need, you must call realize/1 to effectively construct and display the toolbar.
wxMSW note: Note that under wxMSW 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: Then colour remapping is switched off, and a transparent background used. But only use this option under Windows XP with true colour:
This class supports the following styles:
See: Overview toolbar
wxWidgets docs: wxToolBar
addControl(This, Control) -> wx:wx_object()
addControl(This, Control, Options :: [Option]) -> wx:wx_object()
Adds any control to the toolbar, typically e.g. a wxComboBox.
Remark: wxMac: labels are only displayed if wxWidgets is built with wxMAC_USE_NATIVE_TOOLBAR set to 1
addSeparator(This) -> wx:wx_object()
addTool(This, Tool) -> wx:wx_object()
addTool(This, ToolId, Label, Bitmap) -> wx:wx_object()
addTool(This, ToolId, Label, Bitmap, BmpDisabled) ->
addTool(This, ToolId, Label, Bitmap, BmpDisabled :: [Option]) ->
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.
Remark: After you have added tools to a toolbar, you must call realize/1 in order to have the tools appear.
addTool(This, ToolId, Label, Bitmap, BmpDisabled,
Options :: [Option]) ->
addCheckTool(This, ToolId, Label, Bitmap1) -> wx:wx_object()
addCheckTool(This, ToolId, Label, Bitmap1, Options :: [Option]) ->
addRadioTool(This, ToolId, Label, Bitmap1) -> wx:wx_object()
addRadioTool(This, ToolId, Label, Bitmap1, Options :: [Option]) ->
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 is pressed the previously pressed button is automatically released. You should avoid having the radio groups of only one element as it would be impossible for the user to use such button.
By default, the first button in the radio group is initially pressed, the others are not.
addStretchableSpace(This) -> wx:wx_object()
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, e.g. a stretchable space may be added in the beginning and the end of the toolbar to centre all toolbar items.
insertStretchableSpace(This, Pos) -> wx:wx_object()
deleteTool(This, ToolId) -> boolean()
Removes the specified tool from the toolbar and deletes it.
If you don't want to delete the tool, but just to remove it from the toolbar (to possibly add it back later), you may use removeTool/2 instead.
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.
deleteToolByPos(This, Pos) -> boolean()
This function behaves like deleteTool/2 but it deletes the tool at the specified position and not the one with the given id.
enableTool(This, ToolId, Enable) -> ok
findById(This, Id) -> wx:wx_object()
Returns a pointer to the tool identified by id or NULL if no corresponding tool is found.
findControl(This, Id) -> wxControl:wxControl()
Returns a pointer to the control identified by id or NULL if no corresponding control is found.
findToolForPosition(This, X, Y) -> wx:wx_object()
Finds a tool for the given mouse position.
Return: A pointer to a tool if a tool is found, or NULL otherwise.
Remark: Currently not implemented in wxGTK (always returns NULL there).
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 this 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 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.
Returns the left/right and top/bottom margins, which are also used for inter-toolspacing.
getToolEnabled(This, ToolId) -> boolean()
Called to determine whether a tool is enabled (responds to user input).
Return: true if the tool is enabled, false otherwise.
getToolLongHelp(This, ToolId) -> unicode:charlist()
getToolPacking(This) -> integer()
Returns the value used for packing tools.
getToolPos(This, ToolId) -> integer()
Returns the tool position in the toolbar, or wxNOT_FOUND if the tool is not found.
getToolSeparation(This) -> integer()
Returns the default separator size.
getToolShortHelp(This, ToolId) -> unicode:charlist()
getToolState(This, ToolId) -> boolean()
Gets the on/off state of a toggle tool.
Return: true if the tool is toggled on, false otherwise.
insertControl(This, Pos, Control) -> wx:wx_object()
insertControl(This, Pos, Control, Options :: [Option]) ->
insertSeparator(This, Pos) -> wx:wx_object()
insertTool(This, Pos, Tool) -> wx:wx_object()
insertTool(This, Pos, ToolId, Label, Bitmap) -> wx:wx_object()
insertTool(This, Pos, ToolId, Label, Bitmap, Options :: [Option]) ->
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.
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()
This function should be called after you have added tools.
removeTool(This, Id) -> wx:wx_object()
setMargins(This, X, Y) -> ok
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.
setToolBitmapSize(This, Size) -> ok
setToolLongHelp(This, ToolId, HelpString) -> ok
setToolPacking(This, Packing) -> ok
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.
setToolShortHelp(This, ToolId, HelpString) -> ok
setToolSeparation(This, Separation) -> ok
Sets the default separator size.
The default value is 5.
toggleTool(This, ToolId, Toggle) -> ok
Toggles a tool on or off.
This does not cause any event to get emitted.
Remark: Only applies to a tool that has been specified as a toggle tool.