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"
35 //---------------------------------------------------------------------------
37 class wxStatusBar : public wxWindow {
39 wxStatusBar(wxWindow* parent, wxWindowID id,
40 const wxPoint& pos = wxPyDefaultPosition,
41 const wxSize& size = wxPyDefaultSize,
42 long style = wxST_SIZEGRIP,
43 char* name = "statusBar");
45 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
48 %new wxRect* GetFieldRect(long item) {
49 wxRect* rect= new wxRect;
50 self->GetFieldRect(item, *rect);
54 int GetFieldsCount(void);
55 wxString GetStatusText(int ir = 0);
56 void DrawField(wxDC& dc, int i);
57 void DrawFieldText(wxDC& dc, int i);
58 void InitColours(void);
60 void SetFieldsCount(int number = 1);
61 void SetStatusText(const wxString& text, int i = 0);
62 void SetStatusWidths(int LCOUNT, int* choices);
66 //---------------------------------------------------------------------------
70 enum wxToolBarToolStyle
72 wxTOOL_STYLE_BUTTON = 1,
73 wxTOOL_STYLE_SEPARATOR = 2,
79 class wxToolBarToolBase {
81 // wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL,
82 // int id = wxID_SEPARATOR,
83 // const wxBitmap& bitmap1 = wxNullBitmap,
84 // const wxBitmap& bitmap2 = wxNullBitmap,
85 // bool toggle = FALSE,
86 // wxObject *clientData = (wxObject *) NULL,
87 // const wxString& shortHelpString = wxEmptyString,
88 // const wxString& longHelpString = wxEmptyString);
89 // wxToolBarToolBase(wxToolBarBase *tbar, wxControl *control);
90 // ~wxToolBarToolBase();
92 %addmethods { void Destroy() { delete self; } }
95 wxControl *GetControl();
96 wxToolBarBase *GetToolBar();
104 const wxBitmap& GetBitmap1();
105 const wxBitmap& GetBitmap2();
106 const wxBitmap& GetBitmap();
107 wxString GetShortHelp();
108 wxString GetLongHelp();
109 bool Enable(bool enable);
110 bool Toggle(bool toggle);
111 bool SetToggle(bool toggle);
112 bool SetShortHelp(const wxString& help);
113 bool SetLongHelp(const wxString& help);
114 void SetBitmap1(const wxBitmap& bmp);
115 void SetBitmap2(const wxBitmap& bmp);
117 void Attach(wxToolBarBase *tbar);
119 //wxObject *GetClientData();
121 // convert the ClientData back to a PyObject
122 PyObject* GetClientData() {
123 wxPyUserData* udata = (wxPyUserData*)self->GetClientData();
125 Py_INCREF(udata->m_obj);
133 void SetClientData(PyObject* clientData) {
134 self->SetClientData(new wxPyUserData(clientData));
141 class wxToolBarBase : public wxControl {
144 // This is an Abstract Base Class
147 // wrap ClientData in a class that knows about PyObjects
148 wxToolBarToolBase *AddTool(int id,
149 const wxBitmap& bitmap,
150 const wxBitmap& pushedBitmap = wxNullBitmap,
152 PyObject *clientData = NULL,
153 const wxString& shortHelpString = wxPyEmptyStr,
154 const wxString& longHelpString = wxPyEmptyStr) {
155 wxPyUserData* udata = NULL;
157 udata = new wxPyUserData(clientData);
158 return self->AddTool(id, bitmap, pushedBitmap, (bool)toggle,
159 udata, shortHelpString, longHelpString);
162 // This one is easier to use...
163 wxToolBarToolBase *AddSimpleTool(int id,
164 const wxBitmap& bitmap,
165 const wxString& shortHelpString = wxPyEmptyStr,
166 const wxString& longHelpString = wxPyEmptyStr,
167 int toggle = FALSE) {
168 return self->AddTool(id, bitmap, wxNullBitmap, toggle, NULL,
169 shortHelpString, longHelpString);
173 // wrap ClientData in a class that knows about PyObjects
174 wxToolBarToolBase *InsertTool(size_t pos,
176 const wxBitmap& bitmap,
177 const wxBitmap& pushedBitmap = wxNullBitmap,
179 PyObject *clientData = NULL,
180 const wxString& shortHelpString = wxPyEmptyStr,
181 const wxString& longHelpString = wxPyEmptyStr) {
182 wxPyUserData* udata = NULL;
184 udata = new wxPyUserData(clientData);
185 return self->InsertTool(pos, id, bitmap, pushedBitmap, (bool)toggle,
186 udata, shortHelpString, longHelpString);
189 // This one is easier to use...
190 wxToolBarToolBase *InsertSimpleTool(size_t pos,
192 const wxBitmap& bitmap,
193 const wxString& shortHelpString = wxPyEmptyStr,
194 const wxString& longHelpString = wxPyEmptyStr,
195 int toggle = FALSE) {
196 return self->InsertTool(pos, id, bitmap, wxNullBitmap, toggle, NULL,
197 shortHelpString, longHelpString);
202 wxToolBarToolBase *AddControl(wxControl *control);
203 wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
205 wxToolBarToolBase *AddSeparator();
206 wxToolBarToolBase *InsertSeparator(size_t pos);
208 wxToolBarToolBase *RemoveTool(int id);
210 bool DeleteToolByPos(size_t pos);
211 bool DeleteTool(int id);
215 void EnableTool(int id, bool enable);
216 void ToggleTool(int id, bool toggle);
217 void SetToggle(int id, bool toggle);
221 // convert the ClientData back to a PyObject
222 PyObject* GetToolClientData(int index) {
223 wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(index);
225 Py_INCREF(udata->m_obj);
233 void SetToolClientData(int index, PyObject* clientData) {
234 self->SetToolClientData(index, new wxPyUserData(clientData));
239 bool GetToolState(int id);
240 bool GetToolEnabled(int id);
241 void SetToolShortHelp(int id, const wxString& helpString);
242 wxString GetToolShortHelp(int id);
243 void SetToolLongHelp(int id, const wxString& helpString);
244 wxString GetToolLongHelp(int id);
246 %name(SetMarginsXY) void SetMargins(int x, int y);
247 void SetMargins(const wxSize& size);
248 void SetToolPacking(int packing);
249 void SetToolSeparation(int separation);
250 wxSize GetToolMargins();
251 int GetToolPacking();
252 int GetToolSeparation();
254 void SetRows(int nRows);
255 void SetMaxRowsCols(int rows, int cols);
259 void SetToolBitmapSize(const wxSize& size);
260 wxSize GetToolBitmapSize();
261 wxSize GetToolSize();
268 class wxToolBar : public wxToolBarBase {
270 wxToolBar(wxWindow *parent,
272 const wxPoint& pos = wxPyDefaultPosition,
273 const wxSize& size = wxPyDefaultSize,
274 long style = wxNO_BORDER | wxTB_HORIZONTAL,
275 const char* name = wxToolBarNameStr);
277 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
279 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
285 class wxToolBarSimple : public wxToolBarBase {
287 wxToolBarSimple(wxWindow *parent,
289 const wxPoint& pos = wxPyDefaultPosition,
290 const wxSize& size = wxPyDefaultSize,
291 long style = wxNO_BORDER | wxTB_HORIZONTAL,
292 const char* name = wxToolBarNameStr);
294 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
296 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
299 //---------------------------------------------------------------------------
305 class wxToolBarTool {
309 void SetSize( long w, long h )
312 wxControl *GetControl();
316 wxObject * m_clientData;
324 bool m_deleteSecondBitmap;
328 bool m_isMenuCommand;
329 wxString m_shortHelpString;
330 wxString m_longHelpString;
335 // class wxToolBarBase : public wxControl {
338 class wxToolBar : public wxControl {
340 wxToolBar(wxWindow* parent, wxWindowID id,
341 const wxPoint& pos = wxPyDefaultPosition,
342 const wxSize& size = wxPyDefaultSize,
343 long style = wxTB_HORIZONTAL | wxNO_BORDER,
344 char* name = "toolBar");
346 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
349 bool AddControl(wxControl * control);
353 // Ignoge the clientData for now...
355 wxToolBarTool* AddTool(int toolIndex,
356 const wxBitmap& bitmap1,
357 const wxBitmap& bitmap2 = wxNullBitmap,
358 int isToggle = FALSE,
361 //wxObject* clientData = NULL,
362 const wxString& shortHelpString = wxPyEmptyStr,
363 const wxString& longHelpString = wxPyEmptyStr) {
364 return self->AddTool(toolIndex, bitmap1, bitmap2,
365 isToggle, xPos, yPos, NULL,
366 shortHelpString, longHelpString);
369 wxToolBarTool* AddSimpleTool(int toolIndex,
370 const wxBitmap& bitmap,
371 const wxString& shortHelpString = wxPyEmptyStr,
372 const wxString& longHelpString = wxPyEmptyStr) {
373 return self->AddTool(toolIndex, bitmap, wxNullBitmap,
375 shortHelpString, longHelpString);
380 void EnableTool(int toolIndex, bool enable);
382 wxToolBarTool* FindToolForPosition(long x, long y);
383 wxSize GetToolSize();
384 wxSize GetToolBitmapSize();
385 void SetToolBitmapSize(const wxSize& size);
388 wxSize GetToolMargins();
389 // wxObject* GetToolClientData(int toolIndex);
390 bool GetToolEnabled(int toolIndex);
391 wxString GetToolLongHelp(int toolIndex);
392 int GetToolPacking();
393 int GetToolSeparation();
394 wxString GetToolShortHelp(int toolIndex);
395 bool GetToolState(int toolIndex);
400 void SetToolLongHelp(int toolIndex, const wxString& helpString);
401 void SetToolShortHelp(int toolIndex, const wxString& helpString);
402 void SetMargins(const wxSize& size);
403 void SetToolPacking(int packing);
404 void SetToolSeparation(int separation);
405 void ToggleTool(int toolIndex, const bool toggle);
406 void SetToggle(int toolIndex, bool toggle);
407 void SetMaxRowsCols(int rows, int cols);
415 //---------------------------------------------------------------------------