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