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