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"
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
174 // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
175 // is created and used as the disabled image.
176 wxToolBarToolBase *AddTool(int id,
177 const wxString& label,
178 const wxBitmap& bitmap,
179 const wxBitmap& bmpDisabled,
180 wxItemKind kind = wxITEM_NORMAL,
181 const wxString& shortHelp = wxPyEmptyString,
182 const wxString& longHelp = wxPyEmptyString,
183 PyObject *clientData = NULL)
185 wxPyUserData* udata = NULL;
187 udata = new wxPyUserData(clientData);
188 return self->AddTool(id, label, bitmap, bmpDisabled, kind,
189 shortHelp, longHelp, udata);
192 // The most common version of AddTool
193 wxToolBarToolBase *AddSimpleTool(int id,
194 const wxString& label,
195 const wxBitmap& bitmap,
196 const wxString& shortHelp = wxPyEmptyString,
197 const wxString& longHelp = wxPyEmptyString,
198 wxItemKind kind = wxITEM_NORMAL)
200 return self->AddTool(id, label, bitmap, wxNullBitmap, kind,
201 shortHelp, longHelp, NULL);
204 // add a check tool, i.e. a tool which can be toggled
205 wxToolBarToolBase *AddCheckTool(int id,
206 const wxString& label,
207 const wxBitmap& bitmap,
208 const wxBitmap& bmpDisabled = wxNullBitmap,
209 const wxString& shortHelp = wxPyEmptyString,
210 const wxString& longHelp = wxPyEmptyString,
211 PyObject *clientData = NULL)
213 wxPyUserData* udata = NULL;
215 udata = new wxPyUserData(clientData);
216 return self->AddCheckTool(id, label, bitmap, bmpDisabled,
217 shortHelp, longHelp, udata);
220 // add a radio tool, i.e. a tool which can be toggled and releases any
221 // other toggled radio tools in the same group when it happens
222 wxToolBarToolBase *AddRadioTool(int id,
223 const wxString& label,
224 const wxBitmap& bitmap,
225 const wxBitmap& bmpDisabled = wxNullBitmap,
226 const wxString& shortHelp = wxPyEmptyString,
227 const wxString& longHelp = wxPyEmptyString,
228 PyObject *clientData = NULL)
230 wxPyUserData* udata = NULL;
232 udata = new wxPyUserData(clientData);
233 return self->AddRadioTool(id, label, bitmap, bmpDisabled,
234 shortHelp, longHelp, udata);
237 // insert the new tool at the given position, if pos == GetToolsCount(), it
238 // is equivalent to AddTool()
239 wxToolBarToolBase *InsertTool(size_t pos,
241 const wxString& label,
242 const wxBitmap& bitmap,
243 const wxBitmap& bmpDisabled = wxNullBitmap,
244 wxItemKind kind = wxITEM_NORMAL,
245 const wxString& shortHelp = wxPyEmptyString,
246 const wxString& longHelp = wxPyEmptyString,
247 PyObject *clientData = NULL)
249 wxPyUserData* udata = NULL;
251 udata = new wxPyUserData(clientData);
252 return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind,
253 shortHelp, longHelp, udata);
256 // A simpler InsertTool
257 wxToolBarToolBase *InsertSimpleTool(size_t pos,
259 const wxString& label,
260 const wxBitmap& bitmap,
261 wxItemKind kind = wxITEM_NORMAL,
262 const wxString& shortHelp = wxPyEmptyString,
263 const wxString& longHelp = wxPyEmptyString)
265 return self->InsertTool(pos, id, label, bitmap, wxNullBitmap, kind,
266 shortHelp, longHelp);
271 wxToolBarToolBase *AddControl(wxControl *control);
272 wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
274 wxToolBarToolBase *AddSeparator();
275 wxToolBarToolBase *InsertSeparator(size_t pos);
277 wxToolBarToolBase *RemoveTool(int id);
279 bool DeleteToolByPos(size_t pos);
280 bool DeleteTool(int id);
284 void EnableTool(int id, bool enable);
285 void ToggleTool(int id, bool toggle);
286 void SetToggle(int id, bool toggle);
290 // convert the ClientData back to a PyObject
291 PyObject* GetToolClientData(int id) {
292 wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
294 Py_INCREF(udata->m_obj);
302 void SetToolClientData(int id, PyObject* clientData) {
303 self->SetToolClientData(id, new wxPyUserData(clientData));
308 bool GetToolState(int id);
309 bool GetToolEnabled(int id);
310 void SetToolShortHelp(int id, const wxString& helpString);
311 wxString GetToolShortHelp(int id);
312 void SetToolLongHelp(int id, const wxString& helpString);
313 wxString GetToolLongHelp(int id);
315 %name(SetMarginsXY) void SetMargins(int x, int y);
316 void SetMargins(const wxSize& size);
317 void SetToolPacking(int packing);
318 void SetToolSeparation(int separation);
319 wxSize GetToolMargins();
321 int GetToolPacking();
322 int GetToolSeparation();
324 void SetRows(int nRows);
325 void SetMaxRowsCols(int rows, int cols);
329 void SetToolBitmapSize(const wxSize& size);
330 wxSize GetToolBitmapSize();
331 wxSize GetToolSize();
333 // returns a (non separator) tool containing the point (x, y) or NULL if
334 // there is no tool at this point (corrdinates are client)
335 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
337 // return TRUE if this is a vertical toolbar, otherwise FALSE
344 class wxToolBar : public wxToolBarBase {
346 wxToolBar(wxWindow *parent,
348 const wxPoint& pos = wxDefaultPosition,
349 const wxSize& size = wxDefaultSize,
350 long style = wxNO_BORDER | wxTB_HORIZONTAL,
351 const wxString& name = wxPyToolBarNameStr);
352 %name(wxPreToolBar)wxToolBar();
354 bool Create(wxWindow *parent,
356 const wxPoint& pos = wxDefaultPosition,
357 const wxSize& size = wxDefaultSize,
358 long style = wxNO_BORDER | wxTB_HORIZONTAL,
359 const wxString& name = wxPyToolBarNameStr);
361 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
362 %pragma(python) addtomethod = "wxPreToolBar:val._setOORInfo(val)"
364 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
370 class wxToolBarSimple : public wxToolBarBase {
372 wxToolBarSimple(wxWindow *parent,
374 const wxPoint& pos = wxDefaultPosition,
375 const wxSize& size = wxDefaultSize,
376 long style = wxNO_BORDER | wxTB_HORIZONTAL,
377 const wxString& name = wxPyToolBarNameStr);
378 %name(wxPreToolBarSimple)wxToolBarSimple();
380 bool Create(wxWindow *parent,
382 const wxPoint& pos = wxDefaultPosition,
383 const wxSize& size = wxDefaultSize,
384 long style = wxNO_BORDER | wxTB_HORIZONTAL,
385 const wxString& name = wxPyToolBarNameStr);
387 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
388 %pragma(python) addtomethod = "wxPreToolBarSimple:val._setOORInfo(val)"
390 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
393 //---------------------------------------------------------------------------
394 //---------------------------------------------------------------------------