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