📄 toolbar.tex
字号:
\section{\class{wxToolBar}}\label{wxtoolbar}The name wxToolBar is defined to be a synonym for one of the following classes:\begin{itemize}\itemsep=0pt\item {\bf wxToolBar95} The native Windows 95 toolbar. Used on Windows 95, NT 4 and above.\item {\bf wxToolBarMSW} A Windows implementation. Used on 16-bit Windows.\item {\bf wxToolBarGTK} The GTK toolbar.\end{itemize}\wxheading{Derived from}wxToolBarBase\\\helpref{wxControl}{wxcontrol}\\\helpref{wxWindow}{wxwindow}\\\helpref{wxEvtHandler}{wxevthandler}\\\helpref{wxObject}{wxobject}\wxheading{Include files}<wx/toolbar.h> (to allow wxWidgets to select an appropriate toolbar class)\\<wx/tbarbase.h> (the base class)\wxheading{Remarks}You may also create a toolbar that is managed by the frame, bycalling \helpref{wxFrame::CreateToolBar}{wxframecreatetoolbar}. Under Pocket PC,you should \arg{always} use this function for creating the toolbarto be managed by the frame, so that wxWidgets can use a combinedmenubar and toolbar. Where you manage your own toolbars, create a wxToolBaras usual.The meaning of a "separator" is a vertical line under Windows and simple space under GTK+.{\bf 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 suppressthis behaviour, otherwise system colours in your bitmaps will inadvertently bemapped to system colours. To do this, set the {\tt msw.remap} system optionbefore creating the toolbar:\begin{verbatim} wxSystemOptions::SetOption(wxT("msw.remap"), 0);\end{verbatim}If you wish to use 32-bit images (which include an alpha channel for transparency)use:\begin{verbatim} wxSystemOptions::SetOption(wxT("msw.remap"), 2);\end{verbatim}then colour remapping is switched off, and a transparent background used. But onlyuse this option under Windows XP with true colour:\begin{verbatim} (wxTheApp->GetComCtl32Version() >= 600 && ::wxDisplayDepth() >= 32)\end{verbatim}\wxheading{Window styles}\twocolwidtha{5cm}\begin{twocollist}\itemsep=0pt\twocolitem{\windowstyle{wxTB\_FLAT}}{Gives the toolbar a flat look (Windows and GTK only).}\twocolitem{\windowstyle{wxTB\_DOCKABLE}}{Makes the toolbar floatable and dockable (GTK only).}\twocolitem{\windowstyle{wxTB\_HORIZONTAL}}{Specifies horizontal layout (default).}\twocolitem{\windowstyle{wxTB\_VERTICAL}}{Specifies vertical layout.}\twocolitem{\windowstyle{wxTB\_TEXT}}{Shows the text in the toolbar buttons; by default only icons are shown.}\twocolitem{\windowstyle{wxTB\_NOICONS}}{Specifies no icons in the toolbar buttons; by default they are shown.}\twocolitem{\windowstyle{wxTB\_NODIVIDER}}{Specifies no divider (border) above the toolbar (Windows only).}\twocolitem{\windowstyle{wxTB\_NOALIGN}}{Specifies no alignment with the parent window (Windows only, not very useful).}\twocolitem{\windowstyle{wxTB\_HORZ\_LAYOUT}}{Shows the text and the icons alongside, not vertically stacked (Windows and GTK2 only). This style must be used with wxTB\_TEXT.}\twocolitem{\windowstyle{wxTB\_HORZ\_TEXT}}{Combination of wxTB\_HORZ\_LAYOUT and wxTB\_TEXT.}\twocolitem{\windowstyle{wxTB\_NO\_TOOLTIPS}}{Don't show the short help tooltips for the tools when the mouse hovers over them.}\twocolitem{\windowstyle{wxTB\_BOTTOM}}{Align the toolbar at the bottom of parent window.}\twocolitem{\windowstyle{wxTB\_RIGHT}}{Align the toolbar at the right side of parent window.}\end{twocollist}See also \helpref{window styles overview}{windowstyles}. Note that the Win32native toolbar ignores {\tt wxTB\_NOICONS} style. Also, toggling the {\tt wxTB\_TEXT} works only if the style was initially on.\wxheading{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 toolbarwindow 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 notallowed as an identifier in the event system.\twocolwidtha{7cm}\begin{twocollist}\itemsep=0pt\twocolitem{{\bf EVT\_TOOL(id, func)}}{Process a wxEVT\_COMMAND\_TOOL\_CLICKED event(a synonym for wxEVT\_COMMAND\_MENU\_SELECTED). Pass the id of the tool.}\twocolitem{{\bf EVT\_MENU(id, func)}}{The same as EVT\_TOOL.}\twocolitem{{\bf EVT\_TOOL\_RANGE(id1, id2, func)}}{Process a wxEVT\_COMMAND\_TOOL\_CLICKED eventfor a range of identifiers. Pass the ids of the tools.}\twocolitem{{\bf EVT\_MENU\_RANGE(id1, id2, func)}}{The same as EVT\_TOOL\_RANGE.}\twocolitem{{\bf EVT\_TOOL\_RCLICKED(id, func)}}{Process a wxEVT\_COMMAND\_TOOL\_RCLICKED event.Pass the id of the tool.}\twocolitem{{\bf EVT\_TOOL\_RCLICKED\_RANGE(id1, id2, func)}}{Process a wxEVT\_COMMAND\_TOOL\_RCLICKED eventfor a range of ids. Pass the ids of the tools.}\twocolitem{{\bf EVT\_TOOL\_ENTER(id, func)}}{Process a wxEVT\_COMMAND\_TOOL\_ENTER event.Pass the id of the toolbar itself. The value of wxCommandEvent::GetSelection is the tool id, or -1 if the mouse cursor has moved off a tool.}\end{twocollist}\wxheading{See also}\overview{Toolbar overview}{wxtoolbaroverview},\rtfsp\helpref{wxScrolledWindow}{wxscrolledwindow}\latexignore{\rtfignore{\wxheading{Members}}}\membersection{wxToolBar::wxToolBar}\label{wxtoolbarconstr}\func{}{wxToolBar}{\void}Default constructor.\func{}{wxToolBar}{\param{wxWindow*}{ parent}, \param{wxWindowID }{id}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize}, \param{long }{style = wxTB\_HORIZONTAL \pipe wxNO\_BORDER}, \param{const wxString\& }{name = wxPanelNameStr}}Constructs a toolbar.\wxheading{Parameters}\docparam{parent}{Pointer to a parent window.}\docparam{id}{Window identifier. If -1, will automatically create an identifier.}\docparam{pos}{Window position. wxDefaultPosition is (-1, -1) which indicates that wxWidgetsshould generate a default position for the window. If using the wxWindow class directly, supplyan actual position.}\docparam{size}{Window size. wxDefaultSize is (-1, -1) which indicates that wxWidgetsshould generate a default size for the window.}\docparam{style}{Window style. See \helpref{wxToolBar}{wxtoolbar} for details.}\docparam{name}{Window name.}\wxheading{Remarks}After a toolbar is created, you use \helpref{wxToolBar::AddTool}{wxtoolbaraddtool} andperhaps \helpref{wxToolBar::AddSeparator}{wxtoolbaraddseparator}, and then youmust call \helpref{wxToolBar::Realize}{wxtoolbarrealize} to construct and display the toolbartools.You may also create a toolbar that is managed by the frame, bycalling \helpref{wxFrame::CreateToolBar}{wxframecreatetoolbar}.\membersection{wxToolBar::\destruct{wxToolBar}}\label{wxtoolbardtor}\func{void}{\destruct{wxToolBar}}{\void}Toolbar destructor.\membersection{wxToolBar::AddControl}\label{wxtoolbaraddcontrol}\func{bool}{AddControl}{\param{wxControl*}{ control}}Adds any control to the toolbar, typically e.g. a combobox.\docparam{control}{The control to be added.}\membersection{wxToolBar::AddSeparator}\label{wxtoolbaraddseparator}\func{void}{AddSeparator}{\void}Adds a separator for spacing groups of tools.\wxheading{See also}\helpref{wxToolBar::AddTool}{wxtoolbaraddtool}, \helpref{wxToolBar::SetToolSeparation}{wxtoolbarsettoolseparation}\membersection{wxToolBar::AddTool}\label{wxtoolbaraddtool}\func{wxToolBarToolBase*}{AddTool}{\param{int}{ toolId},\rtfsp\param{const wxString\&}{ label},\rtfsp\param{const wxBitmap\&}{ bitmap1},\rtfsp\param{const wxString\& }{shortHelpString = ""},\rtfsp\param{wxItemKind}{ kind = wxITEM\_NORMAL}}\func{wxToolBarToolBase*}{AddTool}{\param{int}{ toolId},\rtfsp\param{const wxString\&}{ label},\rtfsp\param{const wxBitmap\&}{ bitmap1},\rtfsp\param{const wxBitmap\&}{ bitmap2 = wxNullBitmap},\rtfsp\param{wxItemKind}{ kind = wxITEM\_NORMAL},\rtfsp\param{const wxString\& }{shortHelpString = ""},\param{const wxString\& }{longHelpString = ""},\rtfsp\param{wxObject* }{clientData = \NULL}}\func{wxToolBarToolBase*}{AddTool}{\param{wxToolBarToolBase* }{tool}}Adds a tool to the toolbar. The first (short and most commonly used) versionhas fewer parameters than the full version at the price of not being able tospecify some of the more rarely used button features. The last version allowsyou to add an existing tool.\wxheading{Parameters}\docparam{toolId}{An integer by whichthe tool may be identified in subsequent operations.}\docparam{kind}{May be wxITEM\_NORMAL for a normal button (default),wxITEM\_CHECK for a checkable tool (such tool stays pressed after it had beentoggled) or wxITEM\_RADIO for a checkable tool which makes part of a radiogroup of tools each of which is automatically unchecked whenever another buttonin the group is checked}\docparam{bitmap1}{The primary tool bitmap.}\docparam{bitmap2}{The bitmap used when the tool is disabled. If it is equal towxNullBitmap, the disabled bitmap is automatically generated by greing thenormal one.}\docparam{shortHelpString}{This string is used for the tools tooltip}\docparam{longHelpString}{This string is shown in the statusbar (if any) of theparent frame when the mouse pointer is inside the tool}\docparam{clientData}{An optional pointer to client data which can beretrieved later using \helpref{wxToolBar::GetToolClientData}{wxtoolbargettoolclientdata}.}\docparam{tool}{The tool to be added.}\wxheading{Remarks}After you have added tools to a toolbar, you must call \helpref{wxToolBar::Realize}{wxtoolbarrealize} inorder to have the tools appear.\wxheading{See also}\helpref{wxToolBar::AddSeparator}{wxtoolbaraddseparator},\rtfsp\helpref{wxToolBar::AddCheckTool}{wxtoolbaraddchecktool},\rtfsp\helpref{wxToolBar::AddRadioTool}{wxtoolbaraddradiotool},\rtfsp\helpref{wxToolBar::InsertTool}{wxtoolbarinserttool},\rtfsp\helpref{wxToolBar::DeleteTool}{wxtoolbardeletetool},\rtfsp\helpref{wxToolBar::Realize}{wxtoolbarrealize}\membersection{wxToolBar::AddCheckTool}\label{wxtoolbaraddchecktool}\func{wxToolBarToolBase*}{AddCheckTool}{\param{int}{ toolId},\rtfsp\param{const wxString\&}{ label},\rtfsp\param{const wxBitmap\&}{ bitmap1},\rtfsp\param{const wxBitmap\&}{ bitmap2},\rtfsp\param{const wxString\& }{shortHelpString = ""},\rtfsp\param{const wxString\& }{longHelpString = ""},\rtfsp\param{wxObject* }{clientData = \NULL}}Adds a new check (or toggle) tool to the toolbar. The parameters are the sameas in \helpref{wxToolBar::AddTool}{wxtoolbaraddtool}.\wxheading{See also}\helpref{wxToolBar::AddTool}{wxtoolbaraddtool}\membersection{wxToolBar::AddRadioTool}\label{wxtoolbaraddradiotool}\func{wxToolBarToolBase*}{AddRadioTool}{\param{int}{ toolId},\rtfsp\param{const wxString\&}{ label},\rtfsp\param{const wxBitmap\&}{ bitmap1},\rtfsp\param{const wxBitmap\&}{ bitmap2},\rtfsp\param{const wxString\& }{shortHelpString = ""},\rtfsp\param{const wxString\& }{longHelpString = ""},\rtfsp\param{wxObject* }{clientData = \NULL}}Adds a new radio tool to the toolbar. Consecutive radio tools form a radiogroup such that exactly one button in the group is pressed at any moment, inother words whenever a button in the group is pressed the previously pressedbutton is automatically released. You should avoid having the radio groups ofonly 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, theothers are not.\wxheading{See also}\helpref{wxToolBar::AddTool}{wxtoolbaraddtool}\membersection{wxToolBar::DeleteTool}\label{wxtoolbardeletetool}\func{bool}{DeleteTool}{\param{int }{toolId}}Removes the specified tool from the toolbar and deletes it. If you don't wantto delete the tool, but just to remove it from the toolbar (to possibly add itback later), you may use \helpref{RemoveTool}{wxtoolbarremovetool} instead.Note that it is unnecessary to call \helpref{Realize}{wxtoolbarrealize} for thechange to take place, it will happen immediately.Returns true if the tool was deleted, false otherwise.\wxheading{See also}\helpref{DeleteToolByPos}{wxtoolbardeletetoolbypos}\membersection{wxToolBar::DeleteToolByPos}\label{wxtoolbardeletetoolbypos}\func{bool}{DeleteToolByPos}{\param{size\_t }{pos}}This function behaves like \helpref{DeleteTool}{wxtoolbardeletetool} but itdeletes the tool at the specified position and not the one with the given id.\membersection{wxToolBar::EnableTool}\label{wxtoolbarenabletool}\func{void}{EnableTool}{\param{int }{toolId}, \param{const bool}{ enable}}Enables or disables the tool.\wxheading{Parameters}\docparam{toolId}{Tool to enable or disable.}\docparam{enable}{If true, enables the tool, otherwise disables it.}{\bf NB:} This function should only be called after \helpref{Realize}{wxtoolbarrealize}.\wxheading{Remarks}Some implementations will change the visible state of the tool to indicate that it is disabled.\wxheading{See also}\helpref{wxToolBar::GetToolEnabled}{wxtoolbargettoolenabled},\rtfsp\helpref{wxToolBar::ToggleTool}{wxtoolbartoggletool}\membersection{wxToolBar::FindById}\label{wxtoolbarfindbyid}\func{wxToolBarToolBase*}{FindById}{\param{int }{id}}Returns a pointer to the tool identified by \arg{id} or\NULL if no corresponding tool is found.\membersection{wxToolBar::FindControl}\label{wxtoolbarfindcontrol}\func{wxControl*}{FindControl}{\param{int }{id}}Returns a pointer to the control identified by \arg{id} or \NULL if no corresponding control is found.\membersection{wxToolBar::FindToolForPosition}\label{wxtoolbarfindtoolforposition}\constfunc{wxToolBarToolBase*}{FindToolForPosition}{\param{wxCoord }{x}, \param{wxCoord }{y}}Finds a tool for the given mouse position.\wxheading{Parameters}\docparam{x}{X position.}\docparam{y}{Y position.}\wxheading{Return value}A pointer to a tool if a tool is found, or \NULL otherwise.\wxheading{Remarks}Currently not implemented in wxGTK (always returns \NULL there).\membersection{wxToolBar::GetToolSize}\label{wxtoolbargettoolsize}\func{wxSize}{GetToolSize}{\void}Returns the size of a whole button, which is usually larger than a tool bitmap becauseof added 3D effects.\wxheading{See also}\helpref{wxToolBar::SetToolBitmapSize}{wxtoolbarsettoolbitmapsize},\rtfsp\helpref{wxToolBar::GetToolBitmapSize}{wxtoolbargettoolbitmapsize}\membersection{wxToolBar::GetToolBitmapSize}\label{wxtoolbargettoolbitmapsize}\func{wxSize}{GetToolBitmapSize}{\void}Returns the size of bitmap that the toolbar expects to have. The default bitmap size is 16 by 15 pixels.\wxheading{Remarks}Note that this is the size of the bitmap you pass to \helpref{wxToolBar::AddTool}{wxtoolbaraddtool},and not the eventual size of the tool button.\wxheading{See also}\helpref{wxToolBar::SetToolBitmapSize}{wxtoolbarsettoolbitmapsize},\rtfsp\helpref{wxToolBar::GetToolSize}{wxtoolbargettoolsize}\membersection{wxToolBar::GetMargins}\label{wxtoolbargetmargins}\constfunc{wxSize}{GetMargins}{\void}Returns the left/right and top/bottom margins, which are also used for inter-toolspacing.\wxheading{See also}\helpref{wxToolBar::SetMargins}{wxtoolbarsetmargins}\membersection{wxToolBar::GetToolClientData}\label{wxtoolbargettoolclientdata}\constfunc{wxObject*}{GetToolClientData}{\param{int }{toolId}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -