]>
Commit | Line | Data |
---|---|---|
b1462dfa | 1 | //////////////////////////////////////////////////////////////////////////// |
7bf85405 RD |
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 | ||
cf694132 | 18 | |
efc5f224 RD |
19 | //--------------------------------------------------------------------------- |
20 | ||
2f90df85 RD |
21 | typedef unsigned char byte; |
22 | ||
7bf85405 RD |
23 | |
24 | class wxPyApp: public wxApp | |
25 | { | |
26 | public: | |
cf694132 RD |
27 | wxPyApp(); |
28 | ~wxPyApp(); | |
4268f798 RD |
29 | bool OnInit(); |
30 | int MainLoop(); | |
7bf85405 | 31 | }; |
4268f798 | 32 | |
7bf85405 RD |
33 | extern wxPyApp *wxPythonApp; |
34 | ||
35 | //---------------------------------------------------------------------- | |
36 | ||
0d6f9504 | 37 | void __wxPreStart(); |
7bf85405 | 38 | PyObject* __wxStart(PyObject*, PyObject* args); |
7ff49f0c | 39 | void __wxCleanup(); |
7bf85405 | 40 | |
9416aa89 | 41 | //extern PyObject* wxPython_dict; |
7bf85405 RD |
42 | PyObject* __wxSetDictionary(PyObject*, PyObject* args); |
43 | ||
7bf85405 | 44 | void wxPyEventThunker(wxObject*, wxEvent& event); |
efc5f224 | 45 | |
1e7ecb7b RD |
46 | PyObject* wxPyConstructObject(void* ptr, |
47 | const char* className, | |
48 | int setThisOwn=0); | |
9416aa89 RD |
49 | PyObject* wxPyConstructObject(void* ptr, |
50 | const char* className, | |
51 | PyObject* klass, | |
52 | int setThisOwn=0); | |
53 | PyObject* wxPyClassExists(const char* className); | |
2f4e9287 RD |
54 | PyObject* wxPyMake_wxObject(wxObject* source, bool checkEvtHandler=TRUE); |
55 | PyObject* wxPyMake_wxSizer(wxSizer* source); | |
9416aa89 RD |
56 | void wxPyPtrTypeMap_Add(const char* commonName, const char* ptrName); |
57 | ||
1e7ecb7b RD |
58 | PyObject* wxPy_ConvertList(wxListBase* list, const char* className); |
59 | long wxPyGetWinHandle(wxWindow* win); | |
9b3d3bc4 | 60 | |
19a97bd6 RD |
61 | //---------------------------------------------------------------------- |
62 | ||
4268f798 RD |
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 | |
19a97bd6 RD |
69 | |
70 | ||
4268f798 RD |
71 | // For Python --> C++ |
72 | PyThreadState* wxPyBeginAllowThreads(); | |
73 | void wxPyEndAllowThreads(PyThreadState* state); | |
9b3d3bc4 | 74 | |
4268f798 RD |
75 | // For C++ --> Python |
76 | void wxPyBeginBlockThreads(); | |
77 | void wxPyEndBlockThreads(); | |
9b3d3bc4 | 78 | |
c368d904 RD |
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 | |
1e7ecb7b | 89 | class wxPyInputStream { |
c368d904 RD |
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 | ||
7bf85405 | 117 | //---------------------------------------------------------------------- |
2f90df85 RD |
118 | // These are helpers used by the typemaps |
119 | ||
1e7ecb7b RD |
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); | |
e0672e2f | 124 | wxPoint* wxPoint_LIST_helper(PyObject* source, int* npoints); |
1e7ecb7b RD |
125 | wxBitmap** wxBitmap_LIST_helper(PyObject* source); |
126 | wxString* wxString_LIST_helper(PyObject* source); | |
127 | wxAcceleratorEntry* wxAcceleratorEntry_LIST_helper(PyObject* source); | |
9d37f964 | 128 | wxPen** wxPen_LIST_helper(PyObject* source); |
1e7ecb7b RD |
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); | |
7bf85405 | 135 | |
9d37f964 RD |
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 | ||
7b7ac0ab | 145 | PyObject* wxArrayString2PyList_helper(const wxArrayString& arr); |
b37c7e1d RD |
146 | |
147 | ||
148 | #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; } | |
149 | ||
2f90df85 | 150 | //---------------------------------------------------------------------- |
7bf85405 RD |
151 | |
152 | #ifndef SWIGCODE | |
153 | extern "C" void SWIG_MakePtr(char *, void *, char *); | |
154 | extern "C" char *SWIG_GetPtr(char *, void **, char *); | |
d559219f | 155 | extern "C" char *SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type); |
7bf85405 RD |
156 | #endif |
157 | ||
158 | ||
159 | #ifdef _MSC_VER | |
160 | # pragma warning(disable:4800) | |
f6bcfd97 | 161 | # pragma warning(disable:4190) |
7bf85405 RD |
162 | #endif |
163 | ||
7bf85405 RD |
164 | //---------------------------------------------------------------------- |
165 | ||
166 | class wxPyCallback : public wxObject { | |
2f90df85 | 167 | DECLARE_ABSTRACT_CLASS(wxPyCallback); |
7bf85405 | 168 | public: |
cf694132 | 169 | wxPyCallback(PyObject* func); |
2f90df85 | 170 | wxPyCallback(const wxPyCallback& other); |
cf694132 | 171 | ~wxPyCallback(); |
7bf85405 RD |
172 | |
173 | void EventThunker(wxEvent& event); | |
174 | ||
175 | PyObject* m_func; | |
176 | }; | |
177 | ||
7bf85405 RD |
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 | ||
cf694132 | 191 | //--------------------------------------------------------------------------- |
65dd82cb | 192 | //--------------------------------------------------------------------------- |
9b3d3bc4 RD |
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. | |
65dd82cb RD |
196 | |
197 | ||
e19b7164 | 198 | class wxPyEvtSelfRef { |
65dd82cb | 199 | public: |
e19b7164 RD |
200 | wxPyEvtSelfRef(); |
201 | ~wxPyEvtSelfRef(); | |
65dd82cb RD |
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 | ||
e19b7164 | 212 | class wxPyEvent : public wxEvent, public wxPyEvtSelfRef { |
07b2e1cd | 213 | DECLARE_ABSTRACT_CLASS(wxPyEvent) |
65dd82cb RD |
214 | public: |
215 | wxPyEvent(int id=0); | |
07b2e1cd | 216 | wxPyEvent(const wxPyEvent& evt); |
65dd82cb RD |
217 | ~wxPyEvent(); |
218 | ||
07b2e1cd | 219 | virtual wxEvent* Clone() const { return new wxPyEvent(*this); } |
65dd82cb RD |
220 | }; |
221 | ||
222 | ||
e19b7164 | 223 | class wxPyCommandEvent : public wxCommandEvent, public wxPyEvtSelfRef { |
07b2e1cd | 224 | DECLARE_ABSTRACT_CLASS(wxPyCommandEvent) |
65dd82cb RD |
225 | public: |
226 | wxPyCommandEvent(wxEventType commandType = wxEVT_NULL, int id=0); | |
07b2e1cd | 227 | wxPyCommandEvent(const wxPyCommandEvent& evt); |
65dd82cb RD |
228 | ~wxPyCommandEvent(); |
229 | ||
07b2e1cd | 230 | virtual wxEvent* Clone() const { return new wxPyCommandEvent(*this); } |
65dd82cb RD |
231 | }; |
232 | ||
bb0054cd | 233 | |
1e7ecb7b RD |
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 | ||
4268f798 RD |
250 | PyThreadState* (*p_wxPyBeginAllowThreads)(); |
251 | void (*p_wxPyEndAllowThreads)(PyThreadState* state); | |
252 | void (*p_wxPyBeginBlockThreads)(); | |
253 | void (*p_wxPyEndBlockThreads)(); | |
19a97bd6 | 254 | |
1e7ecb7b RD |
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); | |
e0672e2f | 262 | wxPoint* (*p_wxPoint_LIST_helper)(PyObject* source, int* npoints); |
1e7ecb7b RD |
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 | ||
0122b7e3 | 273 | void (*p_wxPyCBH_setCallbackInfo)(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref); |
1e7ecb7b RD |
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 | ||
9416aa89 | 279 | PyObject* (*p_wxPyClassExists)(const char* className); |
2f4e9287 RD |
280 | PyObject* (*p_wxPyMake_wxObject)(wxObject* source, bool checkEvtHandler); |
281 | PyObject* (*p_wxPyMake_wxSizer)(wxSizer* source); | |
9416aa89 | 282 | void (*p_wxPyPtrTypeMap_Add)(const char* commonName, const char* ptrName); |
7b7ac0ab | 283 | PyObject* (*p_wxArrayString2PyList_helper)(const wxArrayString& arr); |
1e7ecb7b RD |
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 | ||
0122b7e3 | 332 | void wxPyCBH_setCallbackInfo(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref); |
1e7ecb7b RD |
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() { | |
1e7ecb7b | 350 | #ifdef wxPyUSE_EXPORT |
4268f798 | 351 | wxPyCoreAPIPtr->p_wxPyBeginBlockThreads(); |
1e7ecb7b | 352 | Py_DECREF(m_obj); |
4268f798 | 353 | wxPyCoreAPIPtr->p_wxPyEndBlockThreads(); |
1e7ecb7b | 354 | #else |
4268f798 | 355 | wxPyBeginBlockThreads(); |
bdb9373a | 356 | Py_DECREF(m_obj); |
4268f798 | 357 | wxPyEndBlockThreads(); |
1e7ecb7b RD |
358 | #endif |
359 | } | |
360 | PyObject* m_obj; | |
361 | }; | |
362 | ||
363 | ||
364 | ||
900d9886 RD |
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 | |
4268f798 | 374 | wxPyCoreAPIPtr->p_wxPyBeginBlockThreads(); |
900d9886 | 375 | Py_DECREF(m_obj); |
4268f798 | 376 | wxPyCoreAPIPtr->p_wxPyEndBlockThreads(); |
900d9886 | 377 | #else |
4268f798 | 378 | wxPyBeginBlockThreads(); |
900d9886 | 379 | Py_DECREF(m_obj); |
4268f798 | 380 | wxPyEndBlockThreads(); |
900d9886 RD |
381 | #endif |
382 | } | |
383 | PyObject* m_obj; | |
384 | }; | |
385 | ||
386 | ||
387 | ||
bb0054cd RD |
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 | |
b1462dfa | 391 | // return type, if any, as well as any parameter types. |
bb0054cd RD |
392 | //--------------------------------------------------------------------------- |
393 | ||
f6bcfd97 | 394 | #define PYPRIVATE \ |
0122b7e3 RD |
395 | void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \ |
396 | wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \ | |
f6bcfd97 | 397 | } \ |
c368d904 | 398 | private: wxPyCallbackHelper m_myInst |
efc5f224 RD |
399 | |
400 | //--------------------------------------------------------------------------- | |
401 | ||
d559219f RD |
402 | #define DEC_PYCALLBACK__(CBNAME) \ |
403 | void CBNAME(); \ | |
404 | void base_##CBNAME(); | |
405 | ||
406 | ||
19a97bd6 RD |
407 | #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \ |
408 | void CLASS::CBNAME() { \ | |
409 | bool found; \ | |
4268f798 | 410 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
411 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
412 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
4268f798 | 413 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
414 | if (! found) \ |
415 | PCLASS::CBNAME(); \ | |
416 | } \ | |
417 | void CLASS::base_##CBNAME() { \ | |
418 | PCLASS::CBNAME(); \ | |
d559219f RD |
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) { \ | |
059a841c | 430 | bool rval=FALSE, found; \ |
4268f798 | 431 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 432 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
1e7ecb7b | 433 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \ |
4268f798 | 434 | wxPyEndBlockThreads(); \ |
19a97bd6 | 435 | if (! found) \ |
d559219f | 436 | rval = PCLASS::CBNAME(a,b); \ |
d559219f | 437 | return rval; \ |
bb0054cd | 438 | } \ |
d559219f | 439 | bool CLASS::base_##CBNAME(int a, int b) { \ |
bb0054cd RD |
440 | return PCLASS::CBNAME(a,b); \ |
441 | } | |
442 | ||
443 | //--------------------------------------------------------------------------- | |
444 | ||
c368d904 RD |
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) { \ | |
19a97bd6 | 452 | bool found; \ |
4268f798 | 453 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
454 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
455 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \ | |
4268f798 | 456 | wxPyEndBlockThreads(); \ |
19a97bd6 | 457 | if (! found) \ |
c368d904 | 458 | PCLASS::CBNAME(a,b); \ |
c368d904 RD |
459 | } \ |
460 | void CLASS::base_##CBNAME(int a, int b) { \ | |
461 | PCLASS::CBNAME(a,b); \ | |
462 | } | |
463 | ||
464 | //--------------------------------------------------------------------------- | |
465 | ||
d559219f RD |
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) { \ | |
059a841c | 473 | bool rval=FALSE, found; \ |
4268f798 | 474 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 475 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
059a841c | 476 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\ |
4268f798 | 477 | wxPyEndBlockThreads(); \ |
19a97bd6 | 478 | if (! found) \ |
d559219f | 479 | rval = PCLASS::CBNAME(a); \ |
d559219f | 480 | return rval; \ |
bb0054cd | 481 | } \ |
d559219f | 482 | bool CLASS::base_##CBNAME(int a) { \ |
bb0054cd RD |
483 | return PCLASS::CBNAME(a); \ |
484 | } | |
485 | ||
efc5f224 RD |
486 | //--------------------------------------------------------------------------- |
487 | ||
d559219f RD |
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) { \ | |
059a841c | 494 | bool rval=FALSE; \ |
4268f798 | 495 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 496 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ |
1e7ecb7b | 497 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \ |
194fa2ac | 498 | else rval = FALSE; \ |
4268f798 | 499 | wxPyEndBlockThreads(); \ |
d559219f | 500 | return rval; \ |
bb0054cd RD |
501 | } |
502 | ||
503 | ||
504 | //--------------------------------------------------------------------------- | |
505 | ||
d559219f RD |
506 | #define DEC_PYCALLBACK__DC(CBNAME) \ |
507 | void CBNAME(wxDC& a); \ | |
508 | void base_##CBNAME(wxDC& a); | |
509 | ||
510 | ||
19a97bd6 RD |
511 | #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \ |
512 | void CLASS::CBNAME(wxDC& a) { \ | |
513 | bool found; \ | |
4268f798 | 514 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
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 | } \ | |
4268f798 | 520 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
521 | if (! found) \ |
522 | PCLASS::CBNAME(a); \ | |
523 | } \ | |
524 | void CLASS::base_##CBNAME(wxDC& a) { \ | |
525 | PCLASS::CBNAME(a); \ | |
bb0054cd RD |
526 | } |
527 | ||
efc5f224 RD |
528 | |
529 | ||
bb0054cd RD |
530 | //--------------------------------------------------------------------------- |
531 | ||
d559219f RD |
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) { \ | |
19a97bd6 | 539 | bool found; \ |
4268f798 | 540 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
541 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
542 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
1e7ecb7b | 543 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \ |
de20db99 RD |
544 | Py_DECREF(obj); \ |
545 | } \ | |
4268f798 | 546 | wxPyEndBlockThreads(); \ |
19a97bd6 | 547 | if (! found) \ |
efc5f224 RD |
548 | PCLASS::CBNAME(a, b); \ |
549 | } \ | |
d559219f | 550 | void CLASS::base_##CBNAME(wxDC& a, bool b) { \ |
efc5f224 RD |
551 | PCLASS::CBNAME(a, b); \ |
552 | } | |
553 | ||
554 | //--------------------------------------------------------------------------- | |
555 | ||
d559219f RD |
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) { \ | |
19a97bd6 | 563 | bool found; \ |
4268f798 | 564 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
565 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
566 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
1e7ecb7b | 567 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \ |
de20db99 RD |
568 | Py_DECREF(obj); \ |
569 | } \ | |
4268f798 | 570 | wxPyEndBlockThreads(); \ |
19a97bd6 | 571 | if (! found) \ |
efc5f224 RD |
572 | PCLASS::CBNAME(a, b); \ |
573 | } \ | |
d559219f | 574 | void CLASS::base_##CBNAME(wxDC& a, bool b) { \ |
efc5f224 RD |
575 | PCLASS::CBNAME(a, b); \ |
576 | } | |
577 | ||
578 | //--------------------------------------------------------------------------- | |
579 | ||
d559219f RD |
580 | #define DEC_PYCALLBACK__2DBL(CBNAME) \ |
581 | void CBNAME(double a, double b); \ | |
582 | void base_##CBNAME(double a, double b); | |
583 | ||
584 | ||
19a97bd6 RD |
585 | #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \ |
586 | void CLASS::CBNAME(double a, double b) { \ | |
587 | bool found; \ | |
4268f798 | 588 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
589 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
590 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \ | |
4268f798 | 591 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
592 | if (! found) \ |
593 | PCLASS::CBNAME(a, b); \ | |
594 | } \ | |
595 | void CLASS::base_##CBNAME(double a, double b) { \ | |
596 | PCLASS::CBNAME(a, b); \ | |
efc5f224 RD |
597 | } |
598 | ||
599 | //--------------------------------------------------------------------------- | |
600 | ||
d559219f RD |
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) { \ | |
19a97bd6 | 608 | bool found; \ |
4268f798 | 609 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
610 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
611 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \ | |
efc5f224 | 612 | a,b,c,d)); \ |
4268f798 | 613 | wxPyEndBlockThreads(); \ |
19a97bd6 | 614 | if (! found) \ |
efc5f224 RD |
615 | PCLASS::CBNAME(a, b, c, d); \ |
616 | } \ | |
d559219f | 617 | void CLASS::base_##CBNAME(double a, double b, int c, int d) { \ |
efc5f224 RD |
618 | PCLASS::CBNAME(a, b, c, d); \ |
619 | } | |
620 | ||
621 | //--------------------------------------------------------------------------- | |
622 | ||
19a97bd6 | 623 | #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \ |
d559219f RD |
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) { \ | |
19a97bd6 | 630 | bool found; \ |
4268f798 | 631 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
632 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
633 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
1e7ecb7b | 634 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \ |
de20db99 RD |
635 | Py_DECREF(obj); \ |
636 | } \ | |
4268f798 | 637 | wxPyEndBlockThreads(); \ |
19a97bd6 | 638 | if (! found) \ |
d559219f | 639 | PCLASS::CBNAME(a, b, c, d, e, f); \ |
d559219f RD |
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); \ | |
efc5f224 RD |
643 | } |
644 | ||
645 | //--------------------------------------------------------------------------- | |
646 | ||
d559219f RD |
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) { \ | |
19a97bd6 | 654 | bool found; \ |
4268f798 | 655 | wxPyBeginBlockThreads(); \ |
059a841c | 656 | bool rval=FALSE; \ |
19a97bd6 RD |
657 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
658 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
1e7ecb7b | 659 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\ |
de20db99 RD |
660 | Py_DECREF(obj); \ |
661 | } \ | |
4268f798 | 662 | wxPyEndBlockThreads(); \ |
19a97bd6 | 663 | if (! found) \ |
99a49d3e | 664 | rval = PCLASS::CBNAME(a, b, c, d, e, f); \ |
99a49d3e | 665 | return rval; \ |
d559219f RD |
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); \ | |
efc5f224 RD |
669 | } |
670 | ||
671 | //--------------------------------------------------------------------------- | |
672 | ||
d559219f RD |
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) { \ | |
19a97bd6 | 680 | bool found; \ |
4268f798 | 681 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 682 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
f2e1c18a | 683 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \ |
d559219f | 684 | (int)a,b,c,d,e)); \ |
4268f798 | 685 | wxPyEndBlockThreads(); \ |
19a97bd6 | 686 | if (! found) \ |
d559219f | 687 | PCLASS::CBNAME(a, b, c, d, e); \ |
d559219f RD |
688 | } \ |
689 | void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \ | |
690 | PCLASS::CBNAME(a, b, c, d, e); \ | |
efc5f224 RD |
691 | } |
692 | ||
693 | //--------------------------------------------------------------------------- | |
694 | ||
19a97bd6 | 695 | #define DEC_PYCALLBACK__DC4DBL(CBNAME) \ |
d559219f RD |
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) { \ | |
19a97bd6 | 702 | bool found; \ |
4268f798 | 703 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
704 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
705 | PyObject* obj = wxPyMake_wxObject(&a); \ | |
1e7ecb7b | 706 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \ |
de20db99 RD |
707 | Py_DECREF(obj); \ |
708 | } \ | |
4268f798 | 709 | wxPyEndBlockThreads(); \ |
19a97bd6 | 710 | if (! found) \ |
d559219f | 711 | PCLASS::CBNAME(a, b, c, d, e); \ |
d559219f RD |
712 | } \ |
713 | void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\ | |
714 | PCLASS::CBNAME(a, b, c, d, e); \ | |
efc5f224 RD |
715 | } |
716 | ||
717 | //--------------------------------------------------------------------------- | |
718 | ||
d559219f RD |
719 | #define DEC_PYCALLBACK__DCBOOL(CBNAME) \ |
720 | void CBNAME(wxDC& a, bool b); \ | |
721 | void base_##CBNAME(wxDC& a, bool b); | |
722 | ||
723 | ||
19a97bd6 RD |
724 | #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \ |
725 | void CLASS::CBNAME(wxDC& a, bool b) { \ | |
726 | bool found; \ | |
4268f798 | 727 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
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 | } \ | |
4268f798 | 733 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
734 | if (! found) \ |
735 | PCLASS::CBNAME(a, b); \ | |
736 | } \ | |
737 | void CLASS::base_##CBNAME(wxDC& a, bool b) { \ | |
738 | PCLASS::CBNAME(a, b); \ | |
efc5f224 | 739 | } |
bb0054cd | 740 | |
7bf85405 | 741 | //--------------------------------------------------------------------------- |
7bf85405 | 742 | |
d559219f RD |
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) { \ | |
19a97bd6 | 751 | bool found; \ |
4268f798 | 752 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
753 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
754 | PyObject* obj = wxPyMake_wxObject(a); \ | |
1e7ecb7b | 755 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\ |
de20db99 RD |
756 | Py_DECREF(obj); \ |
757 | } \ | |
4268f798 | 758 | wxPyEndBlockThreads(); \ |
19a97bd6 | 759 | if (! found) \ |
d559219f | 760 | PCLASS::CBNAME(a, b, c, d, e, f); \ |
d559219f RD |
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); \ | |
efc5f224 RD |
765 | } |
766 | ||
767 | //--------------------------------------------------------------------------- | |
768 | ||
d559219f RD |
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) { \ | |
19a97bd6 | 776 | bool found; \ |
4268f798 | 777 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
778 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
779 | PyObject* obj = wxPyMake_wxObject(a); \ | |
1e7ecb7b | 780 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \ |
de20db99 RD |
781 | Py_DECREF(obj); \ |
782 | } \ | |
4268f798 | 783 | wxPyEndBlockThreads(); \ |
19a97bd6 | 784 | if (! found) \ |
d559219f | 785 | PCLASS::CBNAME(a, b, c, d, e); \ |
d559219f RD |
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); \ | |
efc5f224 RD |
790 | } |
791 | ||
792 | //--------------------------------------------------------------------------- | |
793 | ||
d559219f RD |
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 | ||
19a97bd6 RD |
799 | #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \ |
800 | void CLASS::CBNAME(double a, double b, int c) { \ | |
801 | bool found; \ | |
4268f798 | 802 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
803 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
804 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \ | |
4268f798 | 805 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
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); \ | |
efc5f224 RD |
811 | } |
812 | ||
813 | //--------------------------------------------------------------------------- | |
814 | ||
d559219f RD |
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) { \ | |
19a97bd6 | 822 | bool found; \ |
4268f798 | 823 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
824 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
825 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\ | |
4268f798 | 826 | wxPyEndBlockThreads(); \ |
19a97bd6 | 827 | if (! found) \ |
d559219f | 828 | PCLASS::CBNAME(a, b, c, d); \ |
d559219f RD |
829 | } \ |
830 | void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \ | |
831 | PCLASS::CBNAME(a, b, c, d); \ | |
efc5f224 RD |
832 | } |
833 | ||
834 | //--------------------------------------------------------------------------- | |
835 | //--------------------------------------------------------------------------- | |
389c5527 RD |
836 | |
837 | #define DEC_PYCALLBACK__STRING(CBNAME) \ | |
838 | void CBNAME(const wxString& a); \ | |
839 | void base_##CBNAME(const wxString& a); | |
840 | ||
841 | ||
19a97bd6 RD |
842 | #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \ |
843 | void CLASS::CBNAME(const wxString& a) { \ | |
844 | bool found; \ | |
4268f798 | 845 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
846 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
847 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \ | |
4268f798 | 848 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
849 | if (! found) \ |
850 | PCLASS::CBNAME(a); \ | |
851 | } \ | |
852 | void CLASS::base_##CBNAME(const wxString& a) { \ | |
853 | PCLASS::CBNAME(a); \ | |
389c5527 RD |
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) { \ | |
059a841c | 865 | bool rval=FALSE; \ |
19a97bd6 | 866 | bool found; \ |
4268f798 | 867 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
868 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
869 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str()));\ | |
4268f798 | 870 | wxPyEndBlockThreads(); \ |
19a97bd6 | 871 | if (! found) \ |
389c5527 | 872 | rval = PCLASS::CBNAME(a); \ |
389c5527 RD |
873 | return rval; \ |
874 | } \ | |
875 | bool CLASS::base_##CBNAME(const wxString& a) { \ | |
876 | return PCLASS::CBNAME(a); \ | |
877 | } | |
878 | ||
879 | //--------------------------------------------------------------------------- | |
880 | ||
c368d904 RD |
881 | #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \ |
882 | bool CBNAME(const wxString& a); | |
883 | \ | |
19a97bd6 RD |
884 | #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \ |
885 | bool CLASS::CBNAME(const wxString& a) { \ | |
059a841c | 886 | bool rval=FALSE; \ |
4268f798 | 887 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
888 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ |
889 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \ | |
4268f798 | 890 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
891 | return rval; \ |
892 | } \ | |
c368d904 RD |
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; \ | |
4268f798 | 902 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 903 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ |
c368d904 | 904 | PyObject* ro; \ |
19a97bd6 | 905 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(s)", a.c_str()));\ |
c368d904 | 906 | if (ro) { \ |
de20db99 RD |
907 | PyObject* str = PyObject_Str(ro); \ |
908 | rval = PyString_AsString(str); \ | |
909 | Py_DECREF(ro); Py_DECREF(str); \ | |
c368d904 RD |
910 | } \ |
911 | } \ | |
4268f798 | 912 | wxPyEndBlockThreads(); \ |
c368d904 RD |
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; \ | |
4268f798 | 924 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 925 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ |
c368d904 | 926 | PyObject* ro; \ |
1e7ecb7b | 927 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(si)", a.c_str(),b)); \ |
c368d904 | 928 | if (ro) { \ |
de20db99 RD |
929 | PyObject* str = PyObject_Str(ro); \ |
930 | rval = PyString_AsString(str); \ | |
931 | Py_DECREF(ro); Py_DECREF(str); \ | |
c368d904 RD |
932 | } \ |
933 | } \ | |
4268f798 | 934 | wxPyEndBlockThreads(); \ |
c368d904 RD |
935 | return rval; \ |
936 | } \ | |
937 | ||
938 | //--------------------------------------------------------------------------- | |
939 | ||
f0261a72 RD |
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) { \ | |
059a841c | 947 | bool rval=FALSE; \ |
19a97bd6 | 948 | bool found; \ |
4268f798 | 949 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
950 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
951 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ss)", \ | |
f0261a72 | 952 | a.c_str(), b.c_str())); \ |
4268f798 | 953 | wxPyEndBlockThreads(); \ |
19a97bd6 | 954 | if (! found) \ |
f0261a72 | 955 | rval = PCLASS::CBNAME(a, b); \ |
f0261a72 RD |
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 | ||
389c5527 RD |
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; \ | |
19a97bd6 | 972 | bool found; \ |
4268f798 | 973 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 974 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
389c5527 | 975 | PyObject* ro; \ |
19a97bd6 | 976 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ |
f6bcfd97 | 977 | if (ro) { \ |
de20db99 RD |
978 | PyObject* str = PyObject_Str(ro); \ |
979 | rval = PyString_AsString(str); \ | |
980 | Py_DECREF(ro); Py_DECREF(str); \ | |
f6bcfd97 | 981 | } \ |
389c5527 | 982 | } \ |
4268f798 | 983 | wxPyEndBlockThreads(); \ |
19a97bd6 | 984 | if (! found) \ |
b1462dfa | 985 | rval = PCLASS::CBNAME(); \ |
389c5527 RD |
986 | return rval; \ |
987 | } \ | |
b1462dfa RD |
988 | wxString CLASS::base_##CBNAME() { \ |
989 | return PCLASS::CBNAME(); \ | |
389c5527 RD |
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; \ | |
4268f798 | 1001 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1002 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ |
389c5527 | 1003 | PyObject* ro; \ |
19a97bd6 | 1004 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ |
f6bcfd97 | 1005 | if (ro) { \ |
de20db99 RD |
1006 | PyObject* str = PyObject_Str(ro); \ |
1007 | rval = PyString_AsString(str); \ | |
1008 | Py_DECREF(ro); Py_DECREF(str); \ | |
f6bcfd97 | 1009 | } \ |
389c5527 | 1010 | } \ |
4268f798 | 1011 | wxPyEndBlockThreads(); \ |
389c5527 RD |
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) { \ | |
059a841c | 1023 | bool rval=FALSE; \ |
4268f798 | 1024 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
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)); \ | |
de20db99 RD |
1028 | Py_DECREF(obj); \ |
1029 | } \ | |
4268f798 | 1030 | wxPyEndBlockThreads(); \ |
389c5527 RD |
1031 | return rval; \ |
1032 | } | |
1033 | ||
0122b7e3 RD |
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; \ | |
4268f798 | 1044 | wxPyBeginBlockThreads(); \ |
0122b7e3 RD |
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 | } \ | |
4268f798 | 1050 | wxPyEndBlockThreads(); \ |
0122b7e3 RD |
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; \ | |
4268f798 | 1068 | wxPyBeginBlockThreads(); \ |
0122b7e3 RD |
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 | } \ | |
4268f798 | 1076 | wxPyEndBlockThreads(); \ |
0122b7e3 RD |
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 | ||
389c5527 | 1086 | //--------------------------------------------------------------------------- |
2f90df85 RD |
1087 | |
1088 | #define DEC_PYCALLBACK___pure(CBNAME) \ | |
1089 | void CBNAME(); \ | |
1090 | ||
1091 | ||
1092 | #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \ | |
1093 | void CLASS::CBNAME() { \ | |
4268f798 | 1094 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
1095 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ |
1096 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
4268f798 | 1097 | wxPyEndBlockThreads(); \ |
2f90df85 RD |
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); \ | |
4268f798 | 1109 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1110 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ |
2f90df85 RD |
1111 | PyObject* ro; \ |
1112 | wxSize* ptr; \ | |
19a97bd6 | 1113 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \ |
f6bcfd97 BP |
1114 | if (ro) { \ |
1115 | if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \ | |
1116 | rval = *ptr; \ | |
1117 | Py_DECREF(ro); \ | |
1118 | } \ | |
2f90df85 | 1119 | } \ |
4268f798 | 1120 | wxPyEndBlockThreads(); \ |
2f90df85 RD |
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 | ||
19a97bd6 RD |
1131 | #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \ |
1132 | bool CLASS::CBNAME(wxWindow* a) { \ | |
059a841c | 1133 | bool rval=FALSE; \ |
19a97bd6 | 1134 | bool found; \ |
4268f798 | 1135 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
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 | } \ | |
4268f798 | 1141 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
1142 | if (! found) \ |
1143 | rval = PCLASS::CBNAME(a); \ | |
1144 | return rval; \ | |
1145 | } \ | |
1146 | bool CLASS::base_##CBNAME(wxWindow* a) { \ | |
1147 | return PCLASS::CBNAME(a); \ | |
2f90df85 RD |
1148 | } |
1149 | ||
389c5527 | 1150 | //--------------------------------------------------------------------------- |
2f90df85 RD |
1151 | |
1152 | #define DEC_PYCALLBACK_BOOL_(CBNAME) \ | |
1153 | bool CBNAME(); \ | |
1154 | bool base_##CBNAME(); | |
1155 | ||
1156 | ||
19a97bd6 RD |
1157 | #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \ |
1158 | bool CLASS::CBNAME() { \ | |
059a841c | 1159 | bool rval=FALSE; \ |
19a97bd6 | 1160 | bool found; \ |
4268f798 | 1161 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
1162 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
1163 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
4268f798 | 1164 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
1165 | if (! found) \ |
1166 | rval = PCLASS::CBNAME(); \ | |
1167 | return rval; \ | |
1168 | } \ | |
1169 | bool CLASS::base_##CBNAME() { \ | |
1170 | return PCLASS::CBNAME(); \ | |
2f90df85 RD |
1171 | } |
1172 | ||
b1462dfa RD |
1173 | //--------------------------------------------------------------------------- |
1174 | ||
19a97bd6 RD |
1175 | #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \ |
1176 | wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \ | |
b1462dfa RD |
1177 | wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def); |
1178 | ||
1179 | ||
19a97bd6 RD |
1180 | #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \ |
1181 | wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \ | |
059a841c | 1182 | int rval=0; \ |
19a97bd6 | 1183 | bool found; \ |
4268f798 | 1184 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1185 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
1e7ecb7b | 1186 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\ |
4268f798 | 1187 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
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); \ | |
b1462dfa RD |
1194 | } |
1195 | ||
1196 | //--------------------------------------------------------------------------- | |
1197 | ||
c368d904 RD |
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) { \ | |
4268f798 | 1203 | wxPyBeginBlockThreads(); \ |
c368d904 | 1204 | wxFSFile* rval=0; \ |
19a97bd6 | 1205 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \ |
c368d904 | 1206 | PyObject* ro; \ |
19a97bd6 RD |
1207 | PyObject* obj = wxPyMake_wxObject(&a); \ |
1208 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Os)",\ | |
de20db99 | 1209 | obj, b.c_str())); \ |
c368d904 RD |
1210 | if (ro) { \ |
1211 | SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \ | |
1212 | Py_DECREF(ro); \ | |
1213 | } \ | |
de20db99 RD |
1214 | Py_DECREF(obj); \ |
1215 | } \ | |
4268f798 | 1216 | wxPyEndBlockThreads(); \ |
c368d904 RD |
1217 | return rval; \ |
1218 | }; | |
1219 | ||
1220 | //--------------------------------------------------------------------------- | |
1221 | ||
b1462dfa RD |
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) { \ | |
059a841c | 1229 | bool rval=FALSE; \ |
19a97bd6 | 1230 | bool found; \ |
4268f798 | 1231 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
1232 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
1233 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\ | |
4268f798 | 1234 | wxPyEndBlockThreads(); \ |
19a97bd6 | 1235 | if (! found) \ |
b1462dfa | 1236 | rval = PCLASS::CBNAME(a); \ |
b1462dfa RD |
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) { \ | |
4268f798 | 1251 | wxPyBeginBlockThreads(); \ |
059a841c | 1252 | int rval=0; \ |
19a97bd6 | 1253 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ |
1e7ecb7b | 1254 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\ |
4268f798 | 1255 | wxPyEndBlockThreads(); \ |
b1462dfa RD |
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) { \ | |
059a841c | 1267 | bool rval=FALSE; \ |
4268f798 | 1268 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1269 | if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \ |
1e7ecb7b | 1270 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));\ |
4268f798 | 1271 | wxPyEndBlockThreads(); \ |
b1462dfa RD |
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() { \ | |
059a841c | 1284 | size_t rval=0; \ |
19a97bd6 | 1285 | bool found; \ |
4268f798 | 1286 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
1287 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ |
1288 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ | |
4268f798 | 1289 | wxPyEndBlockThreads(); \ |
19a97bd6 | 1290 | if (! found) \ |
b1462dfa | 1291 | rval = PCLASS::CBNAME(); \ |
b1462dfa RD |
1292 | return rval; \ |
1293 | } \ | |
1294 | size_t CLASS::base_##CBNAME() { \ | |
1295 | return PCLASS::CBNAME(); \ | |
1296 | } | |
1297 | ||
1298 | //--------------------------------------------------------------------------- | |
1299 | ||
c7e7022c RD |
1300 | #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \ |
1301 | wxDataFormat CBNAME(size_t a); \ | |
1302 | wxDataFormat base_##CBNAME(size_t a); | |
b1462dfa RD |
1303 | |
1304 | ||
1305 | #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \ | |
1306 | wxDataFormat CLASS::CBNAME(size_t a) { \ | |
059a841c | 1307 | wxDataFormat rval=0; \ |
19a97bd6 | 1308 | bool found; \ |
4268f798 | 1309 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1310 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
b1462dfa RD |
1311 | PyObject* ro; \ |
1312 | wxDataFormat* ptr; \ | |
c7e7022c | 1313 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \ |
f6bcfd97 BP |
1314 | if (ro) { \ |
1315 | if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \ | |
1316 | rval = *ptr; \ | |
1317 | Py_DECREF(ro); \ | |
1318 | } \ | |
b1462dfa | 1319 | } \ |
4268f798 | 1320 | wxPyEndBlockThreads(); \ |
19a97bd6 | 1321 | if (! found) \ |
b1462dfa | 1322 | rval = PCLASS::CBNAME(a); \ |
b1462dfa RD |
1323 | return rval; \ |
1324 | } \ | |
1325 | wxDataFormat CLASS::base_##CBNAME(size_t a) { \ | |
1326 | return PCLASS::CBNAME(a); \ | |
1327 | } | |
1328 | ||
389c5527 | 1329 | //--------------------------------------------------------------------------- |
f6bcfd97 BP |
1330 | |
1331 | #define DEC_PYCALLBACK__constany(CBNAME, Type) \ | |
1332 | void CBNAME(const Type& a); \ | |
1333 | void base_##CBNAME(const Type& a); | |
1334 | ||
1335 | ||
19a97bd6 RD |
1336 | #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \ |
1337 | void CLASS::CBNAME(const Type& a) { \ | |
1338 | bool found; \ | |
4268f798 | 1339 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
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 | } \ | |
4268f798 | 1345 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
1346 | if (! found) \ |
1347 | PCLASS::CBNAME(a); \ | |
1348 | } \ | |
1349 | void CLASS::base_##CBNAME(const Type& a) { \ | |
1350 | PCLASS::CBNAME(a); \ | |
f6bcfd97 BP |
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 | ||
19a97bd6 RD |
1361 | #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \ |
1362 | void CLASS::CBNAME(Type& a) { \ | |
1363 | bool found; \ | |
4268f798 | 1364 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
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 | } \ | |
4268f798 | 1370 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
1371 | if (! found) \ |
1372 | PCLASS::CBNAME(a); \ | |
1373 | } \ | |
1374 | void CLASS::base_##CBNAME(Type& a) { \ | |
1375 | PCLASS::CBNAME(a); \ | |
f6bcfd97 BP |
1376 | } |
1377 | ||
efc5f224 | 1378 | //--------------------------------------------------------------------------- |
f6bcfd97 BP |
1379 | |
1380 | #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \ | |
1381 | bool CBNAME(Type& a); \ | |
1382 | bool base_##CBNAME(Type& a); | |
1383 | ||
1384 | ||
19a97bd6 RD |
1385 | #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \ |
1386 | bool CLASS::CBNAME(Type& a) { \ | |
36fd8ec3 | 1387 | bool rv=FALSE; \ |
19a97bd6 | 1388 | bool found; \ |
4268f798 | 1389 | wxPyBeginBlockThreads(); \ |
19a97bd6 RD |
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 | } \ | |
4268f798 | 1395 | wxPyEndBlockThreads(); \ |
19a97bd6 RD |
1396 | if (! found) \ |
1397 | rv = PCLASS::CBNAME(a); \ | |
1398 | return rv; \ | |
1399 | } \ | |
1400 | bool CLASS::base_##CBNAME(Type& a) { \ | |
1401 | return PCLASS::CBNAME(a); \ | |
f6bcfd97 BP |
1402 | } |
1403 | ||
efc5f224 RD |
1404 | //--------------------------------------------------------------------------- |
1405 | ||
c7e7022c RD |
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; \ | |
19a97bd6 | 1414 | bool found; \ |
4268f798 | 1415 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1416 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
c7e7022c RD |
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 | } \ | |
4268f798 | 1425 | wxPyEndBlockThreads(); \ |
19a97bd6 | 1426 | if (! found) \ |
c7e7022c | 1427 | rval = PCLASS::CBNAME(a,b); \ |
c7e7022c RD |
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; \ | |
19a97bd6 | 1444 | bool found; \ |
4268f798 | 1445 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1446 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
c7e7022c RD |
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 | } \ | |
4268f798 | 1454 | wxPyEndBlockThreads(); \ |
19a97bd6 | 1455 | if (! found) \ |
c7e7022c | 1456 | rval = PCLASS::CBNAME(a); \ |
c7e7022c RD |
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) \ | |
00b6c4e3 | 1467 | wxListItemAttr* CBNAME(long a) const; \ |
c7e7022c RD |
1468 | wxListItemAttr* base_##CBNAME(long a); |
1469 | ||
1470 | ||
1471 | #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \ | |
00b6c4e3 | 1472 | wxListItemAttr *CLASS::CBNAME(long a) const { \ |
c7e7022c | 1473 | wxListItemAttr *rval = NULL; \ |
19a97bd6 | 1474 | bool found; \ |
4268f798 | 1475 | wxPyBeginBlockThreads(); \ |
19a97bd6 | 1476 | if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ |
c7e7022c RD |
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 | } \ | |
4268f798 | 1486 | wxPyEndBlockThreads(); \ |
19a97bd6 | 1487 | if (! found) \ |
c7e7022c | 1488 | rval = PCLASS::CBNAME(a); \ |
c7e7022c RD |
1489 | return rval; \ |
1490 | } \ | |
1491 | wxListItemAttr *CLASS::base_##CBNAME(long a) { \ | |
1492 | return PCLASS::CBNAME(a); \ | |
1493 | } | |
1494 | ||
1495 | //--------------------------------------------------------------------------- | |
1496 | ||
0122b7e3 RD |
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) { \ | |
36fd8ec3 | 1503 | bool rval=FALSE; \ |
0122b7e3 | 1504 | bool found; \ |
4268f798 | 1505 | wxPyBeginBlockThreads(); \ |
0122b7e3 RD |
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 | } \ | |
4268f798 | 1516 | wxPyEndBlockThreads(); \ |
0122b7e3 RD |
1517 | if (! found) \ |
1518 | return PCLASS::CBNAME(e); \ | |
9d37f964 | 1519 | return rval; \ |
0122b7e3 RD |
1520 | } \ |
1521 | bool CLASS::base_##CBNAME(wxMouseEvent& e) { \ | |
1522 | return PCLASS::CBNAME(e); \ | |
1523 | } | |
1524 | ||
1525 | ||
1526 | //--------------------------------------------------------------------------- | |
1527 | ||
7bf85405 | 1528 | #endif |