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