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