]> git.saurik.com Git - wxWidgets.git/blame - include/wx/tbarbase.h
Add wxHL_* styles
[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
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
d3c7fc99 108 virtual ~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
197protected:
198 wxToolBarBase *m_tbar; // the toolbar to which we belong (may be NULL)
199
e76c0b5f
VZ
200 // tool parameters
201 int m_toolStyle; // see enum wxToolBarToolStyle
202 int m_id; // the tool id, wxID_SEPARATOR for separator
203 wxItemKind m_kind; // for normal buttons may be wxITEM_NORMAL/CHECK/RADIO
1c383dba
VZ
204
205 // as controls have their own client data, no need to waste memory
206 union
207 {
208 wxObject *m_clientData;
209 wxControl *m_control;
210 };
211
8a0681f9
VZ
212 // tool state
213 bool m_toggled;
8a0681f9 214 bool m_enabled;
1c383dba 215
e76c0b5f
VZ
216 // normal and disabled bitmaps for the tool, both can be invalid
217 wxBitmap m_bmpNormal;
218 wxBitmap m_bmpDisabled;
1c383dba 219
3216dbf5
VZ
220 // the button label
221 wxString m_label;
222
8a0681f9
VZ
223 // short and long help strings
224 wxString m_shortHelpString;
225 wxString m_longHelpString;
22f3361e 226
d6071228 227 DECLARE_DYNAMIC_CLASS_NO_COPY(wxToolBarToolBase)
10b959e3
JS
228};
229
8a0681f9 230// a list of toolbar tools
f6bcfd97 231WX_DECLARE_EXPORTED_LIST(wxToolBarToolBase, wxToolBarToolsList);
8a0681f9 232
1c383dba
VZ
233// ----------------------------------------------------------------------------
234// the base class for all toolbars
235// ----------------------------------------------------------------------------
236
10b959e3
JS
237class WXDLLEXPORT wxToolBarBase : public wxControl
238{
1c383dba
VZ
239public:
240 wxToolBarBase();
8a0681f9 241 virtual ~wxToolBarBase();
10b959e3 242
1c383dba
VZ
243 // toolbar construction
244 // --------------------
10b959e3 245
e76c0b5f
VZ
246 // the full AddTool() function
247 //
248 // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
249 // is created and used as the disabled image.
d9e2e4c2 250 wxToolBarToolBase *AddTool(int toolid,
e76c0b5f 251 const wxString& label,
3ca6a5f0 252 const wxBitmap& bitmap,
e76c0b5f
VZ
253 const wxBitmap& bmpDisabled,
254 wxItemKind kind = wxITEM_NORMAL,
255 const wxString& shortHelp = wxEmptyString,
256 const wxString& longHelp = wxEmptyString,
257 wxObject *data = NULL)
3ca6a5f0 258 {
d9e2e4c2 259 return DoAddTool(toolid, label, bitmap, bmpDisabled, kind,
e76c0b5f 260 shortHelp, longHelp, data);
3ca6a5f0
BP
261 }
262
e76c0b5f 263 // the most common AddTool() version
d9e2e4c2 264 wxToolBarToolBase *AddTool(int toolid,
e76c0b5f 265 const wxString& label,
8a0681f9 266 const wxBitmap& bitmap,
e76c0b5f
VZ
267 const wxString& shortHelp = wxEmptyString,
268 wxItemKind kind = wxITEM_NORMAL)
8a0681f9 269 {
d9e2e4c2 270 return AddTool(toolid, label, bitmap, wxNullBitmap, kind, shortHelp);
e76c0b5f
VZ
271 }
272
273 // add a check tool, i.e. a tool which can be toggled
d9e2e4c2 274 wxToolBarToolBase *AddCheckTool(int toolid,
e76c0b5f
VZ
275 const wxString& label,
276 const wxBitmap& bitmap,
277 const wxBitmap& bmpDisabled = wxNullBitmap,
278 const wxString& shortHelp = wxEmptyString,
279 const wxString& longHelp = wxEmptyString,
280 wxObject *data = NULL)
281 {
d9e2e4c2 282 return AddTool(toolid, label, bitmap, bmpDisabled, wxITEM_CHECK,
e76c0b5f
VZ
283 shortHelp, longHelp, data);
284 }
285
286 // add a radio tool, i.e. a tool which can be toggled and releases any
287 // other toggled radio tools in the same group when it happens
d9e2e4c2 288 wxToolBarToolBase *AddRadioTool(int toolid,
e76c0b5f
VZ
289 const wxString& label,
290 const wxBitmap& bitmap,
291 const wxBitmap& bmpDisabled = wxNullBitmap,
292 const wxString& shortHelp = wxEmptyString,
293 const wxString& longHelp = wxEmptyString,
294 wxObject *data = NULL)
295 {
d9e2e4c2 296 return AddTool(toolid, label, bitmap, bmpDisabled, wxITEM_RADIO,
e76c0b5f 297 shortHelp, longHelp, data);
8a0681f9
VZ
298 }
299
8a0681f9
VZ
300
301 // insert the new tool at the given position, if pos == GetToolsCount(), it
302 // is equivalent to AddTool()
303 virtual wxToolBarToolBase *InsertTool
304 (
305 size_t pos,
d9e2e4c2 306 int toolid,
e76c0b5f 307 const wxString& label,
8a0681f9 308 const wxBitmap& bitmap,
e76c0b5f
VZ
309 const wxBitmap& bmpDisabled = wxNullBitmap,
310 wxItemKind kind = wxITEM_NORMAL,
311 const wxString& shortHelp = wxEmptyString,
312 const wxString& longHelp = wxEmptyString,
313 wxObject *clientData = NULL
8a0681f9
VZ
314 );
315
dd91da4e
VZ
316 virtual wxToolBarToolBase *AddTool (wxToolBarToolBase *tool);
317 virtual wxToolBarToolBase *InsertTool (size_t pos, wxToolBarToolBase *tool);
318
cb719f2e 319 // add an arbitrary control to the toolbar (notice that
8a0681f9
VZ
320 // the control will be deleted by the toolbar and that it will also adjust
321 // its position/size)
1c383dba
VZ
322 //
323 // NB: the control should have toolbar as its parent
8a0681f9
VZ
324 virtual wxToolBarToolBase *AddControl(wxControl *control);
325 virtual wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
cb719f2e 326
fba2d5e6 327 // get the control with the given id or return NULL
d9e2e4c2 328 virtual wxControl *FindControl( int toolid );
10b959e3 329
8a0681f9
VZ
330 // add a separator to the toolbar
331 virtual wxToolBarToolBase *AddSeparator();
332 virtual wxToolBarToolBase *InsertSeparator(size_t pos);
333
334 // remove the tool from the toolbar: the caller is responsible for actually
335 // deleting the pointer
d9e2e4c2 336 virtual wxToolBarToolBase *RemoveTool(int toolid);
8a0681f9
VZ
337
338 // delete tool either by index or by position
339 virtual bool DeleteToolByPos(size_t pos);
d9e2e4c2 340 virtual bool DeleteTool(int toolid);
8a0681f9
VZ
341
342 // delete all tools
1c383dba 343 virtual void ClearTools();
10b959e3 344
1c383dba
VZ
345 // must be called after all buttons have been created to finish toolbar
346 // initialisation
8a0681f9 347 virtual bool Realize();
10b959e3 348
1c383dba
VZ
349 // tools state
350 // -----------
10b959e3 351
d9e2e4c2
DE
352 virtual void EnableTool(int toolid, bool enable);
353 virtual void ToggleTool(int toolid, bool toggle);
b02da6b1 354
1c383dba 355 // Set this to be togglable (or not)
d9e2e4c2 356 virtual void SetToggle(int toolid, bool toggle);
8a0681f9 357
6fd5fa4f 358 // set/get tools client data (not for controls)
d9e2e4c2
DE
359 virtual wxObject *GetToolClientData(int toolid) const;
360 virtual void SetToolClientData(int toolid, wxObject *clientData);
10b959e3 361
e6c96a7c
JS
362 // returns tool pos, or wxNOT_FOUND if tool isn't found
363 virtual int GetToolPos(int id) const;
364
cb719f2e 365 // return true if the tool is toggled
d9e2e4c2 366 virtual bool GetToolState(int toolid) const;
8a0681f9 367
d9e2e4c2 368 virtual bool GetToolEnabled(int toolid) const;
81d66cf3 369
d9e2e4c2
DE
370 virtual void SetToolShortHelp(int toolid, const wxString& helpString);
371 virtual wxString GetToolShortHelp(int toolid) const;
372 virtual void SetToolLongHelp(int toolid, const wxString& helpString);
373 virtual wxString GetToolLongHelp(int toolid) const;
10b959e3 374
bbd321ff
RD
375 virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap) {}
376 virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap) {}
377
1c383dba
VZ
378 // margins/packing/separation
379 // --------------------------
10b959e3 380
1c383dba
VZ
381 virtual void SetMargins(int x, int y);
382 void SetMargins(const wxSize& size)
383 { SetMargins((int) size.x, (int) size.y); }
8a0681f9
VZ
384 virtual void SetToolPacking(int packing)
385 { m_toolPacking = packing; }
386 virtual void SetToolSeparation(int separation)
387 { m_toolSeparation = separation; }
10b959e3 388
e76c0b5f
VZ
389 virtual wxSize GetToolMargins() const { return wxSize(m_xMargin, m_yMargin); }
390 virtual int GetToolPacking() const { return m_toolPacking; }
391 virtual int GetToolSeparation() const { return m_toolSeparation; }
ef7eaedd 392
8a0681f9
VZ
393 // toolbar geometry
394 // ----------------
395
396 // set the number of toolbar rows
397 virtual void SetRows(int nRows);
398
399 // the toolbar can wrap - limit the number of columns or rows it may take
1c383dba
VZ
400 void SetMaxRowsCols(int rows, int cols)
401 { m_maxRows = rows; m_maxCols = cols; }
402 int GetMaxRows() const { return m_maxRows; }
403 int GetMaxCols() const { return m_maxCols; }
10b959e3 404
8a0681f9
VZ
405 // get/set the size of the bitmaps used by the toolbar: should be called
406 // before adding any tools to the toolbar
1c383dba
VZ
407 virtual void SetToolBitmapSize(const wxSize& size)
408 { m_defaultWidth = size.x; m_defaultHeight = size.y; };
409 virtual wxSize GetToolBitmapSize() const
410 { return wxSize(m_defaultWidth, m_defaultHeight); }
10b959e3 411
8a0681f9
VZ
412 // the button size in some implementations is bigger than the bitmap size:
413 // get the total button size (by default the same as bitmap size)
1c383dba 414 virtual wxSize GetToolSize() const
8a0681f9 415 { return GetToolBitmapSize(); } ;
10b959e3 416
8a0681f9
VZ
417 // returns a (non separator) tool containing the point (x, y) or NULL if
418 // there is no tool at this point (corrdinates are client)
419 virtual wxToolBarToolBase *FindToolForPosition(wxCoord x,
420 wxCoord y) const = 0;
421
d6071228
RD
422 // find the tool by id
423 wxToolBarToolBase *FindById(int toolid) const;
424
cb719f2e 425 // return true if this is a vertical toolbar, otherwise false
7a976304 426 bool IsVertical() const { return HasFlag(wxTB_LEFT | wxTB_RIGHT); }
3216dbf5 427
e76c0b5f
VZ
428
429 // the old versions of the various methods kept for compatibility
430 // don't use in the new code!
431 // --------------------------------------------------------------
432
d9e2e4c2 433 wxToolBarToolBase *AddTool(int toolid,
e76c0b5f
VZ
434 const wxBitmap& bitmap,
435 const wxBitmap& bmpDisabled,
cb719f2e 436 bool toggle = false,
e76c0b5f
VZ
437 wxObject *clientData = NULL,
438 const wxString& shortHelpString = wxEmptyString,
439 const wxString& longHelpString = wxEmptyString)
440 {
d9e2e4c2 441 return AddTool(toolid, wxEmptyString,
e76c0b5f
VZ
442 bitmap, bmpDisabled,
443 toggle ? wxITEM_CHECK : wxITEM_NORMAL,
444 shortHelpString, longHelpString, clientData);
445 }
446
d9e2e4c2 447 wxToolBarToolBase *AddTool(int toolid,
e76c0b5f
VZ
448 const wxBitmap& bitmap,
449 const wxString& shortHelpString = wxEmptyString,
450 const wxString& longHelpString = wxEmptyString)
451 {
d9e2e4c2 452 return AddTool(toolid, wxEmptyString,
e76c0b5f
VZ
453 bitmap, wxNullBitmap, wxITEM_NORMAL,
454 shortHelpString, longHelpString, NULL);
455 }
456
d9e2e4c2 457 wxToolBarToolBase *AddTool(int toolid,
e76c0b5f
VZ
458 const wxBitmap& bitmap,
459 const wxBitmap& bmpDisabled,
460 bool toggle,
461 wxCoord xPos,
cb719f2e 462 wxCoord yPos = wxDefaultCoord,
e76c0b5f
VZ
463 wxObject *clientData = NULL,
464 const wxString& shortHelp = wxEmptyString,
465 const wxString& longHelp = wxEmptyString)
466 {
d9e2e4c2 467 return DoAddTool(toolid, wxEmptyString, bitmap, bmpDisabled,
e76c0b5f
VZ
468 toggle ? wxITEM_CHECK : wxITEM_NORMAL,
469 shortHelp, longHelp, clientData, xPos, yPos);
470 }
471
472 wxToolBarToolBase *InsertTool(size_t pos,
d9e2e4c2 473 int toolid,
e76c0b5f
VZ
474 const wxBitmap& bitmap,
475 const wxBitmap& bmpDisabled = wxNullBitmap,
cb719f2e 476 bool toggle = false,
e76c0b5f
VZ
477 wxObject *clientData = NULL,
478 const wxString& shortHelp = wxEmptyString,
479 const wxString& longHelp = wxEmptyString)
480 {
d9e2e4c2 481 return InsertTool(pos, toolid, wxEmptyString, bitmap, bmpDisabled,
e76c0b5f
VZ
482 toggle ? wxITEM_CHECK : wxITEM_NORMAL,
483 shortHelp, longHelp, clientData);
484 }
485
8a0681f9
VZ
486 // event handlers
487 // --------------
10b959e3 488
1c383dba 489 // NB: these functions are deprecated, use EVT_TOOL_XXX() instead!
10b959e3 490
cb719f2e 491 // Only allow toggle if returns true. Call when left button up.
d9e2e4c2 492 virtual bool OnLeftClick(int toolid, bool toggleDown);
b02da6b1 493
1c383dba 494 // Call when right button down.
d9e2e4c2 495 virtual void OnRightClick(int toolid, long x, long y);
10b959e3 496
1c383dba 497 // Called when the mouse cursor enters a tool bitmap.
cb719f2e 498 // Argument is wxID_ANY if mouse is exiting the toolbar.
d9e2e4c2 499 virtual void OnMouseEnter(int toolid);
1c383dba
VZ
500
501 // more deprecated functions
502 // -------------------------
503
e76c0b5f
VZ
504 // use GetToolMargins() instead
505 wxSize GetMargins() const { return GetToolMargins(); }
506
1c383dba
VZ
507 // implementation only from now on
508 // -------------------------------
509
8a0681f9 510 size_t GetToolsCount() const { return m_tools.GetCount(); }
1c383dba 511
8a0681f9 512 // Do the toolbar button updates (check for EVT_UPDATE_UI handlers)
e39af974 513 virtual void UpdateWindowUI(long flags = wxUPDATE_UI_NONE) ;
b02da6b1 514
33b12a3a 515 // don't want toolbars to accept the focus
cb719f2e 516 virtual bool AcceptsFocus() const { return false; }
4f430439 517
8a0681f9
VZ
518protected:
519 // to implement in derived classes
520 // -------------------------------
1c383dba 521
e76c0b5f
VZ
522 // create a new toolbar tool and add it to the toolbar, this is typically
523 // implemented by just calling InsertTool()
524 virtual wxToolBarToolBase *DoAddTool
525 (
d9e2e4c2 526 int toolid,
e76c0b5f
VZ
527 const wxString& label,
528 const wxBitmap& bitmap,
529 const wxBitmap& bmpDisabled,
530 wxItemKind kind,
531 const wxString& shortHelp = wxEmptyString,
532 const wxString& longHelp = wxEmptyString,
533 wxObject *clientData = NULL,
cb719f2e
WS
534 wxCoord xPos = wxDefaultCoord,
535 wxCoord yPos = wxDefaultCoord
e76c0b5f
VZ
536 );
537
8a0681f9
VZ
538 // the tool is not yet inserted into m_tools list when this function is
539 // called and will only be added to it if this function succeeds
540 virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool) = 0;
1c383dba 541
8a0681f9
VZ
542 // the tool is still in m_tools list when this function is called, it will
543 // only be deleted from it if it succeeds
544 virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool) = 0;
1c383dba 545
8a0681f9
VZ
546 // called when the tools enabled flag changes
547 virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable) = 0;
1c383dba 548
8a0681f9
VZ
549 // called when the tool is toggled
550 virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle) = 0;
1c383dba 551
8a0681f9
VZ
552 // called when the tools "can be toggled" flag changes
553 virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle) = 0;
10b959e3 554
8a0681f9 555 // the functions to create toolbar tools
d9e2e4c2 556 virtual wxToolBarToolBase *CreateTool(int toolid,
e76c0b5f
VZ
557 const wxString& label,
558 const wxBitmap& bmpNormal,
559 const wxBitmap& bmpDisabled,
560 wxItemKind kind,
8a0681f9 561 wxObject *clientData,
e76c0b5f
VZ
562 const wxString& shortHelp,
563 const wxString& longHelp) = 0;
564
8a0681f9 565 virtual wxToolBarToolBase *CreateTool(wxControl *control) = 0;
1c383dba 566
8a0681f9
VZ
567 // helper functions
568 // ----------------
1c383dba 569
d408730c
VZ
570 // call this from derived class ctor/Create() to ensure that we have either
571 // wxTB_HORIZONTAL or wxTB_VERTICAL style, there is a lot of existing code
572 // which randomly checks either one or the other of them and gets confused
573 // if neither is set (and making one of them 0 is not an option neither as
574 // then the existing tests would break down)
575 void FixupStyle();
576
6bb7cee4
VZ
577 // un-toggle all buttons in the same radio group
578 void UnToggleRadioGroup(wxToolBarToolBase *tool);
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()
fc7a2a60 600 DECLARE_NO_COPY_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