]>
Commit | Line | Data |
---|---|---|
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 | ||
33 | %pragma(python) code = "import wx" | |
34 | ||
35 | ||
36 | //--------------------------------------------------------------------------- | |
37 | ||
38 | class wxStatusBar : public wxWindow { | |
39 | public: | |
40 | wxStatusBar(wxWindow* parent, wxWindowID id = -1, | |
41 | long style = wxST_SIZEGRIP, | |
42 | char* name = "statusBar"); | |
43 | %name(wxPreStatusBar)wxStatusBar(); | |
44 | ||
45 | bool Create(wxWindow* parent, wxWindowID id, | |
46 | long style = wxST_SIZEGRIP, | |
47 | char* name = "statusBar"); | |
48 | ||
49 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
50 | %pragma(python) addtomethod = "wxPreStatusBar:val._setOORInfo(val)" | |
51 | ||
52 | %addmethods { | |
53 | %new wxRect* GetFieldRect(long item) { | |
54 | wxRect* rect= new wxRect; | |
55 | self->GetFieldRect(item, *rect); | |
56 | return rect; | |
57 | } | |
58 | } | |
59 | int GetFieldsCount(void); | |
60 | wxString GetStatusText(int ir = 0); | |
61 | int GetBorderX(); | |
62 | int GetBorderY(); | |
63 | ||
64 | void SetFieldsCount(int number = 1); | |
65 | void SetStatusText(const wxString& text, int i = 0); | |
66 | void SetStatusWidths(int LCOUNT, int* choices); | |
67 | void SetMinHeight(int height); | |
68 | }; | |
69 | ||
70 | ||
71 | //--------------------------------------------------------------------------- | |
72 | ||
73 | class wxToolBarBase; | |
74 | ||
75 | enum wxToolBarToolStyle | |
76 | { | |
77 | wxTOOL_STYLE_BUTTON = 1, | |
78 | wxTOOL_STYLE_SEPARATOR = 2, | |
79 | wxTOOL_STYLE_CONTROL | |
80 | }; | |
81 | ||
82 | ||
83 | ||
84 | class wxToolBarToolBase : public wxObject { | |
85 | public: | |
86 | // wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL, | |
87 | // int id = wxID_SEPARATOR, | |
88 | // const wxBitmap& bitmap1 = wxNullBitmap, | |
89 | // const wxBitmap& bitmap2 = wxNullBitmap, | |
90 | // bool toggle = FALSE, | |
91 | // wxObject *clientData = (wxObject *) NULL, | |
92 | // const wxString& shortHelpString = wxEmptyString, | |
93 | // const wxString& longHelpString = wxEmptyString); | |
94 | // wxToolBarToolBase(wxToolBarBase *tbar, wxControl *control); | |
95 | // ~wxToolBarToolBase(); | |
96 | ||
97 | %addmethods { void Destroy() { delete self; } } | |
98 | ||
99 | int GetId(); | |
100 | wxControl *GetControl(); | |
101 | wxToolBarBase *GetToolBar(); | |
102 | int IsButton(); | |
103 | int IsControl(); | |
104 | int IsSeparator(); | |
105 | int GetStyle(); | |
106 | bool IsEnabled(); | |
107 | bool IsToggled(); | |
108 | bool CanBeToggled(); | |
109 | wxBitmap GetBitmap1(); | |
110 | wxBitmap GetBitmap2(); | |
111 | wxBitmap GetBitmap(); | |
112 | wxString GetShortHelp(); | |
113 | wxString GetLongHelp(); | |
114 | bool Enable(bool enable); | |
115 | bool Toggle(bool toggle); | |
116 | bool SetToggle(bool toggle); | |
117 | bool SetShortHelp(const wxString& help); | |
118 | bool SetLongHelp(const wxString& help); | |
119 | void SetBitmap1(const wxBitmap& bmp); | |
120 | void SetBitmap2(const wxBitmap& bmp); | |
121 | void Detach(); | |
122 | void Attach(wxToolBarBase *tbar); | |
123 | ||
124 | //wxObject *GetClientData(); | |
125 | %addmethods { | |
126 | // convert the ClientData back to a PyObject | |
127 | PyObject* GetClientData() { | |
128 | wxPyUserData* udata = (wxPyUserData*)self->GetClientData(); | |
129 | if (udata) { | |
130 | Py_INCREF(udata->m_obj); | |
131 | return udata->m_obj; | |
132 | } else { | |
133 | Py_INCREF(Py_None); | |
134 | return Py_None; | |
135 | } | |
136 | } | |
137 | ||
138 | void SetClientData(PyObject* clientData) { | |
139 | self->SetClientData(new wxPyUserData(clientData)); | |
140 | } | |
141 | } | |
142 | }; | |
143 | ||
144 | ||
145 | ||
146 | class wxToolBarBase : public wxControl { | |
147 | public: | |
148 | ||
149 | // This is an Abstract Base Class | |
150 | ||
151 | %addmethods { | |
152 | // wrap ClientData in a class that knows about PyObjects | |
153 | wxToolBarToolBase *AddTool(int id, | |
154 | const wxBitmap& bitmap, | |
155 | const wxBitmap& pushedBitmap = wxNullBitmap, | |
156 | int isToggle = FALSE, | |
157 | PyObject *clientData = NULL, | |
158 | const wxString& shortHelpString = wxEmptyString, | |
159 | const wxString& longHelpString = wxEmptyString) { | |
160 | wxPyUserData* udata = NULL; | |
161 | if (clientData) | |
162 | udata = new wxPyUserData(clientData); | |
163 | return self->AddTool(id, bitmap, pushedBitmap, (bool)isToggle, | |
164 | udata, shortHelpString, longHelpString); | |
165 | } | |
166 | ||
167 | // This one is easier to use... | |
168 | wxToolBarToolBase *AddSimpleTool(int id, | |
169 | const wxBitmap& bitmap, | |
170 | const wxString& shortHelpString = wxEmptyString, | |
171 | const wxString& longHelpString = wxEmptyString, | |
172 | int isToggle = FALSE) { | |
173 | return self->AddTool(id, bitmap, wxNullBitmap, isToggle, NULL, | |
174 | shortHelpString, longHelpString); | |
175 | } | |
176 | ||
177 | ||
178 | // wrap ClientData in a class that knows about PyObjects | |
179 | wxToolBarToolBase *InsertTool(size_t pos, | |
180 | int id, | |
181 | const wxBitmap& bitmap, | |
182 | const wxBitmap& pushedBitmap = wxNullBitmap, | |
183 | int isToggle = FALSE, | |
184 | PyObject *clientData = NULL, | |
185 | const wxString& shortHelpString = wxEmptyString, | |
186 | const wxString& longHelpString = wxEmptyString) { | |
187 | wxPyUserData* udata = NULL; | |
188 | if (clientData) | |
189 | udata = new wxPyUserData(clientData); | |
190 | return self->InsertTool(pos, id, bitmap, pushedBitmap, (bool)isToggle, | |
191 | udata, shortHelpString, longHelpString); | |
192 | } | |
193 | ||
194 | // This one is easier to use... | |
195 | wxToolBarToolBase *InsertSimpleTool(size_t pos, | |
196 | int id, | |
197 | const wxBitmap& bitmap, | |
198 | const wxString& shortHelpString = wxEmptyString, | |
199 | const wxString& longHelpString = wxEmptyString, | |
200 | int isToggle = FALSE) { | |
201 | return self->InsertTool(pos, id, bitmap, wxNullBitmap, isToggle, NULL, | |
202 | shortHelpString, longHelpString); | |
203 | } | |
204 | } | |
205 | ||
206 | ||
207 | wxToolBarToolBase *AddControl(wxControl *control); | |
208 | wxToolBarToolBase *InsertControl(size_t pos, wxControl *control); | |
209 | ||
210 | wxToolBarToolBase *AddSeparator(); | |
211 | wxToolBarToolBase *InsertSeparator(size_t pos); | |
212 | ||
213 | wxToolBarToolBase *RemoveTool(int id); | |
214 | ||
215 | bool DeleteToolByPos(size_t pos); | |
216 | bool DeleteTool(int id); | |
217 | void ClearTools(); | |
218 | bool Realize(); | |
219 | ||
220 | void EnableTool(int id, bool enable); | |
221 | void ToggleTool(int id, bool toggle); | |
222 | void SetToggle(int id, bool toggle); | |
223 | ||
224 | ||
225 | %addmethods { | |
226 | // convert the ClientData back to a PyObject | |
227 | PyObject* GetToolClientData(int index) { | |
228 | wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(index); | |
229 | if (udata) { | |
230 | Py_INCREF(udata->m_obj); | |
231 | return udata->m_obj; | |
232 | } else { | |
233 | Py_INCREF(Py_None); | |
234 | return Py_None; | |
235 | } | |
236 | } | |
237 | ||
238 | void SetToolClientData(int index, PyObject* clientData) { | |
239 | self->SetToolClientData(index, new wxPyUserData(clientData)); | |
240 | } | |
241 | } | |
242 | ||
243 | ||
244 | bool GetToolState(int id); | |
245 | bool GetToolEnabled(int id); | |
246 | void SetToolShortHelp(int id, const wxString& helpString); | |
247 | wxString GetToolShortHelp(int id); | |
248 | void SetToolLongHelp(int id, const wxString& helpString); | |
249 | wxString GetToolLongHelp(int id); | |
250 | ||
251 | %name(SetMarginsXY) void SetMargins(int x, int y); | |
252 | void SetMargins(const wxSize& size); | |
253 | void SetToolPacking(int packing); | |
254 | void SetToolSeparation(int separation); | |
255 | wxSize GetToolMargins(); | |
256 | wxSize GetMargins(); | |
257 | int GetToolPacking(); | |
258 | int GetToolSeparation(); | |
259 | ||
260 | void SetRows(int nRows); | |
261 | void SetMaxRowsCols(int rows, int cols); | |
262 | int GetMaxRows(); | |
263 | int GetMaxCols(); | |
264 | ||
265 | void SetToolBitmapSize(const wxSize& size); | |
266 | wxSize GetToolBitmapSize(); | |
267 | wxSize GetToolSize(); | |
268 | ||
269 | }; | |
270 | ||
271 | ||
272 | ||
273 | ||
274 | class wxToolBar : public wxToolBarBase { | |
275 | public: | |
276 | wxToolBar(wxWindow *parent, | |
277 | wxWindowID id, | |
278 | const wxPoint& pos = wxDefaultPosition, | |
279 | const wxSize& size = wxDefaultSize, | |
280 | long style = wxNO_BORDER | wxTB_HORIZONTAL, | |
281 | const char* name = wxToolBarNameStr); | |
282 | %name(wxPreToolBar)wxToolBar(); | |
283 | ||
284 | bool Create(wxWindow *parent, | |
285 | wxWindowID id, | |
286 | const wxPoint& pos = wxDefaultPosition, | |
287 | const wxSize& size = wxDefaultSize, | |
288 | long style = wxNO_BORDER | wxTB_HORIZONTAL, | |
289 | const char* name = wxToolBarNameStr); | |
290 | ||
291 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
292 | %pragma(python) addtomethod = "wxPreToolBar:val._setOORInfo(val)" | |
293 | ||
294 | wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y); | |
295 | }; | |
296 | ||
297 | ||
298 | ||
299 | ||
300 | class wxToolBarSimple : public wxToolBarBase { | |
301 | public: | |
302 | wxToolBarSimple(wxWindow *parent, | |
303 | wxWindowID id, | |
304 | const wxPoint& pos = wxDefaultPosition, | |
305 | const wxSize& size = wxDefaultSize, | |
306 | long style = wxNO_BORDER | wxTB_HORIZONTAL, | |
307 | const char* name = wxToolBarNameStr); | |
308 | %name(wxPreToolBarSimple)wxToolBarSimple(); | |
309 | ||
310 | bool Create(wxWindow *parent, | |
311 | wxWindowID id, | |
312 | const wxPoint& pos = wxDefaultPosition, | |
313 | const wxSize& size = wxDefaultSize, | |
314 | long style = wxNO_BORDER | wxTB_HORIZONTAL, | |
315 | const char* name = wxToolBarNameStr); | |
316 | ||
317 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
318 | %pragma(python) addtomethod = "wxPreToolBarSimple:val._setOORInfo(val)" | |
319 | ||
320 | wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y); | |
321 | }; | |
322 | ||
323 | //--------------------------------------------------------------------------- | |
324 | //--------------------------------------------------------------------------- | |
325 |