]>
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 | |
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 | |
31 | the visible state of the item within the 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 BP |
38 | @code |
39 | wxSystemOptions::SetOption(wxT("msw.remap"), 0); | |
40 | @endcode | |
7977b62a BP |
41 | If you wish to use 32-bit images (which include an alpha channel for |
42 | transparency) use: | |
7977b62a BP |
43 | @code |
44 | wxSystemOptions::SetOption(wxT("msw.remap"), 2); | |
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 | ||
88 | @beginEventTable{wxCommandEvent} | |
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 | |
101 | tool. | |
102 | @event{EVT_TOOL_RCLICKED_RANGE(id1, id2, func)} | |
103 | Process a @c wxEVT_COMMAND_TOOL_RCLICKED event for a range of ids. Pass | |
104 | the ids of the tools. | |
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 | |
108 | -1 if the mouse cursor has moved off a tool. | |
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 | |
b1557978 FM |
227 | Note that the meaning of a "separator" is a vertical line under wxMSW and |
228 | a simple space under wxGTK. | |
229 | ||
4cc4bfaf | 230 | @see AddTool(), SetToolSeparation() |
23324ae1 | 231 | */ |
43c48e1e | 232 | virtual wxToolBarToolBase* AddSeparator(); |
23324ae1 | 233 | |
8d13e301 | 234 | //@{ |
23324ae1 | 235 | /** |
922da38b BP |
236 | Adds a tool to the toolbar. |
237 | ||
238 | @param tool | |
239 | The tool to be added. | |
240 | ||
241 | @remarks After you have added tools to a toolbar, you must call | |
242 | Realize() in order to have the tools appear. | |
243 | ||
244 | @see AddSeparator(), AddCheckTool(), AddRadioTool(), | |
245 | InsertTool(), DeleteTool(), Realize(), SetDropdownMenu() | |
246 | */ | |
adaaa686 | 247 | virtual wxToolBarToolBase* AddTool(wxToolBarToolBase* tool); |
922da38b BP |
248 | |
249 | /** | |
408776d0 | 250 | Adds a tool to the toolbar. This most commonly used version has fewer |
922da38b BP |
251 | parameters than the full version below which specifies the more rarely |
252 | used button features. | |
3c4f71cc | 253 | |
7c913512 | 254 | @param toolId |
7977b62a BP |
255 | An integer by which the tool may be identified in subsequent |
256 | operations. | |
408776d0 | 257 | @param label |
922da38b BP |
258 | The string to be displayed with the tool. |
259 | @param bitmap | |
260 | The primary tool bitmap. | |
261 | @param shortHelp | |
262 | This string is used for the tools tooltip. | |
7c913512 | 263 | @param kind |
7977b62a BP |
264 | May be ::wxITEM_NORMAL for a normal button (default), ::wxITEM_CHECK |
265 | for a checkable tool (such tool stays pressed after it had been | |
266 | toggled) or ::wxITEM_RADIO for a checkable tool which makes part of | |
408776d0 | 267 | a radio group of tools each of which is automatically unchecked |
970e987e RR |
268 | whenever another button in the group is checked. ::wxITEM_DROPDOWN |
269 | specifies that a drop-down menu button will appear next to the | |
270 | tool button (only GTK+ and MSW). Call SetDropdownMenu() afterwards. | |
922da38b BP |
271 | |
272 | @remarks After you have added tools to a toolbar, you must call | |
273 | Realize() in order to have the tools appear. | |
274 | ||
275 | @see AddSeparator(), AddCheckTool(), AddRadioTool(), | |
276 | InsertTool(), DeleteTool(), Realize(), SetDropdownMenu() | |
277 | */ | |
278 | wxToolBarToolBase* AddTool(int toolId, const wxString& label, | |
279 | const wxBitmap& bitmap, | |
280 | const wxString& shortHelp = wxEmptyString, | |
281 | wxItemKind kind = wxITEM_NORMAL); | |
282 | ||
283 | /** | |
284 | Adds a tool to the toolbar. | |
285 | ||
286 | @param toolId | |
287 | An integer by which the tool may be identified in subsequent | |
288 | operations. | |
408776d0 | 289 | @param label |
922da38b BP |
290 | The string to be displayed with the tool. |
291 | @param bitmap | |
4cc4bfaf | 292 | The primary tool bitmap. |
922da38b | 293 | @param bmpDisabled |
4cc4bfaf | 294 | The bitmap used when the tool is disabled. If it is equal to |
408776d0 | 295 | ::wxNullBitmap (default), the disabled bitmap is automatically |
922da38b | 296 | generated by greying the normal one. |
7c913512 | 297 | @param shortHelpString |
7977b62a | 298 | This string is used for the tools tooltip. |
7c913512 | 299 | @param longHelpString |
7977b62a BP |
300 | This string is shown in the statusbar (if any) of the parent frame |
301 | when the mouse pointer is inside the tool. | |
922da38b BP |
302 | @param kind |
303 | May be ::wxITEM_NORMAL for a normal button (default), ::wxITEM_CHECK | |
304 | for a checkable tool (such tool stays pressed after it had been | |
305 | toggled) or ::wxITEM_RADIO for a checkable tool which makes part of | |
408776d0 | 306 | a radio group of tools each of which is automatically unchecked |
922da38b BP |
307 | whenever another button in the group is checked. ::wxITEM_DROPDOWN |
308 | specifies that a drop-down menu button will appear next to the | |
309 | tool button (only GTK+ and MSW). Call SetDropdownMenu() afterwards. | |
7c913512 | 310 | @param clientData |
7977b62a BP |
311 | An optional pointer to client data which can be retrieved later |
312 | using GetToolClientData(). | |
3c4f71cc | 313 | |
23324ae1 | 314 | @remarks After you have added tools to a toolbar, you must call |
7977b62a | 315 | Realize() in order to have the tools appear. |
3c4f71cc | 316 | |
4cc4bfaf | 317 | @see AddSeparator(), AddCheckTool(), AddRadioTool(), |
970e987e | 318 | InsertTool(), DeleteTool(), Realize(), SetDropdownMenu() |
23324ae1 FM |
319 | */ |
320 | wxToolBarToolBase* AddTool(int toolId, const wxString& label, | |
922da38b BP |
321 | const wxBitmap& bitmap, |
322 | const wxBitmap& bmpDisabled = wxNullBitmap, | |
7c913512 | 323 | wxItemKind kind = wxITEM_NORMAL, |
922da38b BP |
324 | const wxString& shortHelpString = wxEmptyString, |
325 | const wxString& longHelpString = wxEmptyString, | |
4cc4bfaf | 326 | wxObject* clientData = NULL); |
8d13e301 | 327 | //@} |
23324ae1 FM |
328 | |
329 | /** | |
330 | Deletes all the tools in the toolbar. | |
331 | */ | |
adaaa686 | 332 | virtual void ClearTools(); |
23324ae1 FM |
333 | |
334 | /** | |
7977b62a BP |
335 | Removes the specified tool from the toolbar and deletes it. If you don't |
336 | want to delete the tool, but just to remove it from the toolbar (to | |
337 | possibly add it back later), you may use RemoveTool() instead. | |
338 | ||
339 | @note It is unnecessary to call Realize() for the change to take | |
340 | place, it will happen immediately. | |
341 | ||
342 | @returns @true if the tool was deleted, @false otherwise. | |
3c4f71cc | 343 | |
4cc4bfaf | 344 | @see DeleteToolByPos() |
23324ae1 | 345 | */ |
adaaa686 | 346 | virtual bool DeleteTool(int toolId); |
23324ae1 FM |
347 | |
348 | /** | |
7977b62a BP |
349 | This function behaves like DeleteTool() but it deletes the tool at the |
350 | specified position and not the one with the given id. | |
23324ae1 | 351 | */ |
adaaa686 | 352 | virtual bool DeleteToolByPos(size_t pos); |
23324ae1 FM |
353 | |
354 | /** | |
355 | Enables or disables the tool. | |
3c4f71cc | 356 | |
7c913512 | 357 | @param toolId |
4cc4bfaf | 358 | Tool to enable or disable. |
7c913512 | 359 | @param enable |
4cc4bfaf | 360 | If @true, enables the tool, otherwise disables it. |
3c4f71cc | 361 | |
23324ae1 | 362 | @remarks Some implementations will change the visible state of the tool |
7977b62a BP |
363 | to indicate that it is disabled. |
364 | ||
3c4f71cc | 365 | |
4cc4bfaf | 366 | @see GetToolEnabled(), ToggleTool() |
23324ae1 | 367 | */ |
adaaa686 | 368 | virtual void EnableTool(int toolId, bool enable); |
23324ae1 FM |
369 | |
370 | /** | |
7977b62a BP |
371 | Returns a pointer to the tool identified by @a id or @NULL if no |
372 | corresponding tool is found. | |
23324ae1 | 373 | */ |
adaaa686 | 374 | wxToolBarToolBase* FindById(int id) const; |
23324ae1 FM |
375 | |
376 | /** | |
7977b62a BP |
377 | Returns a pointer to the control identified by @a id or @NULL if no |
378 | corresponding control is found. | |
23324ae1 | 379 | */ |
adaaa686 | 380 | virtual wxControl* FindControl(int id); |
23324ae1 FM |
381 | |
382 | /** | |
383 | Finds a tool for the given mouse position. | |
3c4f71cc | 384 | |
7c913512 | 385 | @param x |
4cc4bfaf | 386 | X position. |
7c913512 | 387 | @param y |
4cc4bfaf | 388 | Y position. |
3c4f71cc | 389 | |
d29a9a8a | 390 | @return A pointer to a tool if a tool is found, or @NULL otherwise. |
3c4f71cc | 391 | |
7977b62a BP |
392 | @remarks Currently not implemented in wxGTK (always returns @NULL |
393 | there). | |
23324ae1 | 394 | */ |
adaaa686 | 395 | virtual wxToolBarToolBase* FindToolForPosition(wxCoord x, wxCoord y) const; |
23324ae1 FM |
396 | |
397 | /** | |
398 | Returns the left/right and top/bottom margins, which are also used for | |
399 | inter-toolspacing. | |
3c4f71cc | 400 | |
4cc4bfaf | 401 | @see SetMargins() |
23324ae1 | 402 | */ |
328f5751 | 403 | wxSize GetMargins() const; |
23324ae1 FM |
404 | |
405 | /** | |
7977b62a BP |
406 | Returns the size of bitmap that the toolbar expects to have. The default |
407 | bitmap size is 16 by 15 pixels. | |
3c4f71cc | 408 | |
7977b62a BP |
409 | @remarks Note that this is the size of the bitmap you pass to AddTool(), |
410 | and not the eventual size of the tool button. | |
3c4f71cc | 411 | |
4cc4bfaf | 412 | @see SetToolBitmapSize(), GetToolSize() |
23324ae1 | 413 | */ |
adaaa686 | 414 | virtual wxSize GetToolBitmapSize() const; |
23324ae1 FM |
415 | |
416 | /** | |
417 | Get any client data associated with the tool. | |
3c4f71cc | 418 | |
7c913512 | 419 | @param toolId |
4cc4bfaf | 420 | Id of the tool, as passed to AddTool(). |
3c4f71cc | 421 | |
d29a9a8a | 422 | @return Client data, or @NULL if there is none. |
23324ae1 | 423 | */ |
adaaa686 | 424 | virtual wxObject* GetToolClientData(int toolId) const; |
23324ae1 FM |
425 | |
426 | /** | |
427 | Called to determine whether a tool is enabled (responds to user input). | |
3c4f71cc | 428 | |
7c913512 | 429 | @param toolId |
4cc4bfaf | 430 | Id of the tool in question. |
3c4f71cc | 431 | |
d29a9a8a | 432 | @return @true if the tool is enabled, @false otherwise. |
3c4f71cc | 433 | |
4cc4bfaf | 434 | @see EnableTool() |
23324ae1 | 435 | */ |
adaaa686 | 436 | virtual bool GetToolEnabled(int toolId) const; |
23324ae1 FM |
437 | |
438 | /** | |
439 | Returns the long help for the given tool. | |
3c4f71cc | 440 | |
7c913512 | 441 | @param toolId |
4cc4bfaf | 442 | The tool in question. |
3c4f71cc | 443 | |
4cc4bfaf | 444 | @see SetToolLongHelp(), SetToolShortHelp() |
23324ae1 | 445 | */ |
adaaa686 | 446 | virtual wxString GetToolLongHelp(int toolId) const; |
23324ae1 FM |
447 | |
448 | /** | |
449 | Returns the value used for packing tools. | |
3c4f71cc | 450 | |
4cc4bfaf | 451 | @see SetToolPacking() |
23324ae1 | 452 | */ |
adaaa686 | 453 | virtual int GetToolPacking() const; |
23324ae1 FM |
454 | |
455 | /** | |
7977b62a BP |
456 | Returns the tool position in the toolbar, or @c wxNOT_FOUND if the tool |
457 | is not found. | |
23324ae1 | 458 | */ |
adaaa686 | 459 | virtual int GetToolPos(int toolId) const; |
23324ae1 FM |
460 | |
461 | /** | |
462 | Returns the default separator size. | |
3c4f71cc | 463 | |
4cc4bfaf | 464 | @see SetToolSeparation() |
23324ae1 | 465 | */ |
adaaa686 | 466 | virtual int GetToolSeparation() const; |
23324ae1 FM |
467 | |
468 | /** | |
469 | Returns the short help for the given tool. | |
3c4f71cc | 470 | |
7c913512 | 471 | @param toolId |
4cc4bfaf | 472 | The tool in question. |
3c4f71cc | 473 | |
4cc4bfaf | 474 | @see GetToolLongHelp(), SetToolShortHelp() |
23324ae1 | 475 | */ |
adaaa686 | 476 | virtual wxString GetToolShortHelp(int toolId) const; |
23324ae1 FM |
477 | |
478 | /** | |
7977b62a BP |
479 | Returns the size of a whole button, which is usually larger than a tool |
480 | bitmap because of added 3D effects. | |
3c4f71cc | 481 | |
4cc4bfaf | 482 | @see SetToolBitmapSize(), GetToolBitmapSize() |
23324ae1 | 483 | */ |
adaaa686 | 484 | virtual wxSize GetToolSize() const; |
23324ae1 FM |
485 | |
486 | /** | |
487 | Gets the on/off state of a toggle tool. | |
3c4f71cc | 488 | |
7c913512 | 489 | @param toolId |
4cc4bfaf | 490 | The tool in question. |
3c4f71cc | 491 | |
d29a9a8a | 492 | @return @true if the tool is toggled on, @false otherwise. |
3c4f71cc | 493 | |
4cc4bfaf | 494 | @see ToggleTool() |
23324ae1 | 495 | */ |
adaaa686 | 496 | virtual bool GetToolState(int toolId) const; |
23324ae1 FM |
497 | |
498 | /** | |
499 | Returns the number of tools in the toolbar. | |
500 | */ | |
43c48e1e | 501 | size_t GetToolsCount() const; |
23324ae1 FM |
502 | |
503 | /** | |
7977b62a BP |
504 | Inserts the control into the toolbar at the given position. You must |
505 | call Realize() for the change to take place. | |
3c4f71cc | 506 | |
4cc4bfaf | 507 | @see AddControl(), InsertTool() |
23324ae1 | 508 | */ |
43c48e1e FM |
509 | virtual wxToolBarToolBase* InsertControl(size_t pos, wxControl* control, |
510 | const wxString& label = wxEmptyString); | |
23324ae1 FM |
511 | |
512 | /** | |
7977b62a BP |
513 | Inserts the separator into the toolbar at the given position. You must |
514 | call Realize() for the change to take place. | |
3c4f71cc | 515 | |
4cc4bfaf | 516 | @see AddSeparator(), InsertTool() |
23324ae1 | 517 | */ |
adaaa686 | 518 | virtual wxToolBarToolBase* InsertSeparator(size_t pos); |
23324ae1 FM |
519 | |
520 | //@{ | |
521 | /** | |
7977b62a BP |
522 | Inserts the tool with the specified attributes into the toolbar at the |
523 | given position. | |
524 | ||
23324ae1 | 525 | You must call Realize() for the change to take place. |
3c4f71cc | 526 | |
4cc4bfaf FM |
527 | @see AddTool(), InsertControl(), InsertSeparator() |
528 | */ | |
529 | wxToolBarToolBase* InsertTool(size_t pos, int toolId, | |
530 | const wxBitmap& bitmap1, | |
531 | const wxBitmap& bitmap2 = wxNullBitmap, | |
532 | bool isToggle = false, | |
533 | wxObject* clientData = NULL, | |
8d13e301 FM |
534 | const wxString& shortHelpString = wxEmptyString, |
535 | const wxString& longHelpString = wxEmptyString); | |
4cc4bfaf FM |
536 | wxToolBarToolBase* InsertTool(size_t pos, |
537 | wxToolBarToolBase* tool); | |
23324ae1 FM |
538 | //@} |
539 | ||
540 | /** | |
7977b62a BP |
541 | Called when the user clicks on a tool with the left mouse button. This |
542 | is the old way of detecting tool clicks; although it will still work, | |
543 | you should use the EVT_MENU() or EVT_TOOL() macro instead. | |
3c4f71cc | 544 | |
7c913512 | 545 | @param toolId |
4cc4bfaf | 546 | The identifier passed to AddTool(). |
7c913512 | 547 | @param toggleDown |
7977b62a BP |
548 | @true if the tool is a toggle and the toggle is down, otherwise is |
549 | @false. | |
3c4f71cc | 550 | |
d29a9a8a | 551 | @return If the tool is a toggle and this function returns @false, the |
7977b62a BP |
552 | toggle state (internal and visual) will not be changed. This |
553 | provides a way of specifying that toggle operations are not | |
554 | permitted in some circumstances. | |
3c4f71cc | 555 | |
4cc4bfaf | 556 | @see OnMouseEnter(), OnRightClick() |
23324ae1 | 557 | */ |
adaaa686 | 558 | virtual bool OnLeftClick(int toolId, bool toggleDown); |
23324ae1 FM |
559 | |
560 | /** | |
7977b62a BP |
561 | This is called when the mouse cursor moves into a tool or out of the |
562 | toolbar. This is the old way of detecting mouse enter events; | |
563 | although it will still work, you should use the EVT_TOOL_ENTER() | |
564 | macro instead. | |
3c4f71cc | 565 | |
7c913512 | 566 | @param toolId |
7977b62a BP |
567 | Greater than -1 if the mouse cursor has moved into the tool, or -1 |
568 | if the mouse cursor has moved. The programmer can override this to | |
569 | provide extra information about the tool, such as a short | |
570 | description on the status line. | |
3c4f71cc | 571 | |
23324ae1 | 572 | @remarks With some derived toolbar classes, if the mouse moves quickly |
7977b62a BP |
573 | out of the toolbar, wxWidgets may not be able to detect it. |
574 | Therefore this function may not always be called when expected. | |
23324ae1 | 575 | */ |
adaaa686 | 576 | virtual void OnMouseEnter(int toolId); |
23324ae1 FM |
577 | |
578 | /** | |
7977b62a BP |
579 | @deprecated This is the old way of detecting tool right clicks; |
580 | although it will still work, you should use the | |
581 | EVT_TOOL_RCLICKED() macro instead. | |
582 | ||
23324ae1 FM |
583 | Called when the user clicks on a tool with the right mouse button. The |
584 | programmer should override this function to detect right tool clicks. | |
3c4f71cc | 585 | |
7c913512 | 586 | @param toolId |
4cc4bfaf | 587 | The identifier passed to AddTool(). |
7c913512 | 588 | @param x |
4cc4bfaf | 589 | The x position of the mouse cursor. |
7c913512 | 590 | @param y |
4cc4bfaf | 591 | The y position of the mouse cursor. |
3c4f71cc | 592 | |
23324ae1 | 593 | @remarks A typical use of this member might be to pop up a menu. |
3c4f71cc | 594 | |
4cc4bfaf | 595 | @see OnMouseEnter(), OnLeftClick() |
23324ae1 | 596 | */ |
43c48e1e | 597 | virtual void OnRightClick(int toolId, long x, long y); |
23324ae1 FM |
598 | |
599 | /** | |
600 | This function should be called after you have added tools. | |
601 | */ | |
adaaa686 | 602 | virtual bool Realize(); |
23324ae1 FM |
603 | |
604 | /** | |
7977b62a BP |
605 | Removes the given tool from the toolbar but doesn't delete it. This |
606 | allows to insert/add this tool back to this (or another) toolbar later. | |
607 | ||
608 | @note It is unnecessary to call Realize() for the change to take place, | |
609 | it will happen immediately. | |
610 | ||
3c4f71cc | 611 | |
4cc4bfaf | 612 | @see DeleteTool() |
23324ae1 | 613 | */ |
adaaa686 | 614 | virtual wxToolBarToolBase* RemoveTool(int id); |
23324ae1 FM |
615 | |
616 | /** | |
7977b62a BP |
617 | Sets the bitmap resource identifier for specifying tool bitmaps as |
618 | indices into a custom bitmap. Windows CE only. | |
23324ae1 FM |
619 | */ |
620 | void SetBitmapResource(int resourceId); | |
621 | ||
622 | /** | |
7977b62a | 623 | Sets the dropdown menu for the tool given by its @e id. The tool itself |
970e987e RR |
624 | will delete the menu when it's no longer needed. Only supported under |
625 | GTK+ und MSW. | |
7977b62a BP |
626 | |
627 | If you define a EVT_TOOL_DROPDOWN() handler in your program, you must | |
628 | call wxEvent::Skip() from it or the menu won't be displayed. | |
23324ae1 FM |
629 | */ |
630 | bool SetDropdownMenu(int id, wxMenu* menu); | |
631 | ||
8d13e301 | 632 | //@{ |
23324ae1 FM |
633 | /** |
634 | Set the values to be used as margins for the toolbar. | |
3c4f71cc | 635 | |
7c913512 | 636 | @param x |
4cc4bfaf | 637 | Left margin, right margin and inter-tool separation value. |
7c913512 | 638 | @param y |
4cc4bfaf | 639 | Top margin, bottom margin and inter-tool separation value. |
3c4f71cc | 640 | |
23324ae1 | 641 | @remarks This must be called before the tools are added if absolute |
7977b62a BP |
642 | positioning is to be used, and the default (zero-size) margins are |
643 | to be overridden. | |
3c4f71cc | 644 | |
922da38b BP |
645 | @see GetMargins() |
646 | */ | |
adaaa686 | 647 | virtual void SetMargins(int x, int y); |
922da38b BP |
648 | |
649 | /** | |
650 | Set the margins for the toolbar. | |
651 | ||
652 | @param size | |
653 | Margin size. | |
654 | ||
655 | @remarks This must be called before the tools are added if absolute | |
656 | positioning is to be used, and the default (zero-size) margins are | |
657 | to be overridden. | |
658 | ||
4cc4bfaf | 659 | @see GetMargins(), wxSize |
23324ae1 FM |
660 | */ |
661 | void SetMargins(const wxSize& size); | |
8d13e301 | 662 | //@} |
23324ae1 FM |
663 | |
664 | /** | |
7977b62a BP |
665 | Sets the default size of each tool bitmap. The default bitmap size is 16 |
666 | by 15 pixels. | |
3c4f71cc | 667 | |
7c913512 | 668 | @param size |
4cc4bfaf | 669 | The size of the bitmaps in the toolbar. |
3c4f71cc | 670 | |
23324ae1 | 671 | @remarks This should be called to tell the toolbar what the tool bitmap |
7977b62a | 672 | size is. Call it before you add tools. |
3c4f71cc | 673 | |
4cc4bfaf | 674 | @see GetToolBitmapSize(), GetToolSize() |
23324ae1 | 675 | */ |
adaaa686 | 676 | virtual void SetToolBitmapSize(const wxSize& size); |
23324ae1 FM |
677 | |
678 | /** | |
679 | Sets the client data associated with the tool. | |
680 | */ | |
adaaa686 | 681 | virtual void SetToolClientData(int id, wxObject* clientData); |
23324ae1 FM |
682 | |
683 | /** | |
684 | Sets the bitmap to be used by the tool with the given ID when the tool | |
7977b62a BP |
685 | is in a disabled state. This can only be used on Button tools, not |
686 | controls. | |
687 | ||
688 | @note The native toolbar classes on the main platforms all synthesize | |
689 | the disabled bitmap from the normal bitmap, so this function will | |
690 | have no effect on those platforms. | |
691 | ||
23324ae1 | 692 | */ |
adaaa686 | 693 | virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap); |
23324ae1 FM |
694 | |
695 | /** | |
696 | Sets the long help for the given tool. | |
3c4f71cc | 697 | |
7c913512 | 698 | @param toolId |
4cc4bfaf | 699 | The tool in question. |
7c913512 | 700 | @param helpString |
4cc4bfaf | 701 | A string for the long help. |
3c4f71cc | 702 | |
23324ae1 | 703 | @remarks You might use the long help for displaying the tool purpose on |
7977b62a | 704 | the status line. |
3c4f71cc | 705 | |
4cc4bfaf | 706 | @see GetToolLongHelp(), SetToolShortHelp(), |
23324ae1 | 707 | */ |
adaaa686 | 708 | virtual void SetToolLongHelp(int toolId, const wxString& helpString); |
23324ae1 FM |
709 | |
710 | /** | |
7977b62a BP |
711 | Sets the bitmap to be used by the tool with the given ID. This can only |
712 | be used on Button tools, not controls. | |
23324ae1 | 713 | */ |
adaaa686 | 714 | virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap); |
23324ae1 FM |
715 | |
716 | /** | |
717 | Sets the value used for spacing tools. The default value is 1. | |
3c4f71cc | 718 | |
7c913512 | 719 | @param packing |
4cc4bfaf | 720 | The value for packing. |
3c4f71cc | 721 | |
408776d0 | 722 | @remarks The packing is used for spacing in the vertical direction if |
7977b62a BP |
723 | the toolbar is horizontal, and for spacing in the horizontal |
724 | direction if the toolbar is vertical. | |
3c4f71cc | 725 | |
4cc4bfaf | 726 | @see GetToolPacking() |
23324ae1 | 727 | */ |
adaaa686 | 728 | virtual void SetToolPacking(int packing); |
23324ae1 FM |
729 | |
730 | /** | |
731 | Sets the default separator size. The default value is 5. | |
3c4f71cc | 732 | |
7c913512 | 733 | @param separation |
4cc4bfaf | 734 | The separator size. |
3c4f71cc | 735 | |
4cc4bfaf | 736 | @see AddSeparator() |
23324ae1 | 737 | */ |
adaaa686 | 738 | virtual void SetToolSeparation(int separation); |
23324ae1 FM |
739 | |
740 | /** | |
741 | Sets the short help for the given tool. | |
3c4f71cc | 742 | |
7c913512 | 743 | @param toolId |
4cc4bfaf | 744 | The tool in question. |
7c913512 | 745 | @param helpString |
4cc4bfaf | 746 | The string for the short help. |
3c4f71cc | 747 | |
23324ae1 | 748 | @remarks An application might use short help for identifying the tool |
7977b62a BP |
749 | purpose in a tooltip. |
750 | ||
3c4f71cc | 751 | |
4cc4bfaf | 752 | @see GetToolShortHelp(), SetToolLongHelp() |
23324ae1 | 753 | */ |
adaaa686 | 754 | virtual void SetToolShortHelp(int toolId, const wxString& helpString); |
23324ae1 FM |
755 | |
756 | /** | |
757 | Toggles a tool on or off. This does not cause any event to get emitted. | |
3c4f71cc | 758 | |
7c913512 | 759 | @param toolId |
4cc4bfaf | 760 | Tool in question. |
7c913512 | 761 | @param toggle |
4cc4bfaf | 762 | If @true, toggles the tool on, otherwise toggles it off. |
3c4f71cc | 763 | |
7977b62a BP |
764 | @remarks Only applies to a tool that has been specified as a toggle |
765 | tool. | |
23324ae1 | 766 | */ |
adaaa686 | 767 | virtual void ToggleTool(int toolId, bool toggle); |
23324ae1 | 768 | }; |
e54c96f1 | 769 |