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 //wxObject *GetClientData();
107 // convert the ClientData back to a PyObject
108 PyObject* GetClientData() {
109 wxPyUserData* udata = (wxPyUserData*)self->GetClientData();
111 Py_INCREF(udata->m_obj);
119 void SetClientData(PyObject* clientData) {
120 self->SetClientData(new wxPyUserData(clientData));
125 GetBitmap1 = GetNormalBitmap
126 GetBitmap2 = GetDisabledBitmap
127 SetBitmap1 = SetNormalBitmap
128 SetBitmap2 = SetDisabledBitmap
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`");
148 class wxToolBarBase : public wxControl {
151 // This is an Abstract Base Class
155 // The full AddTool() function. Call it DoAddTool in wxPython and
156 // implement the other Add methods by calling it.
158 // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
159 // is created and used as the disabled image.
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)
169 wxPyUserData* udata = NULL;
170 if (clientData && clientData != Py_None)
171 udata = new wxPyUserData(clientData);
172 return self->AddTool(id, label, bitmap, bmpDisabled, kind,
173 shortHelp, longHelp, udata);
177 // Insert the new tool at the given position, if pos == GetToolsCount(), it
178 // is equivalent to DoAddTool()
179 wxToolBarToolBase *DoInsertTool(size_t pos,
181 const wxString& label,
182 const wxBitmap& bitmap,
183 const wxBitmap& bmpDisabled = wxNullBitmap,
184 wxItemKind kind = wxITEM_NORMAL,
185 const wxString& shortHelp = wxPyEmptyString,
186 const wxString& longHelp = wxPyEmptyString,
187 PyObject *clientData = NULL)
189 wxPyUserData* udata = NULL;
190 if (clientData && clientData != Py_None)
191 udata = new wxPyUserData(clientData);
192 return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind,
193 shortHelp, longHelp, udata);
200 %# These match the original Add methods for this class, kept for
201 %# backwards compatibility with versions < 2.3.3.
204 def AddTool(self, id, bitmap,
205 pushedBitmap = wx.NullBitmap,
208 shortHelpString = '',
209 longHelpString = '') :
210 '''Old style method to add a tool to the toolbar.'''
211 kind = wx.ITEM_NORMAL
212 if isToggle: kind = wx.ITEM_CHECK
213 return self.DoAddTool(id, '', bitmap, pushedBitmap, kind,
214 shortHelpString, longHelpString, clientData)
216 def AddSimpleTool(self, id, bitmap,
217 shortHelpString = '',
220 '''Old style method to add a tool to the toolbar.'''
221 kind = wx.ITEM_NORMAL
222 if isToggle: kind = wx.ITEM_CHECK
223 return self.DoAddTool(id, '', bitmap, wx.NullBitmap, kind,
224 shortHelpString, longHelpString, None)
226 def InsertTool(self, pos, id, bitmap,
227 pushedBitmap = wx.NullBitmap,
230 shortHelpString = '',
231 longHelpString = ''):
232 '''Old style method to insert a tool in the toolbar.'''
233 kind = wx.ITEM_NORMAL
234 if isToggle: kind = wx.ITEM_CHECK
235 return self.DoInsertTool(pos, id, '', bitmap, pushedBitmap, kind,
236 shortHelpString, longHelpString, clientData)
238 def InsertSimpleTool(self, pos, id, bitmap,
239 shortHelpString = '',
242 '''Old style method to insert a tool in the toolbar.'''
243 kind = wx.ITEM_NORMAL
244 if isToggle: kind = wx.ITEM_CHECK
245 return self.DoInsertTool(pos, id, '', bitmap, wx.NullBitmap, kind,
246 shortHelpString, longHelpString, None)
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...
255 def AddLabelTool(self, id, label, bitmap,
256 bmpDisabled = wx.NullBitmap,
257 kind = wx.ITEM_NORMAL,
258 shortHelp = '', longHelp = '',
261 The full AddTool() function.
263 If bmpDisabled is wx.NullBitmap, a shadowed version of the normal bitmap
264 is created and used as the disabled image.
266 return self.DoAddTool(id, label, bitmap, bmpDisabled, kind,
267 shortHelp, longHelp, clientData)
270 def InsertLabelTool(self, pos, id, label, bitmap,
271 bmpDisabled = wx.NullBitmap,
272 kind = wx.ITEM_NORMAL,
273 shortHelp = '', longHelp = '',
276 Insert the new tool at the given position, if pos == GetToolsCount(), it
277 is equivalent to AddTool()
279 return self.DoInsertTool(pos, id, label, bitmap, bmpDisabled, kind,
280 shortHelp, longHelp, clientData)
282 def AddCheckLabelTool(self, id, label, bitmap,
283 bmpDisabled = wx.NullBitmap,
284 shortHelp = '', longHelp = '',
286 '''Add a check tool, i.e. a tool which can be toggled'''
287 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_CHECK,
288 shortHelp, longHelp, clientData)
290 def AddRadioLabelTool(self, id, label, bitmap,
291 bmpDisabled = wx.NullBitmap,
292 shortHelp = '', longHelp = '',
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
298 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_RADIO,
299 shortHelp, longHelp, clientData)
302 %# For consistency with the backwards compatible methods above, here are
303 %# some non-'Label' versions of the Check and Radio methods
305 def AddCheckTool(self, id, bitmap,
306 bmpDisabled = wx.NullBitmap,
307 shortHelp = '', longHelp = '',
309 '''Add a check tool, i.e. a tool which can be toggled'''
310 return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.ITEM_CHECK,
311 shortHelp, longHelp, clientData)
313 def AddRadioTool(self, id, bitmap,
314 bmpDisabled = wx.NullBitmap,
315 shortHelp = '', longHelp = '',
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
321 return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.ITEM_RADIO,
322 shortHelp, longHelp, clientData)
325 %Rename(AddToolItem, wxToolBarToolBase*, AddTool (wxToolBarToolBase *tool));
326 %Rename(InsertToolItem, wxToolBarToolBase*, InsertTool (size_t pos, wxToolBarToolBase *tool));
328 wxToolBarToolBase *AddControl(wxControl *control);
329 wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
330 wxControl *FindControl( int id );
332 wxToolBarToolBase *AddSeparator();
333 wxToolBarToolBase *InsertSeparator(size_t pos);
335 wxToolBarToolBase *RemoveTool(int id);
337 bool DeleteToolByPos(size_t pos);
338 bool DeleteTool(int id);
342 void EnableTool(int id, bool enable);
343 void ToggleTool(int id, bool toggle);
344 void SetToggle(int id, bool toggle);
348 // convert the ClientData back to a PyObject
349 PyObject* GetToolClientData(int id) {
350 wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
352 Py_INCREF(udata->m_obj);
360 void SetToolClientData(int id, PyObject* clientData) {
361 self->SetToolClientData(id, new wxPyUserData(clientData));
365 // returns tool pos, or wxNOT_FOUND if tool isn't found
366 int GetToolPos(int id) const;
368 bool GetToolState(int id);
369 bool GetToolEnabled(int id);
370 void SetToolShortHelp(int id, const wxString& helpString);
371 wxString GetToolShortHelp(int id);
372 void SetToolLongHelp(int id, const wxString& helpString);
373 wxString GetToolLongHelp(int id);
375 %Rename(SetMarginsXY, void, SetMargins(int x, int y));
376 void SetMargins(const wxSize& size);
377 void SetToolPacking(int packing);
378 void SetToolSeparation(int separation);
379 wxSize GetToolMargins();
381 int GetToolPacking();
382 int GetToolSeparation();
384 void SetRows(int nRows);
385 void SetMaxRowsCols(int rows, int cols);
389 void SetToolBitmapSize(const wxSize& size);
390 wxSize GetToolBitmapSize();
391 wxSize GetToolSize();
393 // returns a (non separator) tool containing the point (x, y) or NULL if
394 // there is no tool at this point (corrdinates are client)
395 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
397 // find the tool by id
398 wxToolBarToolBase *FindById(int toolid) const;
400 // return True if this is a vertical toolbar, otherwise False
403 size_t GetToolsCount() const;
405 %property(Margins, GetMargins, SetMargins, doc="See `GetMargins` and `SetMargins`");
406 %property(MaxCols, GetMaxCols, doc="See `GetMaxCols`");
407 %property(MaxRows, GetMaxRows, doc="See `GetMaxRows`");
408 %property(ToolBitmapSize, GetToolBitmapSize, SetToolBitmapSize, doc="See `GetToolBitmapSize` and `SetToolBitmapSize`");
409 %property(ToolMargins, GetToolMargins, doc="See `GetToolMargins`");
410 %property(ToolPacking, GetToolPacking, SetToolPacking, doc="See `GetToolPacking` and `SetToolPacking`");
411 %property(ToolSeparation, GetToolSeparation, SetToolSeparation, doc="See `GetToolSeparation` and `SetToolSeparation`");
412 %property(ToolSize, GetToolSize, doc="See `GetToolSize`");
413 %property(ToolsCount, GetToolsCount, doc="See `GetToolsCount`");
419 MustHaveApp(wxToolBar);
421 class wxToolBar : public wxToolBarBase {
423 %pythonAppend wxToolBar "self._setOORInfo(self)"
424 %pythonAppend wxToolBar() ""
425 %typemap(out) wxToolBar*; // turn off this typemap
427 wxToolBar(wxWindow *parent,
429 const wxPoint& pos = wxDefaultPosition,
430 const wxSize& size = wxDefaultSize,
431 long style = wxNO_BORDER | wxTB_HORIZONTAL,
432 const wxString& name = wxPyToolBarNameStr);
433 %RenameCtor(PreToolBar, wxToolBar());
435 // Turn it back on again
436 %typemap(out) wxToolBar* { $result = wxPyMake_wxObject($1, $owner); }
438 bool Create(wxWindow *parent,
440 const wxPoint& pos = wxDefaultPosition,
441 const wxSize& size = wxDefaultSize,
442 long style = wxNO_BORDER | wxTB_HORIZONTAL,
443 const wxString& name = wxPyToolBarNameStr);
445 static wxVisualAttributes
446 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
449 //---------------------------------------------------------------------------
453 #include <wx/generic/buttonbar.h>
456 MustHaveApp(wxToolBar);
457 class wxButtonToolBar : public wxToolBarBase
460 %pythonAppend wxButtonToolBar "self._setOORInfo(self)"
461 %pythonAppend wxButtonToolBar() ""
463 wxButtonToolBar(wxWindow *parent,
465 const wxPoint& pos = wxDefaultPosition,
466 const wxSize& size = wxDefaultSize,
468 const wxString& name = wxPyToolBarNameStr);
469 %RenameCtor(PreButtonToolBar, wxButtonToolBar());
472 bool Create(wxWindow *parent,
474 const wxPoint& pos = wxDefaultPosition,
475 const wxSize& size = wxDefaultSize,
477 const wxString& name = wxPyToolBarNameStr);
481 //---------------------------------------------------------------------------