]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_toolbar.i
reSWIGged
[wxWidgets.git] / wxPython / src / _toolbar.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _toolbar.i
3 // Purpose: SWIG interface defs for wxStatusBar
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 24-Aug-1998
8 // RCS-ID: $Id$
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17
18 %{
19 DECLARE_DEF_STRING(ToolBarNameStr);
20 %}
21
22 //---------------------------------------------------------------------------
23 %newgroup;
24
25
26 class wxToolBarBase;
27
28 enum wxToolBarToolStyle
29 {
30 wxTOOL_STYLE_BUTTON = 1,
31 wxTOOL_STYLE_SEPARATOR = 2,
32 wxTOOL_STYLE_CONTROL
33 };
34
35 enum {
36 wxTB_HORIZONTAL,
37 wxTB_VERTICAL,
38 wxTB_3DBUTTONS,
39 wxTB_FLAT,
40 wxTB_DOCKABLE,
41 wxTB_NOICONS,
42 wxTB_TEXT,
43 wxTB_NODIVIDER,
44 wxTB_NOALIGN,
45 wxTB_HORZ_LAYOUT,
46 wxTB_HORZ_TEXT,
47 };
48
49
50
51 // wxToolBarTool is a toolbar element.
52 //
53 // It has a unique id (except for the separators which always have id -1), the
54 // style (telling whether it is a normal button, separator or a control), the
55 // state (toggled or not, enabled or not) and short and long help strings. The
56 // default implementations use the short help string for the tooltip text which
57 // is popped up when the mouse pointer enters the tool and the long help string
58 // for the applications status bar.
59 class wxToolBarToolBase : public wxObject {
60 public:
61 // wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL,
62 // int id = wxID_SEPARATOR,
63 // const wxString& label = wxEmptyString,
64 // const wxBitmap& bmpNormal = wxNullBitmap,
65 // const wxBitmap& bmpDisabled = wxNullBitmap,
66 // wxItemKind kind = wxITEM_NORMAL,
67 // wxObject *clientData = (wxObject *) NULL,
68 // const wxString& shortHelpString = wxEmptyString,
69 // const wxString& longHelpString = wxEmptyString)
70 // ~wxToolBarToolBase();
71
72 int GetId();
73 wxControl *GetControl();
74 wxToolBarBase *GetToolBar();
75 int IsButton();
76 int IsControl();
77 int IsSeparator();
78 int GetStyle();
79 wxItemKind GetKind();
80 bool IsEnabled();
81 bool IsToggled();
82 bool CanBeToggled();
83 const wxBitmap& GetNormalBitmap();
84 const wxBitmap& GetDisabledBitmap();
85 wxBitmap GetBitmap();
86 wxString GetLabel();
87 wxString GetShortHelp();
88 wxString GetLongHelp();
89 bool Enable(bool enable);
90 void Toggle();
91 bool SetToggle(bool toggle);
92 bool SetShortHelp(const wxString& help);
93 bool SetLongHelp(const wxString& help);
94 void SetNormalBitmap(const wxBitmap& bmp);
95 void SetDisabledBitmap(const wxBitmap& bmp);
96 void SetLabel(const wxString& label);
97 void Detach();
98 void Attach(wxToolBarBase *tbar);
99
100 //wxObject *GetClientData();
101 %extend {
102 // convert the ClientData back to a PyObject
103 PyObject* GetClientData() {
104 wxPyUserData* udata = (wxPyUserData*)self->GetClientData();
105 if (udata) {
106 Py_INCREF(udata->m_obj);
107 return udata->m_obj;
108 } else {
109 Py_INCREF(Py_None);
110 return Py_None;
111 }
112 }
113
114 void SetClientData(PyObject* clientData) {
115 self->SetClientData(new wxPyUserData(clientData));
116 }
117 }
118
119 %pythoncode {
120 GetBitmap1 = GetNormalBitmap
121 GetBitmap2 = GetDisabledBitmap
122 SetBitmap1 = SetNormalBitmap
123 SetBitmap2 = SetDisabledBitmap
124 }
125 };
126
127
128
129
130 class wxToolBarBase : public wxControl {
131 public:
132
133 // This is an Abstract Base Class
134
135 %extend {
136
137 // The full AddTool() function. Call it DoAddTool in wxPython and
138 // implement the other Add methods by calling it.
139 //
140 // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
141 // is created and used as the disabled image.
142 wxToolBarToolBase *DoAddTool(int id,
143 const wxString& label,
144 const wxBitmap& bitmap,
145 const wxBitmap& bmpDisabled = wxNullBitmap,
146 wxItemKind kind = wxITEM_NORMAL,
147 const wxString& shortHelp = wxPyEmptyString,
148 const wxString& longHelp = wxPyEmptyString,
149 PyObject *clientData = NULL)
150 {
151 wxPyUserData* udata = NULL;
152 if (clientData && clientData != Py_None)
153 udata = new wxPyUserData(clientData);
154 return self->AddTool(id, label, bitmap, bmpDisabled, kind,
155 shortHelp, longHelp, udata);
156 }
157
158
159 // Insert the new tool at the given position, if pos == GetToolsCount(), it
160 // is equivalent to DoAddTool()
161 wxToolBarToolBase *DoInsertTool(size_t pos,
162 int id,
163 const wxString& label,
164 const wxBitmap& bitmap,
165 const wxBitmap& bmpDisabled = wxNullBitmap,
166 wxItemKind kind = wxITEM_NORMAL,
167 const wxString& shortHelp = wxPyEmptyString,
168 const wxString& longHelp = wxPyEmptyString,
169 PyObject *clientData = NULL)
170 {
171 wxPyUserData* udata = NULL;
172 if (clientData && clientData != Py_None)
173 udata = new wxPyUserData(clientData);
174 return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind,
175 shortHelp, longHelp, udata);
176 }
177
178 }
179
180
181 %pythoncode {
182 %# These match the original Add methods for this class, kept for
183 %# backwards compatibility with versions < 2.3.3.
184
185
186 def AddTool(self, id, bitmap,
187 pushedBitmap = wx.NullBitmap,
188 isToggle = 0,
189 clientData = None,
190 shortHelpString = '',
191 longHelpString = '') :
192 '''Old style method to add a tool to the toolbar.'''
193 kind = wx.ITEM_NORMAL
194 if isToggle: kind = wx.ITEM_CHECK
195 return self.DoAddTool(id, '', bitmap, pushedBitmap, kind,
196 shortHelpString, longHelpString, clientData)
197
198 def AddSimpleTool(self, id, bitmap,
199 shortHelpString = '',
200 longHelpString = '',
201 isToggle = 0):
202 '''Old style method to add a tool to the toolbar.'''
203 kind = wx.ITEM_NORMAL
204 if isToggle: kind = wx.ITEM_CHECK
205 return self.DoAddTool(id, '', bitmap, wx.NullBitmap, kind,
206 shortHelpString, longHelpString, None)
207
208 def InsertTool(self, pos, id, bitmap,
209 pushedBitmap = wx.NullBitmap,
210 isToggle = 0,
211 clientData = None,
212 shortHelpString = '',
213 longHelpString = ''):
214 '''Old style method to insert a tool in the toolbar.'''
215 kind = wx.ITEM_NORMAL
216 if isToggle: kind = wx.ITEM_CHECK
217 return self.DoInsertTool(pos, id, '', bitmap, pushedBitmap, kind,
218 shortHelpString, longHelpString, clientData)
219
220 def InsertSimpleTool(self, pos, id, bitmap,
221 shortHelpString = '',
222 longHelpString = '',
223 isToggle = 0):
224 '''Old style method to insert a tool in the toolbar.'''
225 kind = wx.ITEM_NORMAL
226 if isToggle: kind = wx.ITEM_CHECK
227 return self.DoInsertTool(pos, id, '', bitmap, wx.NullBitmap, kind,
228 shortHelpString, longHelpString, None)
229
230
231 %# The following are the new toolbar Add methods starting with
232 %# 2.3.3. They are renamed to have 'Label' in the name so as to be
233 %# able to keep backwards compatibility with using the above
234 %# methods. Eventually these should migrate to be the methods used
235 %# primarily and lose the 'Label' in the name...
236
237 def AddLabelTool(self, id, label, bitmap,
238 bmpDisabled = wx.NullBitmap,
239 kind = wx.ITEM_NORMAL,
240 shortHelp = '', longHelp = '',
241 clientData = None):
242 '''
243 The full AddTool() function.
244
245 If bmpDisabled is wx.NullBitmap, a shadowed version of the normal bitmap
246 is created and used as the disabled image.
247 '''
248 return self.DoAddTool(id, label, bitmap, bmpDisabled, kind,
249 shortHelp, longHelp, clientData)
250
251
252 def InsertLabelTool(self, pos, id, label, bitmap,
253 bmpDisabled = wx.NullBitmap,
254 kind = wx.ITEM_NORMAL,
255 shortHelp = '', longHelp = '',
256 clientData = None):
257 '''
258 Insert the new tool at the given position, if pos == GetToolsCount(), it
259 is equivalent to AddTool()
260 '''
261 return self.DoInsertTool(pos, id, label, bitmap, bmpDisabled, kind,
262 shortHelp, longHelp, clientData)
263
264 def AddCheckLabelTool(self, id, label, bitmap,
265 bmpDisabled = wx.NullBitmap,
266 shortHelp = '', longHelp = '',
267 clientData = None):
268 '''Add a check tool, i.e. a tool which can be toggled'''
269 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_CHECK,
270 shortHelp, longHelp, clientData)
271
272 def AddRadioLabelTool(self, id, label, bitmap,
273 bmpDisabled = wx.NullBitmap,
274 shortHelp = '', longHelp = '',
275 clientData = None):
276 '''
277 Add a radio tool, i.e. a tool which can be toggled and releases any
278 other toggled radio tools in the same group when it happens
279 '''
280 return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_RADIO,
281 shortHelp, longHelp, clientData)
282
283
284 %# For consistency with the backwards compatible methods above, here are
285 %# some non-'Label' versions of the Check and Radio methods
286 def AddCheckTool(self, id, bitmap,
287 bmpDisabled = wx.NullBitmap,
288 shortHelp = '', longHelp = '',
289 clientData = None):
290 '''Add a check tool, i.e. a tool which can be toggled'''
291 return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.ITEM_CHECK,
292 shortHelp, longHelp, clientData)
293
294 def AddRadioTool(self, id, bitmap,
295 bmpDisabled = wx.NullBitmap,
296 shortHelp = '', longHelp = '',
297 clientData = None):
298 '''
299 Add a radio tool, i.e. a tool which can be toggled and releases any
300 other toggled radio tools in the same group when it happens
301 '''
302 return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.ITEM_RADIO,
303 shortHelp, longHelp, clientData)
304 }
305
306 // TODO?
307 //wxToolBarToolBase *AddTool (wxToolBarToolBase *tool);
308 //wxToolBarToolBase *InsertTool (size_t pos, wxToolBarToolBase *tool);
309
310 wxToolBarToolBase *AddControl(wxControl *control);
311 wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
312 wxControl *FindControl( int id );
313
314 wxToolBarToolBase *AddSeparator();
315 wxToolBarToolBase *InsertSeparator(size_t pos);
316
317 wxToolBarToolBase *RemoveTool(int id);
318
319 bool DeleteToolByPos(size_t pos);
320 bool DeleteTool(int id);
321 void ClearTools();
322 bool Realize();
323
324 void EnableTool(int id, bool enable);
325 void ToggleTool(int id, bool toggle);
326 void SetToggle(int id, bool toggle);
327
328
329 %extend {
330 // convert the ClientData back to a PyObject
331 PyObject* GetToolClientData(int id) {
332 wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
333 if (udata) {
334 Py_INCREF(udata->m_obj);
335 return udata->m_obj;
336 } else {
337 Py_INCREF(Py_None);
338 return Py_None;
339 }
340 }
341
342 void SetToolClientData(int id, PyObject* clientData) {
343 self->SetToolClientData(id, new wxPyUserData(clientData));
344 }
345 }
346
347 // returns tool pos, or wxNOT_FOUND if tool isn't found
348 int GetToolPos(int id) const;
349
350 bool GetToolState(int id);
351 bool GetToolEnabled(int id);
352 void SetToolShortHelp(int id, const wxString& helpString);
353 wxString GetToolShortHelp(int id);
354 void SetToolLongHelp(int id, const wxString& helpString);
355 wxString GetToolLongHelp(int id);
356
357 %name(SetMarginsXY) void SetMargins(int x, int y);
358 void SetMargins(const wxSize& size);
359 void SetToolPacking(int packing);
360 void SetToolSeparation(int separation);
361 wxSize GetToolMargins();
362 wxSize GetMargins();
363 int GetToolPacking();
364 int GetToolSeparation();
365
366 void SetRows(int nRows);
367 void SetMaxRowsCols(int rows, int cols);
368 int GetMaxRows();
369 int GetMaxCols();
370
371 void SetToolBitmapSize(const wxSize& size);
372 wxSize GetToolBitmapSize();
373 wxSize GetToolSize();
374
375 // returns a (non separator) tool containing the point (x, y) or NULL if
376 // there is no tool at this point (corrdinates are client)
377 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
378
379 // return True if this is a vertical toolbar, otherwise False
380 bool IsVertical();
381 };
382
383
384
385
386 class wxToolBar : public wxToolBarBase {
387 public:
388 %addtofunc wxToolBar "self._setOORInfo(self)"
389 %addtofunc wxToolBar() ""
390
391 wxToolBar(wxWindow *parent,
392 wxWindowID id,
393 const wxPoint& pos = wxDefaultPosition,
394 const wxSize& size = wxDefaultSize,
395 long style = wxNO_BORDER | wxTB_HORIZONTAL,
396 const wxString& name = wxPyToolBarNameStr);
397 %name(PreToolBar)wxToolBar();
398
399 bool Create(wxWindow *parent,
400 wxWindowID id,
401 const wxPoint& pos = wxDefaultPosition,
402 const wxSize& size = wxDefaultSize,
403 long style = wxNO_BORDER | wxTB_HORIZONTAL,
404 const wxString& name = wxPyToolBarNameStr);
405
406 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
407 };
408
409 //---------------------------------------------------------------------------