]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: toolbar.h | |
e54c96f1 | 3 | // Purpose: interface of wxToolBar |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxToolBar | |
7c913512 | 11 | |
bb69632a FM |
12 | A toolbar is a bar of buttons and/or other controls usually placed below |
13 | the menu bar in a wxFrame. | |
7977b62a | 14 | |
bb69632a | 15 | You may create a toolbar that is managed by the frame, by calling |
7977b62a BP |
16 | wxFrame::CreateToolBar(). Under Pocket PC, you should always use this |
17 | function for creating the toolbar to be managed by the frame, so that | |
18 | wxWidgets can use a combined menubar and toolbar. Where you manage your | |
19 | own toolbars, create a wxToolBar as usual. | |
20 | ||
21 | The meaning of a "separator" is a vertical line under Windows and simple | |
22 | space under GTK+. | |
23 | ||
bb69632a FM |
24 | <b>wxMSW note</b>: Note that under wxMSW toolbar paints tools to reflect |
25 | system-wide colours. If you use more than 16 colours in your tool bitmaps, | |
26 | you may wish to suppress this behaviour, otherwise system colours in your | |
27 | bitmaps will inadvertently be mapped to system colours. | |
7977b62a | 28 | To do this, set the msw.remap system option before creating the toolbar: |
7977b62a BP |
29 | @code |
30 | wxSystemOptions::SetOption(wxT("msw.remap"), 0); | |
31 | @endcode | |
7977b62a BP |
32 | If you wish to use 32-bit images (which include an alpha channel for |
33 | transparency) use: | |
7977b62a BP |
34 | @code |
35 | wxSystemOptions::SetOption(wxT("msw.remap"), 2); | |
36 | @endcode | |
7977b62a BP |
37 | Then colour remapping is switched off, and a transparent background |
38 | used. But only use this option under Windows XP with true colour: | |
7977b62a BP |
39 | @code |
40 | if (wxTheApp->GetComCtl32Version() >= 600 && ::wxDisplayDepth() >= 32) | |
41 | @endcode | |
408776d0 | 42 | |
7977b62a BP |
43 | There are several different types of tools you can add to a toolbar. These |
44 | types are controlled by the ::wxItemKind enumeration. | |
7c913512 | 45 | |
23324ae1 | 46 | @beginStyleTable |
8c6791e4 | 47 | @style{wxTB_FLAT} |
7977b62a | 48 | Gives the toolbar a flat look (Windows and GTK only). |
8c6791e4 | 49 | @style{wxTB_DOCKABLE} |
7977b62a | 50 | Makes the toolbar floatable and dockable (GTK only). |
8c6791e4 | 51 | @style{wxTB_HORIZONTAL} |
7977b62a | 52 | Specifies horizontal layout (default). |
8c6791e4 | 53 | @style{wxTB_VERTICAL} |
7977b62a | 54 | Specifies vertical layout. |
8c6791e4 | 55 | @style{wxTB_TEXT} |
7977b62a | 56 | Shows the text in the toolbar buttons; by default only icons are shown. |
8c6791e4 | 57 | @style{wxTB_NOICONS} |
7977b62a | 58 | Specifies no icons in the toolbar buttons; by default they are shown. |
8c6791e4 | 59 | @style{wxTB_NODIVIDER} |
7977b62a | 60 | Specifies no divider (border) above the toolbar (Windows only) |
8c6791e4 | 61 | @style{wxTB_NOALIGN} |
7977b62a BP |
62 | Specifies no alignment with the parent window (Windows only, not very |
63 | useful). | |
8c6791e4 | 64 | @style{wxTB_HORZ_LAYOUT} |
7977b62a BP |
65 | Shows the text and the icons alongside, not vertically stacked (Windows |
66 | and GTK 2 only). This style must be used with @c wxTB_TEXT. | |
8c6791e4 | 67 | @style{wxTB_HORZ_TEXT} |
7977b62a | 68 | Combination of @c wxTB_HORZ_LAYOUT and @c wxTB_TEXT. |
8c6791e4 | 69 | @style{wxTB_NO_TOOLTIPS} |
7977b62a BP |
70 | Don't show the short help tooltips for the tools when the mouse hovers |
71 | over them. | |
8c6791e4 | 72 | @style{wxTB_BOTTOM} |
7977b62a | 73 | Align the toolbar at the bottom of parent window. |
8c6791e4 | 74 | @style{wxTB_RIGHT} |
7977b62a | 75 | Align the toolbar at the right side of parent window. |
23324ae1 | 76 | @endStyleTable |
7c913512 | 77 | |
7977b62a BP |
78 | See also @ref overview_windowstyles. Note that the Win32 native toolbar |
79 | ignores @c wxTB_NOICONS style. Also, toggling the @c wxTB_TEXT works only | |
80 | if the style was initially on. | |
81 | ||
82 | @beginEventTable{wxCommandEvent} | |
83 | @event{EVT_TOOL(id, func)} | |
84 | Process a @c wxEVT_COMMAND_TOOL_CLICKED event (a synonym for @c | |
85 | wxEVT_COMMAND_MENU_SELECTED). Pass the id of the tool. | |
86 | @event{EVT_MENU(id, func)} | |
87 | The same as EVT_TOOL(). | |
88 | @event{EVT_TOOL_RANGE(id1, id2, func)} | |
89 | Process a @c wxEVT_COMMAND_TOOL_CLICKED event for a range of | |
90 | identifiers. Pass the ids of the tools. | |
91 | @event{EVT_MENU_RANGE(id1, id2, func)} | |
92 | The same as EVT_TOOL_RANGE(). | |
93 | @event{EVT_TOOL_RCLICKED(id, func)} | |
94 | Process a @c wxEVT_COMMAND_TOOL_RCLICKED event. Pass the id of the | |
95 | tool. | |
96 | @event{EVT_TOOL_RCLICKED_RANGE(id1, id2, func)} | |
97 | Process a @c wxEVT_COMMAND_TOOL_RCLICKED event for a range of ids. Pass | |
98 | the ids of the tools. | |
99 | @event{EVT_TOOL_ENTER(id, func)} | |
100 | Process a @c wxEVT_COMMAND_TOOL_ENTER event. Pass the id of the toolbar | |
101 | itself. The value of wxCommandEvent::GetSelection() is the tool id, or | |
102 | -1 if the mouse cursor has moved off a tool. | |
103 | @event{EVT_TOOL_DROPDOWN(id, func)} | |
104 | Process a @c wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED event. If unhandled, | |
105 | displays the default dropdown menu set using | |
106 | wxToolBar::SetDropdownMenu(). | |
107 | @endEventTable | |
408776d0 | 108 | |
7977b62a BP |
109 | The toolbar class emits menu commands in the same way that a frame menubar |
110 | does, so you can use one EVT_MENU() macro for both a menu item and a toolbar | |
111 | button. The event handler functions take a wxCommandEvent argument. For most | |
112 | event macros, the identifier of the tool is passed, but for EVT_TOOL_ENTER() | |
113 | the toolbar window identifier is passed and the tool identifier is retrieved | |
114 | from the wxCommandEvent. This is because the identifier may be -1 when the | |
115 | mouse moves off a tool, and -1 is not allowed as an identifier in the event | |
116 | system. | |
117 | ||
118 | @library{wxcore} | |
23324ae1 | 119 | @category{miscwnd} |
7c913512 | 120 | |
f09b5681 | 121 | @see @ref overview_toolbar |
23324ae1 FM |
122 | */ |
123 | class wxToolBar : public wxControl | |
124 | { | |
125 | public: | |
7977b62a BP |
126 | /** |
127 | Default constructor. | |
128 | */ | |
129 | wxToolBar(); | |
130 | ||
23324ae1 FM |
131 | /** |
132 | Constructs a toolbar. | |
3c4f71cc | 133 | |
7c913512 | 134 | @param parent |
4cc4bfaf | 135 | Pointer to a parent window. |
7c913512 | 136 | @param id |
4cc4bfaf | 137 | Window identifier. If -1, will automatically create an identifier. |
7c913512 | 138 | @param pos |
7977b62a BP |
139 | Window position. ::wxDefaultPosition is (-1, -1) which indicates that |
140 | wxWidgets should generate a default position for the window. If | |
141 | using the wxWindow class directly, supply an actual position. | |
7c913512 | 142 | @param size |
7977b62a BP |
143 | Window size. ::wxDefaultSize is (-1, -1) which indicates that |
144 | wxWidgets should generate a default size for the window. | |
7c913512 | 145 | @param style |
4cc4bfaf | 146 | Window style. See wxToolBar for details. |
7c913512 | 147 | @param name |
4cc4bfaf | 148 | Window name. |
3c4f71cc | 149 | |
7977b62a BP |
150 | @remarks After a toolbar is created, you use AddTool() and perhaps |
151 | AddSeparator(), and then you must call Realize() to construct and | |
152 | display the toolbar tools. | |
23324ae1 | 153 | */ |
7c913512 FM |
154 | wxToolBar(wxWindow* parent, wxWindowID id, |
155 | const wxPoint& pos = wxDefaultPosition, | |
156 | const wxSize& size = wxDefaultSize, | |
4cc4bfaf | 157 | long style = wxTB_HORIZONTAL | wxBORDER_NONE, |
408776d0 | 158 | const wxString& name = wxToolBarNameStr); |
23324ae1 FM |
159 | |
160 | /** | |
161 | Toolbar destructor. | |
162 | */ | |
adaaa686 | 163 | virtual ~wxToolBar(); |
23324ae1 FM |
164 | |
165 | /** | |
7977b62a BP |
166 | Adds a new check (or toggle) tool to the toolbar. The parameters are the |
167 | same as in AddTool(). | |
3c4f71cc | 168 | |
4cc4bfaf | 169 | @see AddTool() |
23324ae1 | 170 | */ |
43c48e1e | 171 | wxToolBarToolBase* AddCheckTool(int toolId, const wxString& label, |
23324ae1 | 172 | const wxBitmap& bitmap1, |
43c48e1e FM |
173 | const wxBitmap& bmpDisabled = wxNullBitmap, |
174 | const wxString& shortHelp = wxEmptyString, | |
175 | const wxString& longHelp = wxEmptyString, | |
4cc4bfaf | 176 | wxObject* clientData = NULL); |
23324ae1 FM |
177 | |
178 | /** | |
7977b62a | 179 | Adds any control to the toolbar, typically e.g. a wxComboBox. |
3c4f71cc | 180 | |
7c913512 | 181 | @param control |
4cc4bfaf | 182 | The control to be added. |
7c913512 | 183 | @param label |
4cc4bfaf | 184 | Text to be displayed near the control. |
3c4f71cc | 185 | |
7977b62a BP |
186 | @remarks |
187 | wxMSW: the label is only displayed if there is enough space | |
188 | available below the embedded control. | |
189 | ||
190 | @remarks | |
191 | wxMac: labels are only displayed if wxWidgets is built with @c | |
192 | wxMAC_USE_NATIVE_TOOLBAR set to 1 | |
23324ae1 | 193 | */ |
43c48e1e FM |
194 | virtual wxToolBarToolBase* AddControl(wxControl* control, |
195 | const wxString& label = wxEmptyString); | |
23324ae1 FM |
196 | |
197 | /** | |
7977b62a BP |
198 | Adds a new radio tool to the toolbar. Consecutive radio tools form a |
199 | radio group such that exactly one button in the group is pressed at any | |
200 | moment, in other words whenever a button in the group is pressed the | |
201 | previously pressed button is automatically released. You should avoid | |
202 | having the radio groups of only one element as it would be impossible | |
203 | for the user to use such button. | |
408776d0 | 204 | |
7977b62a BP |
205 | By default, the first button in the radio group is initially pressed, |
206 | the others are not. | |
207 | ||
3c4f71cc | 208 | |
4cc4bfaf | 209 | @see AddTool() |
23324ae1 | 210 | */ |
43c48e1e | 211 | wxToolBarToolBase* AddRadioTool(int toolId, const wxString& label, |
23324ae1 | 212 | const wxBitmap& bitmap1, |
43c48e1e FM |
213 | const wxBitmap& bmpDisabled = wxNullBitmap, |
214 | const wxString& shortHelp = wxEmptyString, | |
215 | const wxString& longHelp = wxEmptyString, | |
4cc4bfaf | 216 | wxObject* clientData = NULL); |
23324ae1 FM |
217 | |
218 | /** | |
219 | Adds a separator for spacing groups of tools. | |
3c4f71cc | 220 | |
4cc4bfaf | 221 | @see AddTool(), SetToolSeparation() |
23324ae1 | 222 | */ |
43c48e1e | 223 | virtual wxToolBarToolBase* AddSeparator(); |
23324ae1 | 224 | |
23324ae1 | 225 | /** |
922da38b BP |
226 | Adds a tool to the toolbar. |
227 | ||
228 | @param tool | |
229 | The tool to be added. | |
230 | ||
231 | @remarks After you have added tools to a toolbar, you must call | |
232 | Realize() in order to have the tools appear. | |
233 | ||
234 | @see AddSeparator(), AddCheckTool(), AddRadioTool(), | |
235 | InsertTool(), DeleteTool(), Realize(), SetDropdownMenu() | |
236 | */ | |
adaaa686 | 237 | virtual wxToolBarToolBase* AddTool(wxToolBarToolBase* tool); |
922da38b BP |
238 | |
239 | /** | |
408776d0 | 240 | Adds a tool to the toolbar. This most commonly used version has fewer |
922da38b BP |
241 | parameters than the full version below which specifies the more rarely |
242 | used button features. | |
3c4f71cc | 243 | |
7c913512 | 244 | @param toolId |
7977b62a BP |
245 | An integer by which the tool may be identified in subsequent |
246 | operations. | |
408776d0 | 247 | @param label |
922da38b BP |
248 | The string to be displayed with the tool. |
249 | @param bitmap | |
250 | The primary tool bitmap. | |
251 | @param shortHelp | |
252 | This string is used for the tools tooltip. | |
7c913512 | 253 | @param kind |
7977b62a BP |
254 | May be ::wxITEM_NORMAL for a normal button (default), ::wxITEM_CHECK |
255 | for a checkable tool (such tool stays pressed after it had been | |
256 | toggled) or ::wxITEM_RADIO for a checkable tool which makes part of | |
408776d0 | 257 | a radio group of tools each of which is automatically unchecked |
970e987e RR |
258 | whenever another button in the group is checked. ::wxITEM_DROPDOWN |
259 | specifies that a drop-down menu button will appear next to the | |
260 | tool button (only GTK+ and MSW). Call SetDropdownMenu() afterwards. | |
922da38b BP |
261 | |
262 | @remarks After you have added tools to a toolbar, you must call | |
263 | Realize() in order to have the tools appear. | |
264 | ||
265 | @see AddSeparator(), AddCheckTool(), AddRadioTool(), | |
266 | InsertTool(), DeleteTool(), Realize(), SetDropdownMenu() | |
267 | */ | |
268 | wxToolBarToolBase* AddTool(int toolId, const wxString& label, | |
269 | const wxBitmap& bitmap, | |
270 | const wxString& shortHelp = wxEmptyString, | |
271 | wxItemKind kind = wxITEM_NORMAL); | |
272 | ||
273 | /** | |
274 | Adds a tool to the toolbar. | |
275 | ||
276 | @param toolId | |
277 | An integer by which the tool may be identified in subsequent | |
278 | operations. | |
408776d0 | 279 | @param label |
922da38b BP |
280 | The string to be displayed with the tool. |
281 | @param bitmap | |
4cc4bfaf | 282 | The primary tool bitmap. |
922da38b | 283 | @param bmpDisabled |
4cc4bfaf | 284 | The bitmap used when the tool is disabled. If it is equal to |
408776d0 | 285 | ::wxNullBitmap (default), the disabled bitmap is automatically |
922da38b | 286 | generated by greying the normal one. |
7c913512 | 287 | @param shortHelpString |
7977b62a | 288 | This string is used for the tools tooltip. |
7c913512 | 289 | @param longHelpString |
7977b62a BP |
290 | This string is shown in the statusbar (if any) of the parent frame |
291 | when the mouse pointer is inside the tool. | |
922da38b BP |
292 | @param kind |
293 | May be ::wxITEM_NORMAL for a normal button (default), ::wxITEM_CHECK | |
294 | for a checkable tool (such tool stays pressed after it had been | |
295 | toggled) or ::wxITEM_RADIO for a checkable tool which makes part of | |
408776d0 | 296 | a radio group of tools each of which is automatically unchecked |
922da38b BP |
297 | whenever another button in the group is checked. ::wxITEM_DROPDOWN |
298 | specifies that a drop-down menu button will appear next to the | |
299 | tool button (only GTK+ and MSW). Call SetDropdownMenu() afterwards. | |
7c913512 | 300 | @param clientData |
7977b62a BP |
301 | An optional pointer to client data which can be retrieved later |
302 | using GetToolClientData(). | |
3c4f71cc | 303 | |
23324ae1 | 304 | @remarks After you have added tools to a toolbar, you must call |
7977b62a | 305 | Realize() in order to have the tools appear. |
3c4f71cc | 306 | |
4cc4bfaf | 307 | @see AddSeparator(), AddCheckTool(), AddRadioTool(), |
970e987e | 308 | InsertTool(), DeleteTool(), Realize(), SetDropdownMenu() |
23324ae1 FM |
309 | */ |
310 | wxToolBarToolBase* AddTool(int toolId, const wxString& label, | |
922da38b BP |
311 | const wxBitmap& bitmap, |
312 | const wxBitmap& bmpDisabled = wxNullBitmap, | |
7c913512 | 313 | wxItemKind kind = wxITEM_NORMAL, |
922da38b BP |
314 | const wxString& shortHelpString = wxEmptyString, |
315 | const wxString& longHelpString = wxEmptyString, | |
4cc4bfaf | 316 | wxObject* clientData = NULL); |
23324ae1 FM |
317 | |
318 | /** | |
319 | Deletes all the tools in the toolbar. | |
320 | */ | |
adaaa686 | 321 | virtual void ClearTools(); |
23324ae1 FM |
322 | |
323 | /** | |
7977b62a BP |
324 | Removes the specified tool from the toolbar and deletes it. If you don't |
325 | want to delete the tool, but just to remove it from the toolbar (to | |
326 | possibly add it back later), you may use RemoveTool() instead. | |
327 | ||
328 | @note It is unnecessary to call Realize() for the change to take | |
329 | place, it will happen immediately. | |
330 | ||
331 | @returns @true if the tool was deleted, @false otherwise. | |
3c4f71cc | 332 | |
4cc4bfaf | 333 | @see DeleteToolByPos() |
23324ae1 | 334 | */ |
adaaa686 | 335 | virtual bool DeleteTool(int toolId); |
23324ae1 FM |
336 | |
337 | /** | |
7977b62a BP |
338 | This function behaves like DeleteTool() but it deletes the tool at the |
339 | specified position and not the one with the given id. | |
23324ae1 | 340 | */ |
adaaa686 | 341 | virtual bool DeleteToolByPos(size_t pos); |
23324ae1 FM |
342 | |
343 | /** | |
344 | Enables or disables the tool. | |
3c4f71cc | 345 | |
7c913512 | 346 | @param toolId |
4cc4bfaf | 347 | Tool to enable or disable. |
7c913512 | 348 | @param enable |
4cc4bfaf | 349 | If @true, enables the tool, otherwise disables it. |
3c4f71cc | 350 | |
23324ae1 | 351 | @remarks Some implementations will change the visible state of the tool |
7977b62a BP |
352 | to indicate that it is disabled. |
353 | ||
3c4f71cc | 354 | |
4cc4bfaf | 355 | @see GetToolEnabled(), ToggleTool() |
23324ae1 | 356 | */ |
adaaa686 | 357 | virtual void EnableTool(int toolId, bool enable); |
23324ae1 FM |
358 | |
359 | /** | |
7977b62a BP |
360 | Returns a pointer to the tool identified by @a id or @NULL if no |
361 | corresponding tool is found. | |
23324ae1 | 362 | */ |
adaaa686 | 363 | wxToolBarToolBase* FindById(int id) const; |
23324ae1 FM |
364 | |
365 | /** | |
7977b62a BP |
366 | Returns a pointer to the control identified by @a id or @NULL if no |
367 | corresponding control is found. | |
23324ae1 | 368 | */ |
adaaa686 | 369 | virtual wxControl* FindControl(int id); |
23324ae1 FM |
370 | |
371 | /** | |
372 | Finds a tool for the given mouse position. | |
3c4f71cc | 373 | |
7c913512 | 374 | @param x |
4cc4bfaf | 375 | X position. |
7c913512 | 376 | @param y |
4cc4bfaf | 377 | Y position. |
3c4f71cc | 378 | |
d29a9a8a | 379 | @return A pointer to a tool if a tool is found, or @NULL otherwise. |
3c4f71cc | 380 | |
7977b62a BP |
381 | @remarks Currently not implemented in wxGTK (always returns @NULL |
382 | there). | |
23324ae1 | 383 | */ |
adaaa686 | 384 | virtual wxToolBarToolBase* FindToolForPosition(wxCoord x, wxCoord y) const; |
23324ae1 FM |
385 | |
386 | /** | |
387 | Returns the left/right and top/bottom margins, which are also used for | |
388 | inter-toolspacing. | |
3c4f71cc | 389 | |
4cc4bfaf | 390 | @see SetMargins() |
23324ae1 | 391 | */ |
328f5751 | 392 | wxSize GetMargins() const; |
23324ae1 FM |
393 | |
394 | /** | |
7977b62a BP |
395 | Returns the size of bitmap that the toolbar expects to have. The default |
396 | bitmap size is 16 by 15 pixels. | |
3c4f71cc | 397 | |
7977b62a BP |
398 | @remarks Note that this is the size of the bitmap you pass to AddTool(), |
399 | and not the eventual size of the tool button. | |
3c4f71cc | 400 | |
4cc4bfaf | 401 | @see SetToolBitmapSize(), GetToolSize() |
23324ae1 | 402 | */ |
adaaa686 | 403 | virtual wxSize GetToolBitmapSize() const; |
23324ae1 FM |
404 | |
405 | /** | |
406 | Get any client data associated with the tool. | |
3c4f71cc | 407 | |
7c913512 | 408 | @param toolId |
4cc4bfaf | 409 | Id of the tool, as passed to AddTool(). |
3c4f71cc | 410 | |
d29a9a8a | 411 | @return Client data, or @NULL if there is none. |
23324ae1 | 412 | */ |
adaaa686 | 413 | virtual wxObject* GetToolClientData(int toolId) const; |
23324ae1 FM |
414 | |
415 | /** | |
416 | Called to determine whether a tool is enabled (responds to user input). | |
3c4f71cc | 417 | |
7c913512 | 418 | @param toolId |
4cc4bfaf | 419 | Id of the tool in question. |
3c4f71cc | 420 | |
d29a9a8a | 421 | @return @true if the tool is enabled, @false otherwise. |
3c4f71cc | 422 | |
4cc4bfaf | 423 | @see EnableTool() |
23324ae1 | 424 | */ |
adaaa686 | 425 | virtual bool GetToolEnabled(int toolId) const; |
23324ae1 FM |
426 | |
427 | /** | |
428 | Returns the long help for the given tool. | |
3c4f71cc | 429 | |
7c913512 | 430 | @param toolId |
4cc4bfaf | 431 | The tool in question. |
3c4f71cc | 432 | |
4cc4bfaf | 433 | @see SetToolLongHelp(), SetToolShortHelp() |
23324ae1 | 434 | */ |
adaaa686 | 435 | virtual wxString GetToolLongHelp(int toolId) const; |
23324ae1 FM |
436 | |
437 | /** | |
438 | Returns the value used for packing tools. | |
3c4f71cc | 439 | |
4cc4bfaf | 440 | @see SetToolPacking() |
23324ae1 | 441 | */ |
adaaa686 | 442 | virtual int GetToolPacking() const; |
23324ae1 FM |
443 | |
444 | /** | |
7977b62a BP |
445 | Returns the tool position in the toolbar, or @c wxNOT_FOUND if the tool |
446 | is not found. | |
23324ae1 | 447 | */ |
adaaa686 | 448 | virtual int GetToolPos(int toolId) const; |
23324ae1 FM |
449 | |
450 | /** | |
451 | Returns the default separator size. | |
3c4f71cc | 452 | |
4cc4bfaf | 453 | @see SetToolSeparation() |
23324ae1 | 454 | */ |
adaaa686 | 455 | virtual int GetToolSeparation() const; |
23324ae1 FM |
456 | |
457 | /** | |
458 | Returns the short help for the given tool. | |
3c4f71cc | 459 | |
7c913512 | 460 | @param toolId |
4cc4bfaf | 461 | The tool in question. |
3c4f71cc | 462 | |
4cc4bfaf | 463 | @see GetToolLongHelp(), SetToolShortHelp() |
23324ae1 | 464 | */ |
adaaa686 | 465 | virtual wxString GetToolShortHelp(int toolId) const; |
23324ae1 FM |
466 | |
467 | /** | |
7977b62a BP |
468 | Returns the size of a whole button, which is usually larger than a tool |
469 | bitmap because of added 3D effects. | |
3c4f71cc | 470 | |
4cc4bfaf | 471 | @see SetToolBitmapSize(), GetToolBitmapSize() |
23324ae1 | 472 | */ |
adaaa686 | 473 | virtual wxSize GetToolSize() const; |
23324ae1 FM |
474 | |
475 | /** | |
476 | Gets the on/off state of a toggle tool. | |
3c4f71cc | 477 | |
7c913512 | 478 | @param toolId |
4cc4bfaf | 479 | The tool in question. |
3c4f71cc | 480 | |
d29a9a8a | 481 | @return @true if the tool is toggled on, @false otherwise. |
3c4f71cc | 482 | |
4cc4bfaf | 483 | @see ToggleTool() |
23324ae1 | 484 | */ |
adaaa686 | 485 | virtual bool GetToolState(int toolId) const; |
23324ae1 FM |
486 | |
487 | /** | |
488 | Returns the number of tools in the toolbar. | |
489 | */ | |
43c48e1e | 490 | size_t GetToolsCount() const; |
23324ae1 FM |
491 | |
492 | /** | |
7977b62a BP |
493 | Inserts the control into the toolbar at the given position. You must |
494 | call Realize() for the change to take place. | |
3c4f71cc | 495 | |
4cc4bfaf | 496 | @see AddControl(), InsertTool() |
23324ae1 | 497 | */ |
43c48e1e FM |
498 | virtual wxToolBarToolBase* InsertControl(size_t pos, wxControl* control, |
499 | const wxString& label = wxEmptyString); | |
23324ae1 FM |
500 | |
501 | /** | |
7977b62a BP |
502 | Inserts the separator into the toolbar at the given position. You must |
503 | call Realize() for the change to take place. | |
3c4f71cc | 504 | |
4cc4bfaf | 505 | @see AddSeparator(), InsertTool() |
23324ae1 | 506 | */ |
adaaa686 | 507 | virtual wxToolBarToolBase* InsertSeparator(size_t pos); |
23324ae1 FM |
508 | |
509 | //@{ | |
510 | /** | |
7977b62a BP |
511 | Inserts the tool with the specified attributes into the toolbar at the |
512 | given position. | |
513 | ||
23324ae1 | 514 | You must call Realize() for the change to take place. |
3c4f71cc | 515 | |
4cc4bfaf FM |
516 | @see AddTool(), InsertControl(), InsertSeparator() |
517 | */ | |
518 | wxToolBarToolBase* InsertTool(size_t pos, int toolId, | |
519 | const wxBitmap& bitmap1, | |
520 | const wxBitmap& bitmap2 = wxNullBitmap, | |
521 | bool isToggle = false, | |
522 | wxObject* clientData = NULL, | |
523 | const wxString& shortHelpString = "", | |
524 | const wxString& longHelpString = ""); | |
525 | wxToolBarToolBase* InsertTool(size_t pos, | |
526 | wxToolBarToolBase* tool); | |
23324ae1 FM |
527 | //@} |
528 | ||
529 | /** | |
7977b62a BP |
530 | Called when the user clicks on a tool with the left mouse button. This |
531 | is the old way of detecting tool clicks; although it will still work, | |
532 | you should use the EVT_MENU() or EVT_TOOL() macro instead. | |
3c4f71cc | 533 | |
7c913512 | 534 | @param toolId |
4cc4bfaf | 535 | The identifier passed to AddTool(). |
7c913512 | 536 | @param toggleDown |
7977b62a BP |
537 | @true if the tool is a toggle and the toggle is down, otherwise is |
538 | @false. | |
3c4f71cc | 539 | |
d29a9a8a | 540 | @return If the tool is a toggle and this function returns @false, the |
7977b62a BP |
541 | toggle state (internal and visual) will not be changed. This |
542 | provides a way of specifying that toggle operations are not | |
543 | permitted in some circumstances. | |
3c4f71cc | 544 | |
4cc4bfaf | 545 | @see OnMouseEnter(), OnRightClick() |
23324ae1 | 546 | */ |
adaaa686 | 547 | virtual bool OnLeftClick(int toolId, bool toggleDown); |
23324ae1 FM |
548 | |
549 | /** | |
7977b62a BP |
550 | This is called when the mouse cursor moves into a tool or out of the |
551 | toolbar. This is the old way of detecting mouse enter events; | |
552 | although it will still work, you should use the EVT_TOOL_ENTER() | |
553 | macro instead. | |
3c4f71cc | 554 | |
7c913512 | 555 | @param toolId |
7977b62a BP |
556 | Greater than -1 if the mouse cursor has moved into the tool, or -1 |
557 | if the mouse cursor has moved. The programmer can override this to | |
558 | provide extra information about the tool, such as a short | |
559 | description on the status line. | |
3c4f71cc | 560 | |
23324ae1 | 561 | @remarks With some derived toolbar classes, if the mouse moves quickly |
7977b62a BP |
562 | out of the toolbar, wxWidgets may not be able to detect it. |
563 | Therefore this function may not always be called when expected. | |
23324ae1 | 564 | */ |
adaaa686 | 565 | virtual void OnMouseEnter(int toolId); |
23324ae1 FM |
566 | |
567 | /** | |
7977b62a BP |
568 | @deprecated This is the old way of detecting tool right clicks; |
569 | although it will still work, you should use the | |
570 | EVT_TOOL_RCLICKED() macro instead. | |
571 | ||
23324ae1 FM |
572 | Called when the user clicks on a tool with the right mouse button. The |
573 | programmer should override this function to detect right tool clicks. | |
3c4f71cc | 574 | |
7c913512 | 575 | @param toolId |
4cc4bfaf | 576 | The identifier passed to AddTool(). |
7c913512 | 577 | @param x |
4cc4bfaf | 578 | The x position of the mouse cursor. |
7c913512 | 579 | @param y |
4cc4bfaf | 580 | The y position of the mouse cursor. |
3c4f71cc | 581 | |
23324ae1 | 582 | @remarks A typical use of this member might be to pop up a menu. |
3c4f71cc | 583 | |
4cc4bfaf | 584 | @see OnMouseEnter(), OnLeftClick() |
23324ae1 | 585 | */ |
43c48e1e | 586 | virtual void OnRightClick(int toolId, long x, long y); |
23324ae1 FM |
587 | |
588 | /** | |
589 | This function should be called after you have added tools. | |
590 | */ | |
adaaa686 | 591 | virtual bool Realize(); |
23324ae1 FM |
592 | |
593 | /** | |
7977b62a BP |
594 | Removes the given tool from the toolbar but doesn't delete it. This |
595 | allows to insert/add this tool back to this (or another) toolbar later. | |
596 | ||
597 | @note It is unnecessary to call Realize() for the change to take place, | |
598 | it will happen immediately. | |
599 | ||
3c4f71cc | 600 | |
4cc4bfaf | 601 | @see DeleteTool() |
23324ae1 | 602 | */ |
adaaa686 | 603 | virtual wxToolBarToolBase* RemoveTool(int id); |
23324ae1 FM |
604 | |
605 | /** | |
7977b62a BP |
606 | Sets the bitmap resource identifier for specifying tool bitmaps as |
607 | indices into a custom bitmap. Windows CE only. | |
23324ae1 FM |
608 | */ |
609 | void SetBitmapResource(int resourceId); | |
610 | ||
611 | /** | |
7977b62a | 612 | Sets the dropdown menu for the tool given by its @e id. The tool itself |
970e987e RR |
613 | will delete the menu when it's no longer needed. Only supported under |
614 | GTK+ und MSW. | |
7977b62a BP |
615 | |
616 | If you define a EVT_TOOL_DROPDOWN() handler in your program, you must | |
617 | call wxEvent::Skip() from it or the menu won't be displayed. | |
23324ae1 FM |
618 | */ |
619 | bool SetDropdownMenu(int id, wxMenu* menu); | |
620 | ||
23324ae1 FM |
621 | /** |
622 | Set the values to be used as margins for the toolbar. | |
3c4f71cc | 623 | |
7c913512 | 624 | @param x |
4cc4bfaf | 625 | Left margin, right margin and inter-tool separation value. |
7c913512 | 626 | @param y |
4cc4bfaf | 627 | Top margin, bottom margin and inter-tool separation value. |
3c4f71cc | 628 | |
23324ae1 | 629 | @remarks This must be called before the tools are added if absolute |
7977b62a BP |
630 | positioning is to be used, and the default (zero-size) margins are |
631 | to be overridden. | |
3c4f71cc | 632 | |
922da38b BP |
633 | @see GetMargins() |
634 | */ | |
adaaa686 | 635 | virtual void SetMargins(int x, int y); |
922da38b BP |
636 | |
637 | /** | |
638 | Set the margins for the toolbar. | |
639 | ||
640 | @param size | |
641 | Margin size. | |
642 | ||
643 | @remarks This must be called before the tools are added if absolute | |
644 | positioning is to be used, and the default (zero-size) margins are | |
645 | to be overridden. | |
646 | ||
4cc4bfaf | 647 | @see GetMargins(), wxSize |
23324ae1 FM |
648 | */ |
649 | void SetMargins(const wxSize& size); | |
23324ae1 FM |
650 | |
651 | /** | |
7977b62a BP |
652 | Sets the default size of each tool bitmap. The default bitmap size is 16 |
653 | by 15 pixels. | |
3c4f71cc | 654 | |
7c913512 | 655 | @param size |
4cc4bfaf | 656 | The size of the bitmaps in the toolbar. |
3c4f71cc | 657 | |
23324ae1 | 658 | @remarks This should be called to tell the toolbar what the tool bitmap |
7977b62a | 659 | size is. Call it before you add tools. |
3c4f71cc | 660 | |
4cc4bfaf | 661 | @see GetToolBitmapSize(), GetToolSize() |
23324ae1 | 662 | */ |
adaaa686 | 663 | virtual void SetToolBitmapSize(const wxSize& size); |
23324ae1 FM |
664 | |
665 | /** | |
666 | Sets the client data associated with the tool. | |
667 | */ | |
adaaa686 | 668 | virtual void SetToolClientData(int id, wxObject* clientData); |
23324ae1 FM |
669 | |
670 | /** | |
671 | Sets the bitmap to be used by the tool with the given ID when the tool | |
7977b62a BP |
672 | is in a disabled state. This can only be used on Button tools, not |
673 | controls. | |
674 | ||
675 | @note The native toolbar classes on the main platforms all synthesize | |
676 | the disabled bitmap from the normal bitmap, so this function will | |
677 | have no effect on those platforms. | |
678 | ||
23324ae1 | 679 | */ |
adaaa686 | 680 | virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap); |
23324ae1 FM |
681 | |
682 | /** | |
683 | Sets the long help for the given tool. | |
3c4f71cc | 684 | |
7c913512 | 685 | @param toolId |
4cc4bfaf | 686 | The tool in question. |
7c913512 | 687 | @param helpString |
4cc4bfaf | 688 | A string for the long help. |
3c4f71cc | 689 | |
23324ae1 | 690 | @remarks You might use the long help for displaying the tool purpose on |
7977b62a | 691 | the status line. |
3c4f71cc | 692 | |
4cc4bfaf | 693 | @see GetToolLongHelp(), SetToolShortHelp(), |
23324ae1 | 694 | */ |
adaaa686 | 695 | virtual void SetToolLongHelp(int toolId, const wxString& helpString); |
23324ae1 FM |
696 | |
697 | /** | |
7977b62a BP |
698 | Sets the bitmap to be used by the tool with the given ID. This can only |
699 | be used on Button tools, not controls. | |
23324ae1 | 700 | */ |
adaaa686 | 701 | virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap); |
23324ae1 FM |
702 | |
703 | /** | |
704 | Sets the value used for spacing tools. The default value is 1. | |
3c4f71cc | 705 | |
7c913512 | 706 | @param packing |
4cc4bfaf | 707 | The value for packing. |
3c4f71cc | 708 | |
408776d0 | 709 | @remarks The packing is used for spacing in the vertical direction if |
7977b62a BP |
710 | the toolbar is horizontal, and for spacing in the horizontal |
711 | direction if the toolbar is vertical. | |
3c4f71cc | 712 | |
4cc4bfaf | 713 | @see GetToolPacking() |
23324ae1 | 714 | */ |
adaaa686 | 715 | virtual void SetToolPacking(int packing); |
23324ae1 FM |
716 | |
717 | /** | |
718 | Sets the default separator size. The default value is 5. | |
3c4f71cc | 719 | |
7c913512 | 720 | @param separation |
4cc4bfaf | 721 | The separator size. |
3c4f71cc | 722 | |
4cc4bfaf | 723 | @see AddSeparator() |
23324ae1 | 724 | */ |
adaaa686 | 725 | virtual void SetToolSeparation(int separation); |
23324ae1 FM |
726 | |
727 | /** | |
728 | Sets the short help for the given tool. | |
3c4f71cc | 729 | |
7c913512 | 730 | @param toolId |
4cc4bfaf | 731 | The tool in question. |
7c913512 | 732 | @param helpString |
4cc4bfaf | 733 | The string for the short help. |
3c4f71cc | 734 | |
23324ae1 | 735 | @remarks An application might use short help for identifying the tool |
7977b62a BP |
736 | purpose in a tooltip. |
737 | ||
3c4f71cc | 738 | |
4cc4bfaf | 739 | @see GetToolShortHelp(), SetToolLongHelp() |
23324ae1 | 740 | */ |
adaaa686 | 741 | virtual void SetToolShortHelp(int toolId, const wxString& helpString); |
23324ae1 FM |
742 | |
743 | /** | |
744 | Toggles a tool on or off. This does not cause any event to get emitted. | |
3c4f71cc | 745 | |
7c913512 | 746 | @param toolId |
4cc4bfaf | 747 | Tool in question. |
7c913512 | 748 | @param toggle |
4cc4bfaf | 749 | If @true, toggles the tool on, otherwise toggles it off. |
3c4f71cc | 750 | |
7977b62a BP |
751 | @remarks Only applies to a tool that has been specified as a toggle |
752 | tool. | |
23324ae1 | 753 | */ |
adaaa686 | 754 | virtual void ToggleTool(int toolId, bool toggle); |
23324ae1 | 755 | }; |
e54c96f1 | 756 |