]>
Commit | Line | Data |
---|---|---|
9c039d08 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: stattool.i | |
3 | // Purpose: SWIG definitions for StatusBar and ToolBar classes | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 08/24/1998 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1998 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | ||
14 | %module stattool | |
15 | ||
16 | %{ | |
17 | #include "helpers.h" | |
18 | #include <wx/toolbar.h> | |
19 | #include <wx/tbarsmpl.h> | |
20 | %} | |
21 | ||
22 | //---------------------------------------------------------------------- | |
23 | ||
24 | %include typemaps.i | |
25 | %include my_typemaps.i | |
26 | ||
27 | // Import some definitions of other classes, etc. | |
28 | %import _defs.i | |
29 | %import misc.i | |
30 | %import windows.i | |
31 | %import controls.i | |
32 | ||
b8b8dda7 | 33 | %pragma(python) code = "import wx" |
9c039d08 | 34 | |
b68dc582 | 35 | |
137b5242 RD |
36 | //---------------------------------------------------------------------- |
37 | ||
38 | %{ | |
39 | // Put some wx default wxChar* values into wxStrings. | |
40 | DECLARE_DEF_STRING(StatusLineNameStr); | |
41 | DECLARE_DEF_STRING(ToolBarNameStr); | |
42 | static const wxString wxPyEmptyString(wxT("")); | |
43 | %} | |
44 | ||
9c039d08 RD |
45 | //--------------------------------------------------------------------------- |
46 | ||
47 | class wxStatusBar : public wxWindow { | |
48 | public: | |
99f7d340 | 49 | wxStatusBar(wxWindow* parent, wxWindowID id = -1, |
9c039d08 | 50 | long style = wxST_SIZEGRIP, |
137b5242 | 51 | const wxString& name = wxPyStatusLineNameStr); |
09f3d4e6 RD |
52 | %name(wxPreStatusBar)wxStatusBar(); |
53 | ||
54 | bool Create(wxWindow* parent, wxWindowID id, | |
55 | long style = wxST_SIZEGRIP, | |
137b5242 | 56 | const wxString& name = wxPyStatusLineNameStr); |
9c039d08 | 57 | |
0122b7e3 | 58 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 59 | %pragma(python) addtomethod = "wxPreStatusBar:val._setOORInfo(val)" |
9c039d08 RD |
60 | |
61 | %addmethods { | |
62 | %new wxRect* GetFieldRect(long item) { | |
63 | wxRect* rect= new wxRect; | |
64 | self->GetFieldRect(item, *rect); | |
65 | return rect; | |
66 | } | |
67 | } | |
68 | int GetFieldsCount(void); | |
69 | wxString GetStatusText(int ir = 0); | |
26b9cf27 RD |
70 | int GetBorderX(); |
71 | int GetBorderY(); | |
72 | ||
9c039d08 RD |
73 | void SetFieldsCount(int number = 1); |
74 | void SetStatusText(const wxString& text, int i = 0); | |
eec92d76 | 75 | void SetStatusWidths(int LCOUNT, int* choices); |
26b9cf27 | 76 | void SetMinHeight(int height); |
9c039d08 RD |
77 | }; |
78 | ||
79 | ||
80 | //--------------------------------------------------------------------------- | |
81 | ||
9b3d3bc4 RD |
82 | class wxToolBarBase; |
83 | ||
84 | enum wxToolBarToolStyle | |
85 | { | |
86 | wxTOOL_STYLE_BUTTON = 1, | |
87 | wxTOOL_STYLE_SEPARATOR = 2, | |
88 | wxTOOL_STYLE_CONTROL | |
89 | }; | |
90 | ||
91 | ||
92 | ||
9416aa89 | 93 | class wxToolBarToolBase : public wxObject { |
9b3d3bc4 RD |
94 | public: |
95 | // wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL, | |
96 | // int id = wxID_SEPARATOR, | |
97 | // const wxBitmap& bitmap1 = wxNullBitmap, | |
98 | // const wxBitmap& bitmap2 = wxNullBitmap, | |
99 | // bool toggle = FALSE, | |
100 | // wxObject *clientData = (wxObject *) NULL, | |
137b5242 RD |
101 | // const wxString& shortHelpString = wxPyEmptyString, |
102 | // const wxString& longHelpString = wxPyEmptyString); | |
9b3d3bc4 RD |
103 | // wxToolBarToolBase(wxToolBarBase *tbar, wxControl *control); |
104 | // ~wxToolBarToolBase(); | |
105 | ||
106 | %addmethods { void Destroy() { delete self; } } | |
107 | ||
108 | int GetId(); | |
109 | wxControl *GetControl(); | |
110 | wxToolBarBase *GetToolBar(); | |
111 | int IsButton(); | |
112 | int IsControl(); | |
113 | int IsSeparator(); | |
114 | int GetStyle(); | |
115 | bool IsEnabled(); | |
116 | bool IsToggled(); | |
117 | bool CanBeToggled(); | |
c6ebc32a RD |
118 | const wxBitmap& GetNormalBitmap(); |
119 | const wxBitmap& GetDisabledBitmap(); | |
c5943253 | 120 | wxBitmap GetBitmap(); |
c6ebc32a | 121 | wxString GetLabel(); |
9b3d3bc4 RD |
122 | wxString GetShortHelp(); |
123 | wxString GetLongHelp(); | |
124 | bool Enable(bool enable); | |
c6ebc32a | 125 | void Toggle(); |
9b3d3bc4 RD |
126 | bool SetToggle(bool toggle); |
127 | bool SetShortHelp(const wxString& help); | |
128 | bool SetLongHelp(const wxString& help); | |
c6ebc32a RD |
129 | void SetNormalBitmap(const wxBitmap& bmp); |
130 | void SetDisabledBitmap(const wxBitmap& bmp); | |
131 | void SetLabel(const wxString& label); | |
9b3d3bc4 RD |
132 | void Detach(); |
133 | void Attach(wxToolBarBase *tbar); | |
134 | ||
135 | //wxObject *GetClientData(); | |
136 | %addmethods { | |
137 | // convert the ClientData back to a PyObject | |
138 | PyObject* GetClientData() { | |
139 | wxPyUserData* udata = (wxPyUserData*)self->GetClientData(); | |
140 | if (udata) { | |
141 | Py_INCREF(udata->m_obj); | |
142 | return udata->m_obj; | |
143 | } else { | |
144 | Py_INCREF(Py_None); | |
145 | return Py_None; | |
146 | } | |
147 | } | |
148 | ||
149 | void SetClientData(PyObject* clientData) { | |
150 | self->SetClientData(new wxPyUserData(clientData)); | |
151 | } | |
152 | } | |
c6ebc32a RD |
153 | |
154 | %pragma(python) addtoclass=" | |
155 | GetBitmap1 = GetNormalBitmap | |
156 | GetBitmap2 = GetDisabledBitmap | |
157 | SetBitmap1 = SetNormalBitmap | |
158 | SetBitmap2 = SetDisabledBitmap | |
159 | " | |
9b3d3bc4 RD |
160 | }; |
161 | ||
162 | ||
163 | ||
164 | class wxToolBarBase : public wxControl { | |
165 | public: | |
166 | ||
167 | // This is an Abstract Base Class | |
168 | ||
169 | %addmethods { | |
170 | // wrap ClientData in a class that knows about PyObjects | |
171 | wxToolBarToolBase *AddTool(int id, | |
172 | const wxBitmap& bitmap, | |
173 | const wxBitmap& pushedBitmap = wxNullBitmap, | |
c368d904 | 174 | int isToggle = FALSE, |
9b3d3bc4 | 175 | PyObject *clientData = NULL, |
137b5242 RD |
176 | const wxString& shortHelpString = wxPyEmptyString, |
177 | const wxString& longHelpString = wxPyEmptyString) { | |
9b3d3bc4 RD |
178 | wxPyUserData* udata = NULL; |
179 | if (clientData) | |
180 | udata = new wxPyUserData(clientData); | |
c368d904 | 181 | return self->AddTool(id, bitmap, pushedBitmap, (bool)isToggle, |
9b3d3bc4 RD |
182 | udata, shortHelpString, longHelpString); |
183 | } | |
184 | ||
185 | // This one is easier to use... | |
186 | wxToolBarToolBase *AddSimpleTool(int id, | |
187 | const wxBitmap& bitmap, | |
137b5242 RD |
188 | const wxString& shortHelpString = wxPyEmptyString, |
189 | const wxString& longHelpString = wxPyEmptyString, | |
c368d904 RD |
190 | int isToggle = FALSE) { |
191 | return self->AddTool(id, bitmap, wxNullBitmap, isToggle, NULL, | |
9b3d3bc4 RD |
192 | shortHelpString, longHelpString); |
193 | } | |
194 | ||
195 | ||
196 | // wrap ClientData in a class that knows about PyObjects | |
197 | wxToolBarToolBase *InsertTool(size_t pos, | |
198 | int id, | |
199 | const wxBitmap& bitmap, | |
200 | const wxBitmap& pushedBitmap = wxNullBitmap, | |
c368d904 | 201 | int isToggle = FALSE, |
9b3d3bc4 | 202 | PyObject *clientData = NULL, |
137b5242 RD |
203 | const wxString& shortHelpString = wxPyEmptyString, |
204 | const wxString& longHelpString = wxPyEmptyString) { | |
9b3d3bc4 RD |
205 | wxPyUserData* udata = NULL; |
206 | if (clientData) | |
207 | udata = new wxPyUserData(clientData); | |
c368d904 | 208 | return self->InsertTool(pos, id, bitmap, pushedBitmap, (bool)isToggle, |
9b3d3bc4 RD |
209 | udata, shortHelpString, longHelpString); |
210 | } | |
211 | ||
212 | // This one is easier to use... | |
213 | wxToolBarToolBase *InsertSimpleTool(size_t pos, | |
214 | int id, | |
215 | const wxBitmap& bitmap, | |
137b5242 RD |
216 | const wxString& shortHelpString = wxPyEmptyString, |
217 | const wxString& longHelpString = wxPyEmptyString, | |
c368d904 RD |
218 | int isToggle = FALSE) { |
219 | return self->InsertTool(pos, id, bitmap, wxNullBitmap, isToggle, NULL, | |
9b3d3bc4 RD |
220 | shortHelpString, longHelpString); |
221 | } | |
222 | } | |
223 | ||
224 | ||
225 | wxToolBarToolBase *AddControl(wxControl *control); | |
226 | wxToolBarToolBase *InsertControl(size_t pos, wxControl *control); | |
227 | ||
228 | wxToolBarToolBase *AddSeparator(); | |
229 | wxToolBarToolBase *InsertSeparator(size_t pos); | |
230 | ||
231 | wxToolBarToolBase *RemoveTool(int id); | |
232 | ||
233 | bool DeleteToolByPos(size_t pos); | |
234 | bool DeleteTool(int id); | |
235 | void ClearTools(); | |
236 | bool Realize(); | |
237 | ||
238 | void EnableTool(int id, bool enable); | |
239 | void ToggleTool(int id, bool toggle); | |
240 | void SetToggle(int id, bool toggle); | |
241 | ||
242 | ||
243 | %addmethods { | |
244 | // convert the ClientData back to a PyObject | |
c6ebc32a RD |
245 | PyObject* GetToolClientData(int id) { |
246 | wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id); | |
9b3d3bc4 RD |
247 | if (udata) { |
248 | Py_INCREF(udata->m_obj); | |
249 | return udata->m_obj; | |
250 | } else { | |
251 | Py_INCREF(Py_None); | |
252 | return Py_None; | |
253 | } | |
254 | } | |
255 | ||
c6ebc32a RD |
256 | void SetToolClientData(int id, PyObject* clientData) { |
257 | self->SetToolClientData(id, new wxPyUserData(clientData)); | |
9b3d3bc4 RD |
258 | } |
259 | } | |
260 | ||
261 | ||
262 | bool GetToolState(int id); | |
263 | bool GetToolEnabled(int id); | |
264 | void SetToolShortHelp(int id, const wxString& helpString); | |
265 | wxString GetToolShortHelp(int id); | |
266 | void SetToolLongHelp(int id, const wxString& helpString); | |
267 | wxString GetToolLongHelp(int id); | |
268 | ||
269 | %name(SetMarginsXY) void SetMargins(int x, int y); | |
270 | void SetMargins(const wxSize& size); | |
271 | void SetToolPacking(int packing); | |
272 | void SetToolSeparation(int separation); | |
273 | wxSize GetToolMargins(); | |
83b18bab | 274 | wxSize GetMargins(); |
9b3d3bc4 RD |
275 | int GetToolPacking(); |
276 | int GetToolSeparation(); | |
277 | ||
278 | void SetRows(int nRows); | |
279 | void SetMaxRowsCols(int rows, int cols); | |
280 | int GetMaxRows(); | |
281 | int GetMaxCols(); | |
282 | ||
283 | void SetToolBitmapSize(const wxSize& size); | |
284 | wxSize GetToolBitmapSize(); | |
285 | wxSize GetToolSize(); | |
286 | ||
c6ebc32a RD |
287 | // returns a (non separator) tool containing the point (x, y) or NULL if |
288 | // there is no tool at this point (corrdinates are client) | |
289 | wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y); | |
290 | ||
291 | // return TRUE if this is a vertical toolbar, otherwise FALSE | |
292 | bool IsVertical(); | |
9b3d3bc4 RD |
293 | }; |
294 | ||
295 | ||
296 | ||
297 | ||
298 | class wxToolBar : public wxToolBarBase { | |
299 | public: | |
300 | wxToolBar(wxWindow *parent, | |
301 | wxWindowID id, | |
b68dc582 RD |
302 | const wxPoint& pos = wxDefaultPosition, |
303 | const wxSize& size = wxDefaultSize, | |
9b3d3bc4 | 304 | long style = wxNO_BORDER | wxTB_HORIZONTAL, |
137b5242 | 305 | const wxString& name = wxPyToolBarNameStr); |
09f3d4e6 RD |
306 | %name(wxPreToolBar)wxToolBar(); |
307 | ||
308 | bool Create(wxWindow *parent, | |
309 | wxWindowID id, | |
310 | const wxPoint& pos = wxDefaultPosition, | |
311 | const wxSize& size = wxDefaultSize, | |
312 | long style = wxNO_BORDER | wxTB_HORIZONTAL, | |
137b5242 | 313 | const wxString& name = wxPyToolBarNameStr); |
9b3d3bc4 | 314 | |
0122b7e3 | 315 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 316 | %pragma(python) addtomethod = "wxPreToolBar:val._setOORInfo(val)" |
9b3d3bc4 RD |
317 | |
318 | wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y); | |
319 | }; | |
320 | ||
321 | ||
322 | ||
323 | ||
324 | class wxToolBarSimple : public wxToolBarBase { | |
325 | public: | |
326 | wxToolBarSimple(wxWindow *parent, | |
327 | wxWindowID id, | |
b68dc582 RD |
328 | const wxPoint& pos = wxDefaultPosition, |
329 | const wxSize& size = wxDefaultSize, | |
9b3d3bc4 | 330 | long style = wxNO_BORDER | wxTB_HORIZONTAL, |
137b5242 | 331 | const wxString& name = wxPyToolBarNameStr); |
09f3d4e6 RD |
332 | %name(wxPreToolBarSimple)wxToolBarSimple(); |
333 | ||
334 | bool Create(wxWindow *parent, | |
335 | wxWindowID id, | |
336 | const wxPoint& pos = wxDefaultPosition, | |
337 | const wxSize& size = wxDefaultSize, | |
338 | long style = wxNO_BORDER | wxTB_HORIZONTAL, | |
137b5242 | 339 | const wxString& name = wxPyToolBarNameStr); |
9b3d3bc4 | 340 | |
0122b7e3 | 341 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
17c0e08c | 342 | %pragma(python) addtomethod = "wxPreToolBarSimple:val._setOORInfo(val)" |
9b3d3bc4 RD |
343 | |
344 | wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y); | |
345 | }; | |
346 | ||
347 | //--------------------------------------------------------------------------- | |
9c039d08 RD |
348 | //--------------------------------------------------------------------------- |
349 |