]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_toolbar.i
remove obsolete color cube and image to bitmap code
[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 };
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 = wxPyEmptyString,
64 // const wxBitmap& bmpNormal = wxNullBitmap,
65 // const wxBitmap& bmpDisabled = wxNullBitmap,
66 // wxItemKind kind = wxITEM_NORMAL,
67 // wxObject *clientData = (wxObject *) NULL,
68 // const wxString& shortHelpString = wxPyEmptyString,
69 // const wxString& longHelpString = wxPyEmptyString)
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
287 def AddCheckTool(self, id, 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, '', bitmap, bmpDisabled, wx.ITEM_CHECK,
293 shortHelp, longHelp, clientData)
294
295 def AddRadioTool(self, id, 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, '', bitmap, bmpDisabled, wx.ITEM_RADIO,
304 shortHelp, longHelp, clientData)
305 }
306
307 %Rename(AddToolItem, wxToolBarToolBase*, AddTool (wxToolBarToolBase *tool));
308 %Rename(InsertToolItem, 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 %Rename(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 // find the tool by id
380 wxToolBarToolBase *FindById(int toolid) const;
381
382 // return True if this is a vertical toolbar, otherwise False
383 bool IsVertical();
384
385 size_t GetToolsCount() const;
386 };
387
388
389
390
391 MustHaveApp(wxToolBar);
392
393 class wxToolBar : public wxToolBarBase {
394 public:
395 %pythonAppend wxToolBar "self._setOORInfo(self)"
396 %pythonAppend wxToolBar() ""
397 %typemap(out) wxToolBar*; // turn off this typemap
398
399 wxToolBar(wxWindow *parent,
400 wxWindowID id=-1,
401 const wxPoint& pos = wxDefaultPosition,
402 const wxSize& size = wxDefaultSize,
403 long style = wxNO_BORDER | wxTB_HORIZONTAL,
404 const wxString& name = wxPyToolBarNameStr);
405 %RenameCtor(PreToolBar, wxToolBar());
406
407 // Turn it back on again
408 %typemap(out) wxToolBar* { $result = wxPyMake_wxObject($1, $owner); }
409
410 bool Create(wxWindow *parent,
411 wxWindowID id=-1,
412 const wxPoint& pos = wxDefaultPosition,
413 const wxSize& size = wxDefaultSize,
414 long style = wxNO_BORDER | wxTB_HORIZONTAL,
415 const wxString& name = wxPyToolBarNameStr);
416
417 static wxVisualAttributes
418 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
419 };
420
421 //---------------------------------------------------------------------------
422
423 #if 0
424 %{
425 #include <wx/generic/buttonbar.h>
426 %}
427
428 MustHaveApp(wxToolBar);
429 class wxButtonToolBar : public wxToolBarBase
430 {
431 public:
432 %pythonAppend wxButtonToolBar "self._setOORInfo(self)"
433 %pythonAppend wxButtonToolBar() ""
434
435 wxButtonToolBar(wxWindow *parent,
436 wxWindowID id=-1,
437 const wxPoint& pos = wxDefaultPosition,
438 const wxSize& size = wxDefaultSize,
439 long style = 0,
440 const wxString& name = wxPyToolBarNameStr);
441 %RenameCtor(PreButtonToolBar, wxButtonToolBar());
442
443
444 bool Create(wxWindow *parent,
445 wxWindowID id=-1,
446 const wxPoint& pos = wxDefaultPosition,
447 const wxSize& size = wxDefaultSize,
448 long style = 0,
449 const wxString& name = wxPyToolBarNameStr);
450 };
451
452 #endif
453 //---------------------------------------------------------------------------