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