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