]>
git.saurik.com Git - wxWidgets.git/blob - interface/toolbar.h
260a01ccbbc484b33482708eba9a3994e14149ea
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxToolBar class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 The name wxToolBar is defined to be a synonym for one of the following classes:
15 @b wxToolBar95 The native Windows 95 toolbar. Used on Windows 95, NT 4 and
17 @b wxToolBarMSW A Windows implementation. Used on 16-bit Windows.
18 @b wxToolBarGTK The GTK toolbar.
23 Gives the toolbar a flat look (Windows and GTK only).
24 @style{wxTB_DOCKABLE}:
25 Makes the toolbar floatable and dockable (GTK only).
26 @style{wxTB_HORIZONTAL}:
27 Specifies horizontal layout (default).
28 @style{wxTB_VERTICAL}:
29 Specifies vertical layout.
31 Shows the text in the toolbar buttons; by default only icons are
34 Specifies no icons in the toolbar buttons; by default they are
36 @style{wxTB_NODIVIDER}:
37 Specifies no divider (border) above the toolbar (Windows only).
39 Specifies no alignment with the parent window (Windows only, not
41 @style{wxTB_HORZ_LAYOUT}:
42 Shows the text and the icons alongside, not vertically stacked
43 (Windows and GTK 2 only). This style must be used with wxTB_TEXT.
44 @style{wxTB_HORZ_TEXT}:
45 Combination of wxTB_HORZ_LAYOUT and wxTB_TEXT.
46 @style{wxTB_NO_TOOLTIPS}:
47 Don't show the short help tooltips for the tools when the mouse
50 Align the toolbar at the bottom of parent window.
52 Align the toolbar at the right side of parent window.
59 @ref overview_wxtoolbaroverview "Toolbar overview", wxScrolledWindow
61 class wxToolBar
: public wxControl
69 Pointer to a parent window.
71 Window identifier. If -1, will automatically create an identifier.
73 Window position. wxDefaultPosition is (-1, -1) which indicates that
75 should generate a default position for the window. If using the wxWindow
76 class directly, supply
79 Window size. wxDefaultSize is (-1, -1) which indicates that wxWidgets
80 should generate a default size for the window.
82 Window style. See wxToolBar for details.
86 @remarks After a toolbar is created, you use AddTool() and
87 perhaps AddSeparator(), and then you must call
88 Realize() to construct and display the toolbar
92 wxToolBar(wxWindow
* parent
, wxWindowID id
,
93 const wxPoint
& pos
= wxDefaultPosition
,
94 const wxSize
& size
= wxDefaultSize
,
95 long style
= wxTB_HORIZONTAL
| wxBORDER_NONE
,
96 const wxString
& name
= wxPanelNameStr
);
105 Adds a new check (or toggle) tool to the toolbar. The parameters are the same
110 wxToolBarToolBase
* AddCheckTool(int toolId
,
111 const wxString
& label
,
112 const wxBitmap
& bitmap1
,
113 const wxBitmap
& bitmap2
,
114 const wxString
& shortHelpString
= "",
115 const wxString
& longHelpString
= "",
116 wxObject
* clientData
= NULL
);
119 Adds any control to the toolbar, typically e.g. a combobox.
122 The control to be added.
124 Text to be displayed near the control.
126 @remarks wxMSW: the label is only displayed if there is enough space
127 available below the embedded control.
129 bool AddControl(wxControl
* control
, const wxString label
= "");
132 Adds a new radio tool to the toolbar. Consecutive radio tools form a radio
133 group such that exactly one button in the group is pressed at any moment, in
134 other words whenever a button in the group is pressed the previously pressed
135 button is automatically released. You should avoid having the radio groups of
136 only one element as it would be impossible for the user to use such button.
137 By default, the first button in the radio group is initially pressed, the
142 wxToolBarToolBase
* AddRadioTool(int toolId
,
143 const wxString
& label
,
144 const wxBitmap
& bitmap1
,
145 const wxBitmap
& bitmap2
,
146 const wxString
& shortHelpString
= "",
147 const wxString
& longHelpString
= "",
148 wxObject
* clientData
= NULL
);
151 Adds a separator for spacing groups of tools.
153 @see AddTool(), SetToolSeparation()
159 Adds a tool to the toolbar. The first (short and most commonly used) version
160 has fewer parameters than the full version at the price of not being able to
161 specify some of the more rarely used button features. The last version allows
162 you to add an existing tool.
166 the tool may be identified in subsequent operations.
168 May be wxITEM_NORMAL for a normal button (default),
169 wxITEM_CHECK for a checkable tool (such tool stays pressed after it had been
170 toggled) or wxITEM_RADIO for a checkable tool which makes part of a radio
171 group of tools each of which is automatically unchecked whenever another
173 in the group is checked
175 The primary tool bitmap.
177 The bitmap used when the tool is disabled. If it is equal to
178 wxNullBitmap, the disabled bitmap is automatically generated by greing the
180 @param shortHelpString
181 This string is used for the tools tooltip
182 @param longHelpString
183 This string is shown in the statusbar (if any) of the
184 parent frame when the mouse pointer is inside the tool
186 An optional pointer to client data which can be
187 retrieved later using GetToolClientData().
189 The tool to be added.
191 @remarks After you have added tools to a toolbar, you must call
192 Realize() in order to have the tools appear.
194 @see AddSeparator(), AddCheckTool(), AddRadioTool(),
195 InsertTool(), DeleteTool(), Realize()
197 wxToolBarToolBase
* AddTool(int toolId
, const wxString
& label
,
198 const wxBitmap
& bitmap1
,
199 const wxString
& shortHelpString
= "",
200 wxItemKind kind
= wxITEM_NORMAL
);
201 wxToolBarToolBase
* AddTool(int toolId
, const wxString
& label
,
202 const wxBitmap
& bitmap1
,
203 const wxBitmap
& bitmap2
= wxNullBitmap
,
204 wxItemKind kind
= wxITEM_NORMAL
,
205 const wxString
& shortHelpString
= "",
206 const wxString
& longHelpString
= "",
207 wxObject
* clientData
= NULL
);
208 wxToolBarToolBase
* AddTool(wxToolBarToolBase
* tool
);
212 Deletes all the tools in the toolbar.
217 Removes the specified tool from the toolbar and deletes it. If you don't want
218 to delete the tool, but just to remove it from the toolbar (to possibly add it
219 back later), you may use RemoveTool() instead.
220 Note that it is unnecessary to call Realize() for the
221 change to take place, it will happen immediately.
222 Returns @true if the tool was deleted, @false otherwise.
224 @see DeleteToolByPos()
226 bool DeleteTool(int toolId
);
229 This function behaves like DeleteTool() but it
230 deletes the tool at the specified position and not the one with the given id.
232 bool DeleteToolByPos(size_t pos
);
235 Enables or disables the tool.
238 Tool to enable or disable.
240 If @true, enables the tool, otherwise disables it.
242 @remarks Some implementations will change the visible state of the tool
243 to indicate that it is disabled.
245 @see GetToolEnabled(), ToggleTool()
247 void EnableTool(int toolId
, bool enable
);
250 Returns a pointer to the tool identified by @a id or
251 @NULL if no corresponding tool is found.
253 wxToolBarToolBase
* FindById(int id
);
256 Returns a pointer to the control identified by @a id or
257 @NULL if no corresponding control is found.
259 wxControl
* FindControl(int id
);
262 Finds a tool for the given mouse position.
269 @returns A pointer to a tool if a tool is found, or @NULL otherwise.
271 @remarks Currently not implemented in wxGTK (always returns @NULL there).
273 wxToolBarToolBase
* FindToolForPosition(wxCoord x
, wxCoord y
) const;
276 Returns the left/right and top/bottom margins, which are also used for
281 wxSize
GetMargins() const;
284 Returns the size of bitmap that the toolbar expects to have. The default bitmap
285 size is 16 by 15 pixels.
287 @remarks Note that this is the size of the bitmap you pass to
288 AddTool(), and not the eventual size of the
291 @see SetToolBitmapSize(), GetToolSize()
293 wxSize
GetToolBitmapSize();
296 Get any client data associated with the tool.
299 Id of the tool, as passed to AddTool().
301 @returns Client data, or @NULL if there is none.
303 wxObject
* GetToolClientData(int toolId
) const;
306 Called to determine whether a tool is enabled (responds to user input).
309 Id of the tool in question.
311 @returns @true if the tool is enabled, @false otherwise.
315 bool GetToolEnabled(int toolId
) const;
318 Returns the long help for the given tool.
321 The tool in question.
323 @see SetToolLongHelp(), SetToolShortHelp()
325 wxString
GetToolLongHelp(int toolId
) const;
328 Returns the value used for packing tools.
330 @see SetToolPacking()
332 int GetToolPacking() const;
335 Returns the tool position in the toolbar, or @c wxNOT_FOUND if the tool is not
338 int GetToolPos(int toolId
) const;
341 Returns the default separator size.
343 @see SetToolSeparation()
345 int GetToolSeparation() const;
348 Returns the short help for the given tool.
351 The tool in question.
353 @see GetToolLongHelp(), SetToolShortHelp()
355 wxString
GetToolShortHelp(int toolId
) const;
358 Returns the size of a whole button, which is usually larger than a tool bitmap
362 @see SetToolBitmapSize(), GetToolBitmapSize()
364 wxSize
GetToolSize();
367 Gets the on/off state of a toggle tool.
370 The tool in question.
372 @returns @true if the tool is toggled on, @false otherwise.
376 bool GetToolState(int toolId
) const;
379 Returns the number of tools in the toolbar.
381 int GetToolsCount() const;
384 Inserts the control into the toolbar at the given position.
385 You must call Realize() for the change to take place.
387 @see AddControl(), InsertTool()
389 wxToolBarToolBase
* InsertControl(size_t pos
, wxControl
* control
);
392 Inserts the separator into the toolbar at the given position.
393 You must call Realize() for the change to take place.
395 @see AddSeparator(), InsertTool()
397 wxToolBarToolBase
* InsertSeparator(size_t pos
);
401 Inserts the tool with the specified attributes into the toolbar at the given
403 You must call Realize() for the change to take place.
405 @see AddTool(), InsertControl(), InsertSeparator()
407 wxToolBarToolBase
* InsertTool(size_t pos
, int toolId
,
408 const wxBitmap
& bitmap1
,
409 const wxBitmap
& bitmap2
= wxNullBitmap
,
410 bool isToggle
= false,
411 wxObject
* clientData
= NULL
,
412 const wxString
& shortHelpString
= "",
413 const wxString
& longHelpString
= "");
414 wxToolBarToolBase
* InsertTool(size_t pos
,
415 wxToolBarToolBase
* tool
);
419 Called when the user clicks on a tool with the left mouse button.
420 This is the old way of detecting tool clicks; although it will still work,
421 you should use the EVT_MENU or EVT_TOOL macro instead.
424 The identifier passed to AddTool().
426 @true if the tool is a toggle and the toggle is down, otherwise is @false.
428 @returns If the tool is a toggle and this function returns @false, the
429 toggle toggle state (internal and visual) will not be
430 changed. This provides a way of specifying that toggle
431 operations are not permitted in some circumstances.
433 @see OnMouseEnter(), OnRightClick()
435 bool OnLeftClick(int toolId
, bool toggleDown
);
438 This is called when the mouse cursor moves into a tool or out of
440 This is the old way of detecting mouse enter events; although it will still
442 you should use the EVT_TOOL_ENTER macro instead.
445 Greater than -1 if the mouse cursor has moved into the tool,
446 or -1 if the mouse cursor has moved. The
447 programmer can override this to provide extra information about the tool,
448 such as a short description on the status line.
450 @remarks With some derived toolbar classes, if the mouse moves quickly
451 out of the toolbar, wxWidgets may not be able to detect
452 it. Therefore this function may not always be called
455 void OnMouseEnter(int toolId
);
458 Called when the user clicks on a tool with the right mouse button. The
459 programmer should override this function to detect right tool clicks.
460 This is the old way of detecting tool right clicks; although it will still work,
461 you should use the EVT_TOOL_RCLICKED macro instead.
464 The identifier passed to AddTool().
466 The x position of the mouse cursor.
468 The y position of the mouse cursor.
470 @remarks A typical use of this member might be to pop up a menu.
472 @see OnMouseEnter(), OnLeftClick()
474 void OnRightClick(int toolId
, float x
, float y
);
477 This function should be called after you have added tools.
482 Removes the given tool from the toolbar but doesn't delete it. This allows to
483 insert/add this tool back to this (or another) toolbar later.
484 Note that it is unnecessary to call Realize() for the
485 change to take place, it will happen immediately.
489 wxToolBarToolBase
* RemoveTool(int id
);
492 Sets the bitmap resource identifier for specifying tool bitmaps as indices
493 into a custom bitmap. Windows CE only.
495 void SetBitmapResource(int resourceId
);
498 Sets the dropdown menu for the tool given by its @e id. The tool itself will
499 delete the menu when it's no longer needed.
500 If you define a EVT_TOOL_DROPDOWN handler in your program, you must call
501 wxEvent::Skip from it or the menu won't be displayed.
503 bool SetDropdownMenu(int id
, wxMenu
* menu
);
507 Set the values to be used as margins for the toolbar.
512 Left margin, right margin and inter-tool separation value.
514 Top margin, bottom margin and inter-tool separation value.
516 @remarks This must be called before the tools are added if absolute
517 positioning is to be used, and the default (zero-size)
518 margins are to be overridden.
520 @see GetMargins(), wxSize
522 void SetMargins(const wxSize
& size
);
523 void SetMargins(int x
, int y
);
527 Sets the default size of each tool bitmap. The default bitmap size is 16 by 15
531 The size of the bitmaps in the toolbar.
533 @remarks This should be called to tell the toolbar what the tool bitmap
534 size is. Call it before you add tools.
536 @see GetToolBitmapSize(), GetToolSize()
538 void SetToolBitmapSize(const wxSize
& size
);
541 Sets the client data associated with the tool.
543 void SetToolClientData(int id
, wxObject
* clientData
);
546 Sets the bitmap to be used by the tool with the given ID when the tool
547 is in a disabled state. This can only be used on Button tools, not
548 controls. NOTE: The native toolbar classes on the main platforms all
549 synthesize the disabled bitmap from the normal bitmap, so this
550 function will have no effect on those platforms.
552 void SetToolDisabledBitmap(int id
, const wxBitmap
& bitmap
);
555 Sets the long help for the given tool.
558 The tool in question.
560 A string for the long help.
562 @remarks You might use the long help for displaying the tool purpose on
565 @see GetToolLongHelp(), SetToolShortHelp(),
567 void SetToolLongHelp(int toolId
, const wxString
& helpString
);
570 Sets the bitmap to be used by the tool with the given ID. This can
571 only be used on Button tools, not controls.
573 void SetToolNormalBitmap(int id
, const wxBitmap
& bitmap
);
576 Sets the value used for spacing tools. The default value is 1.
579 The value for packing.
581 @remarks The packing is used for spacing in the vertical direction if the
582 toolbar is horizontal, and for spacing in the
583 horizontal direction if the toolbar is vertical.
585 @see GetToolPacking()
587 void SetToolPacking(int packing
);
590 Sets the default separator size. The default value is 5.
597 void SetToolSeparation(int separation
);
600 Sets the short help for the given tool.
603 The tool in question.
605 The string for the short help.
607 @remarks An application might use short help for identifying the tool
608 purpose in a tooltip.
610 @see GetToolShortHelp(), SetToolLongHelp()
612 void SetToolShortHelp(int toolId
, const wxString
& helpString
);
615 Toggles a tool on or off. This does not cause any event to get emitted.
620 If @true, toggles the tool on, otherwise toggles it off.
622 @remarks Only applies to a tool that has been specified as a toggle tool.
624 void ToggleTool(int toolId
, bool toggle
);