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,
52 // wxToolBarTool is a toolbar element.
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.
60 class wxToolBarToolBase : public wxObject {
62 // wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL,
63 // int id = wxID_SEPARATOR,
64 // const wxString& label = wxPyEmptyString,
65 // const wxBitmap& bmpNormal = wxNullBitmap,
66 // const wxBitmap& bmpDisabled = wxNullBitmap,
67 // wxItemKind kind = wxITEM_NORMAL,
68 // wxObject *clientData = (wxObject *) NULL,
69 // const wxString& shortHelpString = wxPyEmptyString,
70 // const wxString& longHelpString = wxPyEmptyString)
71 // ~wxToolBarToolBase();
74 wxControl *GetControl();
75 wxToolBarBase *GetToolBar();
84 const wxBitmap& GetNormalBitmap();
85 const wxBitmap& GetDisabledBitmap();
88 wxString GetShortHelp();
89 wxString GetLongHelp();
90 bool Enable(bool enable);
92 bool SetToggle(bool toggle);
93 bool SetShortHelp(const wxString& help);
94 bool SetLongHelp(const wxString& help);
95 void SetNormalBitmap(const wxBitmap& bmp);
96 void SetDisabledBitmap(const wxBitmap& bmp);
97 void SetLabel(const wxString& label);
99 void Attach(wxToolBarBase *tbar);
101 //wxObject *GetClientData();
103 // convert the ClientData back to a PyObject
104 PyObject* GetClientData() {
105 wxPyUserData* udata = (wxPyUserData*)self->GetClientData();
107 Py_INCREF(udata->m_obj);
115 void SetClientData(PyObject* clientData) {
116 self->SetClientData(new wxPyUserData(clientData));
121 GetBitmap1 = GetNormalBitmap
122 GetBitmap2 = GetDisabledBitmap
123 SetBitmap1 = SetNormalBitmap
124 SetBitmap2 = SetDisabledBitmap
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`");
144 class wxToolBarBase : public wxControl {
147 // This is an Abstract Base Class
151 // The full AddTool() function. Call it DoAddTool in wxPython and
152 // implement the other Add methods by calling it.
154 // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
155 // is created and used as the disabled image.
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)
165 wxPyUserData* udata = NULL;
166 if (clientData && clientData != Py_None)
167 udata = new wxPyUserData(clientData);
168 return self->AddTool(id, label, bitmap, bmpDisabled, kind,
169 shortHelp, longHelp, udata);
173 // Insert the new tool at the given position, if pos == GetToolsCount(), it
174 // is equivalent to DoAddTool()
175 wxToolBarToolBase *DoInsertTool(size_t pos,
177 const wxString& label,
178 const wxBitmap& bitmap,
179 const wxBitmap& bmpDisabled = wxNullBitmap,
180 wxItemKind kind = wxITEM_NORMAL,
181 const wxString& shortHelp = wxPyEmptyString,
182 const wxString& longHelp = wxPyEmptyString,
183 PyObject *clientData = NULL)
185 wxPyUserData* udata = NULL;
186 if (clientData && clientData != Py_None)
187 udata = new wxPyUserData(clientData);
188 return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind,
189 shortHelp, longHelp, udata);
196 %# These match the original Add methods for this class, kept for
197 %# backwards compatibility with versions < 2.3.3.
200 def AddTool(self, id, bitmap,
201 pushedBitmap = wx.NullBitmap,
204 shortHelpString = '',
205 longHelpString = '') :
206 '''Old style method to add a tool to the toolbar.'''
207 kind = wx.ITEM_NORMAL
208 if isToggle: kind = wx.ITEM_CHECK
209 return self.DoAddTool(id, '', bitmap, pushedBitmap, kind,
210 shortHelpString, longHelpString, clientData)
212 def AddSimpleTool(self, id, bitmap,
213 shortHelpString = '',
216 '''Old style method to add a tool to the toolbar.'''
217 kind = wx.ITEM_NORMAL
218 if isToggle: kind = wx.ITEM_CHECK
219 return self.DoAddTool(id, '', bitmap, wx.NullBitmap, kind,
220 shortHelpString, longHelpString, None)
222 def InsertTool(self, pos, id, bitmap,
223 pushedBitmap = wx.NullBitmap,
226 shortHelpString = '',
227 longHelpString = ''):
228 '''Old style method to insert a tool in the toolbar.'''
229 kind = wx.ITEM_NORMAL
230 if isToggle: kind = wx.ITEM_CHECK
231 return self.DoInsertTool(pos, id, '', bitmap, pushedBitmap, kind,
232 shortHelpString, longHelpString, clientData)
234 def InsertSimpleTool(self, pos, id, bitmap,
235 shortHelpString = '',
238 '''Old style method to insert a tool in the toolbar.'''
239 kind = wx.ITEM_NORMAL
240 if isToggle: kind = wx.ITEM_CHECK
241 return self.DoInsertTool(pos, id, '', bitmap, wx.NullBitmap, kind,
242 shortHelpString, longHelpString, None)
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...
251 def AddLabelTool(self, id, label, bitmap,
252 bmpDisabled = wx.NullBitmap,
253 kind = wx.ITEM_NORMAL,
254 shortHelp = '', longHelp = '',
257 The full AddTool() function.
259 If bmpDisabled is wx.NullBitmap, a shadowed version of the normal bitmap
260 is created and used as the disabled image.
262 return self.DoAddTool(id, label, bitmap, bmpDisabled, kind,
263 shortHelp, longHelp, clientData)
266 def InsertLabelTool(self, pos, id, label, bitmap,
267 bmpDisabled = wx.NullBitmap,
268 kind = wx.ITEM_NORMAL,
269 shortHelp = '', longHelp = '',
272 Insert the new tool at the given position, if pos == GetToolsCount(), it
273 is equivalent to AddTool()
275 return self.DoInsertTool(pos, id, label, bitmap, bmpDisabled, kind,
276 shortHelp, longHelp, clientData)
278 def AddCheckLabelTool(self, id, label, bitmap,
279 bmpDisabled = wx.NullBitmap,
280 shortHelp = '', longHelp = '',
282 '''Add a check tool, i.e. a tool which can be toggled'''
283 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_CHECK,
284 shortHelp, longHelp, clientData)
286 def AddRadioLabelTool(self, id, label, bitmap,
287 bmpDisabled = wx.NullBitmap,
288 shortHelp = '', longHelp = '',
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
294 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_RADIO,
295 shortHelp, longHelp, clientData)
298 %# For consistency with the backwards compatible methods above, here are
299 %# some non-'Label' versions of the Check and Radio methods
301 def AddCheckTool(self, id, bitmap,
302 bmpDisabled = wx.NullBitmap,
303 shortHelp = '', longHelp = '',
305 '''Add a check tool, i.e. a tool which can be toggled'''
306 return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.ITEM_CHECK,
307 shortHelp, longHelp, clientData)
309 def AddRadioTool(self, id, bitmap,
310 bmpDisabled = wx.NullBitmap,
311 shortHelp = '', longHelp = '',
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
317 return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.ITEM_RADIO,
318 shortHelp, longHelp, clientData)
321 %Rename(AddToolItem, wxToolBarToolBase*, AddTool (wxToolBarToolBase *tool));
322 %Rename(InsertToolItem, wxToolBarToolBase*, InsertTool (size_t pos, wxToolBarToolBase *tool));
324 wxToolBarToolBase *AddControl(wxControl *control);
325 wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
326 wxControl *FindControl( int id );
328 wxToolBarToolBase *AddSeparator();
329 wxToolBarToolBase *InsertSeparator(size_t pos);
331 wxToolBarToolBase *RemoveTool(int id);
333 bool DeleteToolByPos(size_t pos);
334 bool DeleteTool(int id);
338 void EnableTool(int id, bool enable);
339 void ToggleTool(int id, bool toggle);
340 void SetToggle(int id, bool toggle);
344 // convert the ClientData back to a PyObject
345 PyObject* GetToolClientData(int id) {
346 wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
348 Py_INCREF(udata->m_obj);
356 void SetToolClientData(int id, PyObject* clientData) {
357 self->SetToolClientData(id, new wxPyUserData(clientData));
361 // returns tool pos, or wxNOT_FOUND if tool isn't found
362 int GetToolPos(int id) const;
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);
371 %Rename(SetMarginsXY, void, SetMargins(int x, int y));
372 void SetMargins(const wxSize& size);
373 void SetToolPacking(int packing);
374 void SetToolSeparation(int separation);
375 wxSize GetToolMargins();
377 int GetToolPacking();
378 int GetToolSeparation();
380 void SetRows(int nRows);
381 void SetMaxRowsCols(int rows, int cols);
385 void SetToolBitmapSize(const wxSize& size);
386 wxSize GetToolBitmapSize();
387 wxSize GetToolSize();
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);
393 // find the tool by id
394 wxToolBarToolBase *FindById(int toolid) const;
396 // return True if this is a vertical toolbar, otherwise False
399 size_t GetToolsCount() const;
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`");
415 MustHaveApp(wxToolBar);
417 class wxToolBar : public wxToolBarBase {
419 %pythonAppend wxToolBar "self._setOORInfo(self)"
420 %pythonAppend wxToolBar() ""
421 %typemap(out) wxToolBar*; // turn off this typemap
423 wxToolBar(wxWindow *parent,
425 const wxPoint& pos = wxDefaultPosition,
426 const wxSize& size = wxDefaultSize,
427 long style = wxNO_BORDER | wxTB_HORIZONTAL,
428 const wxString& name = wxPyToolBarNameStr);
429 %RenameCtor(PreToolBar, wxToolBar());
431 // Turn it back on again
432 %typemap(out) wxToolBar* { $result = wxPyMake_wxObject($1, $owner); }
434 bool Create(wxWindow *parent,
436 const wxPoint& pos = wxDefaultPosition,
437 const wxSize& size = wxDefaultSize,
438 long style = wxNO_BORDER | wxTB_HORIZONTAL,
439 const wxString& name = wxPyToolBarNameStr);
441 static wxVisualAttributes
442 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
445 //---------------------------------------------------------------------------
449 #include <wx/generic/buttonbar.h>
452 MustHaveApp(wxToolBar);
453 class wxButtonToolBar : public wxToolBarBase
456 %pythonAppend wxButtonToolBar "self._setOORInfo(self)"
457 %pythonAppend wxButtonToolBar() ""
459 wxButtonToolBar(wxWindow *parent,
461 const wxPoint& pos = wxDefaultPosition,
462 const wxSize& size = wxDefaultSize,
464 const wxString& name = wxPyToolBarNameStr);
465 %RenameCtor(PreButtonToolBar, wxButtonToolBar());
468 bool Create(wxWindow *parent,
470 const wxPoint& pos = wxDefaultPosition,
471 const wxSize& size = wxDefaultSize,
473 const wxString& name = wxPyToolBarNameStr);
477 //---------------------------------------------------------------------------