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,
51 // wxToolBarTool is a toolbar element.
53 // It has a unique id (except for the separators which always have id -1), the
54 // style (telling whether it is a normal button, separator or a control), the
55 // state (toggled or not, enabled or not) and short and long help strings. The
56 // default implementations use the short help string for the tooltip text which
57 // is popped up when the mouse pointer enters the tool and the long help string
58 // for the applications status bar.
59 class wxToolBarToolBase : public wxObject {
61 // wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL,
62 // int id = wxID_SEPARATOR,
63 // const wxString& label = wxPyEmptyString,
64 // const wxBitmap& bmpNormal = wxNullBitmap,
65 // const wxBitmap& bmpDisabled = wxNullBitmap,
66 // wxItemKind kind = wxITEM_NORMAL,
67 // wxObject *clientData = (wxObject *) NULL,
68 // const wxString& shortHelpString = wxPyEmptyString,
69 // const wxString& longHelpString = wxPyEmptyString)
70 // ~wxToolBarToolBase();
73 wxControl *GetControl();
74 wxToolBarBase *GetToolBar();
83 const wxBitmap& GetNormalBitmap();
84 const wxBitmap& GetDisabledBitmap();
87 wxString GetShortHelp();
88 wxString GetLongHelp();
89 bool Enable(bool enable);
91 bool SetToggle(bool toggle);
92 bool SetShortHelp(const wxString& help);
93 bool SetLongHelp(const wxString& help);
94 void SetNormalBitmap(const wxBitmap& bmp);
95 void SetDisabledBitmap(const wxBitmap& bmp);
96 void SetLabel(const wxString& label);
98 void Attach(wxToolBarBase *tbar);
100 //wxObject *GetClientData();
102 // convert the ClientData back to a PyObject
103 PyObject* GetClientData() {
104 wxPyUserData* udata = (wxPyUserData*)self->GetClientData();
106 Py_INCREF(udata->m_obj);
114 void SetClientData(PyObject* clientData) {
115 self->SetClientData(new wxPyUserData(clientData));
120 GetBitmap1 = GetNormalBitmap
121 GetBitmap2 = GetDisabledBitmap
122 SetBitmap1 = SetNormalBitmap
123 SetBitmap2 = SetDisabledBitmap
126 %property(Bitmap, GetBitmap, doc="See `GetBitmap`");
127 %property(ClientData, GetClientData, SetClientData, doc="See `GetClientData` and `SetClientData`");
128 %property(Control, GetControl, doc="See `GetControl`");
129 %property(DisabledBitmap, GetDisabledBitmap, SetDisabledBitmap, doc="See `GetDisabledBitmap` and `SetDisabledBitmap`");
130 %property(Id, GetId, doc="See `GetId`");
131 %property(Kind, GetKind, doc="See `GetKind`");
132 %property(Label, GetLabel, SetLabel, doc="See `GetLabel` and `SetLabel`");
133 %property(LongHelp, GetLongHelp, SetLongHelp, doc="See `GetLongHelp` and `SetLongHelp`");
134 %property(NormalBitmap, GetNormalBitmap, SetNormalBitmap, doc="See `GetNormalBitmap` and `SetNormalBitmap`");
135 %property(ShortHelp, GetShortHelp, SetShortHelp, doc="See `GetShortHelp` and `SetShortHelp`");
136 %property(Style, GetStyle, doc="See `GetStyle`");
137 %property(ToolBar, GetToolBar, doc="See `GetToolBar`");
143 class wxToolBarBase : public wxControl {
146 // This is an Abstract Base Class
150 // The full AddTool() function. Call it DoAddTool in wxPython and
151 // implement the other Add methods by calling it.
153 // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
154 // is created and used as the disabled image.
155 wxToolBarToolBase *DoAddTool(int id,
156 const wxString& label,
157 const wxBitmap& bitmap,
158 const wxBitmap& bmpDisabled = wxNullBitmap,
159 wxItemKind kind = wxITEM_NORMAL,
160 const wxString& shortHelp = wxPyEmptyString,
161 const wxString& longHelp = wxPyEmptyString,
162 PyObject *clientData = NULL)
164 wxPyUserData* udata = NULL;
165 if (clientData && clientData != Py_None)
166 udata = new wxPyUserData(clientData);
167 return self->AddTool(id, label, bitmap, bmpDisabled, kind,
168 shortHelp, longHelp, udata);
172 // Insert the new tool at the given position, if pos == GetToolsCount(), it
173 // is equivalent to DoAddTool()
174 wxToolBarToolBase *DoInsertTool(size_t pos,
176 const wxString& label,
177 const wxBitmap& bitmap,
178 const wxBitmap& bmpDisabled = wxNullBitmap,
179 wxItemKind kind = wxITEM_NORMAL,
180 const wxString& shortHelp = wxPyEmptyString,
181 const wxString& longHelp = wxPyEmptyString,
182 PyObject *clientData = NULL)
184 wxPyUserData* udata = NULL;
185 if (clientData && clientData != Py_None)
186 udata = new wxPyUserData(clientData);
187 return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind,
188 shortHelp, longHelp, udata);
195 %# These match the original Add methods for this class, kept for
196 %# backwards compatibility with versions < 2.3.3.
199 def AddTool(self, id, bitmap,
200 pushedBitmap = wx.NullBitmap,
203 shortHelpString = '',
204 longHelpString = '') :
205 '''Old style method to add a tool to the toolbar.'''
206 kind = wx.ITEM_NORMAL
207 if isToggle: kind = wx.ITEM_CHECK
208 return self.DoAddTool(id, '', bitmap, pushedBitmap, kind,
209 shortHelpString, longHelpString, clientData)
211 def AddSimpleTool(self, id, bitmap,
212 shortHelpString = '',
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, wx.NullBitmap, kind,
219 shortHelpString, longHelpString, None)
221 def InsertTool(self, pos, id, bitmap,
222 pushedBitmap = wx.NullBitmap,
225 shortHelpString = '',
226 longHelpString = ''):
227 '''Old style method to insert a tool in the toolbar.'''
228 kind = wx.ITEM_NORMAL
229 if isToggle: kind = wx.ITEM_CHECK
230 return self.DoInsertTool(pos, id, '', bitmap, pushedBitmap, kind,
231 shortHelpString, longHelpString, clientData)
233 def InsertSimpleTool(self, pos, id, bitmap,
234 shortHelpString = '',
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, wx.NullBitmap, kind,
241 shortHelpString, longHelpString, None)
244 %# The following are the new toolbar Add methods starting with
245 %# 2.3.3. They are renamed to have 'Label' in the name so as to be
246 %# able to keep backwards compatibility with using the above
247 %# methods. Eventually these should migrate to be the methods used
248 %# primarily and lose the 'Label' in the name...
250 def AddLabelTool(self, id, label, bitmap,
251 bmpDisabled = wx.NullBitmap,
252 kind = wx.ITEM_NORMAL,
253 shortHelp = '', longHelp = '',
256 The full AddTool() function.
258 If bmpDisabled is wx.NullBitmap, a shadowed version of the normal bitmap
259 is created and used as the disabled image.
261 return self.DoAddTool(id, label, bitmap, bmpDisabled, kind,
262 shortHelp, longHelp, clientData)
265 def InsertLabelTool(self, pos, id, label, bitmap,
266 bmpDisabled = wx.NullBitmap,
267 kind = wx.ITEM_NORMAL,
268 shortHelp = '', longHelp = '',
271 Insert the new tool at the given position, if pos == GetToolsCount(), it
272 is equivalent to AddTool()
274 return self.DoInsertTool(pos, id, label, bitmap, bmpDisabled, kind,
275 shortHelp, longHelp, clientData)
277 def AddCheckLabelTool(self, id, label, bitmap,
278 bmpDisabled = wx.NullBitmap,
279 shortHelp = '', longHelp = '',
281 '''Add a check tool, i.e. a tool which can be toggled'''
282 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_CHECK,
283 shortHelp, longHelp, clientData)
285 def AddRadioLabelTool(self, id, label, bitmap,
286 bmpDisabled = wx.NullBitmap,
287 shortHelp = '', longHelp = '',
290 Add a radio tool, i.e. a tool which can be toggled and releases any
291 other toggled radio tools in the same group when it happens
293 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_RADIO,
294 shortHelp, longHelp, clientData)
297 %# For consistency with the backwards compatible methods above, here are
298 %# some non-'Label' versions of the Check and Radio methods
300 def AddCheckTool(self, id, bitmap,
301 bmpDisabled = wx.NullBitmap,
302 shortHelp = '', longHelp = '',
304 '''Add a check tool, i.e. a tool which can be toggled'''
305 return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.ITEM_CHECK,
306 shortHelp, longHelp, clientData)
308 def AddRadioTool(self, id, bitmap,
309 bmpDisabled = wx.NullBitmap,
310 shortHelp = '', longHelp = '',
313 Add a radio tool, i.e. a tool which can be toggled and releases any
314 other toggled radio tools in the same group when it happens
316 return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.ITEM_RADIO,
317 shortHelp, longHelp, clientData)
320 %Rename(AddToolItem, wxToolBarToolBase*, AddTool (wxToolBarToolBase *tool));
321 %Rename(InsertToolItem, wxToolBarToolBase*, InsertTool (size_t pos, wxToolBarToolBase *tool));
323 wxToolBarToolBase *AddControl(wxControl *control);
324 wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
325 wxControl *FindControl( int id );
327 wxToolBarToolBase *AddSeparator();
328 wxToolBarToolBase *InsertSeparator(size_t pos);
330 wxToolBarToolBase *RemoveTool(int id);
332 bool DeleteToolByPos(size_t pos);
333 bool DeleteTool(int id);
337 void EnableTool(int id, bool enable);
338 void ToggleTool(int id, bool toggle);
339 void SetToggle(int id, bool toggle);
343 // convert the ClientData back to a PyObject
344 PyObject* GetToolClientData(int id) {
345 wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
347 Py_INCREF(udata->m_obj);
355 void SetToolClientData(int id, PyObject* clientData) {
356 self->SetToolClientData(id, new wxPyUserData(clientData));
360 // returns tool pos, or wxNOT_FOUND if tool isn't found
361 int GetToolPos(int id) const;
363 bool GetToolState(int id);
364 bool GetToolEnabled(int id);
365 void SetToolShortHelp(int id, const wxString& helpString);
366 wxString GetToolShortHelp(int id);
367 void SetToolLongHelp(int id, const wxString& helpString);
368 wxString GetToolLongHelp(int id);
370 %Rename(SetMarginsXY, void, SetMargins(int x, int y));
371 void SetMargins(const wxSize& size);
372 void SetToolPacking(int packing);
373 void SetToolSeparation(int separation);
374 wxSize GetToolMargins();
376 int GetToolPacking();
377 int GetToolSeparation();
379 void SetRows(int nRows);
380 void SetMaxRowsCols(int rows, int cols);
384 void SetToolBitmapSize(const wxSize& size);
385 wxSize GetToolBitmapSize();
386 wxSize GetToolSize();
388 // returns a (non separator) tool containing the point (x, y) or NULL if
389 // there is no tool at this point (corrdinates are client)
390 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
392 // find the tool by id
393 wxToolBarToolBase *FindById(int toolid) const;
395 // return True if this is a vertical toolbar, otherwise False
398 size_t GetToolsCount() const;
400 %property(Margins, GetMargins, SetMargins, doc="See `GetMargins` and `SetMargins`");
401 %property(MaxCols, GetMaxCols, doc="See `GetMaxCols`");
402 %property(MaxRows, GetMaxRows, doc="See `GetMaxRows`");
403 %property(ToolBitmapSize, GetToolBitmapSize, SetToolBitmapSize, doc="See `GetToolBitmapSize` and `SetToolBitmapSize`");
404 %property(ToolMargins, GetToolMargins, doc="See `GetToolMargins`");
405 %property(ToolPacking, GetToolPacking, SetToolPacking, doc="See `GetToolPacking` and `SetToolPacking`");
406 %property(ToolSeparation, GetToolSeparation, SetToolSeparation, doc="See `GetToolSeparation` and `SetToolSeparation`");
407 %property(ToolSize, GetToolSize, doc="See `GetToolSize`");
408 %property(ToolsCount, GetToolsCount, doc="See `GetToolsCount`");
414 MustHaveApp(wxToolBar);
416 class wxToolBar : public wxToolBarBase {
418 %pythonAppend wxToolBar "self._setOORInfo(self)"
419 %pythonAppend wxToolBar() ""
420 %typemap(out) wxToolBar*; // turn off this typemap
422 wxToolBar(wxWindow *parent,
424 const wxPoint& pos = wxDefaultPosition,
425 const wxSize& size = wxDefaultSize,
426 long style = wxNO_BORDER | wxTB_HORIZONTAL,
427 const wxString& name = wxPyToolBarNameStr);
428 %RenameCtor(PreToolBar, wxToolBar());
430 // Turn it back on again
431 %typemap(out) wxToolBar* { $result = wxPyMake_wxObject($1, $owner); }
433 bool Create(wxWindow *parent,
435 const wxPoint& pos = wxDefaultPosition,
436 const wxSize& size = wxDefaultSize,
437 long style = wxNO_BORDER | wxTB_HORIZONTAL,
438 const wxString& name = wxPyToolBarNameStr);
440 static wxVisualAttributes
441 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
444 //---------------------------------------------------------------------------
448 #include <wx/generic/buttonbar.h>
451 MustHaveApp(wxToolBar);
452 class wxButtonToolBar : public wxToolBarBase
455 %pythonAppend wxButtonToolBar "self._setOORInfo(self)"
456 %pythonAppend wxButtonToolBar() ""
458 wxButtonToolBar(wxWindow *parent,
460 const wxPoint& pos = wxDefaultPosition,
461 const wxSize& size = wxDefaultSize,
463 const wxString& name = wxPyToolBarNameStr);
464 %RenameCtor(PreButtonToolBar, wxButtonToolBar());
467 bool Create(wxWindow *parent,
469 const wxPoint& pos = wxDefaultPosition,
470 const wxSize& size = wxDefaultSize,
472 const wxString& name = wxPyToolBarNameStr);
476 //---------------------------------------------------------------------------