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 wxBitmap& bitmap1 = wxNullBitmap,
98 // const wxBitmap& bitmap2 = wxNullBitmap,
99 // bool toggle = FALSE,
100 // wxObject *clientData = (wxObject *) NULL,
101 // const wxString& shortHelpString = wxPyEmptyString,
102 // const wxString& longHelpString = wxPyEmptyString);
103 // wxToolBarToolBase(wxToolBarBase *tbar, wxControl *control);
104 // ~wxToolBarToolBase();
106 %addmethods { void Destroy() { delete self; } }
109 wxControl *GetControl();
110 wxToolBarBase *GetToolBar();
118 const wxBitmap& GetNormalBitmap();
119 const wxBitmap& GetDisabledBitmap();
120 wxBitmap GetBitmap();
122 wxString GetShortHelp();
123 wxString GetLongHelp();
124 bool Enable(bool enable);
126 bool SetToggle(bool toggle);
127 bool SetShortHelp(const wxString& help);
128 bool SetLongHelp(const wxString& help);
129 void SetNormalBitmap(const wxBitmap& bmp);
130 void SetDisabledBitmap(const wxBitmap& bmp);
131 void SetLabel(const wxString& label);
133 void Attach(wxToolBarBase *tbar);
135 //wxObject *GetClientData();
137 // convert the ClientData back to a PyObject
138 PyObject* GetClientData() {
139 wxPyUserData* udata = (wxPyUserData*)self->GetClientData();
141 Py_INCREF(udata->m_obj);
149 void SetClientData(PyObject* clientData) {
150 self->SetClientData(new wxPyUserData(clientData));
154 %pragma(python) addtoclass="
155 GetBitmap1 = GetNormalBitmap
156 GetBitmap2 = GetDisabledBitmap
157 SetBitmap1 = SetNormalBitmap
158 SetBitmap2 = SetDisabledBitmap
164 class wxToolBarBase : public wxControl {
167 // This is an Abstract Base Class
170 // wrap ClientData in a class that knows about PyObjects
171 wxToolBarToolBase *AddTool(int id,
172 const wxBitmap& bitmap,
173 const wxBitmap& pushedBitmap = wxNullBitmap,
174 int isToggle = FALSE,
175 PyObject *clientData = NULL,
176 const wxString& shortHelpString = wxPyEmptyString,
177 const wxString& longHelpString = wxPyEmptyString) {
178 wxPyUserData* udata = NULL;
180 udata = new wxPyUserData(clientData);
181 return self->AddTool(id, bitmap, pushedBitmap, (bool)isToggle,
182 udata, shortHelpString, longHelpString);
185 // This one is easier to use...
186 wxToolBarToolBase *AddSimpleTool(int id,
187 const wxBitmap& bitmap,
188 const wxString& shortHelpString = wxPyEmptyString,
189 const wxString& longHelpString = wxPyEmptyString,
190 int isToggle = FALSE) {
191 return self->AddTool(id, bitmap, wxNullBitmap, isToggle, NULL,
192 shortHelpString, longHelpString);
196 // wrap ClientData in a class that knows about PyObjects
197 wxToolBarToolBase *InsertTool(size_t pos,
199 const wxBitmap& bitmap,
200 const wxBitmap& pushedBitmap = wxNullBitmap,
201 int isToggle = FALSE,
202 PyObject *clientData = NULL,
203 const wxString& shortHelpString = wxPyEmptyString,
204 const wxString& longHelpString = wxPyEmptyString) {
205 wxPyUserData* udata = NULL;
207 udata = new wxPyUserData(clientData);
208 return self->InsertTool(pos, id, bitmap, pushedBitmap, (bool)isToggle,
209 udata, shortHelpString, longHelpString);
212 // This one is easier to use...
213 wxToolBarToolBase *InsertSimpleTool(size_t pos,
215 const wxBitmap& bitmap,
216 const wxString& shortHelpString = wxPyEmptyString,
217 const wxString& longHelpString = wxPyEmptyString,
218 int isToggle = FALSE) {
219 return self->InsertTool(pos, id, bitmap, wxNullBitmap, isToggle, NULL,
220 shortHelpString, longHelpString);
225 wxToolBarToolBase *AddControl(wxControl *control);
226 wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
228 wxToolBarToolBase *AddSeparator();
229 wxToolBarToolBase *InsertSeparator(size_t pos);
231 wxToolBarToolBase *RemoveTool(int id);
233 bool DeleteToolByPos(size_t pos);
234 bool DeleteTool(int id);
238 void EnableTool(int id, bool enable);
239 void ToggleTool(int id, bool toggle);
240 void SetToggle(int id, bool toggle);
244 // convert the ClientData back to a PyObject
245 PyObject* GetToolClientData(int id) {
246 wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
248 Py_INCREF(udata->m_obj);
256 void SetToolClientData(int id, PyObject* clientData) {
257 self->SetToolClientData(id, new wxPyUserData(clientData));
262 bool GetToolState(int id);
263 bool GetToolEnabled(int id);
264 void SetToolShortHelp(int id, const wxString& helpString);
265 wxString GetToolShortHelp(int id);
266 void SetToolLongHelp(int id, const wxString& helpString);
267 wxString GetToolLongHelp(int id);
269 %name(SetMarginsXY) void SetMargins(int x, int y);
270 void SetMargins(const wxSize& size);
271 void SetToolPacking(int packing);
272 void SetToolSeparation(int separation);
273 wxSize GetToolMargins();
275 int GetToolPacking();
276 int GetToolSeparation();
278 void SetRows(int nRows);
279 void SetMaxRowsCols(int rows, int cols);
283 void SetToolBitmapSize(const wxSize& size);
284 wxSize GetToolBitmapSize();
285 wxSize GetToolSize();
287 // returns a (non separator) tool containing the point (x, y) or NULL if
288 // there is no tool at this point (corrdinates are client)
289 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
291 // return TRUE if this is a vertical toolbar, otherwise FALSE
298 class wxToolBar : public wxToolBarBase {
300 wxToolBar(wxWindow *parent,
302 const wxPoint& pos = wxDefaultPosition,
303 const wxSize& size = wxDefaultSize,
304 long style = wxNO_BORDER | wxTB_HORIZONTAL,
305 const wxString& name = wxPyToolBarNameStr);
306 %name(wxPreToolBar)wxToolBar();
308 bool Create(wxWindow *parent,
310 const wxPoint& pos = wxDefaultPosition,
311 const wxSize& size = wxDefaultSize,
312 long style = wxNO_BORDER | wxTB_HORIZONTAL,
313 const wxString& name = wxPyToolBarNameStr);
315 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
316 %pragma(python) addtomethod = "wxPreToolBar:val._setOORInfo(val)"
318 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
324 class wxToolBarSimple : public wxToolBarBase {
326 wxToolBarSimple(wxWindow *parent,
328 const wxPoint& pos = wxDefaultPosition,
329 const wxSize& size = wxDefaultSize,
330 long style = wxNO_BORDER | wxTB_HORIZONTAL,
331 const wxString& name = wxPyToolBarNameStr);
332 %name(wxPreToolBarSimple)wxToolBarSimple();
334 bool Create(wxWindow *parent,
336 const wxPoint& pos = wxDefaultPosition,
337 const wxSize& size = wxDefaultSize,
338 long style = wxNO_BORDER | wxTB_HORIZONTAL,
339 const wxString& name = wxPyToolBarNameStr);
341 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
342 %pragma(python) addtomethod = "wxPreToolBarSimple:val._setOORInfo(val)"
344 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
347 //---------------------------------------------------------------------------
348 //---------------------------------------------------------------------------