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__
18 //----------------------------------------------------------------------
20 // if we want to handle threads and Python threads are available...
21 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
23 #define WXP_WITH_THREAD
24 #define wxPy_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
25 #define wxPy_END_ALLOW_THREADS Py_END_ALLOW_THREADS
27 #else // no Python threads...
28 #undef WXP_WITH_THREAD
29 #define wxPy_BEGIN_ALLOW_THREADS
30 #define wxPy_END_ALLOW_THREADS
34 //---------------------------------------------------------------------------
36 typedef unsigned char byte
;
39 class wxPyApp
: public wxApp
47 extern wxPyApp
*wxPythonApp
;
49 //----------------------------------------------------------------------
52 PyObject
* __wxStart(PyObject
*, PyObject
* args
);
55 //extern PyObject* wxPython_dict;
56 PyObject
* __wxSetDictionary(PyObject
*, PyObject
* args
);
58 void wxPyEventThunker(wxObject
*, wxEvent
& event
);
60 PyObject
* wxPyConstructObject(void* ptr
,
61 const char* className
,
63 PyObject
* wxPyConstructObject(void* ptr
,
64 const char* className
,
67 PyObject
* wxPyClassExists(const char* className
);
68 PyObject
* wxPyMake_wxObject(wxObject
* source
);
69 void wxPyPtrTypeMap_Add(const char* commonName
, const char* ptrName
);
71 PyObject
* wxPy_ConvertList(wxListBase
* list
, const char* className
);
72 long wxPyGetWinHandle(wxWindow
* win
);
74 //----------------------------------------------------------------------
77 PyThreadState
* newState
;
78 PyThreadState
* prevState
;
80 wxPyTState() : newState(NULL
), prevState(NULL
) {}
84 wxPyTState
* wxPyBeginBlockThreads();
85 void wxPyEndBlockThreads(wxPyTState
* state
);
88 //----------------------------------------------------------------------
89 // Handle wxInputStreams by Joerg Baumann
90 // See stream.i for implementations
92 // list class for return list of strings, e.g. readlines()
93 WX_DECLARE_LIST(wxString
, wxStringPtrList
);
96 // C++ class wxPyInputStream to act as base for python class wxInputStream
97 // Use it in python like a python file object
98 class wxPyInputStream
{
100 // underlying wxInputStream
104 wxPyInputStream(wxInputStream
* wxi_
) : wxi(wxi_
) {}
107 // python file object interface for input files (most of it)
111 wxString
* read(int size
=-1);
112 wxString
* readline(int size
=-1);
113 wxStringPtrList
* readlines(int sizehint
=-1);
114 void seek(int offset
, int whence
=0);
119 void truncate(int size=-1);
120 void write(wxString data);
121 void writelines(wxStringPtrList);
126 //----------------------------------------------------------------------
127 // These are helpers used by the typemaps
129 byte
* byte_LIST_helper(PyObject
* source
);
130 int* int_LIST_helper(PyObject
* source
);
131 long* long_LIST_helper(PyObject
* source
);
132 char** string_LIST_helper(PyObject
* source
);
133 wxPoint
* wxPoint_LIST_helper(PyObject
* source
, int* npoints
);
134 wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
135 wxString
* wxString_LIST_helper(PyObject
* source
);
136 wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
138 bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
139 bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
140 bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
141 bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
142 bool wxColour_helper(PyObject
* source
, wxColour
** obj
);
144 //----------------------------------------------------------------------
147 extern "C" void SWIG_MakePtr(char *, void *, char *);
148 extern "C" char *SWIG_GetPtr(char *, void **, char *);
149 extern "C" char *SWIG_GetPtrObj(PyObject
*obj
, void **ptr
, char *type
);
154 # pragma warning(disable:4800)
155 # pragma warning(disable:4190)
158 //----------------------------------------------------------------------
160 class wxPyCallback
: public wxObject
{
161 DECLARE_ABSTRACT_CLASS(wxPyCallback
);
163 wxPyCallback(PyObject
* func
);
164 wxPyCallback(const wxPyCallback
& other
);
167 void EventThunker(wxEvent
& event
);
172 //---------------------------------------------------------------------------
174 class wxPyTimer
: public wxTimer
{
176 wxPyTimer(PyObject
* callback
);
185 //---------------------------------------------------------------------------
186 //---------------------------------------------------------------------------
187 // These Event classes can be derived from in Python and passed through the
188 // event system without loosing anything. They do this by keeping a reference
189 // to themselves and some special case handling in wxPyCallback::EventThunker.
192 class wxPyEvtSelfRef
{
197 void SetSelf(PyObject
* self
, bool clone
=FALSE
);
198 PyObject
* GetSelf() const;
206 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
207 DECLARE_DYNAMIC_CLASS(wxPyEvent
)
212 void CopyObject(wxObject
& dest
) const;
216 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
217 DECLARE_DYNAMIC_CLASS(wxPyCommandEvent
)
219 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
222 void CopyObject(wxObject
& dest
) const;
226 //---------------------------------------------------------------------------
227 // Export a C API in a struct. Other modules will be able to load this from
228 // the wxc module and will then have safe access to these functions, even if
229 // in another shared library.
231 class wxPyCallbackHelper
;
235 void (*p_SWIG_MakePtr
)(char*, void*, char*);
236 char* (*p_SWIG_GetPtr
)(char*, void**, char*);
237 char* (*p_SWIG_GetPtrObj
)(PyObject
*, void**, char*);
238 void (*p_SWIG_RegisterMapping
)(char*, char*, void *(*cast
)(void *));
239 void (*p_SWIG_addvarlink
)(PyObject
*, char*, PyObject
*(*get_attr
)(void), int (*set_attr
)(PyObject
*p
));
240 PyObject
* (*p_SWIG_newvarlink
)(void);
242 wxPyTState
* (*p_wxPyBeginBlockThreads
)();
243 void (*p_wxPyEndBlockThreads
)(wxPyTState
* state
);
245 PyObject
* (*p_wxPyConstructObject
)(void *, const char *, int);
246 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
, const char* className
);
248 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
249 int* (*p_int_LIST_helper
)(PyObject
* source
);
250 long* (*p_long_LIST_helper
)(PyObject
* source
);
251 char** (*p_string_LIST_helper
)(PyObject
* source
);
252 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
253 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
254 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
255 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
257 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
258 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
259 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
260 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
261 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
263 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
264 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
);
265 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
266 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
267 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
269 PyObject
* (*p_wxPyClassExists
)(const char* className
);
270 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
);
271 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
275 #ifdef wxPyUSE_EXPORT
276 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
; // Each module needs one, but may not use it.
279 //---------------------------------------------------------------------------
280 // This class holds an instance of a Python Shadow Class object and assists
281 // with looking up and invoking Python callback methods from C++ virtual
282 // method redirections. For all classes which have virtuals which should be
283 // overridable in wxPython, a new subclass is created that contains a
284 // wxPyCallbackHelper.
287 class wxPyCallbackHelper
{
289 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
291 wxPyCallbackHelper() {
298 ~wxPyCallbackHelper() {
299 #ifdef wxPyUSE_EXPORT
300 wxPyCoreAPIPtr
->p_wxPyCBH_delete(this);
302 wxPyCBH_delete(this);
306 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=TRUE
);
307 bool findCallback(const char* name
) const;
308 int callCallback(PyObject
* argTuple
) const;
309 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
314 PyObject
* m_lastFound
;
317 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
321 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
322 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
);
323 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
324 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
325 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
329 //----------------------------------------------------------------------
331 class wxPyUserData
: public wxObject
{
333 wxPyUserData(PyObject
* obj
) {
339 #ifdef wxPyUSE_EXPORT
340 wxPyTState
* state
= wxPyCoreAPIPtr
->p_wxPyBeginBlockThreads();
342 wxPyCoreAPIPtr
->p_wxPyEndBlockThreads(state
);
344 wxPyTState
* state
= wxPyBeginBlockThreads();
346 wxPyEndBlockThreads(state
);
354 class wxPyClientData
: public wxClientData
{
356 wxPyClientData(PyObject
* obj
) {
362 #ifdef wxPyUSE_EXPORT
363 wxPyTState
* state
= wxPyCoreAPIPtr
->p_wxPyBeginBlockThreads();
365 wxPyCoreAPIPtr
->p_wxPyEndBlockThreads(state
);
367 wxPyTState
* state
= wxPyBeginBlockThreads();
369 wxPyEndBlockThreads(state
);
377 //---------------------------------------------------------------------------
378 // These macros are used to implement the virtual methods that should
379 // redirect to a Python method if one exists. The names designate the
380 // return type, if any, as well as any parameter types.
381 //---------------------------------------------------------------------------
384 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
385 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
387 private: wxPyCallbackHelper m_myInst
389 //---------------------------------------------------------------------------
391 #define DEC_PYCALLBACK__(CBNAME) \
393 void base_##CBNAME();
396 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
397 void CLASS::CBNAME() { \
399 wxPyTState* state = wxPyBeginBlockThreads(); \
400 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
401 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
402 wxPyEndBlockThreads(state); \
406 void CLASS::base_##CBNAME() { \
410 //---------------------------------------------------------------------------
412 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
413 bool CBNAME(int a, int b); \
414 bool base_##CBNAME(int a, int b);
417 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
418 bool CLASS::CBNAME(int a, int b) { \
419 bool rval=FALSE, found; \
420 wxPyTState* state = wxPyBeginBlockThreads(); \
421 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
422 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
423 wxPyEndBlockThreads(state); \
425 rval = PCLASS::CBNAME(a,b); \
428 bool CLASS::base_##CBNAME(int a, int b) { \
429 return PCLASS::CBNAME(a,b); \
432 //---------------------------------------------------------------------------
434 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
435 void CBNAME(int a, int b); \
436 void base_##CBNAME(int a, int b);
439 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
440 void CLASS::CBNAME(int a, int b) { \
442 wxPyTState* state = wxPyBeginBlockThreads(); \
443 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
444 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
445 wxPyEndBlockThreads(state); \
447 PCLASS::CBNAME(a,b); \
449 void CLASS::base_##CBNAME(int a, int b) { \
450 PCLASS::CBNAME(a,b); \
453 //---------------------------------------------------------------------------
455 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
456 bool CBNAME(int a); \
457 bool base_##CBNAME(int a);
460 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
461 bool CLASS::CBNAME(int a) { \
462 bool rval=FALSE, found; \
463 wxPyTState* state = wxPyBeginBlockThreads(); \
464 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
465 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
466 wxPyEndBlockThreads(state); \
468 rval = PCLASS::CBNAME(a); \
471 bool CLASS::base_##CBNAME(int a) { \
472 return PCLASS::CBNAME(a); \
475 //---------------------------------------------------------------------------
477 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
481 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
482 bool CLASS::CBNAME(int a) { \
484 wxPyTState* state = wxPyBeginBlockThreads(); \
485 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
486 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
488 wxPyEndBlockThreads(state); \
493 //---------------------------------------------------------------------------
495 #define DEC_PYCALLBACK__DC(CBNAME) \
496 void CBNAME(wxDC& a); \
497 void base_##CBNAME(wxDC& a);
500 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
501 void CLASS::CBNAME(wxDC& a) { \
503 wxPyTState* state = wxPyBeginBlockThreads(); \
504 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
505 PyObject* obj = wxPyMake_wxObject(&a); \
506 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
509 wxPyEndBlockThreads(state); \
513 void CLASS::base_##CBNAME(wxDC& a) { \
519 //---------------------------------------------------------------------------
521 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
522 void CBNAME(wxDC& a, bool b); \
523 void base_##CBNAME(wxDC& a, bool b);
526 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
527 void CLASS::CBNAME(wxDC& a, bool b) { \
529 wxPyTState* state = wxPyBeginBlockThreads(); \
530 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
531 PyObject* obj = wxPyMake_wxObject(&a); \
532 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
535 wxPyEndBlockThreads(state); \
537 PCLASS::CBNAME(a, b); \
539 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
540 PCLASS::CBNAME(a, b); \
543 //---------------------------------------------------------------------------
545 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
546 void CBNAME(wxDC& a, bool b); \
547 void base_##CBNAME(wxDC& a, bool b);
550 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
551 void CLASS::CBNAME(wxDC& a, bool b) { \
553 wxPyTState* state = wxPyBeginBlockThreads(); \
554 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
555 PyObject* obj = wxPyMake_wxObject(&a); \
556 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
559 wxPyEndBlockThreads(state); \
561 PCLASS::CBNAME(a, b); \
563 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
564 PCLASS::CBNAME(a, b); \
567 //---------------------------------------------------------------------------
569 #define DEC_PYCALLBACK__2DBL(CBNAME) \
570 void CBNAME(double a, double b); \
571 void base_##CBNAME(double a, double b);
574 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
575 void CLASS::CBNAME(double a, double b) { \
577 wxPyTState* state = wxPyBeginBlockThreads(); \
578 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
579 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
580 wxPyEndBlockThreads(state); \
582 PCLASS::CBNAME(a, b); \
584 void CLASS::base_##CBNAME(double a, double b) { \
585 PCLASS::CBNAME(a, b); \
588 //---------------------------------------------------------------------------
590 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
591 void CBNAME(double a, double b, int c, int d); \
592 void base_##CBNAME(double a, double b, int c, int d);
595 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
596 void CLASS::CBNAME(double a, double b, int c, int d) { \
598 wxPyTState* state = wxPyBeginBlockThreads(); \
599 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
600 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
602 wxPyEndBlockThreads(state); \
604 PCLASS::CBNAME(a, b, c, d); \
606 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
607 PCLASS::CBNAME(a, b, c, d); \
610 //---------------------------------------------------------------------------
612 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
613 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
614 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
617 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
618 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
620 wxPyTState* state = wxPyBeginBlockThreads(); \
621 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
622 PyObject* obj = wxPyMake_wxObject(&a); \
623 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
626 wxPyEndBlockThreads(state); \
628 PCLASS::CBNAME(a, b, c, d, e, f); \
630 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
631 PCLASS::CBNAME(a, b, c, d, e, f); \
634 //---------------------------------------------------------------------------
636 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
637 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
638 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
641 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
642 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
644 wxPyTState* state = wxPyBeginBlockThreads(); \
646 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
647 PyObject* obj = wxPyMake_wxObject(&a); \
648 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
651 wxPyEndBlockThreads(state); \
653 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
656 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
657 return PCLASS::CBNAME(a, b, c, d, e, f); \
660 //---------------------------------------------------------------------------
662 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
663 void CBNAME(bool a, double b, double c, int d, int e); \
664 void base_##CBNAME(bool a, double b, double c, int d, int e);
667 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
668 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
670 wxPyTState* state = wxPyBeginBlockThreads(); \
671 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
672 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
674 wxPyEndBlockThreads(state); \
676 PCLASS::CBNAME(a, b, c, d, e); \
678 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
679 PCLASS::CBNAME(a, b, c, d, e); \
682 //---------------------------------------------------------------------------
684 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
685 void CBNAME(wxDC& a, double b, double c, double d, double e); \
686 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
689 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
690 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
692 wxPyTState* state = wxPyBeginBlockThreads(); \
693 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
694 PyObject* obj = wxPyMake_wxObject(&a); \
695 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
698 wxPyEndBlockThreads(state); \
700 PCLASS::CBNAME(a, b, c, d, e); \
702 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
703 PCLASS::CBNAME(a, b, c, d, e); \
706 //---------------------------------------------------------------------------
708 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
709 void CBNAME(wxDC& a, bool b); \
710 void base_##CBNAME(wxDC& a, bool b);
713 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
714 void CLASS::CBNAME(wxDC& a, bool b) { \
716 wxPyTState* state = wxPyBeginBlockThreads(); \
717 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
718 PyObject* obj = wxPyMake_wxObject(&a); \
719 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
722 wxPyEndBlockThreads(state); \
724 PCLASS::CBNAME(a, b); \
726 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
727 PCLASS::CBNAME(a, b); \
730 //---------------------------------------------------------------------------
732 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
733 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
734 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
737 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
738 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
741 wxPyTState* state = wxPyBeginBlockThreads(); \
742 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
743 PyObject* obj = wxPyMake_wxObject(a); \
744 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
747 wxPyEndBlockThreads(state); \
749 PCLASS::CBNAME(a, b, c, d, e, f); \
751 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
753 PCLASS::CBNAME(a, b, c, d, e, f); \
756 //---------------------------------------------------------------------------
758 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
759 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
760 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
763 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
764 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
766 wxPyTState* state = wxPyBeginBlockThreads(); \
767 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
768 PyObject* obj = wxPyMake_wxObject(a); \
769 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
772 wxPyEndBlockThreads(state); \
774 PCLASS::CBNAME(a, b, c, d, e); \
776 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
778 PCLASS::CBNAME(a, b, c, d, e); \
781 //---------------------------------------------------------------------------
783 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
784 void CBNAME(double a, double b, int c); \
785 void base_##CBNAME(double a, double b, int c);
788 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
789 void CLASS::CBNAME(double a, double b, int c) { \
791 wxPyTState* state = wxPyBeginBlockThreads(); \
792 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
793 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
794 wxPyEndBlockThreads(state); \
796 PCLASS::CBNAME(a, b, c); \
798 void CLASS::base_##CBNAME(double a, double b, int c) { \
799 PCLASS::CBNAME(a, b, c); \
802 //---------------------------------------------------------------------------
804 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
805 void CBNAME(bool a, double b, double c, int d); \
806 void base_##CBNAME(bool a, double b, double c, int d);
809 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
810 void CLASS::CBNAME(bool a, double b, double c, int d) { \
812 wxPyTState* state = wxPyBeginBlockThreads(); \
813 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
814 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
815 wxPyEndBlockThreads(state); \
817 PCLASS::CBNAME(a, b, c, d); \
819 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
820 PCLASS::CBNAME(a, b, c, d); \
823 //---------------------------------------------------------------------------
824 //---------------------------------------------------------------------------
826 #define DEC_PYCALLBACK__STRING(CBNAME) \
827 void CBNAME(const wxString& a); \
828 void base_##CBNAME(const wxString& a);
831 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
832 void CLASS::CBNAME(const wxString& a) { \
834 wxPyTState* state = wxPyBeginBlockThreads(); \
835 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
836 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \
837 wxPyEndBlockThreads(state); \
841 void CLASS::base_##CBNAME(const wxString& a) { \
845 //---------------------------------------------------------------------------
847 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
848 bool CBNAME(const wxString& a); \
849 bool base_##CBNAME(const wxString& a);
852 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
853 bool CLASS::CBNAME(const wxString& a) { \
856 wxPyTState* state = wxPyBeginBlockThreads(); \
857 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
858 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str()));\
859 wxPyEndBlockThreads(state); \
861 rval = PCLASS::CBNAME(a); \
864 bool CLASS::base_##CBNAME(const wxString& a) { \
865 return PCLASS::CBNAME(a); \
868 //---------------------------------------------------------------------------
870 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
871 bool CBNAME(const wxString& a);
873 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
874 bool CLASS::CBNAME(const wxString& a) { \
876 wxPyTState* state = wxPyBeginBlockThreads(); \
877 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
878 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \
879 wxPyEndBlockThreads(state); \
883 //---------------------------------------------------------------------------
885 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
886 wxString CBNAME(const wxString& a); \
888 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
889 wxString CLASS::CBNAME(const wxString& a) { \
891 wxPyTState* state = wxPyBeginBlockThreads(); \
892 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
894 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(s)", a.c_str()));\
896 PyObject* str = PyObject_Str(ro); \
897 rval = PyString_AsString(str); \
898 Py_DECREF(ro); Py_DECREF(str); \
901 wxPyEndBlockThreads(state); \
905 //---------------------------------------------------------------------------
907 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
908 wxString CBNAME(const wxString& a,int b); \
910 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
911 wxString CLASS::CBNAME(const wxString& a,int b) { \
913 wxPyTState* state = wxPyBeginBlockThreads(); \
914 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
916 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(si)", a.c_str(),b)); \
918 PyObject* str = PyObject_Str(ro); \
919 rval = PyString_AsString(str); \
920 Py_DECREF(ro); Py_DECREF(str); \
923 wxPyEndBlockThreads(state); \
927 //---------------------------------------------------------------------------
929 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
930 bool CBNAME(const wxString& a, const wxString& b); \
931 bool base_##CBNAME(const wxString& a, const wxString& b);
934 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
935 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
938 wxPyTState* state = wxPyBeginBlockThreads(); \
939 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
940 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ss)", \
941 a.c_str(), b.c_str())); \
942 wxPyEndBlockThreads(state); \
944 rval = PCLASS::CBNAME(a, b); \
947 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
948 return PCLASS::CBNAME(a, b); \
951 //---------------------------------------------------------------------------
953 #define DEC_PYCALLBACK_STRING_(CBNAME) \
955 wxString base_##CBNAME();
958 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
959 wxString CLASS::CBNAME() { \
962 wxPyTState* state = wxPyBeginBlockThreads(); \
963 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
965 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
967 PyObject* str = PyObject_Str(ro); \
968 rval = PyString_AsString(str); \
969 Py_DECREF(ro); Py_DECREF(str); \
972 wxPyEndBlockThreads(state); \
974 rval = PCLASS::CBNAME(); \
977 wxString CLASS::base_##CBNAME() { \
978 return PCLASS::CBNAME(); \
981 //---------------------------------------------------------------------------
983 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
987 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
988 wxString CLASS::CBNAME() { \
990 wxPyTState* state = wxPyBeginBlockThreads(); \
991 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
993 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
995 PyObject* str = PyObject_Str(ro); \
996 rval = PyString_AsString(str); \
997 Py_DECREF(ro); Py_DECREF(str); \
1000 wxPyEndBlockThreads(state); \
1004 //---------------------------------------------------------------------------
1006 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1007 bool CBNAME(const wxHtmlTag& a); \
1010 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1011 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1013 wxPyTState* state = wxPyBeginBlockThreads(); \
1014 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1015 PyObject* obj = wxPyConstructObject((void*)&a, "wxHtmlTag", 0); \
1016 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1019 wxPyEndBlockThreads(state); \
1023 //---------------------------------------------------------------------------
1025 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1026 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \
1027 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y);
1029 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1030 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1033 wxPyTState* state = wxPyBeginBlockThreads(); \
1034 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1035 PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \
1036 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1039 wxPyEndBlockThreads(state); \
1041 PCLASS::CBNAME(cell, x, y); \
1043 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1044 PCLASS::CBNAME(cell, x, y); \
1048 //---------------------------------------------------------------------------
1050 #define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \
1051 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \
1052 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e);
1054 #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \
1055 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1057 wxPyTState* state = wxPyBeginBlockThreads(); \
1058 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1059 PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \
1060 PyObject* o2 = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
1061 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1065 wxPyEndBlockThreads(state); \
1067 PCLASS::CBNAME(cell, x, y, e); \
1069 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1070 PCLASS::CBNAME(cell, x, y, e); \
1075 //---------------------------------------------------------------------------
1077 #define DEC_PYCALLBACK___pure(CBNAME) \
1081 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1082 void CLASS::CBNAME() { \
1083 wxPyTState* state = wxPyBeginBlockThreads(); \
1084 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1085 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1086 wxPyEndBlockThreads(state); \
1089 //---------------------------------------------------------------------------
1091 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1095 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1096 wxSize CLASS::CBNAME() { \
1098 wxPyTState* state = wxPyBeginBlockThreads(); \
1099 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1102 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1104 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
1109 wxPyEndBlockThreads(state); \
1113 //---------------------------------------------------------------------------
1115 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1116 bool CBNAME(wxWindow* a); \
1117 bool base_##CBNAME(wxWindow* a);
1120 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1121 bool CLASS::CBNAME(wxWindow* a) { \
1124 wxPyTState* state = wxPyBeginBlockThreads(); \
1125 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1126 PyObject* obj = wxPyMake_wxObject(a); \
1127 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1130 wxPyEndBlockThreads(state); \
1132 rval = PCLASS::CBNAME(a); \
1135 bool CLASS::base_##CBNAME(wxWindow* a) { \
1136 return PCLASS::CBNAME(a); \
1139 //---------------------------------------------------------------------------
1141 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1143 bool base_##CBNAME();
1146 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1147 bool CLASS::CBNAME() { \
1150 wxPyTState* state = wxPyBeginBlockThreads(); \
1151 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1152 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1153 wxPyEndBlockThreads(state); \
1155 rval = PCLASS::CBNAME(); \
1158 bool CLASS::base_##CBNAME() { \
1159 return PCLASS::CBNAME(); \
1162 //---------------------------------------------------------------------------
1164 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1165 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
1166 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1169 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1170 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1173 wxPyTState* state = wxPyBeginBlockThreads(); \
1174 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1175 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1176 wxPyEndBlockThreads(state); \
1178 rval = PCLASS::CBNAME(a, b, c); \
1179 return (wxDragResult)rval; \
1181 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1182 return PCLASS::CBNAME(a, b, c); \
1185 //---------------------------------------------------------------------------
1187 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1188 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location); \
1190 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1191 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1192 wxPyTState* state = wxPyBeginBlockThreads(); \
1194 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1196 PyObject* obj = wxPyMake_wxObject(&a); \
1197 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Os)",\
1200 SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \
1205 wxPyEndBlockThreads(state); \
1209 //---------------------------------------------------------------------------
1211 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1212 bool CBNAME(wxDragResult a); \
1213 bool base_##CBNAME(wxDragResult a);
1216 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1217 bool CLASS::CBNAME(wxDragResult a) { \
1220 wxPyTState* state = wxPyBeginBlockThreads(); \
1221 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1222 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\
1223 wxPyEndBlockThreads(state); \
1225 rval = PCLASS::CBNAME(a); \
1228 bool CLASS::base_##CBNAME(wxDragResult a) { \
1229 return PCLASS::CBNAME(a); \
1232 //---------------------------------------------------------------------------
1234 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1235 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1238 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1239 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1240 wxPyTState* state = wxPyBeginBlockThreads(); \
1242 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1243 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1244 wxPyEndBlockThreads(state); \
1245 return (wxDragResult)rval; \
1248 //---------------------------------------------------------------------------
1250 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1251 bool CBNAME(int a, int b, const wxString& c);
1254 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1255 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1257 wxPyTState* state = wxPyBeginBlockThreads(); \
1258 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1259 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));\
1260 wxPyEndBlockThreads(state); \
1264 //---------------------------------------------------------------------------
1266 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1268 size_t base_##CBNAME();
1271 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1272 size_t CLASS::CBNAME() { \
1275 wxPyTState* state = wxPyBeginBlockThreads(); \
1276 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1277 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1278 wxPyEndBlockThreads(state); \
1280 rval = PCLASS::CBNAME(); \
1283 size_t CLASS::base_##CBNAME() { \
1284 return PCLASS::CBNAME(); \
1287 //---------------------------------------------------------------------------
1289 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1290 wxDataFormat CBNAME(size_t a); \
1291 wxDataFormat base_##CBNAME(size_t a);
1294 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1295 wxDataFormat CLASS::CBNAME(size_t a) { \
1296 wxDataFormat rval=0; \
1298 wxPyTState* state = wxPyBeginBlockThreads(); \
1299 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1301 wxDataFormat* ptr; \
1302 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1304 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
1309 wxPyEndBlockThreads(state); \
1311 rval = PCLASS::CBNAME(a); \
1314 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1315 return PCLASS::CBNAME(a); \
1318 //---------------------------------------------------------------------------
1320 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1321 void CBNAME(const Type& a); \
1322 void base_##CBNAME(const Type& a);
1325 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1326 void CLASS::CBNAME(const Type& a) { \
1328 wxPyTState* state = wxPyBeginBlockThreads(); \
1329 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1330 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1331 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1334 wxPyEndBlockThreads(state); \
1336 PCLASS::CBNAME(a); \
1338 void CLASS::base_##CBNAME(const Type& a) { \
1339 PCLASS::CBNAME(a); \
1343 //---------------------------------------------------------------------------
1345 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1346 void CBNAME(Type& a); \
1347 void base_##CBNAME(Type& a);
1350 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1351 void CLASS::CBNAME(Type& a) { \
1353 wxPyTState* state = wxPyBeginBlockThreads(); \
1354 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1355 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1356 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1359 wxPyEndBlockThreads(state); \
1361 PCLASS::CBNAME(a); \
1363 void CLASS::base_##CBNAME(Type& a) { \
1364 PCLASS::CBNAME(a); \
1367 //---------------------------------------------------------------------------
1369 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1370 bool CBNAME(Type& a); \
1371 bool base_##CBNAME(Type& a);
1374 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1375 bool CLASS::CBNAME(Type& a) { \
1378 wxPyTState* state = wxPyBeginBlockThreads(); \
1379 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1380 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1381 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1384 wxPyEndBlockThreads(state); \
1386 rv = PCLASS::CBNAME(a); \
1389 bool CLASS::base_##CBNAME(Type& a) { \
1390 return PCLASS::CBNAME(a); \
1393 //---------------------------------------------------------------------------
1395 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1396 wxString CBNAME(long a, long b) const; \
1397 wxString base_##CBNAME(long a, long b)const ;
1400 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1401 wxString CLASS::CBNAME(long a, long b) const { \
1404 wxPyTState* state = wxPyBeginBlockThreads(); \
1405 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1407 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1409 PyObject* str = PyObject_Str(ro); \
1410 rval = PyString_AsString(str); \
1411 Py_DECREF(ro); Py_DECREF(str); \
1414 wxPyEndBlockThreads(state); \
1416 rval = PCLASS::CBNAME(a,b); \
1419 wxString CLASS::base_##CBNAME(long a, long b) const { \
1420 return PCLASS::CBNAME(a,b); \
1423 //---------------------------------------------------------------------------
1425 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1426 int CBNAME(long a) const; \
1427 int base_##CBNAME(long a)const ;
1430 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1431 int CLASS::CBNAME(long a) const { \
1434 wxPyTState* state = wxPyBeginBlockThreads(); \
1435 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1437 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1439 rval = PyInt_AsLong(ro); \
1443 wxPyEndBlockThreads(state); \
1445 rval = PCLASS::CBNAME(a); \
1448 int CLASS::base_##CBNAME(long a) const { \
1449 return PCLASS::CBNAME(a); \
1453 //---------------------------------------------------------------------------
1455 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
1456 wxListItemAttr* CBNAME(long a) const; \
1457 wxListItemAttr* base_##CBNAME(long a);
1460 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
1461 wxListItemAttr *CLASS::CBNAME(long a) const { \
1462 wxListItemAttr *rval = NULL; \
1464 wxPyTState* state = wxPyBeginBlockThreads(); \
1465 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1467 wxListItemAttr* ptr; \
1468 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1470 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxListItemAttr_p")) \
1475 wxPyEndBlockThreads(state); \
1477 rval = PCLASS::CBNAME(a); \
1480 wxListItemAttr *CLASS::base_##CBNAME(long a) { \
1481 return PCLASS::CBNAME(a); \
1484 //---------------------------------------------------------------------------
1486 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
1487 bool CBNAME(wxMouseEvent& e); \
1488 bool base_##CBNAME(wxMouseEvent& e);
1490 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
1491 bool CLASS::CBNAME(wxMouseEvent& e) { \
1494 wxPyTState* state = wxPyBeginBlockThreads(); \
1495 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1497 PyObject* obj = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
1498 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1500 rval = PyInt_AsLong(ro); \
1505 wxPyEndBlockThreads(state); \
1507 return PCLASS::CBNAME(e); \
1509 bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
1510 return PCLASS::CBNAME(e); \
1514 //---------------------------------------------------------------------------