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