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