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
;
228 void (*p_SWIG_MakePtr
)(char*, void*, char*);
229 char* (*p_SWIG_GetPtr
)(char*, void**, char*);
230 char* (*p_SWIG_GetPtrObj
)(PyObject
*, void**, char*);
231 void (*p_SWIG_RegisterMapping
)(char*, char*, void *(*cast
)(void *));
232 void (*p_SWIG_addvarlink
)(PyObject
*, char*, PyObject
*(*get_attr
)(void), int (*set_attr
)(PyObject
*p
));
233 PyObject
* (*p_SWIG_newvarlink
)(void);
235 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
236 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
237 void (*p_wxPyBeginBlockThreads
)();
238 void (*p_wxPyEndBlockThreads
)();
240 PyObject
* (*p_wxPyConstructObject
)(void *, const wxString
&, int);
241 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
, const char* className
);
243 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
244 wxString (*p_Py2wxString
)(PyObject
* source
);
245 PyObject
* (*p_wx2PyString
)(const wxString
& src
);
247 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
248 int* (*p_int_LIST_helper
)(PyObject
* source
);
249 long* (*p_long_LIST_helper
)(PyObject
* source
);
250 char** (*p_string_LIST_helper
)(PyObject
* source
);
251 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
252 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
253 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
254 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
256 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
257 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
258 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
259 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
260 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
262 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
263 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
);
264 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
265 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
266 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
268 PyObject
* (*p_wxPyClassExists
)(const wxString
& className
);
269 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool checkEvtHandler
);
270 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
);
271 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
272 PyObject
* (*p_wxArrayString2PyList_helper
)(const wxArrayString
& arr
);
273 PyObject
* (*p_wxArrayInt2PyList_helper
)(const wxArrayInt
& arr
);
275 void (*p_wxPyClientData_dtor
)(wxPyClientData
*);
276 void (*p_wxPyUserData_dtor
)(wxPyUserData
*);
277 void (*p_wxPyOORClientData_dtor
)(wxPyOORClientData
*);
280 #ifdef wxPyUSE_EXPORT
281 // Notice that this is static, not extern. This is by design, each module
282 // needs one, but doesn't have to use it.
283 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
;
287 //---------------------------------------------------------------------------
290 class wxPyUserData
: public wxObject
{
292 wxPyUserData(PyObject
* obj
) {
298 #ifdef wxPyUSE_EXPORT
299 wxPyCoreAPIPtr
->p_wxPyUserData_dtor(this);
301 wxPyUserData_dtor(this);
308 class wxPyClientData
: public wxClientData
{
310 wxPyClientData(PyObject
* obj
) {
316 #ifdef wxPyUSE_EXPORT
317 wxPyCoreAPIPtr
->p_wxPyClientData_dtor(this);
319 wxPyClientData_dtor(this);
326 class wxPyOORClientData
: public wxPyClientData
{
328 wxPyOORClientData(PyObject
* obj
)
329 : wxPyClientData(obj
) {}
331 ~wxPyOORClientData() {
332 #ifdef wxPyUSE_EXPORT
333 wxPyCoreAPIPtr
->p_wxPyOORClientData_dtor(this);
335 wxPyOORClientData_dtor(this);
340 //---------------------------------------------------------------------------
341 // This class holds an instance of a Python Shadow Class object and assists
342 // with looking up and invoking Python callback methods from C++ virtual
343 // method redirections. For all classes which have virtuals which should be
344 // overridable in wxPython, a new subclass is created that contains a
345 // wxPyCallbackHelper.
348 class wxPyCallbackHelper
{
350 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
352 wxPyCallbackHelper() {
359 ~wxPyCallbackHelper() {
360 #ifdef wxPyUSE_EXPORT
361 wxPyCoreAPIPtr
->p_wxPyCBH_delete(this);
363 wxPyCBH_delete(this);
367 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=TRUE
);
368 bool findCallback(const char* name
) const;
369 int callCallback(PyObject
* argTuple
) const;
370 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
375 PyObject
* m_lastFound
;
378 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
382 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
383 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
);
384 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
385 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
386 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
391 //---------------------------------------------------------------------------
392 // These macros are used to implement the virtual methods that should
393 // redirect to a Python method if one exists. The names designate the
394 // return type, if any, as well as any parameter types.
395 //---------------------------------------------------------------------------
398 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
399 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
401 private: wxPyCallbackHelper m_myInst
403 //---------------------------------------------------------------------------
405 #define DEC_PYCALLBACK__(CBNAME) \
407 void base_##CBNAME();
410 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
411 void CLASS::CBNAME() { \
413 wxPyBeginBlockThreads(); \
414 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
415 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
416 wxPyEndBlockThreads(); \
420 void CLASS::base_##CBNAME() { \
424 //---------------------------------------------------------------------------
426 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
427 bool CBNAME(int a, int b); \
428 bool base_##CBNAME(int a, int b);
431 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
432 bool CLASS::CBNAME(int a, int b) { \
433 bool rval=FALSE, found; \
434 wxPyBeginBlockThreads(); \
435 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
436 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
437 wxPyEndBlockThreads(); \
439 rval = PCLASS::CBNAME(a,b); \
442 bool CLASS::base_##CBNAME(int a, int b) { \
443 return PCLASS::CBNAME(a,b); \
446 //---------------------------------------------------------------------------
448 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
449 void CBNAME(int a, int b); \
450 void base_##CBNAME(int a, int b);
453 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
454 void CLASS::CBNAME(int a, int b) { \
456 wxPyBeginBlockThreads(); \
457 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
458 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
459 wxPyEndBlockThreads(); \
461 PCLASS::CBNAME(a,b); \
463 void CLASS::base_##CBNAME(int a, int b) { \
464 PCLASS::CBNAME(a,b); \
467 //---------------------------------------------------------------------------
469 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
470 void CBNAME(int a, int b, int c, int d); \
471 void base_##CBNAME(int a, int b, int c, int d);
474 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
475 void CLASS::CBNAME(int a, int b, int c, int d) { \
477 wxPyBeginBlockThreads(); \
478 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
479 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
480 wxPyEndBlockThreads(); \
482 PCLASS::CBNAME(a,b,c,d); \
484 void CLASS::base_##CBNAME(int a, int b, int c, int d) { \
485 PCLASS::CBNAME(a,b,c,d); \
488 //---------------------------------------------------------------------------
489 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
490 void CBNAME(int a, int b, int c, int d, int e); \
491 void base_##CBNAME(int a, int b, int c, int d, int e);
494 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
495 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
497 wxPyBeginBlockThreads(); \
498 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
499 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
500 wxPyEndBlockThreads(); \
502 PCLASS::CBNAME(a,b,c,d,e); \
504 void CLASS::base_##CBNAME(int a, int b, int c, int d, int e) { \
505 PCLASS::CBNAME(a,b,c,d,e); \
508 //---------------------------------------------------------------------------
510 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
511 void CBNAME(int* a, int* b) const; \
512 void base_##CBNAME(int* a, int* b) const;
515 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
516 void CLASS::CBNAME(int* a, int* b) const { \
517 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
519 wxPyBeginBlockThreads(); \
520 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
522 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
524 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
525 PyObject* o1 = PySequence_GetItem(ro, 0); \
526 PyObject* o2 = PySequence_GetItem(ro, 1); \
527 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
528 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
531 PyErr_SetString(PyExc_TypeError, errmsg); \
536 PyErr_SetString(PyExc_TypeError, errmsg); \
541 wxPyEndBlockThreads(); \
543 PCLASS::CBNAME(a,b); \
545 void CLASS::base_##CBNAME(int* a, int* b) const { \
546 PCLASS::CBNAME(a,b); \
550 //---------------------------------------------------------------------------
552 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
553 wxSize CBNAME() const; \
554 wxSize base_##CBNAME() const;
557 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
558 wxSize CLASS::CBNAME() const { \
559 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
560 bool found; wxSize rval(0,0); \
561 wxPyBeginBlockThreads(); \
562 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
564 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
566 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
567 PyObject* o1 = PySequence_GetItem(ro, 0); \
568 PyObject* o2 = PySequence_GetItem(ro, 1); \
569 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
570 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
573 PyErr_SetString(PyExc_TypeError, errmsg); \
578 PyErr_SetString(PyExc_TypeError, errmsg); \
583 wxPyEndBlockThreads(); \
585 return PCLASS::CBNAME(); \
589 wxSize CLASS::base_##CBNAME() const { \
590 return PCLASS::CBNAME(); \
594 //---------------------------------------------------------------------------
596 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
597 bool CBNAME(int a); \
598 bool base_##CBNAME(int a);
601 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
602 bool CLASS::CBNAME(int a) { \
603 bool rval=FALSE, found; \
604 wxPyBeginBlockThreads(); \
605 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
606 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
607 wxPyEndBlockThreads(); \
609 rval = PCLASS::CBNAME(a); \
612 bool CLASS::base_##CBNAME(int a) { \
613 return PCLASS::CBNAME(a); \
616 //---------------------------------------------------------------------------
618 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
622 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
623 bool CLASS::CBNAME(int a) { \
625 wxPyBeginBlockThreads(); \
626 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
627 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
629 wxPyEndBlockThreads(); \
634 //---------------------------------------------------------------------------
636 #define DEC_PYCALLBACK__DC(CBNAME) \
637 void CBNAME(wxDC& a); \
638 void base_##CBNAME(wxDC& a);
641 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
642 void CLASS::CBNAME(wxDC& a) { \
644 wxPyBeginBlockThreads(); \
645 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
646 PyObject* obj = wxPyMake_wxObject(&a); \
647 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
650 wxPyEndBlockThreads(); \
654 void CLASS::base_##CBNAME(wxDC& a) { \
660 //---------------------------------------------------------------------------
662 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
663 void CBNAME(wxDC& a, bool b); \
664 void base_##CBNAME(wxDC& a, bool b);
667 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
668 void CLASS::CBNAME(wxDC& a, bool b) { \
670 wxPyBeginBlockThreads(); \
671 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
672 PyObject* obj = wxPyMake_wxObject(&a); \
673 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
676 wxPyEndBlockThreads(); \
678 PCLASS::CBNAME(a, b); \
680 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
681 PCLASS::CBNAME(a, b); \
684 //---------------------------------------------------------------------------
686 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
687 void CBNAME(wxDC& a, bool b); \
688 void base_##CBNAME(wxDC& a, bool b);
691 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
692 void CLASS::CBNAME(wxDC& a, bool b) { \
694 wxPyBeginBlockThreads(); \
695 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
696 PyObject* obj = wxPyMake_wxObject(&a); \
697 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
700 wxPyEndBlockThreads(); \
702 PCLASS::CBNAME(a, b); \
704 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
705 PCLASS::CBNAME(a, b); \
708 //---------------------------------------------------------------------------
710 #define DEC_PYCALLBACK__2DBL(CBNAME) \
711 void CBNAME(double a, double b); \
712 void base_##CBNAME(double a, double b);
715 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
716 void CLASS::CBNAME(double a, double b) { \
718 wxPyBeginBlockThreads(); \
719 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
720 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
721 wxPyEndBlockThreads(); \
723 PCLASS::CBNAME(a, b); \
725 void CLASS::base_##CBNAME(double a, double b) { \
726 PCLASS::CBNAME(a, b); \
729 //---------------------------------------------------------------------------
731 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
732 void CBNAME(double a, double b, int c, int d); \
733 void base_##CBNAME(double a, double b, int c, int d);
736 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
737 void CLASS::CBNAME(double a, double b, int c, int d) { \
739 wxPyBeginBlockThreads(); \
740 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
741 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
743 wxPyEndBlockThreads(); \
745 PCLASS::CBNAME(a, b, c, d); \
747 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
748 PCLASS::CBNAME(a, b, c, d); \
751 //---------------------------------------------------------------------------
753 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
754 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
755 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
758 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
759 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
761 wxPyBeginBlockThreads(); \
762 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
763 PyObject* obj = wxPyMake_wxObject(&a); \
764 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
767 wxPyEndBlockThreads(); \
769 PCLASS::CBNAME(a, b, c, d, e, f); \
771 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
772 PCLASS::CBNAME(a, b, c, d, e, f); \
775 //---------------------------------------------------------------------------
777 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
778 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
779 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
782 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
783 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
785 wxPyBeginBlockThreads(); \
787 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
788 PyObject* obj = wxPyMake_wxObject(&a); \
789 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
792 wxPyEndBlockThreads(); \
794 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
797 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
798 return PCLASS::CBNAME(a, b, c, d, e, f); \
801 //---------------------------------------------------------------------------
803 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
804 void CBNAME(bool a, double b, double c, int d, int e); \
805 void base_##CBNAME(bool a, double b, double c, int d, int e);
808 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
809 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
811 wxPyBeginBlockThreads(); \
812 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
813 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
815 wxPyEndBlockThreads(); \
817 PCLASS::CBNAME(a, b, c, d, e); \
819 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
820 PCLASS::CBNAME(a, b, c, d, e); \
823 //---------------------------------------------------------------------------
825 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
826 void CBNAME(wxDC& a, double b, double c, double d, double e); \
827 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
830 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
831 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
833 wxPyBeginBlockThreads(); \
834 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
835 PyObject* obj = wxPyMake_wxObject(&a); \
836 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
839 wxPyEndBlockThreads(); \
841 PCLASS::CBNAME(a, b, c, d, e); \
843 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
844 PCLASS::CBNAME(a, b, c, d, e); \
847 //---------------------------------------------------------------------------
849 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
850 void CBNAME(wxDC& a, bool b); \
851 void base_##CBNAME(wxDC& a, bool b);
854 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
855 void CLASS::CBNAME(wxDC& a, bool b) { \
857 wxPyBeginBlockThreads(); \
858 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
859 PyObject* obj = wxPyMake_wxObject(&a); \
860 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
863 wxPyEndBlockThreads(); \
865 PCLASS::CBNAME(a, b); \
867 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
868 PCLASS::CBNAME(a, b); \
871 //---------------------------------------------------------------------------
873 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
874 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
875 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
878 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
879 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
882 wxPyBeginBlockThreads(); \
883 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
884 PyObject* obj = wxPyMake_wxObject(a); \
885 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
888 wxPyEndBlockThreads(); \
890 PCLASS::CBNAME(a, b, c, d, e, f); \
892 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
894 PCLASS::CBNAME(a, b, c, d, e, f); \
897 //---------------------------------------------------------------------------
899 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
900 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
901 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
904 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
905 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
907 wxPyBeginBlockThreads(); \
908 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
909 PyObject* obj = wxPyMake_wxObject(a); \
910 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
913 wxPyEndBlockThreads(); \
915 PCLASS::CBNAME(a, b, c, d, e); \
917 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
919 PCLASS::CBNAME(a, b, c, d, e); \
922 //---------------------------------------------------------------------------
924 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
925 void CBNAME(double a, double b, int c); \
926 void base_##CBNAME(double a, double b, int c);
929 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
930 void CLASS::CBNAME(double a, double b, int c) { \
932 wxPyBeginBlockThreads(); \
933 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
934 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
935 wxPyEndBlockThreads(); \
937 PCLASS::CBNAME(a, b, c); \
939 void CLASS::base_##CBNAME(double a, double b, int c) { \
940 PCLASS::CBNAME(a, b, c); \
943 //---------------------------------------------------------------------------
945 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
946 void CBNAME(bool a, double b, double c, int d); \
947 void base_##CBNAME(bool a, double b, double c, int d);
950 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
951 void CLASS::CBNAME(bool a, double b, double c, int d) { \
953 wxPyBeginBlockThreads(); \
954 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
955 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
956 wxPyEndBlockThreads(); \
958 PCLASS::CBNAME(a, b, c, d); \
960 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
961 PCLASS::CBNAME(a, b, c, d); \
964 //---------------------------------------------------------------------------
965 //---------------------------------------------------------------------------
967 #define DEC_PYCALLBACK__STRING(CBNAME) \
968 void CBNAME(const wxString& a); \
969 void base_##CBNAME(const wxString& a);
971 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
972 void CLASS::CBNAME(const wxString& a) { \
974 wxPyBeginBlockThreads(); \
975 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
976 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", wx2PyString(a))); \
977 wxPyEndBlockThreads(); \
981 void CLASS::base_##CBNAME(const wxString& a) { \
985 //---------------------------------------------------------------------------
987 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
988 bool CBNAME(const wxString& a); \
989 bool base_##CBNAME(const wxString& a);
991 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
992 bool CLASS::CBNAME(const wxString& a) { \
995 wxPyBeginBlockThreads(); \
996 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
997 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", wx2PyString(a)));\
998 wxPyEndBlockThreads(); \
1000 rval = PCLASS::CBNAME(a); \
1003 bool CLASS::base_##CBNAME(const wxString& a) { \
1004 return PCLASS::CBNAME(a); \
1007 //---------------------------------------------------------------------------
1009 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1010 bool CBNAME(const wxString& a);
1012 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1013 bool CLASS::CBNAME(const wxString& a) { \
1015 wxPyBeginBlockThreads(); \
1016 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1017 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", wx2PyString(a))); \
1018 wxPyEndBlockThreads(); \
1022 //---------------------------------------------------------------------------
1024 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1025 wxString CBNAME(const wxString& a); \
1027 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1028 wxString CLASS::CBNAME(const wxString& a) { \
1030 wxPyBeginBlockThreads(); \
1031 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1033 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", wx2PyString(a)));\
1035 rval = Py2wxString(ro); \
1039 wxPyEndBlockThreads(); \
1043 //---------------------------------------------------------------------------
1045 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1046 wxString CBNAME(const wxString& a,int b); \
1048 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1049 wxString CLASS::CBNAME(const wxString& a,int b) { \
1051 wxPyBeginBlockThreads(); \
1052 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1054 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)", wx2PyString(a),b)); \
1056 rval = Py2wxString(ro); \
1060 wxPyEndBlockThreads(); \
1064 //---------------------------------------------------------------------------
1066 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1067 bool CBNAME(const wxString& a, const wxString& b); \
1068 bool base_##CBNAME(const wxString& a, const wxString& b);
1070 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1071 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1074 wxPyBeginBlockThreads(); \
1075 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1076 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", \
1077 wx2PyString(a), wx2PyString(b))); \
1078 wxPyEndBlockThreads(); \
1080 rval = PCLASS::CBNAME(a, b); \
1083 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
1084 return PCLASS::CBNAME(a, b); \
1087 //---------------------------------------------------------------------------
1089 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1090 wxString CBNAME(); \
1091 wxString base_##CBNAME();
1093 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1094 wxString CLASS::CBNAME() { \
1097 wxPyBeginBlockThreads(); \
1098 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1100 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1102 rval = Py2wxString(ro); \
1106 wxPyEndBlockThreads(); \
1108 rval = PCLASS::CBNAME(); \
1111 wxString CLASS::base_##CBNAME() { \
1112 return PCLASS::CBNAME(); \
1115 //---------------------------------------------------------------------------
1117 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1120 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1121 wxString CLASS::CBNAME() { \
1123 wxPyBeginBlockThreads(); \
1124 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1126 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1128 rval = Py2wxString(ro); \
1132 wxPyEndBlockThreads(); \
1136 //---------------------------------------------------------------------------
1138 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1139 bool CBNAME(const wxHtmlTag& a); \
1142 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1143 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1145 wxPyBeginBlockThreads(); \
1146 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1147 PyObject* obj = wxPyConstructObject((void*)&a, "wxHtmlTag", 0); \
1148 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1151 wxPyEndBlockThreads(); \
1155 //---------------------------------------------------------------------------
1157 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1158 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \
1159 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y);
1161 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1162 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1164 wxPyBeginBlockThreads(); \
1165 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1166 PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \
1167 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1170 wxPyEndBlockThreads(); \
1172 PCLASS::CBNAME(cell, x, y); \
1174 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1175 PCLASS::CBNAME(cell, x, y); \
1179 //---------------------------------------------------------------------------
1181 #define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \
1182 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \
1183 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e);
1185 #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \
1186 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1188 wxPyBeginBlockThreads(); \
1189 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1190 PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \
1191 PyObject* o2 = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
1192 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1196 wxPyEndBlockThreads(); \
1198 PCLASS::CBNAME(cell, x, y, e); \
1200 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1201 PCLASS::CBNAME(cell, x, y, e); \
1206 //---------------------------------------------------------------------------
1208 #define DEC_PYCALLBACK___pure(CBNAME) \
1212 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1213 void CLASS::CBNAME() { \
1214 wxPyBeginBlockThreads(); \
1215 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1216 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1217 wxPyEndBlockThreads(); \
1220 //---------------------------------------------------------------------------
1222 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1226 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1227 wxSize CLASS::CBNAME() { \
1228 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1230 wxPyBeginBlockThreads(); \
1231 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1234 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1236 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
1238 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1239 PyObject* o1 = PySequence_GetItem(ro, 0); \
1240 PyObject* o2 = PySequence_GetItem(ro, 1); \
1241 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1242 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1244 PyErr_SetString(PyExc_TypeError, errmsg); \
1249 PyErr_SetString(PyExc_TypeError, errmsg); \
1254 wxPyEndBlockThreads(); \
1258 //---------------------------------------------------------------------------
1260 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1261 bool CBNAME(wxWindow* a); \
1262 bool base_##CBNAME(wxWindow* a);
1265 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1266 bool CLASS::CBNAME(wxWindow* a) { \
1269 wxPyBeginBlockThreads(); \
1270 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1271 PyObject* obj = wxPyMake_wxObject(a); \
1272 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1275 wxPyEndBlockThreads(); \
1277 rval = PCLASS::CBNAME(a); \
1280 bool CLASS::base_##CBNAME(wxWindow* a) { \
1281 return PCLASS::CBNAME(a); \
1284 //---------------------------------------------------------------------------
1286 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1288 bool base_##CBNAME();
1291 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1292 bool CLASS::CBNAME() { \
1295 wxPyBeginBlockThreads(); \
1296 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1297 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1298 wxPyEndBlockThreads(); \
1300 rval = PCLASS::CBNAME(); \
1303 bool CLASS::base_##CBNAME() { \
1304 return PCLASS::CBNAME(); \
1307 //---------------------------------------------------------------------------
1309 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1310 bool CBNAME() const; \
1311 bool base_##CBNAME() const;
1314 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1315 bool CLASS::CBNAME() const { \
1318 wxPyBeginBlockThreads(); \
1319 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1320 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1321 wxPyEndBlockThreads(); \
1323 rval = PCLASS::CBNAME(); \
1326 bool CLASS::base_##CBNAME() const { \
1327 return PCLASS::CBNAME(); \
1330 //---------------------------------------------------------------------------
1332 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1333 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
1334 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1337 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1338 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1341 wxPyBeginBlockThreads(); \
1342 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1343 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1344 wxPyEndBlockThreads(); \
1346 rval = PCLASS::CBNAME(a, b, c); \
1347 return (wxDragResult)rval; \
1349 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1350 return PCLASS::CBNAME(a, b, c); \
1353 //---------------------------------------------------------------------------
1355 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1356 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location); \
1358 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1359 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1360 wxPyBeginBlockThreads(); \
1362 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1364 PyObject* obj = wxPyMake_wxObject(&a); \
1365 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)",\
1366 obj, wx2PyString(b))); \
1368 SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \
1373 wxPyEndBlockThreads(); \
1377 //---------------------------------------------------------------------------
1379 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1380 bool CBNAME(wxDragResult a); \
1381 bool base_##CBNAME(wxDragResult a);
1384 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1385 bool CLASS::CBNAME(wxDragResult a) { \
1388 wxPyBeginBlockThreads(); \
1389 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1390 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\
1391 wxPyEndBlockThreads(); \
1393 rval = PCLASS::CBNAME(a); \
1396 bool CLASS::base_##CBNAME(wxDragResult a) { \
1397 return PCLASS::CBNAME(a); \
1400 //---------------------------------------------------------------------------
1402 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1403 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1406 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1407 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1408 wxPyBeginBlockThreads(); \
1410 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1411 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1412 wxPyEndBlockThreads(); \
1413 return (wxDragResult)rval; \
1416 //---------------------------------------------------------------------------
1418 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1419 bool CBNAME(int a, int b, const wxString& c);
1421 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1422 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1424 wxPyBeginBlockThreads(); \
1425 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1426 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b, wx2PyString(c)));\
1427 wxPyEndBlockThreads(); \
1431 //---------------------------------------------------------------------------
1433 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1435 size_t base_##CBNAME();
1438 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1439 size_t CLASS::CBNAME() { \
1442 wxPyBeginBlockThreads(); \
1443 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1444 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1445 wxPyEndBlockThreads(); \
1447 rval = PCLASS::CBNAME(); \
1450 size_t CLASS::base_##CBNAME() { \
1451 return PCLASS::CBNAME(); \
1454 //---------------------------------------------------------------------------
1456 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1457 wxDataFormat CBNAME(size_t a); \
1458 wxDataFormat base_##CBNAME(size_t a);
1461 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1462 wxDataFormat CLASS::CBNAME(size_t a) { \
1463 wxDataFormat rval=0; \
1465 wxPyBeginBlockThreads(); \
1466 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1468 wxDataFormat* ptr; \
1469 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1471 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
1476 wxPyEndBlockThreads(); \
1478 rval = PCLASS::CBNAME(a); \
1481 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1482 return PCLASS::CBNAME(a); \
1485 //---------------------------------------------------------------------------
1487 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1488 void CBNAME(const Type& a); \
1489 void base_##CBNAME(const Type& a);
1492 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1493 void CLASS::CBNAME(const Type& a) { \
1495 wxPyBeginBlockThreads(); \
1496 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1497 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1498 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1501 wxPyEndBlockThreads(); \
1503 PCLASS::CBNAME(a); \
1505 void CLASS::base_##CBNAME(const Type& a) { \
1506 PCLASS::CBNAME(a); \
1510 //---------------------------------------------------------------------------
1512 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1513 void CBNAME(Type& a); \
1514 void base_##CBNAME(Type& a);
1517 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1518 void CLASS::CBNAME(Type& a) { \
1520 wxPyBeginBlockThreads(); \
1521 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1522 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1523 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1526 wxPyEndBlockThreads(); \
1528 PCLASS::CBNAME(a); \
1530 void CLASS::base_##CBNAME(Type& a) { \
1531 PCLASS::CBNAME(a); \
1534 //---------------------------------------------------------------------------
1536 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1537 bool CBNAME(Type& a); \
1538 bool base_##CBNAME(Type& a);
1541 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1542 bool CLASS::CBNAME(Type& a) { \
1545 wxPyBeginBlockThreads(); \
1546 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1547 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1548 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1551 wxPyEndBlockThreads(); \
1553 rv = PCLASS::CBNAME(a); \
1556 bool CLASS::base_##CBNAME(Type& a) { \
1557 return PCLASS::CBNAME(a); \
1560 //---------------------------------------------------------------------------
1562 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1563 wxString CBNAME(long a, long b) const; \
1564 wxString base_##CBNAME(long a, long b)const ;
1566 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1567 wxString CLASS::CBNAME(long a, long b) const { \
1570 wxPyBeginBlockThreads(); \
1571 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1573 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1575 rval = Py2wxString(ro); \
1579 wxPyEndBlockThreads(); \
1581 rval = PCLASS::CBNAME(a,b); \
1584 wxString CLASS::base_##CBNAME(long a, long b) const { \
1585 return PCLASS::CBNAME(a,b); \
1588 //---------------------------------------------------------------------------
1590 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1591 int CBNAME(long a) const; \
1592 int base_##CBNAME(long a)const ;
1595 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1596 int CLASS::CBNAME(long a) const { \
1599 wxPyBeginBlockThreads(); \
1600 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1602 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1604 rval = PyInt_AsLong(ro); \
1608 wxPyEndBlockThreads(); \
1610 rval = PCLASS::CBNAME(a); \
1613 int CLASS::base_##CBNAME(long a) const { \
1614 return PCLASS::CBNAME(a); \
1618 //---------------------------------------------------------------------------
1620 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
1621 wxListItemAttr* CBNAME(long a) const; \
1622 wxListItemAttr* base_##CBNAME(long a);
1625 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
1626 wxListItemAttr *CLASS::CBNAME(long a) const { \
1627 wxListItemAttr *rval = NULL; \
1629 wxPyBeginBlockThreads(); \
1630 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1632 wxListItemAttr* ptr; \
1633 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1635 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxListItemAttr_p")) \
1640 wxPyEndBlockThreads(); \
1642 rval = PCLASS::CBNAME(a); \
1645 wxListItemAttr *CLASS::base_##CBNAME(long a) { \
1646 return PCLASS::CBNAME(a); \
1649 //---------------------------------------------------------------------------
1651 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
1652 bool CBNAME(wxMouseEvent& e); \
1653 bool base_##CBNAME(wxMouseEvent& e);
1655 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
1656 bool CLASS::CBNAME(wxMouseEvent& e) { \
1659 wxPyBeginBlockThreads(); \
1660 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1662 PyObject* obj = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
1663 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1665 rval = PyInt_AsLong(ro); \
1670 wxPyEndBlockThreads(); \
1672 return PCLASS::CBNAME(e); \
1675 bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
1676 return PCLASS::CBNAME(e); \
1680 //---------------------------------------------------------------------------