]> git.saurik.com Git - wxWidgets.git/blame - include/wx/tbarbase.h
fixed typo in wxString::swap() which was completely broken
[wxWidgets.git] / include / wx / tbarbase.h
CommitLineData
10b959e3 1/////////////////////////////////////////////////////////////////////////////
6d167489 2// Name: wx/tbarbase.h
10b959e3
JS
3// Purpose: Base class for toolbar classes
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
1c383dba 9// Licence: wxWindows licence
10b959e3
JS
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_TBARBASE_H_
13#define _WX_TBARBASE_H_
10b959e3 14
1c383dba
VZ
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
10b959e3 19#ifdef __GNUG__
1c383dba 20 #pragma interface "tbarbase.h"
10b959e3
JS
21#endif
22
23#include "wx/defs.h"
24
1e6feb95
VZ
25#if wxUSE_TOOLBAR
26
10b959e3
JS
27#include "wx/bitmap.h"
28#include "wx/list.h"
29#include "wx/control.h"
30
8a0681f9
VZ
31class WXDLLEXPORT wxToolBarBase;
32class WXDLLEXPORT wxToolBarToolBase;
c229e50d 33class WXDLLEXPORT wxImage;
1c383dba
VZ
34
35// ----------------------------------------------------------------------------
36// constants
37// ----------------------------------------------------------------------------
38
f39f9220 39WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr;
10b959e3
JS
40WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize;
41WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition;
42
8a0681f9 43enum wxToolBarToolStyle
1c383dba
VZ
44{
45 wxTOOL_STYLE_BUTTON = 1,
46 wxTOOL_STYLE_SEPARATOR = 2,
47 wxTOOL_STYLE_CONTROL
48};
10b959e3 49
1c383dba 50// ----------------------------------------------------------------------------
8a0681f9
VZ
51// wxToolBarTool is a toolbar element.
52//
53// It has a unique id (except for the separators which always have id -1), the
54// style (telling whether it is a normal button, separator or a control), the
55// state (toggled or not, enabled or not) and short and long help strings. The
56// default implementations use the short help string for the tooltip text which
57// is popped up when the mouse pointer enters the tool and the long help string
58// for the applications status bar.
1c383dba 59// ----------------------------------------------------------------------------
4fcd73bd 60
8a0681f9 61class WXDLLEXPORT wxToolBarToolBase : public wxObject
10b959e3 62{
1c383dba
VZ
63public:
64 // ctors & dtor
65 // ------------
66
8a0681f9
VZ
67 wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL,
68 int id = wxID_SEPARATOR,
e76c0b5f
VZ
69 const wxString& label = wxEmptyString,
70 const wxBitmap& bmpNormal = wxNullBitmap,
71 const wxBitmap& bmpDisabled = wxNullBitmap,
72 wxItemKind kind = wxITEM_NORMAL,
8a0681f9
VZ
73 wxObject *clientData = (wxObject *) NULL,
74 const wxString& shortHelpString = wxEmptyString,
75 const wxString& longHelpString = wxEmptyString)
e76c0b5f
VZ
76 : m_label(label),
77 m_shortHelpString(shortHelpString),
8a0681f9
VZ
78 m_longHelpString(longHelpString)
79 {
80 m_tbar = tbar;
81 m_id = id;
82 m_clientData = clientData;
83
e76c0b5f
VZ
84 m_bmpNormal = bmpNormal;
85 m_bmpDisabled = bmpDisabled;
86
87 m_kind = kind;
8a0681f9 88
8a0681f9
VZ
89 m_enabled = TRUE;
90 m_toggled = FALSE;
91
92 m_toolStyle = id == wxID_SEPARATOR ? wxTOOL_STYLE_SEPARATOR
93 : wxTOOL_STYLE_BUTTON;
94 }
95
96 wxToolBarToolBase(wxToolBarBase *tbar, wxControl *control)
97 {
98 m_tbar = tbar;
99 m_control = control;
100 m_id = control->GetId();
101
e76c0b5f
VZ
102 m_kind = wxITEM_MAX; // invalid value
103
8a0681f9
VZ
104 m_enabled = TRUE;
105 m_toggled = FALSE;
106
107 m_toolStyle = wxTOOL_STYLE_CONTROL;
108 }
109
110 ~wxToolBarToolBase();
1c383dba
VZ
111
112 // accessors
113 // ---------
114
8a0681f9
VZ
115 // general
116 int GetId() const { return m_id; }
1c383dba
VZ
117
118 wxControl *GetControl() const
119 {
8a0681f9 120 wxASSERT_MSG( IsControl(), _T("this toolbar tool is not a control") );
1c383dba
VZ
121
122 return m_control;
123 }
10b959e3 124
8a0681f9
VZ
125 wxToolBarBase *GetToolBar() const { return m_tbar; }
126
127 // style
42d6e136
VZ
128 bool IsButton() const { return m_toolStyle == wxTOOL_STYLE_BUTTON; }
129 bool IsControl() const { return m_toolStyle == wxTOOL_STYLE_CONTROL; }
130 bool IsSeparator() const { return m_toolStyle == wxTOOL_STYLE_SEPARATOR; }
8a0681f9 131 int GetStyle() const { return m_toolStyle; }
e76c0b5f
VZ
132 wxItemKind GetKind() const
133 {
134 wxASSERT_MSG( IsButton(), _T("only makes sense for buttons") );
135
136 return m_kind;
137 }
8a0681f9
VZ
138
139 // state
140 bool IsEnabled() const { return m_enabled; }
141 bool IsToggled() const { return m_toggled; }
e76c0b5f
VZ
142 bool CanBeToggled() const
143 { return m_kind == wxITEM_CHECK || m_kind == wxITEM_RADIO; }
8a0681f9
VZ
144
145 // attributes
e76c0b5f
VZ
146 const wxBitmap& GetNormalBitmap() const { return m_bmpNormal; }
147 const wxBitmap& GetDisabledBitmap() const { return m_bmpDisabled; }
8a0681f9
VZ
148
149 const wxBitmap& GetBitmap() const
3216dbf5
VZ
150 { return IsEnabled() ? GetNormalBitmap() : GetDisabledBitmap(); }
151
152 wxString GetLabel() const { return m_label; }
8a0681f9
VZ
153
154 wxString GetShortHelp() const { return m_shortHelpString; }
155 wxString GetLongHelp() const { return m_longHelpString; }
156
157 wxObject *GetClientData() const
158 {
6fd5fa4f
VZ
159 if ( m_toolStyle == wxTOOL_STYLE_CONTROL )
160 {
2063a4a0 161 return (wxObject*)m_control->GetClientData();
6fd5fa4f
VZ
162 }
163 else
164 {
165 return m_clientData;
166 }
8a0681f9
VZ
167 }
168
169 // modifiers: return TRUE if the state really changed
170 bool Enable(bool enable);
171 bool Toggle(bool toggle);
172 bool SetToggle(bool toggle);
173 bool SetShortHelp(const wxString& help);
174 bool SetLongHelp(const wxString& help);
175
176 void Toggle() { Toggle(!IsToggled()); }
177
e76c0b5f
VZ
178 void SetNormalBitmap(const wxBitmap& bmp) { m_bmpNormal = bmp; }
179 void SetDisabledBitmap(const wxBitmap& bmp) { m_bmpDisabled = bmp; }
3216dbf5 180
c631abda 181 virtual void SetLabel(const wxString& label) { m_label = label; }
8a0681f9 182
6fd5fa4f
VZ
183 void SetClientData(wxObject *clientData)
184 {
185 if ( m_toolStyle == wxTOOL_STYLE_CONTROL )
186 {
187 m_control->SetClientData(clientData);
188 }
189 else
190 {
191 m_clientData = clientData;
192 }
193 }
194
8a0681f9
VZ
195 // add tool to/remove it from a toolbar
196 virtual void Detach() { m_tbar = (wxToolBarBase *)NULL; }
197 virtual void Attach(wxToolBarBase *tbar) { m_tbar = tbar; }
198
3216dbf5
VZ
199 // compatibility only, don't use
200#if WXWIN_COMPATIBILITY_2_2
201 const wxBitmap& GetBitmap1() const { return GetNormalBitmap(); }
202 const wxBitmap& GetBitmap2() const { return GetDisabledBitmap(); }
203
204 void SetBitmap1(const wxBitmap& bmp) { SetNormalBitmap(bmp); }
205 void SetBitmap2(const wxBitmap& bmp) { SetDisabledBitmap(bmp); }
206#endif // WXWIN_COMPATIBILITY_2_2
207
8a0681f9
VZ
208protected:
209 wxToolBarBase *m_tbar; // the toolbar to which we belong (may be NULL)
210
e76c0b5f
VZ
211 // tool parameters
212 int m_toolStyle; // see enum wxToolBarToolStyle
213 int m_id; // the tool id, wxID_SEPARATOR for separator
214 wxItemKind m_kind; // for normal buttons may be wxITEM_NORMAL/CHECK/RADIO
1c383dba
VZ
215
216 // as controls have their own client data, no need to waste memory
217 union
218 {
219 wxObject *m_clientData;
220 wxControl *m_control;
221 };
222
8a0681f9
VZ
223 // tool state
224 bool m_toggled;
8a0681f9 225 bool m_enabled;
1c383dba 226
e76c0b5f
VZ
227 // normal and disabled bitmaps for the tool, both can be invalid
228 wxBitmap m_bmpNormal;
229 wxBitmap m_bmpDisabled;
1c383dba 230
3216dbf5
VZ
231 // the button label
232 wxString m_label;
233
8a0681f9
VZ
234 // short and long help strings
235 wxString m_shortHelpString;
236 wxString m_longHelpString;
10b959e3
JS
237};
238
8a0681f9 239// a list of toolbar tools
f6bcfd97 240WX_DECLARE_EXPORTED_LIST(wxToolBarToolBase, wxToolBarToolsList);
8a0681f9 241
1c383dba
VZ
242// ----------------------------------------------------------------------------
243// the base class for all toolbars
244// ----------------------------------------------------------------------------
245
10b959e3
JS
246class WXDLLEXPORT wxToolBarBase : public wxControl
247{
1c383dba
VZ
248public:
249 wxToolBarBase();
8a0681f9 250 virtual ~wxToolBarBase();
10b959e3 251
1c383dba
VZ
252 // toolbar construction
253 // --------------------
10b959e3 254
e76c0b5f
VZ
255 // the full AddTool() function
256 //
257 // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
258 // is created and used as the disabled image.
3ca6a5f0 259 wxToolBarToolBase *AddTool(int id,
e76c0b5f 260 const wxString& label,
3ca6a5f0 261 const wxBitmap& bitmap,
e76c0b5f
VZ
262 const wxBitmap& bmpDisabled,
263 wxItemKind kind = wxITEM_NORMAL,
264 const wxString& shortHelp = wxEmptyString,
265 const wxString& longHelp = wxEmptyString,
266 wxObject *data = NULL)
3ca6a5f0 267 {
e76c0b5f
VZ
268 return DoAddTool(id, label, bitmap, bmpDisabled, kind,
269 shortHelp, longHelp, data);
3ca6a5f0
BP
270 }
271
e76c0b5f 272 // the most common AddTool() version
8a0681f9 273 wxToolBarToolBase *AddTool(int id,
e76c0b5f 274 const wxString& label,
8a0681f9 275 const wxBitmap& bitmap,
e76c0b5f
VZ
276 const wxString& shortHelp = wxEmptyString,
277 wxItemKind kind = wxITEM_NORMAL)
8a0681f9 278 {
e76c0b5f
VZ
279 return AddTool(id, label, bitmap, wxNullBitmap, kind, shortHelp);
280 }
281
282 // add a check tool, i.e. a tool which can be toggled
283 wxToolBarToolBase *AddCheckTool(int id,
284 const wxString& label,
285 const wxBitmap& bitmap,
286 const wxBitmap& bmpDisabled = wxNullBitmap,
287 const wxString& shortHelp = wxEmptyString,
288 const wxString& longHelp = wxEmptyString,
289 wxObject *data = NULL)
290 {
291 return AddTool(id, label, bitmap, bmpDisabled, wxITEM_CHECK,
292 shortHelp, longHelp, data);
293 }
294
295 // add a radio tool, i.e. a tool which can be toggled and releases any
296 // other toggled radio tools in the same group when it happens
297 wxToolBarToolBase *AddRadioTool(int id,
298 const wxString& label,
299 const wxBitmap& bitmap,
300 const wxBitmap& bmpDisabled = wxNullBitmap,
301 const wxString& shortHelp = wxEmptyString,
302 const wxString& longHelp = wxEmptyString,
303 wxObject *data = NULL)
304 {
305 return AddTool(id, label, bitmap, bmpDisabled, wxITEM_RADIO,
306 shortHelp, longHelp, data);
8a0681f9
VZ
307 }
308
8a0681f9
VZ
309
310 // insert the new tool at the given position, if pos == GetToolsCount(), it
311 // is equivalent to AddTool()
312 virtual wxToolBarToolBase *InsertTool
313 (
314 size_t pos,
315 int id,
e76c0b5f 316 const wxString& label,
8a0681f9 317 const wxBitmap& bitmap,
e76c0b5f
VZ
318 const wxBitmap& bmpDisabled = wxNullBitmap,
319 wxItemKind kind = wxITEM_NORMAL,
320 const wxString& shortHelp = wxEmptyString,
321 const wxString& longHelp = wxEmptyString,
322 wxObject *clientData = NULL
8a0681f9
VZ
323 );
324
325 // add an arbitrary control to the toolbar, return TRUE if ok (notice that
326 // the control will be deleted by the toolbar and that it will also adjust
327 // its position/size)
1c383dba
VZ
328 //
329 // NB: the control should have toolbar as its parent
8a0681f9
VZ
330 virtual wxToolBarToolBase *AddControl(wxControl *control);
331 virtual wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
10b959e3 332
8a0681f9
VZ
333 // add a separator to the toolbar
334 virtual wxToolBarToolBase *AddSeparator();
335 virtual wxToolBarToolBase *InsertSeparator(size_t pos);
336
337 // remove the tool from the toolbar: the caller is responsible for actually
338 // deleting the pointer
339 virtual wxToolBarToolBase *RemoveTool(int id);
340
341 // delete tool either by index or by position
342 virtual bool DeleteToolByPos(size_t pos);
343 virtual bool DeleteTool(int id);
344
345 // delete all tools
1c383dba 346 virtual void ClearTools();
10b959e3 347
1c383dba
VZ
348 // must be called after all buttons have been created to finish toolbar
349 // initialisation
8a0681f9 350 virtual bool Realize();
10b959e3 351
1c383dba
VZ
352 // tools state
353 // -----------
10b959e3 354
8a0681f9
VZ
355 virtual void EnableTool(int id, bool enable);
356 virtual void ToggleTool(int id, bool toggle);
b02da6b1 357
1c383dba 358 // Set this to be togglable (or not)
8a0681f9
VZ
359 virtual void SetToggle(int id, bool toggle);
360
6fd5fa4f
VZ
361 // set/get tools client data (not for controls)
362 virtual wxObject *GetToolClientData(int id) const;
363 virtual void SetToolClientData(int id, wxObject *clientData);
10b959e3 364
8a0681f9
VZ
365 // return TRUE if the tool is toggled
366 virtual bool GetToolState(int id) const;
367
368 virtual bool GetToolEnabled(int id) const;
81d66cf3 369
8a0681f9
VZ
370 virtual void SetToolShortHelp(int id, const wxString& helpString);
371 virtual wxString GetToolShortHelp(int id) const;
372 virtual void SetToolLongHelp(int id, const wxString& helpString);
373 virtual wxString GetToolLongHelp(int id) const;
10b959e3 374
1c383dba
VZ
375 // margins/packing/separation
376 // --------------------------
10b959e3 377
1c383dba
VZ
378 virtual void SetMargins(int x, int y);
379 void SetMargins(const wxSize& size)
380 { SetMargins((int) size.x, (int) size.y); }
8a0681f9
VZ
381 virtual void SetToolPacking(int packing)
382 { m_toolPacking = packing; }
383 virtual void SetToolSeparation(int separation)
384 { m_toolSeparation = separation; }
10b959e3 385
e76c0b5f
VZ
386 virtual wxSize GetToolMargins() const { return wxSize(m_xMargin, m_yMargin); }
387 virtual int GetToolPacking() const { return m_toolPacking; }
388 virtual int GetToolSeparation() const { return m_toolSeparation; }
ef7eaedd 389
8a0681f9
VZ
390 // toolbar geometry
391 // ----------------
392
393 // set the number of toolbar rows
394 virtual void SetRows(int nRows);
395
396 // the toolbar can wrap - limit the number of columns or rows it may take
1c383dba
VZ
397 void SetMaxRowsCols(int rows, int cols)
398 { m_maxRows = rows; m_maxCols = cols; }
399 int GetMaxRows() const { return m_maxRows; }
400 int GetMaxCols() const { return m_maxCols; }
10b959e3 401
8a0681f9
VZ
402 // get/set the size of the bitmaps used by the toolbar: should be called
403 // before adding any tools to the toolbar
1c383dba
VZ
404 virtual void SetToolBitmapSize(const wxSize& size)
405 { m_defaultWidth = size.x; m_defaultHeight = size.y; };
406 virtual wxSize GetToolBitmapSize() const
407 { return wxSize(m_defaultWidth, m_defaultHeight); }
10b959e3 408
8a0681f9
VZ
409 // the button size in some implementations is bigger than the bitmap size:
410 // get the total button size (by default the same as bitmap size)
1c383dba 411 virtual wxSize GetToolSize() const
8a0681f9 412 { return GetToolBitmapSize(); } ;
10b959e3 413
8a0681f9
VZ
414 // returns a (non separator) tool containing the point (x, y) or NULL if
415 // there is no tool at this point (corrdinates are client)
416 virtual wxToolBarToolBase *FindToolForPosition(wxCoord x,
417 wxCoord y) const = 0;
418
3216dbf5
VZ
419 // return TRUE if this is a vertical toolbar, otherwise FALSE
420 bool IsVertical() const { return HasFlag(wxTB_VERTICAL); }
421
e76c0b5f
VZ
422
423 // the old versions of the various methods kept for compatibility
424 // don't use in the new code!
425 // --------------------------------------------------------------
426
427 wxToolBarToolBase *AddTool(int id,
428 const wxBitmap& bitmap,
429 const wxBitmap& bmpDisabled,
430 bool toggle = FALSE,
431 wxObject *clientData = NULL,
432 const wxString& shortHelpString = wxEmptyString,
433 const wxString& longHelpString = wxEmptyString)
434 {
435 return AddTool(id, wxEmptyString,
436 bitmap, bmpDisabled,
437 toggle ? wxITEM_CHECK : wxITEM_NORMAL,
438 shortHelpString, longHelpString, clientData);
439 }
440
441 wxToolBarToolBase *AddTool(int id,
442 const wxBitmap& bitmap,
443 const wxString& shortHelpString = wxEmptyString,
444 const wxString& longHelpString = wxEmptyString)
445 {
446 return AddTool(id, wxEmptyString,
447 bitmap, wxNullBitmap, wxITEM_NORMAL,
448 shortHelpString, longHelpString, NULL);
449 }
450
451 wxToolBarToolBase *AddTool(int id,
452 const wxBitmap& bitmap,
453 const wxBitmap& bmpDisabled,
454 bool toggle,
455 wxCoord xPos,
456 wxCoord yPos = -1,
457 wxObject *clientData = NULL,
458 const wxString& shortHelp = wxEmptyString,
459 const wxString& longHelp = wxEmptyString)
460 {
461 return DoAddTool(id, wxEmptyString, bitmap, bmpDisabled,
462 toggle ? wxITEM_CHECK : wxITEM_NORMAL,
463 shortHelp, longHelp, clientData, xPos, yPos);
464 }
465
466 wxToolBarToolBase *InsertTool(size_t pos,
467 int id,
468 const wxBitmap& bitmap,
469 const wxBitmap& bmpDisabled = wxNullBitmap,
470 bool toggle = FALSE,
471 wxObject *clientData = NULL,
472 const wxString& shortHelp = wxEmptyString,
473 const wxString& longHelp = wxEmptyString)
474 {
475 return InsertTool(pos, id, wxEmptyString, bitmap, bmpDisabled,
476 toggle ? wxITEM_CHECK : wxITEM_NORMAL,
477 shortHelp, longHelp, clientData);
478 }
479
8a0681f9
VZ
480 // event handlers
481 // --------------
10b959e3 482
1c383dba 483 // NB: these functions are deprecated, use EVT_TOOL_XXX() instead!
10b959e3 484
1c383dba 485 // Only allow toggle if returns TRUE. Call when left button up.
8a0681f9 486 virtual bool OnLeftClick(int id, bool toggleDown);
b02da6b1 487
1c383dba 488 // Call when right button down.
8a0681f9 489 virtual void OnRightClick(int id, long x, long y);
10b959e3 490
1c383dba
VZ
491 // Called when the mouse cursor enters a tool bitmap.
492 // Argument is -1 if mouse is exiting the toolbar.
8a0681f9 493 virtual void OnMouseEnter(int id);
1c383dba
VZ
494
495 // more deprecated functions
496 // -------------------------
497
498#if WXWIN_COMPATIBILITY
499 void SetDefaultSize(int w, int h) { SetDefaultSize(wxSize(w, h)); }
500 long GetDefaultWidth() const { return m_defaultWidth; }
501 long GetDefaultHeight() const { return m_defaultHeight; }
502 int GetDefaultButtonWidth() const { return (int) GetDefaultButtonSize().x; };
503 int GetDefaultButtonHeight() const { return (int) GetDefaultButtonSize().y; };
504 virtual void SetDefaultSize(const wxSize& size) { SetToolBitmapSize(size); }
505 virtual wxSize GetDefaultSize() const { return GetToolBitmapSize(); }
506 virtual wxSize GetDefaultButtonSize() const { return GetToolSize(); }
1c383dba
VZ
507#endif // WXWIN_COMPATIBILITY
508
e76c0b5f
VZ
509 // use GetToolMargins() instead
510 wxSize GetMargins() const { return GetToolMargins(); }
511
1c383dba
VZ
512 // implementation only from now on
513 // -------------------------------
514
8a0681f9 515 size_t GetToolsCount() const { return m_tools.GetCount(); }
1c383dba 516
8a0681f9 517 void OnIdle(wxIdleEvent& event);
1c383dba 518
8a0681f9
VZ
519 // Do the toolbar button updates (check for EVT_UPDATE_UI handlers)
520 virtual void DoToolbarUpdates();
b02da6b1 521
33b12a3a
VZ
522 // don't want toolbars to accept the focus
523 virtual bool AcceptsFocus() const { return FALSE; }
4f430439 524
8a0681f9
VZ
525protected:
526 // to implement in derived classes
527 // -------------------------------
1c383dba 528
e76c0b5f
VZ
529 // create a new toolbar tool and add it to the toolbar, this is typically
530 // implemented by just calling InsertTool()
531 virtual wxToolBarToolBase *DoAddTool
532 (
533 int id,
534 const wxString& label,
535 const wxBitmap& bitmap,
536 const wxBitmap& bmpDisabled,
537 wxItemKind kind,
538 const wxString& shortHelp = wxEmptyString,
539 const wxString& longHelp = wxEmptyString,
540 wxObject *clientData = NULL,
541 wxCoord xPos = -1,
542 wxCoord yPos = -1
543 );
544
8a0681f9
VZ
545 // the tool is not yet inserted into m_tools list when this function is
546 // called and will only be added to it if this function succeeds
547 virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool) = 0;
1c383dba 548
8a0681f9
VZ
549 // the tool is still in m_tools list when this function is called, it will
550 // only be deleted from it if it succeeds
551 virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool) = 0;
1c383dba 552
8a0681f9
VZ
553 // called when the tools enabled flag changes
554 virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable) = 0;
1c383dba 555
8a0681f9
VZ
556 // called when the tool is toggled
557 virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle) = 0;
1c383dba 558
8a0681f9
VZ
559 // called when the tools "can be toggled" flag changes
560 virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle) = 0;
10b959e3 561
8a0681f9
VZ
562 // the functions to create toolbar tools
563 virtual wxToolBarToolBase *CreateTool(int id,
e76c0b5f
VZ
564 const wxString& label,
565 const wxBitmap& bmpNormal,
566 const wxBitmap& bmpDisabled,
567 wxItemKind kind,
8a0681f9 568 wxObject *clientData,
e76c0b5f
VZ
569 const wxString& shortHelp,
570 const wxString& longHelp) = 0;
571
8a0681f9 572 virtual wxToolBarToolBase *CreateTool(wxControl *control) = 0;
1c383dba 573
8a0681f9
VZ
574 // helper functions
575 // ----------------
1c383dba 576
8a0681f9
VZ
577 // find the tool by id
578 wxToolBarToolBase *FindById(int id) const;
1c383dba 579
8a0681f9
VZ
580 // the list of all our tools
581 wxToolBarToolsList m_tools;
1c383dba 582
8a0681f9
VZ
583 // the offset of the first tool
584 int m_xMargin;
585 int m_yMargin;
10b959e3 586
8a0681f9
VZ
587 // the maximum number of toolbar rows/columns
588 int m_maxRows;
589 int m_maxCols;
1c383dba 590
8a0681f9
VZ
591 // the tool packing and separation
592 int m_toolPacking,
593 m_toolSeparation;
1c383dba 594
8a0681f9
VZ
595 // the size of the toolbar bitmaps
596 wxCoord m_defaultWidth, m_defaultHeight;
1c383dba
VZ
597
598private:
10b959e3 599 DECLARE_EVENT_TABLE()
12ed316d 600 DECLARE_CLASS(wxToolBarBase)
10b959e3
JS
601};
602
c229e50d
JS
603// Helper function for creating the image for disabled buttons
604bool wxCreateGreyedImage(const wxImage& in, wxImage& out) ;
605
1e6feb95
VZ
606#endif // wxUSE_TOOLBAR
607
10b959e3 608#endif
34138703 609 // _WX_TBARBASE_H_
10b959e3 610