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