1 ////////////////////////////////////////////////////////////////////////////
3 // Purpose: Helper functions/classes for the wxPython extension module
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef __wxp_helpers__
14 #define __wxp_helpers__
19 //---------------------------------------------------------------------------
21 typedef unsigned char byte
;
24 class wxPyApp
: public wxApp
33 extern wxPyApp
*wxPythonApp
;
35 //----------------------------------------------------------------------
38 PyObject
* __wxStart(PyObject
*, PyObject
* args
);
41 //extern PyObject* wxPython_dict;
42 PyObject
* __wxSetDictionary(PyObject
*, PyObject
* args
);
44 void wxPyEventThunker(wxObject
*, wxEvent
& event
);
46 PyObject
* wxPyConstructObject(void* ptr
,
47 const wxString
& className
,
49 PyObject
* wxPyConstructObject(void* ptr
,
50 const wxString
& className
,
54 PyObject
* wx2PyString(const wxString
& src
);
55 wxString
Py2wxString(PyObject
* source
);
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
);
62 PyObject
* wxPy_ConvertList(wxListBase
* list
, const char* className
);
63 long wxPyGetWinHandle(wxWindow
* win
);
65 //----------------------------------------------------------------------
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
76 PyThreadState
* wxPyBeginAllowThreads();
77 void wxPyEndAllowThreads(PyThreadState
* state
);
80 void wxPyBeginBlockThreads();
81 void wxPyEndBlockThreads();
83 //----------------------------------------------------------------------
84 // These are helpers used by the typemaps
86 wxString
* wxString_in_helper(PyObject
* source
);
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
);
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
);
104 //----------------------------------------------------------------------
105 // Other helpful stuff
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))
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
);
116 PyObject
* wxArrayString2PyList_helper(const wxArrayString
& arr
);
117 PyObject
* wxArrayInt2PyList_helper(const wxArrayInt
& arr
);
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)
123 //----------------------------------------------------------------------
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
);
133 # pragma warning(disable:4800)
134 # pragma warning(disable:4190)
137 //----------------------------------------------------------------------
139 class wxPyCallback
: public wxObject
{
140 DECLARE_ABSTRACT_CLASS(wxPyCallback
);
142 wxPyCallback(PyObject
* func
);
143 wxPyCallback(const wxPyCallback
& other
);
146 void EventThunker(wxEvent
& event
);
151 //---------------------------------------------------------------------------
153 class wxPyTimer
: public wxTimer
{
155 wxPyTimer(PyObject
* callback
);
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.
171 class wxPyEvtSelfRef
{
176 void SetSelf(PyObject
* self
, bool clone
=FALSE
);
177 PyObject
* GetSelf() const;
185 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
186 DECLARE_ABSTRACT_CLASS(wxPyEvent
)
189 wxPyEvent(const wxPyEvent
& evt
);
192 virtual wxEvent
* Clone() const { return new wxPyEvent(*this); }
196 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
197 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent
)
199 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
200 wxPyCommandEvent(const wxPyCommandEvent
& evt
);
203 virtual wxEvent
* Clone() const { return new wxPyCommandEvent(*this); }
208 //----------------------------------------------------------------------
209 // Forward decalre a few things used in the exported API
210 class wxPyClientData
;
212 class wxPyOORClientData
;
214 void wxPyClientData_dtor(wxPyClientData
* self
);
215 void wxPyUserData_dtor(wxPyUserData
* self
);
216 void wxPyOORClientData_dtor(wxPyOORClientData
* self
);
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.
224 class wxPyCallbackHelper
;
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);
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
;
245 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
246 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
247 void (*p_wxPyBeginBlockThreads
)();
248 void (*p_wxPyEndBlockThreads
)();
250 PyObject
* (*p_wxPyConstructObject
)(void *, const wxString
&, int);
251 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
, const char* className
);
253 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
254 wxString (*p_Py2wxString
)(PyObject
* source
);
255 PyObject
* (*p_wx2PyString
)(const wxString
& src
);
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
);
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
);
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
);
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
);
285 void (*p_wxPyClientData_dtor
)(wxPyClientData
*);
286 void (*p_wxPyUserData_dtor
)(wxPyUserData
*);
287 void (*p_wxPyOORClientData_dtor
)(wxPyOORClientData
*);
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
;
297 //---------------------------------------------------------------------------
300 class wxPyUserData
: public wxObject
{
302 wxPyUserData(PyObject
* obj
) {
308 #ifdef wxPyUSE_EXPORT
309 wxPyCoreAPIPtr
->p_wxPyUserData_dtor(this);
311 wxPyUserData_dtor(this);
318 class wxPyClientData
: public wxClientData
{
320 wxPyClientData(PyObject
* obj
) {
326 #ifdef wxPyUSE_EXPORT
327 wxPyCoreAPIPtr
->p_wxPyClientData_dtor(this);
329 wxPyClientData_dtor(this);
336 class wxPyOORClientData
: public wxPyClientData
{
338 wxPyOORClientData(PyObject
* obj
)
339 : wxPyClientData(obj
) {}
341 ~wxPyOORClientData() {
342 #ifdef wxPyUSE_EXPORT
343 wxPyCoreAPIPtr
->p_wxPyOORClientData_dtor(this);
345 wxPyOORClientData_dtor(this);
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.
358 class wxPyCallbackHelper
{
360 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
362 wxPyCallbackHelper() {
369 ~wxPyCallbackHelper() {
370 #ifdef wxPyUSE_EXPORT
371 wxPyCoreAPIPtr
->p_wxPyCBH_delete(this);
373 wxPyCBH_delete(this);
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;
385 PyObject
* m_lastFound
;
388 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
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
);
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 //---------------------------------------------------------------------------
408 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
409 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
411 private: wxPyCallbackHelper m_myInst
413 //---------------------------------------------------------------------------
415 #define DEC_PYCALLBACK__(CBNAME) \
417 void base_##CBNAME();
420 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
421 void CLASS::CBNAME() { \
423 wxPyBeginBlockThreads(); \
424 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
425 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
426 wxPyEndBlockThreads(); \
430 void CLASS::base_##CBNAME() { \
434 //---------------------------------------------------------------------------
436 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
437 bool CBNAME(int a, int b); \
438 bool base_##CBNAME(int a, int b);
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(); \
449 rval = PCLASS::CBNAME(a,b); \
452 bool CLASS::base_##CBNAME(int a, int b) { \
453 return PCLASS::CBNAME(a,b); \
456 //---------------------------------------------------------------------------
458 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
459 void CBNAME(int a, int b); \
460 void base_##CBNAME(int a, int b);
463 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
464 void CLASS::CBNAME(int a, int b) { \
466 wxPyBeginBlockThreads(); \
467 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
468 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
469 wxPyEndBlockThreads(); \
471 PCLASS::CBNAME(a,b); \
473 void CLASS::base_##CBNAME(int a, int b) { \
474 PCLASS::CBNAME(a,b); \
477 //---------------------------------------------------------------------------
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);
484 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
485 void CLASS::CBNAME(int a, int b, int c, int d) { \
487 wxPyBeginBlockThreads(); \
488 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
489 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
490 wxPyEndBlockThreads(); \
492 PCLASS::CBNAME(a,b,c,d); \
494 void CLASS::base_##CBNAME(int a, int b, int c, int d) { \
495 PCLASS::CBNAME(a,b,c,d); \
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);
504 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
505 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
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(); \
512 PCLASS::CBNAME(a,b,c,d,e); \
514 void CLASS::base_##CBNAME(int a, int b, int c, int d, int e) { \
515 PCLASS::CBNAME(a,b,c,d,e); \
518 //---------------------------------------------------------------------------
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;
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."; \
529 wxPyBeginBlockThreads(); \
530 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
532 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
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); \
541 PyErr_SetString(PyExc_TypeError, errmsg); \
546 PyErr_SetString(PyExc_TypeError, errmsg); \
551 wxPyEndBlockThreads(); \
553 PCLASS::CBNAME(a,b); \
555 void CLASS::base_##CBNAME(int* a, int* b) const { \
556 PCLASS::CBNAME(a,b); \
560 //---------------------------------------------------------------------------
562 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
563 wxSize CBNAME() const; \
564 wxSize base_##CBNAME() const;
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))) { \
574 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
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)); \
583 PyErr_SetString(PyExc_TypeError, errmsg); \
588 PyErr_SetString(PyExc_TypeError, errmsg); \
593 wxPyEndBlockThreads(); \
595 return PCLASS::CBNAME(); \
599 wxSize CLASS::base_##CBNAME() const { \
600 return PCLASS::CBNAME(); \
604 //---------------------------------------------------------------------------
606 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
607 bool CBNAME(int a); \
608 bool base_##CBNAME(int a);
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(); \
619 rval = PCLASS::CBNAME(a); \
622 bool CLASS::base_##CBNAME(int a) { \
623 return PCLASS::CBNAME(a); \
626 //---------------------------------------------------------------------------
628 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
632 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
633 bool CLASS::CBNAME(int a) { \
635 wxPyBeginBlockThreads(); \
636 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
637 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
639 wxPyEndBlockThreads(); \
644 //---------------------------------------------------------------------------
646 #define DEC_PYCALLBACK__DC(CBNAME) \
647 void CBNAME(wxDC& a); \
648 void base_##CBNAME(wxDC& a);
651 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
652 void CLASS::CBNAME(wxDC& a) { \
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)); \
660 wxPyEndBlockThreads(); \
664 void CLASS::base_##CBNAME(wxDC& a) { \
670 //---------------------------------------------------------------------------
672 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
673 void CBNAME(wxDC& a, bool b); \
674 void base_##CBNAME(wxDC& a, bool b);
677 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
678 void CLASS::CBNAME(wxDC& a, bool b) { \
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)); \
686 wxPyEndBlockThreads(); \
688 PCLASS::CBNAME(a, b); \
690 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
691 PCLASS::CBNAME(a, b); \
694 //---------------------------------------------------------------------------
696 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
697 void CBNAME(wxDC& a, bool b); \
698 void base_##CBNAME(wxDC& a, bool b);
701 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
702 void CLASS::CBNAME(wxDC& a, bool b) { \
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)); \
710 wxPyEndBlockThreads(); \
712 PCLASS::CBNAME(a, b); \
714 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
715 PCLASS::CBNAME(a, b); \
718 //---------------------------------------------------------------------------
720 #define DEC_PYCALLBACK__2DBL(CBNAME) \
721 void CBNAME(double a, double b); \
722 void base_##CBNAME(double a, double b);
725 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
726 void CLASS::CBNAME(double a, double b) { \
728 wxPyBeginBlockThreads(); \
729 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
730 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
731 wxPyEndBlockThreads(); \
733 PCLASS::CBNAME(a, b); \
735 void CLASS::base_##CBNAME(double a, double b) { \
736 PCLASS::CBNAME(a, b); \
739 //---------------------------------------------------------------------------
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);
746 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
747 void CLASS::CBNAME(double a, double b, int c, int d) { \
749 wxPyBeginBlockThreads(); \
750 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
751 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
753 wxPyEndBlockThreads(); \
755 PCLASS::CBNAME(a, b, c, d); \
757 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
758 PCLASS::CBNAME(a, b, c, d); \
761 //---------------------------------------------------------------------------
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);
768 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
769 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
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)); \
777 wxPyEndBlockThreads(); \
779 PCLASS::CBNAME(a, b, c, d, e, f); \
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); \
785 //---------------------------------------------------------------------------
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);
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) { \
795 wxPyBeginBlockThreads(); \
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));\
802 wxPyEndBlockThreads(); \
804 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
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); \
811 //---------------------------------------------------------------------------
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);
818 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
819 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
821 wxPyBeginBlockThreads(); \
822 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
823 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
825 wxPyEndBlockThreads(); \
827 PCLASS::CBNAME(a, b, c, d, e); \
829 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
830 PCLASS::CBNAME(a, b, c, d, e); \
833 //---------------------------------------------------------------------------
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);
840 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
841 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
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)); \
849 wxPyEndBlockThreads(); \
851 PCLASS::CBNAME(a, b, c, d, e); \
853 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
854 PCLASS::CBNAME(a, b, c, d, e); \
857 //---------------------------------------------------------------------------
859 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
860 void CBNAME(wxDC& a, bool b); \
861 void base_##CBNAME(wxDC& a, bool b);
864 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
865 void CLASS::CBNAME(wxDC& a, bool b) { \
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)); \
873 wxPyEndBlockThreads(); \
875 PCLASS::CBNAME(a, b); \
877 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
878 PCLASS::CBNAME(a, b); \
881 //---------------------------------------------------------------------------
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);
888 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
889 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
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));\
898 wxPyEndBlockThreads(); \
900 PCLASS::CBNAME(a, b, c, d, e, f); \
902 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
904 PCLASS::CBNAME(a, b, c, d, e, f); \
907 //---------------------------------------------------------------------------
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);
914 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
915 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
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)); \
923 wxPyEndBlockThreads(); \
925 PCLASS::CBNAME(a, b, c, d, e); \
927 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
929 PCLASS::CBNAME(a, b, c, d, e); \
932 //---------------------------------------------------------------------------
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);
939 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
940 void CLASS::CBNAME(double a, double b, int c) { \
942 wxPyBeginBlockThreads(); \
943 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
944 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
945 wxPyEndBlockThreads(); \
947 PCLASS::CBNAME(a, b, c); \
949 void CLASS::base_##CBNAME(double a, double b, int c) { \
950 PCLASS::CBNAME(a, b, c); \
953 //---------------------------------------------------------------------------
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);
960 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
961 void CLASS::CBNAME(bool a, double b, double c, int d) { \
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(); \
968 PCLASS::CBNAME(a, b, c, d); \
970 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
971 PCLASS::CBNAME(a, b, c, d); \
974 //---------------------------------------------------------------------------
975 //---------------------------------------------------------------------------
977 #define DEC_PYCALLBACK__STRING(CBNAME) \
978 void CBNAME(const wxString& a); \
979 void base_##CBNAME(const wxString& a);
981 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
982 void CLASS::CBNAME(const wxString& a) { \
984 wxPyBeginBlockThreads(); \
985 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
986 PyObject* s = wx2PyString(a); \
987 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
990 wxPyEndBlockThreads(); \
994 void CLASS::base_##CBNAME(const wxString& a) { \
998 //---------------------------------------------------------------------------
1000 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1001 bool CBNAME(const wxString& a); \
1002 bool base_##CBNAME(const wxString& a);
1004 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1005 bool CLASS::CBNAME(const wxString& a) { \
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)); \
1014 wxPyEndBlockThreads(); \
1016 rval = PCLASS::CBNAME(a); \
1019 bool CLASS::base_##CBNAME(const wxString& a) { \
1020 return PCLASS::CBNAME(a); \
1023 //---------------------------------------------------------------------------
1025 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1026 bool CBNAME(const wxString& a);
1028 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1029 bool CLASS::CBNAME(const wxString& a) { \
1031 wxPyBeginBlockThreads(); \
1032 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1033 PyObject* s = wx2PyString(a); \
1034 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1037 wxPyEndBlockThreads(); \
1041 //---------------------------------------------------------------------------
1043 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1044 wxString CBNAME(const wxString& a); \
1046 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1047 wxString CLASS::CBNAME(const wxString& a) { \
1049 wxPyBeginBlockThreads(); \
1050 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1052 PyObject* s = wx2PyString(a); \
1053 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1056 rval = Py2wxString(ro); \
1060 wxPyEndBlockThreads(); \
1064 //---------------------------------------------------------------------------
1066 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1067 wxString CBNAME(const wxString& a,int b); \
1069 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1070 wxString CLASS::CBNAME(const wxString& a,int b) { \
1072 wxPyBeginBlockThreads(); \
1073 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1075 PyObject* s = wx2PyString(a); \
1076 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1079 rval = Py2wxString(ro); \
1083 wxPyEndBlockThreads(); \
1087 //---------------------------------------------------------------------------
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);
1093 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1094 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
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)); \
1105 wxPyEndBlockThreads(); \
1107 rval = PCLASS::CBNAME(a, b); \
1110 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
1111 return PCLASS::CBNAME(a, b); \
1114 //---------------------------------------------------------------------------
1116 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1117 wxString CBNAME(); \
1118 wxString base_##CBNAME();
1120 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1121 wxString CLASS::CBNAME() { \
1124 wxPyBeginBlockThreads(); \
1125 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1127 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1129 rval = Py2wxString(ro); \
1133 wxPyEndBlockThreads(); \
1135 rval = PCLASS::CBNAME(); \
1138 wxString CLASS::base_##CBNAME() { \
1139 return PCLASS::CBNAME(); \
1142 //---------------------------------------------------------------------------
1144 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1147 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1148 wxString CLASS::CBNAME() { \
1150 wxPyBeginBlockThreads(); \
1151 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1153 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1155 rval = Py2wxString(ro); \
1159 wxPyEndBlockThreads(); \
1163 //---------------------------------------------------------------------------
1165 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1166 bool CBNAME(const wxHtmlTag& a); \
1169 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1170 bool CLASS::CBNAME(const wxHtmlTag& a) { \
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)); \
1178 wxPyEndBlockThreads(); \
1182 //---------------------------------------------------------------------------
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);
1188 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1189 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
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)); \
1197 wxPyEndBlockThreads(); \
1199 PCLASS::CBNAME(cell, x, y); \
1201 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1202 PCLASS::CBNAME(cell, x, y); \
1206 //---------------------------------------------------------------------------
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);
1212 #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \
1213 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
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)); \
1223 wxPyEndBlockThreads(); \
1225 PCLASS::CBNAME(cell, x, y, e); \
1227 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1228 PCLASS::CBNAME(cell, x, y, e); \
1233 //---------------------------------------------------------------------------
1235 #define DEC_PYCALLBACK___pure(CBNAME) \
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(); \
1247 //---------------------------------------------------------------------------
1249 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
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."; \
1257 wxPyBeginBlockThreads(); \
1258 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1261 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1263 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
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)); \
1271 PyErr_SetString(PyExc_TypeError, errmsg); \
1276 PyErr_SetString(PyExc_TypeError, errmsg); \
1281 wxPyEndBlockThreads(); \
1285 //---------------------------------------------------------------------------
1287 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1288 bool CBNAME(wxWindow* a); \
1289 bool base_##CBNAME(wxWindow* a);
1292 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1293 bool CLASS::CBNAME(wxWindow* a) { \
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)); \
1302 wxPyEndBlockThreads(); \
1304 rval = PCLASS::CBNAME(a); \
1307 bool CLASS::base_##CBNAME(wxWindow* a) { \
1308 return PCLASS::CBNAME(a); \
1311 //---------------------------------------------------------------------------
1313 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1315 bool base_##CBNAME();
1318 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1319 bool CLASS::CBNAME() { \
1322 wxPyBeginBlockThreads(); \
1323 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1324 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1325 wxPyEndBlockThreads(); \
1327 rval = PCLASS::CBNAME(); \
1330 bool CLASS::base_##CBNAME() { \
1331 return PCLASS::CBNAME(); \
1334 //---------------------------------------------------------------------------
1336 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1337 bool CBNAME() const; \
1338 bool base_##CBNAME() const;
1341 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1342 bool CLASS::CBNAME() const { \
1345 wxPyBeginBlockThreads(); \
1346 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1347 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1348 wxPyEndBlockThreads(); \
1350 rval = PCLASS::CBNAME(); \
1353 bool CLASS::base_##CBNAME() const { \
1354 return PCLASS::CBNAME(); \
1357 //---------------------------------------------------------------------------
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);
1364 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1365 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1368 wxPyBeginBlockThreads(); \
1369 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1370 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1371 wxPyEndBlockThreads(); \
1373 rval = PCLASS::CBNAME(a, b, c); \
1374 return (wxDragResult)rval; \
1376 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1377 return PCLASS::CBNAME(a, b, c); \
1380 //---------------------------------------------------------------------------
1382 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1383 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location); \
1385 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1386 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1387 wxPyBeginBlockThreads(); \
1389 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1391 PyObject* obj = wxPyMake_wxObject(&a); \
1392 PyObject* s = wx2PyString(b); \
1393 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)",\
1396 SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \
1402 wxPyEndBlockThreads(); \
1406 //---------------------------------------------------------------------------
1408 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1409 bool CBNAME(wxDragResult a); \
1410 bool base_##CBNAME(wxDragResult a);
1413 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1414 bool CLASS::CBNAME(wxDragResult a) { \
1417 wxPyBeginBlockThreads(); \
1418 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1419 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\
1420 wxPyEndBlockThreads(); \
1422 rval = PCLASS::CBNAME(a); \
1425 bool CLASS::base_##CBNAME(wxDragResult a) { \
1426 return PCLASS::CBNAME(a); \
1429 //---------------------------------------------------------------------------
1431 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1432 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1435 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1436 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1437 wxPyBeginBlockThreads(); \
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; \
1445 //---------------------------------------------------------------------------
1447 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1448 bool CBNAME(int a, int b, const wxString& c);
1450 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1451 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
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));\
1459 wxPyEndBlockThreads(); \
1463 //---------------------------------------------------------------------------
1465 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1467 size_t base_##CBNAME();
1470 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1471 size_t CLASS::CBNAME() { \
1474 wxPyBeginBlockThreads(); \
1475 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1476 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1477 wxPyEndBlockThreads(); \
1479 rval = PCLASS::CBNAME(); \
1482 size_t CLASS::base_##CBNAME() { \
1483 return PCLASS::CBNAME(); \
1486 //---------------------------------------------------------------------------
1488 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1489 wxDataFormat CBNAME(size_t a); \
1490 wxDataFormat base_##CBNAME(size_t a);
1493 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1494 wxDataFormat CLASS::CBNAME(size_t a) { \
1495 wxDataFormat rval=0; \
1497 wxPyBeginBlockThreads(); \
1498 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1500 wxDataFormat* ptr; \
1501 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1503 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
1508 wxPyEndBlockThreads(); \
1510 rval = PCLASS::CBNAME(a); \
1513 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1514 return PCLASS::CBNAME(a); \
1517 //---------------------------------------------------------------------------
1519 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1520 void CBNAME(const Type& a); \
1521 void base_##CBNAME(const Type& a);
1524 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1525 void CLASS::CBNAME(const Type& a) { \
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)); \
1533 wxPyEndBlockThreads(); \
1535 PCLASS::CBNAME(a); \
1537 void CLASS::base_##CBNAME(const Type& a) { \
1538 PCLASS::CBNAME(a); \
1542 //---------------------------------------------------------------------------
1544 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1545 void CBNAME(Type& a); \
1546 void base_##CBNAME(Type& a);
1549 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1550 void CLASS::CBNAME(Type& a) { \
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)); \
1558 wxPyEndBlockThreads(); \
1560 PCLASS::CBNAME(a); \
1562 void CLASS::base_##CBNAME(Type& a) { \
1563 PCLASS::CBNAME(a); \
1566 //---------------------------------------------------------------------------
1568 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1569 bool CBNAME(Type& a); \
1570 bool base_##CBNAME(Type& a);
1573 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1574 bool CLASS::CBNAME(Type& a) { \
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)); \
1583 wxPyEndBlockThreads(); \
1585 rv = PCLASS::CBNAME(a); \
1588 bool CLASS::base_##CBNAME(Type& a) { \
1589 return PCLASS::CBNAME(a); \
1592 //---------------------------------------------------------------------------
1594 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1595 wxString CBNAME(long a, long b) const; \
1596 wxString base_##CBNAME(long a, long b)const ;
1598 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1599 wxString CLASS::CBNAME(long a, long b) const { \
1602 wxPyBeginBlockThreads(); \
1603 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1605 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1607 rval = Py2wxString(ro); \
1611 wxPyEndBlockThreads(); \
1613 rval = PCLASS::CBNAME(a,b); \
1616 wxString CLASS::base_##CBNAME(long a, long b) const { \
1617 return PCLASS::CBNAME(a,b); \
1620 //---------------------------------------------------------------------------
1622 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1623 int CBNAME(long a) const; \
1624 int base_##CBNAME(long a)const ;
1627 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1628 int CLASS::CBNAME(long a) const { \
1631 wxPyBeginBlockThreads(); \
1632 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1634 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1636 rval = PyInt_AsLong(ro); \
1640 wxPyEndBlockThreads(); \
1642 rval = PCLASS::CBNAME(a); \
1645 int CLASS::base_##CBNAME(long a) const { \
1646 return PCLASS::CBNAME(a); \
1650 //---------------------------------------------------------------------------
1652 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
1653 wxListItemAttr* CBNAME(long a) const; \
1654 wxListItemAttr* base_##CBNAME(long a);
1657 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
1658 wxListItemAttr *CLASS::CBNAME(long a) const { \
1659 wxListItemAttr *rval = NULL; \
1661 wxPyBeginBlockThreads(); \
1662 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1664 wxListItemAttr* ptr; \
1665 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1667 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxListItemAttr_p")) \
1672 wxPyEndBlockThreads(); \
1674 rval = PCLASS::CBNAME(a); \
1677 wxListItemAttr *CLASS::base_##CBNAME(long a) { \
1678 return PCLASS::CBNAME(a); \
1681 //---------------------------------------------------------------------------
1683 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
1684 bool CBNAME(wxMouseEvent& e); \
1685 bool base_##CBNAME(wxMouseEvent& e);
1687 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
1688 bool CLASS::CBNAME(wxMouseEvent& e) { \
1691 wxPyBeginBlockThreads(); \
1692 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1694 PyObject* obj = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
1695 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1697 rval = PyInt_AsLong(ro); \
1702 wxPyEndBlockThreads(); \
1704 return PCLASS::CBNAME(e); \
1707 bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
1708 return PCLASS::CBNAME(e); \
1712 //---------------------------------------------------------------------------