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
);
106 //----------------------------------------------------------------------
109 extern "C" void SWIG_MakePtr(char *, void *, char *);
110 extern "C" char *SWIG_GetPtr(char *, void **, char *);
111 extern "C" char *SWIG_GetPtrObj(PyObject
*obj
, void **ptr
, char *type
);
116 # pragma warning(disable:4800)
121 // Non-const versions to keep SWIG happy.
122 extern wxPoint wxPyDefaultPosition
;
123 extern wxSize wxPyDefaultSize
;
124 extern wxString wxPyEmptyStr
;
126 //----------------------------------------------------------------------
128 class wxPyCallback
: public wxObject
{
129 DECLARE_ABSTRACT_CLASS(wxPyCallback
);
131 wxPyCallback(PyObject
* func
);
132 wxPyCallback(const wxPyCallback
& other
);
135 void EventThunker(wxEvent
& event
);
140 //---------------------------------------------------------------------------
142 class wxPyTimer
: public wxTimer
{
144 wxPyTimer(PyObject
* callback
);
153 //---------------------------------------------------------------------------
158 //---------------------------------------------------------------------------
159 // This class holds an instance of a Python Shadow Class object and assists
160 // with looking up and invoking Python callback methods from C++ virtual
161 // method redirections. For all classes which have virtuals which should be
162 // overridable in wxPython, a new subclass is created that contains a
163 // wxPyCallbackHelper.
165 // **** This class should be combined with wxPyCallback defined above.
168 class HELPEREXPORT wxPyCallbackHelper
{
170 wxPyCallbackHelper();
171 ~wxPyCallbackHelper();
173 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
175 void setSelf(PyObject
* self
, int incref
=TRUE
);
177 bool findCallback(const wxString
& name
);
178 int callCallback(PyObject
* argTuple
);
179 PyObject
* callCallbackObj(PyObject
* argTuple
);
183 PyObject
* m_lastFound
;
188 //---------------------------------------------------------------------------
189 //---------------------------------------------------------------------------
190 // These Event classes can be derived from in Python and passed through the
191 // event system without loosing anything. They do this by keeping a reference
192 // to themselves and some special case handling in wxPyCallback::EventThunker.
195 class wxPyEvtSelfRef
{
200 void SetSelf(PyObject
* self
, bool clone
=FALSE
);
201 PyObject
* GetSelf() const;
209 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
210 DECLARE_DYNAMIC_CLASS(wxPyEvent
)
215 void CopyObject(wxObject
& dest
) const;
219 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
220 DECLARE_DYNAMIC_CLASS(wxPyCommandEvent
)
222 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
225 void CopyObject(wxObject
& dest
) const;
229 //---------------------------------------------------------------------------
230 // These macros are used to implement the virtual methods that should
231 // redirect to a Python method if one exists. The names designate the
232 // return type, if any, as well as any parameter types.
233 //---------------------------------------------------------------------------
236 void _setSelf(PyObject* self, int incref=1) { \
237 m_myInst.setSelf(self, incref); \
239 private: wxPyCallbackHelper m_myInst;
241 //---------------------------------------------------------------------------
243 #define DEC_PYCALLBACK__(CBNAME) \
245 void base_##CBNAME();
248 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
249 void CLASS::CBNAME() { \
250 bool doSave = wxPyRestoreThread(); \
251 if (m_myInst.findCallback(#CBNAME)) \
252 m_myInst.callCallback(Py_BuildValue("()")); \
255 wxPySaveThread(doSave); \
257 void CLASS::base_##CBNAME() { \
261 //---------------------------------------------------------------------------
263 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
264 bool CBNAME(int a, int b); \
265 bool base_##CBNAME(int a, int b);
268 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
269 bool CLASS::CBNAME(int a, int b) { \
271 bool doSave = wxPyRestoreThread(); \
272 if (m_myInst.findCallback(#CBNAME)) \
273 rval = m_myInst.callCallback(Py_BuildValue("(ii)",a,b)); \
275 rval = PCLASS::CBNAME(a,b); \
276 wxPySaveThread(doSave); \
279 bool CLASS::base_##CBNAME(int a, int b) { \
280 return PCLASS::CBNAME(a,b); \
283 //---------------------------------------------------------------------------
285 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
286 bool CBNAME(int a); \
287 bool base_##CBNAME(int a);
290 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
291 bool CLASS::CBNAME(int a) { \
293 bool doSave = wxPyRestoreThread(); \
294 if (m_myInst.findCallback(#CBNAME)) \
295 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
297 rval = PCLASS::CBNAME(a); \
298 wxPySaveThread(doSave); \
301 bool CLASS::base_##CBNAME(int a) { \
302 return PCLASS::CBNAME(a); \
305 //---------------------------------------------------------------------------
307 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
311 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
312 bool CLASS::CBNAME(int a) { \
314 bool doSave = wxPyRestoreThread(); \
315 if (m_myInst.findCallback(#CBNAME)) \
316 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
318 wxPySaveThread(doSave); \
323 //---------------------------------------------------------------------------
325 #define DEC_PYCALLBACK__DC(CBNAME) \
326 void CBNAME(wxDC& a); \
327 void base_##CBNAME(wxDC& a);
330 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
331 void CLASS::CBNAME(wxDC& a) { \
332 bool doSave = wxPyRestoreThread(); \
333 if (m_myInst.findCallback(#CBNAME)) \
334 m_myInst.callCallback(Py_BuildValue("(O)", \
335 wxPyConstructObject(&a, "wxDC"))); \
338 wxPySaveThread(doSave); \
340 void CLASS::base_##CBNAME(wxDC& a) { \
346 //---------------------------------------------------------------------------
348 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
349 void CBNAME(wxDC& a, bool b); \
350 void base_##CBNAME(wxDC& a, bool b);
353 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
354 void CLASS::CBNAME(wxDC& a, bool b) { \
355 bool doSave = wxPyRestoreThread(); \
356 if (m_myInst.findCallback(#CBNAME)) \
357 m_myInst.callCallback(Py_BuildValue("(Oi)", \
358 wxPyConstructObject(&a, "wxDC"), (int)b)); \
360 PCLASS::CBNAME(a, b); \
361 wxPySaveThread(doSave); \
363 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
364 PCLASS::CBNAME(a, b); \
367 //---------------------------------------------------------------------------
369 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
370 void CBNAME(wxDC& a, bool b); \
371 void base_##CBNAME(wxDC& a, bool b);
374 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
375 void CLASS::CBNAME(wxDC& a, bool b) { \
376 bool doSave = wxPyRestoreThread(); \
377 if (m_myInst.findCallback(#CBNAME)) \
378 m_myInst.callCallback(Py_BuildValue("(Oi)", \
379 wxPyConstructObject(&a, "wxDC"), (int)b)); \
381 PCLASS::CBNAME(a, b); \
382 wxPySaveThread(doSave); \
384 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
385 PCLASS::CBNAME(a, b); \
388 //---------------------------------------------------------------------------
390 #define DEC_PYCALLBACK__2DBL(CBNAME) \
391 void CBNAME(double a, double b); \
392 void base_##CBNAME(double a, double b);
395 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
396 void CLASS::CBNAME(double a, double b) { \
397 bool doSave = wxPyRestoreThread(); \
398 if (m_myInst.findCallback(#CBNAME)) \
399 m_myInst.callCallback(Py_BuildValue("(dd)",a,b)); \
401 PCLASS::CBNAME(a, b); \
402 wxPySaveThread(doSave); \
404 void CLASS::base_##CBNAME(double a, double b) { \
405 PCLASS::CBNAME(a, b); \
408 //---------------------------------------------------------------------------
410 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
411 void CBNAME(double a, double b, int c, int d); \
412 void base_##CBNAME(double a, double b, int c, int d);
415 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
416 void CLASS::CBNAME(double a, double b, int c, int d) { \
417 bool doSave = wxPyRestoreThread(); \
418 if (m_myInst.findCallback(#CBNAME)) \
419 m_myInst.callCallback(Py_BuildValue("(ddii)", \
422 PCLASS::CBNAME(a, b, c, d); \
423 wxPySaveThread(doSave); \
425 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
426 PCLASS::CBNAME(a, b, c, d); \
429 //---------------------------------------------------------------------------
431 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
432 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
433 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
436 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
437 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
438 bool doSave = wxPyRestoreThread(); \
439 if (m_myInst.findCallback(#CBNAME)) \
440 m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
441 wxPyConstructObject(&a, "wxDC"), \
442 b, c, d, e, (int)f)); \
444 PCLASS::CBNAME(a, b, c, d, e, f); \
445 wxPySaveThread(doSave); \
447 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
448 PCLASS::CBNAME(a, b, c, d, e, f); \
451 //---------------------------------------------------------------------------
453 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
454 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
455 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
458 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
459 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
460 bool doSave = wxPyRestoreThread(); \
462 if (m_myInst.findCallback(#CBNAME)) \
463 rval = m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
464 wxPyConstructObject(&a, "wxDC"), \
465 b, c, d, e, (int)f)); \
467 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
468 wxPySaveThread(doSave); \
471 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
472 return PCLASS::CBNAME(a, b, c, d, e, f); \
475 //---------------------------------------------------------------------------
477 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
478 void CBNAME(bool a, double b, double c, int d, int e); \
479 void base_##CBNAME(bool a, double b, double c, int d, int e);
482 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
483 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
484 bool doSave = wxPyRestoreThread(); \
485 if (m_myInst.findCallback(#CBNAME)) \
486 m_myInst.callCallback(Py_BuildValue("(idii)", \
489 PCLASS::CBNAME(a, b, c, d, e); \
490 wxPySaveThread(doSave); \
492 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
493 PCLASS::CBNAME(a, b, c, d, e); \
496 //---------------------------------------------------------------------------
498 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
499 void CBNAME(wxDC& a, double b, double c, double d, double e); \
500 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
503 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
504 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
505 bool doSave = wxPyRestoreThread(); \
506 if (m_myInst.findCallback(#CBNAME)) \
507 m_myInst.callCallback(Py_BuildValue("(Odddd)", \
508 wxPyConstructObject(&a, "wxDC"), \
511 PCLASS::CBNAME(a, b, c, d, e); \
512 wxPySaveThread(doSave); \
514 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
515 PCLASS::CBNAME(a, b, c, d, e); \
518 //---------------------------------------------------------------------------
520 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
521 void CBNAME(wxDC& a, bool b); \
522 void base_##CBNAME(wxDC& a, bool b);
525 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
526 void CLASS::CBNAME(wxDC& a, bool b) { \
527 bool doSave = wxPyRestoreThread(); \
528 if (m_myInst.findCallback(#CBNAME)) \
529 m_myInst.callCallback(Py_BuildValue("(Oi)", \
530 wxPyConstructObject(&a, "wxDC"), \
533 PCLASS::CBNAME(a, b); \
534 wxPySaveThread(doSave); \
536 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
537 PCLASS::CBNAME(a, b); \
540 //---------------------------------------------------------------------------
542 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
543 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
544 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
547 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
548 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
550 bool doSave = wxPyRestoreThread(); \
551 if (m_myInst.findCallback(#CBNAME)) \
552 m_myInst.callCallback(Py_BuildValue("(Oiddii)", \
553 wxPyConstructObject(a, "wxPyControlPoint"), \
554 (int)b, c, d, e, f)); \
556 PCLASS::CBNAME(a, b, c, d, e, f); \
557 wxPySaveThread(doSave); \
559 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
561 PCLASS::CBNAME(a, b, c, d, e, f); \
564 //---------------------------------------------------------------------------
566 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
567 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
568 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
571 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
572 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
573 bool doSave = wxPyRestoreThread(); \
574 if (m_myInst.findCallback(#CBNAME)) \
575 m_myInst.callCallback(Py_BuildValue("(Oddii)", \
576 wxPyConstructObject(a, "wxPyControlPoint"), \
579 PCLASS::CBNAME(a, b, c, d, e); \
580 wxPySaveThread(doSave); \
582 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
584 PCLASS::CBNAME(a, b, c, d, e); \
587 //---------------------------------------------------------------------------
589 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
590 void CBNAME(double a, double b, int c); \
591 void base_##CBNAME(double a, double b, int c);
594 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
595 void CLASS::CBNAME(double a, double b, int c) { \
596 bool doSave = wxPyRestoreThread(); \
597 if (m_myInst.findCallback(#CBNAME)) \
598 m_myInst.callCallback(Py_BuildValue("(ddi)", a,b,c)); \
600 PCLASS::CBNAME(a, b, c); \
601 wxPySaveThread(doSave); \
603 void CLASS::base_##CBNAME(double a, double b, int c) { \
604 PCLASS::CBNAME(a, b, c); \
607 //---------------------------------------------------------------------------
609 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
610 void CBNAME(bool a, double b, double c, int d); \
611 void base_##CBNAME(bool a, double b, double c, int d);
614 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
615 void CLASS::CBNAME(bool a, double b, double c, int d) { \
616 bool doSave = wxPyRestoreThread(); \
617 if (m_myInst.findCallback(#CBNAME)) \
618 m_myInst.callCallback(Py_BuildValue("(iddi)", (int)a,b,c,d)); \
620 PCLASS::CBNAME(a, b, c, d); \
621 wxPySaveThread(doSave); \
623 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
624 PCLASS::CBNAME(a, b, c, d); \
627 //---------------------------------------------------------------------------
628 //---------------------------------------------------------------------------
630 #define DEC_PYCALLBACK__STRING(CBNAME) \
631 void CBNAME(const wxString& a); \
632 void base_##CBNAME(const wxString& a);
635 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
636 void CLASS::CBNAME(const wxString& a) { \
637 bool doSave = wxPyRestoreThread(); \
638 if (m_myInst.findCallback(#CBNAME)) \
639 m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
642 wxPySaveThread(doSave); \
644 void CLASS::base_##CBNAME(const wxString& a) { \
648 //---------------------------------------------------------------------------
650 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
651 bool CBNAME(const wxString& a); \
652 bool base_##CBNAME(const wxString& a);
655 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
656 bool CLASS::CBNAME(const wxString& a) { \
658 bool doSave = wxPyRestoreThread(); \
659 if (m_myInst.findCallback(#CBNAME)) \
660 rval = m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
662 rval = PCLASS::CBNAME(a); \
663 wxPySaveThread(doSave); \
666 bool CLASS::base_##CBNAME(const wxString& a) { \
667 return PCLASS::CBNAME(a); \
670 //---------------------------------------------------------------------------
672 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
673 bool CBNAME(const wxString& a, const wxString& b); \
674 bool base_##CBNAME(const wxString& a, const wxString& b);
677 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
678 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
680 bool doSave = wxPyRestoreThread(); \
681 if (m_myInst.findCallback(#CBNAME)) \
682 rval = m_myInst.callCallback(Py_BuildValue("(ss)", \
683 a.c_str(), b.c_str())); \
685 rval = PCLASS::CBNAME(a, b); \
686 wxPySaveThread(doSave); \
689 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
690 return PCLASS::CBNAME(a, b); \
693 //---------------------------------------------------------------------------
695 #define DEC_PYCALLBACK_STRING_(CBNAME) \
697 wxString base_##CBNAME();
700 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
701 wxString CLASS::CBNAME() { \
703 bool doSave = wxPyRestoreThread(); \
704 if (m_myInst.findCallback(#CBNAME)) { \
706 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
707 rval = PyString_AsString(PyObject_Str(ro)); \
710 rval = PCLASS::CBNAME(); \
711 wxPySaveThread(doSave); \
714 wxString CLASS::base_##CBNAME() { \
715 return PCLASS::CBNAME(); \
718 //---------------------------------------------------------------------------
720 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
724 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
725 wxString CLASS::CBNAME() { \
727 bool doSave = wxPyRestoreThread(); \
728 if (m_myInst.findCallback(#CBNAME)) { \
730 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
731 rval = PyString_AsString(PyObject_Str(ro)); \
733 wxPySaveThread(doSave); \
737 //---------------------------------------------------------------------------
739 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
740 bool CBNAME(const wxHtmlTag& a); \
743 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
744 bool CLASS::CBNAME(const wxHtmlTag& a) { \
746 bool doSave = wxPyRestoreThread(); \
747 if (m_myInst.findCallback(#CBNAME)) \
748 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
749 wxPyConstructObject((void*)&a,"wxHtmlTag"))); \
750 wxPySaveThread(doSave); \
754 //---------------------------------------------------------------------------
756 #define DEC_PYCALLBACK___pure(CBNAME) \
760 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
761 void CLASS::CBNAME() { \
762 bool doSave = wxPyRestoreThread(); \
763 if (m_myInst.findCallback(#CBNAME)) \
764 m_myInst.callCallback(Py_BuildValue("()")); \
765 wxPySaveThread(doSave); \
768 //---------------------------------------------------------------------------
770 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
774 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
775 wxSize CLASS::CBNAME() { \
777 bool doSave = wxPyRestoreThread(); \
778 if (m_myInst.findCallback(#CBNAME)) { \
781 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
782 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
785 wxPySaveThread(doSave); \
789 //---------------------------------------------------------------------------
791 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
792 bool CBNAME(wxWindow* a); \
793 bool base_##CBNAME(wxWindow* a);
796 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
797 bool CLASS::CBNAME(wxWindow* a) { \
799 bool doSave = wxPyRestoreThread(); \
800 if (m_myInst.findCallback(#CBNAME)) \
801 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
802 wxPyConstructObject((void*)a,"wxWindow"))); \
804 rval = PCLASS::CBNAME(a); \
805 wxPySaveThread(doSave); \
808 bool CLASS::base_##CBNAME(wxWindow* a) { \
809 return PCLASS::CBNAME(a); \
812 //---------------------------------------------------------------------------
814 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
816 bool base_##CBNAME();
819 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
820 bool CLASS::CBNAME() { \
822 bool doSave = wxPyRestoreThread(); \
823 if (m_myInst.findCallback(#CBNAME)) \
824 rval = m_myInst.callCallback(Py_BuildValue("()")); \
826 rval = PCLASS::CBNAME(); \
827 wxPySaveThread(doSave); \
830 bool CLASS::base_##CBNAME() { \
831 return PCLASS::CBNAME(); \
834 //---------------------------------------------------------------------------
836 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
837 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
838 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
841 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
842 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
843 bool doSave = wxPyRestoreThread(); \
845 if (m_myInst.findCallback(#CBNAME)) \
846 rval = m_myInst.callCallback(Py_BuildValue("(iii)", a,b,c));\
848 rval = PCLASS::CBNAME(a, b, c); \
849 wxPySaveThread(doSave); \
850 return (wxDragResult)rval; \
852 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
853 return PCLASS::CBNAME(a, b, c); \
856 //---------------------------------------------------------------------------
858 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
859 bool CBNAME(wxDragResult a); \
860 bool base_##CBNAME(wxDragResult a);
863 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
864 bool CLASS::CBNAME(wxDragResult a) { \
865 bool doSave = wxPyRestoreThread(); \
867 if (m_myInst.findCallback(#CBNAME)) \
868 rval = m_myInst.callCallback(Py_BuildValue("(i)", a)); \
870 rval = PCLASS::CBNAME(a); \
871 wxPySaveThread(doSave); \
874 bool CLASS::base_##CBNAME(wxDragResult a) { \
875 return PCLASS::CBNAME(a); \
878 //---------------------------------------------------------------------------
880 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
881 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
884 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
885 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
886 bool doSave = wxPyRestoreThread(); \
888 if (m_myInst.findCallback(#CBNAME)) \
889 rval = m_myInst.callCallback(Py_BuildValue("(iii)", a,b,c));\
890 wxPySaveThread(doSave); \
891 return (wxDragResult)rval; \
894 //---------------------------------------------------------------------------
896 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
897 bool CBNAME(int a, int b, const wxString& c);
900 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
901 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
903 bool doSave = wxPyRestoreThread(); \
904 if (m_myInst.findCallback(#CBNAME)) \
905 rval = m_myInst.callCallback(Py_BuildValue("(iis)",a,b,c.c_str()));\
906 wxPySaveThread(doSave); \
910 //---------------------------------------------------------------------------
912 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
914 size_t base_##CBNAME();
917 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
918 size_t CLASS::CBNAME() { \
920 bool doSave = wxPyRestoreThread(); \
921 if (m_myInst.findCallback(#CBNAME)) \
922 rval = m_myInst.callCallback(Py_BuildValue("()")); \
924 rval = PCLASS::CBNAME(); \
925 wxPySaveThread(doSave); \
928 size_t CLASS::base_##CBNAME() { \
929 return PCLASS::CBNAME(); \
932 //---------------------------------------------------------------------------
934 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
935 wxDataFormat CBNAME(); \
936 wxDataFormat base_##CBNAME();
939 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
940 wxDataFormat CLASS::CBNAME(size_t a) { \
942 bool doSave = wxPyRestoreThread(); \
943 if (m_myInst.findCallback(#CBNAME)) { \
946 ro = m_myInst.callCallbackObj(Py_BuildValue("(i)", a)); \
947 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
951 rval = PCLASS::CBNAME(a); \
952 wxPySaveThread(doSave); \
955 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
956 return PCLASS::CBNAME(a); \
959 //---------------------------------------------------------------------------
960 //---------------------------------------------------------------------------
961 //---------------------------------------------------------------------------