]>
Commit | Line | Data |
---|---|---|
9c039d08 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: stattool.i | |
3 | // Purpose: SWIG definitions for StatusBar and ToolBar classes | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 08/24/1998 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1998 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | ||
14 | %module stattool | |
15 | ||
16 | %{ | |
17 | #include "helpers.h" | |
18 | #include <wx/toolbar.h> | |
19 | #include <wx/tbarsmpl.h> | |
20 | %} | |
21 | ||
22 | //---------------------------------------------------------------------- | |
23 | ||
24 | %include typemaps.i | |
25 | %include my_typemaps.i | |
26 | ||
27 | // Import some definitions of other classes, etc. | |
28 | %import _defs.i | |
29 | %import misc.i | |
30 | %import windows.i | |
31 | %import controls.i | |
32 | ||
b8b8dda7 | 33 | %pragma(python) code = "import wx" |
15030c51 | 34 | %pragma(python) code = "wxITEM_NORMAL = 0 # predeclare this since wx isn't fully imported yet" |
b68dc582 | 35 | |
137b5242 RD |
36 | //---------------------------------------------------------------------- |
37 | ||
38 | %{ | |
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("")); | |
43 | %} | |
44 | ||
9c039d08 RD |
45 | //--------------------------------------------------------------------------- |
46 | ||
47 | class wxStatusBar : public wxWindow { | |
48 | public: | |
99f7d340 | 49 | wxStatusBar(wxWindow* parent, wxWindowID id = -1, |
9c039d08 | 50 | long style = wxST_SIZEGRIP, |
137b5242 | 51 | const wxString& name = wxPyStatusLineNameStr); |
09f3d4e6 RD |
52 | %name(wxPreStatusBar)wxStatusBar(); |
53 | ||
54 | bool Create(wxWindow* parent, wxWindowID id, | |
55 | long style = wxST_SIZEGRIP, | |
137b5242 | 56 | const wxString& name = wxPyStatusLineNameStr); |
9c039d08 | 57 | |
0122b7e3 | 58 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 59 | %pragma(python) addtomethod = "wxPreStatusBar:val._setOORInfo(val)" |
9c039d08 RD |
60 | |
61 | %addmethods { | |
62 | %new wxRect* GetFieldRect(long item) { | |
63 | wxRect* rect= new wxRect; | |
64 | self->GetFieldRect(item, *rect); | |
65 | return rect; | |
66 | } | |
67 | } | |
68 | int GetFieldsCount(void); | |
69 | wxString GetStatusText(int ir = 0); | |
26b9cf27 RD |
70 | int GetBorderX(); |
71 | int GetBorderY(); | |
72 | ||
9c039d08 RD |
73 | void SetFieldsCount(int number = 1); |
74 | void SetStatusText(const wxString& text, int i = 0); | |
eec92d76 | 75 | void SetStatusWidths(int LCOUNT, int* choices); |
94e36a51 RD |
76 | void PushStatusText(const wxString& text, int number = 0); |
77 | void PopStatusText(int number = 0); | |
78 | ||
26b9cf27 | 79 | void SetMinHeight(int height); |
9c039d08 RD |
80 | }; |
81 | ||
82 | ||
83 | //--------------------------------------------------------------------------- | |
84 | ||
9b3d3bc4 RD |
85 | class wxToolBarBase; |
86 | ||
87 | enum wxToolBarToolStyle | |
88 | { | |
89 | wxTOOL_STYLE_BUTTON = 1, | |
90 | wxTOOL_STYLE_SEPARATOR = 2, | |
91 | wxTOOL_STYLE_CONTROL | |
92 | }; | |
93 | ||
3ef86e32 RD |
94 | enum { |
95 | wxTB_HORIZONTAL, | |
96 | wxTB_VERTICAL, | |
97 | wxTB_3DBUTTONS, | |
98 | wxTB_FLAT, | |
99 | wxTB_DOCKABLE, | |
100 | wxTB_NOICONS, | |
101 | wxTB_TEXT, | |
102 | wxTB_NODIVIDER, | |
103 | wxTB_NOALIGN, | |
104 | wxTB_HORZ_LAYOUT, | |
105 | wxTB_HORZ_TEXT, | |
106 | }; | |
107 | ||
9b3d3bc4 RD |
108 | |
109 | ||
9416aa89 | 110 | class wxToolBarToolBase : public wxObject { |
9b3d3bc4 RD |
111 | public: |
112 | // wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL, | |
113 | // int id = wxID_SEPARATOR, | |
b96c7a38 RD |
114 | // const wxString& label = wxEmptyString, |
115 | // const wxBitmap& bmpNormal = wxNullBitmap, | |
116 | // const wxBitmap& bmpDisabled = wxNullBitmap, | |
117 | // wxItemKind kind = wxITEM_NORMAL, | |
9b3d3bc4 | 118 | // wxObject *clientData = (wxObject *) NULL, |
b96c7a38 RD |
119 | // const wxString& shortHelpString = wxEmptyString, |
120 | // const wxString& longHelpString = wxEmptyString) | |
9b3d3bc4 RD |
121 | // ~wxToolBarToolBase(); |
122 | ||
123 | %addmethods { void Destroy() { delete self; } } | |
124 | ||
125 | int GetId(); | |
126 | wxControl *GetControl(); | |
127 | wxToolBarBase *GetToolBar(); | |
128 | int IsButton(); | |
129 | int IsControl(); | |
130 | int IsSeparator(); | |
131 | int GetStyle(); | |
b96c7a38 | 132 | wxItemKind GetKind(); |
9b3d3bc4 RD |
133 | bool IsEnabled(); |
134 | bool IsToggled(); | |
135 | bool CanBeToggled(); | |
c6ebc32a RD |
136 | const wxBitmap& GetNormalBitmap(); |
137 | const wxBitmap& GetDisabledBitmap(); | |
c5943253 | 138 | wxBitmap GetBitmap(); |
c6ebc32a | 139 | wxString GetLabel(); |
9b3d3bc4 RD |
140 | wxString GetShortHelp(); |
141 | wxString GetLongHelp(); | |
142 | bool Enable(bool enable); | |
c6ebc32a | 143 | void Toggle(); |
9b3d3bc4 RD |
144 | bool SetToggle(bool toggle); |
145 | bool SetShortHelp(const wxString& help); | |
146 | bool SetLongHelp(const wxString& help); | |
c6ebc32a RD |
147 | void SetNormalBitmap(const wxBitmap& bmp); |
148 | void SetDisabledBitmap(const wxBitmap& bmp); | |
149 | void SetLabel(const wxString& label); | |
9b3d3bc4 RD |
150 | void Detach(); |
151 | void Attach(wxToolBarBase *tbar); | |
152 | ||
153 | //wxObject *GetClientData(); | |
154 | %addmethods { | |
155 | // convert the ClientData back to a PyObject | |
156 | PyObject* GetClientData() { | |
157 | wxPyUserData* udata = (wxPyUserData*)self->GetClientData(); | |
158 | if (udata) { | |
159 | Py_INCREF(udata->m_obj); | |
160 | return udata->m_obj; | |
161 | } else { | |
162 | Py_INCREF(Py_None); | |
163 | return Py_None; | |
164 | } | |
165 | } | |
166 | ||
167 | void SetClientData(PyObject* clientData) { | |
168 | self->SetClientData(new wxPyUserData(clientData)); | |
169 | } | |
170 | } | |
c6ebc32a RD |
171 | |
172 | %pragma(python) addtoclass=" | |
173 | GetBitmap1 = GetNormalBitmap | |
174 | GetBitmap2 = GetDisabledBitmap | |
175 | SetBitmap1 = SetNormalBitmap | |
176 | SetBitmap2 = SetDisabledBitmap | |
177 | " | |
9b3d3bc4 RD |
178 | }; |
179 | ||
180 | ||
181 | ||
182 | class wxToolBarBase : public wxControl { | |
183 | public: | |
184 | ||
185 | // This is an Abstract Base Class | |
186 | ||
187 | %addmethods { | |
b96c7a38 | 188 | |
15030c51 RD |
189 | // The full AddTool() function. Call it DoAddTool in wxPython and |
190 | // implement the other Add methods by calling it. | |
b96c7a38 RD |
191 | // |
192 | // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap | |
193 | // is created and used as the disabled image. | |
15030c51 RD |
194 | wxToolBarToolBase *DoAddTool(int id, |
195 | const wxString& label, | |
196 | const wxBitmap& bitmap, | |
197 | const wxBitmap& bmpDisabled = wxNullBitmap, | |
198 | wxItemKind kind = wxITEM_NORMAL, | |
199 | const wxString& shortHelp = wxPyEmptyString, | |
200 | const wxString& longHelp = wxPyEmptyString, | |
201 | PyObject *clientData = NULL) | |
b96c7a38 | 202 | { |
9b3d3bc4 | 203 | wxPyUserData* udata = NULL; |
15030c51 | 204 | if (clientData && clientData != Py_None) |
9b3d3bc4 | 205 | udata = new wxPyUserData(clientData); |
b96c7a38 RD |
206 | return self->AddTool(id, label, bitmap, bmpDisabled, kind, |
207 | shortHelp, longHelp, udata); | |
9b3d3bc4 RD |
208 | } |
209 | ||
9b3d3bc4 | 210 | |
15030c51 RD |
211 | // Insert the new tool at the given position, if pos == GetToolsCount(), it |
212 | // is equivalent to DoAddTool() | |
1e4a197e | 213 | wxToolBarToolBase *DoInsertTool(size_t pos, |
9b3d3bc4 | 214 | int id, |
b96c7a38 | 215 | const wxString& label, |
9b3d3bc4 | 216 | const wxBitmap& bitmap, |
b96c7a38 RD |
217 | const wxBitmap& bmpDisabled = wxNullBitmap, |
218 | wxItemKind kind = wxITEM_NORMAL, | |
c12de7f8 RD |
219 | const wxString& shortHelp = wxPyEmptyString, |
220 | const wxString& longHelp = wxPyEmptyString, | |
b96c7a38 RD |
221 | PyObject *clientData = NULL) |
222 | { | |
9b3d3bc4 | 223 | wxPyUserData* udata = NULL; |
15030c51 | 224 | if (clientData && clientData != Py_None) |
9b3d3bc4 | 225 | udata = new wxPyUserData(clientData); |
b96c7a38 RD |
226 | return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind, |
227 | shortHelp, longHelp, udata); | |
9b3d3bc4 RD |
228 | } |
229 | ||
9b3d3bc4 RD |
230 | } |
231 | ||
232 | ||
15030c51 RD |
233 | %pragma(python) addtoclass = " |
234 | # These match the original Add methods for this class, kept for | |
235 | # backwards compatibility with versions < 2.3.3. | |
236 | ||
237 | ||
238 | def AddTool(self, id, bitmap, | |
239 | pushedBitmap = wxNullBitmap, | |
240 | isToggle = 0, | |
241 | clientData = None, | |
242 | shortHelpString = '', | |
243 | longHelpString = '') : | |
244 | '''Old style method to add a tool to the toolbar.''' | |
245 | kind = wx.wxITEM_NORMAL | |
246 | if isToggle: kind = wx.wxITEM_CHECK | |
247 | return self.DoAddTool(id, '', bitmap, pushedBitmap, kind, | |
248 | shortHelpString, longHelpString, clientData) | |
249 | ||
250 | def AddSimpleTool(self, id, bitmap, | |
251 | shortHelpString = '', | |
252 | longHelpString = '', | |
253 | isToggle = 0): | |
254 | '''Old style method to add a tool to the toolbar.''' | |
255 | kind = wx.wxITEM_NORMAL | |
256 | if isToggle: kind = wx.wxITEM_CHECK | |
257 | return self.DoAddTool(id, '', bitmap, wxNullBitmap, kind, | |
258 | shortHelpString, longHelpString, None) | |
259 | ||
260 | def InsertTool(self, pos, id, bitmap, | |
261 | pushedBitmap = wxNullBitmap, | |
262 | isToggle = 0, | |
263 | clientData = None, | |
264 | shortHelpString = '', | |
265 | longHelpString = ''): | |
266 | '''Old style method to insert a tool in the toolbar.''' | |
267 | kind = wx.wxITEM_NORMAL | |
268 | if isToggle: kind = wx.wxITEM_CHECK | |
269 | return self.DoInsertTool(pos, id, '', bitmap, pushedBitmap, kind, | |
270 | shortHelpString, longHelpString, clientData) | |
271 | ||
272 | def InsertSimpleTool(self, pos, id, bitmap, | |
273 | shortHelpString = '', | |
274 | longHelpString = '', | |
275 | isToggle = 0): | |
276 | '''Old style method to insert a tool in the toolbar.''' | |
277 | kind = wx.wxITEM_NORMAL | |
278 | if isToggle: kind = wx.wxITEM_CHECK | |
279 | return self.DoInsertTool(pos, id, '', bitmap, wxNullBitmap, kind, | |
280 | shortHelpString, longHelpString, None) | |
281 | ||
282 | ||
283 | # The following are the new toolbar Add methods starting with | |
284 | # 2.3.3. They are renamed to have 'Label' in the name so as to be | |
285 | # able to keep backwards compatibility with using the above | |
286 | # methods. Eventually these should migrate to be the methods used | |
1e4a197e | 287 | # primarily and lose the 'Label' in the name... |
15030c51 RD |
288 | |
289 | def AddLabelTool(self, id, label, bitmap, | |
290 | bmpDisabled = wxNullBitmap, | |
291 | kind = wxITEM_NORMAL, | |
292 | shortHelp = '', longHelp = '', | |
293 | clientData = None): | |
294 | ''' | |
295 | The full AddTool() function. | |
296 | ||
297 | If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap | |
298 | is created and used as the disabled image. | |
299 | ''' | |
300 | return self.DoAddTool(id, label, bitmap, bmpDisabled, kind, | |
301 | shortHelp, longHelp, clientData) | |
302 | ||
303 | ||
304 | def InsertLabelTool(self, pos, id, label, bitmap, | |
305 | bmpDisabled = wxNullBitmap, | |
306 | kind = wxITEM_NORMAL, | |
307 | shortHelp = '', longHelp = '', | |
308 | clientData = None): | |
309 | ''' | |
310 | Insert the new tool at the given position, if pos == GetToolsCount(), it | |
311 | is equivalent to AddTool() | |
312 | ''' | |
313 | return self.DoInsertTool(pos, id, label, bitmap, bmpDisabled, kind, | |
314 | shortHelp, longHelp, clientData) | |
315 | ||
316 | def AddCheckLabelTool(self, id, label, bitmap, | |
317 | bmpDisabled = wxNullBitmap, | |
318 | shortHelp = '', longHelp = '', | |
319 | clientData = None): | |
320 | '''Add a check tool, i.e. a tool which can be toggled''' | |
321 | return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.wxITEM_CHECK, | |
322 | shortHelp, longHelp, clientData) | |
323 | ||
324 | def AddRadioLabelTool(self, id, label, bitmap, | |
325 | bmpDisabled = wxNullBitmap, | |
326 | shortHelp = '', longHelp = '', | |
327 | clientData = None): | |
328 | ''' | |
329 | Add a radio tool, i.e. a tool which can be toggled and releases any | |
330 | other toggled radio tools in the same group when it happens | |
331 | ''' | |
332 | return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.wxITEM_RADIO, | |
333 | shortHelp, longHelp, clientData) | |
334 | ||
335 | ||
336 | # For consistency with the backwards compatible methods above, here are | |
337 | # some non-'Label' versions of the Check and Radio methods | |
338 | def AddCheckTool(self, id, bitmap, | |
339 | bmpDisabled = wxNullBitmap, | |
340 | shortHelp = '', longHelp = '', | |
341 | clientData = None): | |
342 | '''Add a check tool, i.e. a tool which can be toggled''' | |
343 | return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.wxITEM_CHECK, | |
344 | shortHelp, longHelp, clientData) | |
345 | ||
346 | def AddRadioTool(self, id, bitmap, | |
347 | bmpDisabled = wxNullBitmap, | |
348 | shortHelp = '', longHelp = '', | |
349 | clientData = None): | |
350 | ''' | |
351 | Add a radio tool, i.e. a tool which can be toggled and releases any | |
352 | other toggled radio tools in the same group when it happens | |
353 | ''' | |
354 | return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.wxITEM_RADIO, | |
355 | shortHelp, longHelp, clientData) | |
356 | " | |
357 | ||
9cbf6f6e RD |
358 | // TODO? |
359 | //wxToolBarToolBase *AddTool (wxToolBarToolBase *tool); | |
360 | //wxToolBarToolBase *InsertTool (size_t pos, wxToolBarToolBase *tool); | |
15030c51 | 361 | |
9b3d3bc4 RD |
362 | wxToolBarToolBase *AddControl(wxControl *control); |
363 | wxToolBarToolBase *InsertControl(size_t pos, wxControl *control); | |
fe953afb | 364 | wxControl *FindControl( int id ); |
9b3d3bc4 RD |
365 | |
366 | wxToolBarToolBase *AddSeparator(); | |
367 | wxToolBarToolBase *InsertSeparator(size_t pos); | |
368 | ||
369 | wxToolBarToolBase *RemoveTool(int id); | |
370 | ||
371 | bool DeleteToolByPos(size_t pos); | |
372 | bool DeleteTool(int id); | |
373 | void ClearTools(); | |
374 | bool Realize(); | |
375 | ||
376 | void EnableTool(int id, bool enable); | |
377 | void ToggleTool(int id, bool toggle); | |
378 | void SetToggle(int id, bool toggle); | |
379 | ||
380 | ||
381 | %addmethods { | |
382 | // convert the ClientData back to a PyObject | |
c6ebc32a RD |
383 | PyObject* GetToolClientData(int id) { |
384 | wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id); | |
9b3d3bc4 RD |
385 | if (udata) { |
386 | Py_INCREF(udata->m_obj); | |
387 | return udata->m_obj; | |
388 | } else { | |
389 | Py_INCREF(Py_None); | |
390 | return Py_None; | |
391 | } | |
392 | } | |
393 | ||
c6ebc32a RD |
394 | void SetToolClientData(int id, PyObject* clientData) { |
395 | self->SetToolClientData(id, new wxPyUserData(clientData)); | |
9b3d3bc4 RD |
396 | } |
397 | } | |
398 | ||
3ef86e32 RD |
399 | // returns tool pos, or wxNOT_FOUND if tool isn't found |
400 | int GetToolPos(int id) const; | |
9b3d3bc4 RD |
401 | |
402 | bool GetToolState(int id); | |
403 | bool GetToolEnabled(int id); | |
404 | void SetToolShortHelp(int id, const wxString& helpString); | |
405 | wxString GetToolShortHelp(int id); | |
406 | void SetToolLongHelp(int id, const wxString& helpString); | |
407 | wxString GetToolLongHelp(int id); | |
408 | ||
409 | %name(SetMarginsXY) void SetMargins(int x, int y); | |
410 | void SetMargins(const wxSize& size); | |
411 | void SetToolPacking(int packing); | |
412 | void SetToolSeparation(int separation); | |
413 | wxSize GetToolMargins(); | |
83b18bab | 414 | wxSize GetMargins(); |
9b3d3bc4 RD |
415 | int GetToolPacking(); |
416 | int GetToolSeparation(); | |
417 | ||
418 | void SetRows(int nRows); | |
419 | void SetMaxRowsCols(int rows, int cols); | |
420 | int GetMaxRows(); | |
421 | int GetMaxCols(); | |
422 | ||
423 | void SetToolBitmapSize(const wxSize& size); | |
424 | wxSize GetToolBitmapSize(); | |
425 | wxSize GetToolSize(); | |
426 | ||
c6ebc32a RD |
427 | // returns a (non separator) tool containing the point (x, y) or NULL if |
428 | // there is no tool at this point (corrdinates are client) | |
429 | wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y); | |
430 | ||
431 | // return TRUE if this is a vertical toolbar, otherwise FALSE | |
432 | bool IsVertical(); | |
9b3d3bc4 RD |
433 | }; |
434 | ||
435 | ||
436 | ||
437 | ||
438 | class wxToolBar : public wxToolBarBase { | |
439 | public: | |
440 | wxToolBar(wxWindow *parent, | |
441 | wxWindowID id, | |
b68dc582 RD |
442 | const wxPoint& pos = wxDefaultPosition, |
443 | const wxSize& size = wxDefaultSize, | |
9b3d3bc4 | 444 | long style = wxNO_BORDER | wxTB_HORIZONTAL, |
137b5242 | 445 | const wxString& name = wxPyToolBarNameStr); |
09f3d4e6 RD |
446 | %name(wxPreToolBar)wxToolBar(); |
447 | ||
448 | bool Create(wxWindow *parent, | |
449 | wxWindowID id, | |
450 | const wxPoint& pos = wxDefaultPosition, | |
451 | const wxSize& size = wxDefaultSize, | |
452 | long style = wxNO_BORDER | wxTB_HORIZONTAL, | |
137b5242 | 453 | const wxString& name = wxPyToolBarNameStr); |
9b3d3bc4 | 454 | |
0122b7e3 | 455 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 456 | %pragma(python) addtomethod = "wxPreToolBar:val._setOORInfo(val)" |
9b3d3bc4 RD |
457 | |
458 | wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y); | |
459 | }; | |
460 | ||
461 | ||
462 | ||
463 | ||
464 | class wxToolBarSimple : public wxToolBarBase { | |
465 | public: | |
466 | wxToolBarSimple(wxWindow *parent, | |
467 | wxWindowID id, | |
b68dc582 RD |
468 | const wxPoint& pos = wxDefaultPosition, |
469 | const wxSize& size = wxDefaultSize, | |
9b3d3bc4 | 470 | long style = wxNO_BORDER | wxTB_HORIZONTAL, |
137b5242 | 471 | const wxString& name = wxPyToolBarNameStr); |
09f3d4e6 RD |
472 | %name(wxPreToolBarSimple)wxToolBarSimple(); |
473 | ||
474 | bool Create(wxWindow *parent, | |
475 | wxWindowID id, | |
476 | const wxPoint& pos = wxDefaultPosition, | |
477 | const wxSize& size = wxDefaultSize, | |
478 | long style = wxNO_BORDER | wxTB_HORIZONTAL, | |
137b5242 | 479 | const wxString& name = wxPyToolBarNameStr); |
9b3d3bc4 | 480 | |
0122b7e3 | 481 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 482 | %pragma(python) addtomethod = "wxPreToolBarSimple:val._setOORInfo(val)" |
9b3d3bc4 RD |
483 | |
484 | wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y); | |
485 | }; | |
486 | ||
487 | //--------------------------------------------------------------------------- | |
9c039d08 RD |
488 | //--------------------------------------------------------------------------- |
489 |