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