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