]>
Commit | Line | Data |
---|---|---|
f6bcfd97 BP |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: grid.i | |
3 | // Purpose: SWIG definitions for the new wxGrid and related classes | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 17-March-2000 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2000 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | %module grid | |
14 | ||
15 | #ifndef OLD_GRID | |
16 | ||
17 | %{ | |
6e2129f9 | 18 | #include "wxPython.h" |
f6bcfd97 | 19 | #include <wx/grid.h> |
19a97bd6 | 20 | #include <wx/generic/gridctrl.h> |
f6bcfd97 BP |
21 | %} |
22 | ||
23 | //---------------------------------------------------------------------- | |
24 | ||
25 | %include typemaps.i | |
26 | %include my_typemaps.i | |
27 | ||
28 | // Import some definitions of other classes, etc. | |
29 | %import _defs.i | |
30 | %import misc.i | |
31 | %import gdi.i | |
32 | %import windows.i | |
33 | %import controls.i | |
34 | %import events.i | |
35 | ||
36 | %pragma(python) code = "import wx" | |
37 | ||
137b5242 RD |
38 | //---------------------------------------------------------------------- |
39 | ||
40 | %{ | |
41 | // Put some wx default wxChar* values into wxStrings. | |
42 | DECLARE_DEF_STRING(PanelNameStr); | |
33ff77f6 RD |
43 | DECLARE_DEF_STRING2(DateTimeFormatStr, wxT("%c")); |
44 | static const wxString wxPyEmptyString(wxT("")); | |
137b5242 RD |
45 | %} |
46 | ||
f6bcfd97 | 47 | //--------------------------------------------------------------------------- |
a66212dc RD |
48 | // OOR related typemaps and helper functions |
49 | ||
50 | %typemap(python, out) wxGridCellRenderer* { $target = wxPyMake_wxGridCellRenderer($source); } | |
51 | %typemap(python, out) wxGridCellEditor* { $target = wxPyMake_wxGridCellEditor($source); } | |
52 | %typemap(python, out) wxGridCellAttr* { $target = wxPyMake_wxGridCellAttr($source); } | |
53 | %typemap(python, out) wxGridCellAttrProvider* { $target = wxPyMake_wxGridCellAttrProvider($source); } | |
54 | %typemap(python, out) wxGridTableBase* { $target = wxPyMake_wxGridTableBase($source); } | |
55 | ||
56 | ||
57 | %{ | |
58 | ||
59 | #define wxPyMake_TEMPLATE(TYPE) \ | |
60 | PyObject* wxPyMake_##TYPE(TYPE* source) { \ | |
61 | PyObject* target = NULL; \ | |
62 | if (source) { \ | |
63 | /* Check if there is already a pointer to a Python object in the \ | |
64 | OOR data that we can use. */ \ | |
65 | wxPyOORClientData* data = (wxPyOORClientData*)source->GetClientObject(); \ | |
66 | if (data) { \ | |
67 | target = data->m_obj; \ | |
68 | Py_INCREF(target); \ | |
69 | } \ | |
70 | /* Otherwise make a new wrapper for it the old fashioned way and \ | |
71 | give it the OOR treatment */ \ | |
72 | if (! target) { \ | |
73 | target = wxPyConstructObject(source, #TYPE, FALSE); \ | |
74 | if (target) \ | |
75 | source->SetClientObject(new wxPyOORClientData(target)); \ | |
76 | } \ | |
77 | } else { /* source was NULL so return None. */ \ | |
78 | Py_INCREF(Py_None); target = Py_None; \ | |
79 | } \ | |
80 | return target; \ | |
81 | } \ | |
82 | ||
83 | ||
84 | wxPyMake_TEMPLATE(wxGridCellRenderer) | |
85 | wxPyMake_TEMPLATE(wxGridCellEditor) | |
86 | wxPyMake_TEMPLATE(wxGridCellAttr) | |
87 | wxPyMake_TEMPLATE(wxGridCellAttrProvider) | |
88 | wxPyMake_TEMPLATE(wxGridTableBase) | |
89 | ||
90 | %} | |
91 | ||
f6bcfd97 BP |
92 | //--------------------------------------------------------------------------- |
93 | // Macros, similar to what's in helpers.h, to aid in the creation of | |
94 | // virtual methods that are able to make callbacks to Python. Many of these | |
95 | // are specific to wxGrid and so are kept here to reduce the mess in helpers.h | |
96 | // a bit. | |
97 | ||
98 | ||
99 | %{ | |
9416aa89 RD |
100 | #define PYCALLBACK_GCA_INTINTKIND(PCLASS, CBNAME) \ |
101 | wxGridCellAttr* CBNAME(int a, int b, wxGridCellAttr::wxAttrKind c) { \ | |
102 | wxGridCellAttr* rval = NULL; \ | |
19a97bd6 | 103 | bool found; \ |
4268f798 | 104 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 105 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
9416aa89 RD |
106 | PyObject* ro; \ |
107 | wxGridCellAttr* ptr; \ | |
108 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iii)", a, b, c)); \ | |
109 | if (ro) { \ | |
f6bcfd97 | 110 | if (!SWIG_GetPtrObj(ro, (void **)&ptr, "_wxGridCellAttr_p")) \ |
9416aa89 RD |
111 | rval = ptr; \ |
112 | Py_DECREF(ro); \ | |
113 | } \ | |
114 | } \ | |
4268f798 | 115 | wxPyEndBlockThreads(); \ |
19a97bd6 | 116 | if (! found) \ |
9416aa89 | 117 | rval = PCLASS::CBNAME(a, b, c); \ |
9416aa89 RD |
118 | return rval; \ |
119 | } \ | |
120 | wxGridCellAttr *base_##CBNAME(int a, int b, wxGridCellAttr::wxAttrKind c) { \ | |
121 | return PCLASS::CBNAME(a, b, c); \ | |
f6bcfd97 BP |
122 | } |
123 | ||
124 | ||
125 | ||
19a97bd6 RD |
126 | #define PYCALLBACK__GCAINTINT(PCLASS, CBNAME) \ |
127 | void CBNAME(wxGridCellAttr *attr, int a, int b) { \ | |
a66212dc | 128 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
129 | bool found; \ |
130 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
a66212dc RD |
131 | PyObject* obj = wxPyMake_wxGridCellAttr(attr); \ |
132 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oii)", obj, a, b)); \ | |
19a97bd6 RD |
133 | Py_DECREF(obj); \ |
134 | } \ | |
a66212dc | 135 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
136 | if (! found) \ |
137 | PCLASS::CBNAME(attr, a, b); \ | |
138 | } \ | |
139 | void base_##CBNAME(wxGridCellAttr *attr, int a, int b) { \ | |
140 | PCLASS::CBNAME(attr, a, b); \ | |
f6bcfd97 BP |
141 | } |
142 | ||
143 | ||
144 | ||
19a97bd6 RD |
145 | #define PYCALLBACK__GCAINT(PCLASS, CBNAME) \ |
146 | void CBNAME(wxGridCellAttr *attr, int val) { \ | |
a66212dc | 147 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
148 | bool found; \ |
149 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
a66212dc | 150 | PyObject* obj = wxPyMake_wxGridCellAttr(attr); \ |
19a97bd6 RD |
151 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, val)); \ |
152 | Py_DECREF(obj); \ | |
153 | } \ | |
4268f798 | 154 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
155 | if (! found) \ |
156 | PCLASS::CBNAME(attr, val); \ | |
157 | } \ | |
158 | void base_##CBNAME(wxGridCellAttr *attr, int val) { \ | |
159 | PCLASS::CBNAME(attr, val); \ | |
f6bcfd97 BP |
160 | } |
161 | ||
162 | ||
163 | ||
19a97bd6 RD |
164 | #define PYCALLBACK_INT__pure(CBNAME) \ |
165 | int CBNAME() { \ | |
4268f798 | 166 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
167 | int rval = 0; \ |
168 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ | |
169 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
4268f798 | 170 | wxPyEndBlockThreads(); \ |
19a97bd6 | 171 | return rval; \ |
f6bcfd97 BP |
172 | } |
173 | ||
174 | ||
175 | ||
19a97bd6 RD |
176 | #define PYCALLBACK_BOOL_INTINT_pure(CBNAME) \ |
177 | bool CBNAME(int a, int b) { \ | |
4268f798 | 178 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
179 | bool rval = 0; \ |
180 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ | |
181 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \ | |
4268f798 | 182 | wxPyEndBlockThreads(); \ |
19a97bd6 | 183 | return rval; \ |
f6bcfd97 BP |
184 | } |
185 | ||
186 | ||
19a97bd6 RD |
187 | #define PYCALLBACK_STRING_INTINT_pure(CBNAME) \ |
188 | wxString CBNAME(int a, int b) { \ | |
a541c325 | 189 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
190 | wxString rval; \ |
191 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ | |
192 | PyObject* ro; \ | |
193 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \ | |
194 | if (ro) { \ | |
a541c325 RD |
195 | rval = Py2wxString(ro); \ |
196 | Py_DECREF(ro); \ | |
19a97bd6 RD |
197 | } \ |
198 | } \ | |
a541c325 | 199 | wxPyEndBlockThreads(); \ |
19a97bd6 | 200 | return rval; \ |
f6bcfd97 BP |
201 | } |
202 | ||
203 | ||
19a97bd6 RD |
204 | #define PYCALLBACK__INTINTSTRING_pure(CBNAME) \ |
205 | void CBNAME(int a, int b, const wxString& c) { \ | |
a541c325 | 206 | wxPyBeginBlockThreads(); \ |
a66212dc RD |
207 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ |
208 | PyObject* s = wx2PyString(c); \ | |
209 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\ | |
210 | Py_DECREF(s); \ | |
211 | } \ | |
a541c325 | 212 | wxPyEndBlockThreads(); \ |
f6bcfd97 BP |
213 | } |
214 | ||
a541c325 | 215 | |
19a97bd6 RD |
216 | #define PYCALLBACK_STRING_INTINT(PCLASS, CBNAME) \ |
217 | wxString CBNAME(int a, int b) { \ | |
218 | bool found; \ | |
a541c325 | 219 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
220 | wxString rval; \ |
221 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
222 | PyObject* ro; \ | |
223 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \ | |
224 | if (ro) { \ | |
a541c325 RD |
225 | rval = Py2wxString(ro); \ |
226 | Py_DECREF(ro); \ | |
19a97bd6 RD |
227 | } \ |
228 | } \ | |
a541c325 | 229 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
230 | if (! found) \ |
231 | rval = PCLASS::CBNAME(a, b); \ | |
232 | return rval; \ | |
233 | } \ | |
234 | wxString base_##CBNAME(int a, int b) { \ | |
235 | return PCLASS::CBNAME(a, b); \ | |
f6bcfd97 BP |
236 | } |
237 | ||
238 | ||
19a97bd6 RD |
239 | #define PYCALLBACK_BOOL_INTINTSTRING(PCLASS, CBNAME) \ |
240 | bool CBNAME(int a, int b, const wxString& c) { \ | |
36fd8ec3 | 241 | bool rval = 0; \ |
19a97bd6 | 242 | bool found; \ |
a541c325 | 243 | wxPyBeginBlockThreads(); \ |
3b3ab7f6 | 244 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
a66212dc RD |
245 | PyObject* s = wx2PyString(c); \ |
246 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\ | |
247 | Py_DECREF(s); \ | |
248 | } \ | |
a541c325 | 249 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
250 | if (! found) \ |
251 | rval = PCLASS::CBNAME(a,b,c); \ | |
252 | return rval; \ | |
253 | } \ | |
254 | bool base_##CBNAME(int a, int b, const wxString& c) { \ | |
255 | return PCLASS::CBNAME(a,b,c); \ | |
f6bcfd97 BP |
256 | } |
257 | ||
258 | ||
259 | ||
260 | ||
19a97bd6 RD |
261 | #define PYCALLBACK_LONG_INTINT(PCLASS, CBNAME) \ |
262 | long CBNAME(int a, int b) { \ | |
263 | long rval; \ | |
264 | bool found; \ | |
4268f798 | 265 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
266 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
267 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ | |
4268f798 | 268 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
269 | if (! found) \ |
270 | rval = PCLASS::CBNAME(a,b); \ | |
271 | return rval; \ | |
272 | } \ | |
273 | long base_##CBNAME(int a, int b) { \ | |
274 | return PCLASS::CBNAME(a,b); \ | |
f6bcfd97 BP |
275 | } |
276 | ||
277 | ||
278 | ||
19a97bd6 RD |
279 | #define PYCALLBACK_BOOL_INTINT(PCLASS, CBNAME) \ |
280 | bool CBNAME(int a, int b) { \ | |
36fd8ec3 | 281 | bool rval = 0; \ |
19a97bd6 | 282 | bool found; \ |
4268f798 | 283 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
284 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
285 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ | |
4268f798 | 286 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
287 | if (! found) \ |
288 | rval = PCLASS::CBNAME(a,b); \ | |
289 | return rval; \ | |
290 | } \ | |
291 | bool base_##CBNAME(int a, int b) { \ | |
292 | return PCLASS::CBNAME(a,b); \ | |
f6bcfd97 BP |
293 | } |
294 | ||
295 | ||
296 | ||
19a97bd6 RD |
297 | #define PYCALLBACK_DOUBLE_INTINT(PCLASS, CBNAME) \ |
298 | double CBNAME(int a, int b) { \ | |
299 | bool found; \ | |
4268f798 | 300 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
301 | double rval; \ |
302 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
303 | PyObject* ro; \ | |
304 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",a,b)); \ | |
305 | if (ro) { \ | |
306 | PyObject* str = PyObject_Str(ro); \ | |
307 | rval = PyFloat_AsDouble(str); \ | |
308 | Py_DECREF(ro); Py_DECREF(str); \ | |
309 | } \ | |
310 | } \ | |
a66212dc | 311 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
312 | if (! found) \ |
313 | rval = PCLASS::CBNAME(a, b); \ | |
314 | return rval; \ | |
315 | } \ | |
316 | double base_##CBNAME(int a, int b) { \ | |
317 | return PCLASS::CBNAME(a, b); \ | |
f6bcfd97 BP |
318 | } |
319 | ||
320 | ||
321 | ||
19a97bd6 RD |
322 | #define PYCALLBACK__(PCLASS, CBNAME) \ |
323 | void CBNAME() { \ | |
324 | bool found; \ | |
a66212dc | 325 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
326 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
327 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
a66212dc | 328 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
329 | if (! found) \ |
330 | PCLASS::CBNAME(); \ | |
331 | } \ | |
332 | void base_##CBNAME() { \ | |
333 | PCLASS::CBNAME(); \ | |
f6bcfd97 BP |
334 | } |
335 | ||
336 | ||
337 | ||
338 | ||
19a97bd6 RD |
339 | #define PYCALLBACK_BOOL_SIZETSIZET(PCLASS, CBNAME) \ |
340 | bool CBNAME(size_t a, size_t b) { \ | |
36fd8ec3 | 341 | bool rval = 0; \ |
19a97bd6 | 342 | bool found; \ |
a66212dc | 343 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
344 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
345 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ | |
a66212dc | 346 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
347 | if (! found) \ |
348 | rval = PCLASS::CBNAME(a,b); \ | |
349 | return rval; \ | |
350 | } \ | |
351 | bool base_##CBNAME(size_t a, size_t b) { \ | |
352 | return PCLASS::CBNAME(a,b); \ | |
f6bcfd97 BP |
353 | } |
354 | ||
355 | ||
356 | ||
19a97bd6 RD |
357 | #define PYCALLBACK_BOOL_SIZET(PCLASS, CBNAME) \ |
358 | bool CBNAME(size_t a) { \ | |
36fd8ec3 | 359 | bool rval = 0; \ |
19a97bd6 | 360 | bool found; \ |
a66212dc | 361 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
362 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
363 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \ | |
a66212dc | 364 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
365 | if (! found) \ |
366 | rval = PCLASS::CBNAME(a); \ | |
367 | return rval; \ | |
368 | } \ | |
369 | bool base_##CBNAME(size_t a) { \ | |
370 | return PCLASS::CBNAME(a); \ | |
f6bcfd97 BP |
371 | } |
372 | ||
373 | ||
19a97bd6 RD |
374 | #define PYCALLBACK_STRING_INT(PCLASS, CBNAME) \ |
375 | wxString CBNAME(int a) { \ | |
376 | bool found; \ | |
a541c325 | 377 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
378 | wxString rval; \ |
379 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
380 | PyObject* ro; \ | |
381 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a)); \ | |
382 | if (ro) { \ | |
a541c325 RD |
383 | rval = Py2wxString(ro); \ |
384 | Py_DECREF(ro); \ | |
19a97bd6 RD |
385 | } \ |
386 | } \ | |
a541c325 | 387 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
388 | if (! found) \ |
389 | rval = PCLASS::CBNAME(a); \ | |
390 | return rval; \ | |
391 | } \ | |
392 | wxString base_##CBNAME(int a) { \ | |
393 | return PCLASS::CBNAME(a); \ | |
f6bcfd97 BP |
394 | } |
395 | ||
396 | ||
19a97bd6 RD |
397 | #define PYCALLBACK__INTSTRING(PCLASS, CBNAME) \ |
398 | void CBNAME(int a, const wxString& c) { \ | |
399 | bool found; \ | |
a541c325 | 400 | wxPyBeginBlockThreads(); \ |
85260f24 | 401 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
a66212dc RD |
402 | PyObject* s = wx2PyString(c); \ |
403 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iO)",a,s)); \ | |
404 | Py_DECREF(s); \ | |
405 | } \ | |
a541c325 | 406 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
407 | if (! found) \ |
408 | PCLASS::CBNAME(a,c); \ | |
409 | } \ | |
410 | void base_##CBNAME(int a, const wxString& c) { \ | |
411 | PCLASS::CBNAME(a,c); \ | |
f6bcfd97 BP |
412 | } |
413 | ||
414 | ||
415 | ||
416 | ||
19a97bd6 RD |
417 | #define PYCALLBACK_BOOL_(PCLASS, CBNAME) \ |
418 | bool CBNAME() { \ | |
36fd8ec3 | 419 | bool rval = 0; \ |
19a97bd6 | 420 | bool found; \ |
a541c325 | 421 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
422 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
423 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
a541c325 | 424 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
425 | if (! found) \ |
426 | rval = PCLASS::CBNAME(); \ | |
427 | return rval; \ | |
428 | } \ | |
429 | bool base_##CBNAME() { \ | |
430 | return PCLASS::CBNAME(); \ | |
f6bcfd97 BP |
431 | } |
432 | ||
433 | ||
434 | ||
19a97bd6 RD |
435 | #define PYCALLBACK__SIZETINT(PCLASS, CBNAME) \ |
436 | void CBNAME(size_t a, int b) { \ | |
437 | bool found; \ | |
a541c325 | 438 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
439 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
440 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b)); \ | |
a541c325 | 441 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
442 | if (! found) \ |
443 | PCLASS::CBNAME(a,b); \ | |
444 | } \ | |
445 | void base_##CBNAME(size_t a, int b) { \ | |
446 | PCLASS::CBNAME(a,b); \ | |
f6bcfd97 BP |
447 | } |
448 | ||
449 | ||
450 | ||
451 | ||
19a97bd6 RD |
452 | #define PYCALLBACK__INTINTLONG(PCLASS, CBNAME) \ |
453 | void CBNAME(int a, int b, long c) { \ | |
454 | bool found; \ | |
a541c325 | 455 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
456 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
457 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c)); \ | |
a541c325 | 458 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
459 | if (! found) \ |
460 | PCLASS::CBNAME(a,b,c); \ | |
461 | } \ | |
462 | void base_##CBNAME(int a, int b, long c) { \ | |
463 | PCLASS::CBNAME(a,b,c); \ | |
f6bcfd97 BP |
464 | } |
465 | ||
466 | ||
467 | ||
468 | ||
19a97bd6 RD |
469 | #define PYCALLBACK__INTINTDOUBLE(PCLASS, CBNAME) \ |
470 | void CBNAME(int a, int b, double c) { \ | |
471 | bool found; \ | |
a541c325 | 472 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
473 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
474 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iif)", a,b,c)); \ | |
a541c325 | 475 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
476 | if (! found) \ |
477 | PCLASS::CBNAME(a,b,c); \ | |
478 | } \ | |
479 | void base_##CBNAME(int a, int b, double c) { \ | |
480 | PCLASS::CBNAME(a,b,c); \ | |
f6bcfd97 BP |
481 | } |
482 | ||
483 | ||
484 | ||
19a97bd6 RD |
485 | #define PYCALLBACK__INTINTBOOL(PCLASS, CBNAME) \ |
486 | void CBNAME(int a, int b, bool c) { \ | |
487 | bool found; \ | |
a541c325 | 488 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
489 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
490 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c)); \ | |
a541c325 | 491 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
492 | if (! found) \ |
493 | PCLASS::CBNAME(a,b,c); \ | |
494 | } \ | |
495 | void base_##CBNAME(int a, int b, bool c) { \ | |
496 | PCLASS::CBNAME(a,b,c); \ | |
f6bcfd97 BP |
497 | } |
498 | ||
499 | ||
500 | ||
501 | ||
33ff77f6 | 502 | %} |
f6bcfd97 | 503 | |
33ff77f6 | 504 | //--------------------------------------------------------------------------- |
f6bcfd97 | 505 | |
33ff77f6 RD |
506 | class wxGridCellCoords; |
507 | class wxGridCellAttr; | |
f6bcfd97 BP |
508 | |
509 | #define wxGRID_VALUE_STRING "string" | |
510 | #define wxGRID_VALUE_BOOL "bool" | |
511 | #define wxGRID_VALUE_NUMBER "long" | |
512 | #define wxGRID_VALUE_FLOAT "double" | |
513 | #define wxGRID_VALUE_CHOICE "choice" | |
514 | #define wxGRID_VALUE_TEXT "string" | |
515 | #define wxGRID_VALUE_LONG "long" | |
33ff77f6 RD |
516 | #define wxGRID_VALUE_CHOICEINT "choiceint" |
517 | #define wxGRID_VALUE_DATETIME "datetime" | |
518 | ||
f6bcfd97 BP |
519 | |
520 | %readonly | |
521 | wxGridCellCoords wxGridNoCellCoords; | |
522 | wxRect wxGridNoCellRect; | |
523 | %readwrite | |
524 | ||
525 | ||
526 | //--------------------------------------------------------------------------- | |
527 | // wxGridCellRenderer is an ABC, and several derived classes are available. | |
528 | // Classes implemented in Python should be derived from wxPyGridCellRenderer. | |
529 | ||
530 | ||
531 | class wxGridCellRenderer | |
532 | { | |
533 | public: | |
33ff77f6 RD |
534 | %addmethods { |
535 | void _setOORInfo(PyObject* _self) { | |
536 | self->SetClientObject(new wxPyOORClientData(_self)); | |
537 | } | |
538 | } | |
539 | ||
f6bcfd97 BP |
540 | void SetParameters(const wxString& params); |
541 | void IncRef(); | |
542 | void DecRef(); | |
543 | ||
544 | virtual void Draw(wxGrid& grid, | |
545 | wxGridCellAttr& attr, | |
546 | wxDC& dc, | |
547 | const wxRect& rect, | |
548 | int row, int col, | |
549 | bool isSelected) = 0; | |
550 | virtual wxSize GetBestSize(wxGrid& grid, | |
551 | wxGridCellAttr& attr, | |
552 | wxDC& dc, | |
553 | int row, int col) = 0; | |
554 | virtual wxGridCellRenderer *Clone() const = 0; | |
555 | }; | |
556 | ||
557 | ||
558 | // The C++ version of wxPyGridCellRenderer | |
559 | %{ | |
560 | class wxPyGridCellRenderer : public wxGridCellRenderer | |
561 | { | |
562 | public: | |
563 | wxPyGridCellRenderer() : wxGridCellRenderer() {}; | |
564 | ||
565 | // Implement Python callback aware virtual methods | |
566 | void Draw(wxGrid& grid, wxGridCellAttr& attr, | |
567 | wxDC& dc, const wxRect& rect, | |
568 | int row, int col, bool isSelected) { | |
4268f798 | 569 | wxPyBeginBlockThreads(); |
1e7ecb7b | 570 | if (wxPyCBH_findCallback(m_myInst, "Draw")) { |
a66212dc RD |
571 | PyObject* go = wxPyMake_wxObject(&grid); |
572 | PyObject* dco = wxPyMake_wxObject(&dc); | |
573 | PyObject* ao = wxPyMake_wxGridCellAttr(&attr); | |
574 | PyObject* ro = wxPyConstructObject((void*)&rect, "wxRect", 0); | |
575 | ||
576 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOOiii)", go, ao, dco, ro, | |
577 | row, col, isSelected)); | |
578 | Py_DECREF(go); | |
579 | Py_DECREF(ao); | |
580 | Py_DECREF(dco); | |
581 | Py_DECREF(ro); | |
f6bcfd97 | 582 | } |
4268f798 | 583 | wxPyEndBlockThreads(); |
f6bcfd97 BP |
584 | } |
585 | ||
586 | wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, | |
587 | int row, int col) { | |
588 | wxSize rval; | |
4268f798 | 589 | wxPyBeginBlockThreads(); |
1e7ecb7b | 590 | if (wxPyCBH_findCallback(m_myInst, "GetBestSize")) { |
f6bcfd97 BP |
591 | PyObject* ro; |
592 | wxSize* ptr; | |
a66212dc RD |
593 | PyObject* go = wxPyMake_wxObject(&grid); |
594 | PyObject* dco = wxPyMake_wxObject(&dc); | |
595 | PyObject* ao = wxPyMake_wxGridCellAttr(&attr); | |
596 | ||
597 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOOii)", | |
598 | go, ao, dco, | |
599 | row, col)); | |
600 | Py_DECREF(go); | |
601 | Py_DECREF(ao); | |
602 | Py_DECREF(dco); | |
603 | ||
f6bcfd97 | 604 | if (ro) { |
db0ff83e RD |
605 | const char* errmsg = "GetBestSize should return a 2-tuple of integers or a wxSize object."; |
606 | if (!SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) { | |
f6bcfd97 | 607 | rval = *ptr; |
db0ff83e RD |
608 | } |
609 | else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { | |
610 | PyObject* o1 = PySequence_GetItem(ro, 0); | |
611 | PyObject* o2 = PySequence_GetItem(ro, 1); | |
612 | if (PyNumber_Check(o1) && PyNumber_Check(o2)) | |
613 | rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); | |
614 | else | |
615 | PyErr_SetString(PyExc_TypeError, errmsg); | |
616 | Py_DECREF(o1); | |
617 | Py_DECREF(o2); | |
618 | } | |
619 | else { | |
620 | PyErr_SetString(PyExc_TypeError, errmsg); | |
621 | } | |
f6bcfd97 BP |
622 | Py_DECREF(ro); |
623 | } | |
624 | } | |
4268f798 | 625 | wxPyEndBlockThreads(); |
f6bcfd97 BP |
626 | return rval; |
627 | } | |
628 | ||
629 | ||
630 | wxGridCellRenderer *Clone() const { | |
631 | wxGridCellRenderer* rval = NULL; | |
4268f798 | 632 | wxPyBeginBlockThreads(); |
1e7ecb7b | 633 | if (wxPyCBH_findCallback(m_myInst, "Clone")) { |
f6bcfd97 BP |
634 | PyObject* ro; |
635 | wxGridCellRenderer* ptr; | |
1e7ecb7b | 636 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); |
f6bcfd97 BP |
637 | if (ro) { |
638 | if (!SWIG_GetPtrObj(ro, (void **)&ptr, "_wxGridCellRenderer_p")) | |
639 | rval = ptr; | |
640 | Py_DECREF(ro); | |
641 | } | |
642 | } | |
4268f798 | 643 | wxPyEndBlockThreads(); |
f6bcfd97 BP |
644 | return rval; |
645 | } | |
646 | ||
647 | DEC_PYCALLBACK__STRING(SetParameters); | |
648 | ||
649 | PYPRIVATE; | |
650 | }; | |
651 | ||
652 | IMP_PYCALLBACK__STRING( wxPyGridCellRenderer, wxGridCellRenderer, SetParameters); | |
653 | ||
654 | %} | |
655 | ||
656 | ||
657 | // Let SWIG know about it so it can create the Python version | |
658 | class wxPyGridCellRenderer : public wxGridCellRenderer { | |
659 | public: | |
660 | wxPyGridCellRenderer(); | |
0122b7e3 RD |
661 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
662 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyGridCellRenderer)" | |
33ff77f6 | 663 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
f6bcfd97 BP |
664 | |
665 | void base_SetParameters(const wxString& params); | |
666 | }; | |
667 | ||
668 | //--------------------------------------------------------------------------- | |
669 | // Predefined Renderers | |
670 | ||
671 | class wxGridCellStringRenderer : public wxGridCellRenderer | |
672 | { | |
673 | public: | |
674 | wxGridCellStringRenderer(); | |
33ff77f6 | 675 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
f6bcfd97 BP |
676 | }; |
677 | ||
678 | ||
679 | class wxGridCellNumberRenderer : public wxGridCellStringRenderer | |
680 | { | |
681 | public: | |
682 | wxGridCellNumberRenderer(); | |
33ff77f6 | 683 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
f6bcfd97 BP |
684 | }; |
685 | ||
686 | ||
687 | class wxGridCellFloatRenderer : public wxGridCellStringRenderer | |
688 | { | |
689 | public: | |
690 | wxGridCellFloatRenderer(int width = -1, int precision = -1); | |
33ff77f6 | 691 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
f6bcfd97 BP |
692 | |
693 | int GetWidth() const; | |
694 | void SetWidth(int width); | |
695 | int GetPrecision() const; | |
696 | void SetPrecision(int precision); | |
697 | }; | |
698 | ||
699 | ||
700 | class wxGridCellBoolRenderer : public wxGridCellRenderer | |
701 | { | |
702 | public: | |
703 | wxGridCellBoolRenderer(); | |
33ff77f6 | 704 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
f6bcfd97 BP |
705 | }; |
706 | ||
707 | ||
19a97bd6 RD |
708 | class wxGridCellDateTimeRenderer : public wxGridCellStringRenderer |
709 | { | |
710 | public: | |
33ff77f6 RD |
711 | wxGridCellDateTimeRenderer(wxString outformat = wxPyDateTimeFormatStr, |
712 | wxString informat = wxPyDateTimeFormatStr); | |
713 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
19a97bd6 RD |
714 | }; |
715 | ||
716 | ||
717 | class wxGridCellEnumRenderer : public wxGridCellStringRenderer | |
718 | { | |
719 | public: | |
33ff77f6 RD |
720 | wxGridCellEnumRenderer( const wxString& choices = wxPyEmptyString ); |
721 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
19a97bd6 RD |
722 | }; |
723 | ||
724 | ||
725 | class wxGridCellAutoWrapStringRenderer : public wxGridCellStringRenderer | |
726 | { | |
727 | public: | |
728 | wxGridCellAutoWrapStringRenderer(); | |
33ff77f6 | 729 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
19a97bd6 RD |
730 | }; |
731 | ||
f6bcfd97 BP |
732 | |
733 | //--------------------------------------------------------------------------- | |
734 | // wxGridCellEditor is an ABC, and several derived classes are available. | |
735 | // Classes implemented in Python should be derived from wxPyGridCellEditor. | |
736 | ||
737 | class wxGridCellEditor | |
738 | { | |
739 | public: | |
33ff77f6 RD |
740 | %addmethods { |
741 | void _setOORInfo(PyObject* _self) { | |
742 | self->SetClientObject(new wxPyOORClientData(_self)); | |
743 | } | |
744 | } | |
745 | ||
f6bcfd97 BP |
746 | bool IsCreated(); |
747 | wxControl* GetControl(); | |
748 | void SetControl(wxControl* control); | |
749 | ||
750 | void SetParameters(const wxString& params); | |
751 | void IncRef(); | |
752 | void DecRef(); | |
753 | ||
754 | virtual void Create(wxWindow* parent, | |
755 | wxWindowID id, | |
756 | wxEvtHandler* evtHandler) = 0; | |
757 | virtual void BeginEdit(int row, int col, wxGrid* grid) = 0; | |
758 | virtual bool EndEdit(int row, int col, wxGrid* grid) = 0; | |
759 | virtual void Reset() = 0; | |
760 | virtual wxGridCellEditor *Clone() const = 0; | |
761 | ||
762 | virtual void SetSize(const wxRect& rect); | |
763 | virtual void Show(bool show, wxGridCellAttr *attr = NULL); | |
764 | virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr); | |
765 | virtual bool IsAcceptedKey(wxKeyEvent& event); | |
766 | virtual void StartingKey(wxKeyEvent& event); | |
767 | virtual void StartingClick(); | |
768 | virtual void HandleReturn(wxKeyEvent& event); | |
769 | virtual void Destroy(); | |
770 | ||
771 | }; | |
772 | ||
773 | ||
774 | // The C++ version of wxPyGridCellEditor | |
775 | %{ | |
776 | class wxPyGridCellEditor : public wxGridCellEditor | |
777 | { | |
778 | public: | |
779 | wxPyGridCellEditor() : wxGridCellEditor() {} | |
780 | ||
781 | void Create(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler) { | |
4268f798 | 782 | wxPyBeginBlockThreads(); |
1e7ecb7b | 783 | if (wxPyCBH_findCallback(m_myInst, "Create")) { |
a66212dc RD |
784 | PyObject* po = wxPyMake_wxObject(parent); |
785 | PyObject* eo = wxPyMake_wxObject(evtHandler); | |
786 | ||
787 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiO)", po, id, eo)); | |
788 | Py_DECREF(po); | |
789 | Py_DECREF(eo); | |
f6bcfd97 | 790 | } |
4268f798 | 791 | wxPyEndBlockThreads(); |
f6bcfd97 BP |
792 | } |
793 | ||
794 | ||
795 | void BeginEdit(int row, int col, wxGrid* grid) { | |
4268f798 | 796 | wxPyBeginBlockThreads(); |
1e7ecb7b | 797 | if (wxPyCBH_findCallback(m_myInst, "BeginEdit")) { |
a66212dc RD |
798 | PyObject* go = wxPyMake_wxObject(grid); |
799 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)", row, col, go)); | |
800 | Py_DECREF(go); | |
f6bcfd97 | 801 | } |
4268f798 | 802 | wxPyEndBlockThreads(); |
f6bcfd97 BP |
803 | } |
804 | ||
805 | ||
806 | bool EndEdit(int row, int col, wxGrid* grid) { | |
807 | bool rv = FALSE; | |
4268f798 | 808 | wxPyBeginBlockThreads(); |
1e7ecb7b | 809 | if (wxPyCBH_findCallback(m_myInst, "EndEdit")) { |
a66212dc RD |
810 | PyObject* go = wxPyMake_wxObject(grid); |
811 | rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)", row, col, go)); | |
812 | Py_DECREF(go); | |
f6bcfd97 | 813 | } |
4268f798 | 814 | wxPyEndBlockThreads(); |
f6bcfd97 BP |
815 | return rv; |
816 | } | |
817 | ||
818 | ||
c368d904 | 819 | wxGridCellEditor*Clone() const { |
f6bcfd97 | 820 | wxGridCellEditor* rval = NULL; |
4268f798 | 821 | wxPyBeginBlockThreads(); |
1e7ecb7b | 822 | if (wxPyCBH_findCallback(m_myInst, "Clone")) { |
f6bcfd97 BP |
823 | PyObject* ro; |
824 | wxGridCellEditor* ptr; | |
1e7ecb7b | 825 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); |
f6bcfd97 BP |
826 | if (ro) { |
827 | if (!SWIG_GetPtrObj(ro, (void **)&ptr, "_wxGridCellEditor_p")) | |
828 | rval = ptr; | |
829 | Py_DECREF(ro); | |
830 | } | |
831 | } | |
4268f798 | 832 | wxPyEndBlockThreads(); |
f6bcfd97 BP |
833 | return rval; |
834 | } | |
835 | ||
836 | ||
837 | void Show(bool show, wxGridCellAttr *attr) { | |
19a97bd6 | 838 | bool found; |
4268f798 | 839 | wxPyBeginBlockThreads(); |
a66212dc RD |
840 | if ((found = wxPyCBH_findCallback(m_myInst, "Show"))) { |
841 | PyObject* ao = wxPyMake_wxGridCellAttr(attr); | |
842 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iO)", show, ao)); | |
843 | Py_DECREF(ao); | |
844 | } | |
4268f798 | 845 | wxPyEndBlockThreads(); |
19a97bd6 | 846 | if (! found) |
f6bcfd97 | 847 | wxGridCellEditor::Show(show, attr); |
f6bcfd97 BP |
848 | } |
849 | void base_Show(bool show, wxGridCellAttr *attr) { | |
850 | wxGridCellEditor::Show(show, attr); | |
851 | } | |
852 | ||
853 | ||
854 | void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr) { | |
a66212dc | 855 | bool found; |
4268f798 | 856 | wxPyBeginBlockThreads(); |
a66212dc RD |
857 | if ((found = wxPyCBH_findCallback(m_myInst, "PaintBackground)"))) { |
858 | PyObject* ao = wxPyMake_wxGridCellAttr(attr); | |
859 | PyObject* ro = wxPyConstructObject((void*)&rectCell, "wxRect", 0); | |
860 | ||
861 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", ro, ao)); | |
862 | ||
863 | Py_DECREF(ro); | |
864 | Py_DECREF(ao); | |
865 | } | |
4268f798 | 866 | wxPyEndBlockThreads(); |
19a97bd6 | 867 | if (! found) |
f6bcfd97 | 868 | wxGridCellEditor::PaintBackground(rectCell, attr); |
f6bcfd97 BP |
869 | } |
870 | void base_PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr) { | |
871 | wxGridCellEditor::PaintBackground(rectCell, attr); | |
872 | } | |
873 | ||
874 | ||
875 | DEC_PYCALLBACK___pure(Reset); | |
876 | DEC_PYCALLBACK__constany(SetSize, wxRect); | |
877 | DEC_PYCALLBACK_bool_any(IsAcceptedKey, wxKeyEvent); | |
878 | DEC_PYCALLBACK__any(StartingKey, wxKeyEvent); | |
879 | DEC_PYCALLBACK__any(HandleReturn, wxKeyEvent); | |
880 | DEC_PYCALLBACK__(StartingClick); | |
881 | DEC_PYCALLBACK__(Destroy); | |
882 | DEC_PYCALLBACK__STRING(SetParameters); | |
883 | ||
884 | PYPRIVATE; | |
885 | }; | |
886 | ||
887 | ||
888 | IMP_PYCALLBACK__STRING( wxPyGridCellEditor, wxGridCellEditor, SetParameters); | |
889 | IMP_PYCALLBACK___pure(wxPyGridCellEditor, wxGridCellEditor, Reset); | |
890 | IMP_PYCALLBACK__constany(wxPyGridCellEditor, wxGridCellEditor, SetSize, wxRect); | |
891 | IMP_PYCALLBACK_bool_any(wxPyGridCellEditor, wxGridCellEditor, IsAcceptedKey, wxKeyEvent); | |
892 | IMP_PYCALLBACK__any(wxPyGridCellEditor, wxGridCellEditor, StartingKey, wxKeyEvent); | |
893 | IMP_PYCALLBACK__any(wxPyGridCellEditor, wxGridCellEditor, HandleReturn, wxKeyEvent); | |
894 | IMP_PYCALLBACK__(wxPyGridCellEditor, wxGridCellEditor, StartingClick); | |
895 | IMP_PYCALLBACK__(wxPyGridCellEditor, wxGridCellEditor, Destroy); | |
896 | ||
897 | %} | |
898 | ||
899 | ||
900 | // Let SWIG know about it so it can create the Python version | |
901 | class wxPyGridCellEditor : public wxGridCellEditor { | |
902 | public: | |
903 | wxPyGridCellEditor(); | |
0122b7e3 RD |
904 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
905 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyGridCellEditor)" | |
33ff77f6 | 906 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
f6bcfd97 BP |
907 | |
908 | void base_SetSize(const wxRect& rect); | |
909 | void base_Show(bool show, wxGridCellAttr *attr = NULL); | |
910 | void base_PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr); | |
abbe77c1 | 911 | void base_IsAcceptedKey(wxKeyEvent& event); |
f6bcfd97 BP |
912 | void base_StartingKey(wxKeyEvent& event); |
913 | void base_StartingClick(); | |
914 | void base_HandleReturn(wxKeyEvent& event); | |
915 | void base_Destroy(); | |
916 | void base_SetParameters(const wxString& params); | |
917 | }; | |
918 | ||
919 | //--------------------------------------------------------------------------- | |
920 | // Predefined Editors | |
921 | ||
922 | class wxGridCellTextEditor : public wxGridCellEditor | |
923 | { | |
924 | public: | |
925 | wxGridCellTextEditor(); | |
33ff77f6 | 926 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
f6bcfd97 BP |
927 | }; |
928 | ||
929 | ||
930 | class wxGridCellNumberEditor : public wxGridCellTextEditor | |
931 | { | |
932 | public: | |
933 | wxGridCellNumberEditor(int min = -1, int max = -1); | |
33ff77f6 | 934 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
f6bcfd97 BP |
935 | }; |
936 | ||
937 | ||
938 | class wxGridCellFloatEditor : public wxGridCellTextEditor | |
939 | { | |
940 | public: | |
941 | wxGridCellFloatEditor(); | |
33ff77f6 | 942 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
f6bcfd97 BP |
943 | }; |
944 | ||
945 | ||
946 | class wxGridCellBoolEditor : public wxGridCellEditor | |
947 | { | |
948 | public: | |
949 | wxGridCellBoolEditor(); | |
33ff77f6 | 950 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
f6bcfd97 BP |
951 | }; |
952 | ||
953 | class wxGridCellChoiceEditor : public wxGridCellEditor | |
954 | { | |
955 | public: | |
956 | wxGridCellChoiceEditor(int LCOUNT = 0, | |
957 | const wxString* choices = NULL, | |
958 | bool allowOthers = FALSE); | |
33ff77f6 | 959 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
f6bcfd97 BP |
960 | }; |
961 | ||
19a97bd6 RD |
962 | |
963 | class wxGridCellEnumEditor : public wxGridCellChoiceEditor | |
964 | { | |
965 | public: | |
33ff77f6 RD |
966 | wxGridCellEnumEditor( const wxString& choices = wxPyEmptyString ); |
967 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
19a97bd6 RD |
968 | }; |
969 | ||
970 | ||
971 | class wxGridCellAutoWrapStringEditor : public wxGridCellTextEditor | |
972 | { | |
973 | public: | |
974 | wxGridCellAutoWrapStringEditor(); | |
33ff77f6 | 975 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
19a97bd6 RD |
976 | }; |
977 | ||
978 | ||
979 | ||
f6bcfd97 BP |
980 | //--------------------------------------------------------------------------- |
981 | ||
982 | ||
983 | class wxGridCellAttr | |
984 | { | |
985 | public: | |
9416aa89 RD |
986 | enum wxAttrKind |
987 | { | |
988 | Any, | |
989 | Default, | |
990 | Cell, | |
991 | Row, | |
992 | Col, | |
993 | Merged | |
994 | }; | |
995 | ||
33ff77f6 RD |
996 | %addmethods { |
997 | void _setOORInfo(PyObject* _self) { | |
998 | self->SetClientObject(new wxPyOORClientData(_self)); | |
999 | } | |
1000 | } | |
1001 | ||
b5a5d647 | 1002 | wxGridCellAttr(wxGridCellAttr *attrDefault = NULL); |
33ff77f6 | 1003 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
f6bcfd97 BP |
1004 | |
1005 | wxGridCellAttr *Clone() const; | |
9416aa89 | 1006 | void MergeWith(wxGridCellAttr *mergefrom); |
f6bcfd97 BP |
1007 | void IncRef(); |
1008 | void DecRef(); | |
1009 | void SetTextColour(const wxColour& colText); | |
1010 | void SetBackgroundColour(const wxColour& colBack); | |
1011 | void SetFont(const wxFont& font); | |
1012 | void SetAlignment(int hAlign, int vAlign); | |
fd512ba2 RD |
1013 | void SetSize(int num_rows, int num_cols); |
1014 | void SetOverflow( bool allow ); | |
f6bcfd97 BP |
1015 | void SetReadOnly(bool isReadOnly = TRUE); |
1016 | ||
1017 | void SetRenderer(wxGridCellRenderer *renderer); | |
1018 | void SetEditor(wxGridCellEditor* editor); | |
9416aa89 | 1019 | void SetKind(wxAttrKind kind); |
f6bcfd97 BP |
1020 | |
1021 | bool HasTextColour() const; | |
1022 | bool HasBackgroundColour() const; | |
1023 | bool HasFont() const; | |
1024 | bool HasAlignment() const; | |
1025 | bool HasRenderer() const; | |
1026 | bool HasEditor() const; | |
9416aa89 | 1027 | bool HasReadWriteMode() const; |
f6bcfd97 | 1028 | |
c5943253 RD |
1029 | wxColour GetTextColour() const; |
1030 | wxColour GetBackgroundColour() const; | |
1031 | wxFont GetFont() const; | |
f6bcfd97 | 1032 | void GetAlignment(int *OUTPUT, int *OUTPUT) const; |
fd512ba2 RD |
1033 | void GetSize(int *num_rows, int *num_cols) const; |
1034 | bool GetOverflow() const; | |
f6bcfd97 BP |
1035 | wxGridCellRenderer *GetRenderer(wxGrid* grid, int row, int col) const; |
1036 | wxGridCellEditor *GetEditor(wxGrid* grid, int row, int col) const; | |
1037 | ||
1038 | bool IsReadOnly() const; | |
1039 | void SetDefAttr(wxGridCellAttr* defAttr); | |
1040 | }; | |
1041 | ||
1042 | //--------------------------------------------------------------------------- | |
1043 | ||
1044 | class wxGridCellAttrProvider | |
1045 | { | |
1046 | public: | |
1047 | wxGridCellAttrProvider(); | |
1048 | // ???? virtual ~wxGridCellAttrProvider(); | |
33ff77f6 RD |
1049 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
1050 | ||
1051 | %addmethods { | |
1052 | void _setOORInfo(PyObject* _self) { | |
1053 | self->SetClientObject(new wxPyOORClientData(_self)); | |
1054 | } | |
1055 | } | |
f6bcfd97 | 1056 | |
9416aa89 RD |
1057 | wxGridCellAttr *GetAttr(int row, int col, |
1058 | wxGridCellAttr::wxAttrKind kind) const; | |
f6bcfd97 BP |
1059 | void SetAttr(wxGridCellAttr *attr, int row, int col); |
1060 | void SetRowAttr(wxGridCellAttr *attr, int row); | |
1061 | void SetColAttr(wxGridCellAttr *attr, int col); | |
1062 | ||
1063 | void UpdateAttrRows( size_t pos, int numRows ); | |
1064 | void UpdateAttrCols( size_t pos, int numCols ); | |
1065 | ||
1066 | }; | |
1067 | ||
1068 | ||
1069 | // A Python-aware version | |
1070 | %{ | |
1071 | class wxPyGridCellAttrProvider : public wxGridCellAttrProvider | |
1072 | { | |
1073 | public: | |
1074 | wxPyGridCellAttrProvider() : wxGridCellAttrProvider() {}; | |
1075 | ||
9416aa89 | 1076 | PYCALLBACK_GCA_INTINTKIND(wxGridCellAttrProvider, GetAttr); |
f6bcfd97 BP |
1077 | PYCALLBACK__GCAINTINT(wxGridCellAttrProvider, SetAttr); |
1078 | PYCALLBACK__GCAINT(wxGridCellAttrProvider, SetRowAttr); | |
1079 | PYCALLBACK__GCAINT(wxGridCellAttrProvider, SetColAttr); | |
1080 | ||
1081 | PYPRIVATE; | |
1082 | }; | |
1083 | %} | |
1084 | ||
1085 | ||
1086 | // The python-aware version get's SWIGified | |
1087 | class wxPyGridCellAttrProvider : public wxGridCellAttrProvider | |
1088 | { | |
1089 | public: | |
1090 | wxPyGridCellAttrProvider(); | |
0122b7e3 RD |
1091 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
1092 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyGridCellAttrProvider)" | |
f6bcfd97 | 1093 | |
9416aa89 RD |
1094 | wxGridCellAttr *base_GetAttr(int row, int col, |
1095 | wxGridCellAttr::wxAttrKind kind); | |
f6bcfd97 BP |
1096 | void base_SetAttr(wxGridCellAttr *attr, int row, int col); |
1097 | void base_SetRowAttr(wxGridCellAttr *attr, int row); | |
1098 | void base_SetColAttr(wxGridCellAttr *attr, int col); | |
1099 | }; | |
1100 | ||
1101 | ||
1102 | //--------------------------------------------------------------------------- | |
1103 | // Grid Table Base class and Python aware version | |
1104 | ||
1105 | ||
9416aa89 | 1106 | class wxGridTableBase : public wxObject |
f6bcfd97 BP |
1107 | { |
1108 | public: | |
1109 | // wxGridTableBase(); This is an ABC | |
1110 | //~wxGridTableBase(); | |
1111 | ||
33ff77f6 RD |
1112 | %addmethods { |
1113 | void _setOORInfo(PyObject* _self) { | |
1114 | self->SetClientObject(new wxPyOORClientData(_self)); | |
1115 | } | |
1116 | } | |
1117 | ||
f6bcfd97 BP |
1118 | void SetAttrProvider(wxGridCellAttrProvider *attrProvider); |
1119 | wxGridCellAttrProvider *GetAttrProvider() const; | |
1120 | void SetView( wxGrid *grid ); | |
1121 | wxGrid * GetView() const; | |
1122 | ||
1123 | ||
1124 | // pure virtuals | |
1125 | virtual int GetNumberRows() = 0; | |
1126 | virtual int GetNumberCols() = 0; | |
1127 | virtual bool IsEmptyCell( int row, int col ) = 0; | |
1128 | virtual wxString GetValue( int row, int col ) = 0; | |
1129 | virtual void SetValue( int row, int col, const wxString& value ) = 0; | |
1130 | ||
1131 | // virtuals overridable in wxPyGridTableBase | |
1132 | virtual wxString GetTypeName( int row, int col ); | |
1133 | virtual bool CanGetValueAs( int row, int col, const wxString& typeName ); | |
1134 | virtual bool CanSetValueAs( int row, int col, const wxString& typeName ); | |
1135 | virtual long GetValueAsLong( int row, int col ); | |
1136 | virtual double GetValueAsDouble( int row, int col ); | |
1137 | virtual bool GetValueAsBool( int row, int col ); | |
1138 | virtual void SetValueAsLong( int row, int col, long value ); | |
1139 | virtual void SetValueAsDouble( int row, int col, double value ); | |
1140 | virtual void SetValueAsBool( int row, int col, bool value ); | |
1141 | ||
1142 | //virtual void* GetValueAsCustom( int row, int col, const wxString& typeName ); | |
1143 | //virtual void SetValueAsCustom( int row, int col, const wxString& typeName, void* value ); | |
1144 | ||
1145 | ||
1146 | virtual void Clear(); | |
1147 | virtual bool InsertRows( size_t pos = 0, size_t numRows = 1 ); | |
1148 | virtual bool AppendRows( size_t numRows = 1 ); | |
1149 | virtual bool DeleteRows( size_t pos = 0, size_t numRows = 1 ); | |
1150 | virtual bool InsertCols( size_t pos = 0, size_t numCols = 1 ); | |
1151 | virtual bool AppendCols( size_t numCols = 1 ); | |
1152 | virtual bool DeleteCols( size_t pos = 0, size_t numCols = 1 ); | |
1153 | ||
1154 | virtual wxString GetRowLabelValue( int row ); | |
1155 | virtual wxString GetColLabelValue( int col ); | |
1156 | virtual void SetRowLabelValue( int row, const wxString& value ); | |
1157 | virtual void SetColLabelValue( int col, const wxString& value ); | |
1158 | ||
1159 | virtual bool CanHaveAttributes(); | |
1160 | ||
9416aa89 RD |
1161 | virtual wxGridCellAttr *GetAttr( int row, int col, |
1162 | wxGridCellAttr::wxAttrKind kind); | |
f6bcfd97 BP |
1163 | virtual void SetAttr(wxGridCellAttr* attr, int row, int col); |
1164 | virtual void SetRowAttr(wxGridCellAttr *attr, int row); | |
1165 | virtual void SetColAttr(wxGridCellAttr *attr, int col); | |
1166 | ||
1167 | }; | |
1168 | ||
1169 | ||
1170 | ||
1171 | // Python-aware version | |
1172 | %{ | |
1173 | class wxPyGridTableBase : public wxGridTableBase | |
1174 | { | |
1175 | public: | |
1176 | wxPyGridTableBase() : wxGridTableBase() {} | |
1177 | ||
1178 | PYCALLBACK_INT__pure(GetNumberRows); | |
1179 | PYCALLBACK_INT__pure(GetNumberCols); | |
1180 | PYCALLBACK_BOOL_INTINT_pure(IsEmptyCell); | |
1181 | PYCALLBACK_STRING_INTINT(wxGridTableBase, GetTypeName); | |
1182 | PYCALLBACK_BOOL_INTINTSTRING(wxGridTableBase, CanGetValueAs); | |
1183 | PYCALLBACK_BOOL_INTINTSTRING(wxGridTableBase, CanSetValueAs); | |
1184 | PYCALLBACK__(wxGridTableBase, Clear); | |
1185 | PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, InsertRows); | |
1186 | PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, DeleteRows); | |
1187 | PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, InsertCols); | |
1188 | PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, DeleteCols); | |
1189 | PYCALLBACK_BOOL_SIZET(wxGridTableBase, AppendRows); | |
1190 | PYCALLBACK_BOOL_SIZET(wxGridTableBase, AppendCols); | |
1191 | PYCALLBACK_STRING_INT(wxGridTableBase, GetRowLabelValue); | |
1192 | PYCALLBACK_STRING_INT(wxGridTableBase, GetColLabelValue); | |
1193 | PYCALLBACK__INTSTRING(wxGridTableBase, SetRowLabelValue); | |
1194 | PYCALLBACK__INTSTRING(wxGridTableBase, SetColLabelValue); | |
1195 | PYCALLBACK_BOOL_(wxGridTableBase, CanHaveAttributes); | |
9416aa89 | 1196 | PYCALLBACK_GCA_INTINTKIND(wxGridTableBase, GetAttr); |
f6bcfd97 BP |
1197 | PYCALLBACK__GCAINTINT(wxGridTableBase, SetAttr); |
1198 | PYCALLBACK__GCAINT(wxGridTableBase, SetRowAttr); | |
1199 | PYCALLBACK__GCAINT(wxGridTableBase, SetColAttr); | |
1200 | ||
1201 | ||
f6bcfd97 | 1202 | wxString GetValue(int row, int col) { |
4268f798 | 1203 | wxPyBeginBlockThreads(); |
f6bcfd97 | 1204 | wxString rval; |
1e7ecb7b | 1205 | if (wxPyCBH_findCallback(m_myInst, "GetValue")) { |
f6bcfd97 | 1206 | PyObject* ro; |
1e7ecb7b | 1207 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",row,col)); |
f6bcfd97 | 1208 | if (ro) { |
a541c325 | 1209 | rval = Py2wxString(ro); |
f6bcfd97 BP |
1210 | Py_DECREF(ro); |
1211 | } | |
1212 | } | |
4268f798 | 1213 | wxPyEndBlockThreads(); |
f6bcfd97 BP |
1214 | return rval; |
1215 | } | |
1216 | ||
1217 | void SetValue(int row, int col, const wxString& val) { | |
4268f798 | 1218 | wxPyBeginBlockThreads(); |
c8bc7bb8 | 1219 | if (wxPyCBH_findCallback(m_myInst, "SetValue")) { |
a66212dc RD |
1220 | PyObject* s = wx2PyString(val); |
1221 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",row,col,s)); | |
1222 | Py_DECREF(s); | |
c8bc7bb8 | 1223 | } |
4268f798 | 1224 | wxPyEndBlockThreads(); |
f6bcfd97 BP |
1225 | } |
1226 | ||
1227 | ||
1228 | // Map the Get/Set methods for the standard non-string types to | |
1229 | // the GetValue and SetValue python methods. | |
1230 | long GetValueAsLong( int row, int col ) { | |
1231 | long rval = 0; | |
4268f798 | 1232 | wxPyBeginBlockThreads(); |
1e7ecb7b | 1233 | if (wxPyCBH_findCallback(m_myInst, "GetValue")) { |
f6bcfd97 BP |
1234 | PyObject* ro; |
1235 | PyObject* num; | |
1e7ecb7b | 1236 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)", row, col)); |
f6bcfd97 BP |
1237 | if (ro && PyNumber_Check(ro)) { |
1238 | num = PyNumber_Int(ro); | |
1239 | if (num) { | |
1240 | rval = PyInt_AsLong(num); | |
1241 | Py_DECREF(num); | |
1242 | } | |
1243 | Py_DECREF(ro); | |
1244 | } | |
1245 | } | |
4268f798 | 1246 | wxPyEndBlockThreads(); |
f6bcfd97 BP |
1247 | return rval; |
1248 | } | |
1249 | ||
1250 | double GetValueAsDouble( int row, int col ) { | |
1251 | double rval = 0.0; | |
4268f798 | 1252 | wxPyBeginBlockThreads(); |
1e7ecb7b | 1253 | if (wxPyCBH_findCallback(m_myInst, "GetValue")) { |
f6bcfd97 BP |
1254 | PyObject* ro; |
1255 | PyObject* num; | |
1e7ecb7b | 1256 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)", row, col)); |
f6bcfd97 BP |
1257 | if (ro && PyNumber_Check(ro)) { |
1258 | num = PyNumber_Float(ro); | |
1259 | if (num) { | |
1260 | rval = PyFloat_AsDouble(num); | |
1261 | Py_DECREF(num); | |
1262 | } | |
1263 | Py_DECREF(ro); | |
1264 | } | |
1265 | } | |
4268f798 | 1266 | wxPyEndBlockThreads(); |
f6bcfd97 BP |
1267 | return rval; |
1268 | } | |
1269 | ||
1270 | bool GetValueAsBool( int row, int col ) { | |
1271 | return (bool)GetValueAsLong(row, col); | |
1272 | } | |
1273 | ||
1274 | void SetValueAsLong( int row, int col, long value ) { | |
4268f798 | 1275 | wxPyBeginBlockThreads(); |
1e7ecb7b RD |
1276 | if (wxPyCBH_findCallback(m_myInst, "SetValue")) { |
1277 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", row, col, value)); | |
f6bcfd97 | 1278 | } |
4268f798 | 1279 | wxPyEndBlockThreads(); |
f6bcfd97 BP |
1280 | } |
1281 | ||
1282 | void SetValueAsDouble( int row, int col, double value ) { | |
4268f798 | 1283 | wxPyBeginBlockThreads(); |
1e7ecb7b RD |
1284 | if (wxPyCBH_findCallback(m_myInst, "SetValue")) { |
1285 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iid)", row, col, value)); | |
f6bcfd97 | 1286 | } |
4268f798 | 1287 | wxPyEndBlockThreads(); |
f6bcfd97 BP |
1288 | } |
1289 | ||
1290 | void SetValueAsBool( int row, int col, bool value ) { | |
1291 | SetValueAsLong( row, col, (long)value ); | |
1292 | } | |
1293 | ||
1294 | ||
1295 | PYPRIVATE; | |
1296 | }; | |
1297 | %} | |
1298 | ||
1299 | ||
1300 | // The python-aware version get's SWIGified | |
1301 | class wxPyGridTableBase : public wxGridTableBase | |
1302 | { | |
1303 | public: | |
1304 | wxPyGridTableBase(); | |
0122b7e3 RD |
1305 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
1306 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyGridTableBase)" | |
33ff77f6 | 1307 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
f6bcfd97 BP |
1308 | |
1309 | %addmethods { void Destroy() { delete self; } } | |
1310 | ||
1311 | wxString base_GetTypeName( int row, int col ); | |
1312 | bool base_CanGetValueAs( int row, int col, const wxString& typeName ); | |
1313 | bool base_CanSetValueAs( int row, int col, const wxString& typeName ); | |
1314 | void base_Clear(); | |
1315 | bool base_InsertRows( size_t pos = 0, size_t numRows = 1 ); | |
1316 | bool base_AppendRows( size_t numRows = 1 ); | |
1317 | bool base_DeleteRows( size_t pos = 0, size_t numRows = 1 ); | |
1318 | bool base_InsertCols( size_t pos = 0, size_t numCols = 1 ); | |
1319 | bool base_AppendCols( size_t numCols = 1 ); | |
1320 | bool base_DeleteCols( size_t pos = 0, size_t numCols = 1 ); | |
1321 | wxString base_GetRowLabelValue( int row ); | |
1322 | wxString base_GetColLabelValue( int col ); | |
1323 | void base_SetRowLabelValue( int row, const wxString& value ); | |
1324 | void base_SetColLabelValue( int col, const wxString& value ); | |
1325 | bool base_CanHaveAttributes(); | |
9416aa89 RD |
1326 | wxGridCellAttr *base_GetAttr( int row, int col, |
1327 | wxGridCellAttr::wxAttrKind kind ); | |
f6bcfd97 BP |
1328 | void base_SetAttr(wxGridCellAttr* attr, int row, int col); |
1329 | void base_SetRowAttr(wxGridCellAttr *attr, int row); | |
1330 | void base_SetColAttr(wxGridCellAttr *attr, int col); | |
1331 | }; | |
1332 | ||
1333 | ||
1334 | //--------------------------------------------------------------------------- | |
1335 | // Predefined Tables | |
1336 | ||
1337 | class wxGridStringTable : public wxGridTableBase | |
1338 | { | |
1339 | public: | |
1340 | wxGridStringTable( int numRows=0, int numCols=0 ); | |
33ff77f6 | 1341 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
f6bcfd97 BP |
1342 | }; |
1343 | ||
1344 | //--------------------------------------------------------------------------- | |
1345 | // The Table can pass messages to the grid to tell it to update itself if | |
1346 | // something has changed. | |
1347 | ||
1348 | enum wxGridTableRequest | |
1349 | { | |
1350 | wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = 2000, | |
1351 | wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES, | |
1352 | wxGRIDTABLE_NOTIFY_ROWS_INSERTED, | |
1353 | wxGRIDTABLE_NOTIFY_ROWS_APPENDED, | |
1354 | wxGRIDTABLE_NOTIFY_ROWS_DELETED, | |
1355 | wxGRIDTABLE_NOTIFY_COLS_INSERTED, | |
1356 | wxGRIDTABLE_NOTIFY_COLS_APPENDED, | |
1357 | wxGRIDTABLE_NOTIFY_COLS_DELETED | |
1358 | }; | |
1359 | ||
1360 | ||
1361 | class wxGridTableMessage | |
1362 | { | |
1363 | public: | |
1364 | wxGridTableMessage( wxGridTableBase *table, int id, | |
1365 | int comInt1 = -1, | |
1366 | int comInt2 = -1 ); | |
1367 | ~wxGridTableMessage(); | |
1368 | ||
1369 | void SetTableObject( wxGridTableBase *table ); | |
1370 | wxGridTableBase * GetTableObject() const; | |
1371 | void SetId( int id ); | |
1372 | int GetId(); | |
1373 | void SetCommandInt( int comInt1 ); | |
1374 | int GetCommandInt(); | |
1375 | void SetCommandInt2( int comInt2 ); | |
1376 | int GetCommandInt2(); | |
1377 | }; | |
1378 | ||
1379 | ||
1380 | //--------------------------------------------------------------------------- | |
1381 | ||
1382 | class wxGridCellCoords | |
1383 | { | |
1384 | public: | |
1385 | wxGridCellCoords( int r=-1, int c=-1 ); | |
1386 | ~wxGridCellCoords(); | |
1387 | ||
1388 | int GetRow() const { return m_row; } | |
1389 | void SetRow( int n ) { m_row = n; } | |
1390 | int GetCol() const { return m_col; } | |
1391 | void SetCol( int n ) { m_col = n; } | |
1392 | void Set( int row, int col ) { m_row = row; m_col = col; } | |
1393 | ||
1394 | %addmethods { | |
1395 | PyObject* asTuple() { | |
1396 | PyObject* tup = PyTuple_New(2); | |
1397 | PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetRow())); | |
1398 | PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->GetCol())); | |
1399 | return tup; | |
1400 | } | |
1401 | ||
1402 | int __cmp__( const wxGridCellCoords& other ) { | |
1403 | return *self != other; | |
1404 | } | |
1405 | } | |
1406 | %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())" | |
1407 | %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())" | |
1408 | }; | |
1409 | ||
1410 | // Typemap to allow conversion of sequence objects to wxGridCellCoords... | |
1411 | %typemap(python,in) wxGridCellCoords& (wxGridCellCoords temp) { | |
1412 | $target = &temp; | |
1413 | if (! wxGridCellCoords_helper($source, &$target)) | |
1414 | return NULL; | |
1415 | } | |
1416 | ||
1417 | // ...and here is the associated helper. | |
1418 | %{ | |
1419 | bool wxGridCellCoords_helper(PyObject* source, wxGridCellCoords** obj) { | |
1420 | ||
1421 | // If source is an object instance then it may already be the right type | |
1422 | if (PyInstance_Check(source)) { | |
1423 | wxGridCellCoords* ptr; | |
1424 | if (SWIG_GetPtrObj(source, (void **)&ptr, "_wxGridCellCoords_p")) | |
1425 | goto error; | |
1426 | *obj = ptr; | |
1427 | return TRUE; | |
1428 | } | |
1429 | // otherwise a 2-tuple of integers is expected | |
1430 | else if (PySequence_Check(source) && PyObject_Length(source) == 2) { | |
1431 | PyObject* o1 = PySequence_GetItem(source, 0); | |
1432 | PyObject* o2 = PySequence_GetItem(source, 1); | |
1433 | **obj = wxGridCellCoords(PyInt_AsLong(o1), PyInt_AsLong(o2)); | |
1434 | return TRUE; | |
1435 | } | |
1436 | ||
1437 | error: | |
1438 | PyErr_SetString(PyExc_TypeError, "Expected a 2-tuple of integers or a wxGridCellCoords object."); | |
1439 | return FALSE; | |
1440 | } | |
1441 | %} | |
1442 | ||
1443 | //--------------------------------------------------------------------------- | |
1444 | //--------------------------------------------------------------------------- | |
1445 | // The grid itself | |
1446 | ||
1447 | ||
1448 | // Fool SWIG into treating this enum as an int | |
1449 | typedef int WXGRIDSELECTIONMODES; | |
1450 | ||
1451 | // but let the C++ code know what it really is. | |
1452 | %{ | |
1453 | typedef wxGrid::wxGridSelectionModes WXGRIDSELECTIONMODES; | |
1454 | %} | |
1455 | ||
1456 | ||
1457 | ||
1458 | class wxGrid : public wxScrolledWindow | |
1459 | { | |
1460 | public: | |
1461 | wxGrid( wxWindow *parent, | |
1462 | wxWindowID id, | |
1463 | const wxPoint& pos = wxDefaultPosition, | |
1464 | const wxSize& size = wxDefaultSize, | |
1465 | long style = wxWANTS_CHARS, | |
137b5242 | 1466 | const wxString& name = wxPyPanelNameStr); |
f6bcfd97 | 1467 | |
0122b7e3 | 1468 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
f6bcfd97 BP |
1469 | |
1470 | enum wxGridSelectionModes {wxGridSelectCells, | |
1471 | wxGridSelectRows, | |
1472 | wxGridSelectColumns}; | |
1473 | ||
1474 | bool CreateGrid( int numRows, int numCols, | |
1475 | WXGRIDSELECTIONMODES selmode = wxGrid::wxGridSelectCells ); | |
1476 | void SetSelectionMode(WXGRIDSELECTIONMODES selmode); | |
1e6796a0 | 1477 | WXGRIDSELECTIONMODES GetSelectionMode(); |
f6bcfd97 BP |
1478 | |
1479 | ||
1480 | // ------ grid dimensions | |
1481 | // | |
1482 | int GetNumberRows(); | |
1483 | int GetNumberCols(); | |
1484 | ||
1485 | ||
f6bcfd97 BP |
1486 | bool ProcessTableMessage( wxGridTableMessage& ); |
1487 | ||
1488 | ||
1489 | wxGridTableBase * GetTable() const; | |
1490 | bool SetTable( wxGridTableBase *table, bool takeOwnership=FALSE, | |
1491 | WXGRIDSELECTIONMODES selmode = | |
1492 | wxGrid::wxGridSelectCells ); | |
1493 | ||
1494 | void ClearGrid(); | |
1495 | bool InsertRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE ); | |
1496 | bool AppendRows( int numRows = 1, bool updateLabels=TRUE ); | |
1497 | bool DeleteRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE ); | |
1498 | bool InsertCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE ); | |
1499 | bool AppendCols( int numCols = 1, bool updateLabels=TRUE ); | |
1500 | bool DeleteCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE ); | |
1501 | ||
f6bcfd97 BP |
1502 | |
1503 | // this function is called when the current cell highlight must be redrawn | |
1504 | // and may be overridden by the user | |
1505 | virtual void DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr ); | |
1506 | ||
f6bcfd97 BP |
1507 | |
1508 | // ------ Cell text drawing functions | |
1509 | // | |
1510 | void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&, | |
1511 | int horizontalAlignment = wxLEFT, | |
1512 | int verticalAlignment = wxTOP ); | |
1513 | ||
b37c7e1d RD |
1514 | // // Split a string containing newline chararcters into an array of |
1515 | // // strings and return the number of lines | |
1516 | // // | |
1517 | // void StringToLines( const wxString& value, wxArrayString& lines ); | |
f6bcfd97 BP |
1518 | |
1519 | void GetTextBoxSize( wxDC& dc, | |
1520 | wxArrayString& lines, | |
1521 | long *OUTPUT, long *OUTPUT ); | |
1522 | ||
1523 | ||
1524 | // ------ | |
1525 | // Code that does a lot of grid modification can be enclosed | |
1526 | // between BeginBatch() and EndBatch() calls to avoid screen | |
1527 | // flicker | |
1528 | // | |
1529 | void BeginBatch(); | |
1530 | void EndBatch(); | |
1531 | int GetBatchCount(); | |
edf2f43e | 1532 | void ForceRefresh(); |
1e6796a0 | 1533 | void Refresh(bool eraseb=TRUE, const wxRect* rect= NULL); |
f6bcfd97 BP |
1534 | |
1535 | ||
1536 | // ------ edit control functions | |
1537 | // | |
fd512ba2 | 1538 | bool IsEditable(); |
f6bcfd97 BP |
1539 | void EnableEditing( bool edit ); |
1540 | ||
1541 | void EnableCellEditControl( bool enable = TRUE ); | |
1542 | void DisableCellEditControl(); | |
1543 | bool CanEnableCellControl() const; | |
1544 | bool IsCellEditControlEnabled() const; | |
1545 | bool IsCellEditControlShown() const; | |
1546 | ||
1547 | bool IsCurrentCellReadOnly() const; | |
1548 | ||
1549 | void ShowCellEditControl(); | |
1550 | void HideCellEditControl(); | |
1551 | void SaveEditControlValue(); | |
1552 | ||
1553 | ||
1554 | // ------ grid location functions | |
1555 | // Note that all of these functions work with the logical coordinates of | |
1556 | // grid cells and labels so you will need to convert from device | |
1557 | // coordinates for mouse events etc. | |
1558 | // | |
1559 | ||
1560 | //void XYToCell( int x, int y, wxGridCellCoords& ); | |
1561 | %addmethods { | |
1562 | %new wxGridCellCoords* XYToCell(int x, int y) { | |
1563 | wxGridCellCoords rv; | |
1564 | self->XYToCell(x, y, rv); | |
1565 | return new wxGridCellCoords(rv); | |
1566 | } | |
1567 | } | |
1568 | ||
1569 | int YToRow( int y ); | |
1570 | int XToCol( int x ); | |
1571 | ||
1572 | int YToEdgeOfRow( int y ); | |
1573 | int XToEdgeOfCol( int x ); | |
1574 | ||
1575 | wxRect CellToRect( int row, int col ); | |
1576 | // TODO: ??? wxRect CellToRect( const wxGridCellCoords& coords ); | |
1577 | ||
1578 | ||
1579 | int GetGridCursorRow(); | |
1580 | int GetGridCursorCol(); | |
1581 | ||
1582 | // check to see if a cell is either wholly visible (the default arg) or | |
1583 | // at least partially visible in the grid window | |
1584 | // | |
1585 | bool IsVisible( int row, int col, bool wholeCellVisible = TRUE ); | |
1586 | // TODO: ??? bool IsVisible( const wxGridCellCoords& coords, bool wholeCellVisible = TRUE ); | |
1587 | void MakeCellVisible( int row, int col ); | |
1588 | // TODO: ??? void MakeCellVisible( const wxGridCellCoords& coords ); | |
1589 | ||
1590 | ||
1591 | // ------ grid cursor movement functions | |
1592 | // | |
1593 | void SetGridCursor( int row, int col ); | |
1594 | bool MoveCursorUp( bool expandSelection ); | |
1595 | bool MoveCursorDown( bool expandSelection ); | |
1596 | bool MoveCursorLeft( bool expandSelection ); | |
1597 | bool MoveCursorRight( bool expandSelection ); | |
1598 | bool MovePageDown(); | |
1599 | bool MovePageUp(); | |
1600 | bool MoveCursorUpBlock( bool expandSelection ); | |
1601 | bool MoveCursorDownBlock( bool expandSelection ); | |
1602 | bool MoveCursorLeftBlock( bool expandSelection ); | |
1603 | bool MoveCursorRightBlock( bool expandSelection ); | |
1604 | ||
1605 | ||
1606 | // ------ label and gridline formatting | |
1607 | // | |
1608 | int GetDefaultRowLabelSize(); | |
1609 | int GetRowLabelSize(); | |
1610 | int GetDefaultColLabelSize(); | |
1611 | int GetColLabelSize(); | |
1612 | wxColour GetLabelBackgroundColour(); | |
1613 | wxColour GetLabelTextColour(); | |
1614 | wxFont GetLabelFont(); | |
1615 | void GetRowLabelAlignment( int *OUTPUT, int *OUTPUT ); | |
1616 | void GetColLabelAlignment( int *OUTPUT, int *OUTPUT ); | |
1617 | wxString GetRowLabelValue( int row ); | |
1618 | wxString GetColLabelValue( int col ); | |
1619 | wxColour GetGridLineColour(); | |
1620 | wxColour GetCellHighlightColour(); | |
9416aa89 RD |
1621 | int GetCellHighlightPenWidth(); |
1622 | int GetCellHighlightROPenWidth(); | |
f6bcfd97 BP |
1623 | |
1624 | void SetRowLabelSize( int width ); | |
1625 | void SetColLabelSize( int height ); | |
1626 | void SetLabelBackgroundColour( const wxColour& ); | |
1627 | void SetLabelTextColour( const wxColour& ); | |
1628 | void SetLabelFont( const wxFont& ); | |
1629 | void SetRowLabelAlignment( int horiz, int vert ); | |
1630 | void SetColLabelAlignment( int horiz, int vert ); | |
1631 | void SetRowLabelValue( int row, const wxString& ); | |
1632 | void SetColLabelValue( int col, const wxString& ); | |
1633 | void SetGridLineColour( const wxColour& ); | |
1634 | void SetCellHighlightColour( const wxColour& ); | |
9416aa89 RD |
1635 | void SetCellHighlightPenWidth(int width); |
1636 | void SetCellHighlightROPenWidth(int width); | |
f6bcfd97 BP |
1637 | |
1638 | void EnableDragRowSize( bool enable = TRUE ); | |
1639 | void DisableDragRowSize(); | |
1640 | bool CanDragRowSize(); | |
1641 | void EnableDragColSize( bool enable = TRUE ); | |
1642 | void DisableDragColSize(); | |
1643 | bool CanDragColSize(); | |
1644 | void EnableDragGridSize(bool enable = TRUE); | |
1645 | void DisableDragGridSize(); | |
1646 | bool CanDragGridSize(); | |
1647 | ||
1648 | // this sets the specified attribute for all cells in this row/col | |
fd512ba2 | 1649 | void SetAttr(int row, int col, wxGridCellAttr *attr); |
f6bcfd97 BP |
1650 | void SetRowAttr(int row, wxGridCellAttr *attr); |
1651 | void SetColAttr(int col, wxGridCellAttr *attr); | |
1652 | ||
1653 | // shortcuts for setting the column parameters | |
1654 | ||
1655 | // set the format for the data in the column: default is string | |
1656 | void SetColFormatBool(int col); | |
1657 | void SetColFormatNumber(int col); | |
1658 | void SetColFormatFloat(int col, int width = -1, int precision = -1); | |
1659 | void SetColFormatCustom(int col, const wxString& typeName); | |
1660 | ||
1661 | void EnableGridLines( bool enable = TRUE ); | |
1662 | bool GridLinesEnabled(); | |
1663 | ||
1664 | // ------ row and col formatting | |
1665 | // | |
1666 | int GetDefaultRowSize(); | |
1667 | int GetRowSize( int row ); | |
1668 | int GetDefaultColSize(); | |
1669 | int GetColSize( int col ); | |
1670 | wxColour GetDefaultCellBackgroundColour(); | |
1671 | wxColour GetCellBackgroundColour( int row, int col ); | |
1672 | wxColour GetDefaultCellTextColour(); | |
1673 | wxColour GetCellTextColour( int row, int col ); | |
1674 | wxFont GetDefaultCellFont(); | |
1675 | wxFont GetCellFont( int row, int col ); | |
1676 | void GetDefaultCellAlignment( int *horiz, int *vert ); | |
1677 | void GetCellAlignment( int row, int col, int *horiz, int *vert ); | |
fd512ba2 RD |
1678 | bool GetDefaultCellOverflow(); |
1679 | bool GetCellOverflow( int row, int col ); | |
1680 | void GetCellSize( int row, int col, int *OUTPUT, int *OUTPUT ); | |
f6bcfd97 BP |
1681 | |
1682 | void SetDefaultRowSize( int height, bool resizeExistingRows = FALSE ); | |
1683 | void SetRowSize( int row, int height ); | |
1684 | void SetDefaultColSize( int width, bool resizeExistingCols = FALSE ); | |
1685 | ||
1686 | void SetColSize( int col, int width ); | |
1687 | ||
1688 | // automatically size the column or row to fit to its contents, if | |
1689 | // setAsMin is TRUE, this optimal width will also be set as minimal width | |
1690 | // for this column | |
1691 | void AutoSizeColumn( int col, bool setAsMin = TRUE ); | |
1692 | void AutoSizeRow( int row, bool setAsMin = TRUE ); | |
1693 | ||
1694 | ||
1695 | // auto size all columns (very ineffective for big grids!) | |
1696 | void AutoSizeColumns( bool setAsMin = TRUE ); | |
1697 | void AutoSizeRows( bool setAsMin = TRUE ); | |
1698 | ||
1699 | // auto size the grid, that is make the columns/rows of the "right" size | |
1700 | // and also set the grid size to just fit its contents | |
1701 | void AutoSize(); | |
1702 | ||
1703 | // column won't be resized to be lesser width - this must be called during | |
1704 | // the grid creation because it won't resize the column if it's already | |
1705 | // narrower than the minimal width | |
1706 | void SetColMinimalWidth( int col, int width ); | |
1707 | void SetRowMinimalHeight( int row, int width ); | |
1708 | ||
1709 | void SetDefaultCellBackgroundColour( const wxColour& ); | |
1710 | void SetCellBackgroundColour( int row, int col, const wxColour& ); | |
1711 | void SetDefaultCellTextColour( const wxColour& ); | |
1712 | ||
1713 | void SetCellTextColour( int row, int col, const wxColour& ); | |
1714 | void SetDefaultCellFont( const wxFont& ); | |
1715 | void SetCellFont( int row, int col, const wxFont& ); | |
1716 | void SetDefaultCellAlignment( int horiz, int vert ); | |
1717 | void SetCellAlignment( int row, int col, int horiz, int vert ); | |
fd512ba2 RD |
1718 | void SetDefaultCellOverflow( bool allow ); |
1719 | void SetCellOverflow( int row, int col, bool allow ); | |
1720 | void SetCellSize( int row, int col, int num_rows, int num_cols ); | |
f6bcfd97 BP |
1721 | |
1722 | // takes ownership of the pointer | |
1723 | void SetDefaultRenderer(wxGridCellRenderer *renderer); | |
1724 | void SetCellRenderer(int row, int col, wxGridCellRenderer *renderer); | |
1725 | wxGridCellRenderer *GetDefaultRenderer() const; | |
1726 | wxGridCellRenderer* GetCellRenderer(int row, int col); | |
1727 | ||
1728 | // takes ownership of the pointer | |
1729 | void SetDefaultEditor(wxGridCellEditor *editor); | |
1730 | void SetCellEditor(int row, int col, wxGridCellEditor *editor); | |
1731 | wxGridCellEditor *GetDefaultEditor() const; | |
1732 | wxGridCellEditor* GetCellEditor(int row, int col); | |
1733 | ||
1734 | ||
1735 | ||
1736 | // ------ cell value accessors | |
1737 | // | |
1738 | wxString GetCellValue( int row, int col ); | |
1739 | // TODO: ??? wxString GetCellValue( const wxGridCellCoords& coords ) | |
1740 | ||
1741 | void SetCellValue( int row, int col, const wxString& s ); | |
1742 | // TODO: ??? void SetCellValue( const wxGridCellCoords& coords, const wxString& s ) | |
1743 | ||
1744 | // returns TRUE if the cell can't be edited | |
1745 | bool IsReadOnly(int row, int col) const; | |
1746 | ||
1747 | // make the cell editable/readonly | |
1748 | void SetReadOnly(int row, int col, bool isReadOnly = TRUE); | |
1749 | ||
1750 | // ------ selections of blocks of cells | |
1751 | // | |
1752 | void SelectRow( int row, bool addToSelected = FALSE ); | |
1753 | void SelectCol( int col, bool addToSelected = FALSE ); | |
1754 | ||
c368d904 RD |
1755 | void SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol, |
1756 | bool addToSelected = FALSE ); | |
f6bcfd97 BP |
1757 | // TODO: ??? void SelectBlock( const wxGridCellCoords& topLeft, |
1758 | // TODO: ??? const wxGridCellCoords& bottomRight ) | |
1759 | ||
1760 | void SelectAll(); | |
1761 | bool IsSelection(); | |
1762 | void ClearSelection(); | |
1763 | bool IsInSelection( int row, int col ); | |
1764 | // TODO: ??? bool IsInSelection( const wxGridCellCoords& coords ) | |
1765 | ||
1e6796a0 RD |
1766 | // TODO: These need typemaps |
1767 | // wxGridCellCoordsArray GetSelectedCells() const; | |
1768 | // wxGridCellCoordsArray GetSelectionBlockTopLeft() const; | |
1769 | // wxGridCellCoordsArray GetSelectionBlockBottomRight() const; | |
1770 | // wxArrayInt GetSelectedRows() const; | |
1771 | // wxArrayInt GetSelectedCols() const; | |
1772 | ||
f6bcfd97 BP |
1773 | |
1774 | // This function returns the rectangle that encloses the block of cells | |
1775 | // limited by TopLeft and BottomRight cell in device coords and clipped | |
1776 | // to the client size of the grid window. | |
1777 | // | |
1778 | wxRect BlockToDeviceRect( const wxGridCellCoords & topLeft, | |
1779 | const wxGridCellCoords & bottomRight ); | |
1780 | ||
1781 | ||
1782 | // Access or update the selection fore/back colours | |
1783 | wxColour GetSelectionBackground() const; | |
1784 | wxColour GetSelectionForeground() const; | |
1785 | ||
1786 | void SetSelectionBackground(const wxColour& c); | |
1787 | void SetSelectionForeground(const wxColour& c); | |
1788 | ||
1789 | ||
1790 | // Methods for a registry for mapping data types to Renderers/Editors | |
1791 | void RegisterDataType(const wxString& typeName, | |
1792 | wxGridCellRenderer* renderer, | |
1793 | wxGridCellEditor* editor); | |
1794 | wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const; | |
1795 | // TODO: ??? wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const | |
1796 | wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const; | |
1797 | wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const; | |
1798 | wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const; | |
1799 | ||
1800 | // grid may occupy more space than needed for its rows/columns, this | |
1801 | // function allows to set how big this extra space is | |
1802 | void SetMargins(int extraWidth, int extraHeight); | |
9416aa89 RD |
1803 | |
1804 | ||
1805 | // Accessors for component windows | |
1806 | wxWindow* GetGridWindow(); | |
1807 | wxWindow* GetGridRowLabelWindow(); | |
1808 | wxWindow* GetGridColLabelWindow(); | |
1809 | wxWindow* GetGridCornerLabelWindow(); | |
1810 | ||
1811 | ||
f6bcfd97 BP |
1812 | }; |
1813 | ||
1814 | ||
1815 | //--------------------------------------------------------------------------- | |
1816 | //--------------------------------------------------------------------------- | |
1817 | // Grid events and stuff | |
1818 | ||
1819 | ||
1820 | ||
1821 | class wxGridEvent : public wxNotifyEvent | |
1822 | { | |
1823 | public: | |
1824 | wxGridEvent(int id, wxEventType type, wxGrid* obj, | |
1825 | int row=-1, int col=-1, int x=-1, int y=-1, bool sel = TRUE, | |
1826 | bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE); | |
1827 | ||
1828 | virtual int GetRow(); | |
1829 | virtual int GetCol(); | |
1830 | wxPoint GetPosition(); | |
1831 | bool Selecting(); | |
1832 | bool ControlDown(); | |
1833 | bool MetaDown(); | |
1834 | bool ShiftDown(); | |
1835 | bool AltDown(); | |
1836 | ||
1837 | }; | |
1838 | ||
1839 | ||
1840 | class wxGridSizeEvent : public wxNotifyEvent | |
1841 | { | |
1842 | public: | |
1843 | wxGridSizeEvent(int id, wxEventType type, wxGrid* obj, | |
1844 | int rowOrCol=-1, int x=-1, int y=-1, | |
1845 | bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE); | |
1846 | ||
1847 | int GetRowOrCol(); | |
1848 | wxPoint GetPosition(); | |
1849 | bool ControlDown(); | |
1850 | bool MetaDown(); | |
1851 | bool ShiftDown(); | |
1852 | bool AltDown(); | |
1853 | ||
1854 | }; | |
1855 | ||
1856 | ||
1857 | class wxGridRangeSelectEvent : public wxNotifyEvent | |
1858 | { | |
1859 | public: | |
1860 | wxGridRangeSelectEvent(int id, wxEventType type, wxGrid* obj, | |
1861 | const wxGridCellCoords& topLeft, | |
1862 | const wxGridCellCoords& bottomRight, | |
1863 | bool sel = TRUE, | |
1864 | bool control=FALSE, bool shift=FALSE, | |
1865 | bool alt=FALSE, bool meta=FALSE); | |
1866 | ||
1867 | wxGridCellCoords GetTopLeftCoords(); | |
1868 | wxGridCellCoords GetBottomRightCoords(); | |
1869 | int GetTopRow(); | |
1870 | int GetBottomRow(); | |
1871 | int GetLeftCol(); | |
1872 | int GetRightCol(); | |
1873 | bool Selecting(); | |
1874 | bool ControlDown(); | |
1875 | bool MetaDown(); | |
1876 | bool ShiftDown(); | |
1877 | bool AltDown(); | |
1878 | }; | |
1879 | ||
bf7945ce RD |
1880 | |
1881 | class wxGridEditorCreatedEvent : public wxCommandEvent { | |
1882 | public: | |
1883 | wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj, | |
1884 | int row, int col, wxControl* ctrl); | |
1885 | ||
1886 | int GetRow(); | |
1887 | int GetCol(); | |
1888 | wxControl* GetControl(); | |
1889 | void SetRow(int row); | |
1890 | void SetCol(int col); | |
1891 | void SetControl(wxControl* ctrl); | |
1892 | }; | |
1893 | ||
1894 | ||
1895 | ||
f6bcfd97 BP |
1896 | enum { |
1897 | wxEVT_GRID_CELL_LEFT_CLICK, | |
1898 | wxEVT_GRID_CELL_RIGHT_CLICK, | |
1899 | wxEVT_GRID_CELL_LEFT_DCLICK, | |
1900 | wxEVT_GRID_CELL_RIGHT_DCLICK, | |
1901 | wxEVT_GRID_LABEL_LEFT_CLICK, | |
1902 | wxEVT_GRID_LABEL_RIGHT_CLICK, | |
1903 | wxEVT_GRID_LABEL_LEFT_DCLICK, | |
1904 | wxEVT_GRID_LABEL_RIGHT_DCLICK, | |
1905 | wxEVT_GRID_ROW_SIZE, | |
1906 | wxEVT_GRID_COL_SIZE, | |
1907 | wxEVT_GRID_RANGE_SELECT, | |
1908 | wxEVT_GRID_CELL_CHANGE, | |
1909 | wxEVT_GRID_SELECT_CELL, | |
1910 | wxEVT_GRID_EDITOR_SHOWN, | |
1911 | wxEVT_GRID_EDITOR_HIDDEN, | |
bf7945ce | 1912 | wxEVT_GRID_EDITOR_CREATED, |
f6bcfd97 BP |
1913 | }; |
1914 | ||
1915 | ||
1916 | ||
1917 | %pragma(python) code = " | |
1918 | def EVT_GRID_CELL_LEFT_CLICK(win, fn): | |
1919 | win.Connect(-1, -1, wxEVT_GRID_CELL_LEFT_CLICK, fn) | |
1920 | ||
1921 | def EVT_GRID_CELL_RIGHT_CLICK(win, fn): | |
1922 | win.Connect(-1, -1, wxEVT_GRID_CELL_RIGHT_CLICK, fn) | |
1923 | ||
1924 | def EVT_GRID_CELL_LEFT_DCLICK(win, fn): | |
1925 | win.Connect(-1, -1, wxEVT_GRID_CELL_LEFT_DCLICK, fn) | |
1926 | ||
1927 | def EVT_GRID_CELL_RIGHT_DCLICK(win, fn): | |
1928 | win.Connect(-1, -1, wxEVT_GRID_CELL_RIGHT_DCLICK, fn) | |
1929 | ||
1930 | def EVT_GRID_LABEL_LEFT_CLICK(win, fn): | |
1931 | win.Connect(-1, -1, wxEVT_GRID_LABEL_LEFT_CLICK, fn) | |
1932 | ||
1933 | def EVT_GRID_LABEL_RIGHT_CLICK(win, fn): | |
1934 | win.Connect(-1, -1, wxEVT_GRID_LABEL_RIGHT_CLICK, fn) | |
1935 | ||
1936 | def EVT_GRID_LABEL_LEFT_DCLICK(win, fn): | |
1937 | win.Connect(-1, -1, wxEVT_GRID_LABEL_LEFT_DCLICK, fn) | |
1938 | ||
1939 | def EVT_GRID_LABEL_RIGHT_DCLICK(win, fn): | |
1940 | win.Connect(-1, -1, wxEVT_GRID_LABEL_RIGHT_DCLICK, fn) | |
1941 | ||
1942 | def EVT_GRID_ROW_SIZE(win, fn): | |
1943 | win.Connect(-1, -1, wxEVT_GRID_ROW_SIZE, fn) | |
1944 | ||
1945 | def EVT_GRID_COL_SIZE(win, fn): | |
1946 | win.Connect(-1, -1, wxEVT_GRID_COL_SIZE, fn) | |
1947 | ||
1948 | def EVT_GRID_RANGE_SELECT(win, fn): | |
1949 | win.Connect(-1, -1, wxEVT_GRID_RANGE_SELECT, fn) | |
1950 | ||
1951 | def EVT_GRID_CELL_CHANGE(win, fn): | |
1952 | win.Connect(-1, -1, wxEVT_GRID_CELL_CHANGE, fn) | |
1953 | ||
1954 | def EVT_GRID_SELECT_CELL(win, fn): | |
1955 | win.Connect(-1, -1, wxEVT_GRID_SELECT_CELL, fn) | |
1956 | ||
1957 | def EVT_GRID_EDITOR_SHOWN(win, fn): | |
1958 | win.Connect(-1, -1, wxEVT_GRID_EDITOR_SHOWN, fn) | |
1959 | ||
1960 | def EVT_GRID_EDITOR_HIDDEN(win, fn): | |
1961 | win.Connect(-1, -1, wxEVT_GRID_EDITOR_HIDDEN, fn) | |
1962 | ||
bf7945ce RD |
1963 | def EVT_GRID_EDITOR_CREATED(win, fn): |
1964 | win.Connect(-1, -1, wxEVT_GRID_EDITOR_CREATED, fn) | |
1965 | ||
f6bcfd97 BP |
1966 | " |
1967 | ||
1968 | //--------------------------------------------------------------------------- | |
1969 | ||
e508a2b6 RD |
1970 | %init %{ |
1971 | wxClassInfo::CleanUpClasses(); | |
1972 | wxClassInfo::InitializeClasses(); | |
1973 | %} | |
1974 | ||
1975 | //--------------------------------------------------------------------------- | |
1976 | ||
f6bcfd97 BP |
1977 | %pragma(python) include="_gridextras.py"; |
1978 | ||
1979 | //--------------------------------------------------------------------------- | |
1980 | ||
1981 | ||
1982 | #endif |