1 ////////////////////////////////////////////////////////////////////////////
3 // Purpose: Helper functions/classes for the wxPython extenaion 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 char* className
,
49 PyObject
* wxPyConstructObject(void* ptr
,
50 const char* className
,
53 PyObject
* wxPyClassExists(const char* className
);
54 PyObject
* wxPyMake_wxObject(wxObject
* source
, bool checkEvtHandler
=TRUE
);
55 PyObject
* wxPyMake_wxSizer(wxSizer
* source
);
56 void wxPyPtrTypeMap_Add(const char* commonName
, const char* ptrName
);
58 PyObject
* wxPy_ConvertList(wxListBase
* list
, const char* className
);
59 long wxPyGetWinHandle(wxWindow
* win
);
61 //----------------------------------------------------------------------
63 // if we want to handle threads and Python threads are available...
64 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
65 #define WXP_WITH_THREAD
66 #else // no Python threads...
67 #undef WXP_WITH_THREAD
72 PyThreadState
* wxPyBeginAllowThreads();
73 void wxPyEndAllowThreads(PyThreadState
* state
);
76 void wxPyBeginBlockThreads();
77 void wxPyEndBlockThreads();
79 //----------------------------------------------------------------------
80 // These are helpers used by the typemaps
82 wxString
* wxString_in_helper(PyObject
* source
);
84 byte
* byte_LIST_helper(PyObject
* source
);
85 int* int_LIST_helper(PyObject
* source
);
86 long* long_LIST_helper(PyObject
* source
);
87 char** string_LIST_helper(PyObject
* source
);
88 wxPoint
* wxPoint_LIST_helper(PyObject
* source
, int* npoints
);
89 wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
90 wxString
* wxString_LIST_helper(PyObject
* source
);
91 wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
92 wxPen
** wxPen_LIST_helper(PyObject
* source
);
94 bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
95 bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
96 bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
97 bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
98 bool wxColour_helper(PyObject
* source
, wxColour
** obj
);
100 #if PYTHON_API_VERSION < 1009
101 #define PySequence_Fast_GET_ITEM(o, i) \
102 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
105 bool _2int_seq_helper(PyObject
* source
, int* i1
, int* i2
);
106 bool _4int_seq_helper(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
109 PyObject
* wxArrayString2PyList_helper(const wxArrayString
& arr
);
110 PyObject
* wxArrayInt2PyList_helper(const wxArrayInt
& arr
);
113 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
115 //----------------------------------------------------------------------
118 extern "C" void SWIG_MakePtr(char *, void *, char *);
119 extern "C" char *SWIG_GetPtr(char *, void **, char *);
120 extern "C" char *SWIG_GetPtrObj(PyObject
*obj
, void **ptr
, char *type
);
125 # pragma warning(disable:4800)
126 # pragma warning(disable:4190)
129 //----------------------------------------------------------------------
131 class wxPyCallback
: public wxObject
{
132 DECLARE_ABSTRACT_CLASS(wxPyCallback
);
134 wxPyCallback(PyObject
* func
);
135 wxPyCallback(const wxPyCallback
& other
);
138 void EventThunker(wxEvent
& event
);
143 //---------------------------------------------------------------------------
145 class wxPyTimer
: public wxTimer
{
147 wxPyTimer(PyObject
* callback
);
156 //---------------------------------------------------------------------------
157 //---------------------------------------------------------------------------
158 // These Event classes can be derived from in Python and passed through the
159 // event system without loosing anything. They do this by keeping a reference
160 // to themselves and some special case handling in wxPyCallback::EventThunker.
163 class wxPyEvtSelfRef
{
168 void SetSelf(PyObject
* self
, bool clone
=FALSE
);
169 PyObject
* GetSelf() const;
177 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
178 DECLARE_ABSTRACT_CLASS(wxPyEvent
)
181 wxPyEvent(const wxPyEvent
& evt
);
184 virtual wxEvent
* Clone() const { return new wxPyEvent(*this); }
188 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
189 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent
)
191 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
192 wxPyCommandEvent(const wxPyCommandEvent
& evt
);
195 virtual wxEvent
* Clone() const { return new wxPyCommandEvent(*this); }
199 //---------------------------------------------------------------------------
200 // Export a C API in a struct. Other modules will be able to load this from
201 // the wxc module and will then have safe access to these functions, even if
202 // in another shared library.
204 class wxPyCallbackHelper
;
208 void (*p_SWIG_MakePtr
)(char*, void*, char*);
209 char* (*p_SWIG_GetPtr
)(char*, void**, char*);
210 char* (*p_SWIG_GetPtrObj
)(PyObject
*, void**, char*);
211 void (*p_SWIG_RegisterMapping
)(char*, char*, void *(*cast
)(void *));
212 void (*p_SWIG_addvarlink
)(PyObject
*, char*, PyObject
*(*get_attr
)(void), int (*set_attr
)(PyObject
*p
));
213 PyObject
* (*p_SWIG_newvarlink
)(void);
215 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
216 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
217 void (*p_wxPyBeginBlockThreads
)();
218 void (*p_wxPyEndBlockThreads
)();
220 PyObject
* (*p_wxPyConstructObject
)(void *, const char *, int);
221 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
, const char* className
);
223 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
225 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
226 int* (*p_int_LIST_helper
)(PyObject
* source
);
227 long* (*p_long_LIST_helper
)(PyObject
* source
);
228 char** (*p_string_LIST_helper
)(PyObject
* source
);
229 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
230 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
231 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
232 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
234 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
235 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
236 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
237 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
238 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
240 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
241 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
);
242 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
243 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
244 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
246 PyObject
* (*p_wxPyClassExists
)(const char* className
);
247 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool checkEvtHandler
);
248 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
);
249 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
250 PyObject
* (*p_wxArrayString2PyList_helper
)(const wxArrayString
& arr
);
251 PyObject
* (*p_wxArrayInt2PyList_helper
)(const wxArrayInt
& arr
);
254 #ifdef wxPyUSE_EXPORT
255 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
; // Each module needs one, but may not use it.
258 //---------------------------------------------------------------------------
259 // This class holds an instance of a Python Shadow Class object and assists
260 // with looking up and invoking Python callback methods from C++ virtual
261 // method redirections. For all classes which have virtuals which should be
262 // overridable in wxPython, a new subclass is created that contains a
263 // wxPyCallbackHelper.
266 class wxPyCallbackHelper
{
268 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
270 wxPyCallbackHelper() {
277 ~wxPyCallbackHelper() {
278 #ifdef wxPyUSE_EXPORT
279 wxPyCoreAPIPtr
->p_wxPyCBH_delete(this);
281 wxPyCBH_delete(this);
285 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=TRUE
);
286 bool findCallback(const char* name
) const;
287 int callCallback(PyObject
* argTuple
) const;
288 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
293 PyObject
* m_lastFound
;
296 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
300 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
301 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
);
302 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
303 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
304 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
308 //----------------------------------------------------------------------
310 class wxPyUserData
: public wxObject
{
312 wxPyUserData(PyObject
* obj
) {
318 #ifdef wxPyUSE_EXPORT
319 wxPyCoreAPIPtr
->p_wxPyBeginBlockThreads();
321 wxPyCoreAPIPtr
->p_wxPyEndBlockThreads();
323 wxPyBeginBlockThreads();
325 wxPyEndBlockThreads();
333 class wxPyClientData
: public wxClientData
{
335 wxPyClientData(PyObject
* obj
) {
341 #ifdef wxPyUSE_EXPORT
342 wxPyCoreAPIPtr
->p_wxPyBeginBlockThreads();
344 wxPyCoreAPIPtr
->p_wxPyEndBlockThreads();
346 wxPyBeginBlockThreads();
348 wxPyEndBlockThreads();
356 //---------------------------------------------------------------------------
357 // These macros are used to implement the virtual methods that should
358 // redirect to a Python method if one exists. The names designate the
359 // return type, if any, as well as any parameter types.
360 //---------------------------------------------------------------------------
363 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
364 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
366 private: wxPyCallbackHelper m_myInst
368 //---------------------------------------------------------------------------
370 #define DEC_PYCALLBACK__(CBNAME) \
372 void base_##CBNAME();
375 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
376 void CLASS::CBNAME() { \
378 wxPyBeginBlockThreads(); \
379 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
380 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
381 wxPyEndBlockThreads(); \
385 void CLASS::base_##CBNAME() { \
389 //---------------------------------------------------------------------------
391 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
392 bool CBNAME(int a, int b); \
393 bool base_##CBNAME(int a, int b);
396 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
397 bool CLASS::CBNAME(int a, int b) { \
398 bool rval=FALSE, found; \
399 wxPyBeginBlockThreads(); \
400 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
401 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
402 wxPyEndBlockThreads(); \
404 rval = PCLASS::CBNAME(a,b); \
407 bool CLASS::base_##CBNAME(int a, int b) { \
408 return PCLASS::CBNAME(a,b); \
411 //---------------------------------------------------------------------------
413 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
414 void CBNAME(int a, int b); \
415 void base_##CBNAME(int a, int b);
418 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
419 void CLASS::CBNAME(int a, int b) { \
421 wxPyBeginBlockThreads(); \
422 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
423 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
424 wxPyEndBlockThreads(); \
426 PCLASS::CBNAME(a,b); \
428 void CLASS::base_##CBNAME(int a, int b) { \
429 PCLASS::CBNAME(a,b); \
432 //---------------------------------------------------------------------------
434 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
435 bool CBNAME(int a); \
436 bool base_##CBNAME(int a);
439 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
440 bool CLASS::CBNAME(int a) { \
441 bool rval=FALSE, found; \
442 wxPyBeginBlockThreads(); \
443 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
444 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
445 wxPyEndBlockThreads(); \
447 rval = PCLASS::CBNAME(a); \
450 bool CLASS::base_##CBNAME(int a) { \
451 return PCLASS::CBNAME(a); \
454 //---------------------------------------------------------------------------
456 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
460 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
461 bool CLASS::CBNAME(int a) { \
463 wxPyBeginBlockThreads(); \
464 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
465 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
467 wxPyEndBlockThreads(); \
472 //---------------------------------------------------------------------------
474 #define DEC_PYCALLBACK__DC(CBNAME) \
475 void CBNAME(wxDC& a); \
476 void base_##CBNAME(wxDC& a);
479 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
480 void CLASS::CBNAME(wxDC& a) { \
482 wxPyBeginBlockThreads(); \
483 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
484 PyObject* obj = wxPyMake_wxObject(&a); \
485 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
488 wxPyEndBlockThreads(); \
492 void CLASS::base_##CBNAME(wxDC& a) { \
498 //---------------------------------------------------------------------------
500 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
501 void CBNAME(wxDC& a, bool b); \
502 void base_##CBNAME(wxDC& a, bool b);
505 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
506 void CLASS::CBNAME(wxDC& a, bool b) { \
508 wxPyBeginBlockThreads(); \
509 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
510 PyObject* obj = wxPyMake_wxObject(&a); \
511 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
514 wxPyEndBlockThreads(); \
516 PCLASS::CBNAME(a, b); \
518 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
519 PCLASS::CBNAME(a, b); \
522 //---------------------------------------------------------------------------
524 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
525 void CBNAME(wxDC& a, bool b); \
526 void base_##CBNAME(wxDC& a, bool b);
529 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
530 void CLASS::CBNAME(wxDC& a, bool b) { \
532 wxPyBeginBlockThreads(); \
533 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
534 PyObject* obj = wxPyMake_wxObject(&a); \
535 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
538 wxPyEndBlockThreads(); \
540 PCLASS::CBNAME(a, b); \
542 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
543 PCLASS::CBNAME(a, b); \
546 //---------------------------------------------------------------------------
548 #define DEC_PYCALLBACK__2DBL(CBNAME) \
549 void CBNAME(double a, double b); \
550 void base_##CBNAME(double a, double b);
553 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
554 void CLASS::CBNAME(double a, double b) { \
556 wxPyBeginBlockThreads(); \
557 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
558 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
559 wxPyEndBlockThreads(); \
561 PCLASS::CBNAME(a, b); \
563 void CLASS::base_##CBNAME(double a, double b) { \
564 PCLASS::CBNAME(a, b); \
567 //---------------------------------------------------------------------------
569 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
570 void CBNAME(double a, double b, int c, int d); \
571 void base_##CBNAME(double a, double b, int c, int d);
574 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
575 void CLASS::CBNAME(double a, double b, int c, int d) { \
577 wxPyBeginBlockThreads(); \
578 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
579 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
581 wxPyEndBlockThreads(); \
583 PCLASS::CBNAME(a, b, c, d); \
585 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
586 PCLASS::CBNAME(a, b, c, d); \
589 //---------------------------------------------------------------------------
591 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
592 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
593 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
596 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
597 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
599 wxPyBeginBlockThreads(); \
600 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
601 PyObject* obj = wxPyMake_wxObject(&a); \
602 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
605 wxPyEndBlockThreads(); \
607 PCLASS::CBNAME(a, b, c, d, e, f); \
609 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
610 PCLASS::CBNAME(a, b, c, d, e, f); \
613 //---------------------------------------------------------------------------
615 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
616 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
617 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
620 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
621 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
623 wxPyBeginBlockThreads(); \
625 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
626 PyObject* obj = wxPyMake_wxObject(&a); \
627 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
630 wxPyEndBlockThreads(); \
632 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
635 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
636 return PCLASS::CBNAME(a, b, c, d, e, f); \
639 //---------------------------------------------------------------------------
641 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
642 void CBNAME(bool a, double b, double c, int d, int e); \
643 void base_##CBNAME(bool a, double b, double c, int d, int e);
646 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
647 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
649 wxPyBeginBlockThreads(); \
650 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
651 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
653 wxPyEndBlockThreads(); \
655 PCLASS::CBNAME(a, b, c, d, e); \
657 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
658 PCLASS::CBNAME(a, b, c, d, e); \
661 //---------------------------------------------------------------------------
663 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
664 void CBNAME(wxDC& a, double b, double c, double d, double e); \
665 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
668 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
669 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
671 wxPyBeginBlockThreads(); \
672 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
673 PyObject* obj = wxPyMake_wxObject(&a); \
674 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
677 wxPyEndBlockThreads(); \
679 PCLASS::CBNAME(a, b, c, d, e); \
681 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
682 PCLASS::CBNAME(a, b, c, d, e); \
685 //---------------------------------------------------------------------------
687 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
688 void CBNAME(wxDC& a, bool b); \
689 void base_##CBNAME(wxDC& a, bool b);
692 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
693 void CLASS::CBNAME(wxDC& a, bool b) { \
695 wxPyBeginBlockThreads(); \
696 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
697 PyObject* obj = wxPyMake_wxObject(&a); \
698 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
701 wxPyEndBlockThreads(); \
703 PCLASS::CBNAME(a, b); \
705 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
706 PCLASS::CBNAME(a, b); \
709 //---------------------------------------------------------------------------
711 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
712 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
713 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
716 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
717 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
720 wxPyBeginBlockThreads(); \
721 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
722 PyObject* obj = wxPyMake_wxObject(a); \
723 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
726 wxPyEndBlockThreads(); \
728 PCLASS::CBNAME(a, b, c, d, e, f); \
730 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
732 PCLASS::CBNAME(a, b, c, d, e, f); \
735 //---------------------------------------------------------------------------
737 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
738 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
739 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
742 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
743 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
745 wxPyBeginBlockThreads(); \
746 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
747 PyObject* obj = wxPyMake_wxObject(a); \
748 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
751 wxPyEndBlockThreads(); \
753 PCLASS::CBNAME(a, b, c, d, e); \
755 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
757 PCLASS::CBNAME(a, b, c, d, e); \
760 //---------------------------------------------------------------------------
762 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
763 void CBNAME(double a, double b, int c); \
764 void base_##CBNAME(double a, double b, int c);
767 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
768 void CLASS::CBNAME(double a, double b, int c) { \
770 wxPyBeginBlockThreads(); \
771 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
772 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
773 wxPyEndBlockThreads(); \
775 PCLASS::CBNAME(a, b, c); \
777 void CLASS::base_##CBNAME(double a, double b, int c) { \
778 PCLASS::CBNAME(a, b, c); \
781 //---------------------------------------------------------------------------
783 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
784 void CBNAME(bool a, double b, double c, int d); \
785 void base_##CBNAME(bool a, double b, double c, int d);
788 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
789 void CLASS::CBNAME(bool a, double b, double c, int d) { \
791 wxPyBeginBlockThreads(); \
792 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
793 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
794 wxPyEndBlockThreads(); \
796 PCLASS::CBNAME(a, b, c, d); \
798 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
799 PCLASS::CBNAME(a, b, c, d); \
802 //---------------------------------------------------------------------------
803 //---------------------------------------------------------------------------
805 #define DEC_PYCALLBACK__STRING(CBNAME) \
806 void CBNAME(const wxString& a); \
807 void base_##CBNAME(const wxString& a);
810 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
811 void CLASS::CBNAME(const wxString& a) { \
813 wxPyBeginBlockThreads(); \
814 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
815 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \
816 wxPyEndBlockThreads(); \
820 void CLASS::base_##CBNAME(const wxString& a) { \
824 //---------------------------------------------------------------------------
826 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
827 bool CBNAME(const wxString& a); \
828 bool base_##CBNAME(const wxString& a);
831 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
832 bool CLASS::CBNAME(const wxString& a) { \
835 wxPyBeginBlockThreads(); \
836 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
837 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str()));\
838 wxPyEndBlockThreads(); \
840 rval = PCLASS::CBNAME(a); \
843 bool CLASS::base_##CBNAME(const wxString& a) { \
844 return PCLASS::CBNAME(a); \
847 //---------------------------------------------------------------------------
849 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
850 bool CBNAME(const wxString& a);
853 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
854 bool CLASS::CBNAME(const wxString& a) { \
856 wxPyBeginBlockThreads(); \
857 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
858 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \
859 wxPyEndBlockThreads(); \
863 //---------------------------------------------------------------------------
865 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
866 wxString CBNAME(const wxString& a); \
869 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
870 wxString CLASS::CBNAME(const wxString& a) { \
872 wxPyBeginBlockThreads(); \
873 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
875 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(s)", a.c_str()));\
877 PyObject* str = PyObject_Str(ro); \
878 rval = PyString_AsString(str); \
879 Py_DECREF(ro); Py_DECREF(str); \
882 wxPyEndBlockThreads(); \
886 //---------------------------------------------------------------------------
888 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
889 wxString CBNAME(const wxString& a,int b); \
892 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
893 wxString CLASS::CBNAME(const wxString& a,int b) { \
895 wxPyBeginBlockThreads(); \
896 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
898 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(si)", a.c_str(),b)); \
900 PyObject* str = PyObject_Str(ro); \
901 rval = PyString_AsString(str); \
902 Py_DECREF(ro); Py_DECREF(str); \
905 wxPyEndBlockThreads(); \
909 //---------------------------------------------------------------------------
911 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
912 bool CBNAME(const wxString& a, const wxString& b); \
913 bool base_##CBNAME(const wxString& a, const wxString& b);
916 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
917 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
920 wxPyBeginBlockThreads(); \
921 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
922 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ss)", \
923 a.c_str(), b.c_str())); \
924 wxPyEndBlockThreads(); \
926 rval = PCLASS::CBNAME(a, b); \
929 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
930 return PCLASS::CBNAME(a, b); \
933 //---------------------------------------------------------------------------
935 #define DEC_PYCALLBACK_STRING_(CBNAME) \
937 wxString base_##CBNAME();
940 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
941 wxString CLASS::CBNAME() { \
944 wxPyBeginBlockThreads(); \
945 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
947 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
949 PyObject* str = PyObject_Str(ro); \
950 rval = PyString_AsString(str); \
951 Py_DECREF(ro); Py_DECREF(str); \
954 wxPyEndBlockThreads(); \
956 rval = PCLASS::CBNAME(); \
959 wxString CLASS::base_##CBNAME() { \
960 return PCLASS::CBNAME(); \
963 //---------------------------------------------------------------------------
965 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
969 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
970 wxString CLASS::CBNAME() { \
972 wxPyBeginBlockThreads(); \
973 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
975 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
977 PyObject* str = PyObject_Str(ro); \
978 rval = PyString_AsString(str); \
979 Py_DECREF(ro); Py_DECREF(str); \
982 wxPyEndBlockThreads(); \
986 //---------------------------------------------------------------------------
988 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
989 bool CBNAME(const wxHtmlTag& a); \
992 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
993 bool CLASS::CBNAME(const wxHtmlTag& a) { \
995 wxPyBeginBlockThreads(); \
996 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
997 PyObject* obj = wxPyConstructObject((void*)&a, "wxHtmlTag", 0); \
998 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1001 wxPyEndBlockThreads(); \
1005 //---------------------------------------------------------------------------
1007 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1008 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \
1009 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y);
1011 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1012 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1014 wxPyBeginBlockThreads(); \
1015 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1016 PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \
1017 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1020 wxPyEndBlockThreads(); \
1022 PCLASS::CBNAME(cell, x, y); \
1024 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1025 PCLASS::CBNAME(cell, x, y); \
1029 //---------------------------------------------------------------------------
1031 #define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \
1032 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \
1033 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e);
1035 #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \
1036 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1038 wxPyBeginBlockThreads(); \
1039 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1040 PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \
1041 PyObject* o2 = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
1042 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1046 wxPyEndBlockThreads(); \
1048 PCLASS::CBNAME(cell, x, y, e); \
1050 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1051 PCLASS::CBNAME(cell, x, y, e); \
1056 //---------------------------------------------------------------------------
1058 #define DEC_PYCALLBACK___pure(CBNAME) \
1062 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1063 void CLASS::CBNAME() { \
1064 wxPyBeginBlockThreads(); \
1065 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1066 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1067 wxPyEndBlockThreads(); \
1070 //---------------------------------------------------------------------------
1072 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1076 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1077 wxSize CLASS::CBNAME() { \
1079 wxPyBeginBlockThreads(); \
1080 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1083 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1085 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
1090 wxPyEndBlockThreads(); \
1094 //---------------------------------------------------------------------------
1096 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1097 bool CBNAME(wxWindow* a); \
1098 bool base_##CBNAME(wxWindow* a);
1101 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1102 bool CLASS::CBNAME(wxWindow* a) { \
1105 wxPyBeginBlockThreads(); \
1106 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1107 PyObject* obj = wxPyMake_wxObject(a); \
1108 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1111 wxPyEndBlockThreads(); \
1113 rval = PCLASS::CBNAME(a); \
1116 bool CLASS::base_##CBNAME(wxWindow* a) { \
1117 return PCLASS::CBNAME(a); \
1120 //---------------------------------------------------------------------------
1122 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1124 bool base_##CBNAME();
1127 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1128 bool CLASS::CBNAME() { \
1131 wxPyBeginBlockThreads(); \
1132 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1133 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1134 wxPyEndBlockThreads(); \
1136 rval = PCLASS::CBNAME(); \
1139 bool CLASS::base_##CBNAME() { \
1140 return PCLASS::CBNAME(); \
1143 //---------------------------------------------------------------------------
1145 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1146 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
1147 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1150 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1151 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1154 wxPyBeginBlockThreads(); \
1155 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1156 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1157 wxPyEndBlockThreads(); \
1159 rval = PCLASS::CBNAME(a, b, c); \
1160 return (wxDragResult)rval; \
1162 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1163 return PCLASS::CBNAME(a, b, c); \
1166 //---------------------------------------------------------------------------
1168 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1169 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location); \
1171 // TODO: unicode fix
1172 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1173 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1174 wxPyBeginBlockThreads(); \
1176 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1178 PyObject* obj = wxPyMake_wxObject(&a); \
1179 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Os)",\
1182 SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \
1187 wxPyEndBlockThreads(); \
1191 //---------------------------------------------------------------------------
1193 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1194 bool CBNAME(wxDragResult a); \
1195 bool base_##CBNAME(wxDragResult a);
1198 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1199 bool CLASS::CBNAME(wxDragResult a) { \
1202 wxPyBeginBlockThreads(); \
1203 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1204 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\
1205 wxPyEndBlockThreads(); \
1207 rval = PCLASS::CBNAME(a); \
1210 bool CLASS::base_##CBNAME(wxDragResult a) { \
1211 return PCLASS::CBNAME(a); \
1214 //---------------------------------------------------------------------------
1216 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1217 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1220 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1221 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1222 wxPyBeginBlockThreads(); \
1224 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1225 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1226 wxPyEndBlockThreads(); \
1227 return (wxDragResult)rval; \
1230 //---------------------------------------------------------------------------
1232 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1233 bool CBNAME(int a, int b, const wxString& c);
1235 // TODO: unicode fix
1236 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1237 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1239 wxPyBeginBlockThreads(); \
1240 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1241 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));\
1242 wxPyEndBlockThreads(); \
1246 //---------------------------------------------------------------------------
1248 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1250 size_t base_##CBNAME();
1253 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1254 size_t CLASS::CBNAME() { \
1257 wxPyBeginBlockThreads(); \
1258 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1259 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1260 wxPyEndBlockThreads(); \
1262 rval = PCLASS::CBNAME(); \
1265 size_t CLASS::base_##CBNAME() { \
1266 return PCLASS::CBNAME(); \
1269 //---------------------------------------------------------------------------
1271 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1272 wxDataFormat CBNAME(size_t a); \
1273 wxDataFormat base_##CBNAME(size_t a);
1276 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1277 wxDataFormat CLASS::CBNAME(size_t a) { \
1278 wxDataFormat rval=0; \
1280 wxPyBeginBlockThreads(); \
1281 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1283 wxDataFormat* ptr; \
1284 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1286 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
1291 wxPyEndBlockThreads(); \
1293 rval = PCLASS::CBNAME(a); \
1296 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1297 return PCLASS::CBNAME(a); \
1300 //---------------------------------------------------------------------------
1302 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1303 void CBNAME(const Type& a); \
1304 void base_##CBNAME(const Type& a);
1307 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1308 void CLASS::CBNAME(const Type& a) { \
1310 wxPyBeginBlockThreads(); \
1311 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1312 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1313 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1316 wxPyEndBlockThreads(); \
1318 PCLASS::CBNAME(a); \
1320 void CLASS::base_##CBNAME(const Type& a) { \
1321 PCLASS::CBNAME(a); \
1325 //---------------------------------------------------------------------------
1327 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1328 void CBNAME(Type& a); \
1329 void base_##CBNAME(Type& a);
1332 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1333 void CLASS::CBNAME(Type& a) { \
1335 wxPyBeginBlockThreads(); \
1336 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1337 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1338 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1341 wxPyEndBlockThreads(); \
1343 PCLASS::CBNAME(a); \
1345 void CLASS::base_##CBNAME(Type& a) { \
1346 PCLASS::CBNAME(a); \
1349 //---------------------------------------------------------------------------
1351 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1352 bool CBNAME(Type& a); \
1353 bool base_##CBNAME(Type& a);
1356 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1357 bool CLASS::CBNAME(Type& a) { \
1360 wxPyBeginBlockThreads(); \
1361 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1362 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1363 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1366 wxPyEndBlockThreads(); \
1368 rv = PCLASS::CBNAME(a); \
1371 bool CLASS::base_##CBNAME(Type& a) { \
1372 return PCLASS::CBNAME(a); \
1375 //---------------------------------------------------------------------------
1377 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1378 wxString CBNAME(long a, long b) const; \
1379 wxString base_##CBNAME(long a, long b)const ;
1381 // TODO: unicode fix
1382 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1383 wxString CLASS::CBNAME(long a, long b) const { \
1386 wxPyBeginBlockThreads(); \
1387 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1389 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1391 PyObject* str = PyObject_Str(ro); \
1392 rval = PyString_AsString(str); \
1393 Py_DECREF(ro); Py_DECREF(str); \
1396 wxPyEndBlockThreads(); \
1398 rval = PCLASS::CBNAME(a,b); \
1401 wxString CLASS::base_##CBNAME(long a, long b) const { \
1402 return PCLASS::CBNAME(a,b); \
1405 //---------------------------------------------------------------------------
1407 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1408 int CBNAME(long a) const; \
1409 int base_##CBNAME(long a)const ;
1412 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1413 int CLASS::CBNAME(long a) const { \
1416 wxPyBeginBlockThreads(); \
1417 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1419 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1421 rval = PyInt_AsLong(ro); \
1425 wxPyEndBlockThreads(); \
1427 rval = PCLASS::CBNAME(a); \
1430 int CLASS::base_##CBNAME(long a) const { \
1431 return PCLASS::CBNAME(a); \
1435 //---------------------------------------------------------------------------
1437 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
1438 wxListItemAttr* CBNAME(long a) const; \
1439 wxListItemAttr* base_##CBNAME(long a);
1442 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
1443 wxListItemAttr *CLASS::CBNAME(long a) const { \
1444 wxListItemAttr *rval = NULL; \
1446 wxPyBeginBlockThreads(); \
1447 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1449 wxListItemAttr* ptr; \
1450 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1452 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxListItemAttr_p")) \
1457 wxPyEndBlockThreads(); \
1459 rval = PCLASS::CBNAME(a); \
1462 wxListItemAttr *CLASS::base_##CBNAME(long a) { \
1463 return PCLASS::CBNAME(a); \
1466 //---------------------------------------------------------------------------
1468 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
1469 bool CBNAME(wxMouseEvent& e); \
1470 bool base_##CBNAME(wxMouseEvent& e);
1472 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
1473 bool CLASS::CBNAME(wxMouseEvent& e) { \
1476 wxPyBeginBlockThreads(); \
1477 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1479 PyObject* obj = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
1480 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1482 rval = PyInt_AsLong(ro); \
1487 wxPyEndBlockThreads(); \
1489 return PCLASS::CBNAME(e); \
1492 bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
1493 return PCLASS::CBNAME(e); \
1497 //---------------------------------------------------------------------------