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