]> git.saurik.com Git - wxWidgets.git/blame - include/wx/tbarbase.h
added missing public keyword to wxWritableCharTypeBuffer declaration
[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
63ec432b 35extern WXDLLEXPORT_DATA(const wxChar) wxToolBarNameStr[];
16cba29d
WS
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 78 if (m_id == wxID_ANY)
f24b783a 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
cdb11cb9
VZ
94 wxToolBarToolBase(wxToolBarBase *tbar,
95 wxControl *control,
96 const wxString& label)
97 : m_label(label)
8a0681f9
VZ
98 {
99 m_tbar = tbar;
100 m_control = control;
101 m_id = control->GetId();
102
e76c0b5f
VZ
103 m_kind = wxITEM_MAX; // invalid value
104
cb719f2e
WS
105 m_enabled = true;
106 m_toggled = false;
8a0681f9
VZ
107
108 m_toolStyle = wxTOOL_STYLE_CONTROL;
109 }
110
d3c7fc99 111 virtual ~wxToolBarToolBase(){}
1c383dba
VZ
112
113 // accessors
114 // ---------
115
8a0681f9
VZ
116 // general
117 int GetId() const { return m_id; }
1c383dba
VZ
118
119 wxControl *GetControl() const
120 {
8a0681f9 121 wxASSERT_MSG( IsControl(), _T("this toolbar tool is not a control") );
1c383dba
VZ
122
123 return m_control;
124 }
10b959e3 125
8a0681f9
VZ
126 wxToolBarBase *GetToolBar() const { return m_tbar; }
127
128 // style
42d6e136
VZ
129 bool IsButton() const { return m_toolStyle == wxTOOL_STYLE_BUTTON; }
130 bool IsControl() const { return m_toolStyle == wxTOOL_STYLE_CONTROL; }
131 bool IsSeparator() const { return m_toolStyle == wxTOOL_STYLE_SEPARATOR; }
8a0681f9 132 int GetStyle() const { return m_toolStyle; }
e76c0b5f
VZ
133 wxItemKind GetKind() const
134 {
135 wxASSERT_MSG( IsButton(), _T("only makes sense for buttons") );
136
137 return m_kind;
138 }
8a0681f9
VZ
139
140 // state
141 bool IsEnabled() const { return m_enabled; }
142 bool IsToggled() const { return m_toggled; }
e76c0b5f
VZ
143 bool CanBeToggled() const
144 { return m_kind == wxITEM_CHECK || m_kind == wxITEM_RADIO; }
8a0681f9
VZ
145
146 // attributes
e76c0b5f
VZ
147 const wxBitmap& GetNormalBitmap() const { return m_bmpNormal; }
148 const wxBitmap& GetDisabledBitmap() const { return m_bmpDisabled; }
8a0681f9
VZ
149
150 const wxBitmap& GetBitmap() const
3216dbf5
VZ
151 { return IsEnabled() ? GetNormalBitmap() : GetDisabledBitmap(); }
152
27e09084 153 const wxString& GetLabel() const { return m_label; }
8a0681f9 154
27e09084
VZ
155 const wxString& GetShortHelp() const { return m_shortHelpString; }
156 const wxString& GetLongHelp() const { return m_longHelpString; }
8a0681f9
VZ
157
158 wxObject *GetClientData() const
159 {
6fd5fa4f
VZ
160 if ( m_toolStyle == wxTOOL_STYLE_CONTROL )
161 {
2063a4a0 162 return (wxObject*)m_control->GetClientData();
6fd5fa4f
VZ
163 }
164 else
165 {
166 return m_clientData;
167 }
8a0681f9
VZ
168 }
169
cb719f2e 170 // modifiers: return true if the state really changed
8a0681f9
VZ
171 bool Enable(bool enable);
172 bool Toggle(bool toggle);
173 bool SetToggle(bool toggle);
174 bool SetShortHelp(const wxString& help);
175 bool SetLongHelp(const wxString& help);
176
177 void Toggle() { Toggle(!IsToggled()); }
178
e76c0b5f
VZ
179 void SetNormalBitmap(const wxBitmap& bmp) { m_bmpNormal = bmp; }
180 void SetDisabledBitmap(const wxBitmap& bmp) { m_bmpDisabled = bmp; }
3216dbf5 181
c631abda 182 virtual void SetLabel(const wxString& label) { m_label = label; }
8a0681f9 183
6fd5fa4f
VZ
184 void SetClientData(wxObject *clientData)
185 {
186 if ( m_toolStyle == wxTOOL_STYLE_CONTROL )
187 {
188 m_control->SetClientData(clientData);
189 }
190 else
191 {
192 m_clientData = clientData;
193 }
194 }
195
8a0681f9
VZ
196 // add tool to/remove it from a toolbar
197 virtual void Detach() { m_tbar = (wxToolBarBase *)NULL; }
198 virtual void Attach(wxToolBarBase *tbar) { m_tbar = tbar; }
199
200protected:
201 wxToolBarBase *m_tbar; // the toolbar to which we belong (may be NULL)
202
e76c0b5f
VZ
203 // tool parameters
204 int m_toolStyle; // see enum wxToolBarToolStyle
205 int m_id; // the tool id, wxID_SEPARATOR for separator
206 wxItemKind m_kind; // for normal buttons may be wxITEM_NORMAL/CHECK/RADIO
1c383dba
VZ
207
208 // as controls have their own client data, no need to waste memory
209 union
210 {
211 wxObject *m_clientData;
212 wxControl *m_control;
213 };
214
8a0681f9
VZ
215 // tool state
216 bool m_toggled;
8a0681f9 217 bool m_enabled;
1c383dba 218
e76c0b5f
VZ
219 // normal and disabled bitmaps for the tool, both can be invalid
220 wxBitmap m_bmpNormal;
221 wxBitmap m_bmpDisabled;
1c383dba 222
3216dbf5
VZ
223 // the button label
224 wxString m_label;
225
8a0681f9
VZ
226 // short and long help strings
227 wxString m_shortHelpString;
228 wxString m_longHelpString;
22f3361e 229
d6071228 230 DECLARE_DYNAMIC_CLASS_NO_COPY(wxToolBarToolBase)
10b959e3
JS
231};
232
8a0681f9 233// a list of toolbar tools
f6bcfd97 234WX_DECLARE_EXPORTED_LIST(wxToolBarToolBase, wxToolBarToolsList);
8a0681f9 235
1c383dba
VZ
236// ----------------------------------------------------------------------------
237// the base class for all toolbars
238// ----------------------------------------------------------------------------
239
10b959e3
JS
240class WXDLLEXPORT wxToolBarBase : public wxControl
241{
1c383dba
VZ
242public:
243 wxToolBarBase();
8a0681f9 244 virtual ~wxToolBarBase();
10b959e3 245
1c383dba
VZ
246 // toolbar construction
247 // --------------------
10b959e3 248
e76c0b5f
VZ
249 // the full AddTool() function
250 //
251 // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
252 // is created and used as the disabled image.
d9e2e4c2 253 wxToolBarToolBase *AddTool(int toolid,
e76c0b5f 254 const wxString& label,
3ca6a5f0 255 const wxBitmap& bitmap,
e76c0b5f
VZ
256 const wxBitmap& bmpDisabled,
257 wxItemKind kind = wxITEM_NORMAL,
258 const wxString& shortHelp = wxEmptyString,
259 const wxString& longHelp = wxEmptyString,
260 wxObject *data = NULL)
3ca6a5f0 261 {
d9e2e4c2 262 return DoAddTool(toolid, label, bitmap, bmpDisabled, kind,
e76c0b5f 263 shortHelp, longHelp, data);
3ca6a5f0
BP
264 }
265
e76c0b5f 266 // the most common AddTool() version
d9e2e4c2 267 wxToolBarToolBase *AddTool(int toolid,
e76c0b5f 268 const wxString& label,
8a0681f9 269 const wxBitmap& bitmap,
e76c0b5f
VZ
270 const wxString& shortHelp = wxEmptyString,
271 wxItemKind kind = wxITEM_NORMAL)
8a0681f9 272 {
d9e2e4c2 273 return AddTool(toolid, label, bitmap, wxNullBitmap, kind, shortHelp);
e76c0b5f
VZ
274 }
275
276 // add a check tool, i.e. a tool which can be toggled
d9e2e4c2 277 wxToolBarToolBase *AddCheckTool(int toolid,
e76c0b5f
VZ
278 const wxString& label,
279 const wxBitmap& bitmap,
280 const wxBitmap& bmpDisabled = wxNullBitmap,
281 const wxString& shortHelp = wxEmptyString,
282 const wxString& longHelp = wxEmptyString,
283 wxObject *data = NULL)
284 {
d9e2e4c2 285 return AddTool(toolid, label, bitmap, bmpDisabled, wxITEM_CHECK,
e76c0b5f
VZ
286 shortHelp, longHelp, data);
287 }
288
289 // add a radio tool, i.e. a tool which can be toggled and releases any
290 // other toggled radio tools in the same group when it happens
d9e2e4c2 291 wxToolBarToolBase *AddRadioTool(int toolid,
e76c0b5f
VZ
292 const wxString& label,
293 const wxBitmap& bitmap,
294 const wxBitmap& bmpDisabled = wxNullBitmap,
295 const wxString& shortHelp = wxEmptyString,
296 const wxString& longHelp = wxEmptyString,
297 wxObject *data = NULL)
298 {
d9e2e4c2 299 return AddTool(toolid, label, bitmap, bmpDisabled, wxITEM_RADIO,
e76c0b5f 300 shortHelp, longHelp, data);
8a0681f9
VZ
301 }
302
8a0681f9
VZ
303
304 // insert the new tool at the given position, if pos == GetToolsCount(), it
305 // is equivalent to AddTool()
306 virtual wxToolBarToolBase *InsertTool
307 (
308 size_t pos,
d9e2e4c2 309 int toolid,
e76c0b5f 310 const wxString& label,
8a0681f9 311 const wxBitmap& bitmap,
e76c0b5f
VZ
312 const wxBitmap& bmpDisabled = wxNullBitmap,
313 wxItemKind kind = wxITEM_NORMAL,
314 const wxString& shortHelp = wxEmptyString,
315 const wxString& longHelp = wxEmptyString,
316 wxObject *clientData = NULL
8a0681f9
VZ
317 );
318
dd91da4e
VZ
319 virtual wxToolBarToolBase *AddTool (wxToolBarToolBase *tool);
320 virtual wxToolBarToolBase *InsertTool (size_t pos, wxToolBarToolBase *tool);
321
cdb11cb9
VZ
322 // add an arbitrary control to the toolbar (notice that the control will be
323 // deleted by the toolbar and that it will also adjust its position/size)
1c383dba 324 //
cdb11cb9 325 // the label is optional and, if specified, will be shown near the control
1c383dba 326 // NB: the control should have toolbar as its parent
cdb11cb9
VZ
327 virtual wxToolBarToolBase *
328 AddControl(wxControl *control, const wxString& label = wxEmptyString);
329
330 virtual wxToolBarToolBase *
331 InsertControl(size_t pos, wxControl *control,
332 const wxString& label = wxEmptyString);
cb719f2e 333
fba2d5e6 334 // get the control with the given id or return NULL
d9e2e4c2 335 virtual wxControl *FindControl( int toolid );
10b959e3 336
8a0681f9
VZ
337 // add a separator to the toolbar
338 virtual wxToolBarToolBase *AddSeparator();
339 virtual wxToolBarToolBase *InsertSeparator(size_t pos);
340
341 // remove the tool from the toolbar: the caller is responsible for actually
342 // deleting the pointer
d9e2e4c2 343 virtual wxToolBarToolBase *RemoveTool(int toolid);
8a0681f9
VZ
344
345 // delete tool either by index or by position
346 virtual bool DeleteToolByPos(size_t pos);
d9e2e4c2 347 virtual bool DeleteTool(int toolid);
8a0681f9
VZ
348
349 // delete all tools
1c383dba 350 virtual void ClearTools();
10b959e3 351
1c383dba
VZ
352 // must be called after all buttons have been created to finish toolbar
353 // initialisation
8a0681f9 354 virtual bool Realize();
10b959e3 355
1c383dba
VZ
356 // tools state
357 // -----------
10b959e3 358
d9e2e4c2
DE
359 virtual void EnableTool(int toolid, bool enable);
360 virtual void ToggleTool(int toolid, bool toggle);
b02da6b1 361
1c383dba 362 // Set this to be togglable (or not)
d9e2e4c2 363 virtual void SetToggle(int toolid, bool toggle);
8a0681f9 364
6fd5fa4f 365 // set/get tools client data (not for controls)
d9e2e4c2
DE
366 virtual wxObject *GetToolClientData(int toolid) const;
367 virtual void SetToolClientData(int toolid, wxObject *clientData);
10b959e3 368
e6c96a7c
JS
369 // returns tool pos, or wxNOT_FOUND if tool isn't found
370 virtual int GetToolPos(int id) const;
371
cb719f2e 372 // return true if the tool is toggled
d9e2e4c2 373 virtual bool GetToolState(int toolid) const;
8a0681f9 374
d9e2e4c2 375 virtual bool GetToolEnabled(int toolid) const;
81d66cf3 376
d9e2e4c2
DE
377 virtual void SetToolShortHelp(int toolid, const wxString& helpString);
378 virtual wxString GetToolShortHelp(int toolid) const;
379 virtual void SetToolLongHelp(int toolid, const wxString& helpString);
380 virtual wxString GetToolLongHelp(int toolid) const;
10b959e3 381
6cd67472
RD
382 virtual void SetToolNormalBitmap(int WXUNUSED(id),
383 const wxBitmap& WXUNUSED(bitmap)) {}
384 virtual void SetToolDisabledBitmap(int WXUNUSED(id),
385 const wxBitmap& WXUNUSED(bitmap)) {}
bbd321ff 386
6cd67472 387
1c383dba
VZ
388 // margins/packing/separation
389 // --------------------------
10b959e3 390
1c383dba
VZ
391 virtual void SetMargins(int x, int y);
392 void SetMargins(const wxSize& size)
393 { SetMargins((int) size.x, (int) size.y); }
8a0681f9
VZ
394 virtual void SetToolPacking(int packing)
395 { m_toolPacking = packing; }
396 virtual void SetToolSeparation(int separation)
397 { m_toolSeparation = separation; }
10b959e3 398
e76c0b5f
VZ
399 virtual wxSize GetToolMargins() const { return wxSize(m_xMargin, m_yMargin); }
400 virtual int GetToolPacking() const { return m_toolPacking; }
401 virtual int GetToolSeparation() const { return m_toolSeparation; }
ef7eaedd 402
8a0681f9
VZ
403 // toolbar geometry
404 // ----------------
405
406 // set the number of toolbar rows
407 virtual void SetRows(int nRows);
408
409 // the toolbar can wrap - limit the number of columns or rows it may take
1c383dba
VZ
410 void SetMaxRowsCols(int rows, int cols)
411 { m_maxRows = rows; m_maxCols = cols; }
412 int GetMaxRows() const { return m_maxRows; }
413 int GetMaxCols() const { return m_maxCols; }
10b959e3 414
8a0681f9
VZ
415 // get/set the size of the bitmaps used by the toolbar: should be called
416 // before adding any tools to the toolbar
1c383dba
VZ
417 virtual void SetToolBitmapSize(const wxSize& size)
418 { m_defaultWidth = size.x; m_defaultHeight = size.y; };
419 virtual wxSize GetToolBitmapSize() const
420 { return wxSize(m_defaultWidth, m_defaultHeight); }
10b959e3 421
8a0681f9
VZ
422 // the button size in some implementations is bigger than the bitmap size:
423 // get the total button size (by default the same as bitmap size)
1c383dba 424 virtual wxSize GetToolSize() const
8a0681f9 425 { return GetToolBitmapSize(); } ;
10b959e3 426
8a0681f9
VZ
427 // returns a (non separator) tool containing the point (x, y) or NULL if
428 // there is no tool at this point (corrdinates are client)
429 virtual wxToolBarToolBase *FindToolForPosition(wxCoord x,
430 wxCoord y) const = 0;
431
d6071228
RD
432 // find the tool by id
433 wxToolBarToolBase *FindById(int toolid) const;
434
cb719f2e 435 // return true if this is a vertical toolbar, otherwise false
7a976304 436 bool IsVertical() const { return HasFlag(wxTB_LEFT | wxTB_RIGHT); }
3216dbf5 437
e76c0b5f
VZ
438
439 // the old versions of the various methods kept for compatibility
440 // don't use in the new code!
441 // --------------------------------------------------------------
442
d9e2e4c2 443 wxToolBarToolBase *AddTool(int toolid,
e76c0b5f
VZ
444 const wxBitmap& bitmap,
445 const wxBitmap& bmpDisabled,
cb719f2e 446 bool toggle = false,
e76c0b5f
VZ
447 wxObject *clientData = NULL,
448 const wxString& shortHelpString = wxEmptyString,
449 const wxString& longHelpString = wxEmptyString)
450 {
d9e2e4c2 451 return AddTool(toolid, wxEmptyString,
e76c0b5f
VZ
452 bitmap, bmpDisabled,
453 toggle ? wxITEM_CHECK : wxITEM_NORMAL,
454 shortHelpString, longHelpString, clientData);
455 }
456
d9e2e4c2 457 wxToolBarToolBase *AddTool(int toolid,
e76c0b5f
VZ
458 const wxBitmap& bitmap,
459 const wxString& shortHelpString = wxEmptyString,
460 const wxString& longHelpString = wxEmptyString)
461 {
d9e2e4c2 462 return AddTool(toolid, wxEmptyString,
e76c0b5f
VZ
463 bitmap, wxNullBitmap, wxITEM_NORMAL,
464 shortHelpString, longHelpString, NULL);
465 }
466
d9e2e4c2 467 wxToolBarToolBase *AddTool(int toolid,
e76c0b5f
VZ
468 const wxBitmap& bitmap,
469 const wxBitmap& bmpDisabled,
470 bool toggle,
471 wxCoord xPos,
cb719f2e 472 wxCoord yPos = wxDefaultCoord,
e76c0b5f
VZ
473 wxObject *clientData = NULL,
474 const wxString& shortHelp = wxEmptyString,
475 const wxString& longHelp = wxEmptyString)
476 {
d9e2e4c2 477 return DoAddTool(toolid, wxEmptyString, bitmap, bmpDisabled,
e76c0b5f
VZ
478 toggle ? wxITEM_CHECK : wxITEM_NORMAL,
479 shortHelp, longHelp, clientData, xPos, yPos);
480 }
481
482 wxToolBarToolBase *InsertTool(size_t pos,
d9e2e4c2 483 int toolid,
e76c0b5f
VZ
484 const wxBitmap& bitmap,
485 const wxBitmap& bmpDisabled = wxNullBitmap,
cb719f2e 486 bool toggle = false,
e76c0b5f
VZ
487 wxObject *clientData = NULL,
488 const wxString& shortHelp = wxEmptyString,
489 const wxString& longHelp = wxEmptyString)
490 {
d9e2e4c2 491 return InsertTool(pos, toolid, wxEmptyString, bitmap, bmpDisabled,
e76c0b5f
VZ
492 toggle ? wxITEM_CHECK : wxITEM_NORMAL,
493 shortHelp, longHelp, clientData);
494 }
495
8a0681f9
VZ
496 // event handlers
497 // --------------
10b959e3 498
1c383dba 499 // NB: these functions are deprecated, use EVT_TOOL_XXX() instead!
10b959e3 500
cb719f2e 501 // Only allow toggle if returns true. Call when left button up.
d9e2e4c2 502 virtual bool OnLeftClick(int toolid, bool toggleDown);
b02da6b1 503
1c383dba 504 // Call when right button down.
d9e2e4c2 505 virtual void OnRightClick(int toolid, long x, long y);
10b959e3 506
1c383dba 507 // Called when the mouse cursor enters a tool bitmap.
cb719f2e 508 // Argument is wxID_ANY if mouse is exiting the toolbar.
d9e2e4c2 509 virtual void OnMouseEnter(int toolid);
1c383dba
VZ
510
511 // more deprecated functions
512 // -------------------------
513
e76c0b5f
VZ
514 // use GetToolMargins() instead
515 wxSize GetMargins() const { return GetToolMargins(); }
516
1c383dba
VZ
517 // implementation only from now on
518 // -------------------------------
519
8a0681f9 520 size_t GetToolsCount() const { return m_tools.GetCount(); }
1c383dba 521
8a0681f9 522 // Do the toolbar button updates (check for EVT_UPDATE_UI handlers)
e39af974 523 virtual void UpdateWindowUI(long flags = wxUPDATE_UI_NONE) ;
b02da6b1 524
33b12a3a 525 // don't want toolbars to accept the focus
cb719f2e 526 virtual bool AcceptsFocus() const { return false; }
4f430439 527
8a0681f9
VZ
528protected:
529 // to implement in derived classes
530 // -------------------------------
1c383dba 531
e76c0b5f
VZ
532 // create a new toolbar tool and add it to the toolbar, this is typically
533 // implemented by just calling InsertTool()
534 virtual wxToolBarToolBase *DoAddTool
535 (
d9e2e4c2 536 int toolid,
e76c0b5f
VZ
537 const wxString& label,
538 const wxBitmap& bitmap,
539 const wxBitmap& bmpDisabled,
540 wxItemKind kind,
541 const wxString& shortHelp = wxEmptyString,
542 const wxString& longHelp = wxEmptyString,
543 wxObject *clientData = NULL,
cb719f2e
WS
544 wxCoord xPos = wxDefaultCoord,
545 wxCoord yPos = wxDefaultCoord
e76c0b5f
VZ
546 );
547
8a0681f9
VZ
548 // the tool is not yet inserted into m_tools list when this function is
549 // called and will only be added to it if this function succeeds
550 virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool) = 0;
1c383dba 551
8a0681f9
VZ
552 // the tool is still in m_tools list when this function is called, it will
553 // only be deleted from it if it succeeds
554 virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool) = 0;
1c383dba 555
8a0681f9
VZ
556 // called when the tools enabled flag changes
557 virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable) = 0;
1c383dba 558
8a0681f9
VZ
559 // called when the tool is toggled
560 virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle) = 0;
1c383dba 561
8a0681f9
VZ
562 // called when the tools "can be toggled" flag changes
563 virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle) = 0;
10b959e3 564
8a0681f9 565 // the functions to create toolbar tools
d9e2e4c2 566 virtual wxToolBarToolBase *CreateTool(int toolid,
e76c0b5f
VZ
567 const wxString& label,
568 const wxBitmap& bmpNormal,
569 const wxBitmap& bmpDisabled,
570 wxItemKind kind,
8a0681f9 571 wxObject *clientData,
e76c0b5f
VZ
572 const wxString& shortHelp,
573 const wxString& longHelp) = 0;
574
cdb11cb9
VZ
575 virtual wxToolBarToolBase *CreateTool(wxControl *control,
576 const wxString& label) = 0;
1c383dba 577
8a0681f9
VZ
578 // helper functions
579 // ----------------
1c383dba 580
d408730c
VZ
581 // call this from derived class ctor/Create() to ensure that we have either
582 // wxTB_HORIZONTAL or wxTB_VERTICAL style, there is a lot of existing code
583 // which randomly checks either one or the other of them and gets confused
584 // if neither is set (and making one of them 0 is not an option neither as
585 // then the existing tests would break down)
586 void FixupStyle();
587
6bb7cee4
VZ
588 // un-toggle all buttons in the same radio group
589 void UnToggleRadioGroup(wxToolBarToolBase *tool);
590
8a0681f9
VZ
591 // the list of all our tools
592 wxToolBarToolsList m_tools;
1c383dba 593
8a0681f9
VZ
594 // the offset of the first tool
595 int m_xMargin;
596 int m_yMargin;
10b959e3 597
8a0681f9
VZ
598 // the maximum number of toolbar rows/columns
599 int m_maxRows;
600 int m_maxCols;
1c383dba 601
8a0681f9
VZ
602 // the tool packing and separation
603 int m_toolPacking,
604 m_toolSeparation;
1c383dba 605
8a0681f9
VZ
606 // the size of the toolbar bitmaps
607 wxCoord m_defaultWidth, m_defaultHeight;
1c383dba
VZ
608
609private:
10b959e3 610 DECLARE_EVENT_TABLE()
fc7a2a60 611 DECLARE_NO_COPY_CLASS(wxToolBarBase)
10b959e3
JS
612};
613
9ac43913
VZ
614// deprecated function for creating the image for disabled buttons, use
615// wxImage::ConvertToGreyscale() instead
616#if WXWIN_COMPATIBILITY_2_8
617
618wxDEPRECATED( bool wxCreateGreyedImage(const wxImage& in, wxImage& out) );
619
620#endif // WXWIN_COMPATIBILITY_2_8
621
c229e50d 622
1e6feb95
VZ
623#endif // wxUSE_TOOLBAR
624
10b959e3 625#endif
34138703 626 // _WX_TBARBASE_H_
10b959e3 627