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