]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/grid.i
compilation error fix (trailing comma in an enum)
[wxWidgets.git] / wxPython / src / grid.i
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, #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 (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 (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, "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 void SetParameters(const wxString& params);
751 void IncRef();
752 void DecRef();
753
754 virtual void Create(wxWindow* parent,
755 wxWindowID id,
756 wxEvtHandler* evtHandler) = 0;
757 virtual void BeginEdit(int row, int col, wxGrid* grid) = 0;
758 virtual bool EndEdit(int row, int col, wxGrid* grid) = 0;
759 virtual void Reset() = 0;
760 virtual wxGridCellEditor *Clone() const = 0;
761
762 virtual void SetSize(const wxRect& rect);
763 virtual void Show(bool show, wxGridCellAttr *attr = NULL);
764 virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
765 virtual bool IsAcceptedKey(wxKeyEvent& event);
766 virtual void StartingKey(wxKeyEvent& event);
767 virtual void StartingClick();
768 virtual void HandleReturn(wxKeyEvent& event);
769 virtual void Destroy();
770
771 };
772
773
774 // The C++ version of wxPyGridCellEditor
775 %{
776 class wxPyGridCellEditor : public wxGridCellEditor
777 {
778 public:
779 wxPyGridCellEditor() : wxGridCellEditor() {}
780
781 void Create(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler) {
782 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();
792 }
793
794
795 void BeginEdit(int row, int col, wxGrid* grid) {
796 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();
803 }
804
805
806 bool EndEdit(int row, int col, wxGrid* grid) {
807 bool rv = FALSE;
808 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();
815 return rv;
816 }
817
818
819 wxGridCellEditor*Clone() const {
820 wxGridCellEditor* rval = NULL;
821 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 (!SWIG_GetPtrObj(ro, (void **)&ptr, "_wxGridCellEditor_p"))
828 rval = ptr;
829 Py_DECREF(ro);
830 }
831 }
832 wxPyEndBlockThreads();
833 return rval;
834 }
835
836
837 void Show(bool show, wxGridCellAttr *attr) {
838 bool found;
839 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();
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 wxPyBeginBlockThreads();
857 if ((found = wxPyCBH_findCallback(m_myInst, "PaintBackground)"))) {
858 PyObject* ao = wxPyMake_wxGridCellAttr(attr);
859 PyObject* ro = wxPyConstructObject((void*)&rectCell, "wxRect", 0);
860
861 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", ro, ao));
862
863 Py_DECREF(ro);
864 Py_DECREF(ao);
865 }
866 wxPyEndBlockThreads();
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
884 PYPRIVATE;
885 };
886
887
888 IMP_PYCALLBACK__STRING( wxPyGridCellEditor, wxGridCellEditor, SetParameters);
889 IMP_PYCALLBACK___pure(wxPyGridCellEditor, wxGridCellEditor, Reset);
890 IMP_PYCALLBACK__constany(wxPyGridCellEditor, wxGridCellEditor, SetSize, wxRect);
891 IMP_PYCALLBACK_bool_any(wxPyGridCellEditor, wxGridCellEditor, IsAcceptedKey, wxKeyEvent);
892 IMP_PYCALLBACK__any(wxPyGridCellEditor, wxGridCellEditor, StartingKey, wxKeyEvent);
893 IMP_PYCALLBACK__any(wxPyGridCellEditor, wxGridCellEditor, HandleReturn, wxKeyEvent);
894 IMP_PYCALLBACK__(wxPyGridCellEditor, wxGridCellEditor, StartingClick);
895 IMP_PYCALLBACK__(wxPyGridCellEditor, wxGridCellEditor, Destroy);
896
897 %}
898
899
900 // Let SWIG know about it so it can create the Python version
901 class wxPyGridCellEditor : public wxGridCellEditor {
902 public:
903 wxPyGridCellEditor();
904 void _setCallbackInfo(PyObject* self, PyObject* _class);
905 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyGridCellEditor)"
906 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
907
908 void base_SetSize(const wxRect& rect);
909 void base_Show(bool show, wxGridCellAttr *attr = NULL);
910 void base_PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
911 void base_IsAcceptedKey(wxKeyEvent& event);
912 void base_StartingKey(wxKeyEvent& event);
913 void base_StartingClick();
914 void base_HandleReturn(wxKeyEvent& event);
915 void base_Destroy();
916 void base_SetParameters(const wxString& params);
917 };
918
919 //---------------------------------------------------------------------------
920 // Predefined Editors
921
922 class wxGridCellTextEditor : public wxGridCellEditor
923 {
924 public:
925 wxGridCellTextEditor();
926 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
927 };
928
929
930 class wxGridCellNumberEditor : public wxGridCellTextEditor
931 {
932 public:
933 wxGridCellNumberEditor(int min = -1, int max = -1);
934 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
935 };
936
937
938 class wxGridCellFloatEditor : public wxGridCellTextEditor
939 {
940 public:
941 wxGridCellFloatEditor();
942 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
943 };
944
945
946 class wxGridCellBoolEditor : public wxGridCellEditor
947 {
948 public:
949 wxGridCellBoolEditor();
950 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
951 };
952
953 class wxGridCellChoiceEditor : public wxGridCellEditor
954 {
955 public:
956 wxGridCellChoiceEditor(int LCOUNT = 0,
957 const wxString* choices = NULL,
958 bool allowOthers = FALSE);
959 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
960 };
961
962
963 class wxGridCellEnumEditor : public wxGridCellChoiceEditor
964 {
965 public:
966 wxGridCellEnumEditor( const wxString& choices = wxPyEmptyString );
967 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
968 };
969
970
971 class wxGridCellAutoWrapStringEditor : public wxGridCellTextEditor
972 {
973 public:
974 wxGridCellAutoWrapStringEditor();
975 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
976 };
977
978
979
980 //---------------------------------------------------------------------------
981
982
983 class wxGridCellAttr
984 {
985 public:
986 enum wxAttrKind
987 {
988 Any,
989 Default,
990 Cell,
991 Row,
992 Col,
993 Merged
994 };
995
996 %addmethods {
997 void _setOORInfo(PyObject* _self) {
998 self->SetClientObject(new wxPyOORClientData(_self));
999 }
1000 }
1001
1002 wxGridCellAttr(wxGridCellAttr *attrDefault = NULL);
1003 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1004
1005 wxGridCellAttr *Clone() const;
1006 void MergeWith(wxGridCellAttr *mergefrom);
1007 void IncRef();
1008 void DecRef();
1009 void SetTextColour(const wxColour& colText);
1010 void SetBackgroundColour(const wxColour& colBack);
1011 void SetFont(const wxFont& font);
1012 void SetAlignment(int hAlign, int vAlign);
1013 void SetReadOnly(bool isReadOnly = TRUE);
1014
1015 void SetRenderer(wxGridCellRenderer *renderer);
1016 void SetEditor(wxGridCellEditor* editor);
1017 void SetKind(wxAttrKind kind);
1018
1019 bool HasTextColour() const;
1020 bool HasBackgroundColour() const;
1021 bool HasFont() const;
1022 bool HasAlignment() const;
1023 bool HasRenderer() const;
1024 bool HasEditor() const;
1025 bool HasReadWriteMode() const;
1026
1027 wxColour GetTextColour() const;
1028 wxColour GetBackgroundColour() const;
1029 wxFont GetFont() const;
1030 void GetAlignment(int *OUTPUT, int *OUTPUT) const;
1031 wxGridCellRenderer *GetRenderer(wxGrid* grid, int row, int col) const;
1032 wxGridCellEditor *GetEditor(wxGrid* grid, int row, int col) const;
1033
1034 bool IsReadOnly() const;
1035 void SetDefAttr(wxGridCellAttr* defAttr);
1036 };
1037
1038 //---------------------------------------------------------------------------
1039
1040 class wxGridCellAttrProvider
1041 {
1042 public:
1043 wxGridCellAttrProvider();
1044 // ???? virtual ~wxGridCellAttrProvider();
1045 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1046
1047 %addmethods {
1048 void _setOORInfo(PyObject* _self) {
1049 self->SetClientObject(new wxPyOORClientData(_self));
1050 }
1051 }
1052
1053 wxGridCellAttr *GetAttr(int row, int col,
1054 wxGridCellAttr::wxAttrKind kind) const;
1055 void SetAttr(wxGridCellAttr *attr, int row, int col);
1056 void SetRowAttr(wxGridCellAttr *attr, int row);
1057 void SetColAttr(wxGridCellAttr *attr, int col);
1058
1059 void UpdateAttrRows( size_t pos, int numRows );
1060 void UpdateAttrCols( size_t pos, int numCols );
1061
1062 };
1063
1064
1065 // A Python-aware version
1066 %{
1067 class wxPyGridCellAttrProvider : public wxGridCellAttrProvider
1068 {
1069 public:
1070 wxPyGridCellAttrProvider() : wxGridCellAttrProvider() {};
1071
1072 PYCALLBACK_GCA_INTINTKIND(wxGridCellAttrProvider, GetAttr);
1073 PYCALLBACK__GCAINTINT(wxGridCellAttrProvider, SetAttr);
1074 PYCALLBACK__GCAINT(wxGridCellAttrProvider, SetRowAttr);
1075 PYCALLBACK__GCAINT(wxGridCellAttrProvider, SetColAttr);
1076
1077 PYPRIVATE;
1078 };
1079 %}
1080
1081
1082 // The python-aware version get's SWIGified
1083 class wxPyGridCellAttrProvider : public wxGridCellAttrProvider
1084 {
1085 public:
1086 wxPyGridCellAttrProvider();
1087 void _setCallbackInfo(PyObject* self, PyObject* _class);
1088 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyGridCellAttrProvider)"
1089
1090 wxGridCellAttr *base_GetAttr(int row, int col,
1091 wxGridCellAttr::wxAttrKind kind);
1092 void base_SetAttr(wxGridCellAttr *attr, int row, int col);
1093 void base_SetRowAttr(wxGridCellAttr *attr, int row);
1094 void base_SetColAttr(wxGridCellAttr *attr, int col);
1095 };
1096
1097
1098 //---------------------------------------------------------------------------
1099 // Grid Table Base class and Python aware version
1100
1101
1102 class wxGridTableBase : public wxObject
1103 {
1104 public:
1105 // wxGridTableBase(); This is an ABC
1106 //~wxGridTableBase();
1107
1108 %addmethods {
1109 void _setOORInfo(PyObject* _self) {
1110 self->SetClientObject(new wxPyOORClientData(_self));
1111 }
1112 }
1113
1114 void SetAttrProvider(wxGridCellAttrProvider *attrProvider);
1115 wxGridCellAttrProvider *GetAttrProvider() const;
1116 void SetView( wxGrid *grid );
1117 wxGrid * GetView() const;
1118
1119
1120 // pure virtuals
1121 virtual int GetNumberRows() = 0;
1122 virtual int GetNumberCols() = 0;
1123 virtual bool IsEmptyCell( int row, int col ) = 0;
1124 virtual wxString GetValue( int row, int col ) = 0;
1125 virtual void SetValue( int row, int col, const wxString& value ) = 0;
1126
1127 // virtuals overridable in wxPyGridTableBase
1128 virtual wxString GetTypeName( int row, int col );
1129 virtual bool CanGetValueAs( int row, int col, const wxString& typeName );
1130 virtual bool CanSetValueAs( int row, int col, const wxString& typeName );
1131 virtual long GetValueAsLong( int row, int col );
1132 virtual double GetValueAsDouble( int row, int col );
1133 virtual bool GetValueAsBool( int row, int col );
1134 virtual void SetValueAsLong( int row, int col, long value );
1135 virtual void SetValueAsDouble( int row, int col, double value );
1136 virtual void SetValueAsBool( int row, int col, bool value );
1137
1138 //virtual void* GetValueAsCustom( int row, int col, const wxString& typeName );
1139 //virtual void SetValueAsCustom( int row, int col, const wxString& typeName, void* value );
1140
1141
1142 virtual void Clear();
1143 virtual bool InsertRows( size_t pos = 0, size_t numRows = 1 );
1144 virtual bool AppendRows( size_t numRows = 1 );
1145 virtual bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
1146 virtual bool InsertCols( size_t pos = 0, size_t numCols = 1 );
1147 virtual bool AppendCols( size_t numCols = 1 );
1148 virtual bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
1149
1150 virtual wxString GetRowLabelValue( int row );
1151 virtual wxString GetColLabelValue( int col );
1152 virtual void SetRowLabelValue( int row, const wxString& value );
1153 virtual void SetColLabelValue( int col, const wxString& value );
1154
1155 virtual bool CanHaveAttributes();
1156
1157 virtual wxGridCellAttr *GetAttr( int row, int col,
1158 wxGridCellAttr::wxAttrKind kind);
1159 virtual void SetAttr(wxGridCellAttr* attr, int row, int col);
1160 virtual void SetRowAttr(wxGridCellAttr *attr, int row);
1161 virtual void SetColAttr(wxGridCellAttr *attr, int col);
1162
1163 };
1164
1165
1166
1167 // Python-aware version
1168 %{
1169 class wxPyGridTableBase : public wxGridTableBase
1170 {
1171 public:
1172 wxPyGridTableBase() : wxGridTableBase() {}
1173
1174 PYCALLBACK_INT__pure(GetNumberRows);
1175 PYCALLBACK_INT__pure(GetNumberCols);
1176 PYCALLBACK_BOOL_INTINT_pure(IsEmptyCell);
1177 PYCALLBACK_STRING_INTINT(wxGridTableBase, GetTypeName);
1178 PYCALLBACK_BOOL_INTINTSTRING(wxGridTableBase, CanGetValueAs);
1179 PYCALLBACK_BOOL_INTINTSTRING(wxGridTableBase, CanSetValueAs);
1180 PYCALLBACK__(wxGridTableBase, Clear);
1181 PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, InsertRows);
1182 PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, DeleteRows);
1183 PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, InsertCols);
1184 PYCALLBACK_BOOL_SIZETSIZET(wxGridTableBase, DeleteCols);
1185 PYCALLBACK_BOOL_SIZET(wxGridTableBase, AppendRows);
1186 PYCALLBACK_BOOL_SIZET(wxGridTableBase, AppendCols);
1187 PYCALLBACK_STRING_INT(wxGridTableBase, GetRowLabelValue);
1188 PYCALLBACK_STRING_INT(wxGridTableBase, GetColLabelValue);
1189 PYCALLBACK__INTSTRING(wxGridTableBase, SetRowLabelValue);
1190 PYCALLBACK__INTSTRING(wxGridTableBase, SetColLabelValue);
1191 PYCALLBACK_BOOL_(wxGridTableBase, CanHaveAttributes);
1192 PYCALLBACK_GCA_INTINTKIND(wxGridTableBase, GetAttr);
1193 PYCALLBACK__GCAINTINT(wxGridTableBase, SetAttr);
1194 PYCALLBACK__GCAINT(wxGridTableBase, SetRowAttr);
1195 PYCALLBACK__GCAINT(wxGridTableBase, SetColAttr);
1196
1197
1198 wxString GetValue(int row, int col) {
1199 wxPyBeginBlockThreads();
1200 wxString rval;
1201 if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
1202 PyObject* ro;
1203 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",row,col));
1204 if (ro) {
1205 rval = Py2wxString(ro);
1206 Py_DECREF(ro);
1207 }
1208 }
1209 wxPyEndBlockThreads();
1210 return rval;
1211 }
1212
1213 void SetValue(int row, int col, const wxString& val) {
1214 wxPyBeginBlockThreads();
1215 if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
1216 PyObject* s = wx2PyString(val);
1217 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",row,col,s));
1218 Py_DECREF(s);
1219 }
1220 wxPyEndBlockThreads();
1221 }
1222
1223
1224 // Map the Get/Set methods for the standard non-string types to
1225 // the GetValue and SetValue python methods.
1226 long GetValueAsLong( int row, int col ) {
1227 long rval = 0;
1228 wxPyBeginBlockThreads();
1229 if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
1230 PyObject* ro;
1231 PyObject* num;
1232 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)", row, col));
1233 if (ro && PyNumber_Check(ro)) {
1234 num = PyNumber_Int(ro);
1235 if (num) {
1236 rval = PyInt_AsLong(num);
1237 Py_DECREF(num);
1238 }
1239 Py_DECREF(ro);
1240 }
1241 }
1242 wxPyEndBlockThreads();
1243 return rval;
1244 }
1245
1246 double GetValueAsDouble( int row, int col ) {
1247 double rval = 0.0;
1248 wxPyBeginBlockThreads();
1249 if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
1250 PyObject* ro;
1251 PyObject* num;
1252 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)", row, col));
1253 if (ro && PyNumber_Check(ro)) {
1254 num = PyNumber_Float(ro);
1255 if (num) {
1256 rval = PyFloat_AsDouble(num);
1257 Py_DECREF(num);
1258 }
1259 Py_DECREF(ro);
1260 }
1261 }
1262 wxPyEndBlockThreads();
1263 return rval;
1264 }
1265
1266 bool GetValueAsBool( int row, int col ) {
1267 return (bool)GetValueAsLong(row, col);
1268 }
1269
1270 void SetValueAsLong( int row, int col, long value ) {
1271 wxPyBeginBlockThreads();
1272 if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
1273 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", row, col, value));
1274 }
1275 wxPyEndBlockThreads();
1276 }
1277
1278 void SetValueAsDouble( int row, int col, double value ) {
1279 wxPyBeginBlockThreads();
1280 if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
1281 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iid)", row, col, value));
1282 }
1283 wxPyEndBlockThreads();
1284 }
1285
1286 void SetValueAsBool( int row, int col, bool value ) {
1287 SetValueAsLong( row, col, (long)value );
1288 }
1289
1290
1291 PYPRIVATE;
1292 };
1293 %}
1294
1295
1296 // The python-aware version get's SWIGified
1297 class wxPyGridTableBase : public wxGridTableBase
1298 {
1299 public:
1300 wxPyGridTableBase();
1301 void _setCallbackInfo(PyObject* self, PyObject* _class);
1302 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyGridTableBase)"
1303 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1304
1305 %addmethods { void Destroy() { delete self; } }
1306
1307 wxString base_GetTypeName( int row, int col );
1308 bool base_CanGetValueAs( int row, int col, const wxString& typeName );
1309 bool base_CanSetValueAs( int row, int col, const wxString& typeName );
1310 void base_Clear();
1311 bool base_InsertRows( size_t pos = 0, size_t numRows = 1 );
1312 bool base_AppendRows( size_t numRows = 1 );
1313 bool base_DeleteRows( size_t pos = 0, size_t numRows = 1 );
1314 bool base_InsertCols( size_t pos = 0, size_t numCols = 1 );
1315 bool base_AppendCols( size_t numCols = 1 );
1316 bool base_DeleteCols( size_t pos = 0, size_t numCols = 1 );
1317 wxString base_GetRowLabelValue( int row );
1318 wxString base_GetColLabelValue( int col );
1319 void base_SetRowLabelValue( int row, const wxString& value );
1320 void base_SetColLabelValue( int col, const wxString& value );
1321 bool base_CanHaveAttributes();
1322 wxGridCellAttr *base_GetAttr( int row, int col,
1323 wxGridCellAttr::wxAttrKind kind );
1324 void base_SetAttr(wxGridCellAttr* attr, int row, int col);
1325 void base_SetRowAttr(wxGridCellAttr *attr, int row);
1326 void base_SetColAttr(wxGridCellAttr *attr, int col);
1327 };
1328
1329
1330 //---------------------------------------------------------------------------
1331 // Predefined Tables
1332
1333 class wxGridStringTable : public wxGridTableBase
1334 {
1335 public:
1336 wxGridStringTable( int numRows=0, int numCols=0 );
1337 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1338 };
1339
1340 //---------------------------------------------------------------------------
1341 // The Table can pass messages to the grid to tell it to update itself if
1342 // something has changed.
1343
1344 enum wxGridTableRequest
1345 {
1346 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = 2000,
1347 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES,
1348 wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
1349 wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
1350 wxGRIDTABLE_NOTIFY_ROWS_DELETED,
1351 wxGRIDTABLE_NOTIFY_COLS_INSERTED,
1352 wxGRIDTABLE_NOTIFY_COLS_APPENDED,
1353 wxGRIDTABLE_NOTIFY_COLS_DELETED
1354 };
1355
1356
1357 class wxGridTableMessage
1358 {
1359 public:
1360 wxGridTableMessage( wxGridTableBase *table, int id,
1361 int comInt1 = -1,
1362 int comInt2 = -1 );
1363 ~wxGridTableMessage();
1364
1365 void SetTableObject( wxGridTableBase *table );
1366 wxGridTableBase * GetTableObject() const;
1367 void SetId( int id );
1368 int GetId();
1369 void SetCommandInt( int comInt1 );
1370 int GetCommandInt();
1371 void SetCommandInt2( int comInt2 );
1372 int GetCommandInt2();
1373 };
1374
1375
1376 //---------------------------------------------------------------------------
1377
1378 class wxGridCellCoords
1379 {
1380 public:
1381 wxGridCellCoords( int r=-1, int c=-1 );
1382 ~wxGridCellCoords();
1383
1384 int GetRow() const { return m_row; }
1385 void SetRow( int n ) { m_row = n; }
1386 int GetCol() const { return m_col; }
1387 void SetCol( int n ) { m_col = n; }
1388 void Set( int row, int col ) { m_row = row; m_col = col; }
1389
1390 %addmethods {
1391 PyObject* asTuple() {
1392 PyObject* tup = PyTuple_New(2);
1393 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetRow()));
1394 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->GetCol()));
1395 return tup;
1396 }
1397
1398 int __cmp__( const wxGridCellCoords& other ) {
1399 return *self != other;
1400 }
1401 }
1402 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
1403 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
1404 };
1405
1406 // Typemap to allow conversion of sequence objects to wxGridCellCoords...
1407 %typemap(python,in) wxGridCellCoords& (wxGridCellCoords temp) {
1408 $target = &temp;
1409 if (! wxGridCellCoords_helper($source, &$target))
1410 return NULL;
1411 }
1412
1413 // ...and here is the associated helper.
1414 %{
1415 bool wxGridCellCoords_helper(PyObject* source, wxGridCellCoords** obj) {
1416
1417 // If source is an object instance then it may already be the right type
1418 if (PyInstance_Check(source)) {
1419 wxGridCellCoords* ptr;
1420 if (SWIG_GetPtrObj(source, (void **)&ptr, "_wxGridCellCoords_p"))
1421 goto error;
1422 *obj = ptr;
1423 return TRUE;
1424 }
1425 // otherwise a 2-tuple of integers is expected
1426 else if (PySequence_Check(source) && PyObject_Length(source) == 2) {
1427 PyObject* o1 = PySequence_GetItem(source, 0);
1428 PyObject* o2 = PySequence_GetItem(source, 1);
1429 **obj = wxGridCellCoords(PyInt_AsLong(o1), PyInt_AsLong(o2));
1430 return TRUE;
1431 }
1432
1433 error:
1434 PyErr_SetString(PyExc_TypeError, "Expected a 2-tuple of integers or a wxGridCellCoords object.");
1435 return FALSE;
1436 }
1437 %}
1438
1439 //---------------------------------------------------------------------------
1440 //---------------------------------------------------------------------------
1441 // The grid itself
1442
1443
1444 // Fool SWIG into treating this enum as an int
1445 typedef int WXGRIDSELECTIONMODES;
1446
1447 // but let the C++ code know what it really is.
1448 %{
1449 typedef wxGrid::wxGridSelectionModes WXGRIDSELECTIONMODES;
1450 %}
1451
1452
1453
1454 class wxGrid : public wxScrolledWindow
1455 {
1456 public:
1457 wxGrid( wxWindow *parent,
1458 wxWindowID id,
1459 const wxPoint& pos = wxDefaultPosition,
1460 const wxSize& size = wxDefaultSize,
1461 long style = wxWANTS_CHARS,
1462 const wxString& name = wxPyPanelNameStr);
1463
1464 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1465
1466 enum wxGridSelectionModes {wxGridSelectCells,
1467 wxGridSelectRows,
1468 wxGridSelectColumns};
1469
1470 bool CreateGrid( int numRows, int numCols,
1471 WXGRIDSELECTIONMODES selmode = wxGrid::wxGridSelectCells );
1472 void SetSelectionMode(WXGRIDSELECTIONMODES selmode);
1473
1474
1475 // ------ grid dimensions
1476 //
1477 int GetNumberRows();
1478 int GetNumberCols();
1479
1480
1481 bool ProcessTableMessage( wxGridTableMessage& );
1482
1483
1484 wxGridTableBase * GetTable() const;
1485 bool SetTable( wxGridTableBase *table, bool takeOwnership=FALSE,
1486 WXGRIDSELECTIONMODES selmode =
1487 wxGrid::wxGridSelectCells );
1488
1489 void ClearGrid();
1490 bool InsertRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE );
1491 bool AppendRows( int numRows = 1, bool updateLabels=TRUE );
1492 bool DeleteRows( int pos = 0, int numRows = 1, bool updateLabels=TRUE );
1493 bool InsertCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE );
1494 bool AppendCols( int numCols = 1, bool updateLabels=TRUE );
1495 bool DeleteCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE );
1496
1497
1498 // this function is called when the current cell highlight must be redrawn
1499 // and may be overridden by the user
1500 virtual void DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr );
1501
1502
1503 // ------ Cell text drawing functions
1504 //
1505 void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&,
1506 int horizontalAlignment = wxLEFT,
1507 int verticalAlignment = wxTOP );
1508
1509 // // Split a string containing newline chararcters into an array of
1510 // // strings and return the number of lines
1511 // //
1512 // void StringToLines( const wxString& value, wxArrayString& lines );
1513
1514 void GetTextBoxSize( wxDC& dc,
1515 wxArrayString& lines,
1516 long *OUTPUT, long *OUTPUT );
1517
1518
1519 // ------
1520 // Code that does a lot of grid modification can be enclosed
1521 // between BeginBatch() and EndBatch() calls to avoid screen
1522 // flicker
1523 //
1524 void BeginBatch();
1525 void EndBatch();
1526 int GetBatchCount();
1527 void ForceRefresh();
1528
1529
1530 // ------ edit control functions
1531 //
1532 bool IsEditable() { return m_editable; }
1533 void EnableEditing( bool edit );
1534
1535 void EnableCellEditControl( bool enable = TRUE );
1536 void DisableCellEditControl();
1537 bool CanEnableCellControl() const;
1538 bool IsCellEditControlEnabled() const;
1539 bool IsCellEditControlShown() const;
1540
1541 bool IsCurrentCellReadOnly() const;
1542
1543 void ShowCellEditControl();
1544 void HideCellEditControl();
1545 void SaveEditControlValue();
1546
1547
1548 // ------ grid location functions
1549 // Note that all of these functions work with the logical coordinates of
1550 // grid cells and labels so you will need to convert from device
1551 // coordinates for mouse events etc.
1552 //
1553
1554 //void XYToCell( int x, int y, wxGridCellCoords& );
1555 %addmethods {
1556 %new wxGridCellCoords* XYToCell(int x, int y) {
1557 wxGridCellCoords rv;
1558 self->XYToCell(x, y, rv);
1559 return new wxGridCellCoords(rv);
1560 }
1561 }
1562
1563 int YToRow( int y );
1564 int XToCol( int x );
1565
1566 int YToEdgeOfRow( int y );
1567 int XToEdgeOfCol( int x );
1568
1569 wxRect CellToRect( int row, int col );
1570 // TODO: ??? wxRect CellToRect( const wxGridCellCoords& coords );
1571
1572
1573 int GetGridCursorRow();
1574 int GetGridCursorCol();
1575
1576 // check to see if a cell is either wholly visible (the default arg) or
1577 // at least partially visible in the grid window
1578 //
1579 bool IsVisible( int row, int col, bool wholeCellVisible = TRUE );
1580 // TODO: ??? bool IsVisible( const wxGridCellCoords& coords, bool wholeCellVisible = TRUE );
1581 void MakeCellVisible( int row, int col );
1582 // TODO: ??? void MakeCellVisible( const wxGridCellCoords& coords );
1583
1584
1585 // ------ grid cursor movement functions
1586 //
1587 void SetGridCursor( int row, int col );
1588 bool MoveCursorUp( bool expandSelection );
1589 bool MoveCursorDown( bool expandSelection );
1590 bool MoveCursorLeft( bool expandSelection );
1591 bool MoveCursorRight( bool expandSelection );
1592 bool MovePageDown();
1593 bool MovePageUp();
1594 bool MoveCursorUpBlock( bool expandSelection );
1595 bool MoveCursorDownBlock( bool expandSelection );
1596 bool MoveCursorLeftBlock( bool expandSelection );
1597 bool MoveCursorRightBlock( bool expandSelection );
1598
1599
1600 // ------ label and gridline formatting
1601 //
1602 int GetDefaultRowLabelSize();
1603 int GetRowLabelSize();
1604 int GetDefaultColLabelSize();
1605 int GetColLabelSize();
1606 wxColour GetLabelBackgroundColour();
1607 wxColour GetLabelTextColour();
1608 wxFont GetLabelFont();
1609 void GetRowLabelAlignment( int *OUTPUT, int *OUTPUT );
1610 void GetColLabelAlignment( int *OUTPUT, int *OUTPUT );
1611 wxString GetRowLabelValue( int row );
1612 wxString GetColLabelValue( int col );
1613 wxColour GetGridLineColour();
1614 wxColour GetCellHighlightColour();
1615 int GetCellHighlightPenWidth();
1616 int GetCellHighlightROPenWidth();
1617
1618 void SetRowLabelSize( int width );
1619 void SetColLabelSize( int height );
1620 void SetLabelBackgroundColour( const wxColour& );
1621 void SetLabelTextColour( const wxColour& );
1622 void SetLabelFont( const wxFont& );
1623 void SetRowLabelAlignment( int horiz, int vert );
1624 void SetColLabelAlignment( int horiz, int vert );
1625 void SetRowLabelValue( int row, const wxString& );
1626 void SetColLabelValue( int col, const wxString& );
1627 void SetGridLineColour( const wxColour& );
1628 void SetCellHighlightColour( const wxColour& );
1629 void SetCellHighlightPenWidth(int width);
1630 void SetCellHighlightROPenWidth(int width);
1631
1632 void EnableDragRowSize( bool enable = TRUE );
1633 void DisableDragRowSize();
1634 bool CanDragRowSize();
1635 void EnableDragColSize( bool enable = TRUE );
1636 void DisableDragColSize();
1637 bool CanDragColSize();
1638 void EnableDragGridSize(bool enable = TRUE);
1639 void DisableDragGridSize();
1640 bool CanDragGridSize();
1641
1642 // this sets the specified attribute for all cells in this row/col
1643 void SetRowAttr(int row, wxGridCellAttr *attr);
1644 void SetColAttr(int col, wxGridCellAttr *attr);
1645
1646 // shortcuts for setting the column parameters
1647
1648 // set the format for the data in the column: default is string
1649 void SetColFormatBool(int col);
1650 void SetColFormatNumber(int col);
1651 void SetColFormatFloat(int col, int width = -1, int precision = -1);
1652 void SetColFormatCustom(int col, const wxString& typeName);
1653
1654 void EnableGridLines( bool enable = TRUE );
1655 bool GridLinesEnabled();
1656
1657 // ------ row and col formatting
1658 //
1659 int GetDefaultRowSize();
1660 int GetRowSize( int row );
1661 int GetDefaultColSize();
1662 int GetColSize( int col );
1663 wxColour GetDefaultCellBackgroundColour();
1664 wxColour GetCellBackgroundColour( int row, int col );
1665 wxColour GetDefaultCellTextColour();
1666 wxColour GetCellTextColour( int row, int col );
1667 wxFont GetDefaultCellFont();
1668 wxFont GetCellFont( int row, int col );
1669 void GetDefaultCellAlignment( int *horiz, int *vert );
1670 void GetCellAlignment( int row, int col, int *horiz, int *vert );
1671
1672 void SetDefaultRowSize( int height, bool resizeExistingRows = FALSE );
1673 void SetRowSize( int row, int height );
1674 void SetDefaultColSize( int width, bool resizeExistingCols = FALSE );
1675
1676 void SetColSize( int col, int width );
1677
1678 // automatically size the column or row to fit to its contents, if
1679 // setAsMin is TRUE, this optimal width will also be set as minimal width
1680 // for this column
1681 void AutoSizeColumn( int col, bool setAsMin = TRUE );
1682 void AutoSizeRow( int row, bool setAsMin = TRUE );
1683
1684
1685 // auto size all columns (very ineffective for big grids!)
1686 void AutoSizeColumns( bool setAsMin = TRUE );
1687 void AutoSizeRows( bool setAsMin = TRUE );
1688
1689 // auto size the grid, that is make the columns/rows of the "right" size
1690 // and also set the grid size to just fit its contents
1691 void AutoSize();
1692
1693 // column won't be resized to be lesser width - this must be called during
1694 // the grid creation because it won't resize the column if it's already
1695 // narrower than the minimal width
1696 void SetColMinimalWidth( int col, int width );
1697 void SetRowMinimalHeight( int row, int width );
1698
1699 void SetDefaultCellBackgroundColour( const wxColour& );
1700 void SetCellBackgroundColour( int row, int col, const wxColour& );
1701 void SetDefaultCellTextColour( const wxColour& );
1702
1703 void SetCellTextColour( int row, int col, const wxColour& );
1704 void SetDefaultCellFont( const wxFont& );
1705 void SetCellFont( int row, int col, const wxFont& );
1706 void SetDefaultCellAlignment( int horiz, int vert );
1707 void SetCellAlignment( int row, int col, int horiz, int vert );
1708
1709 // takes ownership of the pointer
1710 void SetDefaultRenderer(wxGridCellRenderer *renderer);
1711 void SetCellRenderer(int row, int col, wxGridCellRenderer *renderer);
1712 wxGridCellRenderer *GetDefaultRenderer() const;
1713 wxGridCellRenderer* GetCellRenderer(int row, int col);
1714
1715 // takes ownership of the pointer
1716 void SetDefaultEditor(wxGridCellEditor *editor);
1717 void SetCellEditor(int row, int col, wxGridCellEditor *editor);
1718 wxGridCellEditor *GetDefaultEditor() const;
1719 wxGridCellEditor* GetCellEditor(int row, int col);
1720
1721
1722
1723 // ------ cell value accessors
1724 //
1725 wxString GetCellValue( int row, int col );
1726 // TODO: ??? wxString GetCellValue( const wxGridCellCoords& coords )
1727
1728 void SetCellValue( int row, int col, const wxString& s );
1729 // TODO: ??? void SetCellValue( const wxGridCellCoords& coords, const wxString& s )
1730
1731 // returns TRUE if the cell can't be edited
1732 bool IsReadOnly(int row, int col) const;
1733
1734 // make the cell editable/readonly
1735 void SetReadOnly(int row, int col, bool isReadOnly = TRUE);
1736
1737 // ------ selections of blocks of cells
1738 //
1739 void SelectRow( int row, bool addToSelected = FALSE );
1740 void SelectCol( int col, bool addToSelected = FALSE );
1741
1742 void SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol,
1743 bool addToSelected = FALSE );
1744 // TODO: ??? void SelectBlock( const wxGridCellCoords& topLeft,
1745 // TODO: ??? const wxGridCellCoords& bottomRight )
1746
1747 void SelectAll();
1748 bool IsSelection();
1749 void ClearSelection();
1750 bool IsInSelection( int row, int col );
1751 // TODO: ??? bool IsInSelection( const wxGridCellCoords& coords )
1752
1753
1754 // This function returns the rectangle that encloses the block of cells
1755 // limited by TopLeft and BottomRight cell in device coords and clipped
1756 // to the client size of the grid window.
1757 //
1758 wxRect BlockToDeviceRect( const wxGridCellCoords & topLeft,
1759 const wxGridCellCoords & bottomRight );
1760
1761
1762 // Access or update the selection fore/back colours
1763 wxColour GetSelectionBackground() const;
1764 wxColour GetSelectionForeground() const;
1765
1766 void SetSelectionBackground(const wxColour& c);
1767 void SetSelectionForeground(const wxColour& c);
1768
1769
1770 // Methods for a registry for mapping data types to Renderers/Editors
1771 void RegisterDataType(const wxString& typeName,
1772 wxGridCellRenderer* renderer,
1773 wxGridCellEditor* editor);
1774 wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const;
1775 // TODO: ??? wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const
1776 wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const;
1777 wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const;
1778 wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const;
1779
1780 // grid may occupy more space than needed for its rows/columns, this
1781 // function allows to set how big this extra space is
1782 void SetMargins(int extraWidth, int extraHeight);
1783
1784
1785 // Accessors for component windows
1786 wxWindow* GetGridWindow();
1787 wxWindow* GetGridRowLabelWindow();
1788 wxWindow* GetGridColLabelWindow();
1789 wxWindow* GetGridCornerLabelWindow();
1790
1791
1792 };
1793
1794
1795 //---------------------------------------------------------------------------
1796 //---------------------------------------------------------------------------
1797 // Grid events and stuff
1798
1799
1800
1801 class wxGridEvent : public wxNotifyEvent
1802 {
1803 public:
1804 wxGridEvent(int id, wxEventType type, wxGrid* obj,
1805 int row=-1, int col=-1, int x=-1, int y=-1, bool sel = TRUE,
1806 bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE);
1807
1808 virtual int GetRow();
1809 virtual int GetCol();
1810 wxPoint GetPosition();
1811 bool Selecting();
1812 bool ControlDown();
1813 bool MetaDown();
1814 bool ShiftDown();
1815 bool AltDown();
1816
1817 };
1818
1819
1820 class wxGridSizeEvent : public wxNotifyEvent
1821 {
1822 public:
1823 wxGridSizeEvent(int id, wxEventType type, wxGrid* obj,
1824 int rowOrCol=-1, int x=-1, int y=-1,
1825 bool control=FALSE, bool shift=FALSE, bool alt=FALSE, bool meta=FALSE);
1826
1827 int GetRowOrCol();
1828 wxPoint GetPosition();
1829 bool ControlDown();
1830 bool MetaDown();
1831 bool ShiftDown();
1832 bool AltDown();
1833
1834 };
1835
1836
1837 class wxGridRangeSelectEvent : public wxNotifyEvent
1838 {
1839 public:
1840 wxGridRangeSelectEvent(int id, wxEventType type, wxGrid* obj,
1841 const wxGridCellCoords& topLeft,
1842 const wxGridCellCoords& bottomRight,
1843 bool sel = TRUE,
1844 bool control=FALSE, bool shift=FALSE,
1845 bool alt=FALSE, bool meta=FALSE);
1846
1847 wxGridCellCoords GetTopLeftCoords();
1848 wxGridCellCoords GetBottomRightCoords();
1849 int GetTopRow();
1850 int GetBottomRow();
1851 int GetLeftCol();
1852 int GetRightCol();
1853 bool Selecting();
1854 bool ControlDown();
1855 bool MetaDown();
1856 bool ShiftDown();
1857 bool AltDown();
1858 };
1859
1860
1861 class wxGridEditorCreatedEvent : public wxCommandEvent {
1862 public:
1863 wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj,
1864 int row, int col, wxControl* ctrl);
1865
1866 int GetRow();
1867 int GetCol();
1868 wxControl* GetControl();
1869 void SetRow(int row);
1870 void SetCol(int col);
1871 void SetControl(wxControl* ctrl);
1872 };
1873
1874
1875
1876 enum {
1877 wxEVT_GRID_CELL_LEFT_CLICK,
1878 wxEVT_GRID_CELL_RIGHT_CLICK,
1879 wxEVT_GRID_CELL_LEFT_DCLICK,
1880 wxEVT_GRID_CELL_RIGHT_DCLICK,
1881 wxEVT_GRID_LABEL_LEFT_CLICK,
1882 wxEVT_GRID_LABEL_RIGHT_CLICK,
1883 wxEVT_GRID_LABEL_LEFT_DCLICK,
1884 wxEVT_GRID_LABEL_RIGHT_DCLICK,
1885 wxEVT_GRID_ROW_SIZE,
1886 wxEVT_GRID_COL_SIZE,
1887 wxEVT_GRID_RANGE_SELECT,
1888 wxEVT_GRID_CELL_CHANGE,
1889 wxEVT_GRID_SELECT_CELL,
1890 wxEVT_GRID_EDITOR_SHOWN,
1891 wxEVT_GRID_EDITOR_HIDDEN,
1892 wxEVT_GRID_EDITOR_CREATED,
1893 };
1894
1895
1896
1897 %pragma(python) code = "
1898 def EVT_GRID_CELL_LEFT_CLICK(win, fn):
1899 win.Connect(-1, -1, wxEVT_GRID_CELL_LEFT_CLICK, fn)
1900
1901 def EVT_GRID_CELL_RIGHT_CLICK(win, fn):
1902 win.Connect(-1, -1, wxEVT_GRID_CELL_RIGHT_CLICK, fn)
1903
1904 def EVT_GRID_CELL_LEFT_DCLICK(win, fn):
1905 win.Connect(-1, -1, wxEVT_GRID_CELL_LEFT_DCLICK, fn)
1906
1907 def EVT_GRID_CELL_RIGHT_DCLICK(win, fn):
1908 win.Connect(-1, -1, wxEVT_GRID_CELL_RIGHT_DCLICK, fn)
1909
1910 def EVT_GRID_LABEL_LEFT_CLICK(win, fn):
1911 win.Connect(-1, -1, wxEVT_GRID_LABEL_LEFT_CLICK, fn)
1912
1913 def EVT_GRID_LABEL_RIGHT_CLICK(win, fn):
1914 win.Connect(-1, -1, wxEVT_GRID_LABEL_RIGHT_CLICK, fn)
1915
1916 def EVT_GRID_LABEL_LEFT_DCLICK(win, fn):
1917 win.Connect(-1, -1, wxEVT_GRID_LABEL_LEFT_DCLICK, fn)
1918
1919 def EVT_GRID_LABEL_RIGHT_DCLICK(win, fn):
1920 win.Connect(-1, -1, wxEVT_GRID_LABEL_RIGHT_DCLICK, fn)
1921
1922 def EVT_GRID_ROW_SIZE(win, fn):
1923 win.Connect(-1, -1, wxEVT_GRID_ROW_SIZE, fn)
1924
1925 def EVT_GRID_COL_SIZE(win, fn):
1926 win.Connect(-1, -1, wxEVT_GRID_COL_SIZE, fn)
1927
1928 def EVT_GRID_RANGE_SELECT(win, fn):
1929 win.Connect(-1, -1, wxEVT_GRID_RANGE_SELECT, fn)
1930
1931 def EVT_GRID_CELL_CHANGE(win, fn):
1932 win.Connect(-1, -1, wxEVT_GRID_CELL_CHANGE, fn)
1933
1934 def EVT_GRID_SELECT_CELL(win, fn):
1935 win.Connect(-1, -1, wxEVT_GRID_SELECT_CELL, fn)
1936
1937 def EVT_GRID_EDITOR_SHOWN(win, fn):
1938 win.Connect(-1, -1, wxEVT_GRID_EDITOR_SHOWN, fn)
1939
1940 def EVT_GRID_EDITOR_HIDDEN(win, fn):
1941 win.Connect(-1, -1, wxEVT_GRID_EDITOR_HIDDEN, fn)
1942
1943 def EVT_GRID_EDITOR_CREATED(win, fn):
1944 win.Connect(-1, -1, wxEVT_GRID_EDITOR_CREATED, fn)
1945
1946 "
1947
1948 //---------------------------------------------------------------------------
1949
1950 %init %{
1951 wxClassInfo::CleanUpClasses();
1952 wxClassInfo::InitializeClasses();
1953 %}
1954
1955 //---------------------------------------------------------------------------
1956
1957 %pragma(python) include="_gridextras.py";
1958
1959 //---------------------------------------------------------------------------
1960
1961
1962 #endif