wxtoolbarthe name wxtoolbar is defined to be a synonym for one of the following classes:
derived from
wxtoolbarbase include files
<wx/toolbar.h> (to allow wxwidgets to select an appropriate toolbar class) remarks you may also create a toolbar that is managed by the frame, by calling wxframe::createtoolbar. 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 a wxtoolbar as usual. the meaning of a "separator" is a vertical line under windows and simple space under gtk+. wxtoolbar95: note that this 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:
wxsystemoptions::setoption(wxt("msw.remap"), 0);if you wish to use 32-bit images (which include an alpha channel for transparency) use:
wxsystemoptions::setoption(wxt("msw.remap"), 2);then colour remapping is switched off, and a transparent background used. but only use this option under windows xp with true colour:
(wxtheapp->getcomctl32version() >= 600 && ::wxdisplaydepth() >= 32)window styles
see also window styles overview. note that the win32 native toolbar ignores wxtb_noicons style. also, toggling the wxtb_text works only if the style was initially on. event handling 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 wxcommandevent 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 wxcommandevent. 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.
see also toolbar overview, wxscrolledwindow members
wxtoolbar::wxtoolbar
wxtoolbar::wxtoolbarwxtoolbar() default constructor. wxtoolbar(wxwindow* parent, wxwindowid id, const wxpoint& pos = wxdefaultposition, const wxsize& size = wxdefaultsize, long style = wxtb_horizontal | wxno_border, const wxstring& name = wxpanelnamestr) constructs a toolbar. parameters parent
id
pos
size
style
name
remarks after a toolbar is created, you use wxtoolbar::addtool and perhaps wxtoolbar::addseparator, and then you must call wxtoolbar::realize to construct and display the toolbar tools. you may also create a toolbar that is managed by the frame, by calling wxframe::createtoolbar.
wxtoolbar::~wxtoolbarvoid ~wxtoolbar() toolbar destructor.
wxtoolbar::addcontrolbool addcontrol(wxcontrol* control) adds any control to the toolbar, typically e.g. a combobox. control
wxtoolbar::addseparatorvoid addseparator() adds a separator for spacing groups of tools. see also wxtoolbar::addtool, wxtoolbar::settoolseparation
wxtoolbar::addtoolwxtoolbartoolbase* addtool(int toolid, const wxstring& label, const wxbitmap& bitmap1, const wxstring& shorthelpstring = "", wxitemkind kind = wxitem_normal) wxtoolbartoolbase* addtool(int toolid, const wxstring& label, const wxbitmap& bitmap1, const wxbitmap& bitmap2 = wxnullbitmap, wxitemkind kind = wxitem_normal, const wxstring& shorthelpstring = "", const wxstring& longhelpstring = "", wxobject* clientdata = null) wxtoolbartoolbase* addtool(wxtoolbartoolbase* tool) adds a tool to the toolbar. 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. the last version allows you to add an existing tool. parameters toolid
kind
bitmap1
bitmap2
shorthelpstring
longhelpstring
clientdata
tool
remarks after you have added tools to a toolbar, you must call wxtoolbar::realize in order to have the tools appear. see also wxtoolbar::addseparator, wxtoolbar::addchecktool, wxtoolbar::addradiotool, wxtoolbar::inserttool, wxtoolbar::deletetool, wxtoolbar::realize
wxtoolbar::addchecktoolwxtoolbartoolbase* addchecktool(int toolid, const wxstring& label, const wxbitmap& bitmap1, const wxbitmap& bitmap2, const wxstring& shorthelpstring = "", const wxstring& longhelpstring = "", wxobject* clientdata = null) adds a new check (or toggle) tool to the toolbar. the parameters are the same as in wxtoolbar::addtool. see also
wxtoolbar::addradiotoolwxtoolbartoolbase* addradiotool(int toolid, const wxstring& label, const wxbitmap& bitmap1, const wxbitmap& bitmap2, const wxstring& shorthelpstring = "", const wxstring& longhelpstring = "", wxobject* clientdata = null) 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. see also
wxtoolbar::cleartoolsvoid cleartools() deletes all the tools in the toolbar.
wxtoolbar::deletetoolbool deletetool(int toolid) 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 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. see also
wxtoolbar::deletetoolbyposbool deletetoolbypos(size_t pos) this function behaves like deletetool but it deletes the tool at the specified position and not the one with the given id.
wxtoolbar::enabletoolvoid enabletool(int toolid, const bool enable) enables or disables the tool. parameters toolid
enable
nb: this function should only be called after realize. remarks some implementations will change the visible state of the tool to indicate that it is disabled. see also wxtoolbar::gettoolenabled, wxtoolbar::toggletool
wxtoolbar::findbyidwxtoolbartoolbase* findbyid(int id) returns a pointer to the tool identified by id or null if no corresponding tool is found.
wxtoolbar::findcontrolwxcontrol* findcontrol(int id) returns a pointer to the control identified by id or null if no corresponding control is found.
wxtoolbar::findtoolforpositionwxtoolbartoolbase* findtoolforposition(wxcoord x, wxcoord y) const finds a tool for the given mouse position. parameters x
y
return value a pointer to a tool if a tool is found, or null otherwise. remarks currently not implemented in wxgtk (always returns null there).
wxtoolbar::gettoolscountint gettoolscount() const returns the number of tools in the toolbar.
wxtoolbar::gettoolsizewxsize gettoolsize() returns the size of a whole button, which is usually larger than a tool bitmap because of added 3d effects. see also wxtoolbar::settoolbitmapsize, wxtoolbar::gettoolbitmapsize
wxtoolbar::gettoolbitmapsizewxsize gettoolbitmapsize() returns the size of bitmap that the toolbar expects to have. the default bitmap size is 16 by 15 pixels. remarks note that this is the size of the bitmap you pass to wxtoolbar::addtool, and not the eventual size of the tool button. see also wxtoolbar::settoolbitmapsize, wxtoolbar::gettoolsize
wxtoolbar::getmarginswxsize getmargins() const returns the left/right and top/bottom margins, which are also used for inter-toolspacing. see also
wxtoolbar::gettoolclientdatawxobject* gettoolclientdata(int toolid) const get any client data associated with the tool. parameters toolid
return value client data, or null if there is none.
wxtoolbar::gettoolenabledbool gettoolenabled(int toolid) const called to determine whether a tool is enabled (responds to user input). parameters toolid
return value true if the tool is enabled, false otherwise. see also
wxtoolbar::gettoollonghelpwxstring gettoollonghelp(int toolid) const returns the long help for the given tool. parameters toolid
see also wxtoolbar::settoollonghelp, wxtoolbar::settoolshorthelp
wxtoolbar::gettoolpackingint gettoolpacking() const returns the value used for packing tools. see also
wxtoolbar::gettoolposint gettoolpos(int toolid) const returns the tool position in the toolbar, or wxnot_found if the tool is not found.
wxtoolbar::gettoolseparationint gettoolseparation() const returns the default separator size. see also
wxtoolbar::gettoolshorthelpwxstring gettoolshorthelp(int toolid) const returns the short help for the given tool. parameters toolid
see also wxtoolbar::gettoollonghelp, wxtoolbar::settoolshorthelp
wxtoolbar::gettoolstatebool gettoolstate(int toolid) const gets the on/off state of a toggle tool. parameters toolid
return value true if the tool is toggled on, false otherwise. see also
wxtoolbar::insertcontrolwxtoolbartoolbase * insertcontrol(size_t pos, wxcontrol *control) inserts the control into the toolbar at the given position. you must call realize for the change to take place. see also
wxtoolbar::insertseparatorwxtoolbartoolbase * insertseparator(size_t pos) inserts the separator into the toolbar at the given position. you must call realize for the change to take place. see also
wxtoolbar::inserttoolwxtoolbartoolbase * inserttool(size_t pos, int toolid, const wxbitmap& bitmap1, const wxbitmap& bitmap2 = wxnullbitmap, bool istoggle = false, wxobject* clientdata = null, const wxstring& shorthelpstring = "", const wxstring& longhelpstring = "") wxtoolbartoolbase * inserttool(size_t pos, wxtoolbartoolbase* tool) inserts the tool with the specified attributes into the toolbar at the given position. you must call realize for the change to take place. see also
addtool,
wxtoolbar::onleftclickbool onleftclick(int toolid, bool toggledown) 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. parameters toolid
toggledown
return value 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. see also wxtoolbar::onmouseenter, wxtoolbar::onrightclick
wxtoolbar::onmouseentervoid onmouseenter(int toolid) 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. parameters toolid
remarks with some derived toolbar classes, if the mouse moves quickly out of the toolbar, wxwidgets may not be able to detect it. therefore this function may not always be called when expected.
wxtoolbar::onrightclickvoid onrightclick(int toolid, 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. this is the old way of detecting tool right clicks; although it will still work, you should use the evt_tool_rclicked macro instead. parameters toolid
x
y
remarks a typical use of this member might be to pop up a menu. see also wxtoolbar::onmouseenter, wxtoolbar::onleftclick
wxtoolbar::realizebool realize() this function should be called after you have added tools.
wxtoolbar::removetoolwxtoolbartoolbase * removetool(int id) 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. see also
wxtoolbar::setbitmapresourcevoid setbitmapresource(int resourceid) sets the bitmap resource identifier for specifying tool bitmaps as indices into a custom bitmap. windows ce only.
wxtoolbar::setmarginsvoid setmargins(const wxsize& size) void setmargins(int x, int y) set the values to be used as margins for the toolbar. parameters size
x
y
remarks 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. see also
wxtoolbar::settoolbitmapsizevoid settoolbitmapsize(const wxsize& size) sets the default size of each tool bitmap. the default bitmap size is 16 by 15 pixels. parameters size
remarks 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 wxtoolbar::addtool, and not the eventual size of the tool button. see also wxtoolbar::gettoolbitmapsize, wxtoolbar::gettoolsize
wxtoolbar::settoolclientdatavoid settoolclientdata(int id, wxobject* clientdata) sets the client data associated with the tool.
wxtoolbar::settooldisabledbitmapvoid settooldisabledbitmap(int id, const wxbitmap& bitmap) 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.
wxtoolbar::settoollonghelpvoid settoollonghelp(int toolid, const wxstring& helpstring) sets the long help for the given tool. parameters toolid
helpstring
remarks you might use the long help for displaying the tool purpose on the status line. see also wxtoolbar::gettoollonghelp, wxtoolbar::settoolshorthelp,
wxtoolbar::settoolpackingvoid settoolpacking(int packing) sets the value used for spacing tools. the default value is 1. parameters packing
remarks 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. see also
wxtoolbar::settoolshorthelpvoid settoolshorthelp(int toolid, const wxstring& helpstring) sets the short help for the given tool. parameters toolid
helpstring
remarks an application might use short help for identifying the tool purpose in a tooltip. see also wxtoolbar::gettoolshorthelp, wxtoolbar::settoollonghelp
wxtoolbar::settoolnormalbitmapvoid settoolnormalbitmap(int id, const wxbitmap& bitmap) sets the bitmap to be used by the tool with the given id. this can only be used on button tools, not controls.
wxtoolbar::settoolseparationvoid settoolseparation(int separation) sets the default separator size. the default value is 5. parameters separation
see also
wxtoolbar::toggletoolvoid toggletool(int toolid, const bool toggle) toggles a tool on or off. this does not cause any event to get emitted. parameters toolid
toggle
remarks only applies to a tool that has been specified as a toggle tool. see also
|