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