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
130 class wxToolBarBase : public wxControl {
133 // This is an Abstract Base Class
137 // The full AddTool() function. Call it DoAddTool in wxPython and
138 // implement the other Add methods by calling it.
140 // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
141 // is created and used as the disabled image.
142 wxToolBarToolBase *DoAddTool(int id,
143 const wxString& label,
144 const wxBitmap& bitmap,
145 const wxBitmap& bmpDisabled = wxNullBitmap,
146 wxItemKind kind = wxITEM_NORMAL,
147 const wxString& shortHelp = wxPyEmptyString,
148 const wxString& longHelp = wxPyEmptyString,
149 PyObject *clientData = NULL)
151 wxPyUserData* udata = NULL;
152 if (clientData && clientData != Py_None)
153 udata = new wxPyUserData(clientData);
154 return self->AddTool(id, label, bitmap, bmpDisabled, kind,
155 shortHelp, longHelp, udata);
159 // Insert the new tool at the given position, if pos == GetToolsCount(), it
160 // is equivalent to DoAddTool()
161 wxToolBarToolBase *DoInsertTool(size_t pos,
163 const wxString& label,
164 const wxBitmap& bitmap,
165 const wxBitmap& bmpDisabled = wxNullBitmap,
166 wxItemKind kind = wxITEM_NORMAL,
167 const wxString& shortHelp = wxPyEmptyString,
168 const wxString& longHelp = wxPyEmptyString,
169 PyObject *clientData = NULL)
171 wxPyUserData* udata = NULL;
172 if (clientData && clientData != Py_None)
173 udata = new wxPyUserData(clientData);
174 return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind,
175 shortHelp, longHelp, udata);
182 %# These match the original Add methods for this class, kept for
183 %# backwards compatibility with versions < 2.3.3.
186 def AddTool(self, id, bitmap,
187 pushedBitmap = wx.NullBitmap,
190 shortHelpString = '',
191 longHelpString = '') :
192 '''Old style method to add a tool to the toolbar.'''
193 kind = wx.ITEM_NORMAL
194 if isToggle: kind = wx.ITEM_CHECK
195 return self.DoAddTool(id, '', bitmap, pushedBitmap, kind,
196 shortHelpString, longHelpString, clientData)
198 def AddSimpleTool(self, id, bitmap,
199 shortHelpString = '',
202 '''Old style method to add a tool to the toolbar.'''
203 kind = wx.ITEM_NORMAL
204 if isToggle: kind = wx.ITEM_CHECK
205 return self.DoAddTool(id, '', bitmap, wx.NullBitmap, kind,
206 shortHelpString, longHelpString, None)
208 def InsertTool(self, pos, id, bitmap,
209 pushedBitmap = wx.NullBitmap,
212 shortHelpString = '',
213 longHelpString = ''):
214 '''Old style method to insert a tool in the toolbar.'''
215 kind = wx.ITEM_NORMAL
216 if isToggle: kind = wx.ITEM_CHECK
217 return self.DoInsertTool(pos, id, '', bitmap, pushedBitmap, kind,
218 shortHelpString, longHelpString, clientData)
220 def InsertSimpleTool(self, pos, id, bitmap,
221 shortHelpString = '',
224 '''Old style method to insert a tool in the toolbar.'''
225 kind = wx.ITEM_NORMAL
226 if isToggle: kind = wx.ITEM_CHECK
227 return self.DoInsertTool(pos, id, '', bitmap, wx.NullBitmap, kind,
228 shortHelpString, longHelpString, None)
231 %# The following are the new toolbar Add methods starting with
232 %# 2.3.3. They are renamed to have 'Label' in the name so as to be
233 %# able to keep backwards compatibility with using the above
234 %# methods. Eventually these should migrate to be the methods used
235 %# primarily and lose the 'Label' in the name...
237 def AddLabelTool(self, id, label, bitmap,
238 bmpDisabled = wx.NullBitmap,
239 kind = wx.ITEM_NORMAL,
240 shortHelp = '', longHelp = '',
243 The full AddTool() function.
245 If bmpDisabled is wx.NullBitmap, a shadowed version of the normal bitmap
246 is created and used as the disabled image.
248 return self.DoAddTool(id, label, bitmap, bmpDisabled, kind,
249 shortHelp, longHelp, clientData)
252 def InsertLabelTool(self, pos, id, label, bitmap,
253 bmpDisabled = wx.NullBitmap,
254 kind = wx.ITEM_NORMAL,
255 shortHelp = '', longHelp = '',
258 Insert the new tool at the given position, if pos == GetToolsCount(), it
259 is equivalent to AddTool()
261 return self.DoInsertTool(pos, id, label, bitmap, bmpDisabled, kind,
262 shortHelp, longHelp, clientData)
264 def AddCheckLabelTool(self, id, label, bitmap,
265 bmpDisabled = wx.NullBitmap,
266 shortHelp = '', longHelp = '',
268 '''Add a check tool, i.e. a tool which can be toggled'''
269 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_CHECK,
270 shortHelp, longHelp, clientData)
272 def AddRadioLabelTool(self, id, label, bitmap,
273 bmpDisabled = wx.NullBitmap,
274 shortHelp = '', longHelp = '',
277 Add a radio tool, i.e. a tool which can be toggled and releases any
278 other toggled radio tools in the same group when it happens
280 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_RADIO,
281 shortHelp, longHelp, clientData)
284 %# For consistency with the backwards compatible methods above, here are
285 %# some non-'Label' versions of the Check and Radio methods
287 def AddCheckTool(self, id, 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, '', bitmap, bmpDisabled, wx.ITEM_CHECK,
293 shortHelp, longHelp, clientData)
295 def AddRadioTool(self, id, 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, '', bitmap, bmpDisabled, wx.ITEM_RADIO,
304 shortHelp, longHelp, clientData)
307 %Rename(AddToolItem, wxToolBarToolBase*, AddTool (wxToolBarToolBase *tool));
308 %Rename(InsertToolItem, wxToolBarToolBase*, InsertTool (size_t pos, wxToolBarToolBase *tool));
310 wxToolBarToolBase *AddControl(wxControl *control);
311 wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
312 wxControl *FindControl( int id );
314 wxToolBarToolBase *AddSeparator();
315 wxToolBarToolBase *InsertSeparator(size_t pos);
317 wxToolBarToolBase *RemoveTool(int id);
319 bool DeleteToolByPos(size_t pos);
320 bool DeleteTool(int id);
324 void EnableTool(int id, bool enable);
325 void ToggleTool(int id, bool toggle);
326 void SetToggle(int id, bool toggle);
330 // convert the ClientData back to a PyObject
331 PyObject* GetToolClientData(int id) {
332 wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
334 Py_INCREF(udata->m_obj);
342 void SetToolClientData(int id, PyObject* clientData) {
343 self->SetToolClientData(id, new wxPyUserData(clientData));
347 // returns tool pos, or wxNOT_FOUND if tool isn't found
348 int GetToolPos(int id) const;
350 bool GetToolState(int id);
351 bool GetToolEnabled(int id);
352 void SetToolShortHelp(int id, const wxString& helpString);
353 wxString GetToolShortHelp(int id);
354 void SetToolLongHelp(int id, const wxString& helpString);
355 wxString GetToolLongHelp(int id);
357 %Rename(SetMarginsXY, void, SetMargins(int x, int y));
358 void SetMargins(const wxSize& size);
359 void SetToolPacking(int packing);
360 void SetToolSeparation(int separation);
361 wxSize GetToolMargins();
363 int GetToolPacking();
364 int GetToolSeparation();
366 void SetRows(int nRows);
367 void SetMaxRowsCols(int rows, int cols);
371 void SetToolBitmapSize(const wxSize& size);
372 wxSize GetToolBitmapSize();
373 wxSize GetToolSize();
375 // returns a (non separator) tool containing the point (x, y) or NULL if
376 // there is no tool at this point (corrdinates are client)
377 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
379 // find the tool by id
380 wxToolBarToolBase *FindById(int toolid) const;
382 // return True if this is a vertical toolbar, otherwise False
385 size_t GetToolsCount() const;
391 MustHaveApp(wxToolBar);
393 class wxToolBar : public wxToolBarBase {
395 %pythonAppend wxToolBar "self._setOORInfo(self)"
396 %pythonAppend wxToolBar() ""
397 %typemap(out) wxToolBar*; // turn off this typemap
399 wxToolBar(wxWindow *parent,
401 const wxPoint& pos = wxDefaultPosition,
402 const wxSize& size = wxDefaultSize,
403 long style = wxNO_BORDER | wxTB_HORIZONTAL,
404 const wxString& name = wxPyToolBarNameStr);
405 %RenameCtor(PreToolBar, wxToolBar());
407 // Turn it back on again
408 %typemap(out) wxToolBar* { $result = wxPyMake_wxObject($1, $owner); }
410 bool Create(wxWindow *parent,
412 const wxPoint& pos = wxDefaultPosition,
413 const wxSize& size = wxDefaultSize,
414 long style = wxNO_BORDER | wxTB_HORIZONTAL,
415 const wxString& name = wxPyToolBarNameStr);
417 static wxVisualAttributes
418 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
421 //---------------------------------------------------------------------------
425 #include <wx/generic/buttonbar.h>
428 MustHaveApp(wxToolBar);
429 class wxButtonToolBar : public wxToolBarBase
432 %pythonAppend wxButtonToolBar "self._setOORInfo(self)"
433 %pythonAppend wxButtonToolBar() ""
435 wxButtonToolBar(wxWindow *parent,
437 const wxPoint& pos = wxDefaultPosition,
438 const wxSize& size = wxDefaultSize,
440 const wxString& name = wxPyToolBarNameStr);
441 %RenameCtor(PreButtonToolBar, wxButtonToolBar());
444 bool Create(wxWindow *parent,
446 const wxPoint& pos = wxDefaultPosition,
447 const wxSize& size = wxDefaultSize,
449 const wxString& name = wxPyToolBarNameStr);
453 //---------------------------------------------------------------------------