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