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