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
, bool checkEvtHandler
=TRUE
);
69 PyObject
* wxPyMake_wxSizer(wxSizer
* source
);
70 void wxPyPtrTypeMap_Add(const char* commonName
, const char* ptrName
);
72 PyObject
* wxPy_ConvertList(wxListBase
* list
, const char* className
);
73 long wxPyGetWinHandle(wxWindow
* win
);
75 //----------------------------------------------------------------------
78 PyThreadState
* newState
;
79 PyThreadState
* prevState
;
81 wxPyTState() : newState(NULL
), prevState(NULL
) {}
85 wxPyTState
* wxPyBeginBlockThreads();
86 void wxPyEndBlockThreads(wxPyTState
* state
);
89 //----------------------------------------------------------------------
90 // Handle wxInputStreams by Joerg Baumann
91 // See stream.i for implementations
93 // list class for return list of strings, e.g. readlines()
94 WX_DECLARE_LIST(wxString
, wxStringPtrList
);
97 // C++ class wxPyInputStream to act as base for python class wxInputStream
98 // Use it in python like a python file object
99 class wxPyInputStream
{
101 // underlying wxInputStream
105 wxPyInputStream(wxInputStream
* wxi_
) : wxi(wxi_
) {}
108 // python file object interface for input files (most of it)
112 wxString
* read(int size
=-1);
113 wxString
* readline(int size
=-1);
114 wxStringPtrList
* readlines(int sizehint
=-1);
115 void seek(int offset
, int whence
=0);
120 void truncate(int size=-1);
121 void write(wxString data);
122 void writelines(wxStringPtrList);
127 //----------------------------------------------------------------------
128 // These are helpers used by the typemaps
130 byte
* byte_LIST_helper(PyObject
* source
);
131 int* int_LIST_helper(PyObject
* source
);
132 long* long_LIST_helper(PyObject
* source
);
133 char** string_LIST_helper(PyObject
* source
);
134 wxPoint
* wxPoint_LIST_helper(PyObject
* source
, int* npoints
);
135 wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
136 wxString
* wxString_LIST_helper(PyObject
* source
);
137 wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
138 wxPen
** wxPen_LIST_helper(PyObject
* source
);
140 bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
141 bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
142 bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
143 bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
144 bool wxColour_helper(PyObject
* source
, wxColour
** obj
);
146 #if PYTHON_API_VERSION < 1009
147 #define PySequence_Fast_GET_ITEM(o, i) \
148 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
151 bool _2int_seq_helper(PyObject
* source
, int* i1
, int* i2
);
152 bool _4int_seq_helper(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
155 PyObject
* wxArrayString2PyList_helper(const wxArrayString
& app
);
158 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
160 //----------------------------------------------------------------------
163 extern "C" void SWIG_MakePtr(char *, void *, char *);
164 extern "C" char *SWIG_GetPtr(char *, void **, char *);
165 extern "C" char *SWIG_GetPtrObj(PyObject
*obj
, void **ptr
, char *type
);
170 # pragma warning(disable:4800)
171 # pragma warning(disable:4190)
174 //----------------------------------------------------------------------
176 class wxPyCallback
: public wxObject
{
177 DECLARE_ABSTRACT_CLASS(wxPyCallback
);
179 wxPyCallback(PyObject
* func
);
180 wxPyCallback(const wxPyCallback
& other
);
183 void EventThunker(wxEvent
& event
);
188 //---------------------------------------------------------------------------
190 class wxPyTimer
: public wxTimer
{
192 wxPyTimer(PyObject
* callback
);
201 //---------------------------------------------------------------------------
202 //---------------------------------------------------------------------------
203 // These Event classes can be derived from in Python and passed through the
204 // event system without loosing anything. They do this by keeping a reference
205 // to themselves and some special case handling in wxPyCallback::EventThunker.
208 class wxPyEvtSelfRef
{
213 void SetSelf(PyObject
* self
, bool clone
=FALSE
);
214 PyObject
* GetSelf() const;
222 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
223 DECLARE_ABSTRACT_CLASS(wxPyEvent
)
226 wxPyEvent(const wxPyEvent
& evt
);
229 virtual wxEvent
* Clone() const { return new wxPyEvent(*this); }
233 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
234 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent
)
236 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
237 wxPyCommandEvent(const wxPyCommandEvent
& evt
);
240 virtual wxEvent
* Clone() const { return new wxPyCommandEvent(*this); }
244 //---------------------------------------------------------------------------
245 // Export a C API in a struct. Other modules will be able to load this from
246 // the wxc module and will then have safe access to these functions, even if
247 // in another shared library.
249 class wxPyCallbackHelper
;
253 void (*p_SWIG_MakePtr
)(char*, void*, char*);
254 char* (*p_SWIG_GetPtr
)(char*, void**, char*);
255 char* (*p_SWIG_GetPtrObj
)(PyObject
*, void**, char*);
256 void (*p_SWIG_RegisterMapping
)(char*, char*, void *(*cast
)(void *));
257 void (*p_SWIG_addvarlink
)(PyObject
*, char*, PyObject
*(*get_attr
)(void), int (*set_attr
)(PyObject
*p
));
258 PyObject
* (*p_SWIG_newvarlink
)(void);
260 wxPyTState
* (*p_wxPyBeginBlockThreads
)();
261 void (*p_wxPyEndBlockThreads
)(wxPyTState
* state
);
263 PyObject
* (*p_wxPyConstructObject
)(void *, const char *, int);
264 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
, const char* className
);
266 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
267 int* (*p_int_LIST_helper
)(PyObject
* source
);
268 long* (*p_long_LIST_helper
)(PyObject
* source
);
269 char** (*p_string_LIST_helper
)(PyObject
* source
);
270 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
271 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
272 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
273 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
275 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
276 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
277 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
278 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
279 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
281 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
282 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
);
283 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
284 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
285 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
287 PyObject
* (*p_wxPyClassExists
)(const char* className
);
288 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool checkEvtHandler
);
289 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
);
290 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
294 #ifdef wxPyUSE_EXPORT
295 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
; // Each module needs one, but may not use it.
298 //---------------------------------------------------------------------------
299 // This class holds an instance of a Python Shadow Class object and assists
300 // with looking up and invoking Python callback methods from C++ virtual
301 // method redirections. For all classes which have virtuals which should be
302 // overridable in wxPython, a new subclass is created that contains a
303 // wxPyCallbackHelper.
306 class wxPyCallbackHelper
{
308 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
310 wxPyCallbackHelper() {
317 ~wxPyCallbackHelper() {
318 #ifdef wxPyUSE_EXPORT
319 wxPyCoreAPIPtr
->p_wxPyCBH_delete(this);
321 wxPyCBH_delete(this);
325 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=TRUE
);
326 bool findCallback(const char* name
) const;
327 int callCallback(PyObject
* argTuple
) const;
328 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
333 PyObject
* m_lastFound
;
336 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
340 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
341 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
);
342 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
343 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
344 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
348 //----------------------------------------------------------------------
350 class wxPyUserData
: public wxObject
{
352 wxPyUserData(PyObject
* obj
) {
358 #ifdef wxPyUSE_EXPORT
359 wxPyTState
* state
= wxPyCoreAPIPtr
->p_wxPyBeginBlockThreads();
361 wxPyCoreAPIPtr
->p_wxPyEndBlockThreads(state
);
363 wxPyTState
* state
= wxPyBeginBlockThreads();
365 wxPyEndBlockThreads(state
);
373 class wxPyClientData
: public wxClientData
{
375 wxPyClientData(PyObject
* obj
) {
381 #ifdef wxPyUSE_EXPORT
382 wxPyTState
* state
= wxPyCoreAPIPtr
->p_wxPyBeginBlockThreads();
384 wxPyCoreAPIPtr
->p_wxPyEndBlockThreads(state
);
386 wxPyTState
* state
= wxPyBeginBlockThreads();
388 wxPyEndBlockThreads(state
);
396 //---------------------------------------------------------------------------
397 // These macros are used to implement the virtual methods that should
398 // redirect to a Python method if one exists. The names designate the
399 // return type, if any, as well as any parameter types.
400 //---------------------------------------------------------------------------
403 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
404 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
406 private: wxPyCallbackHelper m_myInst
408 //---------------------------------------------------------------------------
410 #define DEC_PYCALLBACK__(CBNAME) \
412 void base_##CBNAME();
415 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
416 void CLASS::CBNAME() { \
418 wxPyTState* state = wxPyBeginBlockThreads(); \
419 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
420 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
421 wxPyEndBlockThreads(state); \
425 void CLASS::base_##CBNAME() { \
429 //---------------------------------------------------------------------------
431 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
432 bool CBNAME(int a, int b); \
433 bool base_##CBNAME(int a, int b);
436 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
437 bool CLASS::CBNAME(int a, int b) { \
438 bool rval=FALSE, found; \
439 wxPyTState* state = wxPyBeginBlockThreads(); \
440 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
441 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
442 wxPyEndBlockThreads(state); \
444 rval = PCLASS::CBNAME(a,b); \
447 bool CLASS::base_##CBNAME(int a, int b) { \
448 return PCLASS::CBNAME(a,b); \
451 //---------------------------------------------------------------------------
453 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
454 void CBNAME(int a, int b); \
455 void base_##CBNAME(int a, int b);
458 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
459 void CLASS::CBNAME(int a, int b) { \
461 wxPyTState* state = wxPyBeginBlockThreads(); \
462 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
463 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
464 wxPyEndBlockThreads(state); \
466 PCLASS::CBNAME(a,b); \
468 void CLASS::base_##CBNAME(int a, int b) { \
469 PCLASS::CBNAME(a,b); \
472 //---------------------------------------------------------------------------
474 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
475 bool CBNAME(int a); \
476 bool base_##CBNAME(int a);
479 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
480 bool CLASS::CBNAME(int a) { \
481 bool rval=FALSE, found; \
482 wxPyTState* state = wxPyBeginBlockThreads(); \
483 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
484 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
485 wxPyEndBlockThreads(state); \
487 rval = PCLASS::CBNAME(a); \
490 bool CLASS::base_##CBNAME(int a) { \
491 return PCLASS::CBNAME(a); \
494 //---------------------------------------------------------------------------
496 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
500 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
501 bool CLASS::CBNAME(int a) { \
503 wxPyTState* state = wxPyBeginBlockThreads(); \
504 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
505 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
507 wxPyEndBlockThreads(state); \
512 //---------------------------------------------------------------------------
514 #define DEC_PYCALLBACK__DC(CBNAME) \
515 void CBNAME(wxDC& a); \
516 void base_##CBNAME(wxDC& a);
519 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
520 void CLASS::CBNAME(wxDC& a) { \
522 wxPyTState* state = wxPyBeginBlockThreads(); \
523 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
524 PyObject* obj = wxPyMake_wxObject(&a); \
525 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
528 wxPyEndBlockThreads(state); \
532 void CLASS::base_##CBNAME(wxDC& a) { \
538 //---------------------------------------------------------------------------
540 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
541 void CBNAME(wxDC& a, bool b); \
542 void base_##CBNAME(wxDC& a, bool b);
545 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
546 void CLASS::CBNAME(wxDC& a, bool b) { \
548 wxPyTState* state = wxPyBeginBlockThreads(); \
549 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
550 PyObject* obj = wxPyMake_wxObject(&a); \
551 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
554 wxPyEndBlockThreads(state); \
556 PCLASS::CBNAME(a, b); \
558 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
559 PCLASS::CBNAME(a, b); \
562 //---------------------------------------------------------------------------
564 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
565 void CBNAME(wxDC& a, bool b); \
566 void base_##CBNAME(wxDC& a, bool b);
569 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
570 void CLASS::CBNAME(wxDC& a, bool b) { \
572 wxPyTState* state = wxPyBeginBlockThreads(); \
573 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
574 PyObject* obj = wxPyMake_wxObject(&a); \
575 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
578 wxPyEndBlockThreads(state); \
580 PCLASS::CBNAME(a, b); \
582 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
583 PCLASS::CBNAME(a, b); \
586 //---------------------------------------------------------------------------
588 #define DEC_PYCALLBACK__2DBL(CBNAME) \
589 void CBNAME(double a, double b); \
590 void base_##CBNAME(double a, double b);
593 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
594 void CLASS::CBNAME(double a, double b) { \
596 wxPyTState* state = wxPyBeginBlockThreads(); \
597 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
598 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
599 wxPyEndBlockThreads(state); \
601 PCLASS::CBNAME(a, b); \
603 void CLASS::base_##CBNAME(double a, double b) { \
604 PCLASS::CBNAME(a, b); \
607 //---------------------------------------------------------------------------
609 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
610 void CBNAME(double a, double b, int c, int d); \
611 void base_##CBNAME(double a, double b, int c, int d);
614 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
615 void CLASS::CBNAME(double a, double b, int c, int d) { \
617 wxPyTState* state = wxPyBeginBlockThreads(); \
618 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
619 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
621 wxPyEndBlockThreads(state); \
623 PCLASS::CBNAME(a, b, c, d); \
625 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
626 PCLASS::CBNAME(a, b, c, d); \
629 //---------------------------------------------------------------------------
631 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
632 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
633 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
636 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
637 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
639 wxPyTState* state = wxPyBeginBlockThreads(); \
640 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
641 PyObject* obj = wxPyMake_wxObject(&a); \
642 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
645 wxPyEndBlockThreads(state); \
647 PCLASS::CBNAME(a, b, c, d, e, f); \
649 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
650 PCLASS::CBNAME(a, b, c, d, e, f); \
653 //---------------------------------------------------------------------------
655 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
656 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
657 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
660 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
661 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
663 wxPyTState* state = wxPyBeginBlockThreads(); \
665 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
666 PyObject* obj = wxPyMake_wxObject(&a); \
667 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
670 wxPyEndBlockThreads(state); \
672 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
675 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
676 return PCLASS::CBNAME(a, b, c, d, e, f); \
679 //---------------------------------------------------------------------------
681 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
682 void CBNAME(bool a, double b, double c, int d, int e); \
683 void base_##CBNAME(bool a, double b, double c, int d, int e);
686 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
687 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
689 wxPyTState* state = wxPyBeginBlockThreads(); \
690 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
691 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
693 wxPyEndBlockThreads(state); \
695 PCLASS::CBNAME(a, b, c, d, e); \
697 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
698 PCLASS::CBNAME(a, b, c, d, e); \
701 //---------------------------------------------------------------------------
703 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
704 void CBNAME(wxDC& a, double b, double c, double d, double e); \
705 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
708 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
709 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
711 wxPyTState* state = wxPyBeginBlockThreads(); \
712 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
713 PyObject* obj = wxPyMake_wxObject(&a); \
714 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
717 wxPyEndBlockThreads(state); \
719 PCLASS::CBNAME(a, b, c, d, e); \
721 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
722 PCLASS::CBNAME(a, b, c, d, e); \
725 //---------------------------------------------------------------------------
727 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
728 void CBNAME(wxDC& a, bool b); \
729 void base_##CBNAME(wxDC& a, bool b);
732 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
733 void CLASS::CBNAME(wxDC& a, bool b) { \
735 wxPyTState* state = wxPyBeginBlockThreads(); \
736 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
737 PyObject* obj = wxPyMake_wxObject(&a); \
738 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
741 wxPyEndBlockThreads(state); \
743 PCLASS::CBNAME(a, b); \
745 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
746 PCLASS::CBNAME(a, b); \
749 //---------------------------------------------------------------------------
751 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
752 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
753 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
756 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
757 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
760 wxPyTState* state = wxPyBeginBlockThreads(); \
761 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
762 PyObject* obj = wxPyMake_wxObject(a); \
763 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
766 wxPyEndBlockThreads(state); \
768 PCLASS::CBNAME(a, b, c, d, e, f); \
770 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
772 PCLASS::CBNAME(a, b, c, d, e, f); \
775 //---------------------------------------------------------------------------
777 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
778 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
779 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
782 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
783 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
785 wxPyTState* state = wxPyBeginBlockThreads(); \
786 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
787 PyObject* obj = wxPyMake_wxObject(a); \
788 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
791 wxPyEndBlockThreads(state); \
793 PCLASS::CBNAME(a, b, c, d, e); \
795 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
797 PCLASS::CBNAME(a, b, c, d, e); \
800 //---------------------------------------------------------------------------
802 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
803 void CBNAME(double a, double b, int c); \
804 void base_##CBNAME(double a, double b, int c);
807 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
808 void CLASS::CBNAME(double a, double b, int c) { \
810 wxPyTState* state = wxPyBeginBlockThreads(); \
811 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
812 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
813 wxPyEndBlockThreads(state); \
815 PCLASS::CBNAME(a, b, c); \
817 void CLASS::base_##CBNAME(double a, double b, int c) { \
818 PCLASS::CBNAME(a, b, c); \
821 //---------------------------------------------------------------------------
823 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
824 void CBNAME(bool a, double b, double c, int d); \
825 void base_##CBNAME(bool a, double b, double c, int d);
828 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
829 void CLASS::CBNAME(bool a, double b, double c, int d) { \
831 wxPyTState* state = wxPyBeginBlockThreads(); \
832 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
833 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
834 wxPyEndBlockThreads(state); \
836 PCLASS::CBNAME(a, b, c, d); \
838 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
839 PCLASS::CBNAME(a, b, c, d); \
842 //---------------------------------------------------------------------------
843 //---------------------------------------------------------------------------
845 #define DEC_PYCALLBACK__STRING(CBNAME) \
846 void CBNAME(const wxString& a); \
847 void base_##CBNAME(const wxString& a);
850 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
851 void CLASS::CBNAME(const wxString& a) { \
853 wxPyTState* state = wxPyBeginBlockThreads(); \
854 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
855 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \
856 wxPyEndBlockThreads(state); \
860 void CLASS::base_##CBNAME(const wxString& a) { \
864 //---------------------------------------------------------------------------
866 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
867 bool CBNAME(const wxString& a); \
868 bool base_##CBNAME(const wxString& a);
871 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
872 bool CLASS::CBNAME(const wxString& a) { \
875 wxPyTState* state = wxPyBeginBlockThreads(); \
876 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
877 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str()));\
878 wxPyEndBlockThreads(state); \
880 rval = PCLASS::CBNAME(a); \
883 bool CLASS::base_##CBNAME(const wxString& a) { \
884 return PCLASS::CBNAME(a); \
887 //---------------------------------------------------------------------------
889 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
890 bool CBNAME(const wxString& a);
892 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
893 bool CLASS::CBNAME(const wxString& a) { \
895 wxPyTState* state = wxPyBeginBlockThreads(); \
896 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
897 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \
898 wxPyEndBlockThreads(state); \
902 //---------------------------------------------------------------------------
904 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
905 wxString CBNAME(const wxString& a); \
907 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
908 wxString CLASS::CBNAME(const wxString& a) { \
910 wxPyTState* state = wxPyBeginBlockThreads(); \
911 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
913 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(s)", a.c_str()));\
915 PyObject* str = PyObject_Str(ro); \
916 rval = PyString_AsString(str); \
917 Py_DECREF(ro); Py_DECREF(str); \
920 wxPyEndBlockThreads(state); \
924 //---------------------------------------------------------------------------
926 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
927 wxString CBNAME(const wxString& a,int b); \
929 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
930 wxString CLASS::CBNAME(const wxString& a,int b) { \
932 wxPyTState* state = wxPyBeginBlockThreads(); \
933 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
935 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(si)", a.c_str(),b)); \
937 PyObject* str = PyObject_Str(ro); \
938 rval = PyString_AsString(str); \
939 Py_DECREF(ro); Py_DECREF(str); \
942 wxPyEndBlockThreads(state); \
946 //---------------------------------------------------------------------------
948 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
949 bool CBNAME(const wxString& a, const wxString& b); \
950 bool base_##CBNAME(const wxString& a, const wxString& b);
953 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
954 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
957 wxPyTState* state = wxPyBeginBlockThreads(); \
958 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
959 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ss)", \
960 a.c_str(), b.c_str())); \
961 wxPyEndBlockThreads(state); \
963 rval = PCLASS::CBNAME(a, b); \
966 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
967 return PCLASS::CBNAME(a, b); \
970 //---------------------------------------------------------------------------
972 #define DEC_PYCALLBACK_STRING_(CBNAME) \
974 wxString base_##CBNAME();
977 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
978 wxString CLASS::CBNAME() { \
981 wxPyTState* state = wxPyBeginBlockThreads(); \
982 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
984 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
986 PyObject* str = PyObject_Str(ro); \
987 rval = PyString_AsString(str); \
988 Py_DECREF(ro); Py_DECREF(str); \
991 wxPyEndBlockThreads(state); \
993 rval = PCLASS::CBNAME(); \
996 wxString CLASS::base_##CBNAME() { \
997 return PCLASS::CBNAME(); \
1000 //---------------------------------------------------------------------------
1002 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1006 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1007 wxString CLASS::CBNAME() { \
1009 wxPyTState* state = wxPyBeginBlockThreads(); \
1010 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1012 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1014 PyObject* str = PyObject_Str(ro); \
1015 rval = PyString_AsString(str); \
1016 Py_DECREF(ro); Py_DECREF(str); \
1019 wxPyEndBlockThreads(state); \
1023 //---------------------------------------------------------------------------
1025 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1026 bool CBNAME(const wxHtmlTag& a); \
1029 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1030 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1032 wxPyTState* state = wxPyBeginBlockThreads(); \
1033 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1034 PyObject* obj = wxPyConstructObject((void*)&a, "wxHtmlTag", 0); \
1035 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1038 wxPyEndBlockThreads(state); \
1042 //---------------------------------------------------------------------------
1044 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1045 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \
1046 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y);
1048 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1049 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1052 wxPyTState* state = wxPyBeginBlockThreads(); \
1053 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1054 PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \
1055 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1058 wxPyEndBlockThreads(state); \
1060 PCLASS::CBNAME(cell, x, y); \
1062 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1063 PCLASS::CBNAME(cell, x, y); \
1067 //---------------------------------------------------------------------------
1069 #define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \
1070 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \
1071 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e);
1073 #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \
1074 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1076 wxPyTState* state = wxPyBeginBlockThreads(); \
1077 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1078 PyObject* obj = wxPyConstructObject((void*)cell, "wxHtmlCell", 0); \
1079 PyObject* o2 = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
1080 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1084 wxPyEndBlockThreads(state); \
1086 PCLASS::CBNAME(cell, x, y, e); \
1088 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1089 PCLASS::CBNAME(cell, x, y, e); \
1094 //---------------------------------------------------------------------------
1096 #define DEC_PYCALLBACK___pure(CBNAME) \
1100 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1101 void CLASS::CBNAME() { \
1102 wxPyTState* state = wxPyBeginBlockThreads(); \
1103 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1104 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1105 wxPyEndBlockThreads(state); \
1108 //---------------------------------------------------------------------------
1110 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1114 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1115 wxSize CLASS::CBNAME() { \
1117 wxPyTState* state = wxPyBeginBlockThreads(); \
1118 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1121 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1123 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
1128 wxPyEndBlockThreads(state); \
1132 //---------------------------------------------------------------------------
1134 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1135 bool CBNAME(wxWindow* a); \
1136 bool base_##CBNAME(wxWindow* a);
1139 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1140 bool CLASS::CBNAME(wxWindow* a) { \
1143 wxPyTState* state = wxPyBeginBlockThreads(); \
1144 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1145 PyObject* obj = wxPyMake_wxObject(a); \
1146 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1149 wxPyEndBlockThreads(state); \
1151 rval = PCLASS::CBNAME(a); \
1154 bool CLASS::base_##CBNAME(wxWindow* a) { \
1155 return PCLASS::CBNAME(a); \
1158 //---------------------------------------------------------------------------
1160 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1162 bool base_##CBNAME();
1165 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1166 bool CLASS::CBNAME() { \
1169 wxPyTState* state = wxPyBeginBlockThreads(); \
1170 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1171 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1172 wxPyEndBlockThreads(state); \
1174 rval = PCLASS::CBNAME(); \
1177 bool CLASS::base_##CBNAME() { \
1178 return PCLASS::CBNAME(); \
1181 //---------------------------------------------------------------------------
1183 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1184 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
1185 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1188 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1189 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1192 wxPyTState* state = wxPyBeginBlockThreads(); \
1193 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1194 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1195 wxPyEndBlockThreads(state); \
1197 rval = PCLASS::CBNAME(a, b, c); \
1198 return (wxDragResult)rval; \
1200 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1201 return PCLASS::CBNAME(a, b, c); \
1204 //---------------------------------------------------------------------------
1206 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1207 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location); \
1209 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1210 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1211 wxPyTState* state = wxPyBeginBlockThreads(); \
1213 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1215 PyObject* obj = wxPyMake_wxObject(&a); \
1216 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Os)",\
1219 SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \
1224 wxPyEndBlockThreads(state); \
1228 //---------------------------------------------------------------------------
1230 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1231 bool CBNAME(wxDragResult a); \
1232 bool base_##CBNAME(wxDragResult a);
1235 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1236 bool CLASS::CBNAME(wxDragResult a) { \
1239 wxPyTState* state = wxPyBeginBlockThreads(); \
1240 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1241 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\
1242 wxPyEndBlockThreads(state); \
1244 rval = PCLASS::CBNAME(a); \
1247 bool CLASS::base_##CBNAME(wxDragResult a) { \
1248 return PCLASS::CBNAME(a); \
1251 //---------------------------------------------------------------------------
1253 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1254 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1257 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1258 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1259 wxPyTState* state = wxPyBeginBlockThreads(); \
1261 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1262 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1263 wxPyEndBlockThreads(state); \
1264 return (wxDragResult)rval; \
1267 //---------------------------------------------------------------------------
1269 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1270 bool CBNAME(int a, int b, const wxString& c);
1273 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1274 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1276 wxPyTState* state = wxPyBeginBlockThreads(); \
1277 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1278 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));\
1279 wxPyEndBlockThreads(state); \
1283 //---------------------------------------------------------------------------
1285 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1287 size_t base_##CBNAME();
1290 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1291 size_t CLASS::CBNAME() { \
1294 wxPyTState* state = wxPyBeginBlockThreads(); \
1295 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1296 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1297 wxPyEndBlockThreads(state); \
1299 rval = PCLASS::CBNAME(); \
1302 size_t CLASS::base_##CBNAME() { \
1303 return PCLASS::CBNAME(); \
1306 //---------------------------------------------------------------------------
1308 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1309 wxDataFormat CBNAME(size_t a); \
1310 wxDataFormat base_##CBNAME(size_t a);
1313 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1314 wxDataFormat CLASS::CBNAME(size_t a) { \
1315 wxDataFormat rval=0; \
1317 wxPyTState* state = wxPyBeginBlockThreads(); \
1318 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1320 wxDataFormat* ptr; \
1321 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1323 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
1328 wxPyEndBlockThreads(state); \
1330 rval = PCLASS::CBNAME(a); \
1333 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1334 return PCLASS::CBNAME(a); \
1337 //---------------------------------------------------------------------------
1339 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1340 void CBNAME(const Type& a); \
1341 void base_##CBNAME(const Type& a);
1344 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1345 void CLASS::CBNAME(const Type& a) { \
1347 wxPyTState* state = wxPyBeginBlockThreads(); \
1348 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1349 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1350 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1353 wxPyEndBlockThreads(state); \
1355 PCLASS::CBNAME(a); \
1357 void CLASS::base_##CBNAME(const Type& a) { \
1358 PCLASS::CBNAME(a); \
1362 //---------------------------------------------------------------------------
1364 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1365 void CBNAME(Type& a); \
1366 void base_##CBNAME(Type& a);
1369 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1370 void CLASS::CBNAME(Type& a) { \
1372 wxPyTState* state = wxPyBeginBlockThreads(); \
1373 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1374 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1375 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1378 wxPyEndBlockThreads(state); \
1380 PCLASS::CBNAME(a); \
1382 void CLASS::base_##CBNAME(Type& a) { \
1383 PCLASS::CBNAME(a); \
1386 //---------------------------------------------------------------------------
1388 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1389 bool CBNAME(Type& a); \
1390 bool base_##CBNAME(Type& a);
1393 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1394 bool CLASS::CBNAME(Type& a) { \
1397 wxPyTState* state = wxPyBeginBlockThreads(); \
1398 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1399 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1400 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1403 wxPyEndBlockThreads(state); \
1405 rv = PCLASS::CBNAME(a); \
1408 bool CLASS::base_##CBNAME(Type& a) { \
1409 return PCLASS::CBNAME(a); \
1412 //---------------------------------------------------------------------------
1414 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1415 wxString CBNAME(long a, long b) const; \
1416 wxString base_##CBNAME(long a, long b)const ;
1419 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1420 wxString CLASS::CBNAME(long a, long b) const { \
1423 wxPyTState* state = wxPyBeginBlockThreads(); \
1424 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1426 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1428 PyObject* str = PyObject_Str(ro); \
1429 rval = PyString_AsString(str); \
1430 Py_DECREF(ro); Py_DECREF(str); \
1433 wxPyEndBlockThreads(state); \
1435 rval = PCLASS::CBNAME(a,b); \
1438 wxString CLASS::base_##CBNAME(long a, long b) const { \
1439 return PCLASS::CBNAME(a,b); \
1442 //---------------------------------------------------------------------------
1444 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1445 int CBNAME(long a) const; \
1446 int base_##CBNAME(long a)const ;
1449 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1450 int CLASS::CBNAME(long a) const { \
1453 wxPyTState* state = wxPyBeginBlockThreads(); \
1454 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1456 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1458 rval = PyInt_AsLong(ro); \
1462 wxPyEndBlockThreads(state); \
1464 rval = PCLASS::CBNAME(a); \
1467 int CLASS::base_##CBNAME(long a) const { \
1468 return PCLASS::CBNAME(a); \
1472 //---------------------------------------------------------------------------
1474 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
1475 wxListItemAttr* CBNAME(long a) const; \
1476 wxListItemAttr* base_##CBNAME(long a);
1479 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
1480 wxListItemAttr *CLASS::CBNAME(long a) const { \
1481 wxListItemAttr *rval = NULL; \
1483 wxPyTState* state = wxPyBeginBlockThreads(); \
1484 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1486 wxListItemAttr* ptr; \
1487 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1489 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxListItemAttr_p")) \
1494 wxPyEndBlockThreads(state); \
1496 rval = PCLASS::CBNAME(a); \
1499 wxListItemAttr *CLASS::base_##CBNAME(long a) { \
1500 return PCLASS::CBNAME(a); \
1503 //---------------------------------------------------------------------------
1505 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
1506 bool CBNAME(wxMouseEvent& e); \
1507 bool base_##CBNAME(wxMouseEvent& e);
1509 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
1510 bool CLASS::CBNAME(wxMouseEvent& e) { \
1513 wxPyTState* state = wxPyBeginBlockThreads(); \
1514 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1516 PyObject* obj = wxPyConstructObject((void*)&e, "wxMouseEvent", 0); \
1517 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1519 rval = PyInt_AsLong(ro); \
1524 wxPyEndBlockThreads(state); \
1526 return PCLASS::CBNAME(e); \
1529 bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
1530 return PCLASS::CBNAME(e); \
1534 //---------------------------------------------------------------------------