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
);
64 extern PyObject
* wxPython_dict
;
65 PyObject
* __wxSetDictionary(PyObject
*, PyObject
* args
);
67 void wxPyEventThunker(wxObject
*, wxEvent
& event
);
69 HELPEREXPORT PyObject
* wxPyConstructObject(void* ptr
, const char* className
);
70 HELPEREXPORT
bool wxPyRestoreThread();
71 HELPEREXPORT
void wxPySaveThread(bool doSave
);
72 HELPEREXPORT PyObject
* wxPy_ConvertList(wxListBase
* list
, const char* className
);
75 //----------------------------------------------------------------------
77 class wxPyUserData
: public wxObject
{
79 wxPyUserData(PyObject
* obj
) { m_obj
= obj
; Py_INCREF(m_obj
); }
81 bool doSave
= wxPyRestoreThread();
83 wxPySaveThread(doSave
);
88 //----------------------------------------------------------------------
89 // These are helpers used by the typemaps
91 HELPEREXPORT byte
* byte_LIST_helper(PyObject
* source
);
92 HELPEREXPORT
int* int_LIST_helper(PyObject
* source
);
93 HELPEREXPORT
long* long_LIST_helper(PyObject
* source
);
94 HELPEREXPORT
char** string_LIST_helper(PyObject
* source
);
95 HELPEREXPORT wxPoint
* wxPoint_LIST_helper(PyObject
* source
);
96 HELPEREXPORT wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
97 HELPEREXPORT wxString
* wxString_LIST_helper(PyObject
* source
);
98 HELPEREXPORT wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
100 HELPEREXPORT
bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
101 HELPEREXPORT
bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
102 HELPEREXPORT
bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
103 HELPEREXPORT
bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
105 //----------------------------------------------------------------------
108 extern "C" void SWIG_MakePtr(char *, void *, char *);
109 extern "C" char *SWIG_GetPtr(char *, void **, char *);
110 extern "C" char *SWIG_GetPtrObj(PyObject
*obj
, void **ptr
, char *type
);
115 # pragma warning(disable:4800)
120 // Non-const versions to keep SWIG happy.
121 extern wxPoint wxPyDefaultPosition
;
122 extern wxSize wxPyDefaultSize
;
123 extern wxString wxPyEmptyStr
;
125 //----------------------------------------------------------------------
127 class wxPyCallback
: public wxObject
{
128 DECLARE_ABSTRACT_CLASS(wxPyCallback
);
130 wxPyCallback(PyObject
* func
);
131 wxPyCallback(const wxPyCallback
& other
);
134 void EventThunker(wxEvent
& event
);
139 //---------------------------------------------------------------------------
141 class wxPyTimer
: public wxTimer
{
143 wxPyTimer(PyObject
* callback
);
152 //---------------------------------------------------------------------------
157 //---------------------------------------------------------------------------
158 // This class holds an instance of a Python Shadow Class object and assists
159 // with looking up and invoking Python callback methods from C++ virtual
160 // method redirections. For all classes which have virtuals which should be
161 // overridable in wxPython, a new subclass is created that contains a
162 // wxPyCallbackHelper.
164 // **** This class should be combined with wxPyCallback defined above.
167 class HELPEREXPORT wxPyCallbackHelper
{
169 wxPyCallbackHelper();
170 ~wxPyCallbackHelper();
172 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
174 void setSelf(PyObject
* self
, int incref
=TRUE
);
176 bool findCallback(const wxString
& name
);
177 int callCallback(PyObject
* argTuple
);
178 PyObject
* callCallbackObj(PyObject
* argTuple
);
182 PyObject
* m_lastFound
;
187 //---------------------------------------------------------------------------
188 //---------------------------------------------------------------------------
189 // These Event classes can be derived from in Python and passed through the
190 // event system without loosing anything. They do this by keeping a reference
191 // to themselves and some special case handling in wxPyCallback::EventThunker.
194 class wxPyEvtSelfRef
{
199 void SetSelf(PyObject
* self
, bool clone
=FALSE
);
200 PyObject
* GetSelf() const;
208 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
209 DECLARE_DYNAMIC_CLASS(wxPyEvent
)
214 void CopyObject(wxObject
& dest
) const;
218 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
219 DECLARE_DYNAMIC_CLASS(wxPyCommandEvent
)
221 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
224 void CopyObject(wxObject
& dest
) const;
228 //---------------------------------------------------------------------------
229 // These macros are used to implement the virtual methods that should
230 // redirect to a Python method if one exists. The names designate the
231 // return type, if any, as well as any parameter types.
232 //---------------------------------------------------------------------------
235 void _setSelf(PyObject* self, int incref=1) { \
236 m_myInst.setSelf(self, incref); \
238 private: wxPyCallbackHelper m_myInst;
240 //---------------------------------------------------------------------------
242 #define DEC_PYCALLBACK__(CBNAME) \
244 void base_##CBNAME();
247 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
248 void CLASS::CBNAME() { \
249 bool doSave = wxPyRestoreThread(); \
250 if (m_myInst.findCallback(#CBNAME)) \
251 m_myInst.callCallback(Py_BuildValue("()")); \
254 wxPySaveThread(doSave); \
256 void CLASS::base_##CBNAME() { \
260 //---------------------------------------------------------------------------
262 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
263 bool CBNAME(int a, int b); \
264 bool base_##CBNAME(int a, int b);
267 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
268 bool CLASS::CBNAME(int a, int b) { \
270 bool doSave = wxPyRestoreThread(); \
271 if (m_myInst.findCallback(#CBNAME)) \
272 rval = m_myInst.callCallback(Py_BuildValue("(ii)",a,b)); \
274 rval = PCLASS::CBNAME(a,b); \
275 wxPySaveThread(doSave); \
278 bool CLASS::base_##CBNAME(int a, int b) { \
279 return PCLASS::CBNAME(a,b); \
282 //---------------------------------------------------------------------------
284 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
285 bool CBNAME(int a); \
286 bool base_##CBNAME(int a);
289 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
290 bool CLASS::CBNAME(int a) { \
292 bool doSave = wxPyRestoreThread(); \
293 if (m_myInst.findCallback(#CBNAME)) \
294 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
296 rval = PCLASS::CBNAME(a); \
297 wxPySaveThread(doSave); \
300 bool CLASS::base_##CBNAME(int a) { \
301 return PCLASS::CBNAME(a); \
304 //---------------------------------------------------------------------------
306 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
310 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
311 bool CLASS::CBNAME(int a) { \
313 bool doSave = wxPyRestoreThread(); \
314 if (m_myInst.findCallback(#CBNAME)) \
315 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
317 wxPySaveThread(doSave); \
322 //---------------------------------------------------------------------------
324 #define DEC_PYCALLBACK__DC(CBNAME) \
325 void CBNAME(wxDC& a); \
326 void base_##CBNAME(wxDC& a);
329 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
330 void CLASS::CBNAME(wxDC& a) { \
331 bool doSave = wxPyRestoreThread(); \
332 if (m_myInst.findCallback(#CBNAME)) \
333 m_myInst.callCallback(Py_BuildValue("(O)", \
334 wxPyConstructObject(&a, "wxDC"))); \
337 wxPySaveThread(doSave); \
339 void CLASS::base_##CBNAME(wxDC& a) { \
345 //---------------------------------------------------------------------------
347 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
348 void CBNAME(wxDC& a, bool b); \
349 void base_##CBNAME(wxDC& a, bool b);
352 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
353 void CLASS::CBNAME(wxDC& a, bool b) { \
354 bool doSave = wxPyRestoreThread(); \
355 if (m_myInst.findCallback(#CBNAME)) \
356 m_myInst.callCallback(Py_BuildValue("(Oi)", \
357 wxPyConstructObject(&a, "wxDC"), (int)b)); \
359 PCLASS::CBNAME(a, b); \
360 wxPySaveThread(doSave); \
362 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
363 PCLASS::CBNAME(a, b); \
366 //---------------------------------------------------------------------------
368 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
369 void CBNAME(wxDC& a, bool b); \
370 void base_##CBNAME(wxDC& a, bool b);
373 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
374 void CLASS::CBNAME(wxDC& a, bool b) { \
375 bool doSave = wxPyRestoreThread(); \
376 if (m_myInst.findCallback(#CBNAME)) \
377 m_myInst.callCallback(Py_BuildValue("(Oi)", \
378 wxPyConstructObject(&a, "wxDC"), (int)b)); \
380 PCLASS::CBNAME(a, b); \
381 wxPySaveThread(doSave); \
383 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
384 PCLASS::CBNAME(a, b); \
387 //---------------------------------------------------------------------------
389 #define DEC_PYCALLBACK__2DBL(CBNAME) \
390 void CBNAME(double a, double b); \
391 void base_##CBNAME(double a, double b);
394 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
395 void CLASS::CBNAME(double a, double b) { \
396 bool doSave = wxPyRestoreThread(); \
397 if (m_myInst.findCallback(#CBNAME)) \
398 m_myInst.callCallback(Py_BuildValue("(dd)",a,b)); \
400 PCLASS::CBNAME(a, b); \
401 wxPySaveThread(doSave); \
403 void CLASS::base_##CBNAME(double a, double b) { \
404 PCLASS::CBNAME(a, b); \
407 //---------------------------------------------------------------------------
409 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
410 void CBNAME(double a, double b, int c, int d); \
411 void base_##CBNAME(double a, double b, int c, int d);
414 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
415 void CLASS::CBNAME(double a, double b, int c, int d) { \
416 bool doSave = wxPyRestoreThread(); \
417 if (m_myInst.findCallback(#CBNAME)) \
418 m_myInst.callCallback(Py_BuildValue("(ddii)", \
421 PCLASS::CBNAME(a, b, c, d); \
422 wxPySaveThread(doSave); \
424 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
425 PCLASS::CBNAME(a, b, c, d); \
428 //---------------------------------------------------------------------------
430 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
431 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
432 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
435 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
436 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
437 bool doSave = wxPyRestoreThread(); \
438 if (m_myInst.findCallback(#CBNAME)) \
439 m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
440 wxPyConstructObject(&a, "wxDC"), \
441 b, c, d, e, (int)f)); \
443 PCLASS::CBNAME(a, b, c, d, e, f); \
444 wxPySaveThread(doSave); \
446 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
447 PCLASS::CBNAME(a, b, c, d, e, f); \
450 //---------------------------------------------------------------------------
452 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
453 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
454 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
457 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
458 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
459 bool doSave = wxPyRestoreThread(); \
461 if (m_myInst.findCallback(#CBNAME)) \
462 rval = m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
463 wxPyConstructObject(&a, "wxDC"), \
464 b, c, d, e, (int)f)); \
466 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
467 wxPySaveThread(doSave); \
470 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
471 return PCLASS::CBNAME(a, b, c, d, e, f); \
474 //---------------------------------------------------------------------------
476 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
477 void CBNAME(bool a, double b, double c, int d, int e); \
478 void base_##CBNAME(bool a, double b, double c, int d, int e);
481 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
482 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
483 bool doSave = wxPyRestoreThread(); \
484 if (m_myInst.findCallback(#CBNAME)) \
485 m_myInst.callCallback(Py_BuildValue("(idii)", \
488 PCLASS::CBNAME(a, b, c, d, e); \
489 wxPySaveThread(doSave); \
491 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
492 PCLASS::CBNAME(a, b, c, d, e); \
495 //---------------------------------------------------------------------------
497 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
498 void CBNAME(wxDC& a, double b, double c, double d, double e); \
499 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
502 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
503 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
504 bool doSave = wxPyRestoreThread(); \
505 if (m_myInst.findCallback(#CBNAME)) \
506 m_myInst.callCallback(Py_BuildValue("(Odddd)", \
507 wxPyConstructObject(&a, "wxDC"), \
510 PCLASS::CBNAME(a, b, c, d, e); \
511 wxPySaveThread(doSave); \
513 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
514 PCLASS::CBNAME(a, b, c, d, e); \
517 //---------------------------------------------------------------------------
519 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
520 void CBNAME(wxDC& a, bool b); \
521 void base_##CBNAME(wxDC& a, bool b);
524 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
525 void CLASS::CBNAME(wxDC& a, bool b) { \
526 bool doSave = wxPyRestoreThread(); \
527 if (m_myInst.findCallback(#CBNAME)) \
528 m_myInst.callCallback(Py_BuildValue("(Oi)", \
529 wxPyConstructObject(&a, "wxDC"), \
532 PCLASS::CBNAME(a, b); \
533 wxPySaveThread(doSave); \
535 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
536 PCLASS::CBNAME(a, b); \
539 //---------------------------------------------------------------------------
541 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
542 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
543 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
546 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
547 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
549 bool doSave = wxPyRestoreThread(); \
550 if (m_myInst.findCallback(#CBNAME)) \
551 m_myInst.callCallback(Py_BuildValue("(Oiddii)", \
552 wxPyConstructObject(a, "wxPyControlPoint"), \
553 (int)b, c, d, e, f)); \
555 PCLASS::CBNAME(a, b, c, d, e, f); \
556 wxPySaveThread(doSave); \
558 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
560 PCLASS::CBNAME(a, b, c, d, e, f); \
563 //---------------------------------------------------------------------------
565 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
566 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
567 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
570 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
571 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
572 bool doSave = wxPyRestoreThread(); \
573 if (m_myInst.findCallback(#CBNAME)) \
574 m_myInst.callCallback(Py_BuildValue("(Oddii)", \
575 wxPyConstructObject(a, "wxPyControlPoint"), \
578 PCLASS::CBNAME(a, b, c, d, e); \
579 wxPySaveThread(doSave); \
581 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
583 PCLASS::CBNAME(a, b, c, d, e); \
586 //---------------------------------------------------------------------------
588 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
589 void CBNAME(double a, double b, int c); \
590 void base_##CBNAME(double a, double b, int c);
593 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
594 void CLASS::CBNAME(double a, double b, int c) { \
595 bool doSave = wxPyRestoreThread(); \
596 if (m_myInst.findCallback(#CBNAME)) \
597 m_myInst.callCallback(Py_BuildValue("(ddi)", a,b,c)); \
599 PCLASS::CBNAME(a, b, c); \
600 wxPySaveThread(doSave); \
602 void CLASS::base_##CBNAME(double a, double b, int c) { \
603 PCLASS::CBNAME(a, b, c); \
606 //---------------------------------------------------------------------------
608 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
609 void CBNAME(bool a, double b, double c, int d); \
610 void base_##CBNAME(bool a, double b, double c, int d);
613 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
614 void CLASS::CBNAME(bool a, double b, double c, int d) { \
615 bool doSave = wxPyRestoreThread(); \
616 if (m_myInst.findCallback(#CBNAME)) \
617 m_myInst.callCallback(Py_BuildValue("(iddi)", (int)a,b,c,d)); \
619 PCLASS::CBNAME(a, b, c, d); \
620 wxPySaveThread(doSave); \
622 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
623 PCLASS::CBNAME(a, b, c, d); \
626 //---------------------------------------------------------------------------
627 //---------------------------------------------------------------------------
629 #define DEC_PYCALLBACK__STRING(CBNAME) \
630 void CBNAME(const wxString& a); \
631 void base_##CBNAME(const wxString& a);
634 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
635 void CLASS::CBNAME(const wxString& a) { \
636 bool doSave = wxPyRestoreThread(); \
637 if (m_myInst.findCallback(#CBNAME)) \
638 m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
641 wxPySaveThread(doSave); \
643 void CLASS::base_##CBNAME(const wxString& a) { \
647 //---------------------------------------------------------------------------
649 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
650 bool CBNAME(const wxString& a); \
651 bool base_##CBNAME(const wxString& a);
654 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
655 bool CLASS::CBNAME(const wxString& a) { \
657 bool doSave = wxPyRestoreThread(); \
658 if (m_myInst.findCallback(#CBNAME)) \
659 rval = m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
661 rval = PCLASS::CBNAME(a); \
662 wxPySaveThread(doSave); \
665 bool CLASS::base_##CBNAME(const wxString& a) { \
666 return PCLASS::CBNAME(a); \
669 //---------------------------------------------------------------------------
671 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
672 bool CBNAME(const wxString& a, const wxString& b); \
673 bool base_##CBNAME(const wxString& a, const wxString& b);
676 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
677 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
679 bool doSave = wxPyRestoreThread(); \
680 if (m_myInst.findCallback(#CBNAME)) \
681 rval = m_myInst.callCallback(Py_BuildValue("(ss)", \
682 a.c_str(), b.c_str())); \
684 rval = PCLASS::CBNAME(a, b); \
685 wxPySaveThread(doSave); \
688 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
689 return PCLASS::CBNAME(a, b); \
692 //---------------------------------------------------------------------------
694 #define DEC_PYCALLBACK_STRING_(CBNAME) \
696 wxString base_##CBNAME();
699 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
700 wxString CLASS::CBNAME() { \
702 bool doSave = wxPyRestoreThread(); \
703 if (m_myInst.findCallback(#CBNAME)) { \
705 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
706 rval = PyString_AsString(PyObject_Str(ro)); \
709 rval = PCLASS::CBNAME(); \
710 wxPySaveThread(doSave); \
713 wxString CLASS::base_##CBNAME() { \
714 return PCLASS::CBNAME(); \
717 //---------------------------------------------------------------------------
719 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
723 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
724 wxString CLASS::CBNAME() { \
726 bool doSave = wxPyRestoreThread(); \
727 if (m_myInst.findCallback(#CBNAME)) { \
729 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
730 rval = PyString_AsString(PyObject_Str(ro)); \
732 wxPySaveThread(doSave); \
736 //---------------------------------------------------------------------------
738 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
739 bool CBNAME(const wxHtmlTag& a); \
742 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
743 bool CLASS::CBNAME(const wxHtmlTag& a) { \
745 bool doSave = wxPyRestoreThread(); \
746 if (m_myInst.findCallback(#CBNAME)) \
747 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
748 wxPyConstructObject((void*)&a,"wxHtmlTag"))); \
749 wxPySaveThread(doSave); \
753 //---------------------------------------------------------------------------
755 #define DEC_PYCALLBACK___pure(CBNAME) \
759 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
760 void CLASS::CBNAME() { \
761 bool doSave = wxPyRestoreThread(); \
762 if (m_myInst.findCallback(#CBNAME)) \
763 m_myInst.callCallback(Py_BuildValue("()")); \
764 wxPySaveThread(doSave); \
767 //---------------------------------------------------------------------------
769 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
773 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
774 wxSize CLASS::CBNAME() { \
776 bool doSave = wxPyRestoreThread(); \
777 if (m_myInst.findCallback(#CBNAME)) { \
780 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
781 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
784 wxPySaveThread(doSave); \
788 //---------------------------------------------------------------------------
790 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
791 bool CBNAME(wxWindow* a); \
792 bool base_##CBNAME(wxWindow* a);
795 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
796 bool CLASS::CBNAME(wxWindow* a) { \
798 bool doSave = wxPyRestoreThread(); \
799 if (m_myInst.findCallback(#CBNAME)) \
800 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
801 wxPyConstructObject((void*)a,"wxWindow"))); \
803 rval = PCLASS::CBNAME(a); \
804 wxPySaveThread(doSave); \
807 bool CLASS::base_##CBNAME(wxWindow* a) { \
808 return PCLASS::CBNAME(a); \
811 //---------------------------------------------------------------------------
813 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
815 bool base_##CBNAME();
818 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
819 bool CLASS::CBNAME() { \
821 bool doSave = wxPyRestoreThread(); \
822 if (m_myInst.findCallback(#CBNAME)) \
823 rval = m_myInst.callCallback(Py_BuildValue("()")); \
825 rval = PCLASS::CBNAME(); \
826 wxPySaveThread(doSave); \
829 bool CLASS::base_##CBNAME() { \
830 return PCLASS::CBNAME(); \
833 //---------------------------------------------------------------------------
835 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
836 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
837 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
840 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
841 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
842 bool doSave = wxPyRestoreThread(); \
844 if (m_myInst.findCallback(#CBNAME)) \
845 rval = m_myInst.callCallback(Py_BuildValue("(iii)", a,b,c));\
847 rval = PCLASS::CBNAME(a, b, c); \
848 wxPySaveThread(doSave); \
849 return (wxDragResult)rval; \
851 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
852 return PCLASS::CBNAME(a, b, c); \
855 //---------------------------------------------------------------------------
857 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
858 bool CBNAME(wxDragResult a); \
859 bool base_##CBNAME(wxDragResult a);
862 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
863 bool CLASS::CBNAME(wxDragResult a) { \
864 bool doSave = wxPyRestoreThread(); \
866 if (m_myInst.findCallback(#CBNAME)) \
867 rval = m_myInst.callCallback(Py_BuildValue("(i)", a)); \
869 rval = PCLASS::CBNAME(a); \
870 wxPySaveThread(doSave); \
873 bool CLASS::base_##CBNAME(wxDragResult a) { \
874 return PCLASS::CBNAME(a); \
877 //---------------------------------------------------------------------------
879 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
880 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
883 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
884 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
885 bool doSave = wxPyRestoreThread(); \
887 if (m_myInst.findCallback(#CBNAME)) \
888 rval = m_myInst.callCallback(Py_BuildValue("(iii)", a,b,c));\
889 wxPySaveThread(doSave); \
890 return (wxDragResult)rval; \
893 //---------------------------------------------------------------------------
895 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
896 bool CBNAME(int a, int b, const wxString& c);
899 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
900 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
902 bool doSave = wxPyRestoreThread(); \
903 if (m_myInst.findCallback(#CBNAME)) \
904 rval = m_myInst.callCallback(Py_BuildValue("(iis)",a,b,c.c_str()));\
905 wxPySaveThread(doSave); \
909 //---------------------------------------------------------------------------
911 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
913 size_t base_##CBNAME();
916 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
917 size_t CLASS::CBNAME() { \
919 bool doSave = wxPyRestoreThread(); \
920 if (m_myInst.findCallback(#CBNAME)) \
921 rval = m_myInst.callCallback(Py_BuildValue("()")); \
923 rval = PCLASS::CBNAME(); \
924 wxPySaveThread(doSave); \
927 size_t CLASS::base_##CBNAME() { \
928 return PCLASS::CBNAME(); \
931 //---------------------------------------------------------------------------
933 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
934 wxDataFormat CBNAME(); \
935 wxDataFormat base_##CBNAME();
938 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
939 wxDataFormat CLASS::CBNAME(size_t a) { \
941 bool doSave = wxPyRestoreThread(); \
942 if (m_myInst.findCallback(#CBNAME)) { \
945 ro = m_myInst.callCallbackObj(Py_BuildValue("(i)", a)); \
946 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
950 rval = PCLASS::CBNAME(a); \
951 wxPySaveThread(doSave); \
954 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
955 return PCLASS::CBNAME(a); \
958 //---------------------------------------------------------------------------
959 //---------------------------------------------------------------------------
960 //---------------------------------------------------------------------------