A ToolBar is a collection of graphical buttons and/or controls which is attached
to the edge of a Wx::Frame. It provides quick access to
one-step application functions, such as opening or saving a file, or
cutting and pasting text.
It has a native style on all platforms; note that on OS X, native
toolbars may only be placed at the top of a Frame. Use
Frame#set_tool_bar to set a toolbar to be managed by a Frame and ensure
native appearance.
You may also create a toolbar that is managed by the frame, by
calling Frame#create_tool_bar. Under Pocket PC,
you should always use this function for creating the toolbar
to be managed by the frame, so that Widgets can use a combined
menubar and toolbar. Where you manage your own toolbars, create a ToolBar
as usual.
The meaning of a “separator” is a vertical line under Windows and simple
space under GTK+.
TB_FLAT |
Gives the toolbar a flat look (Windows and GTK only). |
TB_DOCKABLE |
Makes the toolbar floatable and dockable (GTK only). |
TB_HORIZONTAL |
Specifies horizontal layout (default). |
TB_VERTICAL |
Specifies vertical layout. |
TB_TEXT |
Shows the text in the toolbar buttons; by default only icons are shown. |
TB_NOICONS |
Specifies no icons in the toolbar buttons; by default they are shown. |
TB_NODIVIDER |
Specifies no divider (border) above the toolbar (Windows only). |
TB_NOALIGN |
Specifies no alignment with the parent window (Windows only, not very useful). |
TB_HORZ_LAYOUT |
Shows the text and the icons alongside, not vertically stacked (Windows and GTK2 only). This style must be used with TB_TEXT. |
TB_HORZ_TEXT |
Combination of TB_HORZ_LAYOUT and TB_TEXT. |
TB_NO_TOOLTIPS |
Don’t show the short help tooltips for the tools when the mouse hovers over them. |
TB_BOTTOM |
Align the toolbar at the bottom of parent window. |
TB_RIGHT |
Align the toolbar at the right side of parent window. |
See also window styles overview. Note that the Win32
native toolbar ignores TB_NOICONS
style. Also, toggling the
TB_TEXT
works only if the style was initially on.
Adding and inserting an item (a tool, a check tool, or a radio tool) to a toolbar may be done respectively through ToolBar#add_tool and ToolBar#insert_tool.
A more flexible way is provided by ToolBar#add_item that supports :
The toolbar class emits menu commands in the same way that a frame menubar does,
so you can use one EVT_MENU macro for both a menu item and a toolbar button.
The event handler functions take a CommandEvent argument. For most event macros,
the identifier of the tool is passed, but for EVT_TOOL_ENTER the toolbar
window identifier is passed and the tool identifier is retrieved from the CommandEvent.
This is because the identifier may be -1 when the mouse moves off a tool, and -1 is not
allowed as an identifier in the event system.
evt_tool(id) { | event | … } | Process a EVT_COMMAND_TOOL_CLICKED event(a synonym for EVT_COMMAND_MENU_SELECTED). Pass the id of the tool. |
evt_menu(id) { | event | … } | The same as EVT_TOOL. |
EVT_TOOL_RANGE(id1, id2, func) | Process a EVT_COMMAND_TOOL_CLICKED eventfor a range of identifiers. Pass the ids of the tools. |
EVT_MENU_RANGE(id1, id2, func) | The same as EVT_TOOL_RANGE. |
evt_tool_rclicked(id) { | event | … } | Process a EVT_COMMAND_TOOL_RCLICKED event.Pass the id of the tool. |
EVT_TOOL_RCLICKED_RANGE(id1, id2, func) | Process a EVT_COMMAND_TOOL_RCLICKED eventfor a range of ids. Pass the ids of the tools. |
evt_tool_enter(id) { | event | … } | Process a EVT_COMMAND_TOOL_ENTER event.Pass the id of the toolbar itself. The value of CommandEvent::GetSelection is the tool id, or -1 if the mouse cursor has moved off a tool. |
Toolbar overviewwxtoolbaroverview, ScrolledWindow
Constructs a toolbar.
After a toolbar is created, you use ToolBar#add_tool and
perhaps ToolBar#add_separator, and then you
must call ToolBar#realize to construct and display the toolbar
tools.
You may also create a toolbar that is managed by the frame, by
calling Frame#create_tool_bar.
Toolbar destructor.
Adds any control to the toolbar, typically e.g. a combobox.
Adds a separator for spacing groups of tools.
ToolBar#add_tool, ToolBar#set_tool_separation
Adds or inserts a tool to the toolbar. Returns a ToolBarTool object with
information about the newly added item.
Optional parameters may also be specified by keywords in any order as following :
tool = toolbar.add_item(a_bitmap, :position => 1, :label => “My Button”)
After you have added tools to a toolbar, you must call ToolBar#realize in
order to have the tools appear.
ToolBar#add_separator, ToolBar#add_tool, ToolBar#add_check_tool, ToolBar#add_radio_tool, ToolBar#insert_tool, ToolBar#delete_tool, ToolBar#realize
Adds a tool to the toolbar. Returns a ToolBarTool object with
information about the newly added item.
The first (short and most commonly used) version has fewer parameters
than the full version at the price of not being able to specify some of
the more rarely used button features.
After you have added tools to a toolbar, you must call ToolBar#realize in
order to have the tools appear.
ToolBar#add_separator, ToolBar#add_check_tool, ToolBar#add_radio_tool, ToolBar#insert_tool, ToolBar#delete_tool, ToolBar#realize
Adds a new check (or toggle) tool to the toolbar. The parameters are the same
as in ToolBar#add_tool.
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.
Deletes all the tools in the toolbar.
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 remove_tool instead.
Note that it is unnecessary to call Realize for the
change to take place, it will happen immediately.
Returns true if the tool was deleted, false otherwise.
This function behaves like delete_tool but it
deletes the tool at the specified position and not the one with the given id.
Enables or disables the tool.
NB: This function should only be called after
Realize.
Some implementations will change the visible state of the tool to indicate that it is disabled.
ToolBar#get_tool_enabled, ToolBar#toggle_tool
Returns information about the item with the passed-in id.
Returns a pointer to the Wx::Control identified by id or nil if no
corresponding control is found.
Returns the number of tools in the toolbar.
Returns the size of a whole button, which is usually larger than a tool bitmap because
of added 3D effects.
ToolBar#set_tool_bitmap_size, ToolBar#get_tool_bitmap_size
Returns the size of bitmap that the toolbar expects to have. The default bitmap size is 16 by 15 pixels.
Note that this is the size of the bitmap you pass to ToolBar#add_tool,
and not the eventual size of the tool button.
ToolBar#set_tool_bitmap_size, ToolBar#get_tool_size
Returns the left/right and top/bottom margins, which are also used for inter-toolspacing.
Get any client data associated with the tool.
Client data, or NULL if there is none.
Called to determine whether a tool is enabled (responds to user input).
true if the tool is enabled, false otherwise.
Returns the long help for the given tool.
ToolBar#set_tool_long_help, ToolBar#set_tool_short_help
Returns the value used for packing tools.
Returns the tool position in the toolbar, or NOT_FOUND
if the tool is not found.
Returns the default separator size.
Returns the short help for the given tool.
ToolBar#get_tool_long_help, ToolBar#set_tool_short_help
h3(#ToolBar_gettoolstate). ToolBar#get_tool_state
Gets the on/off state of a toggle tool.
true if the tool is toggled on, false otherwise.
Inserts the control into the toolbar at the given position.
You must call Realize for the change to take place.
Inserts the separator into the toolbar at the given position.
You must call Realize for the change to take place.
Inserts the tool with the specified attributes into the toolbar at the given
position. Returns a ToolBarTool object with
information about the newly inserted item.
You must call Realize for the change to take place.
Called when the user clicks on a tool with the left mouse button.
This is the old way of detecting tool clicks; although it will still work,
you should use the EVT_MENU or EVT_TOOL macro instead.
If the tool is a toggle and this function returns false, the toggle
toggle state (internal and visual) will not be changed. This provides a way of
specifying that toggle operations are not permitted in some circumstances.
ToolBar#on_mouse_enter, ToolBar#on_right_click
This is called when the mouse cursor moves into a tool or out of
the toolbar.
This is the old way of detecting mouse enter events; although it will still work,
you should use the EVT_TOOL_ENTER macro instead.
With some derived toolbar classes, if the mouse moves quickly out of the toolbar, Widgets may not be able to
detect it. Therefore this function may not always be called when expected.
Called when the user clicks on a tool with the right mouse button. The
programmer should override this function to detect right tool clicks.
This is the old way of detecting tool right clicks; although it will still work,
you should use the EVT_TOOL_RCLICKED macro instead.
A typical use of this member might be to pop up a menu.
ToolBar#on_mouse_enter, ToolBar#on_left_click
This function should be called after you have added tools.
Removes the given tool from the toolbar but doesn’t delete it. This allows to
insert/add this tool back to this (or another) toolbar later.
Note that it is unnecessary to call Realize for the
change to take place, it will happen immediately.
Sets the bitmap resource identifier for specifying tool bitmaps as indices
into a custom bitmap. Windows CE only.
Set the values to be used as margins for the toolbar.
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.
Sets the default size of each tool bitmap. The default bitmap size is 16 by 15 pixels.
This should be called to tell the toolbar what the tool bitmap size is. Call
it before you add tools.
Note that this is the size of the bitmap you pass to ToolBar#add_tool,
and not the eventual size of the tool button.
ToolBar#get_tool_bitmap_size, ToolBar#get_tool_size
Sets the client data associated with the tool.
Sets the bitmap to be used by the tool with the given ID when the tool
is in a disabled state. This can only be used on Button tools, not
controls. NOTE: The native toolbar classes on the main platforms all
synthesize the disabled bitmap from the normal bitmap, so this function
will have no effect on those platforms.
Sets the long help for the given tool.
You might use the long help for displaying the tool purpose on the status line.
Sets the bitmap to be used by the tool with the given ID. This can only
be used on Button tools, not controls.
ToolBar#get_tool_long_help, ToolBar#set_tool_short_help,
h3(#ToolBar_settoolpacking). ToolBar#set_tool_packing
Sets the value used for spacing tools. The default value is 1.
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.
Sets the short help for the given tool.
An application might use short help for identifying the tool purpose in a tooltip.
ToolBar#get_tool_short_help, ToolBar#set_tool_long_help
Sets the default separator size. The default value is 5.
Toggles a tool on or off. This does not cause any event to get emitted.
Only applies to a tool that has been specified as a toggle tool.
[This page automatically generated from the Textile source at 2023-06-03 08:07:32 +0000]