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