1
/////////////////////////////////////////////////////////////////////////////
3
// Purpose: SWIG interface defs for wxStatusBar
7
// Created: 24-Aug-1998
8
// RCS-ID: $Id: _toolbar.i 71592 2012-05-30 03:10:49Z RD $
9
// Copyright: (c) 2003 by Total Control Software
10
// Licence: wxWindows license
11
/////////////////////////////////////////////////////////////////////////////
16
//---------------------------------------------------------------------------
18
MAKE_CONST_WXSTRING_NOSWIG(ToolBarNameStr);
21
//---------------------------------------------------------------------------
27
enum wxToolBarToolStyle
29
wxTOOL_STYLE_BUTTON = 1,
30
wxTOOL_STYLE_SEPARATOR = 2,
56
// wxToolBarTool is a toolbar element.
58
// It has a unique id (except for the separators which always have id -1), the
59
// style (telling whether it is a normal button, separator or a control), the
60
// state (toggled or not, enabled or not) and short and long help strings. The
61
// default implementations use the short help string for the tooltip text which
62
// is popped up when the mouse pointer enters the tool and the long help string
63
// for the applications status bar.
64
class wxToolBarToolBase : public wxObject {
66
// wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL,
67
// int id = wxID_SEPARATOR,
68
// const wxString& label = wxPyEmptyString,
69
// const wxBitmap& bmpNormal = wxNullBitmap,
70
// const wxBitmap& bmpDisabled = wxNullBitmap,
71
// wxItemKind kind = wxITEM_NORMAL,
72
// wxObject *clientData = (wxObject *) NULL,
73
// const wxString& shortHelpString = wxPyEmptyString,
74
// const wxString& longHelpString = wxPyEmptyString)
75
// ~wxToolBarToolBase();
78
wxControl *GetControl();
79
wxToolBarBase *GetToolBar();
80
bool IsStretchable() const;
84
bool IsStretchableSpace() const;
87
void MakeStretchable();
91
const wxBitmap& GetNormalBitmap();
92
const wxBitmap& GetDisabledBitmap();
95
wxString GetShortHelp();
96
wxString GetLongHelp();
97
bool Enable(bool enable);
99
bool SetToggle(bool toggle);
100
bool SetShortHelp(const wxString& help);
101
bool SetLongHelp(const wxString& help);
102
void SetNormalBitmap(const wxBitmap& bmp);
103
void SetDisabledBitmap(const wxBitmap& bmp);
104
void SetLabel(const wxString& label);
106
void Attach(wxToolBarBase *tbar);
108
// these methods are only for tools of wxITEM_DROPDOWN kind (but even such
109
// tools can have a NULL associated menu)
110
void SetDropdownMenu(wxMenu *menu);
111
wxMenu *GetDropdownMenu() const;
113
//wxObject *GetClientData();
115
// convert the ClientData back to a PyObject
116
PyObject* GetClientData() {
117
wxPyUserData* udata = (wxPyUserData*)self->GetClientData();
118
return wxPyUserData::SafeGetData(udata);
121
void SetClientData(PyObject* clientData) {
122
self->SetClientData(new wxPyUserData(clientData));
127
GetBitmap1 = GetNormalBitmap
128
GetBitmap2 = GetDisabledBitmap
129
SetBitmap1 = SetNormalBitmap
130
SetBitmap2 = SetDisabledBitmap
133
%property(Bitmap, GetBitmap, doc="See `GetBitmap`");
134
%property(ClientData, GetClientData, SetClientData, doc="See `GetClientData` and `SetClientData`");
135
%property(Control, GetControl, doc="See `GetControl`");
136
%property(DisabledBitmap, GetDisabledBitmap, SetDisabledBitmap, doc="See `GetDisabledBitmap` and `SetDisabledBitmap`");
137
%property(Id, GetId, doc="See `GetId`");
138
%property(Kind, GetKind, doc="See `GetKind`");
139
%property(Label, GetLabel, SetLabel, doc="See `GetLabel` and `SetLabel`");
140
%property(LongHelp, GetLongHelp, SetLongHelp, doc="See `GetLongHelp` and `SetLongHelp`");
141
%property(NormalBitmap, GetNormalBitmap, SetNormalBitmap, doc="See `GetNormalBitmap` and `SetNormalBitmap`");
142
%property(ShortHelp, GetShortHelp, SetShortHelp, doc="See `GetShortHelp` and `SetShortHelp`");
143
%property(Style, GetStyle, doc="See `GetStyle`");
144
%property(ToolBar, GetToolBar, doc="See `GetToolBar`");
150
class wxToolBarBase : public wxControl {
153
// This is an Abstract Base Class
157
// The full AddTool() function. Call it DoAddTool in wxPython and
158
// implement the other Add methods by calling it.
160
// If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
161
// is created and used as the disabled image.
162
wxToolBarToolBase *DoAddTool(int id,
163
const wxString& label,
164
const wxBitmap& bitmap,
165
const wxBitmap& bmpDisabled = wxNullBitmap,
166
wxItemKind kind = wxITEM_NORMAL,
167
const wxString& shortHelp = wxPyEmptyString,
168
const wxString& longHelp = wxPyEmptyString,
169
PyObject *clientData = NULL)
171
wxPyUserData* udata = NULL;
172
if (clientData && clientData != Py_None)
173
udata = new wxPyUserData(clientData);
174
return self->AddTool(id, label, bitmap, bmpDisabled, kind,
175
shortHelp, longHelp, udata);
179
// Insert the new tool at the given position, if pos == GetToolsCount(), it
180
// is equivalent to DoAddTool()
181
wxToolBarToolBase *DoInsertTool(size_t pos,
183
const wxString& label,
184
const wxBitmap& bitmap,
185
const wxBitmap& bmpDisabled = wxNullBitmap,
186
wxItemKind kind = wxITEM_NORMAL,
187
const wxString& shortHelp = wxPyEmptyString,
188
const wxString& longHelp = wxPyEmptyString,
189
PyObject *clientData = NULL)
191
wxPyUserData* udata = NULL;
192
if (clientData && clientData != Py_None)
193
udata = new wxPyUserData(clientData);
194
return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind,
195
shortHelp, longHelp, udata);
202
%# These match the original Add methods for this class, kept for
203
%# backwards compatibility with versions < 2.3.3.
206
def AddTool(self, id, bitmap,
207
pushedBitmap = wx.NullBitmap,
210
shortHelpString = '',
211
longHelpString = '') :
212
'''Old style method to add a tool to the toolbar.'''
213
kind = wx.ITEM_NORMAL
214
if isToggle: kind = wx.ITEM_CHECK
215
return self.DoAddTool(id, '', bitmap, pushedBitmap, kind,
216
shortHelpString, longHelpString, clientData)
218
def AddSimpleTool(self, id, bitmap,
219
shortHelpString = '',
222
'''Old style method to add a tool to the toolbar.'''
223
kind = wx.ITEM_NORMAL
224
if isToggle: kind = wx.ITEM_CHECK
225
return self.DoAddTool(id, '', bitmap, wx.NullBitmap, kind,
226
shortHelpString, longHelpString, None)
228
def InsertTool(self, pos, id, bitmap,
229
pushedBitmap = wx.NullBitmap,
232
shortHelpString = '',
233
longHelpString = ''):
234
'''Old style method to insert a tool in the toolbar.'''
235
kind = wx.ITEM_NORMAL
236
if isToggle: kind = wx.ITEM_CHECK
237
return self.DoInsertTool(pos, id, '', bitmap, pushedBitmap, kind,
238
shortHelpString, longHelpString, clientData)
240
def InsertSimpleTool(self, pos, id, bitmap,
241
shortHelpString = '',
244
'''Old style method to insert a tool in the toolbar.'''
245
kind = wx.ITEM_NORMAL
246
if isToggle: kind = wx.ITEM_CHECK
247
return self.DoInsertTool(pos, id, '', bitmap, wx.NullBitmap, kind,
248
shortHelpString, longHelpString, None)
251
%# The following are the new toolbar Add methods starting with
252
%# 2.3.3. They are renamed to have 'Label' in the name so as to be
253
%# able to keep backwards compatibility with using the above
254
%# methods. Eventually these should migrate to be the methods used
255
%# primarily and lose the 'Label' in the name...
257
def AddLabelTool(self, id, label, bitmap,
258
bmpDisabled = wx.NullBitmap,
259
kind = wx.ITEM_NORMAL,
260
shortHelp = '', longHelp = '',
263
The full AddTool() function.
265
If bmpDisabled is wx.NullBitmap, a shadowed version of the normal bitmap
266
is created and used as the disabled image.
268
return self.DoAddTool(id, label, bitmap, bmpDisabled, kind,
269
shortHelp, longHelp, clientData)
272
def InsertLabelTool(self, pos, id, label, bitmap,
273
bmpDisabled = wx.NullBitmap,
274
kind = wx.ITEM_NORMAL,
275
shortHelp = '', longHelp = '',
278
Insert the new tool at the given position, if pos == GetToolsCount(), it
279
is equivalent to AddTool()
281
return self.DoInsertTool(pos, id, label, bitmap, bmpDisabled, kind,
282
shortHelp, longHelp, clientData)
284
def AddCheckLabelTool(self, id, label, bitmap,
285
bmpDisabled = wx.NullBitmap,
286
shortHelp = '', longHelp = '',
288
'''Add a check tool, i.e. a tool which can be toggled'''
289
return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_CHECK,
290
shortHelp, longHelp, clientData)
292
def AddRadioLabelTool(self, id, label, bitmap,
293
bmpDisabled = wx.NullBitmap,
294
shortHelp = '', longHelp = '',
297
Add a radio tool, i.e. a tool which can be toggled and releases any
298
other toggled radio tools in the same group when it happens
300
return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_RADIO,
301
shortHelp, longHelp, clientData)
304
%# For consistency with the backwards compatible methods above, here are
305
%# some non-'Label' versions of the Check and Radio methods
307
def AddCheckTool(self, id, bitmap,
308
bmpDisabled = wx.NullBitmap,
309
shortHelp = '', longHelp = '',
311
'''Add a check tool, i.e. a tool which can be toggled'''
312
return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.ITEM_CHECK,
313
shortHelp, longHelp, clientData)
315
def AddRadioTool(self, id, bitmap,
316
bmpDisabled = wx.NullBitmap,
317
shortHelp = '', longHelp = '',
320
Add a radio tool, i.e. a tool which can be toggled and releases any
321
other toggled radio tools in the same group when it happens
323
return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.ITEM_RADIO,
324
shortHelp, longHelp, clientData)
327
%Rename(AddToolItem, wxToolBarToolBase*, AddTool (wxToolBarToolBase *tool));
328
%Rename(InsertToolItem, wxToolBarToolBase*, InsertTool (size_t pos, wxToolBarToolBase *tool));
330
wxToolBarToolBase *AddControl(wxControl *control,
331
const wxString& label = wxEmptyString);
332
wxToolBarToolBase *InsertControl(size_t pos, wxControl *control,
333
const wxString& label = wxEmptyString);
334
wxControl *FindControl( int id );
336
wxToolBarToolBase *AddSeparator();
337
wxToolBarToolBase *InsertSeparator(size_t pos);
339
// add a stretchable space to the toolbar: this is similar to a separator
340
// except that it's always blank and that all the extra space the toolbar
341
// has is [equally] distributed among the stretchable spaces in it
342
virtual wxToolBarToolBase *AddStretchableSpace();
343
virtual wxToolBarToolBase *InsertStretchableSpace(size_t pos);
345
wxToolBarToolBase *RemoveTool(int id);
347
bool DeleteToolByPos(size_t pos);
348
bool DeleteTool(int id);
352
void EnableTool(int id, bool enable);
353
void ToggleTool(int id, bool toggle);
354
void SetToggle(int id, bool toggle);
358
// convert the ClientData back to a PyObject
359
PyObject* GetToolClientData(int id) {
360
wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
361
return wxPyUserData::SafeGetData(udata);
364
void SetToolClientData(int id, PyObject* clientData) {
365
self->SetToolClientData(id, new wxPyUserData(clientData));
369
// returns tool pos, or wxNOT_FOUND if tool isn't found
370
int GetToolPos(int id) const;
372
bool GetToolState(int id);
373
bool GetToolEnabled(int id);
374
void SetToolShortHelp(int id, const wxString& helpString);
375
wxString GetToolShortHelp(int id);
376
void SetToolLongHelp(int id, const wxString& helpString);
377
wxString GetToolLongHelp(int id);
379
%Rename(SetMarginsXY, void, SetMargins(int x, int y));
380
void SetMargins(const wxSize& size);
381
void SetToolPacking(int packing);
382
void SetToolSeparation(int separation);
383
wxSize GetToolMargins();
385
int GetToolPacking();
386
int GetToolSeparation();
388
void SetRows(int nRows);
389
void SetMaxRowsCols(int rows, int cols);
393
void SetToolBitmapSize(const wxSize& size);
394
wxSize GetToolBitmapSize();
395
wxSize GetToolSize();
397
// returns a (non separator) tool containing the point (x, y) or NULL if
398
// there is no tool at this point (corrdinates are client)
399
wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
401
// find the tool by id
402
wxToolBarToolBase *FindById(int toolid) const;
404
// return True if this is a vertical toolbar, otherwise False
407
size_t GetToolsCount() const;
408
const wxToolBarToolBase *GetToolByPos(int pos);
411
bool SetDropdownMenu(int toolid, wxMenu *menu);
414
%property(Margins, GetMargins, SetMargins, doc="See `GetMargins` and `SetMargins`");
415
%property(MaxCols, GetMaxCols, doc="See `GetMaxCols`");
416
%property(MaxRows, GetMaxRows, doc="See `GetMaxRows`");
417
%property(ToolBitmapSize, GetToolBitmapSize, SetToolBitmapSize, doc="See `GetToolBitmapSize` and `SetToolBitmapSize`");
418
%property(ToolMargins, GetToolMargins, doc="See `GetToolMargins`");
419
%property(ToolPacking, GetToolPacking, SetToolPacking, doc="See `GetToolPacking` and `SetToolPacking`");
420
%property(ToolSeparation, GetToolSeparation, SetToolSeparation, doc="See `GetToolSeparation` and `SetToolSeparation`");
421
%property(ToolSize, GetToolSize, doc="See `GetToolSize`");
422
%property(ToolsCount, GetToolsCount, doc="See `GetToolsCount`");
428
MustHaveApp(wxToolBar);
430
class wxToolBar : public wxToolBarBase {
432
%pythonAppend wxToolBar "self._setOORInfo(self)"
433
%pythonAppend wxToolBar() ""
434
%typemap(out) wxToolBar*; // turn off this typemap
436
wxToolBar(wxWindow *parent,
438
const wxPoint& pos = wxDefaultPosition,
439
const wxSize& size = wxDefaultSize,
440
long style = wxNO_BORDER | wxTB_HORIZONTAL,
441
const wxString& name = wxPyToolBarNameStr);
442
%RenameCtor(PreToolBar, wxToolBar());
444
// Turn it back on again
445
%typemap(out) wxToolBar* { $result = wxPyMake_wxObject($1, $owner); }
447
bool Create(wxWindow *parent,
449
const wxPoint& pos = wxDefaultPosition,
450
const wxSize& size = wxDefaultSize,
451
long style = wxNO_BORDER | wxTB_HORIZONTAL,
452
const wxString& name = wxPyToolBarNameStr);
454
// TODO: In 2.9 move these to the base class...
455
void SetToolNormalBitmap(int id, const wxBitmap& bitmap);
456
void SetToolDisabledBitmap(int id, const wxBitmap& bitmap);
458
static wxVisualAttributes
459
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
462
//---------------------------------------------------------------------------
466
#include <wx/generic/buttonbar.h>
469
MustHaveApp(wxToolBar);
470
class wxButtonToolBar : public wxToolBarBase
473
%pythonAppend wxButtonToolBar "self._setOORInfo(self)"
474
%pythonAppend wxButtonToolBar() ""
476
wxButtonToolBar(wxWindow *parent,
478
const wxPoint& pos = wxDefaultPosition,
479
const wxSize& size = wxDefaultSize,
481
const wxString& name = wxPyToolBarNameStr);
482
%RenameCtor(PreButtonToolBar, wxButtonToolBar());
485
bool Create(wxWindow *parent,
487
const wxPoint& pos = wxDefaultPosition,
488
const wxSize& size = wxDefaultSize,
490
const wxString& name = wxPyToolBarNameStr);
494
//---------------------------------------------------------------------------