]>
Commit | Line | Data |
---|---|---|
1 | //////////////////////////////////////////////////////////////////////////// | |
2 | // Name: helpers.h | |
3 | // Purpose: Helper functions/classes for the wxPython extenaion module | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 7/1/97 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1998 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | #ifndef __wxp_helpers__ | |
14 | #define __wxp_helpers__ | |
15 | ||
16 | #include <wx/wx.h> | |
17 | ||
18 | ||
19 | //--------------------------------------------------------------------------- | |
20 | ||
21 | typedef unsigned char byte; | |
22 | ||
23 | ||
24 | class wxPyApp: public wxApp | |
25 | { | |
26 | public: | |
27 | wxPyApp(); | |
28 | ~wxPyApp(); | |
29 | bool OnInit(); | |
30 | int MainLoop(); | |
31 | }; | |
32 | ||
33 | extern wxPyApp *wxPythonApp; | |
34 | ||
35 | //---------------------------------------------------------------------- | |
36 | ||
37 | void __wxPreStart(); | |
38 | PyObject* __wxStart(PyObject*, PyObject* args); | |
39 | void __wxCleanup(); | |
40 | ||
41 | //extern PyObject* wxPython_dict; | |
42 | PyObject* __wxSetDictionary(PyObject*, PyObject* args); | |
43 | ||
44 | void wxPyEventThunker(wxObject*, wxEvent& event); | |
45 | ||
46 | PyObject* wxPyConstructObject(void* ptr, | |
47 | const char* className, | |
48 | int setThisOwn=0); | |
49 | PyObject* wxPyConstructObject(void* ptr, | |
50 | const char* className, | |
51 | PyObject* klass, | |
52 | int setThisOwn=0); | |
53 | PyObject* wxPyClassExists(const char* className); | |
54 | PyObject* wxPyMake_wxObject(wxObject* source, bool checkEvtHandler=TRUE); | |
55 | PyObject* wxPyMake_wxSizer(wxSizer* source); | |
56 | void wxPyPtrTypeMap_Add(const char* commonName, const char* ptrName); | |
57 | ||
58 | PyObject* wxPy_ConvertList(wxListBase* list, const char* className); | |
59 | long wxPyGetWinHandle(wxWindow* win); | |
60 | ||
61 | //---------------------------------------------------------------------- | |
62 | ||
63 | // if we want to handle threads and Python threads are available... | |
64 | #if defined(WXP_USE_THREAD) && defined(WITH_THREAD) | |
65 | #define WXP_WITH_THREAD | |
66 | #else // no Python threads... | |
67 | #undef WXP_WITH_THREAD | |
68 | #endif | |
69 | ||
70 | ||
71 | // For Python --> C++ | |
72 | PyThreadState* wxPyBeginAllowThreads(); | |
73 | void wxPyEndAllowThreads(PyThreadState* state); | |
74 | ||
75 | // For C++ --> Python | |
76 | void wxPyBeginBlockThreads(); | |
77 | void wxPyEndBlockThreads(); | |
78 | ||
79 | //---------------------------------------------------------------------- | |
80 | // Handle wxInputStreams by Joerg Baumann | |
81 | // See stream.i for implementations | |
82 | ||
83 | // list class for return list of strings, e.g. readlines() | |
84 | WX_DECLARE_LIST(wxString, wxStringPtrList); | |
85 | ||
86 | ||
87 | // C++ class wxPyInputStream to act as base for python class wxInputStream | |
88 | // Use it in python like a python file object | |
89 | class wxPyInputStream { | |
90 | public: | |
91 | // underlying wxInputStream | |
92 | wxInputStream* wxi; | |
93 | ||
94 | public: | |
95 | wxPyInputStream(wxInputStream* wxi_) : wxi(wxi_) {} | |
96 | ~wxPyInputStream(); | |
97 | ||
98 | // python file object interface for input files (most of it) | |
99 | void close(); | |
100 | void flush(); | |
101 | bool eof(); | |
102 | wxString* read(int size=-1); | |
103 | wxString* readline(int size=-1); | |
104 | wxStringPtrList* readlines(int sizehint=-1); | |
105 | void seek(int offset, int whence=0); | |
106 | int tell(); | |
107 | /* | |
108 | bool isatty(); | |
109 | int fileno(); | |
110 | void truncate(int size=-1); | |
111 | void write(wxString data); | |
112 | void writelines(wxStringPtrList); | |
113 | */ | |
114 | }; | |
115 | ||
116 | ||
117 | //---------------------------------------------------------------------- | |
118 | // These are helpers used by the typemaps | |
119 | ||
120 | byte* byte_LIST_helper(PyObject* source); | |
121 | int* int_LIST_helper(PyObject* source); | |
122 | long* long_LIST_helper(PyObject* source); | |
123 | char** string_LIST_helper(PyObject* source); | |
124 | wxPoint* wxPoint_LIST_helper(PyObject* source, int* npoints); | |
125 | wxBitmap** wxBitmap_LIST_helper(PyObject* source); | |
126 | wxString* wxString_LIST_helper(PyObject* source); | |
127 | wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source); | |
128 | wxPen** wxPen_LIST_helper(PyObject* source); | |
129 | ||
130 | bool wxSize_helper(PyObject* source, wxSize** obj); | |
131 | bool wxPoint_helper(PyObject* source, wxPoint** obj); | |
132 | bool wxRealPoint_helper(PyObject* source, wxRealPoint** obj); | |
133 | bool wxRect_helper(PyObject* source, wxRect** obj); | |
134 | bool wxColour_helper(PyObject* source, wxColour** obj); | |
135 | ||
136 | #if PYTHON_API_VERSION < 1009 | |
137 | #define PySequence_Fast_GET_ITEM(o, i) \ | |
138 | (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i)) | |
139 | #endif | |
140 | ||
141 | bool _2int_seq_helper(PyObject* source, int* i1, int* i2); | |
142 | bool _4int_seq_helper(PyObject* source, int* i1, int* i2, int* i3, int* i4); | |
143 | ||
144 | ||
145 | PyObject* wxArrayString2PyList_helper(const wxArrayString& arr); | |
146 | ||
147 | ||
148 | #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; } | |
149 | ||
150 | //---------------------------------------------------------------------- | |
151 | ||
152 | #ifndef SWIGCODE | |
153 | extern "C" void SWIG_MakePtr(char *, void *, char *); | |
154 | extern "C" char *SWIG_GetPtr(char *, void **, char *); | |
155 | extern "C" char *SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type); | |
156 | #endif | |
157 | ||
158 | ||
159 | #ifdef _MSC_VER | |
160 | # pragma warning(disable:4800) | |
161 | # pragma warning(disable:4190) | |
162 | #endif | |
163 | ||
164 | //---------------------------------------------------------------------- | |
165 | ||
166 | class wxPyCallback : public wxObject { | |
167 | DECLARE_ABSTRACT_CLASS(wxPyCallback); | |
168 | public: | |
169 | wxPyCallback(PyObject* func); | |
170 | wxPyCallback(const wxPyCallback& other); | |
171 | ~wxPyCallback(); | |
172 | ||
173 | void EventThunker(wxEvent& event); | |
174 | ||
175 | PyObject* m_func; | |
176 | }; | |
177 | ||
178 | //--------------------------------------------------------------------------- | |
179 | ||
180 | class wxPyTimer : public wxTimer { | |
181 | public: | |
182 | wxPyTimer(PyObject* callback); | |
183 | ~wxPyTimer(); | |
184 | ||
185 | void Notify(); | |
186 | ||
187 | private: | |
188 | PyObject* func; | |
189 | }; | |
190 | ||
191 | //--------------------------------------------------------------------------- | |
192 | //--------------------------------------------------------------------------- | |
193 | // These Event classes can be derived from in Python and passed through the | |
194 | // event system without loosing anything. They do this by keeping a reference | |
195 | // to themselves and some special case handling in wxPyCallback::EventThunker. | |
196 | ||
197 | ||
198 | class wxPyEvtSelfRef { | |
199 | public: | |
200 | wxPyEvtSelfRef(); | |
201 | ~wxPyEvtSelfRef(); | |
202 | ||
203 | void SetSelf(PyObject* self, bool clone=FALSE); | |
204 | PyObject* GetSelf() const; | |
205 | ||
206 | protected: | |
207 | PyObject* m_self; | |
208 | bool m_cloned; | |
209 | }; | |
210 | ||
211 | ||
212 | class wxPyEvent : public wxEvent, public wxPyEvtSelfRef { | |
213 | DECLARE_ABSTRACT_CLASS(wxPyEvent) | |
214 | public: | |
215 | wxPyEvent(int id=0); | |
216 | wxPyEvent(const wxPyEvent& evt); | |
217 | ~wxPyEvent(); | |
218 | ||
219 | virtual wxEvent* Clone() const { return new wxPyEvent(*this); } | |
220 | }; | |
221 | ||
222 | ||
223 | class wxPyCommandEvent : public wxCommandEvent, public wxPyEvtSelfRef { | |
224 | DECLARE_ABSTRACT_CLASS(wxPyCommandEvent) | |
225 | public: | |
226 | wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0); | |
227 | wxPyCommandEvent(const wxPyCommandEvent& evt); | |
228 | ~wxPyCommandEvent(); | |
229 | ||
230 | virtual wxEvent* Clone() const { return new wxPyCommandEvent(*this); } | |
231 | }; | |
232 | ||
233 | ||
234 | //--------------------------------------------------------------------------- | |
235 | // Export a C API in a struct. Other modules will be able to load this from | |
236 | // the wxc module and will then have safe access to these functions, even if | |
237 | // in another shared library. | |
238 | ||
239 | class wxPyCallbackHelper; | |
240 | ||
241 | struct wxPyCoreAPI { | |
242 | ||
243 | void (*p_SWIG_MakePtr)(char*, void*, char*); | |
244 | char* (*p_SWIG_GetPtr)(char*, void**, char*); | |
245 | char* (*p_SWIG_GetPtrObj)(PyObject*, void**, char*); | |
246 | void (*p_SWIG_RegisterMapping)(char*, char*, void *(*cast)(void *)); | |
247 | void (*p_SWIG_addvarlink)(PyObject*, char*, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)); | |
248 | PyObject* (*p_SWIG_newvarlink)(void); | |
249 | ||
250 | PyThreadState* (*p_wxPyBeginAllowThreads)(); | |
251 | void (*p_wxPyEndAllowThreads)(PyThreadState* state); | |
252 | void (*p_wxPyBeginBlockThreads)(); | |
253 | void (*p_wxPyEndBlockThreads)(); | |
254 | ||
255 | PyObject* (*p_wxPyConstructObject)(void *, const char *, int); | |
256 | PyObject* (*p_wxPy_ConvertList)(wxListBase* list, const char* className); | |
257 | ||
258 | byte* (*p_byte_LIST_helper)(PyObject* source); | |
259 | int* (*p_int_LIST_helper)(PyObject* source); | |
260 | long* (*p_long_LIST_helper)(PyObject* source); | |
261 | char** (*p_string_LIST_helper)(PyObject* source); | |
262 | wxPoint* (*p_wxPoint_LIST_helper)(PyObject* source, int* npoints); | |
263 | wxBitmap** (*p_wxBitmap_LIST_helper)(PyObject* source); | |
264 | wxString* (*p_wxString_LIST_helper)(PyObject* source); | |
265 | wxAcceleratorEntry* (*p_wxAcceleratorEntry_LIST_helper)(PyObject* source); | |
266 | ||
267 | bool (*p_wxSize_helper)(PyObject* source, wxSize** obj); | |
268 | bool (*p_wxPoint_helper)(PyObject* source, wxPoint** obj); | |
269 | bool (*p_wxRealPoint_helper)(PyObject* source, wxRealPoint** obj); | |
270 | bool (*p_wxRect_helper)(PyObject* source, wxRect** obj); | |
271 | bool (*p_wxColour_helper)(PyObject* source, wxColour** obj); | |
272 | ||
273 | void (*p_wxPyCBH_setCallbackInfo)(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref); | |
274 | bool (*p_wxPyCBH_findCallback)(const wxPyCallbackHelper& cbh, const char* name); | |
275 | int (*p_wxPyCBH_callCallback)(const wxPyCallbackHelper& cbh, PyObject* argTuple); | |
276 | PyObject* (*p_wxPyCBH_callCallbackObj)(const wxPyCallbackHelper& cbh, PyObject* argTuple); | |
277 | void (*p_wxPyCBH_delete)(wxPyCallbackHelper* cbh); | |
278 | ||
279 | PyObject* (*p_wxPyClassExists)(const char* className); | |
280 | PyObject* (*p_wxPyMake_wxObject)(wxObject* source, bool checkEvtHandler); | |
281 | PyObject* (*p_wxPyMake_wxSizer)(wxSizer* source); | |
282 | void (*p_wxPyPtrTypeMap_Add)(const char* commonName, const char* ptrName); | |
283 | PyObject* (*p_wxArrayString2PyList_helper)(const wxArrayString& arr); | |
284 | }; | |
285 | ||
286 | #ifdef wxPyUSE_EXPORT | |
287 | static wxPyCoreAPI* wxPyCoreAPIPtr = NULL; // Each module needs one, but may not use it. | |
288 | #endif | |
289 | ||
290 | //--------------------------------------------------------------------------- | |
291 | // This class holds an instance of a Python Shadow Class object and assists | |
292 | // with looking up and invoking Python callback methods from C++ virtual | |
293 | // method redirections. For all classes which have virtuals which should be | |
294 | // overridable in wxPython, a new subclass is created that contains a | |
295 | // wxPyCallbackHelper. | |
296 | // | |
297 | ||
298 | class wxPyCallbackHelper { | |
299 | public: | |
300 | wxPyCallbackHelper(const wxPyCallbackHelper& other); | |
301 | ||
302 | wxPyCallbackHelper() { | |
303 | m_class = NULL; | |
304 | m_self = NULL; | |
305 | m_lastFound = NULL; | |
306 | m_incRef = FALSE; | |
307 | } | |
308 | ||
309 | ~wxPyCallbackHelper() { | |
310 | #ifdef wxPyUSE_EXPORT | |
311 | wxPyCoreAPIPtr->p_wxPyCBH_delete(this); | |
312 | #else | |
313 | wxPyCBH_delete(this); | |
314 | #endif | |
315 | } | |
316 | ||
317 | void setSelf(PyObject* self, PyObject* klass, int incref=TRUE); | |
318 | bool findCallback(const char* name) const; | |
319 | int callCallback(PyObject* argTuple) const; | |
320 | PyObject* callCallbackObj(PyObject* argTuple) const; | |
321 | ||
322 | private: | |
323 | PyObject* m_self; | |
324 | PyObject* m_class; | |
325 | PyObject* m_lastFound; | |
326 | int m_incRef; | |
327 | ||
328 | friend void wxPyCBH_delete(wxPyCallbackHelper* cbh); | |
329 | }; | |
330 | ||
331 | ||
332 | void wxPyCBH_setCallbackInfo(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref); | |
333 | bool wxPyCBH_findCallback(const wxPyCallbackHelper& cbh, const char* name); | |
334 | int wxPyCBH_callCallback(const wxPyCallbackHelper& cbh, PyObject* argTuple); | |
335 | PyObject* wxPyCBH_callCallbackObj(const wxPyCallbackHelper& cbh, PyObject* argTuple); | |
336 | void wxPyCBH_delete(wxPyCallbackHelper* cbh); | |
337 | ||
338 | ||
339 | ||
340 | //---------------------------------------------------------------------- | |
341 | ||
342 | class wxPyUserData : public wxObject { | |
343 | public: | |
344 | wxPyUserData(PyObject* obj) { | |
345 | m_obj = obj; | |
346 | Py_INCREF(m_obj); | |
347 | } | |
348 | ||
349 | ~wxPyUserData() { | |
350 | #ifdef wxPyUSE_EXPORT | |
351 | wxPyCoreAPIPtr->p_wxPyBeginBlockThreads(); | |
352 | Py_DECREF(m_obj); | |
353 | wxPyCoreAPIPtr->p_wxPyEndBlockThreads(); | |
354 | #else | |
355 | wxPyBeginBlockThreads(); | |
356 | Py_DECREF(m_obj); | |
357 | wxPyEndBlockThreads(); | |
358 | #endif | |
359 | } | |
360 | PyObject* m_obj; | |
361 | }; | |
362 | ||
363 | ||
364 | ||
365 | class wxPyClientData : public wxClientData { | |
366 | public: | |
367 | wxPyClientData(PyObject* obj) { | |
368 | m_obj = obj; | |
369 | Py_INCREF(m_obj); | |
370 | } | |
371 | ||
372 | ~wxPyClientData() { | |
373 | #ifdef wxPyUSE_EXPORT | |
374 | wxPyCoreAPIPtr->p_wxPyBeginBlockThreads(); | |
375 | Py_DECREF(m_obj); | |
376 | wxPyCoreAPIPtr->p_wxPyEndBlockThreads(); | |
377 | #else | |
378 | wxPyBeginBlockThreads(); | |
379 | Py_DECREF(m_obj); | |
380 | wxPyEndBlockThreads(); | |
381 | #endif | |
382 | } | |
383 | PyObject* m_obj; | |
384 | }; | |
385 | ||
386 | ||
387 | ||
388 | //--------------------------------------------------------------------------- | |
389 | // These macros are used to implement the virtual methods that should | |
390 | // redirect to a Python method if one exists. The names designate the | |
391 | // return type, if any, as well as any parameter types. | |
392 | //--------------------------------------------------------------------------- | |
393 | ||
394 | #define PYPRIVATE \ | |
395 | void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \ | |
396 | wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \ | |
397 | } \ | |
398 | private: wxPyCallbackHelper m_myInst | |
399 | ||
400 | //--------------------------------------------------------------------------- | |
401 | ||
402 | #define DEC_PYCALLBACK__(CBNAME) \ | |
403 | void CBNAME(); \ | |
404 | void base_##CBNAME(); | |
405 | ||
406 | ||
407 | #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \ | |
408 | void CLASS::CBNAME() { \ | |
409 | bool found; \ | |
410 | wxPyBeginBlockThreads(); \ | |
411 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
412 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
413 | wxPyEndBlockThreads(); \ | |
414 | if (! found) \ | |
415 | PCLASS::CBNAME(); \ | |
416 | } \ | |
417 | void CLASS::base_##CBNAME() { \ | |
418 | PCLASS::CBNAME(); \ | |
419 | } | |
420 | ||
421 | //--------------------------------------------------------------------------- | |
422 | ||
423 | #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \ | |
424 | bool CBNAME(int a, int b); \ | |
425 | bool base_##CBNAME(int a, int b); | |
426 | ||
427 | ||
428 | #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \ | |
429 | bool CLASS::CBNAME(int a, int b) { \ | |
430 | bool rval=FALSE, found; \ | |
431 | wxPyBeginBlockThreads(); \ | |
432 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
433 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \ | |
434 | wxPyEndBlockThreads(); \ | |
435 | if (! found) \ | |
436 | rval = PCLASS::CBNAME(a,b); \ | |
437 | return rval; \ | |
438 | } \ | |
439 | bool CLASS::base_##CBNAME(int a, int b) { \ | |
440 | return PCLASS::CBNAME(a,b); \ | |
441 | } | |
442 | ||
443 | //--------------------------------------------------------------------------- | |
444 | ||
445 | #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \ | |
446 | void CBNAME(int a, int b); \ | |
447 | void base_##CBNAME(int a, int b); | |
448 | ||
449 | ||
450 | #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \ | |
451 | void CLASS::CBNAME(int a, int b) { \ | |
452 | bool found; \ | |
453 | wxPyBeginBlockThreads(); \ | |
454 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
455 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \ | |
456 | wxPyEndBlockThreads(); \ | |
457 | if (! found) \ | |
458 | PCLASS::CBNAME(a,b); \ | |
459 | } \ | |
460 | void CLASS::base_##CBNAME(int a, int b) { \ | |
461 | PCLASS::CBNAME(a,b); \ | |
462 | } | |
463 | ||
464 | //--------------------------------------------------------------------------- | |
465 | ||
466 | #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \ | |
467 | bool CBNAME(int a); \ | |
468 | bool base_##CBNAME(int a); | |
469 | ||
470 | ||
471 | #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \ | |
472 | bool CLASS::CBNAME(int a) { \ | |
473 | bool rval=FALSE, found; \ | |
474 | wxPyBeginBlockThreads(); \ | |
475 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
476 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\ | |
477 | wxPyEndBlockThreads(); \ | |
478 | if (! found) \ | |
479 | rval = PCLASS::CBNAME(a); \ | |
480 | return rval; \ | |
481 | } \ | |
482 | bool CLASS::base_##CBNAME(int a) { \ | |
483 | return PCLASS::CBNAME(a); \ | |
484 | } | |
485 | ||
486 | //--------------------------------------------------------------------------- | |
487 | ||
488 | #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \ | |
489 | bool CBNAME(int a); | |
490 | ||
491 | ||
492 | #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \ | |
493 | bool CLASS::CBNAME(int a) { \ | |
494 | bool rval=FALSE; \ | |
495 | wxPyBeginBlockThreads(); \ | |
496 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ | |
497 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \ | |
498 | else rval = FALSE; \ | |
499 | wxPyEndBlockThreads(); \ | |
500 | return rval; \ | |
501 | } | |
502 | ||
503 | ||
504 | //--------------------------------------------------------------------------- | |
505 | ||
506 | #define DEC_PYCALLBACK__DC(CBNAME) \ | |
507 | void CBNAME(wxDC& a); \ | |
508 | void base_##CBNAME(wxDC& a); | |
509 | ||
510 | ||
511 | #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \ | |
512 | void CLASS::CBNAME(wxDC& a) { \ | |
513 | bool found; \ | |
514 | wxPyBeginBlockThreads(); \ | |
515 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
516 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
517 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ | |
518 | Py_DECREF(obj); \ | |
519 | } \ | |
520 | wxPyEndBlockThreads(); \ | |
521 | if (! found) \ | |
522 | PCLASS::CBNAME(a); \ | |
523 | } \ | |
524 | void CLASS::base_##CBNAME(wxDC& a) { \ | |
525 | PCLASS::CBNAME(a); \ | |
526 | } | |
527 | ||
528 | ||
529 | ||
530 | //--------------------------------------------------------------------------- | |
531 | ||
532 | #define DEC_PYCALLBACK__DCBOOL(CBNAME) \ | |
533 | void CBNAME(wxDC& a, bool b); \ | |
534 | void base_##CBNAME(wxDC& a, bool b); | |
535 | ||
536 | ||
537 | #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \ | |
538 | void CLASS::CBNAME(wxDC& a, bool b) { \ | |
539 | bool found; \ | |
540 | wxPyBeginBlockThreads(); \ | |
541 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
542 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
543 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \ | |
544 | Py_DECREF(obj); \ | |
545 | } \ | |
546 | wxPyEndBlockThreads(); \ | |
547 | if (! found) \ | |
548 | PCLASS::CBNAME(a, b); \ | |
549 | } \ | |
550 | void CLASS::base_##CBNAME(wxDC& a, bool b) { \ | |
551 | PCLASS::CBNAME(a, b); \ | |
552 | } | |
553 | ||
554 | //--------------------------------------------------------------------------- | |
555 | ||
556 | #define DEC_PYCALLBACK__DCBOOL(CBNAME) \ | |
557 | void CBNAME(wxDC& a, bool b); \ | |
558 | void base_##CBNAME(wxDC& a, bool b); | |
559 | ||
560 | ||
561 | #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \ | |
562 | void CLASS::CBNAME(wxDC& a, bool b) { \ | |
563 | bool found; \ | |
564 | wxPyBeginBlockThreads(); \ | |
565 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
566 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
567 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \ | |
568 | Py_DECREF(obj); \ | |
569 | } \ | |
570 | wxPyEndBlockThreads(); \ | |
571 | if (! found) \ | |
572 | PCLASS::CBNAME(a, b); \ | |
573 | } \ | |
574 | void CLASS::base_##CBNAME(wxDC& a, bool b) { \ | |
575 | PCLASS::CBNAME(a, b); \ | |
576 | } | |
577 | ||
578 | //--------------------------------------------------------------------------- | |
579 | ||
580 | #define DEC_PYCALLBACK__2DBL(CBNAME) \ | |
581 | void CBNAME(double a, double b); \ | |
582 | void base_##CBNAME(double a, double b); | |
583 | ||
584 | ||
585 | #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \ | |
586 | void CLASS::CBNAME(double a, double b) { \ | |
587 | bool found; \ | |
588 | wxPyBeginBlockThreads(); \ | |
589 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
590 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \ | |
591 | wxPyEndBlockThreads(); \ | |
592 | if (! found) \ | |
593 | PCLASS::CBNAME(a, b); \ | |
594 | } \ | |
595 | void CLASS::base_##CBNAME(double a, double b) { \ | |
596 | PCLASS::CBNAME(a, b); \ | |
597 | } | |
598 | ||
599 | //--------------------------------------------------------------------------- | |
600 | ||
601 | #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \ | |
602 | void CBNAME(double a, double b, int c, int d); \ | |
603 | void base_##CBNAME(double a, double b, int c, int d); | |
604 | ||
605 | ||
606 | #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \ | |
607 | void CLASS::CBNAME(double a, double b, int c, int d) { \ | |
608 | bool found; \ | |
609 | wxPyBeginBlockThreads(); \ | |
610 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
611 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \ | |
612 | a,b,c,d)); \ | |
613 | wxPyEndBlockThreads(); \ | |
614 | if (! found) \ | |
615 | PCLASS::CBNAME(a, b, c, d); \ | |
616 | } \ | |
617 | void CLASS::base_##CBNAME(double a, double b, int c, int d) { \ | |
618 | PCLASS::CBNAME(a, b, c, d); \ | |
619 | } | |
620 | ||
621 | //--------------------------------------------------------------------------- | |
622 | ||
623 | #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \ | |
624 | void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \ | |
625 | void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f); | |
626 | ||
627 | ||
628 | #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \ | |
629 | void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \ | |
630 | bool found; \ | |
631 | wxPyBeginBlockThreads(); \ | |
632 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
633 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
634 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \ | |
635 | Py_DECREF(obj); \ | |
636 | } \ | |
637 | wxPyEndBlockThreads(); \ | |
638 | if (! found) \ | |
639 | PCLASS::CBNAME(a, b, c, d, e, f); \ | |
640 | } \ | |
641 | void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\ | |
642 | PCLASS::CBNAME(a, b, c, d, e, f); \ | |
643 | } | |
644 | ||
645 | //--------------------------------------------------------------------------- | |
646 | ||
647 | #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \ | |
648 | bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \ | |
649 | bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f); | |
650 | ||
651 | ||
652 | #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \ | |
653 | bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \ | |
654 | bool found; \ | |
655 | wxPyBeginBlockThreads(); \ | |
656 | bool rval=FALSE; \ | |
657 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
658 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
659 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\ | |
660 | Py_DECREF(obj); \ | |
661 | } \ | |
662 | wxPyEndBlockThreads(); \ | |
663 | if (! found) \ | |
664 | rval = PCLASS::CBNAME(a, b, c, d, e, f); \ | |
665 | return rval; \ | |
666 | } \ | |
667 | bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\ | |
668 | return PCLASS::CBNAME(a, b, c, d, e, f); \ | |
669 | } | |
670 | ||
671 | //--------------------------------------------------------------------------- | |
672 | ||
673 | #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \ | |
674 | void CBNAME(bool a, double b, double c, int d, int e); \ | |
675 | void base_##CBNAME(bool a, double b, double c, int d, int e); | |
676 | ||
677 | ||
678 | #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \ | |
679 | void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \ | |
680 | bool found; \ | |
681 | wxPyBeginBlockThreads(); \ | |
682 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
683 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \ | |
684 | (int)a,b,c,d,e)); \ | |
685 | wxPyEndBlockThreads(); \ | |
686 | if (! found) \ | |
687 | PCLASS::CBNAME(a, b, c, d, e); \ | |
688 | } \ | |
689 | void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \ | |
690 | PCLASS::CBNAME(a, b, c, d, e); \ | |
691 | } | |
692 | ||
693 | //--------------------------------------------------------------------------- | |
694 | ||
695 | #define DEC_PYCALLBACK__DC4DBL(CBNAME) \ | |
696 | void CBNAME(wxDC& a, double b, double c, double d, double e); \ | |
697 | void base_##CBNAME(wxDC& a, double b, double c, double d, double e); | |
698 | ||
699 | ||
700 | #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \ | |
701 | void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \ | |
702 | bool found; \ | |
703 | wxPyBeginBlockThreads(); \ | |
704 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
705 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
706 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \ | |
707 | Py_DECREF(obj); \ | |
708 | } \ | |
709 | wxPyEndBlockThreads(); \ | |
710 | if (! found) \ | |
711 | PCLASS::CBNAME(a, b, c, d, e); \ | |
712 | } \ | |
713 | void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\ | |
714 | PCLASS::CBNAME(a, b, c, d, e); \ | |
715 | } | |
716 | ||
717 | //--------------------------------------------------------------------------- | |
718 | ||
719 | #define DEC_PYCALLBACK__DCBOOL(CBNAME) \ | |
720 | void CBNAME(wxDC& a, bool b); \ | |
721 | void base_##CBNAME(wxDC& a, bool b); | |
722 | ||
723 | ||
724 | #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \ | |
725 | void CLASS::CBNAME(wxDC& a, bool b) { \ | |
726 | bool found; \ | |
727 | wxPyBeginBlockThreads(); \ | |
728 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
729 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
730 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \ | |
731 | Py_DECREF(obj); \ | |
732 | } \ | |
733 | wxPyEndBlockThreads(); \ | |
734 | if (! found) \ | |
735 | PCLASS::CBNAME(a, b); \ | |
736 | } \ | |
737 | void CLASS::base_##CBNAME(wxDC& a, bool b) { \ | |
738 | PCLASS::CBNAME(a, b); \ | |
739 | } | |
740 | ||
741 | //--------------------------------------------------------------------------- | |
742 | ||
743 | #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \ | |
744 | void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \ | |
745 | void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); | |
746 | ||
747 | ||
748 | #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \ | |
749 | void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \ | |
750 | int e, int f) { \ | |
751 | bool found; \ | |
752 | wxPyBeginBlockThreads(); \ | |
753 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
754 | PyObject* obj = wxPyMake_wxObject(a); \ | |
755 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\ | |
756 | Py_DECREF(obj); \ | |
757 | } \ | |
758 | wxPyEndBlockThreads(); \ | |
759 | if (! found) \ | |
760 | PCLASS::CBNAME(a, b, c, d, e, f); \ | |
761 | } \ | |
762 | void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \ | |
763 | int e, int f) { \ | |
764 | PCLASS::CBNAME(a, b, c, d, e, f); \ | |
765 | } | |
766 | ||
767 | //--------------------------------------------------------------------------- | |
768 | ||
769 | #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \ | |
770 | void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \ | |
771 | void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e); | |
772 | ||
773 | ||
774 | #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \ | |
775 | void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \ | |
776 | bool found; \ | |
777 | wxPyBeginBlockThreads(); \ | |
778 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
779 | PyObject* obj = wxPyMake_wxObject(a); \ | |
780 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \ | |
781 | Py_DECREF(obj); \ | |
782 | } \ | |
783 | wxPyEndBlockThreads(); \ | |
784 | if (! found) \ | |
785 | PCLASS::CBNAME(a, b, c, d, e); \ | |
786 | } \ | |
787 | void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \ | |
788 | int d, int e) { \ | |
789 | PCLASS::CBNAME(a, b, c, d, e); \ | |
790 | } | |
791 | ||
792 | //--------------------------------------------------------------------------- | |
793 | ||
794 | #define DEC_PYCALLBACK__2DBLINT(CBNAME) \ | |
795 | void CBNAME(double a, double b, int c); \ | |
796 | void base_##CBNAME(double a, double b, int c); | |
797 | ||
798 | ||
799 | #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \ | |
800 | void CLASS::CBNAME(double a, double b, int c) { \ | |
801 | bool found; \ | |
802 | wxPyBeginBlockThreads(); \ | |
803 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
804 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \ | |
805 | wxPyEndBlockThreads(); \ | |
806 | if (! found) \ | |
807 | PCLASS::CBNAME(a, b, c); \ | |
808 | } \ | |
809 | void CLASS::base_##CBNAME(double a, double b, int c) { \ | |
810 | PCLASS::CBNAME(a, b, c); \ | |
811 | } | |
812 | ||
813 | //--------------------------------------------------------------------------- | |
814 | ||
815 | #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \ | |
816 | void CBNAME(bool a, double b, double c, int d); \ | |
817 | void base_##CBNAME(bool a, double b, double c, int d); | |
818 | ||
819 | ||
820 | #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \ | |
821 | void CLASS::CBNAME(bool a, double b, double c, int d) { \ | |
822 | bool found; \ | |
823 | wxPyBeginBlockThreads(); \ | |
824 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
825 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\ | |
826 | wxPyEndBlockThreads(); \ | |
827 | if (! found) \ | |
828 | PCLASS::CBNAME(a, b, c, d); \ | |
829 | } \ | |
830 | void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \ | |
831 | PCLASS::CBNAME(a, b, c, d); \ | |
832 | } | |
833 | ||
834 | //--------------------------------------------------------------------------- | |
835 | //--------------------------------------------------------------------------- | |
836 | ||
837 | #define DEC_PYCALLBACK__STRING(CBNAME) \ | |
838 | void CBNAME(const wxString& a); \ | |
839 | void base_##CBNAME(const wxString& a); | |
840 | ||
841 | ||
842 | #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \ | |
843 | void CLASS::CBNAME(const wxString& a) { \ | |
844 | bool found; \ | |
845 | wxPyBeginBlockThreads(); \ | |
846 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
847 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \ | |
848 | wxPyEndBlockThreads(); \ | |
849 | if (! found) \ | |
850 | PCLASS::CBNAME(a); \ | |
851 | } \ | |
852 | void CLASS::base_##CBNAME(const wxString& a) { \ | |
853 | PCLASS::CBNAME(a); \ | |
854 | } | |
855 | ||
856 | //--------------------------------------------------------------------------- | |
857 | ||
858 | #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \ | |
859 | bool CBNAME(const wxString& a); \ | |
860 | bool base_##CBNAME(const wxString& a); | |
861 | ||
862 | ||
863 | #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \ | |
864 | bool CLASS::CBNAME(const wxString& a) { \ | |
865 | bool rval=FALSE; \ | |
866 | bool found; \ | |
867 | wxPyBeginBlockThreads(); \ | |
868 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
869 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str()));\ | |
870 | wxPyEndBlockThreads(); \ | |
871 | if (! found) \ | |
872 | rval = PCLASS::CBNAME(a); \ | |
873 | return rval; \ | |
874 | } \ | |
875 | bool CLASS::base_##CBNAME(const wxString& a) { \ | |
876 | return PCLASS::CBNAME(a); \ | |
877 | } | |
878 | ||
879 | //--------------------------------------------------------------------------- | |
880 | ||
881 | #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \ | |
882 | bool CBNAME(const wxString& a); | |
883 | \ | |
884 | #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \ | |
885 | bool CLASS::CBNAME(const wxString& a) { \ | |
886 | bool rval=FALSE; \ | |
887 | wxPyBeginBlockThreads(); \ | |
888 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ | |
889 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \ | |
890 | wxPyEndBlockThreads(); \ | |
891 | return rval; \ | |
892 | } \ | |
893 | ||
894 | //--------------------------------------------------------------------------- | |
895 | ||
896 | #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \ | |
897 | wxString CBNAME(const wxString& a); \ | |
898 | ||
899 | #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \ | |
900 | wxString CLASS::CBNAME(const wxString& a) { \ | |
901 | wxString rval; \ | |
902 | wxPyBeginBlockThreads(); \ | |
903 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ | |
904 | PyObject* ro; \ | |
905 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(s)", a.c_str()));\ | |
906 | if (ro) { \ | |
907 | PyObject* str = PyObject_Str(ro); \ | |
908 | rval = PyString_AsString(str); \ | |
909 | Py_DECREF(ro); Py_DECREF(str); \ | |
910 | } \ | |
911 | } \ | |
912 | wxPyEndBlockThreads(); \ | |
913 | return rval; \ | |
914 | } \ | |
915 | ||
916 | //--------------------------------------------------------------------------- | |
917 | ||
918 | #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \ | |
919 | wxString CBNAME(const wxString& a,int b); \ | |
920 | ||
921 | #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \ | |
922 | wxString CLASS::CBNAME(const wxString& a,int b) { \ | |
923 | wxString rval; \ | |
924 | wxPyBeginBlockThreads(); \ | |
925 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ | |
926 | PyObject* ro; \ | |
927 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(si)", a.c_str(),b)); \ | |
928 | if (ro) { \ | |
929 | PyObject* str = PyObject_Str(ro); \ | |
930 | rval = PyString_AsString(str); \ | |
931 | Py_DECREF(ro); Py_DECREF(str); \ | |
932 | } \ | |
933 | } \ | |
934 | wxPyEndBlockThreads(); \ | |
935 | return rval; \ | |
936 | } \ | |
937 | ||
938 | //--------------------------------------------------------------------------- | |
939 | ||
940 | #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \ | |
941 | bool CBNAME(const wxString& a, const wxString& b); \ | |
942 | bool base_##CBNAME(const wxString& a, const wxString& b); | |
943 | ||
944 | ||
945 | #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \ | |
946 | bool CLASS::CBNAME(const wxString& a, const wxString& b) { \ | |
947 | bool rval=FALSE; \ | |
948 | bool found; \ | |
949 | wxPyBeginBlockThreads(); \ | |
950 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
951 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ss)", \ | |
952 | a.c_str(), b.c_str())); \ | |
953 | wxPyEndBlockThreads(); \ | |
954 | if (! found) \ | |
955 | rval = PCLASS::CBNAME(a, b); \ | |
956 | return rval; \ | |
957 | } \ | |
958 | bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \ | |
959 | return PCLASS::CBNAME(a, b); \ | |
960 | } | |
961 | ||
962 | //--------------------------------------------------------------------------- | |
963 | ||
964 | #define DEC_PYCALLBACK_STRING_(CBNAME) \ | |
965 | wxString CBNAME(); \ | |
966 | wxString base_##CBNAME(); | |
967 | ||
968 | ||
969 | #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \ | |
970 | wxString CLASS::CBNAME() { \ | |
971 | wxString rval; \ | |
972 | bool found; \ | |
973 | wxPyBeginBlockThreads(); \ | |
974 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
975 | PyObject* ro; \ | |
976 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ | |
977 | if (ro) { \ | |
978 | PyObject* str = PyObject_Str(ro); \ | |
979 | rval = PyString_AsString(str); \ | |
980 | Py_DECREF(ro); Py_DECREF(str); \ | |
981 | } \ | |
982 | } \ | |
983 | wxPyEndBlockThreads(); \ | |
984 | if (! found) \ | |
985 | rval = PCLASS::CBNAME(); \ | |
986 | return rval; \ | |
987 | } \ | |
988 | wxString CLASS::base_##CBNAME() { \ | |
989 | return PCLASS::CBNAME(); \ | |
990 | } | |
991 | ||
992 | //--------------------------------------------------------------------------- | |
993 | ||
994 | #define DEC_PYCALLBACK_STRING__pure(CBNAME) \ | |
995 | wxString CBNAME(); | |
996 | ||
997 | ||
998 | #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \ | |
999 | wxString CLASS::CBNAME() { \ | |
1000 | wxString rval; \ | |
1001 | wxPyBeginBlockThreads(); \ | |
1002 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ | |
1003 | PyObject* ro; \ | |
1004 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ | |
1005 | if (ro) { \ | |
1006 | PyObject* str = PyObject_Str(ro); \ | |
1007 | rval = PyString_AsString(str); \ | |
1008 | Py_DECREF(ro); Py_DECREF(str); \ | |
1009 | } \ | |
1010 | } \ | |
1011 | wxPyEndBlockThreads(); \ | |
1012 | return rval; \ | |
1013 | } | |
1014 | ||
1015 | //--------------------------------------------------------------------------- | |
1016 | ||
1017 | #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \ | |
1018 | bool CBNAME(const wxHtmlTag& a); \ | |
1019 | ||
1020 | ||
1021 | #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \ | |
1022 | bool CLASS::CBNAME(const wxHtmlTag& a) { \ | |
1023 | bool rval=FALSE; \ | |
1024 | wxPyBeginBlockThreads(); \ | |
1025 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ | |
1026 | PyObject* obj = wxPyConstructObject((void*)&a, "wxHtmlTag", 0); \ | |
1027 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ | |
1028 | Py_DECREF(obj); \ | |
1029 | } \ | |
1030 | wxPyEndBlockThreads(); \ | |
1031 | return rval; \ | |
1032 | } | |
1033 | ||
1034 | //--------------------------------------------------------------------------- | |
1035 | ||
1036 | #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \ | |
1037 | void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \ | |
1038 | void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); | |
1039 | ||
1040 | #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \ | |
1041 | void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \ | |
1042 | wxString rval; \ | |
1043 | bool found; \ | |
1044 | wxPyBeginBlockThreads(); \ | |
1045 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1046 | PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \ | |
1047 | wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \ | |
1048 | Py_DECREF(obj); \ | |
1049 | } \ | |
1050 | wxPyEndBlockThreads(); \ | |
1051 | if (! found) \ | |
1052 | PCLASS::CBNAME(cell, x, y); \ | |
1053 | } \ | |
1054 | void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \ | |
1055 | PCLASS::CBNAME(cell, x, y); \ | |
1056 | } | |
1057 | ||
1058 | ||
1059 | //--------------------------------------------------------------------------- | |
1060 | ||
1061 | #define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \ | |
1062 | void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \ | |
1063 | void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); | |
1064 | ||
1065 | #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \ | |
1066 | void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \ | |
1067 | bool found; \ | |
1068 | wxPyBeginBlockThreads(); \ | |
1069 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1070 | PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \ | |
1071 | PyObject* o2 = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \ | |
1072 | wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \ | |
1073 | Py_DECREF(obj); \ | |
1074 | Py_DECREF(o2); \ | |
1075 | } \ | |
1076 | wxPyEndBlockThreads(); \ | |
1077 | if (! found) \ | |
1078 | PCLASS::CBNAME(cell, x, y, e); \ | |
1079 | } \ | |
1080 | void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \ | |
1081 | PCLASS::CBNAME(cell, x, y, e); \ | |
1082 | } | |
1083 | ||
1084 | ||
1085 | ||
1086 | //--------------------------------------------------------------------------- | |
1087 | ||
1088 | #define DEC_PYCALLBACK___pure(CBNAME) \ | |
1089 | void CBNAME(); \ | |
1090 | ||
1091 | ||
1092 | #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \ | |
1093 | void CLASS::CBNAME() { \ | |
1094 | wxPyBeginBlockThreads(); \ | |
1095 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ | |
1096 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
1097 | wxPyEndBlockThreads(); \ | |
1098 | } | |
1099 | ||
1100 | //--------------------------------------------------------------------------- | |
1101 | ||
1102 | #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \ | |
1103 | wxSize CBNAME(); \ | |
1104 | ||
1105 | ||
1106 | #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \ | |
1107 | wxSize CLASS::CBNAME() { \ | |
1108 | wxSize rval(0,0); \ | |
1109 | wxPyBeginBlockThreads(); \ | |
1110 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ | |
1111 | PyObject* ro; \ | |
1112 | wxSize* ptr; \ | |
1113 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ | |
1114 | if (ro) { \ | |
1115 | if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \ | |
1116 | rval = *ptr; \ | |
1117 | Py_DECREF(ro); \ | |
1118 | } \ | |
1119 | } \ | |
1120 | wxPyEndBlockThreads(); \ | |
1121 | return rval; \ | |
1122 | } | |
1123 | ||
1124 | //--------------------------------------------------------------------------- | |
1125 | ||
1126 | #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \ | |
1127 | bool CBNAME(wxWindow* a); \ | |
1128 | bool base_##CBNAME(wxWindow* a); | |
1129 | ||
1130 | ||
1131 | #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \ | |
1132 | bool CLASS::CBNAME(wxWindow* a) { \ | |
1133 | bool rval=FALSE; \ | |
1134 | bool found; \ | |
1135 | wxPyBeginBlockThreads(); \ | |
1136 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1137 | PyObject* obj = wxPyMake_wxObject(a); \ | |
1138 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ | |
1139 | Py_DECREF(obj); \ | |
1140 | } \ | |
1141 | wxPyEndBlockThreads(); \ | |
1142 | if (! found) \ | |
1143 | rval = PCLASS::CBNAME(a); \ | |
1144 | return rval; \ | |
1145 | } \ | |
1146 | bool CLASS::base_##CBNAME(wxWindow* a) { \ | |
1147 | return PCLASS::CBNAME(a); \ | |
1148 | } | |
1149 | ||
1150 | //--------------------------------------------------------------------------- | |
1151 | ||
1152 | #define DEC_PYCALLBACK_BOOL_(CBNAME) \ | |
1153 | bool CBNAME(); \ | |
1154 | bool base_##CBNAME(); | |
1155 | ||
1156 | ||
1157 | #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \ | |
1158 | bool CLASS::CBNAME() { \ | |
1159 | bool rval=FALSE; \ | |
1160 | bool found; \ | |
1161 | wxPyBeginBlockThreads(); \ | |
1162 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
1163 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
1164 | wxPyEndBlockThreads(); \ | |
1165 | if (! found) \ | |
1166 | rval = PCLASS::CBNAME(); \ | |
1167 | return rval; \ | |
1168 | } \ | |
1169 | bool CLASS::base_##CBNAME() { \ | |
1170 | return PCLASS::CBNAME(); \ | |
1171 | } | |
1172 | ||
1173 | //--------------------------------------------------------------------------- | |
1174 | ||
1175 | #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \ | |
1176 | wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \ | |
1177 | wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def); | |
1178 | ||
1179 | ||
1180 | #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \ | |
1181 | wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \ | |
1182 | int rval=0; \ | |
1183 | bool found; \ | |
1184 | wxPyBeginBlockThreads(); \ | |
1185 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
1186 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\ | |
1187 | wxPyEndBlockThreads(); \ | |
1188 | if (! found) \ | |
1189 | rval = PCLASS::CBNAME(a, b, c); \ | |
1190 | return (wxDragResult)rval; \ | |
1191 | } \ | |
1192 | wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \ | |
1193 | return PCLASS::CBNAME(a, b, c); \ | |
1194 | } | |
1195 | ||
1196 | //--------------------------------------------------------------------------- | |
1197 | ||
1198 | #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \ | |
1199 | wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location); \ | |
1200 | ||
1201 | #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \ | |
1202 | wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \ | |
1203 | wxPyBeginBlockThreads(); \ | |
1204 | wxFSFile* rval=0; \ | |
1205 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ | |
1206 | PyObject* ro; \ | |
1207 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
1208 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Os)",\ | |
1209 | obj, b.c_str())); \ | |
1210 | if (ro) { \ | |
1211 | SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \ | |
1212 | Py_DECREF(ro); \ | |
1213 | } \ | |
1214 | Py_DECREF(obj); \ | |
1215 | } \ | |
1216 | wxPyEndBlockThreads(); \ | |
1217 | return rval; \ | |
1218 | }; | |
1219 | ||
1220 | //--------------------------------------------------------------------------- | |
1221 | ||
1222 | #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \ | |
1223 | bool CBNAME(wxDragResult a); \ | |
1224 | bool base_##CBNAME(wxDragResult a); | |
1225 | ||
1226 | ||
1227 | #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \ | |
1228 | bool CLASS::CBNAME(wxDragResult a) { \ | |
1229 | bool rval=FALSE; \ | |
1230 | bool found; \ | |
1231 | wxPyBeginBlockThreads(); \ | |
1232 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
1233 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\ | |
1234 | wxPyEndBlockThreads(); \ | |
1235 | if (! found) \ | |
1236 | rval = PCLASS::CBNAME(a); \ | |
1237 | return rval; \ | |
1238 | } \ | |
1239 | bool CLASS::base_##CBNAME(wxDragResult a) { \ | |
1240 | return PCLASS::CBNAME(a); \ | |
1241 | } | |
1242 | ||
1243 | //--------------------------------------------------------------------------- | |
1244 | ||
1245 | #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \ | |
1246 | wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); | |
1247 | ||
1248 | ||
1249 | #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \ | |
1250 | wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \ | |
1251 | wxPyBeginBlockThreads(); \ | |
1252 | int rval=0; \ | |
1253 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ | |
1254 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\ | |
1255 | wxPyEndBlockThreads(); \ | |
1256 | return (wxDragResult)rval; \ | |
1257 | } \ | |
1258 | ||
1259 | //--------------------------------------------------------------------------- | |
1260 | ||
1261 | #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \ | |
1262 | bool CBNAME(int a, int b, const wxString& c); | |
1263 | ||
1264 | ||
1265 | #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \ | |
1266 | bool CLASS::CBNAME(int a, int b, const wxString& c) { \ | |
1267 | bool rval=FALSE; \ | |
1268 | wxPyBeginBlockThreads(); \ | |
1269 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ | |
1270 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));\ | |
1271 | wxPyEndBlockThreads(); \ | |
1272 | return rval; \ | |
1273 | } \ | |
1274 | ||
1275 | //--------------------------------------------------------------------------- | |
1276 | ||
1277 | #define DEC_PYCALLBACK_SIZET_(CBNAME) \ | |
1278 | size_t CBNAME(); \ | |
1279 | size_t base_##CBNAME(); | |
1280 | ||
1281 | ||
1282 | #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \ | |
1283 | size_t CLASS::CBNAME() { \ | |
1284 | size_t rval=0; \ | |
1285 | bool found; \ | |
1286 | wxPyBeginBlockThreads(); \ | |
1287 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ | |
1288 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
1289 | wxPyEndBlockThreads(); \ | |
1290 | if (! found) \ | |
1291 | rval = PCLASS::CBNAME(); \ | |
1292 | return rval; \ | |
1293 | } \ | |
1294 | size_t CLASS::base_##CBNAME() { \ | |
1295 | return PCLASS::CBNAME(); \ | |
1296 | } | |
1297 | ||
1298 | //--------------------------------------------------------------------------- | |
1299 | ||
1300 | #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \ | |
1301 | wxDataFormat CBNAME(size_t a); \ | |
1302 | wxDataFormat base_##CBNAME(size_t a); | |
1303 | ||
1304 | ||
1305 | #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \ | |
1306 | wxDataFormat CLASS::CBNAME(size_t a) { \ | |
1307 | wxDataFormat rval=0; \ | |
1308 | bool found; \ | |
1309 | wxPyBeginBlockThreads(); \ | |
1310 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1311 | PyObject* ro; \ | |
1312 | wxDataFormat* ptr; \ | |
1313 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \ | |
1314 | if (ro) { \ | |
1315 | if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \ | |
1316 | rval = *ptr; \ | |
1317 | Py_DECREF(ro); \ | |
1318 | } \ | |
1319 | } \ | |
1320 | wxPyEndBlockThreads(); \ | |
1321 | if (! found) \ | |
1322 | rval = PCLASS::CBNAME(a); \ | |
1323 | return rval; \ | |
1324 | } \ | |
1325 | wxDataFormat CLASS::base_##CBNAME(size_t a) { \ | |
1326 | return PCLASS::CBNAME(a); \ | |
1327 | } | |
1328 | ||
1329 | //--------------------------------------------------------------------------- | |
1330 | ||
1331 | #define DEC_PYCALLBACK__constany(CBNAME, Type) \ | |
1332 | void CBNAME(const Type& a); \ | |
1333 | void base_##CBNAME(const Type& a); | |
1334 | ||
1335 | ||
1336 | #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \ | |
1337 | void CLASS::CBNAME(const Type& a) { \ | |
1338 | bool found; \ | |
1339 | wxPyBeginBlockThreads(); \ | |
1340 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1341 | PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \ | |
1342 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ | |
1343 | Py_DECREF(obj); \ | |
1344 | } \ | |
1345 | wxPyEndBlockThreads(); \ | |
1346 | if (! found) \ | |
1347 | PCLASS::CBNAME(a); \ | |
1348 | } \ | |
1349 | void CLASS::base_##CBNAME(const Type& a) { \ | |
1350 | PCLASS::CBNAME(a); \ | |
1351 | } | |
1352 | ||
1353 | ||
1354 | //--------------------------------------------------------------------------- | |
1355 | ||
1356 | #define DEC_PYCALLBACK__any(CBNAME, Type) \ | |
1357 | void CBNAME(Type& a); \ | |
1358 | void base_##CBNAME(Type& a); | |
1359 | ||
1360 | ||
1361 | #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \ | |
1362 | void CLASS::CBNAME(Type& a) { \ | |
1363 | bool found; \ | |
1364 | wxPyBeginBlockThreads(); \ | |
1365 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1366 | PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \ | |
1367 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ | |
1368 | Py_DECREF(obj); \ | |
1369 | } \ | |
1370 | wxPyEndBlockThreads(); \ | |
1371 | if (! found) \ | |
1372 | PCLASS::CBNAME(a); \ | |
1373 | } \ | |
1374 | void CLASS::base_##CBNAME(Type& a) { \ | |
1375 | PCLASS::CBNAME(a); \ | |
1376 | } | |
1377 | ||
1378 | //--------------------------------------------------------------------------- | |
1379 | ||
1380 | #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \ | |
1381 | bool CBNAME(Type& a); \ | |
1382 | bool base_##CBNAME(Type& a); | |
1383 | ||
1384 | ||
1385 | #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \ | |
1386 | bool CLASS::CBNAME(Type& a) { \ | |
1387 | bool rv=FALSE; \ | |
1388 | bool found; \ | |
1389 | wxPyBeginBlockThreads(); \ | |
1390 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1391 | PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \ | |
1392 | rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ | |
1393 | Py_DECREF(obj); \ | |
1394 | } \ | |
1395 | wxPyEndBlockThreads(); \ | |
1396 | if (! found) \ | |
1397 | rv = PCLASS::CBNAME(a); \ | |
1398 | return rv; \ | |
1399 | } \ | |
1400 | bool CLASS::base_##CBNAME(Type& a) { \ | |
1401 | return PCLASS::CBNAME(a); \ | |
1402 | } | |
1403 | ||
1404 | //--------------------------------------------------------------------------- | |
1405 | ||
1406 | #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \ | |
1407 | wxString CBNAME(long a, long b) const; \ | |
1408 | wxString base_##CBNAME(long a, long b)const ; | |
1409 | ||
1410 | ||
1411 | #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \ | |
1412 | wxString CLASS::CBNAME(long a, long b) const { \ | |
1413 | wxString rval; \ | |
1414 | bool found; \ | |
1415 | wxPyBeginBlockThreads(); \ | |
1416 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1417 | PyObject* ro; \ | |
1418 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \ | |
1419 | if (ro) { \ | |
1420 | PyObject* str = PyObject_Str(ro); \ | |
1421 | rval = PyString_AsString(str); \ | |
1422 | Py_DECREF(ro); Py_DECREF(str); \ | |
1423 | } \ | |
1424 | } \ | |
1425 | wxPyEndBlockThreads(); \ | |
1426 | if (! found) \ | |
1427 | rval = PCLASS::CBNAME(a,b); \ | |
1428 | return rval; \ | |
1429 | } \ | |
1430 | wxString CLASS::base_##CBNAME(long a, long b) const { \ | |
1431 | return PCLASS::CBNAME(a,b); \ | |
1432 | } | |
1433 | ||
1434 | //--------------------------------------------------------------------------- | |
1435 | ||
1436 | #define DEC_PYCALLBACK_INT_LONG(CBNAME) \ | |
1437 | int CBNAME(long a) const; \ | |
1438 | int base_##CBNAME(long a)const ; | |
1439 | ||
1440 | ||
1441 | #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \ | |
1442 | int CLASS::CBNAME(long a) const { \ | |
1443 | int rval=-1; \ | |
1444 | bool found; \ | |
1445 | wxPyBeginBlockThreads(); \ | |
1446 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1447 | PyObject* ro; \ | |
1448 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \ | |
1449 | if (ro) { \ | |
1450 | rval = PyInt_AsLong(ro); \ | |
1451 | Py_DECREF(ro); \ | |
1452 | } \ | |
1453 | } \ | |
1454 | wxPyEndBlockThreads(); \ | |
1455 | if (! found) \ | |
1456 | rval = PCLASS::CBNAME(a); \ | |
1457 | return rval; \ | |
1458 | } \ | |
1459 | int CLASS::base_##CBNAME(long a) const { \ | |
1460 | return PCLASS::CBNAME(a); \ | |
1461 | } | |
1462 | ||
1463 | ||
1464 | //--------------------------------------------------------------------------- | |
1465 | ||
1466 | #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \ | |
1467 | wxListItemAttr* CBNAME(long a) const; \ | |
1468 | wxListItemAttr* base_##CBNAME(long a); | |
1469 | ||
1470 | ||
1471 | #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \ | |
1472 | wxListItemAttr *CLASS::CBNAME(long a) const { \ | |
1473 | wxListItemAttr *rval = NULL; \ | |
1474 | bool found; \ | |
1475 | wxPyBeginBlockThreads(); \ | |
1476 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1477 | PyObject* ro; \ | |
1478 | wxListItemAttr* ptr; \ | |
1479 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \ | |
1480 | if (ro) { \ | |
1481 | if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxListItemAttr_p")) \ | |
1482 | rval = ptr; \ | |
1483 | Py_DECREF(ro); \ | |
1484 | } \ | |
1485 | } \ | |
1486 | wxPyEndBlockThreads(); \ | |
1487 | if (! found) \ | |
1488 | rval = PCLASS::CBNAME(a); \ | |
1489 | return rval; \ | |
1490 | } \ | |
1491 | wxListItemAttr *CLASS::base_##CBNAME(long a) { \ | |
1492 | return PCLASS::CBNAME(a); \ | |
1493 | } | |
1494 | ||
1495 | //--------------------------------------------------------------------------- | |
1496 | ||
1497 | #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \ | |
1498 | bool CBNAME(wxMouseEvent& e); \ | |
1499 | bool base_##CBNAME(wxMouseEvent& e); | |
1500 | ||
1501 | #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \ | |
1502 | bool CLASS::CBNAME(wxMouseEvent& e) { \ | |
1503 | bool rval=FALSE; \ | |
1504 | bool found; \ | |
1505 | wxPyBeginBlockThreads(); \ | |
1506 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ | |
1507 | PyObject* ro; \ | |
1508 | PyObject* obj = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \ | |
1509 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \ | |
1510 | if (ro) { \ | |
1511 | rval = PyInt_AsLong(ro); \ | |
1512 | Py_DECREF(ro); \ | |
1513 | } \ | |
1514 | Py_DECREF(obj); \ | |
1515 | } \ | |
1516 | wxPyEndBlockThreads(); \ | |
1517 | if (! found) \ | |
1518 | return PCLASS::CBNAME(e); \ | |
1519 | return rval; \ | |
1520 | } \ | |
1521 | bool CLASS::base_##CBNAME(wxMouseEvent& e) { \ | |
1522 | return PCLASS::CBNAME(e); \ | |
1523 | } | |
1524 | ||
1525 | ||
1526 | //--------------------------------------------------------------------------- | |
1527 | ||
1528 | #endif |