]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/stattool.i
implement wxColourDialog::Move() (patch 548048)
[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);
26b9cf27 76 void SetMinHeight(int height);
9c039d08
RD
77};
78
79
80//---------------------------------------------------------------------------
81
9b3d3bc4
RD
82class wxToolBarBase;
83
84enum wxToolBarToolStyle
85{
86 wxTOOL_STYLE_BUTTON = 1,
87 wxTOOL_STYLE_SEPARATOR = 2,
88 wxTOOL_STYLE_CONTROL
89};
90
91
92
9416aa89 93class wxToolBarToolBase : public wxObject {
9b3d3bc4
RD
94public:
95// wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL,
96// int id = wxID_SEPARATOR,
b96c7a38
RD
97// const wxString& label = wxEmptyString,
98// const wxBitmap& bmpNormal = wxNullBitmap,
99// const wxBitmap& bmpDisabled = wxNullBitmap,
100// wxItemKind kind = wxITEM_NORMAL,
9b3d3bc4 101// wxObject *clientData = (wxObject *) NULL,
b96c7a38
RD
102// const wxString& shortHelpString = wxEmptyString,
103// const wxString& longHelpString = wxEmptyString)
9b3d3bc4
RD
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();
b96c7a38 115 wxItemKind GetKind();
9b3d3bc4
RD
116 bool IsEnabled();
117 bool IsToggled();
118 bool CanBeToggled();
c6ebc32a
RD
119 const wxBitmap& GetNormalBitmap();
120 const wxBitmap& GetDisabledBitmap();
c5943253 121 wxBitmap GetBitmap();
c6ebc32a 122 wxString GetLabel();
9b3d3bc4
RD
123 wxString GetShortHelp();
124 wxString GetLongHelp();
125 bool Enable(bool enable);
c6ebc32a 126 void Toggle();
9b3d3bc4
RD
127 bool SetToggle(bool toggle);
128 bool SetShortHelp(const wxString& help);
129 bool SetLongHelp(const wxString& help);
c6ebc32a
RD
130 void SetNormalBitmap(const wxBitmap& bmp);
131 void SetDisabledBitmap(const wxBitmap& bmp);
132 void SetLabel(const wxString& label);
9b3d3bc4
RD
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 }
c6ebc32a
RD
154
155 %pragma(python) addtoclass="
156 GetBitmap1 = GetNormalBitmap
157 GetBitmap2 = GetDisabledBitmap
158 SetBitmap1 = SetNormalBitmap
159 SetBitmap2 = SetDisabledBitmap
160 "
9b3d3bc4
RD
161};
162
163
164
165class wxToolBarBase : public wxControl {
166public:
167
168 // This is an Abstract Base Class
169
170 %addmethods {
b96c7a38 171
15030c51
RD
172 // The full AddTool() function. Call it DoAddTool in wxPython and
173 // implement the other Add methods by calling it.
b96c7a38
RD
174 //
175 // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
176 // is created and used as the disabled image.
15030c51
RD
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)
b96c7a38 185 {
9b3d3bc4 186 wxPyUserData* udata = NULL;
15030c51 187 if (clientData && clientData != Py_None)
9b3d3bc4 188 udata = new wxPyUserData(clientData);
b96c7a38
RD
189 return self->AddTool(id, label, bitmap, bmpDisabled, kind,
190 shortHelp, longHelp, udata);
9b3d3bc4
RD
191 }
192
9b3d3bc4 193
15030c51
RD
194 // Insert the new tool at the given position, if pos == GetToolsCount(), it
195 // is equivalent to DoAddTool()
9b3d3bc4
RD
196 wxToolBarToolBase *InsertTool(size_t pos,
197 int id,
b96c7a38 198 const wxString& label,
9b3d3bc4 199 const wxBitmap& bitmap,
b96c7a38
RD
200 const wxBitmap& bmpDisabled = wxNullBitmap,
201 wxItemKind kind = wxITEM_NORMAL,
c12de7f8
RD
202 const wxString& shortHelp = wxPyEmptyString,
203 const wxString& longHelp = wxPyEmptyString,
b96c7a38
RD
204 PyObject *clientData = NULL)
205 {
9b3d3bc4 206 wxPyUserData* udata = NULL;
15030c51 207 if (clientData && clientData != Py_None)
9b3d3bc4 208 udata = new wxPyUserData(clientData);
b96c7a38
RD
209 return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind,
210 shortHelp, longHelp, udata);
9b3d3bc4
RD
211 }
212
9b3d3bc4
RD
213 }
214
215
15030c51
RD
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
9b3d3bc4
RD
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
c6ebc32a
RD
362 PyObject* GetToolClientData(int id) {
363 wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
9b3d3bc4
RD
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
c6ebc32a
RD
373 void SetToolClientData(int id, PyObject* clientData) {
374 self->SetToolClientData(id, new wxPyUserData(clientData));
9b3d3bc4
RD
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();
83b18bab 391 wxSize GetMargins();
9b3d3bc4
RD
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
c6ebc32a
RD
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();
9b3d3bc4
RD
410};
411
412
413
414
415class wxToolBar : public wxToolBarBase {
416public:
417 wxToolBar(wxWindow *parent,
418 wxWindowID id,
b68dc582
RD
419 const wxPoint& pos = wxDefaultPosition,
420 const wxSize& size = wxDefaultSize,
9b3d3bc4 421 long style = wxNO_BORDER | wxTB_HORIZONTAL,
137b5242 422 const wxString& name = wxPyToolBarNameStr);
09f3d4e6
RD
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,
137b5242 430 const wxString& name = wxPyToolBarNameStr);
9b3d3bc4 431
0122b7e3 432 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 433 %pragma(python) addtomethod = "wxPreToolBar:val._setOORInfo(val)"
9b3d3bc4
RD
434
435 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
436};
437
438
439
440
441class wxToolBarSimple : public wxToolBarBase {
442public:
443 wxToolBarSimple(wxWindow *parent,
444 wxWindowID id,
b68dc582
RD
445 const wxPoint& pos = wxDefaultPosition,
446 const wxSize& size = wxDefaultSize,
9b3d3bc4 447 long style = wxNO_BORDER | wxTB_HORIZONTAL,
137b5242 448 const wxString& name = wxPyToolBarNameStr);
09f3d4e6
RD
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,
137b5242 456 const wxString& name = wxPyToolBarNameStr);
9b3d3bc4 457
0122b7e3 458 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 459 %pragma(python) addtomethod = "wxPreToolBarSimple:val._setOORInfo(val)"
9b3d3bc4
RD
460
461 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
462};
463
464//---------------------------------------------------------------------------
9c039d08
RD
465//---------------------------------------------------------------------------
466