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