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
;
213 class wxPyCBInputStream
;
215 void wxPyClientData_dtor(wxPyClientData
* self
);
216 void wxPyUserData_dtor(wxPyUserData
* self
);
217 void wxPyOORClientData_dtor(wxPyOORClientData
* self
);
218 wxPyCBInputStream
* wxPyCBInputStream_create(PyObject
*py
, bool block
);
221 //---------------------------------------------------------------------------
222 // Export a C API in a struct. Other modules will be able to load this from
223 // the wxc module and will then have safe access to these functions, even if
224 // in another shared library.
226 class wxPyCallbackHelper
;
229 // Make SunCC happy and make typedef's for these that are extern "C"
230 typedef void (*p_SWIG_MakePtr_t
)(char*, void*, char*);
231 typedef char* (*p_SWIG_GetPtr_t
)(char*, void**, char*);
232 typedef char* (*p_SWIG_GetPtrObj_t
)(PyObject
*, void**, char*);
233 typedef void (*p_SWIG_RegisterMapping_t
)(char*, char*, void *(*cast
)(void *));
234 typedef void (*p_SWIG_addvarlink_t
)(PyObject
*, char*, PyObject
*(*get_attr
)(void), int (*set_attr
)(PyObject
*p
));
235 typedef PyObject
* (*p_SWIG_newvarlink_t
)(void);
240 p_SWIG_MakePtr_t p_SWIG_MakePtr
;
241 p_SWIG_GetPtr_t p_SWIG_GetPtr
;
242 p_SWIG_GetPtrObj_t p_SWIG_GetPtrObj
;
243 p_SWIG_RegisterMapping_t p_SWIG_RegisterMapping
;
244 p_SWIG_addvarlink_t p_SWIG_addvarlink
;
245 p_SWIG_newvarlink_t p_SWIG_newvarlink
;
247 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
248 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
249 void (*p_wxPyBeginBlockThreads
)();
250 void (*p_wxPyEndBlockThreads
)();
252 PyObject
* (*p_wxPyConstructObject
)(void *, const wxString
&, int);
253 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
, const char* className
);
255 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
256 wxString (*p_Py2wxString
)(PyObject
* source
);
257 PyObject
* (*p_wx2PyString
)(const wxString
& src
);
259 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
260 int* (*p_int_LIST_helper
)(PyObject
* source
);
261 long* (*p_long_LIST_helper
)(PyObject
* source
);
262 char** (*p_string_LIST_helper
)(PyObject
* source
);
263 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
264 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
265 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
266 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
268 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
269 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
270 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
271 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
272 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
274 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
275 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
);
276 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
277 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
278 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
280 PyObject
* (*p_wxPyClassExists
)(const wxString
& className
);
281 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool checkEvtHandler
);
282 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
);
283 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
284 PyObject
* (*p_wxArrayString2PyList_helper
)(const wxArrayString
& arr
);
285 PyObject
* (*p_wxArrayInt2PyList_helper
)(const wxArrayInt
& arr
);
287 void (*p_wxPyClientData_dtor
)(wxPyClientData
*);
288 void (*p_wxPyUserData_dtor
)(wxPyUserData
*);
289 void (*p_wxPyOORClientData_dtor
)(wxPyOORClientData
*);
291 wxPyCBInputStream
* (*p_wxPyCBInputStream_create
)(PyObject
*py
, bool block
);
295 #ifdef wxPyUSE_EXPORT
296 // Notice that this is static, not extern. This is by design, each module
297 // needs one, but doesn't have to use it.
298 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
;
302 //---------------------------------------------------------------------------
305 class wxPyUserData
: public wxObject
{
307 wxPyUserData(PyObject
* obj
) {
313 #ifdef wxPyUSE_EXPORT
314 wxPyCoreAPIPtr
->p_wxPyUserData_dtor(this);
316 wxPyUserData_dtor(this);
323 class wxPyClientData
: public wxClientData
{
325 wxPyClientData(PyObject
* obj
) {
331 #ifdef wxPyUSE_EXPORT
332 wxPyCoreAPIPtr
->p_wxPyClientData_dtor(this);
334 wxPyClientData_dtor(this);
341 class wxPyOORClientData
: public wxPyClientData
{
343 wxPyOORClientData(PyObject
* obj
)
344 : wxPyClientData(obj
) {}
346 ~wxPyOORClientData() {
347 #ifdef wxPyUSE_EXPORT
348 wxPyCoreAPIPtr
->p_wxPyOORClientData_dtor(this);
350 wxPyOORClientData_dtor(this);
355 //---------------------------------------------------------------------------
356 // This class holds an instance of a Python Shadow Class object and assists
357 // with looking up and invoking Python callback methods from C++ virtual
358 // method redirections. For all classes which have virtuals which should be
359 // overridable in wxPython, a new subclass is created that contains a
360 // wxPyCallbackHelper.
363 class wxPyCallbackHelper
{
365 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
367 wxPyCallbackHelper() {
374 ~wxPyCallbackHelper() {
375 #ifdef wxPyUSE_EXPORT
376 wxPyCoreAPIPtr
->p_wxPyCBH_delete(this);
378 wxPyCBH_delete(this);
382 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=TRUE
);
383 bool findCallback(const char* name
) const;
384 int callCallback(PyObject
* argTuple
) const;
385 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
390 PyObject
* m_lastFound
;
393 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
397 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
398 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
);
399 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
400 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
401 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
406 //---------------------------------------------------------------------------
407 // These macros are used to implement the virtual methods that should
408 // redirect to a Python method if one exists. The names designate the
409 // return type, if any, as well as any parameter types.
410 //---------------------------------------------------------------------------
413 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
414 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
416 private: wxPyCallbackHelper m_myInst
418 //---------------------------------------------------------------------------
420 #define DEC_PYCALLBACK__(CBNAME) \
422 void base_##CBNAME();
425 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
426 void CLASS::CBNAME() { \
428 wxPyBeginBlockThreads(); \
429 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
430 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
431 wxPyEndBlockThreads(); \
435 void CLASS::base_##CBNAME() { \
439 //---------------------------------------------------------------------------
441 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
442 bool CBNAME(int a, int b); \
443 bool base_##CBNAME(int a, int b);
446 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
447 bool CLASS::CBNAME(int a, int b) { \
448 bool rval=FALSE, found; \
449 wxPyBeginBlockThreads(); \
450 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
451 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
452 wxPyEndBlockThreads(); \
454 rval = PCLASS::CBNAME(a,b); \
457 bool CLASS::base_##CBNAME(int a, int b) { \
458 return PCLASS::CBNAME(a,b); \
461 //---------------------------------------------------------------------------
463 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
464 void CBNAME(int a, int b); \
465 void base_##CBNAME(int a, int b);
468 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
469 void CLASS::CBNAME(int a, int b) { \
471 wxPyBeginBlockThreads(); \
472 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
473 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
474 wxPyEndBlockThreads(); \
476 PCLASS::CBNAME(a,b); \
478 void CLASS::base_##CBNAME(int a, int b) { \
479 PCLASS::CBNAME(a,b); \
482 //---------------------------------------------------------------------------
484 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
485 void CBNAME(int a, int b, int c, int d); \
486 void base_##CBNAME(int a, int b, int c, int d);
489 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
490 void CLASS::CBNAME(int a, int b, int c, int d) { \
492 wxPyBeginBlockThreads(); \
493 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
494 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
495 wxPyEndBlockThreads(); \
497 PCLASS::CBNAME(a,b,c,d); \
499 void CLASS::base_##CBNAME(int a, int b, int c, int d) { \
500 PCLASS::CBNAME(a,b,c,d); \
503 //---------------------------------------------------------------------------
504 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
505 void CBNAME(int a, int b, int c, int d, int e); \
506 void base_##CBNAME(int a, int b, int c, int d, int e);
509 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
510 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
512 wxPyBeginBlockThreads(); \
513 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
514 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
515 wxPyEndBlockThreads(); \
517 PCLASS::CBNAME(a,b,c,d,e); \
519 void CLASS::base_##CBNAME(int a, int b, int c, int d, int e) { \
520 PCLASS::CBNAME(a,b,c,d,e); \
523 //---------------------------------------------------------------------------
525 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
526 void CBNAME(int* a, int* b) const; \
527 void base_##CBNAME(int* a, int* b) const;
530 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
531 void CLASS::CBNAME(int* a, int* b) const { \
532 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
534 wxPyBeginBlockThreads(); \
535 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
537 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
539 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
540 PyObject* o1 = PySequence_GetItem(ro, 0); \
541 PyObject* o2 = PySequence_GetItem(ro, 1); \
542 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
543 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
546 PyErr_SetString(PyExc_TypeError, errmsg); \
551 PyErr_SetString(PyExc_TypeError, errmsg); \
556 wxPyEndBlockThreads(); \
558 PCLASS::CBNAME(a,b); \
560 void CLASS::base_##CBNAME(int* a, int* b) const { \
561 PCLASS::CBNAME(a,b); \
565 //---------------------------------------------------------------------------
567 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
568 wxSize CBNAME() const; \
569 wxSize base_##CBNAME() const;
572 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
573 wxSize CLASS::CBNAME() const { \
574 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
575 bool found; wxSize rval(0,0); \
576 wxPyBeginBlockThreads(); \
577 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
579 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
581 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
582 PyObject* o1 = PySequence_GetItem(ro, 0); \
583 PyObject* o2 = PySequence_GetItem(ro, 1); \
584 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
585 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
588 PyErr_SetString(PyExc_TypeError, errmsg); \
593 PyErr_SetString(PyExc_TypeError, errmsg); \
598 wxPyEndBlockThreads(); \
600 return PCLASS::CBNAME(); \
604 wxSize CLASS::base_##CBNAME() const { \
605 return PCLASS::CBNAME(); \
609 //---------------------------------------------------------------------------
611 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
612 bool CBNAME(int a); \
613 bool base_##CBNAME(int a);
616 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
617 bool CLASS::CBNAME(int a) { \
618 bool rval=FALSE, found; \
619 wxPyBeginBlockThreads(); \
620 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
621 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
622 wxPyEndBlockThreads(); \
624 rval = PCLASS::CBNAME(a); \
627 bool CLASS::base_##CBNAME(int a) { \
628 return PCLASS::CBNAME(a); \
631 //---------------------------------------------------------------------------
633 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
637 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
638 bool CLASS::CBNAME(int a) { \
640 wxPyBeginBlockThreads(); \
641 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
642 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
644 wxPyEndBlockThreads(); \
649 //---------------------------------------------------------------------------
651 #define DEC_PYCALLBACK__DC(CBNAME) \
652 void CBNAME(wxDC& a); \
653 void base_##CBNAME(wxDC& a);
656 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
657 void CLASS::CBNAME(wxDC& a) { \
659 wxPyBeginBlockThreads(); \
660 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
661 PyObject* obj = wxPyMake_wxObject(&a); \
662 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
665 wxPyEndBlockThreads(); \
669 void CLASS::base_##CBNAME(wxDC& a) { \
675 //---------------------------------------------------------------------------
677 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
678 void CBNAME(wxDC& a, bool b); \
679 void base_##CBNAME(wxDC& a, bool b);
682 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
683 void CLASS::CBNAME(wxDC& a, bool b) { \
685 wxPyBeginBlockThreads(); \
686 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
687 PyObject* obj = wxPyMake_wxObject(&a); \
688 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
691 wxPyEndBlockThreads(); \
693 PCLASS::CBNAME(a, b); \
695 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
696 PCLASS::CBNAME(a, b); \
699 //---------------------------------------------------------------------------
701 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
702 void CBNAME(wxDC& a, bool b); \
703 void base_##CBNAME(wxDC& a, bool b);
706 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
707 void CLASS::CBNAME(wxDC& a, bool b) { \
709 wxPyBeginBlockThreads(); \
710 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
711 PyObject* obj = wxPyMake_wxObject(&a); \
712 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
715 wxPyEndBlockThreads(); \
717 PCLASS::CBNAME(a, b); \
719 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
720 PCLASS::CBNAME(a, b); \
723 //---------------------------------------------------------------------------
725 #define DEC_PYCALLBACK__2DBL(CBNAME) \
726 void CBNAME(double a, double b); \
727 void base_##CBNAME(double a, double b);
730 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
731 void CLASS::CBNAME(double a, double b) { \
733 wxPyBeginBlockThreads(); \
734 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
735 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
736 wxPyEndBlockThreads(); \
738 PCLASS::CBNAME(a, b); \
740 void CLASS::base_##CBNAME(double a, double b) { \
741 PCLASS::CBNAME(a, b); \
744 //---------------------------------------------------------------------------
746 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
747 void CBNAME(double a, double b, int c, int d); \
748 void base_##CBNAME(double a, double b, int c, int d);
751 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
752 void CLASS::CBNAME(double a, double b, int c, int d) { \
754 wxPyBeginBlockThreads(); \
755 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
756 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
758 wxPyEndBlockThreads(); \
760 PCLASS::CBNAME(a, b, c, d); \
762 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
763 PCLASS::CBNAME(a, b, c, d); \
766 //---------------------------------------------------------------------------
768 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
769 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
770 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
773 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
774 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
776 wxPyBeginBlockThreads(); \
777 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
778 PyObject* obj = wxPyMake_wxObject(&a); \
779 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
782 wxPyEndBlockThreads(); \
784 PCLASS::CBNAME(a, b, c, d, e, f); \
786 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
787 PCLASS::CBNAME(a, b, c, d, e, f); \
790 //---------------------------------------------------------------------------
792 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
793 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
794 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
797 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
798 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
800 wxPyBeginBlockThreads(); \
802 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
803 PyObject* obj = wxPyMake_wxObject(&a); \
804 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
807 wxPyEndBlockThreads(); \
809 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
812 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
813 return PCLASS::CBNAME(a, b, c, d, e, f); \
816 //---------------------------------------------------------------------------
818 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
819 void CBNAME(bool a, double b, double c, int d, int e); \
820 void base_##CBNAME(bool a, double b, double c, int d, int e);
823 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
824 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
826 wxPyBeginBlockThreads(); \
827 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
828 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
830 wxPyEndBlockThreads(); \
832 PCLASS::CBNAME(a, b, c, d, e); \
834 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
835 PCLASS::CBNAME(a, b, c, d, e); \
838 //---------------------------------------------------------------------------
840 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
841 void CBNAME(wxDC& a, double b, double c, double d, double e); \
842 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
845 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
846 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
848 wxPyBeginBlockThreads(); \
849 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
850 PyObject* obj = wxPyMake_wxObject(&a); \
851 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
854 wxPyEndBlockThreads(); \
856 PCLASS::CBNAME(a, b, c, d, e); \
858 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
859 PCLASS::CBNAME(a, b, c, d, e); \
862 //---------------------------------------------------------------------------
864 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
865 void CBNAME(wxDC& a, bool b); \
866 void base_##CBNAME(wxDC& a, bool b);
869 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
870 void CLASS::CBNAME(wxDC& a, bool b) { \
872 wxPyBeginBlockThreads(); \
873 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
874 PyObject* obj = wxPyMake_wxObject(&a); \
875 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
878 wxPyEndBlockThreads(); \
880 PCLASS::CBNAME(a, b); \
882 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
883 PCLASS::CBNAME(a, b); \
886 //---------------------------------------------------------------------------
888 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
889 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
890 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
893 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
894 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
897 wxPyBeginBlockThreads(); \
898 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
899 PyObject* obj = wxPyMake_wxObject(a); \
900 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
903 wxPyEndBlockThreads(); \
905 PCLASS::CBNAME(a, b, c, d, e, f); \
907 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
909 PCLASS::CBNAME(a, b, c, d, e, f); \
912 //---------------------------------------------------------------------------
914 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
915 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
916 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
919 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
920 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
922 wxPyBeginBlockThreads(); \
923 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
924 PyObject* obj = wxPyMake_wxObject(a); \
925 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
928 wxPyEndBlockThreads(); \
930 PCLASS::CBNAME(a, b, c, d, e); \
932 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
934 PCLASS::CBNAME(a, b, c, d, e); \
937 //---------------------------------------------------------------------------
939 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
940 void CBNAME(double a, double b, int c); \
941 void base_##CBNAME(double a, double b, int c);
944 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
945 void CLASS::CBNAME(double a, double b, int c) { \
947 wxPyBeginBlockThreads(); \
948 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
949 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
950 wxPyEndBlockThreads(); \
952 PCLASS::CBNAME(a, b, c); \
954 void CLASS::base_##CBNAME(double a, double b, int c) { \
955 PCLASS::CBNAME(a, b, c); \
958 //---------------------------------------------------------------------------
960 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
961 void CBNAME(bool a, double b, double c, int d); \
962 void base_##CBNAME(bool a, double b, double c, int d);
965 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
966 void CLASS::CBNAME(bool a, double b, double c, int d) { \
968 wxPyBeginBlockThreads(); \
969 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
970 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
971 wxPyEndBlockThreads(); \
973 PCLASS::CBNAME(a, b, c, d); \
975 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
976 PCLASS::CBNAME(a, b, c, d); \
979 //---------------------------------------------------------------------------
980 //---------------------------------------------------------------------------
982 #define DEC_PYCALLBACK__STRING(CBNAME) \
983 void CBNAME(const wxString& a); \
984 void base_##CBNAME(const wxString& a);
986 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
987 void CLASS::CBNAME(const wxString& a) { \
989 wxPyBeginBlockThreads(); \
990 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
991 PyObject* s = wx2PyString(a); \
992 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
995 wxPyEndBlockThreads(); \
999 void CLASS::base_##CBNAME(const wxString& a) { \
1000 PCLASS::CBNAME(a); \
1003 //---------------------------------------------------------------------------
1005 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1006 bool CBNAME(const wxString& a); \
1007 bool base_##CBNAME(const wxString& a);
1009 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1010 bool CLASS::CBNAME(const wxString& a) { \
1013 wxPyBeginBlockThreads(); \
1014 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1015 PyObject* s = wx2PyString(a); \
1016 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1019 wxPyEndBlockThreads(); \
1021 rval = PCLASS::CBNAME(a); \
1024 bool CLASS::base_##CBNAME(const wxString& a) { \
1025 return PCLASS::CBNAME(a); \
1028 //---------------------------------------------------------------------------
1030 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1031 bool CBNAME(const wxString& a);
1033 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1034 bool CLASS::CBNAME(const wxString& a) { \
1036 wxPyBeginBlockThreads(); \
1037 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1038 PyObject* s = wx2PyString(a); \
1039 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1042 wxPyEndBlockThreads(); \
1046 //---------------------------------------------------------------------------
1048 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1049 wxString CBNAME(const wxString& a); \
1051 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1052 wxString CLASS::CBNAME(const wxString& a) { \
1054 wxPyBeginBlockThreads(); \
1055 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1057 PyObject* s = wx2PyString(a); \
1058 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1061 rval = Py2wxString(ro); \
1065 wxPyEndBlockThreads(); \
1069 //---------------------------------------------------------------------------
1071 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1072 wxString CBNAME(const wxString& a); \
1073 wxString base_##CBNAME(const wxString& a);
1075 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1076 wxString CLASS::CBNAME(const wxString& a) { \
1079 wxPyBeginBlockThreads(); \
1080 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1082 PyObject* s = wx2PyString(a); \
1083 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1086 rval = Py2wxString(ro); \
1091 rval = PCLASS::CBNAME(a); \
1092 wxPyEndBlockThreads(); \
1096 //---------------------------------------------------------------------------
1098 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1099 wxString CBNAME(const wxString& a,int b); \
1101 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1102 wxString CLASS::CBNAME(const wxString& a,int b) { \
1104 wxPyBeginBlockThreads(); \
1105 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1107 PyObject* s = wx2PyString(a); \
1108 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1111 rval = Py2wxString(ro); \
1115 wxPyEndBlockThreads(); \
1119 //---------------------------------------------------------------------------
1121 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1122 bool CBNAME(const wxString& a, const wxString& b); \
1123 bool base_##CBNAME(const wxString& a, const wxString& b);
1125 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1126 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1129 wxPyBeginBlockThreads(); \
1130 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1131 PyObject* s1 = wx2PyString(a); \
1132 PyObject* s2 = wx2PyString(b); \
1133 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1137 wxPyEndBlockThreads(); \
1139 rval = PCLASS::CBNAME(a, b); \
1142 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
1143 return PCLASS::CBNAME(a, b); \
1146 //---------------------------------------------------------------------------
1148 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1149 wxString CBNAME(); \
1150 wxString base_##CBNAME();
1152 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1153 wxString CLASS::CBNAME() { \
1156 wxPyBeginBlockThreads(); \
1157 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1159 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1161 rval = Py2wxString(ro); \
1165 wxPyEndBlockThreads(); \
1167 rval = PCLASS::CBNAME(); \
1170 wxString CLASS::base_##CBNAME() { \
1171 return PCLASS::CBNAME(); \
1174 //---------------------------------------------------------------------------
1176 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1179 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1180 wxString CLASS::CBNAME() { \
1182 wxPyBeginBlockThreads(); \
1183 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1185 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1187 rval = Py2wxString(ro); \
1191 wxPyEndBlockThreads(); \
1195 //---------------------------------------------------------------------------
1197 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1198 bool CBNAME(const wxHtmlTag& a); \
1201 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1202 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1204 wxPyBeginBlockThreads(); \
1205 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1206 PyObject* obj = wxPyConstructObject((void*)&a, "wxHtmlTag", 0); \
1207 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1210 wxPyEndBlockThreads(); \
1214 //---------------------------------------------------------------------------
1216 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1217 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \
1218 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y);
1220 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1221 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1223 wxPyBeginBlockThreads(); \
1224 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1225 PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \
1226 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1229 wxPyEndBlockThreads(); \
1231 PCLASS::CBNAME(cell, x, y); \
1233 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1234 PCLASS::CBNAME(cell, x, y); \
1238 //---------------------------------------------------------------------------
1240 #define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \
1241 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \
1242 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e);
1244 #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \
1245 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1247 wxPyBeginBlockThreads(); \
1248 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1249 PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \
1250 PyObject* o2 = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
1251 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1255 wxPyEndBlockThreads(); \
1257 PCLASS::CBNAME(cell, x, y, e); \
1259 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1260 PCLASS::CBNAME(cell, x, y, e); \
1265 //---------------------------------------------------------------------------
1267 #define DEC_PYCALLBACK___pure(CBNAME) \
1271 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1272 void CLASS::CBNAME() { \
1273 wxPyBeginBlockThreads(); \
1274 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1275 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1276 wxPyEndBlockThreads(); \
1279 //---------------------------------------------------------------------------
1281 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1285 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1286 wxSize CLASS::CBNAME() { \
1287 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1289 wxPyBeginBlockThreads(); \
1290 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1293 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1295 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
1297 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1298 PyObject* o1 = PySequence_GetItem(ro, 0); \
1299 PyObject* o2 = PySequence_GetItem(ro, 1); \
1300 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1301 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1303 PyErr_SetString(PyExc_TypeError, errmsg); \
1308 PyErr_SetString(PyExc_TypeError, errmsg); \
1313 wxPyEndBlockThreads(); \
1317 //---------------------------------------------------------------------------
1319 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1320 bool CBNAME(wxWindow* a); \
1321 bool base_##CBNAME(wxWindow* a);
1324 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1325 bool CLASS::CBNAME(wxWindow* a) { \
1328 wxPyBeginBlockThreads(); \
1329 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1330 PyObject* obj = wxPyMake_wxObject(a); \
1331 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1334 wxPyEndBlockThreads(); \
1336 rval = PCLASS::CBNAME(a); \
1339 bool CLASS::base_##CBNAME(wxWindow* a) { \
1340 return PCLASS::CBNAME(a); \
1343 //---------------------------------------------------------------------------
1345 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1346 void CBNAME(wxWindowBase* a); \
1347 void base_##CBNAME(wxWindowBase* a);
1350 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1351 void CLASS::CBNAME(wxWindowBase* a) { \
1353 wxPyBeginBlockThreads(); \
1354 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1355 PyObject* obj = wxPyMake_wxObject(a); \
1356 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1359 wxPyEndBlockThreads(); \
1361 PCLASS::CBNAME(a); \
1363 void CLASS::base_##CBNAME(wxWindowBase* a) { \
1364 PCLASS::CBNAME(a); \
1367 //---------------------------------------------------------------------------
1369 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1371 bool base_##CBNAME();
1374 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1375 bool CLASS::CBNAME() { \
1378 wxPyBeginBlockThreads(); \
1379 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1380 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1381 wxPyEndBlockThreads(); \
1383 rval = PCLASS::CBNAME(); \
1386 bool CLASS::base_##CBNAME() { \
1387 return PCLASS::CBNAME(); \
1390 //---------------------------------------------------------------------------
1392 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1393 bool CBNAME() const; \
1394 bool base_##CBNAME() const;
1397 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1398 bool CLASS::CBNAME() const { \
1401 wxPyBeginBlockThreads(); \
1402 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1403 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1404 wxPyEndBlockThreads(); \
1406 rval = PCLASS::CBNAME(); \
1409 bool CLASS::base_##CBNAME() const { \
1410 return PCLASS::CBNAME(); \
1413 //---------------------------------------------------------------------------
1415 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1416 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
1417 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1420 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1421 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1424 wxPyBeginBlockThreads(); \
1425 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1426 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1427 wxPyEndBlockThreads(); \
1429 rval = PCLASS::CBNAME(a, b, c); \
1430 return (wxDragResult)rval; \
1432 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1433 return PCLASS::CBNAME(a, b, c); \
1436 //---------------------------------------------------------------------------
1438 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1439 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location); \
1441 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1442 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1443 wxPyBeginBlockThreads(); \
1445 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1447 PyObject* obj = wxPyMake_wxObject(&a); \
1448 PyObject* s = wx2PyString(b); \
1449 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)",\
1452 SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \
1458 wxPyEndBlockThreads(); \
1462 //---------------------------------------------------------------------------
1464 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1465 bool CBNAME(wxDragResult a); \
1466 bool base_##CBNAME(wxDragResult a);
1469 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1470 bool CLASS::CBNAME(wxDragResult a) { \
1473 wxPyBeginBlockThreads(); \
1474 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1475 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\
1476 wxPyEndBlockThreads(); \
1478 rval = PCLASS::CBNAME(a); \
1481 bool CLASS::base_##CBNAME(wxDragResult a) { \
1482 return PCLASS::CBNAME(a); \
1485 //---------------------------------------------------------------------------
1487 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1488 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1491 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1492 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1493 wxPyBeginBlockThreads(); \
1495 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1496 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1497 wxPyEndBlockThreads(); \
1498 return (wxDragResult)rval; \
1501 //---------------------------------------------------------------------------
1503 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1504 bool CBNAME(int a, int b, const wxString& c);
1506 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1507 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1509 wxPyBeginBlockThreads(); \
1510 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1511 PyObject* s = wx2PyString(c); \
1512 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1515 wxPyEndBlockThreads(); \
1519 //---------------------------------------------------------------------------
1521 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1523 size_t base_##CBNAME();
1526 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1527 size_t CLASS::CBNAME() { \
1530 wxPyBeginBlockThreads(); \
1531 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1532 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1533 wxPyEndBlockThreads(); \
1535 rval = PCLASS::CBNAME(); \
1538 size_t CLASS::base_##CBNAME() { \
1539 return PCLASS::CBNAME(); \
1542 //---------------------------------------------------------------------------
1544 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1545 wxDataFormat CBNAME(size_t a); \
1546 wxDataFormat base_##CBNAME(size_t a);
1549 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1550 wxDataFormat CLASS::CBNAME(size_t a) { \
1551 wxDataFormat rval=0; \
1553 wxPyBeginBlockThreads(); \
1554 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1556 wxDataFormat* ptr; \
1557 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1559 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
1564 wxPyEndBlockThreads(); \
1566 rval = PCLASS::CBNAME(a); \
1569 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1570 return PCLASS::CBNAME(a); \
1573 //---------------------------------------------------------------------------
1575 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1576 void CBNAME(const Type& a); \
1577 void base_##CBNAME(const Type& a);
1580 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1581 void CLASS::CBNAME(const Type& a) { \
1583 wxPyBeginBlockThreads(); \
1584 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1585 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1586 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1589 wxPyEndBlockThreads(); \
1591 PCLASS::CBNAME(a); \
1593 void CLASS::base_##CBNAME(const Type& a) { \
1594 PCLASS::CBNAME(a); \
1598 //---------------------------------------------------------------------------
1600 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1601 void CBNAME(Type& a); \
1602 void base_##CBNAME(Type& a);
1605 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1606 void CLASS::CBNAME(Type& a) { \
1608 wxPyBeginBlockThreads(); \
1609 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1610 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1611 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1614 wxPyEndBlockThreads(); \
1616 PCLASS::CBNAME(a); \
1618 void CLASS::base_##CBNAME(Type& a) { \
1619 PCLASS::CBNAME(a); \
1622 //---------------------------------------------------------------------------
1624 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1625 bool CBNAME(Type& a); \
1626 bool base_##CBNAME(Type& a);
1629 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1630 bool CLASS::CBNAME(Type& a) { \
1633 wxPyBeginBlockThreads(); \
1634 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1635 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1636 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1639 wxPyEndBlockThreads(); \
1641 rv = PCLASS::CBNAME(a); \
1644 bool CLASS::base_##CBNAME(Type& a) { \
1645 return PCLASS::CBNAME(a); \
1648 //---------------------------------------------------------------------------
1650 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
1651 bool CBNAME(Type& a);
1654 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
1655 bool CLASS::CBNAME(Type& a) { \
1657 wxPyBeginBlockThreads(); \
1658 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1659 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1660 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1663 wxPyEndBlockThreads(); \
1667 //---------------------------------------------------------------------------
1669 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1670 wxString CBNAME(long a, long b) const; \
1671 wxString base_##CBNAME(long a, long b)const ;
1673 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1674 wxString CLASS::CBNAME(long a, long b) const { \
1677 wxPyBeginBlockThreads(); \
1678 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1680 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1682 rval = Py2wxString(ro); \
1686 wxPyEndBlockThreads(); \
1688 rval = PCLASS::CBNAME(a,b); \
1691 wxString CLASS::base_##CBNAME(long a, long b) const { \
1692 return PCLASS::CBNAME(a,b); \
1695 //---------------------------------------------------------------------------
1697 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1698 int CBNAME(long a) const; \
1699 int base_##CBNAME(long a)const ;
1702 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1703 int CLASS::CBNAME(long a) const { \
1706 wxPyBeginBlockThreads(); \
1707 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1709 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1711 rval = PyInt_AsLong(ro); \
1715 wxPyEndBlockThreads(); \
1717 rval = PCLASS::CBNAME(a); \
1720 int CLASS::base_##CBNAME(long a) const { \
1721 return PCLASS::CBNAME(a); \
1725 //---------------------------------------------------------------------------
1727 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
1728 wxListItemAttr* CBNAME(long a) const; \
1729 wxListItemAttr* base_##CBNAME(long a);
1732 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
1733 wxListItemAttr *CLASS::CBNAME(long a) const { \
1734 wxListItemAttr *rval = NULL; \
1736 wxPyBeginBlockThreads(); \
1737 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1739 wxListItemAttr* ptr; \
1740 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1742 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxListItemAttr_p")) \
1747 wxPyEndBlockThreads(); \
1749 rval = PCLASS::CBNAME(a); \
1752 wxListItemAttr *CLASS::base_##CBNAME(long a) { \
1753 return PCLASS::CBNAME(a); \
1756 //---------------------------------------------------------------------------
1758 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
1759 bool CBNAME(wxMouseEvent& e); \
1760 bool base_##CBNAME(wxMouseEvent& e);
1762 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
1763 bool CLASS::CBNAME(wxMouseEvent& e) { \
1766 wxPyBeginBlockThreads(); \
1767 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1769 PyObject* obj = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
1770 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1772 rval = PyInt_AsLong(ro); \
1777 wxPyEndBlockThreads(); \
1779 return PCLASS::CBNAME(e); \
1782 bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
1783 return PCLASS::CBNAME(e); \
1787 //---------------------------------------------------------------------------
1789 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
1790 wxWizardPage* CBNAME() const;
1792 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
1793 wxWizardPage* CLASS::CBNAME() const { \
1794 wxWizardPage* rv = NULL; \
1795 wxPyBeginBlockThreads(); \
1796 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1798 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1800 SWIG_GetPtrObj(ro, (void **)&rv, "_wxWizardPage_p"); \
1804 wxPyEndBlockThreads(); \
1808 //---------------------------------------------------------------------------
1810 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
1811 wxBitmap CBNAME() const;
1813 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
1814 wxBitmap CLASS::CBNAME() const { \
1816 wxPyBeginBlockThreads(); \
1817 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1820 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1822 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxBitmap_p")) \
1827 wxPyEndBlockThreads(); \
1831 //---------------------------------------------------------------------------
1833 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
1836 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
1837 wxObject* CLASS::CBNAME() { \
1838 wxObject* rv = NULL; \
1839 wxPyBeginBlockThreads(); \
1840 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1842 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1844 SWIG_GetPtrObj(ro, (void **)&rv, "_wxObject_p"); \
1848 wxPyEndBlockThreads(); \
1852 //---------------------------------------------------------------------------
1854 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
1855 bool CBNAME(wxXmlNode* a);
1858 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
1859 bool CLASS::CBNAME(wxXmlNode* a) { \
1861 wxPyBeginBlockThreads(); \
1862 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1863 PyObject* obj = wxPyConstructObject((void*)a, "wxXmlNode", 0); \
1864 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1867 wxPyEndBlockThreads(); \
1871 //---------------------------------------------------------------------------