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