]>
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 RD |
17 | |
18 | %{ | |
137b5242 | 19 | DECLARE_DEF_STRING(ToolBarNameStr); |
137b5242 RD |
20 | %} |
21 | ||
9c039d08 | 22 | //--------------------------------------------------------------------------- |
d14a1e28 | 23 | %newgroup; |
9c039d08 | 24 | |
9c039d08 | 25 | |
9b3d3bc4 RD |
26 | class wxToolBarBase; |
27 | ||
28 | enum wxToolBarToolStyle | |
29 | { | |
30 | wxTOOL_STYLE_BUTTON = 1, | |
31 | wxTOOL_STYLE_SEPARATOR = 2, | |
32 | wxTOOL_STYLE_CONTROL | |
33 | }; | |
34 | ||
3ef86e32 RD |
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 | ||
9b3d3bc4 RD |
49 | |
50 | ||
d14a1e28 RD |
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. | |
9416aa89 | 59 | class wxToolBarToolBase : public wxObject { |
9b3d3bc4 RD |
60 | public: |
61 | // wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL, | |
62 | // int id = wxID_SEPARATOR, | |
b96c7a38 RD |
63 | // const wxString& label = wxEmptyString, |
64 | // const wxBitmap& bmpNormal = wxNullBitmap, | |
65 | // const wxBitmap& bmpDisabled = wxNullBitmap, | |
66 | // wxItemKind kind = wxITEM_NORMAL, | |
9b3d3bc4 | 67 | // wxObject *clientData = (wxObject *) NULL, |
b96c7a38 RD |
68 | // const wxString& shortHelpString = wxEmptyString, |
69 | // const wxString& longHelpString = wxEmptyString) | |
9b3d3bc4 RD |
70 | // ~wxToolBarToolBase(); |
71 | ||
9b3d3bc4 RD |
72 | int GetId(); |
73 | wxControl *GetControl(); | |
74 | wxToolBarBase *GetToolBar(); | |
75 | int IsButton(); | |
76 | int IsControl(); | |
77 | int IsSeparator(); | |
78 | int GetStyle(); | |
b96c7a38 | 79 | wxItemKind GetKind(); |
9b3d3bc4 RD |
80 | bool IsEnabled(); |
81 | bool IsToggled(); | |
82 | bool CanBeToggled(); | |
c6ebc32a RD |
83 | const wxBitmap& GetNormalBitmap(); |
84 | const wxBitmap& GetDisabledBitmap(); | |
c5943253 | 85 | wxBitmap GetBitmap(); |
c6ebc32a | 86 | wxString GetLabel(); |
9b3d3bc4 RD |
87 | wxString GetShortHelp(); |
88 | wxString GetLongHelp(); | |
89 | bool Enable(bool enable); | |
c6ebc32a | 90 | void Toggle(); |
9b3d3bc4 RD |
91 | bool SetToggle(bool toggle); |
92 | bool SetShortHelp(const wxString& help); | |
93 | bool SetLongHelp(const wxString& help); | |
c6ebc32a RD |
94 | void SetNormalBitmap(const wxBitmap& bmp); |
95 | void SetDisabledBitmap(const wxBitmap& bmp); | |
96 | void SetLabel(const wxString& label); | |
9b3d3bc4 RD |
97 | void Detach(); |
98 | void Attach(wxToolBarBase *tbar); | |
99 | ||
100 | //wxObject *GetClientData(); | |
d14a1e28 | 101 | %extend { |
9b3d3bc4 RD |
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 | } | |
c6ebc32a | 118 | |
d14a1e28 | 119 | %pythoncode { |
c6ebc32a RD |
120 | GetBitmap1 = GetNormalBitmap |
121 | GetBitmap2 = GetDisabledBitmap | |
122 | SetBitmap1 = SetNormalBitmap | |
123 | SetBitmap2 = SetDisabledBitmap | |
d14a1e28 | 124 | } |
9b3d3bc4 RD |
125 | }; |
126 | ||
127 | ||
128 | ||
d14a1e28 | 129 | |
9b3d3bc4 RD |
130 | class wxToolBarBase : public wxControl { |
131 | public: | |
132 | ||
133 | // This is an Abstract Base Class | |
134 | ||
d14a1e28 | 135 | %extend { |
b96c7a38 | 136 | |
15030c51 RD |
137 | // The full AddTool() function. Call it DoAddTool in wxPython and |
138 | // implement the other Add methods by calling it. | |
b96c7a38 RD |
139 | // |
140 | // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap | |
141 | // is created and used as the disabled image. | |
15030c51 RD |
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) | |
b96c7a38 | 150 | { |
9b3d3bc4 | 151 | wxPyUserData* udata = NULL; |
15030c51 | 152 | if (clientData && clientData != Py_None) |
9b3d3bc4 | 153 | udata = new wxPyUserData(clientData); |
b96c7a38 RD |
154 | return self->AddTool(id, label, bitmap, bmpDisabled, kind, |
155 | shortHelp, longHelp, udata); | |
9b3d3bc4 RD |
156 | } |
157 | ||
9b3d3bc4 | 158 | |
15030c51 RD |
159 | // Insert the new tool at the given position, if pos == GetToolsCount(), it |
160 | // is equivalent to DoAddTool() | |
1e4a197e | 161 | wxToolBarToolBase *DoInsertTool(size_t pos, |
9b3d3bc4 | 162 | int id, |
b96c7a38 | 163 | const wxString& label, |
9b3d3bc4 | 164 | const wxBitmap& bitmap, |
b96c7a38 RD |
165 | const wxBitmap& bmpDisabled = wxNullBitmap, |
166 | wxItemKind kind = wxITEM_NORMAL, | |
c12de7f8 RD |
167 | const wxString& shortHelp = wxPyEmptyString, |
168 | const wxString& longHelp = wxPyEmptyString, | |
b96c7a38 RD |
169 | PyObject *clientData = NULL) |
170 | { | |
9b3d3bc4 | 171 | wxPyUserData* udata = NULL; |
15030c51 | 172 | if (clientData && clientData != Py_None) |
9b3d3bc4 | 173 | udata = new wxPyUserData(clientData); |
b96c7a38 RD |
174 | return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind, |
175 | shortHelp, longHelp, udata); | |
9b3d3bc4 RD |
176 | } |
177 | ||
9b3d3bc4 RD |
178 | } |
179 | ||
180 | ||
d14a1e28 RD |
181 | %pythoncode { |
182 | %# These match the original Add methods for this class, kept for | |
183 | %# backwards compatibility with versions < 2.3.3. | |
15030c51 RD |
184 | |
185 | ||
186 | def AddTool(self, id, bitmap, | |
d14a1e28 | 187 | pushedBitmap = wx.NullBitmap, |
15030c51 RD |
188 | isToggle = 0, |
189 | clientData = None, | |
190 | shortHelpString = '', | |
191 | longHelpString = '') : | |
192 | '''Old style method to add a tool to the toolbar.''' | |
d14a1e28 RD |
193 | kind = wx.ITEM_NORMAL |
194 | if isToggle: kind = wx.ITEM_CHECK | |
15030c51 RD |
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.''' | |
d14a1e28 RD |
203 | kind = wx.ITEM_NORMAL |
204 | if isToggle: kind = wx.ITEM_CHECK | |
205 | return self.DoAddTool(id, '', bitmap, wx.NullBitmap, kind, | |
15030c51 RD |
206 | shortHelpString, longHelpString, None) |
207 | ||
208 | def InsertTool(self, pos, id, bitmap, | |
d14a1e28 | 209 | pushedBitmap = wx.NullBitmap, |
15030c51 RD |
210 | isToggle = 0, |
211 | clientData = None, | |
212 | shortHelpString = '', | |
213 | longHelpString = ''): | |
214 | '''Old style method to insert a tool in the toolbar.''' | |
d14a1e28 RD |
215 | kind = wx.ITEM_NORMAL |
216 | if isToggle: kind = wx.ITEM_CHECK | |
15030c51 RD |
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.''' | |
d14a1e28 RD |
225 | kind = wx.ITEM_NORMAL |
226 | if isToggle: kind = wx.ITEM_CHECK | |
227 | return self.DoInsertTool(pos, id, '', bitmap, wx.NullBitmap, kind, | |
15030c51 RD |
228 | shortHelpString, longHelpString, None) |
229 | ||
230 | ||
d14a1e28 RD |
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... | |
15030c51 RD |
236 | |
237 | def AddLabelTool(self, id, label, bitmap, | |
d14a1e28 RD |
238 | bmpDisabled = wx.NullBitmap, |
239 | kind = wx.ITEM_NORMAL, | |
15030c51 RD |
240 | shortHelp = '', longHelp = '', |
241 | clientData = None): | |
242 | ''' | |
243 | The full AddTool() function. | |
244 | ||
d14a1e28 | 245 | If bmpDisabled is wx.NullBitmap, a shadowed version of the normal bitmap |
15030c51 RD |
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, | |
d14a1e28 RD |
253 | bmpDisabled = wx.NullBitmap, |
254 | kind = wx.ITEM_NORMAL, | |
15030c51 RD |
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, | |
d14a1e28 | 265 | bmpDisabled = wx.NullBitmap, |
15030c51 RD |
266 | shortHelp = '', longHelp = '', |
267 | clientData = None): | |
268 | '''Add a check tool, i.e. a tool which can be toggled''' | |
d14a1e28 | 269 | return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_CHECK, |
15030c51 RD |
270 | shortHelp, longHelp, clientData) |
271 | ||
272 | def AddRadioLabelTool(self, id, label, bitmap, | |
d14a1e28 | 273 | bmpDisabled = wx.NullBitmap, |
15030c51 RD |
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 | ''' | |
d14a1e28 | 280 | return self.DoAddTool(id, label, bitmap, bmpDisabled, wx.ITEM_RADIO, |
15030c51 RD |
281 | shortHelp, longHelp, clientData) |
282 | ||
283 | ||
d14a1e28 RD |
284 | %# For consistency with the backwards compatible methods above, here are |
285 | %# some non-'Label' versions of the Check and Radio methods | |
15030c51 | 286 | def AddCheckTool(self, id, bitmap, |
d14a1e28 | 287 | bmpDisabled = wx.NullBitmap, |
15030c51 RD |
288 | shortHelp = '', longHelp = '', |
289 | clientData = None): | |
290 | '''Add a check tool, i.e. a tool which can be toggled''' | |
d14a1e28 | 291 | return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.ITEM_CHECK, |
15030c51 RD |
292 | shortHelp, longHelp, clientData) |
293 | ||
294 | def AddRadioTool(self, id, bitmap, | |
d14a1e28 | 295 | bmpDisabled = wx.NullBitmap, |
15030c51 RD |
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 | ''' | |
d14a1e28 | 302 | return self.DoAddTool(id, '', bitmap, bmpDisabled, wx.ITEM_RADIO, |
15030c51 | 303 | shortHelp, longHelp, clientData) |
d14a1e28 | 304 | } |
15030c51 | 305 | |
9cbf6f6e RD |
306 | // TODO? |
307 | //wxToolBarToolBase *AddTool (wxToolBarToolBase *tool); | |
308 | //wxToolBarToolBase *InsertTool (size_t pos, wxToolBarToolBase *tool); | |
15030c51 | 309 | |
9b3d3bc4 RD |
310 | wxToolBarToolBase *AddControl(wxControl *control); |
311 | wxToolBarToolBase *InsertControl(size_t pos, wxControl *control); | |
fe953afb | 312 | wxControl *FindControl( int id ); |
9b3d3bc4 RD |
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 | ||
d14a1e28 | 329 | %extend { |
9b3d3bc4 | 330 | // convert the ClientData back to a PyObject |
c6ebc32a RD |
331 | PyObject* GetToolClientData(int id) { |
332 | wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id); | |
9b3d3bc4 RD |
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 | ||
c6ebc32a RD |
342 | void SetToolClientData(int id, PyObject* clientData) { |
343 | self->SetToolClientData(id, new wxPyUserData(clientData)); | |
9b3d3bc4 RD |
344 | } |
345 | } | |
346 | ||
3ef86e32 RD |
347 | // returns tool pos, or wxNOT_FOUND if tool isn't found |
348 | int GetToolPos(int id) const; | |
9b3d3bc4 RD |
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(); | |
83b18bab | 362 | wxSize GetMargins(); |
9b3d3bc4 RD |
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 | ||
c6ebc32a RD |
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 | ||
dd9f7fea | 379 | // return True if this is a vertical toolbar, otherwise False |
c6ebc32a | 380 | bool IsVertical(); |
9b3d3bc4 RD |
381 | }; |
382 | ||
383 | ||
384 | ||
385 | ||
386 | class wxToolBar : public wxToolBarBase { | |
387 | public: | |
d14a1e28 RD |
388 | %addtofunc wxToolBar "self._setOORInfo(self)" |
389 | %addtofunc wxToolBar() "" | |
390 | ||
9b3d3bc4 RD |
391 | wxToolBar(wxWindow *parent, |
392 | wxWindowID id, | |
b68dc582 RD |
393 | const wxPoint& pos = wxDefaultPosition, |
394 | const wxSize& size = wxDefaultSize, | |
9b3d3bc4 | 395 | long style = wxNO_BORDER | wxTB_HORIZONTAL, |
137b5242 | 396 | const wxString& name = wxPyToolBarNameStr); |
d14a1e28 | 397 | %name(PreToolBar)wxToolBar(); |
09f3d4e6 RD |
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, | |
137b5242 | 404 | const wxString& name = wxPyToolBarNameStr); |
9b3d3bc4 | 405 | |
9b3d3bc4 RD |
406 | wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y); |
407 | }; | |
408 | ||
9c039d08 | 409 | //--------------------------------------------------------------------------- |