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 SetMinHeight(int height);
80 //---------------------------------------------------------------------------
84 enum wxToolBarToolStyle
86 wxTOOL_STYLE_BUTTON = 1,
87 wxTOOL_STYLE_SEPARATOR = 2,
93 class wxToolBarToolBase : public wxObject {
95 // wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL,
96 // int id = wxID_SEPARATOR,
97 // const wxString& label = wxEmptyString,
98 // const wxBitmap& bmpNormal = wxNullBitmap,
99 // const wxBitmap& bmpDisabled = wxNullBitmap,
100 // wxItemKind kind = wxITEM_NORMAL,
101 // wxObject *clientData = (wxObject *) NULL,
102 // const wxString& shortHelpString = wxEmptyString,
103 // const wxString& longHelpString = wxEmptyString)
104 // ~wxToolBarToolBase();
106 %addmethods { void Destroy() { delete self; } }
109 wxControl *GetControl();
110 wxToolBarBase *GetToolBar();
115 wxItemKind GetKind();
119 const wxBitmap& GetNormalBitmap();
120 const wxBitmap& GetDisabledBitmap();
121 wxBitmap GetBitmap();
123 wxString GetShortHelp();
124 wxString GetLongHelp();
125 bool Enable(bool enable);
127 bool SetToggle(bool toggle);
128 bool SetShortHelp(const wxString& help);
129 bool SetLongHelp(const wxString& help);
130 void SetNormalBitmap(const wxBitmap& bmp);
131 void SetDisabledBitmap(const wxBitmap& bmp);
132 void SetLabel(const wxString& label);
134 void Attach(wxToolBarBase *tbar);
136 //wxObject *GetClientData();
138 // convert the ClientData back to a PyObject
139 PyObject* GetClientData() {
140 wxPyUserData* udata = (wxPyUserData*)self->GetClientData();
142 Py_INCREF(udata->m_obj);
150 void SetClientData(PyObject* clientData) {
151 self->SetClientData(new wxPyUserData(clientData));
155 %pragma(python) addtoclass="
156 GetBitmap1 = GetNormalBitmap
157 GetBitmap2 = GetDisabledBitmap
158 SetBitmap1 = SetNormalBitmap
159 SetBitmap2 = SetDisabledBitmap
165 class wxToolBarBase : public wxControl {
168 // This is an Abstract Base Class
172 // The full AddTool() function. Call it DoAddTool in wxPython and
173 // implement the other Add methods by calling it.
175 // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
176 // is created and used as the disabled image.
177 wxToolBarToolBase *DoAddTool(int id,
178 const wxString& label,
179 const wxBitmap& bitmap,
180 const wxBitmap& bmpDisabled = wxNullBitmap,
181 wxItemKind kind = wxITEM_NORMAL,
182 const wxString& shortHelp = wxPyEmptyString,
183 const wxString& longHelp = wxPyEmptyString,
184 PyObject *clientData = NULL)
186 wxPyUserData* udata = NULL;
187 if (clientData && clientData != Py_None)
188 udata = new wxPyUserData(clientData);
189 return self->AddTool(id, label, bitmap, bmpDisabled, kind,
190 shortHelp, longHelp, udata);
194 // Insert the new tool at the given position, if pos == GetToolsCount(), it
195 // is equivalent to DoAddTool()
196 wxToolBarToolBase *InsertTool(size_t pos,
198 const wxString& label,
199 const wxBitmap& bitmap,
200 const wxBitmap& bmpDisabled = wxNullBitmap,
201 wxItemKind kind = wxITEM_NORMAL,
202 const wxString& shortHelp = wxPyEmptyString,
203 const wxString& longHelp = wxPyEmptyString,
204 PyObject *clientData = NULL)
206 wxPyUserData* udata = NULL;
207 if (clientData && clientData != Py_None)
208 udata = new wxPyUserData(clientData);
209 return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind,
210 shortHelp, longHelp, udata);
216 %pragma(python) addtoclass = "
217 # These match the original Add methods for this class, kept for
218 # backwards compatibility with versions < 2.3.3.
221 def AddTool(self, id, bitmap,
222 pushedBitmap = wxNullBitmap,
225 shortHelpString = '',
226 longHelpString = '') :
227 '''Old style method to add a tool to the toolbar.'''
228 kind = wx.wxITEM_NORMAL
229 if isToggle: kind = wx.wxITEM_CHECK
230 return self.DoAddTool(id, '', bitmap, pushedBitmap, kind,
231 shortHelpString, longHelpString, clientData)
233 def AddSimpleTool(self, id, bitmap,
234 shortHelpString = '',
237 '''Old style method to add a tool to the toolbar.'''
238 kind = wx.wxITEM_NORMAL
239 if isToggle: kind = wx.wxITEM_CHECK
240 return self.DoAddTool(id, '', bitmap, wxNullBitmap, kind,
241 shortHelpString, longHelpString, None)
243 def InsertTool(self, pos, id, bitmap,
244 pushedBitmap = wxNullBitmap,
247 shortHelpString = '',
248 longHelpString = ''):
249 '''Old style method to insert a tool in the toolbar.'''
250 kind = wx.wxITEM_NORMAL
251 if isToggle: kind = wx.wxITEM_CHECK
252 return self.DoInsertTool(pos, id, '', bitmap, pushedBitmap, kind,
253 shortHelpString, longHelpString, clientData)
255 def InsertSimpleTool(self, pos, id, bitmap,
256 shortHelpString = '',
259 '''Old style method to insert a tool in the toolbar.'''
260 kind = wx.wxITEM_NORMAL
261 if isToggle: kind = wx.wxITEM_CHECK
262 return self.DoInsertTool(pos, id, '', bitmap, wxNullBitmap, kind,
263 shortHelpString, longHelpString, None)
266 # The following are the new toolbar Add methods starting with
267 # 2.3.3. They are renamed to have 'Label' in the name so as to be
268 # able to keep backwards compatibility with using the above
269 # methods. Eventually these should migrate to be the methods used
270 # primarily and loose the 'Label' in the name...
272 def AddLabelTool(self, id, label, bitmap,
273 bmpDisabled = wxNullBitmap,
274 kind = wxITEM_NORMAL,
275 shortHelp = '', longHelp = '',
278 The full AddTool() function.
280 If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
281 is created and used as the disabled image.
283 return self.DoAddTool(id, label, bitmap, bmpDisabled, kind,
284 shortHelp, longHelp, clientData)
287 def InsertLabelTool(self, pos, id, label, bitmap,
288 bmpDisabled = wxNullBitmap,
289 kind = wxITEM_NORMAL,
290 shortHelp = '', longHelp = '',
293 Insert the new tool at the given position, if pos == GetToolsCount(), it
294 is equivalent to AddTool()
296 return self.DoInsertTool(pos, id, label, bitmap, bmpDisabled, kind,
297 shortHelp, longHelp, clientData)
299 def AddCheckLabelTool(self, id, label, bitmap,
300 bmpDisabled = wxNullBitmap,
301 shortHelp = '', longHelp = '',
303 '''Add a check tool, i.e. a tool which can be toggled'''
304 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.wxITEM_CHECK,
305 shortHelp, longHelp, clientData)
307 def AddRadioLabelTool(self, id, label, bitmap,
308 bmpDisabled = wxNullBitmap,
309 shortHelp = '', longHelp = '',
312 Add a radio tool, i.e. a tool which can be toggled and releases any
313 other toggled radio tools in the same group when it happens
315 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.wxITEM_RADIO,
316 shortHelp, longHelp, clientData)
319 # For consistency with the backwards compatible methods above, here are
320 # some non-'Label' versions of the Check and Radio methods
321 def AddCheckTool(self, id, bitmap,
322 bmpDisabled = wxNullBitmap,
323 shortHelp = '', longHelp = '',
325 '''Add a check tool, i.e. a tool which can be toggled'''
326 return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.wxITEM_CHECK,
327 shortHelp, longHelp, clientData)
329 def AddRadioTool(self, id, bitmap,
330 bmpDisabled = wxNullBitmap,
331 shortHelp = '', longHelp = '',
334 Add a radio tool, i.e. a tool which can be toggled and releases any
335 other toggled radio tools in the same group when it happens
337 return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.wxITEM_RADIO,
338 shortHelp, longHelp, clientData)
342 wxToolBarToolBase *AddControl(wxControl *control);
343 wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
345 wxToolBarToolBase *AddSeparator();
346 wxToolBarToolBase *InsertSeparator(size_t pos);
348 wxToolBarToolBase *RemoveTool(int id);
350 bool DeleteToolByPos(size_t pos);
351 bool DeleteTool(int id);
355 void EnableTool(int id, bool enable);
356 void ToggleTool(int id, bool toggle);
357 void SetToggle(int id, bool toggle);
361 // convert the ClientData back to a PyObject
362 PyObject* GetToolClientData(int id) {
363 wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
365 Py_INCREF(udata->m_obj);
373 void SetToolClientData(int id, PyObject* clientData) {
374 self->SetToolClientData(id, new wxPyUserData(clientData));
379 bool GetToolState(int id);
380 bool GetToolEnabled(int id);
381 void SetToolShortHelp(int id, const wxString& helpString);
382 wxString GetToolShortHelp(int id);
383 void SetToolLongHelp(int id, const wxString& helpString);
384 wxString GetToolLongHelp(int id);
386 %name(SetMarginsXY) void SetMargins(int x, int y);
387 void SetMargins(const wxSize& size);
388 void SetToolPacking(int packing);
389 void SetToolSeparation(int separation);
390 wxSize GetToolMargins();
392 int GetToolPacking();
393 int GetToolSeparation();
395 void SetRows(int nRows);
396 void SetMaxRowsCols(int rows, int cols);
400 void SetToolBitmapSize(const wxSize& size);
401 wxSize GetToolBitmapSize();
402 wxSize GetToolSize();
404 // returns a (non separator) tool containing the point (x, y) or NULL if
405 // there is no tool at this point (corrdinates are client)
406 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
408 // return TRUE if this is a vertical toolbar, otherwise FALSE
415 class wxToolBar : public wxToolBarBase {
417 wxToolBar(wxWindow *parent,
419 const wxPoint& pos = wxDefaultPosition,
420 const wxSize& size = wxDefaultSize,
421 long style = wxNO_BORDER | wxTB_HORIZONTAL,
422 const wxString& name = wxPyToolBarNameStr);
423 %name(wxPreToolBar)wxToolBar();
425 bool Create(wxWindow *parent,
427 const wxPoint& pos = wxDefaultPosition,
428 const wxSize& size = wxDefaultSize,
429 long style = wxNO_BORDER | wxTB_HORIZONTAL,
430 const wxString& name = wxPyToolBarNameStr);
432 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
433 %pragma(python) addtomethod = "wxPreToolBar:val._setOORInfo(val)"
435 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
441 class wxToolBarSimple : public wxToolBarBase {
443 wxToolBarSimple(wxWindow *parent,
445 const wxPoint& pos = wxDefaultPosition,
446 const wxSize& size = wxDefaultSize,
447 long style = wxNO_BORDER | wxTB_HORIZONTAL,
448 const wxString& name = wxPyToolBarNameStr);
449 %name(wxPreToolBarSimple)wxToolBarSimple();
451 bool Create(wxWindow *parent,
453 const wxPoint& pos = wxDefaultPosition,
454 const wxSize& size = wxDefaultSize,
455 long style = wxNO_BORDER | wxTB_HORIZONTAL,
456 const wxString& name = wxPyToolBarNameStr);
458 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
459 %pragma(python) addtomethod = "wxPreToolBarSimple:val._setOORInfo(val)"
461 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
464 //---------------------------------------------------------------------------
465 //---------------------------------------------------------------------------