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