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