1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG definitions for StatusBar and ToolBar classes
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
18 #include <wx/toolbar.h>
19 #include <wx/tbarsmpl.h>
22 //----------------------------------------------------------------------
25 %include my_typemaps.i
27 // Import some definitions of other classes, etc.
33 %pragma(python) code = "import wx"
34 %pragma(python) code = "wxITEM_NORMAL = 0 # predeclare this since wx isn't fully imported yet"
36 //----------------------------------------------------------------------
39 // Put some wx default wxChar* values into wxStrings.
40 DECLARE_DEF_STRING(StatusLineNameStr);
41 DECLARE_DEF_STRING(ToolBarNameStr);
42 static const wxString wxPyEmptyString(wxT(""));
45 //---------------------------------------------------------------------------
47 class wxStatusBar : public wxWindow {
49 wxStatusBar(wxWindow* parent, wxWindowID id = -1,
50 long style = wxST_SIZEGRIP,
51 const wxString& name = wxPyStatusLineNameStr);
52 %name(wxPreStatusBar)wxStatusBar();
54 bool Create(wxWindow* parent, wxWindowID id,
55 long style = wxST_SIZEGRIP,
56 const wxString& name = wxPyStatusLineNameStr);
58 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
59 %pragma(python) addtomethod = "wxPreStatusBar:val._setOORInfo(val)"
62 %new wxRect* GetFieldRect(long item) {
63 wxRect* rect= new wxRect;
64 self->GetFieldRect(item, *rect);
68 int GetFieldsCount(void);
69 wxString GetStatusText(int ir = 0);
73 void SetFieldsCount(int number = 1);
74 void SetStatusText(const wxString& text, int i = 0);
75 void SetStatusWidths(int LCOUNT, int* choices);
76 void PushStatusText(const wxString& text, int number = 0);
77 void PopStatusText(int number = 0);
79 void SetMinHeight(int height);
83 //---------------------------------------------------------------------------
87 enum wxToolBarToolStyle
89 wxTOOL_STYLE_BUTTON = 1,
90 wxTOOL_STYLE_SEPARATOR = 2,
110 class wxToolBarToolBase : public wxObject {
112 // wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL,
113 // int id = wxID_SEPARATOR,
114 // const wxString& label = wxEmptyString,
115 // const wxBitmap& bmpNormal = wxNullBitmap,
116 // const wxBitmap& bmpDisabled = wxNullBitmap,
117 // wxItemKind kind = wxITEM_NORMAL,
118 // wxObject *clientData = (wxObject *) NULL,
119 // const wxString& shortHelpString = wxEmptyString,
120 // const wxString& longHelpString = wxEmptyString)
121 // ~wxToolBarToolBase();
123 %addmethods { void Destroy() { delete self; } }
126 wxControl *GetControl();
127 wxToolBarBase *GetToolBar();
132 wxItemKind GetKind();
136 const wxBitmap& GetNormalBitmap();
137 const wxBitmap& GetDisabledBitmap();
138 wxBitmap GetBitmap();
140 wxString GetShortHelp();
141 wxString GetLongHelp();
142 bool Enable(bool enable);
144 bool SetToggle(bool toggle);
145 bool SetShortHelp(const wxString& help);
146 bool SetLongHelp(const wxString& help);
147 void SetNormalBitmap(const wxBitmap& bmp);
148 void SetDisabledBitmap(const wxBitmap& bmp);
149 void SetLabel(const wxString& label);
151 void Attach(wxToolBarBase *tbar);
153 //wxObject *GetClientData();
155 // convert the ClientData back to a PyObject
156 PyObject* GetClientData() {
157 wxPyUserData* udata = (wxPyUserData*)self->GetClientData();
159 Py_INCREF(udata->m_obj);
167 void SetClientData(PyObject* clientData) {
168 self->SetClientData(new wxPyUserData(clientData));
172 %pragma(python) addtoclass="
173 GetBitmap1 = GetNormalBitmap
174 GetBitmap2 = GetDisabledBitmap
175 SetBitmap1 = SetNormalBitmap
176 SetBitmap2 = SetDisabledBitmap
182 class wxToolBarBase : public wxControl {
185 // This is an Abstract Base Class
189 // The full AddTool() function. Call it DoAddTool in wxPython and
190 // implement the other Add methods by calling it.
192 // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
193 // is created and used as the disabled image.
194 wxToolBarToolBase *DoAddTool(int id,
195 const wxString& label,
196 const wxBitmap& bitmap,
197 const wxBitmap& bmpDisabled = wxNullBitmap,
198 wxItemKind kind = wxITEM_NORMAL,
199 const wxString& shortHelp = wxPyEmptyString,
200 const wxString& longHelp = wxPyEmptyString,
201 PyObject *clientData = NULL)
203 wxPyUserData* udata = NULL;
204 if (clientData && clientData != Py_None)
205 udata = new wxPyUserData(clientData);
206 return self->AddTool(id, label, bitmap, bmpDisabled, kind,
207 shortHelp, longHelp, udata);
211 // Insert the new tool at the given position, if pos == GetToolsCount(), it
212 // is equivalent to DoAddTool()
213 wxToolBarToolBase *DoInsertTool(size_t pos,
215 const wxString& label,
216 const wxBitmap& bitmap,
217 const wxBitmap& bmpDisabled = wxNullBitmap,
218 wxItemKind kind = wxITEM_NORMAL,
219 const wxString& shortHelp = wxPyEmptyString,
220 const wxString& longHelp = wxPyEmptyString,
221 PyObject *clientData = NULL)
223 wxPyUserData* udata = NULL;
224 if (clientData && clientData != Py_None)
225 udata = new wxPyUserData(clientData);
226 return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind,
227 shortHelp, longHelp, udata);
233 %pragma(python) addtoclass = "
234 # These match the original Add methods for this class, kept for
235 # backwards compatibility with versions < 2.3.3.
238 def AddTool(self, id, bitmap,
239 pushedBitmap = wxNullBitmap,
242 shortHelpString = '',
243 longHelpString = '') :
244 '''Old style method to add a tool to the toolbar.'''
245 kind = wx.wxITEM_NORMAL
246 if isToggle: kind = wx.wxITEM_CHECK
247 return self.DoAddTool(id, '', bitmap, pushedBitmap, kind,
248 shortHelpString, longHelpString, clientData)
250 def AddSimpleTool(self, id, bitmap,
251 shortHelpString = '',
254 '''Old style method to add a tool to the toolbar.'''
255 kind = wx.wxITEM_NORMAL
256 if isToggle: kind = wx.wxITEM_CHECK
257 return self.DoAddTool(id, '', bitmap, wxNullBitmap, kind,
258 shortHelpString, longHelpString, None)
260 def InsertTool(self, pos, id, bitmap,
261 pushedBitmap = wxNullBitmap,
264 shortHelpString = '',
265 longHelpString = ''):
266 '''Old style method to insert a tool in the toolbar.'''
267 kind = wx.wxITEM_NORMAL
268 if isToggle: kind = wx.wxITEM_CHECK
269 return self.DoInsertTool(pos, id, '', bitmap, pushedBitmap, kind,
270 shortHelpString, longHelpString, clientData)
272 def InsertSimpleTool(self, pos, id, bitmap,
273 shortHelpString = '',
276 '''Old style method to insert a tool in the toolbar.'''
277 kind = wx.wxITEM_NORMAL
278 if isToggle: kind = wx.wxITEM_CHECK
279 return self.DoInsertTool(pos, id, '', bitmap, wxNullBitmap, kind,
280 shortHelpString, longHelpString, None)
283 # The following are the new toolbar Add methods starting with
284 # 2.3.3. They are renamed to have 'Label' in the name so as to be
285 # able to keep backwards compatibility with using the above
286 # methods. Eventually these should migrate to be the methods used
287 # primarily and lose the 'Label' in the name...
289 def AddLabelTool(self, id, label, bitmap,
290 bmpDisabled = wxNullBitmap,
291 kind = wxITEM_NORMAL,
292 shortHelp = '', longHelp = '',
295 The full AddTool() function.
297 If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
298 is created and used as the disabled image.
300 return self.DoAddTool(id, label, bitmap, bmpDisabled, kind,
301 shortHelp, longHelp, clientData)
304 def InsertLabelTool(self, pos, id, label, bitmap,
305 bmpDisabled = wxNullBitmap,
306 kind = wxITEM_NORMAL,
307 shortHelp = '', longHelp = '',
310 Insert the new tool at the given position, if pos == GetToolsCount(), it
311 is equivalent to AddTool()
313 return self.DoInsertTool(pos, id, label, bitmap, bmpDisabled, kind,
314 shortHelp, longHelp, clientData)
316 def AddCheckLabelTool(self, id, label, bitmap,
317 bmpDisabled = wxNullBitmap,
318 shortHelp = '', longHelp = '',
320 '''Add a check tool, i.e. a tool which can be toggled'''
321 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.wxITEM_CHECK,
322 shortHelp, longHelp, clientData)
324 def AddRadioLabelTool(self, id, label, bitmap,
325 bmpDisabled = wxNullBitmap,
326 shortHelp = '', longHelp = '',
329 Add a radio tool, i.e. a tool which can be toggled and releases any
330 other toggled radio tools in the same group when it happens
332 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.wxITEM_RADIO,
333 shortHelp, longHelp, clientData)
336 # For consistency with the backwards compatible methods above, here are
337 # some non-'Label' versions of the Check and Radio methods
338 def AddCheckTool(self, id, bitmap,
339 bmpDisabled = wxNullBitmap,
340 shortHelp = '', longHelp = '',
342 '''Add a check tool, i.e. a tool which can be toggled'''
343 return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.wxITEM_CHECK,
344 shortHelp, longHelp, clientData)
346 def AddRadioTool(self, id, bitmap,
347 bmpDisabled = wxNullBitmap,
348 shortHelp = '', longHelp = '',
351 Add a radio tool, i.e. a tool which can be toggled and releases any
352 other toggled radio tools in the same group when it happens
354 return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.wxITEM_RADIO,
355 shortHelp, longHelp, clientData)
359 //wxToolBarToolBase *AddTool (wxToolBarToolBase *tool);
360 //wxToolBarToolBase *InsertTool (size_t pos, wxToolBarToolBase *tool);
362 wxToolBarToolBase *AddControl(wxControl *control);
363 wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
364 wxControl *FindControl( int id );
366 wxToolBarToolBase *AddSeparator();
367 wxToolBarToolBase *InsertSeparator(size_t pos);
369 wxToolBarToolBase *RemoveTool(int id);
371 bool DeleteToolByPos(size_t pos);
372 bool DeleteTool(int id);
376 void EnableTool(int id, bool enable);
377 void ToggleTool(int id, bool toggle);
378 void SetToggle(int id, bool toggle);
382 // convert the ClientData back to a PyObject
383 PyObject* GetToolClientData(int id) {
384 wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
386 Py_INCREF(udata->m_obj);
394 void SetToolClientData(int id, PyObject* clientData) {
395 self->SetToolClientData(id, new wxPyUserData(clientData));
399 // returns tool pos, or wxNOT_FOUND if tool isn't found
400 int GetToolPos(int id) const;
402 bool GetToolState(int id);
403 bool GetToolEnabled(int id);
404 void SetToolShortHelp(int id, const wxString& helpString);
405 wxString GetToolShortHelp(int id);
406 void SetToolLongHelp(int id, const wxString& helpString);
407 wxString GetToolLongHelp(int id);
409 %name(SetMarginsXY) void SetMargins(int x, int y);
410 void SetMargins(const wxSize& size);
411 void SetToolPacking(int packing);
412 void SetToolSeparation(int separation);
413 wxSize GetToolMargins();
415 int GetToolPacking();
416 int GetToolSeparation();
418 void SetRows(int nRows);
419 void SetMaxRowsCols(int rows, int cols);
423 void SetToolBitmapSize(const wxSize& size);
424 wxSize GetToolBitmapSize();
425 wxSize GetToolSize();
427 // returns a (non separator) tool containing the point (x, y) or NULL if
428 // there is no tool at this point (corrdinates are client)
429 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
431 // return TRUE if this is a vertical toolbar, otherwise FALSE
438 class wxToolBar : public wxToolBarBase {
440 wxToolBar(wxWindow *parent,
442 const wxPoint& pos = wxDefaultPosition,
443 const wxSize& size = wxDefaultSize,
444 long style = wxNO_BORDER | wxTB_HORIZONTAL,
445 const wxString& name = wxPyToolBarNameStr);
446 %name(wxPreToolBar)wxToolBar();
448 bool Create(wxWindow *parent,
450 const wxPoint& pos = wxDefaultPosition,
451 const wxSize& size = wxDefaultSize,
452 long style = wxNO_BORDER | wxTB_HORIZONTAL,
453 const wxString& name = wxPyToolBarNameStr);
455 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
456 %pragma(python) addtomethod = "wxPreToolBar:val._setOORInfo(val)"
458 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
464 // class wxToolBarSimple : public wxToolBarBase {
466 // wxToolBarSimple(wxWindow *parent,
468 // const wxPoint& pos = wxDefaultPosition,
469 // const wxSize& size = wxDefaultSize,
470 // long style = wxNO_BORDER | wxTB_HORIZONTAL,
471 // const wxString& name = wxPyToolBarNameStr);
472 // %name(wxPreToolBarSimple)wxToolBarSimple();
474 // bool Create(wxWindow *parent,
476 // const wxPoint& pos = wxDefaultPosition,
477 // const wxSize& size = wxDefaultSize,
478 // long style = wxNO_BORDER | wxTB_HORIZONTAL,
479 // const wxString& name = wxPyToolBarNameStr);
481 // %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
482 // %pragma(python) addtomethod = "wxPreToolBarSimple:val._setOORInfo(val)"
484 // wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
487 //---------------------------------------------------------------------------
488 //---------------------------------------------------------------------------