]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/stattool.i
Commented out wxToolBarSimple since it is fully deprecated now.
[wxWidgets.git] / wxPython / src / stattool.i
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
33 %pragma(python) code = "import wx"
34 %pragma(python) code = "wxITEM_NORMAL = 0 # predeclare this since wx isn't fully imported yet"
35
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
45 //---------------------------------------------------------------------------
46
47 class wxStatusBar : public wxWindow {
48 public:
49 wxStatusBar(wxWindow* parent, wxWindowID id = -1,
50 long style = wxST_SIZEGRIP,
51 const wxString& name = wxPyStatusLineNameStr);
52 %name(wxPreStatusBar)wxStatusBar();
53
54 bool Create(wxWindow* parent, wxWindowID id,
55 long style = wxST_SIZEGRIP,
56 const wxString& name = wxPyStatusLineNameStr);
57
58 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
59 %pragma(python) addtomethod = "wxPreStatusBar:val._setOORInfo(val)"
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);
70 int GetBorderX();
71 int GetBorderY();
72
73 void SetFieldsCount(int number = 1);
74 void SetStatusText(const wxString& text, int i = 0);
75 void SetStatusWidths(int LCOUNT, int* choices);
76 void PushStatusText(const wxString& text, int number = 0);
77 void PopStatusText(int number = 0);
78
79 void SetMinHeight(int height);
80 };
81
82
83 //---------------------------------------------------------------------------
84
85 class wxToolBarBase;
86
87 enum wxToolBarToolStyle
88 {
89 wxTOOL_STYLE_BUTTON = 1,
90 wxTOOL_STYLE_SEPARATOR = 2,
91 wxTOOL_STYLE_CONTROL
92 };
93
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
108
109
110 class wxToolBarToolBase : public wxObject {
111 public:
112 // wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL,
113 // int id = wxID_SEPARATOR,
114 // const wxString& label = wxEmptyString,
115 // const wxBitmap& bmpNormal = wxNullBitmap,
116 // const wxBitmap& bmpDisabled = wxNullBitmap,
117 // wxItemKind kind = wxITEM_NORMAL,
118 // wxObject *clientData = (wxObject *) NULL,
119 // const wxString& shortHelpString = wxEmptyString,
120 // const wxString& longHelpString = wxEmptyString)
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();
132 wxItemKind GetKind();
133 bool IsEnabled();
134 bool IsToggled();
135 bool CanBeToggled();
136 const wxBitmap& GetNormalBitmap();
137 const wxBitmap& GetDisabledBitmap();
138 wxBitmap GetBitmap();
139 wxString GetLabel();
140 wxString GetShortHelp();
141 wxString GetLongHelp();
142 bool Enable(bool enable);
143 void Toggle();
144 bool SetToggle(bool toggle);
145 bool SetShortHelp(const wxString& help);
146 bool SetLongHelp(const wxString& help);
147 void SetNormalBitmap(const wxBitmap& bmp);
148 void SetDisabledBitmap(const wxBitmap& bmp);
149 void SetLabel(const wxString& label);
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 }
171
172 %pragma(python) addtoclass="
173 GetBitmap1 = GetNormalBitmap
174 GetBitmap2 = GetDisabledBitmap
175 SetBitmap1 = SetNormalBitmap
176 SetBitmap2 = SetDisabledBitmap
177 "
178 };
179
180
181
182 class wxToolBarBase : public wxControl {
183 public:
184
185 // This is an Abstract Base Class
186
187 %addmethods {
188
189 // The full AddTool() function. Call it DoAddTool in wxPython and
190 // implement the other Add methods by calling it.
191 //
192 // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
193 // is created and used as the disabled image.
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)
202 {
203 wxPyUserData* udata = NULL;
204 if (clientData && clientData != Py_None)
205 udata = new wxPyUserData(clientData);
206 return self->AddTool(id, label, bitmap, bmpDisabled, kind,
207 shortHelp, longHelp, udata);
208 }
209
210
211 // Insert the new tool at the given position, if pos == GetToolsCount(), it
212 // is equivalent to DoAddTool()
213 wxToolBarToolBase *DoInsertTool(size_t pos,
214 int id,
215 const wxString& label,
216 const wxBitmap& bitmap,
217 const wxBitmap& bmpDisabled = wxNullBitmap,
218 wxItemKind kind = wxITEM_NORMAL,
219 const wxString& shortHelp = wxPyEmptyString,
220 const wxString& longHelp = wxPyEmptyString,
221 PyObject *clientData = NULL)
222 {
223 wxPyUserData* udata = NULL;
224 if (clientData && clientData != Py_None)
225 udata = new wxPyUserData(clientData);
226 return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind,
227 shortHelp, longHelp, udata);
228 }
229
230 }
231
232
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
287 # primarily and lose the 'Label' in the name...
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
358 // TODO?
359 //wxToolBarToolBase *AddTool (wxToolBarToolBase *tool);
360 //wxToolBarToolBase *InsertTool (size_t pos, wxToolBarToolBase *tool);
361
362 wxToolBarToolBase *AddControl(wxControl *control);
363 wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
364 wxControl *FindControl( int id );
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
383 PyObject* GetToolClientData(int id) {
384 wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
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
394 void SetToolClientData(int id, PyObject* clientData) {
395 self->SetToolClientData(id, new wxPyUserData(clientData));
396 }
397 }
398
399 // returns tool pos, or wxNOT_FOUND if tool isn't found
400 int GetToolPos(int id) const;
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();
414 wxSize GetMargins();
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
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();
433 };
434
435
436
437
438 class wxToolBar : public wxToolBarBase {
439 public:
440 wxToolBar(wxWindow *parent,
441 wxWindowID id,
442 const wxPoint& pos = wxDefaultPosition,
443 const wxSize& size = wxDefaultSize,
444 long style = wxNO_BORDER | wxTB_HORIZONTAL,
445 const wxString& name = wxPyToolBarNameStr);
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,
453 const wxString& name = wxPyToolBarNameStr);
454
455 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
456 %pragma(python) addtomethod = "wxPreToolBar:val._setOORInfo(val)"
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,
468 // const wxPoint& pos = wxDefaultPosition,
469 // const wxSize& size = wxDefaultSize,
470 // long style = wxNO_BORDER | wxTB_HORIZONTAL,
471 // const wxString& name = wxPyToolBarNameStr);
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,
479 // const wxString& name = wxPyToolBarNameStr);
480
481 // %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
482 // %pragma(python) addtomethod = "wxPreToolBarSimple:val._setOORInfo(val)"
483
484 // wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
485 // };
486
487 //---------------------------------------------------------------------------
488 //---------------------------------------------------------------------------
489