]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/stattool.i
Committing in .
[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 SetMinHeight(int height);
77 };
78
79
80 //---------------------------------------------------------------------------
81
82 class wxToolBarBase;
83
84 enum wxToolBarToolStyle
85 {
86 wxTOOL_STYLE_BUTTON = 1,
87 wxTOOL_STYLE_SEPARATOR = 2,
88 wxTOOL_STYLE_CONTROL
89 };
90
91
92
93 class wxToolBarToolBase : public wxObject {
94 public:
95 // wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL,
96 // int id = wxID_SEPARATOR,
97 // const wxString& label = wxEmptyString,
98 // const wxBitmap& bmpNormal = wxNullBitmap,
99 // const wxBitmap& bmpDisabled = wxNullBitmap,
100 // wxItemKind kind = wxITEM_NORMAL,
101 // wxObject *clientData = (wxObject *) NULL,
102 // const wxString& shortHelpString = wxEmptyString,
103 // const wxString& longHelpString = wxEmptyString)
104 // ~wxToolBarToolBase();
105
106 %addmethods { void Destroy() { delete self; } }
107
108 int GetId();
109 wxControl *GetControl();
110 wxToolBarBase *GetToolBar();
111 int IsButton();
112 int IsControl();
113 int IsSeparator();
114 int GetStyle();
115 wxItemKind GetKind();
116 bool IsEnabled();
117 bool IsToggled();
118 bool CanBeToggled();
119 const wxBitmap& GetNormalBitmap();
120 const wxBitmap& GetDisabledBitmap();
121 wxBitmap GetBitmap();
122 wxString GetLabel();
123 wxString GetShortHelp();
124 wxString GetLongHelp();
125 bool Enable(bool enable);
126 void Toggle();
127 bool SetToggle(bool toggle);
128 bool SetShortHelp(const wxString& help);
129 bool SetLongHelp(const wxString& help);
130 void SetNormalBitmap(const wxBitmap& bmp);
131 void SetDisabledBitmap(const wxBitmap& bmp);
132 void SetLabel(const wxString& label);
133 void Detach();
134 void Attach(wxToolBarBase *tbar);
135
136 //wxObject *GetClientData();
137 %addmethods {
138 // convert the ClientData back to a PyObject
139 PyObject* GetClientData() {
140 wxPyUserData* udata = (wxPyUserData*)self->GetClientData();
141 if (udata) {
142 Py_INCREF(udata->m_obj);
143 return udata->m_obj;
144 } else {
145 Py_INCREF(Py_None);
146 return Py_None;
147 }
148 }
149
150 void SetClientData(PyObject* clientData) {
151 self->SetClientData(new wxPyUserData(clientData));
152 }
153 }
154
155 %pragma(python) addtoclass="
156 GetBitmap1 = GetNormalBitmap
157 GetBitmap2 = GetDisabledBitmap
158 SetBitmap1 = SetNormalBitmap
159 SetBitmap2 = SetDisabledBitmap
160 "
161 };
162
163
164
165 class wxToolBarBase : public wxControl {
166 public:
167
168 // This is an Abstract Base Class
169
170 %addmethods {
171
172 // The full AddTool() function. Call it DoAddTool in wxPython and
173 // implement the other Add methods by calling it.
174 //
175 // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
176 // is created and used as the disabled image.
177 wxToolBarToolBase *DoAddTool(int id,
178 const wxString& label,
179 const wxBitmap& bitmap,
180 const wxBitmap& bmpDisabled = wxNullBitmap,
181 wxItemKind kind = wxITEM_NORMAL,
182 const wxString& shortHelp = wxPyEmptyString,
183 const wxString& longHelp = wxPyEmptyString,
184 PyObject *clientData = NULL)
185 {
186 wxPyUserData* udata = NULL;
187 if (clientData && clientData != Py_None)
188 udata = new wxPyUserData(clientData);
189 return self->AddTool(id, label, bitmap, bmpDisabled, kind,
190 shortHelp, longHelp, udata);
191 }
192
193
194 // Insert the new tool at the given position, if pos == GetToolsCount(), it
195 // is equivalent to DoAddTool()
196 wxToolBarToolBase *InsertTool(size_t pos,
197 int id,
198 const wxString& label,
199 const wxBitmap& bitmap,
200 const wxBitmap& bmpDisabled = wxNullBitmap,
201 wxItemKind kind = wxITEM_NORMAL,
202 const wxString& shortHelp = wxPyEmptyString,
203 const wxString& longHelp = wxPyEmptyString,
204 PyObject *clientData = NULL)
205 {
206 wxPyUserData* udata = NULL;
207 if (clientData && clientData != Py_None)
208 udata = new wxPyUserData(clientData);
209 return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind,
210 shortHelp, longHelp, udata);
211 }
212
213 }
214
215
216 %pragma(python) addtoclass = "
217 # These match the original Add methods for this class, kept for
218 # backwards compatibility with versions < 2.3.3.
219
220
221 def AddTool(self, id, bitmap,
222 pushedBitmap = wxNullBitmap,
223 isToggle = 0,
224 clientData = None,
225 shortHelpString = '',
226 longHelpString = '') :
227 '''Old style method to add a tool to the toolbar.'''
228 kind = wx.wxITEM_NORMAL
229 if isToggle: kind = wx.wxITEM_CHECK
230 return self.DoAddTool(id, '', bitmap, pushedBitmap, kind,
231 shortHelpString, longHelpString, clientData)
232
233 def AddSimpleTool(self, id, bitmap,
234 shortHelpString = '',
235 longHelpString = '',
236 isToggle = 0):
237 '''Old style method to add a tool to the toolbar.'''
238 kind = wx.wxITEM_NORMAL
239 if isToggle: kind = wx.wxITEM_CHECK
240 return self.DoAddTool(id, '', bitmap, wxNullBitmap, kind,
241 shortHelpString, longHelpString, None)
242
243 def InsertTool(self, pos, id, bitmap,
244 pushedBitmap = wxNullBitmap,
245 isToggle = 0,
246 clientData = None,
247 shortHelpString = '',
248 longHelpString = ''):
249 '''Old style method to insert a tool in the toolbar.'''
250 kind = wx.wxITEM_NORMAL
251 if isToggle: kind = wx.wxITEM_CHECK
252 return self.DoInsertTool(pos, id, '', bitmap, pushedBitmap, kind,
253 shortHelpString, longHelpString, clientData)
254
255 def InsertSimpleTool(self, pos, id, bitmap,
256 shortHelpString = '',
257 longHelpString = '',
258 isToggle = 0):
259 '''Old style method to insert a tool in the toolbar.'''
260 kind = wx.wxITEM_NORMAL
261 if isToggle: kind = wx.wxITEM_CHECK
262 return self.DoInsertTool(pos, id, '', bitmap, wxNullBitmap, kind,
263 shortHelpString, longHelpString, None)
264
265
266 # The following are the new toolbar Add methods starting with
267 # 2.3.3. They are renamed to have 'Label' in the name so as to be
268 # able to keep backwards compatibility with using the above
269 # methods. Eventually these should migrate to be the methods used
270 # primarily and loose the 'Label' in the name...
271
272 def AddLabelTool(self, id, label, bitmap,
273 bmpDisabled = wxNullBitmap,
274 kind = wxITEM_NORMAL,
275 shortHelp = '', longHelp = '',
276 clientData = None):
277 '''
278 The full AddTool() function.
279
280 If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
281 is created and used as the disabled image.
282 '''
283 return self.DoAddTool(id, label, bitmap, bmpDisabled, kind,
284 shortHelp, longHelp, clientData)
285
286
287 def InsertLabelTool(self, pos, id, label, bitmap,
288 bmpDisabled = wxNullBitmap,
289 kind = wxITEM_NORMAL,
290 shortHelp = '', longHelp = '',
291 clientData = None):
292 '''
293 Insert the new tool at the given position, if pos == GetToolsCount(), it
294 is equivalent to AddTool()
295 '''
296 return self.DoInsertTool(pos, id, label, bitmap, bmpDisabled, kind,
297 shortHelp, longHelp, clientData)
298
299 def AddCheckLabelTool(self, id, label, bitmap,
300 bmpDisabled = wxNullBitmap,
301 shortHelp = '', longHelp = '',
302 clientData = None):
303 '''Add a check tool, i.e. a tool which can be toggled'''
304 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.wxITEM_CHECK,
305 shortHelp, longHelp, clientData)
306
307 def AddRadioLabelTool(self, id, label, bitmap,
308 bmpDisabled = wxNullBitmap,
309 shortHelp = '', longHelp = '',
310 clientData = None):
311 '''
312 Add a radio tool, i.e. a tool which can be toggled and releases any
313 other toggled radio tools in the same group when it happens
314 '''
315 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.wxITEM_RADIO,
316 shortHelp, longHelp, clientData)
317
318
319 # For consistency with the backwards compatible methods above, here are
320 # some non-'Label' versions of the Check and Radio methods
321 def AddCheckTool(self, id, bitmap,
322 bmpDisabled = wxNullBitmap,
323 shortHelp = '', longHelp = '',
324 clientData = None):
325 '''Add a check tool, i.e. a tool which can be toggled'''
326 return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.wxITEM_CHECK,
327 shortHelp, longHelp, clientData)
328
329 def AddRadioTool(self, id, bitmap,
330 bmpDisabled = wxNullBitmap,
331 shortHelp = '', longHelp = '',
332 clientData = None):
333 '''
334 Add a radio tool, i.e. a tool which can be toggled and releases any
335 other toggled radio tools in the same group when it happens
336 '''
337 return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.wxITEM_RADIO,
338 shortHelp, longHelp, clientData)
339 "
340
341
342 wxToolBarToolBase *AddControl(wxControl *control);
343 wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
344
345 wxToolBarToolBase *AddSeparator();
346 wxToolBarToolBase *InsertSeparator(size_t pos);
347
348 wxToolBarToolBase *RemoveTool(int id);
349
350 bool DeleteToolByPos(size_t pos);
351 bool DeleteTool(int id);
352 void ClearTools();
353 bool Realize();
354
355 void EnableTool(int id, bool enable);
356 void ToggleTool(int id, bool toggle);
357 void SetToggle(int id, bool toggle);
358
359
360 %addmethods {
361 // convert the ClientData back to a PyObject
362 PyObject* GetToolClientData(int id) {
363 wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
364 if (udata) {
365 Py_INCREF(udata->m_obj);
366 return udata->m_obj;
367 } else {
368 Py_INCREF(Py_None);
369 return Py_None;
370 }
371 }
372
373 void SetToolClientData(int id, PyObject* clientData) {
374 self->SetToolClientData(id, new wxPyUserData(clientData));
375 }
376 }
377
378
379 bool GetToolState(int id);
380 bool GetToolEnabled(int id);
381 void SetToolShortHelp(int id, const wxString& helpString);
382 wxString GetToolShortHelp(int id);
383 void SetToolLongHelp(int id, const wxString& helpString);
384 wxString GetToolLongHelp(int id);
385
386 %name(SetMarginsXY) void SetMargins(int x, int y);
387 void SetMargins(const wxSize& size);
388 void SetToolPacking(int packing);
389 void SetToolSeparation(int separation);
390 wxSize GetToolMargins();
391 wxSize GetMargins();
392 int GetToolPacking();
393 int GetToolSeparation();
394
395 void SetRows(int nRows);
396 void SetMaxRowsCols(int rows, int cols);
397 int GetMaxRows();
398 int GetMaxCols();
399
400 void SetToolBitmapSize(const wxSize& size);
401 wxSize GetToolBitmapSize();
402 wxSize GetToolSize();
403
404 // returns a (non separator) tool containing the point (x, y) or NULL if
405 // there is no tool at this point (corrdinates are client)
406 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
407
408 // return TRUE if this is a vertical toolbar, otherwise FALSE
409 bool IsVertical();
410 };
411
412
413
414
415 class wxToolBar : public wxToolBarBase {
416 public:
417 wxToolBar(wxWindow *parent,
418 wxWindowID id,
419 const wxPoint& pos = wxDefaultPosition,
420 const wxSize& size = wxDefaultSize,
421 long style = wxNO_BORDER | wxTB_HORIZONTAL,
422 const wxString& name = wxPyToolBarNameStr);
423 %name(wxPreToolBar)wxToolBar();
424
425 bool Create(wxWindow *parent,
426 wxWindowID id,
427 const wxPoint& pos = wxDefaultPosition,
428 const wxSize& size = wxDefaultSize,
429 long style = wxNO_BORDER | wxTB_HORIZONTAL,
430 const wxString& name = wxPyToolBarNameStr);
431
432 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
433 %pragma(python) addtomethod = "wxPreToolBar:val._setOORInfo(val)"
434
435 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
436 };
437
438
439
440
441 class wxToolBarSimple : public wxToolBarBase {
442 public:
443 wxToolBarSimple(wxWindow *parent,
444 wxWindowID id,
445 const wxPoint& pos = wxDefaultPosition,
446 const wxSize& size = wxDefaultSize,
447 long style = wxNO_BORDER | wxTB_HORIZONTAL,
448 const wxString& name = wxPyToolBarNameStr);
449 %name(wxPreToolBarSimple)wxToolBarSimple();
450
451 bool Create(wxWindow *parent,
452 wxWindowID id,
453 const wxPoint& pos = wxDefaultPosition,
454 const wxSize& size = wxDefaultSize,
455 long style = wxNO_BORDER | wxTB_HORIZONTAL,
456 const wxString& name = wxPyToolBarNameStr);
457
458 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
459 %pragma(python) addtomethod = "wxPreToolBarSimple:val._setOORInfo(val)"
460
461 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
462 };
463
464 //---------------------------------------------------------------------------
465 //---------------------------------------------------------------------------
466