1 ////////////////////////////////////////////////////////////////////////////
3 // Purpose: Helper functions/classes for the wxPython extenaion module
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef __wxp_helpers__
14 #define __wxp_helpers__
19 //----------------------------------------------------------------------
21 // if we want to handle threads and Python threads are available...
22 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
24 #define WXP_WITH_THREAD
25 #define wxPy_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
26 #define wxPy_END_ALLOW_THREADS Py_END_ALLOW_THREADS
28 #else // no Python threads...
29 #undef WXP_WITH_THREAD
30 #define wxPy_BEGIN_ALLOW_THREADS
31 #define wxPy_END_ALLOW_THREADS
35 //---------------------------------------------------------------------------
37 #if defined(__WXMSW__)
38 # define HELPEREXPORT __declspec(dllexport)
43 typedef unsigned char byte
;
45 //----------------------------------------------------------------------
47 class wxPyApp
: public wxApp
54 //# void AfterMainLoop(void);
57 extern wxPyApp
*wxPythonApp
;
59 //----------------------------------------------------------------------
62 PyObject
* __wxStart(PyObject
*, PyObject
* args
);
65 extern PyObject
* wxPython_dict
;
66 PyObject
* __wxSetDictionary(PyObject
*, PyObject
* args
);
68 void wxPyEventThunker(wxObject
*, wxEvent
& event
);
70 HELPEREXPORT PyObject
* wxPyConstructObject(void* ptr
, const char* className
);
71 HELPEREXPORT
bool wxPyRestoreThread();
72 HELPEREXPORT
void wxPySaveThread(bool doSave
);
73 HELPEREXPORT PyObject
* wxPy_ConvertList(wxListBase
* list
, const char* className
);
74 HELPEREXPORT
long wxPyGetWinHandle(wxWindow
* win
);
76 //----------------------------------------------------------------------
78 class wxPyUserData
: public wxObject
{
80 wxPyUserData(PyObject
* obj
) { m_obj
= obj
; Py_INCREF(m_obj
); }
82 bool doSave
= wxPyRestoreThread();
84 wxPySaveThread(doSave
);
89 //----------------------------------------------------------------------
90 // These are helpers used by the typemaps
92 HELPEREXPORT byte
* byte_LIST_helper(PyObject
* source
);
93 HELPEREXPORT
int* int_LIST_helper(PyObject
* source
);
94 HELPEREXPORT
long* long_LIST_helper(PyObject
* source
);
95 HELPEREXPORT
char** string_LIST_helper(PyObject
* source
);
96 HELPEREXPORT wxPoint
* wxPoint_LIST_helper(PyObject
* source
);
97 HELPEREXPORT wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
98 HELPEREXPORT wxString
* wxString_LIST_helper(PyObject
* source
);
99 HELPEREXPORT wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
101 HELPEREXPORT
bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
102 HELPEREXPORT
bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
103 HELPEREXPORT
bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
104 HELPEREXPORT
bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
105 HELPEREXPORT
bool wxColour_helper(PyObject
* source
, wxColour
** obj
);
107 //----------------------------------------------------------------------
110 extern "C" void SWIG_MakePtr(char *, void *, char *);
111 extern "C" char *SWIG_GetPtr(char *, void **, char *);
112 extern "C" char *SWIG_GetPtrObj(PyObject
*obj
, void **ptr
, char *type
);
117 # pragma warning(disable:4800)
118 # pragma warning(disable:4190)
123 // Non-const versions to keep SWIG happy.
124 extern wxPoint wxPyDefaultPosition
;
125 extern wxSize wxPyDefaultSize
;
126 extern wxString wxPyEmptyStr
;
128 //----------------------------------------------------------------------
130 class wxPyCallback
: public wxObject
{
131 DECLARE_ABSTRACT_CLASS(wxPyCallback
);
133 wxPyCallback(PyObject
* func
);
134 wxPyCallback(const wxPyCallback
& other
);
137 void EventThunker(wxEvent
& event
);
142 //---------------------------------------------------------------------------
144 class wxPyTimer
: public wxTimer
{
146 wxPyTimer(PyObject
* callback
);
155 //---------------------------------------------------------------------------
160 //---------------------------------------------------------------------------
161 // This class holds an instance of a Python Shadow Class object and assists
162 // with looking up and invoking Python callback methods from C++ virtual
163 // method redirections. For all classes which have virtuals which should be
164 // overridable in wxPython, a new subclass is created that contains a
165 // wxPyCallbackHelper.
167 // TODO: This class should be combined with wxPyCallback defined above.
170 class HELPEREXPORT wxPyCallbackHelper
{
172 wxPyCallbackHelper();
173 ~wxPyCallbackHelper();
175 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
177 void setSelf(PyObject
* self
, PyObject
* _class
, int incref
=TRUE
);
179 bool findCallback(const wxString
& name
) const;
180 int callCallback(PyObject
* argTuple
) const;
181 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
186 PyObject
* m_lastFound
;
191 //---------------------------------------------------------------------------
192 //---------------------------------------------------------------------------
193 // These Event classes can be derived from in Python and passed through the
194 // event system without loosing anything. They do this by keeping a reference
195 // to themselves and some special case handling in wxPyCallback::EventThunker.
198 class wxPyEvtSelfRef
{
203 void SetSelf(PyObject
* self
, bool clone
=FALSE
);
204 PyObject
* GetSelf() const;
212 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
213 DECLARE_DYNAMIC_CLASS(wxPyEvent
)
218 void CopyObject(wxObject
& dest
) const;
222 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
223 DECLARE_DYNAMIC_CLASS(wxPyCommandEvent
)
225 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
228 void CopyObject(wxObject
& dest
) const;
232 //---------------------------------------------------------------------------
233 // These macros are used to implement the virtual methods that should
234 // redirect to a Python method if one exists. The names designate the
235 // return type, if any, as well as any parameter types.
236 //---------------------------------------------------------------------------
239 void _setSelf(PyObject* self, PyObject* _class, int incref=1) { \
240 m_myInst.setSelf(self, _class, incref); \
242 private: wxPyCallbackHelper m_myInst;
244 //---------------------------------------------------------------------------
246 #define DEC_PYCALLBACK__(CBNAME) \
248 void base_##CBNAME();
251 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
252 void CLASS::CBNAME() { \
253 bool doSave = wxPyRestoreThread(); \
254 if (m_myInst.findCallback(#CBNAME)) \
255 m_myInst.callCallback(Py_BuildValue("()")); \
258 wxPySaveThread(doSave); \
260 void CLASS::base_##CBNAME() { \
264 //---------------------------------------------------------------------------
266 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
267 bool CBNAME(int a, int b); \
268 bool base_##CBNAME(int a, int b);
271 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
272 bool CLASS::CBNAME(int a, int b) { \
274 bool doSave = wxPyRestoreThread(); \
275 if (m_myInst.findCallback(#CBNAME)) \
276 rval = m_myInst.callCallback(Py_BuildValue("(ii)",a,b)); \
278 rval = PCLASS::CBNAME(a,b); \
279 wxPySaveThread(doSave); \
282 bool CLASS::base_##CBNAME(int a, int b) { \
283 return PCLASS::CBNAME(a,b); \
286 //---------------------------------------------------------------------------
288 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
289 bool CBNAME(int a); \
290 bool base_##CBNAME(int a);
293 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
294 bool CLASS::CBNAME(int a) { \
296 bool doSave = wxPyRestoreThread(); \
297 if (m_myInst.findCallback(#CBNAME)) \
298 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
300 rval = PCLASS::CBNAME(a); \
301 wxPySaveThread(doSave); \
304 bool CLASS::base_##CBNAME(int a) { \
305 return PCLASS::CBNAME(a); \
308 //---------------------------------------------------------------------------
310 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
314 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
315 bool CLASS::CBNAME(int a) { \
317 bool doSave = wxPyRestoreThread(); \
318 if (m_myInst.findCallback(#CBNAME)) \
319 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
321 wxPySaveThread(doSave); \
326 //---------------------------------------------------------------------------
328 #define DEC_PYCALLBACK__DC(CBNAME) \
329 void CBNAME(wxDC& a); \
330 void base_##CBNAME(wxDC& a);
333 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
334 void CLASS::CBNAME(wxDC& a) { \
335 bool doSave = wxPyRestoreThread(); \
336 if (m_myInst.findCallback(#CBNAME)) \
337 m_myInst.callCallback(Py_BuildValue("(O)", \
338 wxPyConstructObject(&a, "wxDC"))); \
341 wxPySaveThread(doSave); \
343 void CLASS::base_##CBNAME(wxDC& a) { \
349 //---------------------------------------------------------------------------
351 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
352 void CBNAME(wxDC& a, bool b); \
353 void base_##CBNAME(wxDC& a, bool b);
356 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
357 void CLASS::CBNAME(wxDC& a, bool b) { \
358 bool doSave = wxPyRestoreThread(); \
359 if (m_myInst.findCallback(#CBNAME)) \
360 m_myInst.callCallback(Py_BuildValue("(Oi)", \
361 wxPyConstructObject(&a, "wxDC"), (int)b)); \
363 PCLASS::CBNAME(a, b); \
364 wxPySaveThread(doSave); \
366 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
367 PCLASS::CBNAME(a, b); \
370 //---------------------------------------------------------------------------
372 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
373 void CBNAME(wxDC& a, bool b); \
374 void base_##CBNAME(wxDC& a, bool b);
377 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
378 void CLASS::CBNAME(wxDC& a, bool b) { \
379 bool doSave = wxPyRestoreThread(); \
380 if (m_myInst.findCallback(#CBNAME)) \
381 m_myInst.callCallback(Py_BuildValue("(Oi)", \
382 wxPyConstructObject(&a, "wxDC"), (int)b)); \
384 PCLASS::CBNAME(a, b); \
385 wxPySaveThread(doSave); \
387 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
388 PCLASS::CBNAME(a, b); \
391 //---------------------------------------------------------------------------
393 #define DEC_PYCALLBACK__2DBL(CBNAME) \
394 void CBNAME(double a, double b); \
395 void base_##CBNAME(double a, double b);
398 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
399 void CLASS::CBNAME(double a, double b) { \
400 bool doSave = wxPyRestoreThread(); \
401 if (m_myInst.findCallback(#CBNAME)) \
402 m_myInst.callCallback(Py_BuildValue("(dd)",a,b)); \
404 PCLASS::CBNAME(a, b); \
405 wxPySaveThread(doSave); \
407 void CLASS::base_##CBNAME(double a, double b) { \
408 PCLASS::CBNAME(a, b); \
411 //---------------------------------------------------------------------------
413 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
414 void CBNAME(double a, double b, int c, int d); \
415 void base_##CBNAME(double a, double b, int c, int d);
418 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
419 void CLASS::CBNAME(double a, double b, int c, int d) { \
420 bool doSave = wxPyRestoreThread(); \
421 if (m_myInst.findCallback(#CBNAME)) \
422 m_myInst.callCallback(Py_BuildValue("(ddii)", \
425 PCLASS::CBNAME(a, b, c, d); \
426 wxPySaveThread(doSave); \
428 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
429 PCLASS::CBNAME(a, b, c, d); \
432 //---------------------------------------------------------------------------
434 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
435 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
436 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
439 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
440 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
441 bool doSave = wxPyRestoreThread(); \
442 if (m_myInst.findCallback(#CBNAME)) \
443 m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
444 wxPyConstructObject(&a, "wxDC"), \
445 b, c, d, e, (int)f)); \
447 PCLASS::CBNAME(a, b, c, d, e, f); \
448 wxPySaveThread(doSave); \
450 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
451 PCLASS::CBNAME(a, b, c, d, e, f); \
454 //---------------------------------------------------------------------------
456 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
457 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
458 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
461 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
462 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
463 bool doSave = wxPyRestoreThread(); \
465 if (m_myInst.findCallback(#CBNAME)) \
466 rval = m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
467 wxPyConstructObject(&a, "wxDC"), \
468 b, c, d, e, (int)f)); \
470 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
471 wxPySaveThread(doSave); \
474 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
475 return PCLASS::CBNAME(a, b, c, d, e, f); \
478 //---------------------------------------------------------------------------
480 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
481 void CBNAME(bool a, double b, double c, int d, int e); \
482 void base_##CBNAME(bool a, double b, double c, int d, int e);
485 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
486 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
487 bool doSave = wxPyRestoreThread(); \
488 if (m_myInst.findCallback(#CBNAME)) \
489 m_myInst.callCallback(Py_BuildValue("(idii)", \
492 PCLASS::CBNAME(a, b, c, d, e); \
493 wxPySaveThread(doSave); \
495 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
496 PCLASS::CBNAME(a, b, c, d, e); \
499 //---------------------------------------------------------------------------
501 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
502 void CBNAME(wxDC& a, double b, double c, double d, double e); \
503 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
506 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
507 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
508 bool doSave = wxPyRestoreThread(); \
509 if (m_myInst.findCallback(#CBNAME)) \
510 m_myInst.callCallback(Py_BuildValue("(Odddd)", \
511 wxPyConstructObject(&a, "wxDC"), \
514 PCLASS::CBNAME(a, b, c, d, e); \
515 wxPySaveThread(doSave); \
517 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
518 PCLASS::CBNAME(a, b, c, d, e); \
521 //---------------------------------------------------------------------------
523 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
524 void CBNAME(wxDC& a, bool b); \
525 void base_##CBNAME(wxDC& a, bool b);
528 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
529 void CLASS::CBNAME(wxDC& a, bool b) { \
530 bool doSave = wxPyRestoreThread(); \
531 if (m_myInst.findCallback(#CBNAME)) \
532 m_myInst.callCallback(Py_BuildValue("(Oi)", \
533 wxPyConstructObject(&a, "wxDC"), \
536 PCLASS::CBNAME(a, b); \
537 wxPySaveThread(doSave); \
539 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
540 PCLASS::CBNAME(a, b); \
543 //---------------------------------------------------------------------------
545 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
546 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
547 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
550 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
551 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
553 bool doSave = wxPyRestoreThread(); \
554 if (m_myInst.findCallback(#CBNAME)) \
555 m_myInst.callCallback(Py_BuildValue("(Oiddii)", \
556 wxPyConstructObject(a, "wxPyControlPoint"), \
557 (int)b, c, d, e, f)); \
559 PCLASS::CBNAME(a, b, c, d, e, f); \
560 wxPySaveThread(doSave); \
562 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
564 PCLASS::CBNAME(a, b, c, d, e, f); \
567 //---------------------------------------------------------------------------
569 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
570 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
571 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
574 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
575 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
576 bool doSave = wxPyRestoreThread(); \
577 if (m_myInst.findCallback(#CBNAME)) \
578 m_myInst.callCallback(Py_BuildValue("(Oddii)", \
579 wxPyConstructObject(a, "wxPyControlPoint"), \
582 PCLASS::CBNAME(a, b, c, d, e); \
583 wxPySaveThread(doSave); \
585 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
587 PCLASS::CBNAME(a, b, c, d, e); \
590 //---------------------------------------------------------------------------
592 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
593 void CBNAME(double a, double b, int c); \
594 void base_##CBNAME(double a, double b, int c);
597 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
598 void CLASS::CBNAME(double a, double b, int c) { \
599 bool doSave = wxPyRestoreThread(); \
600 if (m_myInst.findCallback(#CBNAME)) \
601 m_myInst.callCallback(Py_BuildValue("(ddi)", a,b,c)); \
603 PCLASS::CBNAME(a, b, c); \
604 wxPySaveThread(doSave); \
606 void CLASS::base_##CBNAME(double a, double b, int c) { \
607 PCLASS::CBNAME(a, b, c); \
610 //---------------------------------------------------------------------------
612 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
613 void CBNAME(bool a, double b, double c, int d); \
614 void base_##CBNAME(bool a, double b, double c, int d);
617 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
618 void CLASS::CBNAME(bool a, double b, double c, int d) { \
619 bool doSave = wxPyRestoreThread(); \
620 if (m_myInst.findCallback(#CBNAME)) \
621 m_myInst.callCallback(Py_BuildValue("(iddi)", (int)a,b,c,d)); \
623 PCLASS::CBNAME(a, b, c, d); \
624 wxPySaveThread(doSave); \
626 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
627 PCLASS::CBNAME(a, b, c, d); \
630 //---------------------------------------------------------------------------
631 //---------------------------------------------------------------------------
633 #define DEC_PYCALLBACK__STRING(CBNAME) \
634 void CBNAME(const wxString& a); \
635 void base_##CBNAME(const wxString& a);
638 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
639 void CLASS::CBNAME(const wxString& a) { \
640 bool doSave = wxPyRestoreThread(); \
641 if (m_myInst.findCallback(#CBNAME)) \
642 m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
645 wxPySaveThread(doSave); \
647 void CLASS::base_##CBNAME(const wxString& a) { \
651 //---------------------------------------------------------------------------
653 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
654 bool CBNAME(const wxString& a); \
655 bool base_##CBNAME(const wxString& a);
658 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
659 bool CLASS::CBNAME(const wxString& a) { \
661 bool doSave = wxPyRestoreThread(); \
662 if (m_myInst.findCallback(#CBNAME)) \
663 rval = m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
665 rval = PCLASS::CBNAME(a); \
666 wxPySaveThread(doSave); \
669 bool CLASS::base_##CBNAME(const wxString& a) { \
670 return PCLASS::CBNAME(a); \
673 //---------------------------------------------------------------------------
675 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
676 bool CBNAME(const wxString& a, const wxString& b); \
677 bool base_##CBNAME(const wxString& a, const wxString& b);
680 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
681 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
683 bool doSave = wxPyRestoreThread(); \
684 if (m_myInst.findCallback(#CBNAME)) \
685 rval = m_myInst.callCallback(Py_BuildValue("(ss)", \
686 a.c_str(), b.c_str())); \
688 rval = PCLASS::CBNAME(a, b); \
689 wxPySaveThread(doSave); \
692 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
693 return PCLASS::CBNAME(a, b); \
696 //---------------------------------------------------------------------------
698 #define DEC_PYCALLBACK_STRING_(CBNAME) \
700 wxString base_##CBNAME();
703 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
704 wxString CLASS::CBNAME() { \
706 bool doSave = wxPyRestoreThread(); \
707 if (m_myInst.findCallback(#CBNAME)) { \
709 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
711 rval = PyString_AsString(PyObject_Str(ro)); \
716 rval = PCLASS::CBNAME(); \
717 wxPySaveThread(doSave); \
720 wxString CLASS::base_##CBNAME() { \
721 return PCLASS::CBNAME(); \
724 //---------------------------------------------------------------------------
726 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
730 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
731 wxString CLASS::CBNAME() { \
733 bool doSave = wxPyRestoreThread(); \
734 if (m_myInst.findCallback(#CBNAME)) { \
736 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
738 rval = PyString_AsString(PyObject_Str(ro)); \
742 wxPySaveThread(doSave); \
746 //---------------------------------------------------------------------------
748 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
749 bool CBNAME(const wxHtmlTag& a); \
752 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
753 bool CLASS::CBNAME(const wxHtmlTag& a) { \
755 bool doSave = wxPyRestoreThread(); \
756 if (m_myInst.findCallback(#CBNAME)) \
757 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
758 wxPyConstructObject((void*)&a,"wxHtmlTag"))); \
759 wxPySaveThread(doSave); \
763 //---------------------------------------------------------------------------
765 #define DEC_PYCALLBACK___pure(CBNAME) \
769 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
770 void CLASS::CBNAME() { \
771 bool doSave = wxPyRestoreThread(); \
772 if (m_myInst.findCallback(#CBNAME)) \
773 m_myInst.callCallback(Py_BuildValue("()")); \
774 wxPySaveThread(doSave); \
777 //---------------------------------------------------------------------------
779 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
783 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
784 wxSize CLASS::CBNAME() { \
786 bool doSave = wxPyRestoreThread(); \
787 if (m_myInst.findCallback(#CBNAME)) { \
790 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
792 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
797 wxPySaveThread(doSave); \
801 //---------------------------------------------------------------------------
803 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
804 bool CBNAME(wxWindow* a); \
805 bool base_##CBNAME(wxWindow* a);
808 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
809 bool CLASS::CBNAME(wxWindow* a) { \
811 bool doSave = wxPyRestoreThread(); \
812 if (m_myInst.findCallback(#CBNAME)) \
813 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
814 wxPyConstructObject((void*)a,"wxWindow"))); \
816 rval = PCLASS::CBNAME(a); \
817 wxPySaveThread(doSave); \
820 bool CLASS::base_##CBNAME(wxWindow* a) { \
821 return PCLASS::CBNAME(a); \
824 //---------------------------------------------------------------------------
826 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
828 bool base_##CBNAME();
831 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
832 bool CLASS::CBNAME() { \
834 bool doSave = wxPyRestoreThread(); \
835 if (m_myInst.findCallback(#CBNAME)) \
836 rval = m_myInst.callCallback(Py_BuildValue("()")); \
838 rval = PCLASS::CBNAME(); \
839 wxPySaveThread(doSave); \
842 bool CLASS::base_##CBNAME() { \
843 return PCLASS::CBNAME(); \
846 //---------------------------------------------------------------------------
848 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
849 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
850 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
853 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
854 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
855 bool doSave = wxPyRestoreThread(); \
857 if (m_myInst.findCallback(#CBNAME)) \
858 rval = m_myInst.callCallback(Py_BuildValue("(iii)", a,b,c));\
860 rval = PCLASS::CBNAME(a, b, c); \
861 wxPySaveThread(doSave); \
862 return (wxDragResult)rval; \
864 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
865 return PCLASS::CBNAME(a, b, c); \
868 //---------------------------------------------------------------------------
870 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
871 bool CBNAME(wxDragResult a); \
872 bool base_##CBNAME(wxDragResult a);
875 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
876 bool CLASS::CBNAME(wxDragResult a) { \
877 bool doSave = wxPyRestoreThread(); \
879 if (m_myInst.findCallback(#CBNAME)) \
880 rval = m_myInst.callCallback(Py_BuildValue("(i)", a)); \
882 rval = PCLASS::CBNAME(a); \
883 wxPySaveThread(doSave); \
886 bool CLASS::base_##CBNAME(wxDragResult a) { \
887 return PCLASS::CBNAME(a); \
890 //---------------------------------------------------------------------------
892 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
893 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
896 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
897 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
898 bool doSave = wxPyRestoreThread(); \
900 if (m_myInst.findCallback(#CBNAME)) \
901 rval = m_myInst.callCallback(Py_BuildValue("(iii)", a,b,c));\
902 wxPySaveThread(doSave); \
903 return (wxDragResult)rval; \
906 //---------------------------------------------------------------------------
908 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
909 bool CBNAME(int a, int b, const wxString& c);
912 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
913 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
915 bool doSave = wxPyRestoreThread(); \
916 if (m_myInst.findCallback(#CBNAME)) \
917 rval = m_myInst.callCallback(Py_BuildValue("(iis)",a,b,c.c_str()));\
918 wxPySaveThread(doSave); \
922 //---------------------------------------------------------------------------
924 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
926 size_t base_##CBNAME();
929 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
930 size_t CLASS::CBNAME() { \
932 bool doSave = wxPyRestoreThread(); \
933 if (m_myInst.findCallback(#CBNAME)) \
934 rval = m_myInst.callCallback(Py_BuildValue("()")); \
936 rval = PCLASS::CBNAME(); \
937 wxPySaveThread(doSave); \
940 size_t CLASS::base_##CBNAME() { \
941 return PCLASS::CBNAME(); \
944 //---------------------------------------------------------------------------
946 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
947 wxDataFormat CBNAME(); \
948 wxDataFormat base_##CBNAME();
951 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
952 wxDataFormat CLASS::CBNAME(size_t a) { \
954 bool doSave = wxPyRestoreThread(); \
955 if (m_myInst.findCallback(#CBNAME)) { \
958 ro = m_myInst.callCallbackObj(Py_BuildValue("(i)", a)); \
960 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
966 rval = PCLASS::CBNAME(a); \
967 wxPySaveThread(doSave); \
970 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
971 return PCLASS::CBNAME(a); \
974 //---------------------------------------------------------------------------
976 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
977 void CBNAME(const Type& a); \
978 void base_##CBNAME(const Type& a);
981 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
982 void CLASS::CBNAME(const Type& a) { \
983 bool doSave = wxPyRestoreThread(); \
984 if (m_myInst.findCallback(#CBNAME)) \
985 m_myInst.callCallback(Py_BuildValue("(O)", \
986 wxPyConstructObject((void*)&a, #Type))); \
989 wxPySaveThread(doSave); \
991 void CLASS::base_##CBNAME(const Type& a) { \
996 //---------------------------------------------------------------------------
998 #define DEC_PYCALLBACK__any(CBNAME, Type) \
999 void CBNAME(Type& a); \
1000 void base_##CBNAME(Type& a);
1003 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1004 void CLASS::CBNAME(Type& a) { \
1005 bool doSave = wxPyRestoreThread(); \
1006 if (m_myInst.findCallback(#CBNAME)) \
1007 m_myInst.callCallback(Py_BuildValue("(O)", \
1008 wxPyConstructObject(&a, #Type))); \
1010 PCLASS::CBNAME(a); \
1011 wxPySaveThread(doSave); \
1013 void CLASS::base_##CBNAME(Type& a) { \
1014 PCLASS::CBNAME(a); \
1017 //---------------------------------------------------------------------------
1019 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1020 bool CBNAME(Type& a); \
1021 bool base_##CBNAME(Type& a);
1024 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1025 bool CLASS::CBNAME(Type& a) { \
1027 bool doSave = wxPyRestoreThread(); \
1028 if (m_myInst.findCallback(#CBNAME)) \
1029 rv = m_myInst.callCallback(Py_BuildValue("(O)", \
1030 wxPyConstructObject(&a, #Type))); \
1032 rv = PCLASS::CBNAME(a); \
1033 wxPySaveThread(doSave); \
1036 bool CLASS::base_##CBNAME(Type& a) { \
1037 return PCLASS::CBNAME(a); \
1040 //---------------------------------------------------------------------------