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"
37 static wxString wxPyEmptyStr("");
40 //---------------------------------------------------------------------------
42 class wxStatusBar : public wxWindow {
44 wxStatusBar(wxWindow* parent, wxWindowID id,
45 const wxPoint& pos = wxDefaultPosition,
46 const wxSize& size = wxDefaultSize,
47 long style = wxST_SIZEGRIP,
48 char* name = "statusBar");
50 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
53 %new wxRect* GetFieldRect(long item) {
54 wxRect* rect= new wxRect;
55 self->GetFieldRect(item, *rect);
59 int GetFieldsCount(void);
60 wxString GetStatusText(int ir = 0);
64 // void DrawField(wxDC& dc, int i);
65 // void DrawFieldText(wxDC& dc, int i);
66 // void InitColours(void);
68 void SetFieldsCount(int number = 1);
69 void SetStatusText(const wxString& text, int i = 0);
70 void SetStatusWidths(int LCOUNT, int* choices);
71 void SetMinHeight(int height);
75 //---------------------------------------------------------------------------
79 enum wxToolBarToolStyle
81 wxTOOL_STYLE_BUTTON = 1,
82 wxTOOL_STYLE_SEPARATOR = 2,
88 class wxToolBarToolBase {
90 // wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL,
91 // int id = wxID_SEPARATOR,
92 // const wxBitmap& bitmap1 = wxNullBitmap,
93 // const wxBitmap& bitmap2 = wxNullBitmap,
94 // bool toggle = FALSE,
95 // wxObject *clientData = (wxObject *) NULL,
96 // const wxString& shortHelpString = wxEmptyString,
97 // const wxString& longHelpString = wxEmptyString);
98 // wxToolBarToolBase(wxToolBarBase *tbar, wxControl *control);
99 // ~wxToolBarToolBase();
101 %addmethods { void Destroy() { delete self; } }
104 wxControl *GetControl();
105 wxToolBarBase *GetToolBar();
113 const wxBitmap& GetBitmap1();
114 const wxBitmap& GetBitmap2();
115 const wxBitmap& GetBitmap();
116 wxString GetShortHelp();
117 wxString GetLongHelp();
118 bool Enable(bool enable);
119 bool Toggle(bool toggle);
120 bool SetToggle(bool toggle);
121 bool SetShortHelp(const wxString& help);
122 bool SetLongHelp(const wxString& help);
123 void SetBitmap1(const wxBitmap& bmp);
124 void SetBitmap2(const wxBitmap& bmp);
126 void Attach(wxToolBarBase *tbar);
128 //wxObject *GetClientData();
130 // convert the ClientData back to a PyObject
131 PyObject* GetClientData() {
132 wxPyUserData* udata = (wxPyUserData*)self->GetClientData();
134 Py_INCREF(udata->m_obj);
142 void SetClientData(PyObject* clientData) {
143 self->SetClientData(new wxPyUserData(clientData));
150 class wxToolBarBase : public wxControl {
153 // This is an Abstract Base Class
156 // wrap ClientData in a class that knows about PyObjects
157 wxToolBarToolBase *AddTool(int id,
158 const wxBitmap& bitmap,
159 const wxBitmap& pushedBitmap = wxNullBitmap,
160 int isToggle = FALSE,
161 PyObject *clientData = NULL,
162 const wxString& shortHelpString = wxPyEmptyStr,
163 const wxString& longHelpString = wxPyEmptyStr) {
164 wxPyUserData* udata = NULL;
166 udata = new wxPyUserData(clientData);
167 return self->AddTool(id, bitmap, pushedBitmap, (bool)isToggle,
168 udata, shortHelpString, longHelpString);
171 // This one is easier to use...
172 wxToolBarToolBase *AddSimpleTool(int id,
173 const wxBitmap& bitmap,
174 const wxString& shortHelpString = wxPyEmptyStr,
175 const wxString& longHelpString = wxPyEmptyStr,
176 int isToggle = FALSE) {
177 return self->AddTool(id, bitmap, wxNullBitmap, isToggle, NULL,
178 shortHelpString, longHelpString);
182 // wrap ClientData in a class that knows about PyObjects
183 wxToolBarToolBase *InsertTool(size_t pos,
185 const wxBitmap& bitmap,
186 const wxBitmap& pushedBitmap = wxNullBitmap,
187 int isToggle = FALSE,
188 PyObject *clientData = NULL,
189 const wxString& shortHelpString = wxPyEmptyStr,
190 const wxString& longHelpString = wxPyEmptyStr) {
191 wxPyUserData* udata = NULL;
193 udata = new wxPyUserData(clientData);
194 return self->InsertTool(pos, id, bitmap, pushedBitmap, (bool)isToggle,
195 udata, shortHelpString, longHelpString);
198 // This one is easier to use...
199 wxToolBarToolBase *InsertSimpleTool(size_t pos,
201 const wxBitmap& bitmap,
202 const wxString& shortHelpString = wxPyEmptyStr,
203 const wxString& longHelpString = wxPyEmptyStr,
204 int isToggle = FALSE) {
205 return self->InsertTool(pos, id, bitmap, wxNullBitmap, isToggle, NULL,
206 shortHelpString, longHelpString);
211 wxToolBarToolBase *AddControl(wxControl *control);
212 wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
214 wxToolBarToolBase *AddSeparator();
215 wxToolBarToolBase *InsertSeparator(size_t pos);
217 wxToolBarToolBase *RemoveTool(int id);
219 bool DeleteToolByPos(size_t pos);
220 bool DeleteTool(int id);
224 void EnableTool(int id, bool enable);
225 void ToggleTool(int id, bool toggle);
226 void SetToggle(int id, bool toggle);
230 // convert the ClientData back to a PyObject
231 PyObject* GetToolClientData(int index) {
232 wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(index);
234 Py_INCREF(udata->m_obj);
242 void SetToolClientData(int index, PyObject* clientData) {
243 self->SetToolClientData(index, new wxPyUserData(clientData));
248 bool GetToolState(int id);
249 bool GetToolEnabled(int id);
250 void SetToolShortHelp(int id, const wxString& helpString);
251 wxString GetToolShortHelp(int id);
252 void SetToolLongHelp(int id, const wxString& helpString);
253 wxString GetToolLongHelp(int id);
255 %name(SetMarginsXY) void SetMargins(int x, int y);
256 void SetMargins(const wxSize& size);
257 void SetToolPacking(int packing);
258 void SetToolSeparation(int separation);
259 wxSize GetToolMargins();
261 int GetToolPacking();
262 int GetToolSeparation();
264 void SetRows(int nRows);
265 void SetMaxRowsCols(int rows, int cols);
269 void SetToolBitmapSize(const wxSize& size);
270 wxSize GetToolBitmapSize();
271 wxSize GetToolSize();
278 class wxToolBar : public wxToolBarBase {
280 wxToolBar(wxWindow *parent,
282 const wxPoint& pos = wxDefaultPosition,
283 const wxSize& size = wxDefaultSize,
284 long style = wxNO_BORDER | wxTB_HORIZONTAL,
285 const char* name = wxToolBarNameStr);
287 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
289 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
295 class wxToolBarSimple : public wxToolBarBase {
297 wxToolBarSimple(wxWindow *parent,
299 const wxPoint& pos = wxDefaultPosition,
300 const wxSize& size = wxDefaultSize,
301 long style = wxNO_BORDER | wxTB_HORIZONTAL,
302 const char* name = wxToolBarNameStr);
304 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
306 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
309 //---------------------------------------------------------------------------
315 class wxToolBarTool {
319 void SetSize( long w, long h )
322 wxControl *GetControl();
326 wxObject * m_clientData;
334 bool m_deleteSecondBitmap;
338 bool m_isMenuCommand;
339 wxString m_shortHelpString;
340 wxString m_longHelpString;
345 // class wxToolBarBase : public wxControl {
348 class wxToolBar : public wxControl {
350 wxToolBar(wxWindow* parent, wxWindowID id,
351 const wxPoint& pos = wxDefaultPosition,
352 const wxSize& size = wxDefaultSize,
353 long style = wxTB_HORIZONTAL | wxNO_BORDER,
354 char* name = "toolBar");
356 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
359 bool AddControl(wxControl * control);
363 // Ignoge the clientData for now...
365 wxToolBarTool* AddTool(int toolIndex,
366 const wxBitmap& bitmap1,
367 const wxBitmap& bitmap2 = wxNullBitmap,
368 int isToggle = FALSE,
371 //wxObject* clientData = NULL,
372 const wxString& shortHelpString = wxPyEmptyStr,
373 const wxString& longHelpString = wxPyEmptyStr) {
374 return self->AddTool(toolIndex, bitmap1, bitmap2,
375 isToggle, xPos, yPos, NULL,
376 shortHelpString, longHelpString);
379 wxToolBarTool* AddSimpleTool(int toolIndex,
380 const wxBitmap& bitmap,
381 const wxString& shortHelpString = wxPyEmptyStr,
382 const wxString& longHelpString = wxPyEmptyStr) {
383 return self->AddTool(toolIndex, bitmap, wxNullBitmap,
385 shortHelpString, longHelpString);
390 void EnableTool(int toolIndex, bool enable);
392 wxToolBarTool* FindToolForPosition(long x, long y);
393 wxSize GetToolSize();
394 wxSize GetToolBitmapSize();
395 void SetToolBitmapSize(const wxSize& size);
398 wxSize GetToolMargins();
399 // wxObject* GetToolClientData(int toolIndex);
400 bool GetToolEnabled(int toolIndex);
401 wxString GetToolLongHelp(int toolIndex);
402 int GetToolPacking();
403 int GetToolSeparation();
404 wxString GetToolShortHelp(int toolIndex);
405 bool GetToolState(int toolIndex);
410 void SetToolLongHelp(int toolIndex, const wxString& helpString);
411 void SetToolShortHelp(int toolIndex, const wxString& helpString);
412 void SetMargins(const wxSize& size);
413 void SetToolPacking(int packing);
414 void SetToolSeparation(int separation);
415 void ToggleTool(int toolIndex, const bool toggle);
416 void SetToggle(int toolIndex, bool toggle);
417 void SetMaxRowsCols(int rows, int cols);
425 //---------------------------------------------------------------------------