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