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 bool wxPyRestoreThread();
64 void wxPySaveThread(bool doSave
);
65 PyObject
* wxPy_ConvertList(wxListBase
* list
, const char* className
);
66 long wxPyGetWinHandle(wxWindow
* win
);
70 //----------------------------------------------------------------------
71 // Handle wxInputStreams by Joerg Baumann
72 // See stream.i for implementations
74 // list class for return list of strings, e.g. readlines()
75 WX_DECLARE_LIST(wxString
, wxStringPtrList
);
78 // C++ class wxPyInputStream to act as base for python class wxInputStream
79 // Use it in python like a python file object
80 class wxPyInputStream
{
82 // underlying wxInputStream
86 wxPyInputStream(wxInputStream
* wxi_
) : wxi(wxi_
) {}
89 // python file object interface for input files (most of it)
93 wxString
* read(int size
=-1);
94 wxString
* readline(int size
=-1);
95 wxStringPtrList
* readlines(int sizehint
=-1);
96 void seek(int offset
, int whence
=0);
101 void truncate(int size=-1);
102 void write(wxString data);
103 void writelines(wxStringPtrList);
108 //----------------------------------------------------------------------
109 // These are helpers used by the typemaps
111 byte
* byte_LIST_helper(PyObject
* source
);
112 int* int_LIST_helper(PyObject
* source
);
113 long* long_LIST_helper(PyObject
* source
);
114 char** string_LIST_helper(PyObject
* source
);
115 wxPoint
* wxPoint_LIST_helper(PyObject
* source
, int* npoints
);
116 wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
117 wxString
* wxString_LIST_helper(PyObject
* source
);
118 wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
120 bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
121 bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
122 bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
123 bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
124 bool wxColour_helper(PyObject
* source
, wxColour
** obj
);
126 //----------------------------------------------------------------------
129 extern "C" void SWIG_MakePtr(char *, void *, char *);
130 extern "C" char *SWIG_GetPtr(char *, void **, char *);
131 extern "C" char *SWIG_GetPtrObj(PyObject
*obj
, void **ptr
, char *type
);
136 # pragma warning(disable:4800)
137 # pragma warning(disable:4190)
140 //----------------------------------------------------------------------
142 class wxPyCallback
: public wxObject
{
143 DECLARE_ABSTRACT_CLASS(wxPyCallback
);
145 wxPyCallback(PyObject
* func
);
146 wxPyCallback(const wxPyCallback
& other
);
149 void EventThunker(wxEvent
& event
);
154 //---------------------------------------------------------------------------
156 class wxPyTimer
: public wxTimer
{
158 wxPyTimer(PyObject
* callback
);
167 //---------------------------------------------------------------------------
168 //---------------------------------------------------------------------------
169 // These Event classes can be derived from in Python and passed through the
170 // event system without loosing anything. They do this by keeping a reference
171 // to themselves and some special case handling in wxPyCallback::EventThunker.
174 class wxPyEvtSelfRef
{
179 void SetSelf(PyObject
* self
, bool clone
=FALSE
);
180 PyObject
* GetSelf() const;
188 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
189 DECLARE_DYNAMIC_CLASS(wxPyEvent
)
194 void CopyObject(wxObject
& dest
) const;
198 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
199 DECLARE_DYNAMIC_CLASS(wxPyCommandEvent
)
201 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
204 void CopyObject(wxObject
& dest
) const;
208 //---------------------------------------------------------------------------
209 // Export a C API in a struct. Other modules will be able to load this from
210 // the wxc module and will then have safe access to these functions, even if
211 // in another shared library.
213 class wxPyCallbackHelper
;
217 void (*p_SWIG_MakePtr
)(char*, void*, char*);
218 char* (*p_SWIG_GetPtr
)(char*, void**, char*);
219 char* (*p_SWIG_GetPtrObj
)(PyObject
*, void**, char*);
220 void (*p_SWIG_RegisterMapping
)(char*, char*, void *(*cast
)(void *));
221 void (*p_SWIG_addvarlink
)(PyObject
*, char*, PyObject
*(*get_attr
)(void), int (*set_attr
)(PyObject
*p
));
222 PyObject
* (*p_SWIG_newvarlink
)(void);
224 void (*p_wxPySaveThread
)(bool);
225 bool (*p_wxPyRestoreThread
)();
226 PyObject
* (*p_wxPyConstructObject
)(void *, const char *, int);
227 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
, const char* className
);
229 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
230 int* (*p_int_LIST_helper
)(PyObject
* source
);
231 long* (*p_long_LIST_helper
)(PyObject
* source
);
232 char** (*p_string_LIST_helper
)(PyObject
* source
);
233 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
234 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
235 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
236 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
238 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
239 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
240 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
241 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
242 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
244 void (*p_wxPyCBH_setSelf
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
245 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
);
246 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
247 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
248 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
252 #ifdef wxPyUSE_EXPORT
253 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
; // Each module needs one, but may not use it.
256 //---------------------------------------------------------------------------
257 // This class holds an instance of a Python Shadow Class object and assists
258 // with looking up and invoking Python callback methods from C++ virtual
259 // method redirections. For all classes which have virtuals which should be
260 // overridable in wxPython, a new subclass is created that contains a
261 // wxPyCallbackHelper.
264 class wxPyCallbackHelper
{
266 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
268 wxPyCallbackHelper() {
275 ~wxPyCallbackHelper() {
276 #ifdef wxPyUSE_EXPORT
277 wxPyCoreAPIPtr
->p_wxPyCBH_delete(this);
279 wxPyCBH_delete(this);
283 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=TRUE
);
284 bool findCallback(const char* name
) const;
285 int callCallback(PyObject
* argTuple
) const;
286 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
291 PyObject
* m_lastFound
;
294 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
298 void wxPyCBH_setSelf(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
299 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
);
300 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
301 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
302 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
306 //----------------------------------------------------------------------
308 class wxPyUserData
: public wxObject
{
310 wxPyUserData(PyObject
* obj
) {
317 #ifdef wxPyUSE_EXPORT
318 doSave
= wxPyCoreAPIPtr
->p_wxPyRestoreThread();
320 wxPyCoreAPIPtr
->p_wxPySaveThread(doSave
);
322 doSave
= wxPyRestoreThread();
324 wxPySaveThread(doSave
);
332 //---------------------------------------------------------------------------
333 // These macros are used to implement the virtual methods that should
334 // redirect to a Python method if one exists. The names designate the
335 // return type, if any, as well as any parameter types.
336 //---------------------------------------------------------------------------
339 void _setSelf(PyObject* self, PyObject* _class, int incref=1) { \
340 wxPyCBH_setSelf(m_myInst, self, _class, incref); \
342 private: wxPyCallbackHelper m_myInst
344 //---------------------------------------------------------------------------
346 #define DEC_PYCALLBACK__(CBNAME) \
348 void base_##CBNAME();
351 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
352 void CLASS::CBNAME() { \
353 bool doSave = wxPyRestoreThread(); \
354 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
355 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
358 wxPySaveThread(doSave); \
360 void CLASS::base_##CBNAME() { \
364 //---------------------------------------------------------------------------
366 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
367 bool CBNAME(int a, int b); \
368 bool base_##CBNAME(int a, int b);
371 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
372 bool CLASS::CBNAME(int a, int b) { \
374 bool doSave = wxPyRestoreThread(); \
375 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
376 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
378 rval = PCLASS::CBNAME(a,b); \
379 wxPySaveThread(doSave); \
382 bool CLASS::base_##CBNAME(int a, int b) { \
383 return PCLASS::CBNAME(a,b); \
386 //---------------------------------------------------------------------------
388 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
389 void CBNAME(int a, int b); \
390 void base_##CBNAME(int a, int b);
393 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
394 void CLASS::CBNAME(int a, int b) { \
395 bool doSave = wxPyRestoreThread(); \
396 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
397 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
399 PCLASS::CBNAME(a,b); \
400 wxPySaveThread(doSave); \
402 void CLASS::base_##CBNAME(int a, int b) { \
403 PCLASS::CBNAME(a,b); \
406 //---------------------------------------------------------------------------
408 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
409 bool CBNAME(int a); \
410 bool base_##CBNAME(int a);
413 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
414 bool CLASS::CBNAME(int a) { \
416 bool doSave = wxPyRestoreThread(); \
417 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
418 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
420 rval = PCLASS::CBNAME(a); \
421 wxPySaveThread(doSave); \
424 bool CLASS::base_##CBNAME(int a) { \
425 return PCLASS::CBNAME(a); \
428 //---------------------------------------------------------------------------
430 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
434 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
435 bool CLASS::CBNAME(int a) { \
437 bool doSave = wxPyRestoreThread(); \
438 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
439 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
441 wxPySaveThread(doSave); \
446 //---------------------------------------------------------------------------
448 #define DEC_PYCALLBACK__DC(CBNAME) \
449 void CBNAME(wxDC& a); \
450 void base_##CBNAME(wxDC& a);
453 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
454 void CLASS::CBNAME(wxDC& a) { \
455 bool doSave = wxPyRestoreThread(); \
456 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
457 PyObject* obj = wxPyConstructObject(&a, "wxDC", 0); \
458 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
463 wxPySaveThread(doSave); \
465 void CLASS::base_##CBNAME(wxDC& a) { \
471 //---------------------------------------------------------------------------
473 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
474 void CBNAME(wxDC& a, bool b); \
475 void base_##CBNAME(wxDC& a, bool b);
478 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
479 void CLASS::CBNAME(wxDC& a, bool b) { \
480 bool doSave = wxPyRestoreThread(); \
481 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
482 PyObject* obj = wxPyConstructObject(&a, "wxDC", 0); \
483 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
487 PCLASS::CBNAME(a, b); \
488 wxPySaveThread(doSave); \
490 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
491 PCLASS::CBNAME(a, b); \
494 //---------------------------------------------------------------------------
496 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
497 void CBNAME(wxDC& a, bool b); \
498 void base_##CBNAME(wxDC& a, bool b);
501 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
502 void CLASS::CBNAME(wxDC& a, bool b) { \
503 bool doSave = wxPyRestoreThread(); \
504 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
505 PyObject* obj = wxPyConstructObject(&a, "wxDC", 0); \
506 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
510 PCLASS::CBNAME(a, b); \
511 wxPySaveThread(doSave); \
513 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
514 PCLASS::CBNAME(a, b); \
517 //---------------------------------------------------------------------------
519 #define DEC_PYCALLBACK__2DBL(CBNAME) \
520 void CBNAME(double a, double b); \
521 void base_##CBNAME(double a, double b);
524 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
525 void CLASS::CBNAME(double a, double b) { \
526 bool doSave = wxPyRestoreThread(); \
527 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
528 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
530 PCLASS::CBNAME(a, b); \
531 wxPySaveThread(doSave); \
533 void CLASS::base_##CBNAME(double a, double b) { \
534 PCLASS::CBNAME(a, b); \
537 //---------------------------------------------------------------------------
539 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
540 void CBNAME(double a, double b, int c, int d); \
541 void base_##CBNAME(double a, double b, int c, int d);
544 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
545 void CLASS::CBNAME(double a, double b, int c, int d) { \
546 bool doSave = wxPyRestoreThread(); \
547 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
548 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
551 PCLASS::CBNAME(a, b, c, d); \
552 wxPySaveThread(doSave); \
554 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
555 PCLASS::CBNAME(a, b, c, d); \
558 //---------------------------------------------------------------------------
560 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
561 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
562 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
565 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
566 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
567 bool doSave = wxPyRestoreThread(); \
568 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
569 PyObject* obj = wxPyConstructObject(&a, "wxDC", 0); \
570 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
574 PCLASS::CBNAME(a, b, c, d, e, f); \
575 wxPySaveThread(doSave); \
577 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
578 PCLASS::CBNAME(a, b, c, d, e, f); \
581 //---------------------------------------------------------------------------
583 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
584 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
585 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
588 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
589 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
590 bool doSave = wxPyRestoreThread(); \
592 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
593 PyObject* obj = wxPyConstructObject(&a, "wxDC", 0); \
594 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
598 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
599 wxPySaveThread(doSave); \
602 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
603 return PCLASS::CBNAME(a, b, c, d, e, f); \
606 //---------------------------------------------------------------------------
608 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
609 void CBNAME(bool a, double b, double c, int d, int e); \
610 void base_##CBNAME(bool a, double b, double c, int d, int e);
613 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
614 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
615 bool doSave = wxPyRestoreThread(); \
616 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
617 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
620 PCLASS::CBNAME(a, b, c, d, e); \
621 wxPySaveThread(doSave); \
623 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
624 PCLASS::CBNAME(a, b, c, d, e); \
627 //---------------------------------------------------------------------------
629 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
630 void CBNAME(wxDC& a, double b, double c, double d, double e); \
631 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
634 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
635 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
636 bool doSave = wxPyRestoreThread(); \
637 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
638 PyObject* obj = wxPyConstructObject(&a, "wxDC", 0); \
639 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
643 PCLASS::CBNAME(a, b, c, d, e); \
644 wxPySaveThread(doSave); \
646 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
647 PCLASS::CBNAME(a, b, c, d, e); \
650 //---------------------------------------------------------------------------
652 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
653 void CBNAME(wxDC& a, bool b); \
654 void base_##CBNAME(wxDC& a, bool b);
657 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
658 void CLASS::CBNAME(wxDC& a, bool b) { \
659 bool doSave = wxPyRestoreThread(); \
660 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
661 PyObject* obj = wxPyConstructObject(&a, "wxDC", 0); \
662 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
666 PCLASS::CBNAME(a, b); \
667 wxPySaveThread(doSave); \
669 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
670 PCLASS::CBNAME(a, b); \
673 //---------------------------------------------------------------------------
675 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
676 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
677 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
680 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
681 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
683 bool doSave = wxPyRestoreThread(); \
684 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
685 PyObject* obj = wxPyConstructObject(a, "wxPyControlPoint", 0); \
686 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
690 PCLASS::CBNAME(a, b, c, d, e, f); \
691 wxPySaveThread(doSave); \
693 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
695 PCLASS::CBNAME(a, b, c, d, e, f); \
698 //---------------------------------------------------------------------------
700 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
701 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
702 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
705 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
706 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
707 bool doSave = wxPyRestoreThread(); \
708 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
709 PyObject* obj = wxPyConstructObject(a, "wxPyControlPoint", 0); \
710 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
714 PCLASS::CBNAME(a, b, c, d, e); \
715 wxPySaveThread(doSave); \
717 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
719 PCLASS::CBNAME(a, b, c, d, e); \
722 //---------------------------------------------------------------------------
724 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
725 void CBNAME(double a, double b, int c); \
726 void base_##CBNAME(double a, double b, int c);
729 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
730 void CLASS::CBNAME(double a, double b, int c) { \
731 bool doSave = wxPyRestoreThread(); \
732 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
733 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
735 PCLASS::CBNAME(a, b, c); \
736 wxPySaveThread(doSave); \
738 void CLASS::base_##CBNAME(double a, double b, int c) { \
739 PCLASS::CBNAME(a, b, c); \
742 //---------------------------------------------------------------------------
744 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
745 void CBNAME(bool a, double b, double c, int d); \
746 void base_##CBNAME(bool a, double b, double c, int d);
749 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
750 void CLASS::CBNAME(bool a, double b, double c, int d) { \
751 bool doSave = wxPyRestoreThread(); \
752 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
753 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d)); \
755 PCLASS::CBNAME(a, b, c, d); \
756 wxPySaveThread(doSave); \
758 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
759 PCLASS::CBNAME(a, b, c, d); \
762 //---------------------------------------------------------------------------
763 //---------------------------------------------------------------------------
765 #define DEC_PYCALLBACK__STRING(CBNAME) \
766 void CBNAME(const wxString& a); \
767 void base_##CBNAME(const wxString& a);
770 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
771 void CLASS::CBNAME(const wxString& a) { \
772 bool doSave = wxPyRestoreThread(); \
773 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
774 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \
777 wxPySaveThread(doSave); \
779 void CLASS::base_##CBNAME(const wxString& a) { \
783 //---------------------------------------------------------------------------
785 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
786 bool CBNAME(const wxString& a); \
787 bool base_##CBNAME(const wxString& a);
790 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
791 bool CLASS::CBNAME(const wxString& a) { \
793 bool doSave = wxPyRestoreThread(); \
794 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
795 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \
797 rval = PCLASS::CBNAME(a); \
798 wxPySaveThread(doSave); \
801 bool CLASS::base_##CBNAME(const wxString& a) { \
802 return PCLASS::CBNAME(a); \
805 //---------------------------------------------------------------------------
807 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
808 bool CBNAME(const wxString& a);
810 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
811 bool CLASS::CBNAME(const wxString& a) { \
813 bool doSave = wxPyRestoreThread(); \
814 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
815 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str())); \
816 wxPySaveThread(doSave); \
820 //---------------------------------------------------------------------------
822 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
823 wxString CBNAME(const wxString& a); \
825 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
826 wxString CLASS::CBNAME(const wxString& a) { \
828 bool doSave = wxPyRestoreThread(); \
829 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
831 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(s)", a.c_str())); \
833 PyObject* str = PyObject_Str(ro); \
834 rval = PyString_AsString(str); \
835 Py_DECREF(ro); Py_DECREF(str); \
838 wxPySaveThread(doSave); \
842 //---------------------------------------------------------------------------
844 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
845 wxString CBNAME(const wxString& a,int b); \
847 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
848 wxString CLASS::CBNAME(const wxString& a,int b) { \
850 bool doSave = wxPyRestoreThread(); \
851 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
853 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(si)", a.c_str(),b)); \
855 PyObject* str = PyObject_Str(ro); \
856 rval = PyString_AsString(str); \
857 Py_DECREF(ro); Py_DECREF(str); \
860 wxPySaveThread(doSave); \
864 //---------------------------------------------------------------------------
866 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
867 bool CBNAME(const wxString& a, const wxString& b); \
868 bool base_##CBNAME(const wxString& a, const wxString& b);
871 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
872 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
874 bool doSave = wxPyRestoreThread(); \
875 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
876 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ss)", \
877 a.c_str(), b.c_str())); \
879 rval = PCLASS::CBNAME(a, b); \
880 wxPySaveThread(doSave); \
883 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
884 return PCLASS::CBNAME(a, b); \
887 //---------------------------------------------------------------------------
889 #define DEC_PYCALLBACK_STRING_(CBNAME) \
891 wxString base_##CBNAME();
894 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
895 wxString CLASS::CBNAME() { \
897 bool doSave = wxPyRestoreThread(); \
898 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
900 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
902 PyObject* str = PyObject_Str(ro); \
903 rval = PyString_AsString(str); \
904 Py_DECREF(ro); Py_DECREF(str); \
908 rval = PCLASS::CBNAME(); \
909 wxPySaveThread(doSave); \
912 wxString CLASS::base_##CBNAME() { \
913 return PCLASS::CBNAME(); \
916 //---------------------------------------------------------------------------
918 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
922 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
923 wxString CLASS::CBNAME() { \
925 bool doSave = wxPyRestoreThread(); \
926 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
928 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
930 PyObject* str = PyObject_Str(ro); \
931 rval = PyString_AsString(str); \
932 Py_DECREF(ro); Py_DECREF(str); \
935 wxPySaveThread(doSave); \
939 //---------------------------------------------------------------------------
941 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
942 bool CBNAME(const wxHtmlTag& a); \
945 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
946 bool CLASS::CBNAME(const wxHtmlTag& a) { \
948 bool doSave = wxPyRestoreThread(); \
949 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
950 PyObject* obj = wxPyConstructObject((void*)&a,"wxHtmlTag", 0); \
951 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
954 wxPySaveThread(doSave); \
958 //---------------------------------------------------------------------------
960 #define DEC_PYCALLBACK___pure(CBNAME) \
964 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
965 void CLASS::CBNAME() { \
966 bool doSave = wxPyRestoreThread(); \
967 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
968 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
969 wxPySaveThread(doSave); \
972 //---------------------------------------------------------------------------
974 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
978 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
979 wxSize CLASS::CBNAME() { \
981 bool doSave = wxPyRestoreThread(); \
982 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
985 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
987 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
992 wxPySaveThread(doSave); \
996 //---------------------------------------------------------------------------
998 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
999 bool CBNAME(wxWindow* a); \
1000 bool base_##CBNAME(wxWindow* a);
1003 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1004 bool CLASS::CBNAME(wxWindow* a) { \
1006 bool doSave = wxPyRestoreThread(); \
1007 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1008 PyObject* obj = wxPyConstructObject((void*)a,"wxWindow", 0);\
1009 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1013 rval = PCLASS::CBNAME(a); \
1014 wxPySaveThread(doSave); \
1017 bool CLASS::base_##CBNAME(wxWindow* a) { \
1018 return PCLASS::CBNAME(a); \
1021 //---------------------------------------------------------------------------
1023 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1025 bool base_##CBNAME();
1028 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1029 bool CLASS::CBNAME() { \
1031 bool doSave = wxPyRestoreThread(); \
1032 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1033 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1035 rval = PCLASS::CBNAME(); \
1036 wxPySaveThread(doSave); \
1039 bool CLASS::base_##CBNAME() { \
1040 return PCLASS::CBNAME(); \
1043 //---------------------------------------------------------------------------
1045 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1046 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
1047 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1050 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1051 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1052 bool doSave = wxPyRestoreThread(); \
1054 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1055 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1057 rval = PCLASS::CBNAME(a, b, c); \
1058 wxPySaveThread(doSave); \
1059 return (wxDragResult)rval; \
1061 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1062 return PCLASS::CBNAME(a, b, c); \
1065 //---------------------------------------------------------------------------
1067 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1068 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location); \
1070 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1071 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1072 bool doSave = wxPyRestoreThread(); \
1074 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1076 PyObject* obj = wxPyConstructObject(&a, "wxFileSystem", 0); \
1077 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Os)", \
1080 SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p"); \
1085 wxPySaveThread(doSave); \
1089 //---------------------------------------------------------------------------
1091 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1092 bool CBNAME(wxDragResult a); \
1093 bool base_##CBNAME(wxDragResult a);
1096 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1097 bool CLASS::CBNAME(wxDragResult a) { \
1098 bool doSave = wxPyRestoreThread(); \
1100 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1101 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1103 rval = PCLASS::CBNAME(a); \
1104 wxPySaveThread(doSave); \
1107 bool CLASS::base_##CBNAME(wxDragResult a) { \
1108 return PCLASS::CBNAME(a); \
1111 //---------------------------------------------------------------------------
1113 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1114 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
1117 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1118 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1119 bool doSave = wxPyRestoreThread(); \
1121 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1122 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1123 wxPySaveThread(doSave); \
1124 return (wxDragResult)rval; \
1127 //---------------------------------------------------------------------------
1129 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1130 bool CBNAME(int a, int b, const wxString& c);
1133 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1134 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1136 bool doSave = wxPyRestoreThread(); \
1137 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1138 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));\
1139 wxPySaveThread(doSave); \
1143 //---------------------------------------------------------------------------
1145 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1147 size_t base_##CBNAME();
1150 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1151 size_t CLASS::CBNAME() { \
1153 bool doSave = wxPyRestoreThread(); \
1154 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1155 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1157 rval = PCLASS::CBNAME(); \
1158 wxPySaveThread(doSave); \
1161 size_t CLASS::base_##CBNAME() { \
1162 return PCLASS::CBNAME(); \
1165 //---------------------------------------------------------------------------
1167 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1168 wxDataFormat CBNAME(); \
1169 wxDataFormat base_##CBNAME();
1172 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1173 wxDataFormat CLASS::CBNAME(size_t a) { \
1174 wxDataFormat rval; \
1175 bool doSave = wxPyRestoreThread(); \
1176 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1178 wxDataFormat* ptr; \
1179 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1181 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
1187 rval = PCLASS::CBNAME(a); \
1188 wxPySaveThread(doSave); \
1191 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1192 return PCLASS::CBNAME(a); \
1195 //---------------------------------------------------------------------------
1197 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1198 void CBNAME(const Type& a); \
1199 void base_##CBNAME(const Type& a);
1202 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1203 void CLASS::CBNAME(const Type& a) { \
1204 bool doSave = wxPyRestoreThread(); \
1205 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1206 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1207 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1211 PCLASS::CBNAME(a); \
1212 wxPySaveThread(doSave); \
1214 void CLASS::base_##CBNAME(const Type& a) { \
1215 PCLASS::CBNAME(a); \
1219 //---------------------------------------------------------------------------
1221 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1222 void CBNAME(Type& a); \
1223 void base_##CBNAME(Type& a);
1226 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1227 void CLASS::CBNAME(Type& a) { \
1228 bool doSave = wxPyRestoreThread(); \
1229 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1230 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1231 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1235 PCLASS::CBNAME(a); \
1236 wxPySaveThread(doSave); \
1238 void CLASS::base_##CBNAME(Type& a) { \
1239 PCLASS::CBNAME(a); \
1242 //---------------------------------------------------------------------------
1244 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1245 bool CBNAME(Type& a); \
1246 bool base_##CBNAME(Type& a);
1249 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1250 bool CLASS::CBNAME(Type& a) { \
1252 bool doSave = wxPyRestoreThread(); \
1253 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1254 PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0); \
1255 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1259 rv = PCLASS::CBNAME(a); \
1260 wxPySaveThread(doSave); \
1263 bool CLASS::base_##CBNAME(Type& a) { \
1264 return PCLASS::CBNAME(a); \
1267 //---------------------------------------------------------------------------