A wxToolBar is a canvas containing mouse-sensitive bitmaps. Include the file wx_tbar.h to use this class.
Note: under XView, wxToolBar inherits from wxCanvas, not wxPanel, due to limitations in the XView toolkit.
wxToolBar::wxToolBar
wxToolBar::~wxToolBar
wxToolBar::AddSeparator
wxToolBar::AddTool
wxToolBar::CreateTools
wxToolBar::DrawTool
wxToolBar::EnableTool
wxToolBar::FindToolForPosition
wxToolBar::GetMaxSize
wxToolBar::GetToolClientData
wxToolBar::GetToolEnabled
wxToolBar::GetToolLongHelp
wxToolBar::GetToolShortHelp
wxToolBar::GetToolState
wxToolBar::Layout
wxToolBar::OnLeftClick
wxToolBar::OnMouseEnter
wxToolBar::OnRightClick
wxToolBar::SetMargins
wxToolBar::SetToolLongHelp
wxToolBar::SetToolPacking
wxToolBar::SetToolShortHelp
wxToolBar::SetToolSeparation
wxToolBar::ToggleTool
void wxToolBar(wxWindow *parent, int x = 0, int y = 0,
int width = -1, int height = -1, long style = 0,
int orientation = wxVERTICAL, int nRowsOrColumns = 1, char *name = "toolBar")
Constructs a toolbar canvas.
parent is a parent window, usually a wxFrame.
x, y set the position of the window.
width, height set the size of the window.
style is a bitlist, which may contain the following flags:
wxTB_3DBUTTONS | Gives a 3D look to the buttons, but not to the same extent as wxButtonBar. |
orientation specifies a wxVERTICAL or wxHORIZONTAL orientation for laying out the toolbar.
nRowsOrColumns specifies the number of rows or columns, whose meaning depends on orientation. If laid out vertically, nRowsOrColumns specifies the number of rows to draw before the next column is started; if horizontal, it refers to the number of columns to draw before the next row is started.
name specifies a window name for the toolbar.
Under Windows 95, the wxButtonBar constructor only accepts wxVERTICAL plus the number of rows.
void ~wxToolBar(void)
Toolbar destructor.
void AddSeparator()
Adds a separator for spacing groups of tools.
wxToolBarTool * AddTool(int toolIndex, wxBitmap * bitmap1, wxBitmap * bitmap2 = NULL, Bool isToggle = FALSE, float xPos = -1, float yPos = -1, wxObject *clientData = NULL, char *shortHelpString = NULL, char *longHelpString = NULL)
Adds a tool to the toolbar. The toolIndex is an integer by which the tool may be identified in subsequent operations. isToggle specifies whether the tool is a toggle or not: a toggle tool may be in two states, whereas a non-toggle tool is just a button.
The first bitmap is the primary tool bitmap for toggle and button tools. The second bitmap specifies the on-state bitmap for a toggle tool. If this is NULL, either an inverted version of the primary bitmap is used for the on-state of a toggle tool (monochrome displays) or a black border is drawn around the tool (colour displays).
The arguments xPos and yPos allow the programmer to specify the position of the tool if automatic layout is not suitable. For example, a toolbar along the top of a window may have groups of tools, with spacing between groups. In this case, specifying xPos is all that is required, and yPos will take its value from the current vertical spacing value.
clientData is an optional pointer to client data which can be retrieved later using GetToolClientData.
shortHelpString is used for displaying a tooltip for the tool in the Windows 95 implementation of wxButtonBar.
longHelpString can be used to displayer longer help, such as status line help.
Bool CreateTools()
Required for the Windows 95 version of wxButtonBar: call this function after all tools have been added to the toolbar. It is harmless to call CreateTools for wxToolBar.
void DrawTool(wxMemoryDC& memDC, wxToolBarTool *tool)
Draws the specified tool onto the canvas using the given memory device context. Used internally, and should not need to be used by the programmer.
void EnableTool(int toolIndex, Bool enable)
Enables or disables the tool. Not currently implemented, but should give some indication of whether the tool is active.
wxToolBarTool * FindToolForPosition(float x, float y)
Find a tool for the given mouse position, or return NULL. Used internally, and should not need to be used by the programmer.
void GetMaxSize(float *w, float *h)
Gets the maximum size taken up by the tools after layout, including margins. This can be used to size a frame around the toolbar canvas.
wxObject * GetToolClientData(int toolIndex)
Get any client data associated with the tool.
Bool GetToolEnabled(int toolIndex)
Returns TRUE if the tool is enabled, FALSE otherwise.
char * GetToolLongHelp(int toolIndex)
Returns the long help for the given tool.
char * GetToolShortHelp(int toolIndex)
Returns the short help for the given tool.
Bool GetToolState(int toolIndex)
Gets the on/off state of a toggle tool.
void Layout(void)
Called by the application after the tools have been added to automatically lay the tools out on the canvas. If you have given absolute positions when adding the tools, do not call this.
Bool OnLeftClick(int toolIndex, Bool toggleDown)
Called when the user clicks on a tool with the left mouse button. The programmer should override this function to detect left tool clicks. toolIndex is the identifier passed to AddTool, and toggleDown is TRUE if the tool is a toggle and the toggle is down, otherwise is FALSE.
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.
void OnMouseEnter(int toolIndex)
This is called when the mouse moves into a tool (toolIndex is greater than -1) or out of the toolbox (toolIndex is -1). The programmer can override this to provide extra information about the tool, such as a short description on the status line. Icons are not always as intuitive as they're cracked up to be!
void OnRightClick(int toolIndex, float x, float y)
Called when the user clicks on a tool with the right mouse button. The programmer should override this function to detect right tool clicks. toolIndex is the identifier passed to AddTool, and x and y give the mouse cursor position.
A typical use of this member might be to pop up a menu.
void SetMargins(int x, int y)
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.
void SetToolLongHelp(int toolIndex, char *helpString)
Sets the long help for the given tool.
void SetToolPacking(int packing)
Sets the value used for spacing tools. The default value is 1.
void SetToolShortHelp(int toolIndex, char *helpString)
Sets the short help for the given tool.
void SetToolSeparation(int separation)
Sets the value used by tool separators. The default value is 5.
void ToggleTool(int toolIndex, Bool toggle)
Toggles a tool on or off.