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