1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface defs for wxStatusBar
7 // Created: 24-Aug-1998
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();
88 const wxBitmap& GetNormalBitmap();
89 const wxBitmap& GetDisabledBitmap();
92 wxString GetShortHelp();
93 wxString GetLongHelp();
94 bool Enable(bool enable);
96 bool SetToggle(bool toggle);
97 bool SetShortHelp(const wxString& help);
98 bool SetLongHelp(const wxString& help);
99 void SetNormalBitmap(const wxBitmap& bmp);
100 void SetDisabledBitmap(const wxBitmap& bmp);
101 void SetLabel(const wxString& label);
103 void Attach(wxToolBarBase *tbar);
105 // these methods are only for tools of wxITEM_DROPDOWN kind (but even such
106 // tools can have a NULL associated menu)
107 void SetDropdownMenu(wxMenu *menu);
108 wxMenu *GetDropdownMenu() const;
110 //wxObject *GetClientData();
112 // convert the ClientData back to a PyObject
113 PyObject* GetClientData() {
114 wxPyUserData* udata = (wxPyUserData*)self->GetClientData();
116 Py_INCREF(udata->m_obj);
124 void SetClientData(PyObject* clientData) {
125 self->SetClientData(new wxPyUserData(clientData));
130 GetBitmap1 = GetNormalBitmap
131 GetBitmap2 = GetDisabledBitmap
132 SetBitmap1 = SetNormalBitmap
133 SetBitmap2 = SetDisabledBitmap
136 %property(Bitmap, GetBitmap, doc="See `GetBitmap`");
137 %property(ClientData, GetClientData, SetClientData, doc="See `GetClientData` and `SetClientData`");
138 %property(Control, GetControl, doc="See `GetControl`");
139 %property(DisabledBitmap, GetDisabledBitmap, SetDisabledBitmap, doc="See `GetDisabledBitmap` and `SetDisabledBitmap`");
140 %property(Id, GetId, doc="See `GetId`");
141 %property(Kind, GetKind, doc="See `GetKind`");
142 %property(Label, GetLabel, SetLabel, doc="See `GetLabel` and `SetLabel`");
143 %property(LongHelp, GetLongHelp, SetLongHelp, doc="See `GetLongHelp` and `SetLongHelp`");
144 %property(NormalBitmap, GetNormalBitmap, SetNormalBitmap, doc="See `GetNormalBitmap` and `SetNormalBitmap`");
145 %property(ShortHelp, GetShortHelp, SetShortHelp, doc="See `GetShortHelp` and `SetShortHelp`");
146 %property(Style, GetStyle, doc="See `GetStyle`");
147 %property(ToolBar, GetToolBar, doc="See `GetToolBar`");
153 class wxToolBarBase : public wxControl {
156 // This is an Abstract Base Class
160 // The full AddTool() function. Call it DoAddTool in wxPython and
161 // implement the other Add methods by calling it.
163 // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
164 // is created and used as the disabled image.
165 wxToolBarToolBase *DoAddTool(int id,
166 const wxString& label,
167 const wxBitmap& bitmap,
168 const wxBitmap& bmpDisabled = wxNullBitmap,
169 wxItemKind kind = wxITEM_NORMAL,
170 const wxString& shortHelp = wxPyEmptyString,
171 const wxString& longHelp = wxPyEmptyString,
172 PyObject *clientData = NULL)
174 wxPyUserData* udata = NULL;
175 if (clientData && clientData != Py_None)
176 udata = new wxPyUserData(clientData);
177 return self->AddTool(id, label, bitmap, bmpDisabled, kind,
178 shortHelp, longHelp, udata);
182 // Insert the new tool at the given position, if pos == GetToolsCount(), it
183 // is equivalent to DoAddTool()
184 wxToolBarToolBase *DoInsertTool(size_t pos,
186 const wxString& label,
187 const wxBitmap& bitmap,
188 const wxBitmap& bmpDisabled = wxNullBitmap,
189 wxItemKind kind = wxITEM_NORMAL,
190 const wxString& shortHelp = wxPyEmptyString,
191 const wxString& longHelp = wxPyEmptyString,
192 PyObject *clientData = NULL)
194 wxPyUserData* udata = NULL;
195 if (clientData && clientData != Py_None)
196 udata = new wxPyUserData(clientData);
197 return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind,
198 shortHelp, longHelp, udata);
205 %# These match the original Add methods for this class, kept for
206 %# backwards compatibility with versions < 2.3.3.
209 def AddTool(self, id, bitmap,
210 pushedBitmap = wx.NullBitmap,
213 shortHelpString = '',
214 longHelpString = '') :
215 '''Old style method to add a tool to the toolbar.'''
216 kind = wx.ITEM_NORMAL
217 if isToggle: kind = wx.ITEM_CHECK
218 return self.DoAddTool(id, '', bitmap, pushedBitmap, kind,
219 shortHelpString, longHelpString, clientData)
221 def AddSimpleTool(self, id, bitmap,
222 shortHelpString = '',
225 '''Old style method to add a tool to the toolbar.'''
226 kind = wx.ITEM_NORMAL
227 if isToggle: kind = wx.ITEM_CHECK
228 return self.DoAddTool(id, '', bitmap, wx.NullBitmap, kind,
229 shortHelpString, longHelpString, None)
231 def InsertTool(self, pos, id, bitmap,
232 pushedBitmap = wx.NullBitmap,
235 shortHelpString = '',
236 longHelpString = ''):
237 '''Old style method to insert a tool in the toolbar.'''
238 kind = wx.ITEM_NORMAL
239 if isToggle: kind = wx.ITEM_CHECK
240 return self.DoInsertTool(pos, id, '', bitmap, pushedBitmap, kind,
241 shortHelpString, longHelpString, clientData)
243 def InsertSimpleTool(self, pos, id, bitmap,
244 shortHelpString = '',
247 '''Old style method to insert a tool in the toolbar.'''
248 kind = wx.ITEM_NORMAL
249 if isToggle: kind = wx.ITEM_CHECK
250 return self.DoInsertTool(pos, id, '', bitmap, wx.NullBitmap, kind,
251 shortHelpString, longHelpString, None)
254 %# The following are the new toolbar Add methods starting with
255 %# 2.3.3. They are renamed to have 'Label' in the name so as to be
256 %# able to keep backwards compatibility with using the above
257 %# methods. Eventually these should migrate to be the methods used
258 %# primarily and lose the 'Label' in the name...
260 def AddLabelTool(self, id, label, bitmap,
261 bmpDisabled = wx.NullBitmap,
262 kind = wx.ITEM_NORMAL,
263 shortHelp = '', longHelp = '',
266 The full AddTool() function.
268 If bmpDisabled is wx.NullBitmap, a shadowed version of the normal bitmap
269 is created and used as the disabled image.
271 return self.DoAddTool(id, label, bitmap, bmpDisabled, kind,
272 shortHelp, longHelp, clientData)
275 def InsertLabelTool(self, pos, id, label, bitmap,
276 bmpDisabled = wx.NullBitmap,
277 kind = wx.ITEM_NORMAL,
278 shortHelp = '', longHelp = '',
281 Insert the new tool at the given position, if pos == GetToolsCount(), it
282 is equivalent to AddTool()
284 return self.DoInsertTool(pos, id, label, bitmap, bmpDisabled, kind,
285 shortHelp, longHelp, clientData)
287 def AddCheckLabelTool(self, id, label, bitmap,
288 bmpDisabled = wx.NullBitmap,
289 shortHelp = '', longHelp = '',
291 '''Add a check tool, i.e. a tool which can be toggled'''
292 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_CHECK,
293 shortHelp, longHelp, clientData)
295 def AddRadioLabelTool(self, id, label, bitmap,
296 bmpDisabled = wx.NullBitmap,
297 shortHelp = '', longHelp = '',
300 Add a radio tool, i.e. a tool which can be toggled and releases any
301 other toggled radio tools in the same group when it happens
303 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_RADIO,
304 shortHelp, longHelp, clientData)
307 %# For consistency with the backwards compatible methods above, here are
308 %# some non-'Label' versions of the Check and Radio methods
310 def AddCheckTool(self, id, bitmap,
311 bmpDisabled = wx.NullBitmap,
312 shortHelp = '', longHelp = '',
314 '''Add a check tool, i.e. a tool which can be toggled'''
315 return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.ITEM_CHECK,
316 shortHelp, longHelp, clientData)
318 def AddRadioTool(self, id, bitmap,
319 bmpDisabled = wx.NullBitmap,
320 shortHelp = '', longHelp = '',
323 Add a radio tool, i.e. a tool which can be toggled and releases any
324 other toggled radio tools in the same group when it happens
326 return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.ITEM_RADIO,
327 shortHelp, longHelp, clientData)
330 %Rename(AddToolItem, wxToolBarToolBase*, AddTool (wxToolBarToolBase *tool));
331 %Rename(InsertToolItem, wxToolBarToolBase*, InsertTool (size_t pos, wxToolBarToolBase *tool));
333 wxToolBarToolBase *AddControl(wxControl *control,
334 const wxString& label = wxEmptyString);
335 wxToolBarToolBase *InsertControl(size_t pos, wxControl *control,
336 const wxString& label = wxEmptyString);
337 wxControl *FindControl( int id );
339 wxToolBarToolBase *AddSeparator();
340 wxToolBarToolBase *InsertSeparator(size_t pos);
342 wxToolBarToolBase *RemoveTool(int id);
344 bool DeleteToolByPos(size_t pos);
345 bool DeleteTool(int id);
349 void EnableTool(int id, bool enable);
350 void ToggleTool(int id, bool toggle);
351 void SetToggle(int id, bool toggle);
355 // convert the ClientData back to a PyObject
356 PyObject* GetToolClientData(int id) {
357 wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
359 Py_INCREF(udata->m_obj);
367 void SetToolClientData(int id, PyObject* clientData) {
368 self->SetToolClientData(id, new wxPyUserData(clientData));
372 // returns tool pos, or wxNOT_FOUND if tool isn't found
373 int GetToolPos(int id) const;
375 bool GetToolState(int id);
376 bool GetToolEnabled(int id);
377 void SetToolShortHelp(int id, const wxString& helpString);
378 wxString GetToolShortHelp(int id);
379 void SetToolLongHelp(int id, const wxString& helpString);
380 wxString GetToolLongHelp(int id);
382 %Rename(SetMarginsXY, void, SetMargins(int x, int y));
383 void SetMargins(const wxSize& size);
384 void SetToolPacking(int packing);
385 void SetToolSeparation(int separation);
386 wxSize GetToolMargins();
388 int GetToolPacking();
389 int GetToolSeparation();
391 void SetRows(int nRows);
392 void SetMaxRowsCols(int rows, int cols);
396 void SetToolBitmapSize(const wxSize& size);
397 wxSize GetToolBitmapSize();
398 wxSize GetToolSize();
400 // returns a (non separator) tool containing the point (x, y) or NULL if
401 // there is no tool at this point (corrdinates are client)
402 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
404 // find the tool by id
405 wxToolBarToolBase *FindById(int toolid) const;
407 // return True if this is a vertical toolbar, otherwise False
410 size_t GetToolsCount() const;
413 bool SetDropdownMenu(int toolid, wxMenu *menu);
416 %property(Margins, GetMargins, SetMargins, doc="See `GetMargins` and `SetMargins`");
417 %property(MaxCols, GetMaxCols, doc="See `GetMaxCols`");
418 %property(MaxRows, GetMaxRows, doc="See `GetMaxRows`");
419 %property(ToolBitmapSize, GetToolBitmapSize, SetToolBitmapSize, doc="See `GetToolBitmapSize` and `SetToolBitmapSize`");
420 %property(ToolMargins, GetToolMargins, doc="See `GetToolMargins`");
421 %property(ToolPacking, GetToolPacking, SetToolPacking, doc="See `GetToolPacking` and `SetToolPacking`");
422 %property(ToolSeparation, GetToolSeparation, SetToolSeparation, doc="See `GetToolSeparation` and `SetToolSeparation`");
423 %property(ToolSize, GetToolSize, doc="See `GetToolSize`");
424 %property(ToolsCount, GetToolsCount, doc="See `GetToolsCount`");
430 MustHaveApp(wxToolBar);
432 class wxToolBar : public wxToolBarBase {
434 %pythonAppend wxToolBar "self._setOORInfo(self)"
435 %pythonAppend wxToolBar() ""
436 %typemap(out) wxToolBar*; // turn off this typemap
438 wxToolBar(wxWindow *parent,
440 const wxPoint& pos = wxDefaultPosition,
441 const wxSize& size = wxDefaultSize,
442 long style = wxNO_BORDER | wxTB_HORIZONTAL,
443 const wxString& name = wxPyToolBarNameStr);
444 %RenameCtor(PreToolBar, wxToolBar());
446 // Turn it back on again
447 %typemap(out) wxToolBar* { $result = wxPyMake_wxObject($1, $owner); }
449 bool Create(wxWindow *parent,
451 const wxPoint& pos = wxDefaultPosition,
452 const wxSize& size = wxDefaultSize,
453 long style = wxNO_BORDER | wxTB_HORIZONTAL,
454 const wxString& name = wxPyToolBarNameStr);
456 // TODO: In 2.9 move these to the base class...
457 void SetToolNormalBitmap(int id, const wxBitmap& bitmap);
458 void SetToolDisabledBitmap(int id, const wxBitmap& bitmap);
460 static wxVisualAttributes
461 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
464 //---------------------------------------------------------------------------
468 #include <wx/generic/buttonbar.h>
471 MustHaveApp(wxToolBar);
472 class wxButtonToolBar : public wxToolBarBase
475 %pythonAppend wxButtonToolBar "self._setOORInfo(self)"
476 %pythonAppend wxButtonToolBar() ""
478 wxButtonToolBar(wxWindow *parent,
480 const wxPoint& pos = wxDefaultPosition,
481 const wxSize& size = wxDefaultSize,
483 const wxString& name = wxPyToolBarNameStr);
484 %RenameCtor(PreButtonToolBar, wxButtonToolBar());
487 bool Create(wxWindow *parent,
489 const wxPoint& pos = wxDefaultPosition,
490 const wxSize& size = wxDefaultSize,
492 const wxString& name = wxPyToolBarNameStr);
496 //---------------------------------------------------------------------------