]>
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 RD |
35 | |
36 | %{ | |
37 | static wxString wxPyEmptyStr(""); | |
38 | %} | |
39 | ||
9c039d08 RD |
40 | //--------------------------------------------------------------------------- |
41 | ||
42 | class wxStatusBar : public wxWindow { | |
43 | public: | |
44 | wxStatusBar(wxWindow* parent, wxWindowID id, | |
b68dc582 RD |
45 | const wxPoint& pos = wxDefaultPosition, |
46 | const wxSize& size = wxDefaultSize, | |
9c039d08 RD |
47 | long style = wxST_SIZEGRIP, |
48 | char* name = "statusBar"); | |
49 | ||
f6bcfd97 | 50 | %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)" |
9c039d08 RD |
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); | |
26b9cf27 RD |
61 | int GetBorderX(); |
62 | int GetBorderY(); | |
63 | ||
64 | // void DrawField(wxDC& dc, int i); | |
65 | // void DrawFieldText(wxDC& dc, int i); | |
66 | // void InitColours(void); | |
9c039d08 | 67 | |
9c039d08 RD |
68 | void SetFieldsCount(int number = 1); |
69 | void SetStatusText(const wxString& text, int i = 0); | |
eec92d76 | 70 | void SetStatusWidths(int LCOUNT, int* choices); |
26b9cf27 | 71 | void SetMinHeight(int height); |
9c039d08 RD |
72 | }; |
73 | ||
74 | ||
75 | //--------------------------------------------------------------------------- | |
76 | ||
9b3d3bc4 RD |
77 | class wxToolBarBase; |
78 | ||
79 | enum wxToolBarToolStyle | |
80 | { | |
81 | wxTOOL_STYLE_BUTTON = 1, | |
82 | wxTOOL_STYLE_SEPARATOR = 2, | |
83 | wxTOOL_STYLE_CONTROL | |
84 | }; | |
85 | ||
86 | ||
87 | ||
88 | class wxToolBarToolBase { | |
89 | public: | |
90 | // wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL, | |
91 | // int id = wxID_SEPARATOR, | |
92 | // const wxBitmap& bitmap1 = wxNullBitmap, | |
93 | // const wxBitmap& bitmap2 = wxNullBitmap, | |
94 | // bool toggle = FALSE, | |
95 | // wxObject *clientData = (wxObject *) NULL, | |
96 | // const wxString& shortHelpString = wxEmptyString, | |
97 | // const wxString& longHelpString = wxEmptyString); | |
98 | // wxToolBarToolBase(wxToolBarBase *tbar, wxControl *control); | |
99 | // ~wxToolBarToolBase(); | |
100 | ||
101 | %addmethods { void Destroy() { delete self; } } | |
102 | ||
103 | int GetId(); | |
104 | wxControl *GetControl(); | |
105 | wxToolBarBase *GetToolBar(); | |
106 | int IsButton(); | |
107 | int IsControl(); | |
108 | int IsSeparator(); | |
109 | int GetStyle(); | |
110 | bool IsEnabled(); | |
111 | bool IsToggled(); | |
112 | bool CanBeToggled(); | |
113 | const wxBitmap& GetBitmap1(); | |
114 | const wxBitmap& GetBitmap2(); | |
115 | const wxBitmap& GetBitmap(); | |
116 | wxString GetShortHelp(); | |
117 | wxString GetLongHelp(); | |
118 | bool Enable(bool enable); | |
119 | bool Toggle(bool toggle); | |
120 | bool SetToggle(bool toggle); | |
121 | bool SetShortHelp(const wxString& help); | |
122 | bool SetLongHelp(const wxString& help); | |
123 | void SetBitmap1(const wxBitmap& bmp); | |
124 | void SetBitmap2(const wxBitmap& bmp); | |
125 | void Detach(); | |
126 | void Attach(wxToolBarBase *tbar); | |
127 | ||
128 | //wxObject *GetClientData(); | |
129 | %addmethods { | |
130 | // convert the ClientData back to a PyObject | |
131 | PyObject* GetClientData() { | |
132 | wxPyUserData* udata = (wxPyUserData*)self->GetClientData(); | |
133 | if (udata) { | |
134 | Py_INCREF(udata->m_obj); | |
135 | return udata->m_obj; | |
136 | } else { | |
137 | Py_INCREF(Py_None); | |
138 | return Py_None; | |
139 | } | |
140 | } | |
141 | ||
142 | void SetClientData(PyObject* clientData) { | |
143 | self->SetClientData(new wxPyUserData(clientData)); | |
144 | } | |
145 | } | |
146 | }; | |
147 | ||
148 | ||
149 | ||
150 | class wxToolBarBase : public wxControl { | |
151 | public: | |
152 | ||
153 | // This is an Abstract Base Class | |
154 | ||
155 | %addmethods { | |
156 | // wrap ClientData in a class that knows about PyObjects | |
157 | wxToolBarToolBase *AddTool(int id, | |
158 | const wxBitmap& bitmap, | |
159 | const wxBitmap& pushedBitmap = wxNullBitmap, | |
c368d904 | 160 | int isToggle = FALSE, |
9b3d3bc4 RD |
161 | PyObject *clientData = NULL, |
162 | const wxString& shortHelpString = wxPyEmptyStr, | |
163 | const wxString& longHelpString = wxPyEmptyStr) { | |
164 | wxPyUserData* udata = NULL; | |
165 | if (clientData) | |
166 | udata = new wxPyUserData(clientData); | |
c368d904 | 167 | return self->AddTool(id, bitmap, pushedBitmap, (bool)isToggle, |
9b3d3bc4 RD |
168 | udata, shortHelpString, longHelpString); |
169 | } | |
170 | ||
171 | // This one is easier to use... | |
172 | wxToolBarToolBase *AddSimpleTool(int id, | |
173 | const wxBitmap& bitmap, | |
174 | const wxString& shortHelpString = wxPyEmptyStr, | |
175 | const wxString& longHelpString = wxPyEmptyStr, | |
c368d904 RD |
176 | int isToggle = FALSE) { |
177 | return self->AddTool(id, bitmap, wxNullBitmap, isToggle, NULL, | |
9b3d3bc4 RD |
178 | shortHelpString, longHelpString); |
179 | } | |
180 | ||
181 | ||
182 | // wrap ClientData in a class that knows about PyObjects | |
183 | wxToolBarToolBase *InsertTool(size_t pos, | |
184 | int id, | |
185 | const wxBitmap& bitmap, | |
186 | const wxBitmap& pushedBitmap = wxNullBitmap, | |
c368d904 | 187 | int isToggle = FALSE, |
9b3d3bc4 RD |
188 | PyObject *clientData = NULL, |
189 | const wxString& shortHelpString = wxPyEmptyStr, | |
190 | const wxString& longHelpString = wxPyEmptyStr) { | |
191 | wxPyUserData* udata = NULL; | |
192 | if (clientData) | |
193 | udata = new wxPyUserData(clientData); | |
c368d904 | 194 | return self->InsertTool(pos, id, bitmap, pushedBitmap, (bool)isToggle, |
9b3d3bc4 RD |
195 | udata, shortHelpString, longHelpString); |
196 | } | |
197 | ||
198 | // This one is easier to use... | |
199 | wxToolBarToolBase *InsertSimpleTool(size_t pos, | |
200 | int id, | |
201 | const wxBitmap& bitmap, | |
202 | const wxString& shortHelpString = wxPyEmptyStr, | |
203 | const wxString& longHelpString = wxPyEmptyStr, | |
c368d904 RD |
204 | int isToggle = FALSE) { |
205 | return self->InsertTool(pos, id, bitmap, wxNullBitmap, isToggle, NULL, | |
9b3d3bc4 RD |
206 | shortHelpString, longHelpString); |
207 | } | |
208 | } | |
209 | ||
210 | ||
211 | wxToolBarToolBase *AddControl(wxControl *control); | |
212 | wxToolBarToolBase *InsertControl(size_t pos, wxControl *control); | |
213 | ||
214 | wxToolBarToolBase *AddSeparator(); | |
215 | wxToolBarToolBase *InsertSeparator(size_t pos); | |
216 | ||
217 | wxToolBarToolBase *RemoveTool(int id); | |
218 | ||
219 | bool DeleteToolByPos(size_t pos); | |
220 | bool DeleteTool(int id); | |
221 | void ClearTools(); | |
222 | bool Realize(); | |
223 | ||
224 | void EnableTool(int id, bool enable); | |
225 | void ToggleTool(int id, bool toggle); | |
226 | void SetToggle(int id, bool toggle); | |
227 | ||
228 | ||
229 | %addmethods { | |
230 | // convert the ClientData back to a PyObject | |
231 | PyObject* GetToolClientData(int index) { | |
232 | wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(index); | |
233 | if (udata) { | |
234 | Py_INCREF(udata->m_obj); | |
235 | return udata->m_obj; | |
236 | } else { | |
237 | Py_INCREF(Py_None); | |
238 | return Py_None; | |
239 | } | |
240 | } | |
241 | ||
242 | void SetToolClientData(int index, PyObject* clientData) { | |
243 | self->SetToolClientData(index, new wxPyUserData(clientData)); | |
244 | } | |
245 | } | |
246 | ||
247 | ||
248 | bool GetToolState(int id); | |
249 | bool GetToolEnabled(int id); | |
250 | void SetToolShortHelp(int id, const wxString& helpString); | |
251 | wxString GetToolShortHelp(int id); | |
252 | void SetToolLongHelp(int id, const wxString& helpString); | |
253 | wxString GetToolLongHelp(int id); | |
254 | ||
255 | %name(SetMarginsXY) void SetMargins(int x, int y); | |
256 | void SetMargins(const wxSize& size); | |
257 | void SetToolPacking(int packing); | |
258 | void SetToolSeparation(int separation); | |
259 | wxSize GetToolMargins(); | |
83b18bab | 260 | wxSize GetMargins(); |
9b3d3bc4 RD |
261 | int GetToolPacking(); |
262 | int GetToolSeparation(); | |
263 | ||
264 | void SetRows(int nRows); | |
265 | void SetMaxRowsCols(int rows, int cols); | |
266 | int GetMaxRows(); | |
267 | int GetMaxCols(); | |
268 | ||
269 | void SetToolBitmapSize(const wxSize& size); | |
270 | wxSize GetToolBitmapSize(); | |
271 | wxSize GetToolSize(); | |
272 | ||
273 | }; | |
274 | ||
275 | ||
276 | ||
277 | ||
278 | class wxToolBar : public wxToolBarBase { | |
279 | public: | |
280 | wxToolBar(wxWindow *parent, | |
281 | wxWindowID id, | |
b68dc582 RD |
282 | const wxPoint& pos = wxDefaultPosition, |
283 | const wxSize& size = wxDefaultSize, | |
9b3d3bc4 | 284 | long style = wxNO_BORDER | wxTB_HORIZONTAL, |
8e425133 | 285 | const char* name = wxToolBarNameStr); |
9b3d3bc4 | 286 | |
f6bcfd97 | 287 | %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)" |
9b3d3bc4 RD |
288 | |
289 | wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y); | |
290 | }; | |
291 | ||
292 | ||
293 | ||
294 | ||
295 | class wxToolBarSimple : public wxToolBarBase { | |
296 | public: | |
297 | wxToolBarSimple(wxWindow *parent, | |
298 | wxWindowID id, | |
b68dc582 RD |
299 | const wxPoint& pos = wxDefaultPosition, |
300 | const wxSize& size = wxDefaultSize, | |
9b3d3bc4 | 301 | long style = wxNO_BORDER | wxTB_HORIZONTAL, |
8e425133 | 302 | const char* name = wxToolBarNameStr); |
9b3d3bc4 | 303 | |
f6bcfd97 | 304 | %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)" |
9b3d3bc4 RD |
305 | |
306 | wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y); | |
307 | }; | |
308 | ||
309 | //--------------------------------------------------------------------------- | |
310 | ||
311 | ||
312 | ||
313 | #ifdef THE_OLD_ONE | |
314 | ||
9c039d08 RD |
315 | class wxToolBarTool { |
316 | public: | |
317 | wxToolBarTool(); | |
318 | ~wxToolBarTool(); | |
9b3d3bc4 RD |
319 | void SetSize( long w, long h ) |
320 | long GetWidth (); | |
321 | long GetHeight (); | |
6999b0d8 | 322 | wxControl *GetControl(); |
9c039d08 RD |
323 | |
324 | public: | |
325 | int m_toolStyle; | |
326 | wxObject * m_clientData; | |
327 | int m_index; | |
328 | long m_x; | |
329 | long m_y; | |
330 | long m_width; | |
331 | long m_height; | |
332 | bool m_toggleState; | |
333 | bool m_isToggle; | |
334 | bool m_deleteSecondBitmap; | |
335 | bool m_enabled; | |
336 | wxBitmap m_bitmap1; | |
337 | wxBitmap m_bitmap2; | |
338 | bool m_isMenuCommand; | |
339 | wxString m_shortHelpString; | |
340 | wxString m_longHelpString; | |
341 | }; | |
342 | ||
343 | ||
344 | ||
b26e2dc4 RD |
345 | // class wxToolBarBase : public wxControl { |
346 | // public: | |
347 | ||
348 | class wxToolBar : public wxControl { | |
9c039d08 | 349 | public: |
b26e2dc4 | 350 | wxToolBar(wxWindow* parent, wxWindowID id, |
b68dc582 RD |
351 | const wxPoint& pos = wxDefaultPosition, |
352 | const wxSize& size = wxDefaultSize, | |
b26e2dc4 RD |
353 | long style = wxTB_HORIZONTAL | wxNO_BORDER, |
354 | char* name = "toolBar"); | |
355 | ||
f6bcfd97 | 356 | %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)" |
9c039d08 RD |
357 | |
358 | ||
6999b0d8 | 359 | bool AddControl(wxControl * control); |
08127323 | 360 | void AddSeparator(); |
6999b0d8 | 361 | void ClearTools(); |
9c039d08 RD |
362 | |
363 | // Ignoge the clientData for now... | |
364 | %addmethods { | |
365 | wxToolBarTool* AddTool(int toolIndex, | |
366 | const wxBitmap& bitmap1, | |
367 | const wxBitmap& bitmap2 = wxNullBitmap, | |
368 | int isToggle = FALSE, | |
369 | long xPos = -1, | |
370 | long yPos = -1, | |
371 | //wxObject* clientData = NULL, | |
372 | const wxString& shortHelpString = wxPyEmptyStr, | |
373 | const wxString& longHelpString = wxPyEmptyStr) { | |
374 | return self->AddTool(toolIndex, bitmap1, bitmap2, | |
375 | isToggle, xPos, yPos, NULL, | |
376 | shortHelpString, longHelpString); | |
377 | } | |
08127323 RD |
378 | |
379 | wxToolBarTool* AddSimpleTool(int toolIndex, | |
380 | const wxBitmap& bitmap, | |
381 | const wxString& shortHelpString = wxPyEmptyStr, | |
382 | const wxString& longHelpString = wxPyEmptyStr) { | |
383 | return self->AddTool(toolIndex, bitmap, wxNullBitmap, | |
384 | FALSE, -1, -1, NULL, | |
385 | shortHelpString, longHelpString); | |
386 | } | |
9c039d08 RD |
387 | } |
388 | ||
08127323 | 389 | |
6999b0d8 | 390 | void EnableTool(int toolIndex, bool enable); |
5bff6bb8 | 391 | #ifdef __WXMSW__ |
6999b0d8 | 392 | wxToolBarTool* FindToolForPosition(long x, long y); |
9c039d08 RD |
393 | wxSize GetToolSize(); |
394 | wxSize GetToolBitmapSize(); | |
4f22cf8d | 395 | void SetToolBitmapSize(const wxSize& size); |
9c039d08 | 396 | wxSize GetMaxSize(); |
5bff6bb8 RD |
397 | #endif |
398 | wxSize GetToolMargins(); | |
9c039d08 RD |
399 | // wxObject* GetToolClientData(int toolIndex); |
400 | bool GetToolEnabled(int toolIndex); | |
401 | wxString GetToolLongHelp(int toolIndex); | |
402 | int GetToolPacking(); | |
403 | int GetToolSeparation(); | |
404 | wxString GetToolShortHelp(int toolIndex); | |
405 | bool GetToolState(int toolIndex); | |
406 | ||
9c039d08 RD |
407 | |
408 | bool Realize(); | |
08127323 | 409 | |
9c039d08 | 410 | void SetToolLongHelp(int toolIndex, const wxString& helpString); |
9c039d08 | 411 | void SetToolShortHelp(int toolIndex, const wxString& helpString); |
b26e2dc4 RD |
412 | void SetMargins(const wxSize& size); |
413 | void SetToolPacking(int packing); | |
9c039d08 RD |
414 | void SetToolSeparation(int separation); |
415 | void ToggleTool(int toolIndex, const bool toggle); | |
6999b0d8 | 416 | void SetToggle(int toolIndex, bool toggle); |
6999b0d8 RD |
417 | void SetMaxRowsCols(int rows, int cols); |
418 | int GetMaxRows(); | |
419 | int GetMaxCols(); | |
9c039d08 RD |
420 | }; |
421 | ||
9b3d3bc4 RD |
422 | |
423 | #endif | |
424 | ||
9c039d08 RD |
425 | //--------------------------------------------------------------------------- |
426 |