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