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