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