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