]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_toolbar.i
Apply parts of patch #1719888 to fix compilation on Mac and with
[wxWidgets.git] / wxPython / src / _toolbar.i
CommitLineData
9c039d08 1/////////////////////////////////////////////////////////////////////////////
d14a1e28
RD
2// Name: _toolbar.i
3// Purpose: SWIG interface defs for wxStatusBar
9c039d08
RD
4//
5// Author: Robin Dunn
6//
d14a1e28 7// Created: 24-Aug-1998
9c039d08 8// RCS-ID: $Id$
d14a1e28 9// Copyright: (c) 2003 by Total Control Software
9c039d08
RD
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
d14a1e28 13// Not a %module
9c039d08 14
9c039d08 15
d14a1e28 16//---------------------------------------------------------------------------
137b5242 17
b2dc1044
RD
18MAKE_CONST_WXSTRING_NOSWIG(ToolBarNameStr);
19
137b5242 20
9c039d08 21//---------------------------------------------------------------------------
d14a1e28 22%newgroup;
9c039d08 23
9c039d08 24
9b3d3bc4
RD
25class wxToolBarBase;
26
27enum wxToolBarToolStyle
28{
29 wxTOOL_STYLE_BUTTON = 1,
30 wxTOOL_STYLE_SEPARATOR = 2,
31 wxTOOL_STYLE_CONTROL
32};
33
3ef86e32
RD
34enum {
35 wxTB_HORIZONTAL,
36 wxTB_VERTICAL,
8f514ab4
RD
37 wxTB_TOP,
38 wxTB_LEFT,
39 wxTB_BOTTOM,
40 wxTB_RIGHT,
41
3ef86e32
RD
42 wxTB_3DBUTTONS,
43 wxTB_FLAT,
44 wxTB_DOCKABLE,
45 wxTB_NOICONS,
46 wxTB_TEXT,
47 wxTB_NODIVIDER,
48 wxTB_NOALIGN,
49 wxTB_HORZ_LAYOUT,
50 wxTB_HORZ_TEXT,
8f514ab4 51 wxTB_NO_TOOLTIPS
3ef86e32
RD
52};
53
9b3d3bc4
RD
54
55
d14a1e28
RD
56// wxToolBarTool is a toolbar element.
57//
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.
9416aa89 64class wxToolBarToolBase : public wxObject {
9b3d3bc4
RD
65public:
66// wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL,
67// int id = wxID_SEPARATOR,
b2dc1044 68// const wxString& label = wxPyEmptyString,
b96c7a38
RD
69// const wxBitmap& bmpNormal = wxNullBitmap,
70// const wxBitmap& bmpDisabled = wxNullBitmap,
71// wxItemKind kind = wxITEM_NORMAL,
9b3d3bc4 72// wxObject *clientData = (wxObject *) NULL,
b2dc1044
RD
73// const wxString& shortHelpString = wxPyEmptyString,
74// const wxString& longHelpString = wxPyEmptyString)
9b3d3bc4
RD
75// ~wxToolBarToolBase();
76
9b3d3bc4
RD
77 int GetId();
78 wxControl *GetControl();
79 wxToolBarBase *GetToolBar();
80 int IsButton();
81 int IsControl();
82 int IsSeparator();
83 int GetStyle();
b96c7a38 84 wxItemKind GetKind();
9b3d3bc4
RD
85 bool IsEnabled();
86 bool IsToggled();
87 bool CanBeToggled();
c6ebc32a
RD
88 const wxBitmap& GetNormalBitmap();
89 const wxBitmap& GetDisabledBitmap();
c5943253 90 wxBitmap GetBitmap();
c6ebc32a 91 wxString GetLabel();
9b3d3bc4
RD
92 wxString GetShortHelp();
93 wxString GetLongHelp();
94 bool Enable(bool enable);
c6ebc32a 95 void Toggle();
9b3d3bc4
RD
96 bool SetToggle(bool toggle);
97 bool SetShortHelp(const wxString& help);
98 bool SetLongHelp(const wxString& help);
c6ebc32a
RD
99 void SetNormalBitmap(const wxBitmap& bmp);
100 void SetDisabledBitmap(const wxBitmap& bmp);
101 void SetLabel(const wxString& label);
9b3d3bc4
RD
102 void Detach();
103 void Attach(wxToolBarBase *tbar);
104
105 //wxObject *GetClientData();
d14a1e28 106 %extend {
9b3d3bc4
RD
107 // convert the ClientData back to a PyObject
108 PyObject* GetClientData() {
109 wxPyUserData* udata = (wxPyUserData*)self->GetClientData();
110 if (udata) {
111 Py_INCREF(udata->m_obj);
112 return udata->m_obj;
113 } else {
114 Py_INCREF(Py_None);
115 return Py_None;
116 }
117 }
118
119 void SetClientData(PyObject* clientData) {
120 self->SetClientData(new wxPyUserData(clientData));
121 }
122 }
c6ebc32a 123
d14a1e28 124 %pythoncode {
c6ebc32a
RD
125 GetBitmap1 = GetNormalBitmap
126 GetBitmap2 = GetDisabledBitmap
127 SetBitmap1 = SetNormalBitmap
128 SetBitmap2 = SetDisabledBitmap
d14a1e28 129 }
994453b8
RD
130
131 %property(Bitmap, GetBitmap, doc="See `GetBitmap`");
132 %property(ClientData, GetClientData, SetClientData, doc="See `GetClientData` and `SetClientData`");
133 %property(Control, GetControl, doc="See `GetControl`");
134 %property(DisabledBitmap, GetDisabledBitmap, SetDisabledBitmap, doc="See `GetDisabledBitmap` and `SetDisabledBitmap`");
135 %property(Id, GetId, doc="See `GetId`");
136 %property(Kind, GetKind, doc="See `GetKind`");
137 %property(Label, GetLabel, SetLabel, doc="See `GetLabel` and `SetLabel`");
138 %property(LongHelp, GetLongHelp, SetLongHelp, doc="See `GetLongHelp` and `SetLongHelp`");
139 %property(NormalBitmap, GetNormalBitmap, SetNormalBitmap, doc="See `GetNormalBitmap` and `SetNormalBitmap`");
140 %property(ShortHelp, GetShortHelp, SetShortHelp, doc="See `GetShortHelp` and `SetShortHelp`");
141 %property(Style, GetStyle, doc="See `GetStyle`");
142 %property(ToolBar, GetToolBar, doc="See `GetToolBar`");
9b3d3bc4
RD
143};
144
145
146
d14a1e28 147
9b3d3bc4
RD
148class wxToolBarBase : public wxControl {
149public:
150
151 // This is an Abstract Base Class
152
d14a1e28 153 %extend {
b96c7a38 154
15030c51
RD
155 // The full AddTool() function. Call it DoAddTool in wxPython and
156 // implement the other Add methods by calling it.
b96c7a38
RD
157 //
158 // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
159 // is created and used as the disabled image.
15030c51
RD
160 wxToolBarToolBase *DoAddTool(int id,
161 const wxString& label,
162 const wxBitmap& bitmap,
163 const wxBitmap& bmpDisabled = wxNullBitmap,
164 wxItemKind kind = wxITEM_NORMAL,
165 const wxString& shortHelp = wxPyEmptyString,
166 const wxString& longHelp = wxPyEmptyString,
167 PyObject *clientData = NULL)
b96c7a38 168 {
9b3d3bc4 169 wxPyUserData* udata = NULL;
15030c51 170 if (clientData && clientData != Py_None)
9b3d3bc4 171 udata = new wxPyUserData(clientData);
b96c7a38
RD
172 return self->AddTool(id, label, bitmap, bmpDisabled, kind,
173 shortHelp, longHelp, udata);
9b3d3bc4
RD
174 }
175
9b3d3bc4 176
15030c51
RD
177 // Insert the new tool at the given position, if pos == GetToolsCount(), it
178 // is equivalent to DoAddTool()
1e4a197e 179 wxToolBarToolBase *DoInsertTool(size_t pos,
9b3d3bc4 180 int id,
b96c7a38 181 const wxString& label,
9b3d3bc4 182 const wxBitmap& bitmap,
b96c7a38
RD
183 const wxBitmap& bmpDisabled = wxNullBitmap,
184 wxItemKind kind = wxITEM_NORMAL,
c12de7f8
RD
185 const wxString& shortHelp = wxPyEmptyString,
186 const wxString& longHelp = wxPyEmptyString,
b96c7a38
RD
187 PyObject *clientData = NULL)
188 {
9b3d3bc4 189 wxPyUserData* udata = NULL;
15030c51 190 if (clientData && clientData != Py_None)
9b3d3bc4 191 udata = new wxPyUserData(clientData);
b96c7a38
RD
192 return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind,
193 shortHelp, longHelp, udata);
9b3d3bc4
RD
194 }
195
9b3d3bc4
RD
196 }
197
198
d14a1e28
RD
199 %pythoncode {
200 %# These match the original Add methods for this class, kept for
201 %# backwards compatibility with versions < 2.3.3.
15030c51
RD
202
203
204 def AddTool(self, id, bitmap,
d14a1e28 205 pushedBitmap = wx.NullBitmap,
15030c51
RD
206 isToggle = 0,
207 clientData = None,
208 shortHelpString = '',
209 longHelpString = '') :
210 '''Old style method to add a tool to the toolbar.'''
d14a1e28
RD
211 kind = wx.ITEM_NORMAL
212 if isToggle: kind = wx.ITEM_CHECK
15030c51
RD
213 return self.DoAddTool(id, '', bitmap, pushedBitmap, kind,
214 shortHelpString, longHelpString, clientData)
215
216 def AddSimpleTool(self, id, bitmap,
217 shortHelpString = '',
218 longHelpString = '',
219 isToggle = 0):
220 '''Old style method to add a tool to the toolbar.'''
d14a1e28
RD
221 kind = wx.ITEM_NORMAL
222 if isToggle: kind = wx.ITEM_CHECK
223 return self.DoAddTool(id, '', bitmap, wx.NullBitmap, kind,
15030c51
RD
224 shortHelpString, longHelpString, None)
225
226 def InsertTool(self, pos, id, bitmap,
d14a1e28 227 pushedBitmap = wx.NullBitmap,
15030c51
RD
228 isToggle = 0,
229 clientData = None,
230 shortHelpString = '',
231 longHelpString = ''):
232 '''Old style method to insert a tool in the toolbar.'''
d14a1e28
RD
233 kind = wx.ITEM_NORMAL
234 if isToggle: kind = wx.ITEM_CHECK
15030c51
RD
235 return self.DoInsertTool(pos, id, '', bitmap, pushedBitmap, kind,
236 shortHelpString, longHelpString, clientData)
237
238 def InsertSimpleTool(self, pos, id, bitmap,
239 shortHelpString = '',
240 longHelpString = '',
241 isToggle = 0):
242 '''Old style method to insert a tool in the toolbar.'''
d14a1e28
RD
243 kind = wx.ITEM_NORMAL
244 if isToggle: kind = wx.ITEM_CHECK
245 return self.DoInsertTool(pos, id, '', bitmap, wx.NullBitmap, kind,
15030c51
RD
246 shortHelpString, longHelpString, None)
247
248
d14a1e28
RD
249 %# The following are the new toolbar Add methods starting with
250 %# 2.3.3. They are renamed to have 'Label' in the name so as to be
251 %# able to keep backwards compatibility with using the above
252 %# methods. Eventually these should migrate to be the methods used
253 %# primarily and lose the 'Label' in the name...
15030c51
RD
254
255 def AddLabelTool(self, id, label, bitmap,
d14a1e28
RD
256 bmpDisabled = wx.NullBitmap,
257 kind = wx.ITEM_NORMAL,
15030c51
RD
258 shortHelp = '', longHelp = '',
259 clientData = None):
260 '''
261 The full AddTool() function.
262
d14a1e28 263 If bmpDisabled is wx.NullBitmap, a shadowed version of the normal bitmap
15030c51
RD
264 is created and used as the disabled image.
265 '''
266 return self.DoAddTool(id, label, bitmap, bmpDisabled, kind,
267 shortHelp, longHelp, clientData)
268
269
270 def InsertLabelTool(self, pos, id, label, bitmap,
d14a1e28
RD
271 bmpDisabled = wx.NullBitmap,
272 kind = wx.ITEM_NORMAL,
15030c51
RD
273 shortHelp = '', longHelp = '',
274 clientData = None):
275 '''
276 Insert the new tool at the given position, if pos == GetToolsCount(), it
277 is equivalent to AddTool()
278 '''
279 return self.DoInsertTool(pos, id, label, bitmap, bmpDisabled, kind,
280 shortHelp, longHelp, clientData)
281
282 def AddCheckLabelTool(self, id, label, bitmap,
d14a1e28 283 bmpDisabled = wx.NullBitmap,
15030c51
RD
284 shortHelp = '', longHelp = '',
285 clientData = None):
286 '''Add a check tool, i.e. a tool which can be toggled'''
d14a1e28 287 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_CHECK,
15030c51
RD
288 shortHelp, longHelp, clientData)
289
290 def AddRadioLabelTool(self, id, label, bitmap,
d14a1e28 291 bmpDisabled = wx.NullBitmap,
15030c51
RD
292 shortHelp = '', longHelp = '',
293 clientData = None):
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
297 '''
d14a1e28 298 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_RADIO,
15030c51
RD
299 shortHelp, longHelp, clientData)
300
301
d14a1e28
RD
302 %# For consistency with the backwards compatible methods above, here are
303 %# some non-'Label' versions of the Check and Radio methods
d5573410 304
15030c51 305 def AddCheckTool(self, id, bitmap,
d14a1e28 306 bmpDisabled = wx.NullBitmap,
15030c51
RD
307 shortHelp = '', longHelp = '',
308 clientData = None):
309 '''Add a check tool, i.e. a tool which can be toggled'''
d14a1e28 310 return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.ITEM_CHECK,
15030c51
RD
311 shortHelp, longHelp, clientData)
312
313 def AddRadioTool(self, id, bitmap,
d14a1e28 314 bmpDisabled = wx.NullBitmap,
15030c51
RD
315 shortHelp = '', longHelp = '',
316 clientData = None):
317 '''
318 Add a radio tool, i.e. a tool which can be toggled and releases any
319 other toggled radio tools in the same group when it happens
320 '''
d14a1e28 321 return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.ITEM_RADIO,
15030c51 322 shortHelp, longHelp, clientData)
d14a1e28 323 }
15030c51 324
1b8c7ba6
RD
325 %Rename(AddToolItem, wxToolBarToolBase*, AddTool (wxToolBarToolBase *tool));
326 %Rename(InsertToolItem, wxToolBarToolBase*, InsertTool (size_t pos, wxToolBarToolBase *tool));
15030c51 327
cbfc9df6
RD
328 wxToolBarToolBase *AddControl(wxControl *control,
329 const wxString& label = wxEmptyString);
330 wxToolBarToolBase *InsertControl(size_t pos, wxControl *control,
331 const wxString& label = wxEmptyString);
fe953afb 332 wxControl *FindControl( int id );
9b3d3bc4
RD
333
334 wxToolBarToolBase *AddSeparator();
335 wxToolBarToolBase *InsertSeparator(size_t pos);
336
337 wxToolBarToolBase *RemoveTool(int id);
338
339 bool DeleteToolByPos(size_t pos);
340 bool DeleteTool(int id);
341 void ClearTools();
342 bool Realize();
343
344 void EnableTool(int id, bool enable);
345 void ToggleTool(int id, bool toggle);
346 void SetToggle(int id, bool toggle);
347
348
d14a1e28 349 %extend {
9b3d3bc4 350 // convert the ClientData back to a PyObject
c6ebc32a
RD
351 PyObject* GetToolClientData(int id) {
352 wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
9b3d3bc4
RD
353 if (udata) {
354 Py_INCREF(udata->m_obj);
355 return udata->m_obj;
356 } else {
357 Py_INCREF(Py_None);
358 return Py_None;
359 }
360 }
361
c6ebc32a
RD
362 void SetToolClientData(int id, PyObject* clientData) {
363 self->SetToolClientData(id, new wxPyUserData(clientData));
9b3d3bc4
RD
364 }
365 }
366
3ef86e32
RD
367 // returns tool pos, or wxNOT_FOUND if tool isn't found
368 int GetToolPos(int id) const;
9b3d3bc4
RD
369
370 bool GetToolState(int id);
371 bool GetToolEnabled(int id);
372 void SetToolShortHelp(int id, const wxString& helpString);
373 wxString GetToolShortHelp(int id);
374 void SetToolLongHelp(int id, const wxString& helpString);
375 wxString GetToolLongHelp(int id);
376
1b8c7ba6 377 %Rename(SetMarginsXY, void, SetMargins(int x, int y));
9b3d3bc4
RD
378 void SetMargins(const wxSize& size);
379 void SetToolPacking(int packing);
380 void SetToolSeparation(int separation);
381 wxSize GetToolMargins();
83b18bab 382 wxSize GetMargins();
9b3d3bc4
RD
383 int GetToolPacking();
384 int GetToolSeparation();
385
386 void SetRows(int nRows);
387 void SetMaxRowsCols(int rows, int cols);
388 int GetMaxRows();
389 int GetMaxCols();
390
391 void SetToolBitmapSize(const wxSize& size);
392 wxSize GetToolBitmapSize();
393 wxSize GetToolSize();
394
c6ebc32a
RD
395 // returns a (non separator) tool containing the point (x, y) or NULL if
396 // there is no tool at this point (corrdinates are client)
397 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
398
a6d2f5bb
RD
399 // find the tool by id
400 wxToolBarToolBase *FindById(int toolid) const;
401
dd9f7fea 402 // return True if this is a vertical toolbar, otherwise False
c6ebc32a 403 bool IsVertical();
06336f51
RD
404
405 size_t GetToolsCount() const;
994453b8
RD
406
407 %property(Margins, GetMargins, SetMargins, doc="See `GetMargins` and `SetMargins`");
408 %property(MaxCols, GetMaxCols, doc="See `GetMaxCols`");
409 %property(MaxRows, GetMaxRows, doc="See `GetMaxRows`");
410 %property(ToolBitmapSize, GetToolBitmapSize, SetToolBitmapSize, doc="See `GetToolBitmapSize` and `SetToolBitmapSize`");
411 %property(ToolMargins, GetToolMargins, doc="See `GetToolMargins`");
412 %property(ToolPacking, GetToolPacking, SetToolPacking, doc="See `GetToolPacking` and `SetToolPacking`");
413 %property(ToolSeparation, GetToolSeparation, SetToolSeparation, doc="See `GetToolSeparation` and `SetToolSeparation`");
414 %property(ToolSize, GetToolSize, doc="See `GetToolSize`");
415 %property(ToolsCount, GetToolsCount, doc="See `GetToolsCount`");
9b3d3bc4
RD
416};
417
418
419
420
ab1f7d2a
RD
421MustHaveApp(wxToolBar);
422
9b3d3bc4
RD
423class wxToolBar : public wxToolBarBase {
424public:
2b9048c5
RD
425 %pythonAppend wxToolBar "self._setOORInfo(self)"
426 %pythonAppend wxToolBar() ""
b39c3fa0
RD
427 %typemap(out) wxToolBar*; // turn off this typemap
428
9b3d3bc4 429 wxToolBar(wxWindow *parent,
d5573410 430 wxWindowID id=-1,
b68dc582
RD
431 const wxPoint& pos = wxDefaultPosition,
432 const wxSize& size = wxDefaultSize,
9b3d3bc4 433 long style = wxNO_BORDER | wxTB_HORIZONTAL,
137b5242 434 const wxString& name = wxPyToolBarNameStr);
1b8c7ba6 435 %RenameCtor(PreToolBar, wxToolBar());
09f3d4e6 436
b39c3fa0
RD
437 // Turn it back on again
438 %typemap(out) wxToolBar* { $result = wxPyMake_wxObject($1, $owner); }
439
09f3d4e6 440 bool Create(wxWindow *parent,
d5573410 441 wxWindowID id=-1,
09f3d4e6
RD
442 const wxPoint& pos = wxDefaultPosition,
443 const wxSize& size = wxDefaultSize,
444 long style = wxNO_BORDER | wxTB_HORIZONTAL,
137b5242 445 const wxString& name = wxPyToolBarNameStr);
9b3d3bc4 446
3c69a2ec
RD
447 // TODO: In 2.9 move these to the base class...
448 void SetToolNormalBitmap(int id, const wxBitmap& bitmap);
449 void SetToolDisabledBitmap(int id, const wxBitmap& bitmap);
450
880715c9
RD
451 static wxVisualAttributes
452 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
9b3d3bc4
RD
453};
454
9c039d08 455//---------------------------------------------------------------------------
de871c91
RD
456
457#if 0
458%{
459#include <wx/generic/buttonbar.h>
460%}
461
462MustHaveApp(wxToolBar);
463class wxButtonToolBar : public wxToolBarBase
464{
465public:
466 %pythonAppend wxButtonToolBar "self._setOORInfo(self)"
467 %pythonAppend wxButtonToolBar() ""
468
469 wxButtonToolBar(wxWindow *parent,
470 wxWindowID id=-1,
471 const wxPoint& pos = wxDefaultPosition,
472 const wxSize& size = wxDefaultSize,
473 long style = 0,
474 const wxString& name = wxPyToolBarNameStr);
475 %RenameCtor(PreButtonToolBar, wxButtonToolBar());
476
477
478 bool Create(wxWindow *parent,
479 wxWindowID id=-1,
480 const wxPoint& pos = wxDefaultPosition,
481 const wxSize& size = wxDefaultSize,
482 long style = 0,
483 const wxString& name = wxPyToolBarNameStr);
484};
485
486#endif
487//---------------------------------------------------------------------------