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