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