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