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