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
);
74 //----------------------------------------------------------------------
75 // These are helpers used by the typemaps
77 HELPEREXPORT byte
* byte_LIST_helper(PyObject
* source
);
78 HELPEREXPORT
int* int_LIST_helper(PyObject
* source
);
79 HELPEREXPORT
long* long_LIST_helper(PyObject
* source
);
80 HELPEREXPORT
char** string_LIST_helper(PyObject
* source
);
81 HELPEREXPORT wxPoint
* wxPoint_LIST_helper(PyObject
* source
);
82 HELPEREXPORT wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
83 HELPEREXPORT wxString
* wxString_LIST_helper(PyObject
* source
);
84 HELPEREXPORT wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
86 HELPEREXPORT
bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
87 HELPEREXPORT
bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
88 HELPEREXPORT
bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
89 HELPEREXPORT
bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
91 //----------------------------------------------------------------------
94 extern "C" void SWIG_MakePtr(char *, void *, char *);
95 extern "C" char *SWIG_GetPtr(char *, void **, char *);
96 extern "C" char *SWIG_GetPtrObj(PyObject
*obj
, void **ptr
, char *type
);
101 # pragma warning(disable:4800)
106 // Non-const versions to keep SWIG happy.
107 extern wxPoint wxPyDefaultPosition
;
108 extern wxSize wxPyDefaultSize
;
109 extern wxString wxPyEmptyStr
;
111 //----------------------------------------------------------------------
113 class wxPyCallback
: public wxObject
{
114 DECLARE_ABSTRACT_CLASS(wxPyCallback
);
116 wxPyCallback(PyObject
* func
);
117 wxPyCallback(const wxPyCallback
& other
);
120 void EventThunker(wxEvent
& event
);
125 //---------------------------------------------------------------------------
127 // class wxPyMenu : public wxMenu {
129 // wxPyMenu(const wxString& title = "", PyObject* func=NULL);
133 // static void MenuCallback(wxMenu& menu, wxCommandEvent& evt);
138 //---------------------------------------------------------------------------
140 class wxPyTimer
: public wxTimer
{
142 wxPyTimer(PyObject
* callback
);
151 //---------------------------------------------------------------------------
156 //---------------------------------------------------------------------------
157 // This class holds an instance of a Python Shadow Class object and assists
158 // with looking up and invoking Python callback methods from C++ virtual
159 // method redirections. For all classes which have virtuals which should be
160 // overridable in wxPython, a new subclass is created that contains a
161 // wxPyCallbackHelper.
163 // **** This class should be combined with wxPyCallback defined above.
166 class HELPEREXPORT wxPyCallbackHelper
{
168 wxPyCallbackHelper();
169 ~wxPyCallbackHelper();
171 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
173 void setSelf(PyObject
* self
, int incref
=TRUE
);
175 bool findCallback(const wxString
& name
);
176 int callCallback(PyObject
* argTuple
);
177 PyObject
* callCallbackObj(PyObject
* argTuple
);
181 PyObject
* m_lastFound
;
186 //---------------------------------------------------------------------------
187 //---------------------------------------------------------------------------
188 // These classes can be derived from in Python and passed through the event
189 // system without loosing anything. They do this by keeping a reference to
190 // themselves and some special case handling in wxPyCallback::EventThunker.
193 class wxPyEvtSelfRef
{
198 void SetSelf(PyObject
* self
, bool clone
=FALSE
);
199 PyObject
* GetSelf() const;
207 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
208 DECLARE_DYNAMIC_CLASS(wxPyEvent
)
213 void CopyObject(wxObject
& dest
) const;
217 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
218 DECLARE_DYNAMIC_CLASS(wxPyCommandEvent
)
220 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
223 void CopyObject(wxObject
& dest
) const;
227 //---------------------------------------------------------------------------
228 // These macros are used to implement the virtual methods that should
229 // redirect to a Python method if one exists. The names designate the
230 // return type, if any, as well as any parameter types.
231 //---------------------------------------------------------------------------
234 void _setSelf(PyObject* self, int incref=1) { \
235 m_myInst.setSelf(self, incref); \
237 private: wxPyCallbackHelper m_myInst;
239 //---------------------------------------------------------------------------
241 #define DEC_PYCALLBACK__(CBNAME) \
243 void base_##CBNAME();
246 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
247 void CLASS::CBNAME() { \
248 bool doSave = wxPyRestoreThread(); \
249 if (m_myInst.findCallback(#CBNAME)) \
250 m_myInst.callCallback(Py_BuildValue("()")); \
253 wxPySaveThread(doSave); \
255 void CLASS::base_##CBNAME() { \
259 //---------------------------------------------------------------------------
261 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
262 bool CBNAME(int a, int b); \
263 bool base_##CBNAME(int a, int b);
266 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
267 bool CLASS::CBNAME(int a, int b) { \
269 bool doSave = wxPyRestoreThread(); \
270 if (m_myInst.findCallback(#CBNAME)) \
271 rval = m_myInst.callCallback(Py_BuildValue("(ii)",a,b)); \
273 rval = PCLASS::CBNAME(a,b); \
274 wxPySaveThread(doSave); \
277 bool CLASS::base_##CBNAME(int a, int b) { \
278 return PCLASS::CBNAME(a,b); \
281 //---------------------------------------------------------------------------
283 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
284 bool CBNAME(int a); \
285 bool base_##CBNAME(int a);
288 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
289 bool CLASS::CBNAME(int a) { \
291 bool doSave = wxPyRestoreThread(); \
292 if (m_myInst.findCallback(#CBNAME)) \
293 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
295 rval = PCLASS::CBNAME(a); \
296 wxPySaveThread(doSave); \
299 bool CLASS::base_##CBNAME(int a) { \
300 return PCLASS::CBNAME(a); \
303 //---------------------------------------------------------------------------
305 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
309 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
310 bool CLASS::CBNAME(int a) { \
312 bool doSave = wxPyRestoreThread(); \
313 if (m_myInst.findCallback(#CBNAME)) \
314 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
316 wxPySaveThread(doSave); \
321 //---------------------------------------------------------------------------
323 #define DEC_PYCALLBACK__DC(CBNAME) \
324 void CBNAME(wxDC& a); \
325 void base_##CBNAME(wxDC& a);
328 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
329 void CLASS::CBNAME(wxDC& a) { \
330 bool doSave = wxPyRestoreThread(); \
331 if (m_myInst.findCallback(#CBNAME)) \
332 m_myInst.callCallback(Py_BuildValue("(O)", \
333 wxPyConstructObject(&a, "wxDC"))); \
336 wxPySaveThread(doSave); \
338 void CLASS::base_##CBNAME(wxDC& a) { \
344 //---------------------------------------------------------------------------
346 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
347 void CBNAME(wxDC& a, bool b); \
348 void base_##CBNAME(wxDC& a, bool b);
351 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
352 void CLASS::CBNAME(wxDC& a, bool b) { \
353 bool doSave = wxPyRestoreThread(); \
354 if (m_myInst.findCallback(#CBNAME)) \
355 m_myInst.callCallback(Py_BuildValue("(Oi)", \
356 wxPyConstructObject(&a, "wxDC"), (int)b)); \
358 PCLASS::CBNAME(a, b); \
359 wxPySaveThread(doSave); \
361 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
362 PCLASS::CBNAME(a, b); \
365 //---------------------------------------------------------------------------
367 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
368 void CBNAME(wxDC& a, bool b); \
369 void base_##CBNAME(wxDC& a, bool b);
372 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
373 void CLASS::CBNAME(wxDC& a, bool b) { \
374 bool doSave = wxPyRestoreThread(); \
375 if (m_myInst.findCallback(#CBNAME)) \
376 m_myInst.callCallback(Py_BuildValue("(Oi)", \
377 wxPyConstructObject(&a, "wxDC"), (int)b)); \
379 PCLASS::CBNAME(a, b); \
380 wxPySaveThread(doSave); \
382 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
383 PCLASS::CBNAME(a, b); \
386 //---------------------------------------------------------------------------
388 #define DEC_PYCALLBACK__2DBL(CBNAME) \
389 void CBNAME(double a, double b); \
390 void base_##CBNAME(double a, double b);
393 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
394 void CLASS::CBNAME(double a, double b) { \
395 bool doSave = wxPyRestoreThread(); \
396 if (m_myInst.findCallback(#CBNAME)) \
397 m_myInst.callCallback(Py_BuildValue("(dd)",a,b)); \
399 PCLASS::CBNAME(a, b); \
400 wxPySaveThread(doSave); \
402 void CLASS::base_##CBNAME(double a, double b) { \
403 PCLASS::CBNAME(a, b); \
406 //---------------------------------------------------------------------------
408 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
409 void CBNAME(double a, double b, int c, int d); \
410 void base_##CBNAME(double a, double b, int c, int d);
413 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
414 void CLASS::CBNAME(double a, double b, int c, int d) { \
415 bool doSave = wxPyRestoreThread(); \
416 if (m_myInst.findCallback(#CBNAME)) \
417 m_myInst.callCallback(Py_BuildValue("(ddii)", \
420 PCLASS::CBNAME(a, b, c, d); \
421 wxPySaveThread(doSave); \
423 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
424 PCLASS::CBNAME(a, b, c, d); \
427 //---------------------------------------------------------------------------
429 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
430 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
431 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
434 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
435 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
436 bool doSave = wxPyRestoreThread(); \
437 if (m_myInst.findCallback(#CBNAME)) \
438 m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
439 wxPyConstructObject(&a, "wxDC"), \
440 b, c, d, e, (int)f)); \
442 PCLASS::CBNAME(a, b, c, d, e, f); \
443 wxPySaveThread(doSave); \
445 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
446 PCLASS::CBNAME(a, b, c, d, e, f); \
449 //---------------------------------------------------------------------------
451 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
452 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
453 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
456 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
457 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
458 bool doSave = wxPyRestoreThread(); \
460 if (m_myInst.findCallback(#CBNAME)) \
461 rval = m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
462 wxPyConstructObject(&a, "wxDC"), \
463 b, c, d, e, (int)f)); \
465 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
466 wxPySaveThread(doSave); \
469 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
470 return PCLASS::CBNAME(a, b, c, d, e, f); \
473 //---------------------------------------------------------------------------
475 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
476 void CBNAME(bool a, double b, double c, int d, int e); \
477 void base_##CBNAME(bool a, double b, double c, int d, int e);
480 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
481 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
482 bool doSave = wxPyRestoreThread(); \
483 if (m_myInst.findCallback(#CBNAME)) \
484 m_myInst.callCallback(Py_BuildValue("(idii)", \
487 PCLASS::CBNAME(a, b, c, d, e); \
488 wxPySaveThread(doSave); \
490 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
491 PCLASS::CBNAME(a, b, c, d, e); \
494 //---------------------------------------------------------------------------
496 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
497 void CBNAME(wxDC& a, double b, double c, double d, double e); \
498 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
501 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
502 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
503 bool doSave = wxPyRestoreThread(); \
504 if (m_myInst.findCallback(#CBNAME)) \
505 m_myInst.callCallback(Py_BuildValue("(Odddd)", \
506 wxPyConstructObject(&a, "wxDC"), \
509 PCLASS::CBNAME(a, b, c, d, e); \
510 wxPySaveThread(doSave); \
512 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
513 PCLASS::CBNAME(a, b, c, d, e); \
516 //---------------------------------------------------------------------------
518 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
519 void CBNAME(wxDC& a, bool b); \
520 void base_##CBNAME(wxDC& a, bool b);
523 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
524 void CLASS::CBNAME(wxDC& a, bool b) { \
525 bool doSave = wxPyRestoreThread(); \
526 if (m_myInst.findCallback(#CBNAME)) \
527 m_myInst.callCallback(Py_BuildValue("(Oi)", \
528 wxPyConstructObject(&a, "wxDC"), \
531 PCLASS::CBNAME(a, b); \
532 wxPySaveThread(doSave); \
534 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
535 PCLASS::CBNAME(a, b); \
538 //---------------------------------------------------------------------------
540 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
541 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
542 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
545 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
546 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
548 bool doSave = wxPyRestoreThread(); \
549 if (m_myInst.findCallback(#CBNAME)) \
550 m_myInst.callCallback(Py_BuildValue("(Oiddii)", \
551 wxPyConstructObject(a, "wxPyControlPoint"), \
552 (int)b, c, d, e, f)); \
554 PCLASS::CBNAME(a, b, c, d, e, f); \
555 wxPySaveThread(doSave); \
557 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
559 PCLASS::CBNAME(a, b, c, d, e, f); \
562 //---------------------------------------------------------------------------
564 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
565 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
566 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
569 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
570 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
571 bool doSave = wxPyRestoreThread(); \
572 if (m_myInst.findCallback(#CBNAME)) \
573 m_myInst.callCallback(Py_BuildValue("(Oddii)", \
574 wxPyConstructObject(a, "wxPyControlPoint"), \
577 PCLASS::CBNAME(a, b, c, d, e); \
578 wxPySaveThread(doSave); \
580 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
582 PCLASS::CBNAME(a, b, c, d, e); \
585 //---------------------------------------------------------------------------
587 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
588 void CBNAME(double a, double b, int c); \
589 void base_##CBNAME(double a, double b, int c);
592 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
593 void CLASS::CBNAME(double a, double b, int c) { \
594 bool doSave = wxPyRestoreThread(); \
595 if (m_myInst.findCallback(#CBNAME)) \
596 m_myInst.callCallback(Py_BuildValue("(ddi)", a,b,c)); \
598 PCLASS::CBNAME(a, b, c); \
599 wxPySaveThread(doSave); \
601 void CLASS::base_##CBNAME(double a, double b, int c) { \
602 PCLASS::CBNAME(a, b, c); \
605 //---------------------------------------------------------------------------
607 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
608 void CBNAME(bool a, double b, double c, int d); \
609 void base_##CBNAME(bool a, double b, double c, int d);
612 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
613 void CLASS::CBNAME(bool a, double b, double c, int d) { \
614 bool doSave = wxPyRestoreThread(); \
615 if (m_myInst.findCallback(#CBNAME)) \
616 m_myInst.callCallback(Py_BuildValue("(iddi)", (int)a,b,c,d)); \
618 PCLASS::CBNAME(a, b, c, d); \
619 wxPySaveThread(doSave); \
621 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
622 PCLASS::CBNAME(a, b, c, d); \
625 //---------------------------------------------------------------------------
626 //---------------------------------------------------------------------------
628 #define DEC_PYCALLBACK__STRING(CBNAME) \
629 void CBNAME(const wxString& a); \
630 void base_##CBNAME(const wxString& a);
633 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
634 void CLASS::CBNAME(const wxString& a) { \
635 bool doSave = wxPyRestoreThread(); \
636 if (m_myInst.findCallback(#CBNAME)) \
637 m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
640 wxPySaveThread(doSave); \
642 void CLASS::base_##CBNAME(const wxString& a) { \
646 //---------------------------------------------------------------------------
648 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
649 bool CBNAME(const wxString& a); \
650 bool base_##CBNAME(const wxString& a);
653 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
654 bool CLASS::CBNAME(const wxString& a) { \
656 bool doSave = wxPyRestoreThread(); \
657 if (m_myInst.findCallback(#CBNAME)) \
658 rval = m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
660 rval = PCLASS::CBNAME(a); \
661 wxPySaveThread(doSave); \
664 bool CLASS::base_##CBNAME(const wxString& a) { \
665 return PCLASS::CBNAME(a); \
668 //---------------------------------------------------------------------------
670 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
671 bool CBNAME(const wxString& a, const wxString& b); \
672 bool base_##CBNAME(const wxString& a, const wxString& b);
675 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
676 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
678 bool doSave = wxPyRestoreThread(); \
679 if (m_myInst.findCallback(#CBNAME)) \
680 rval = m_myInst.callCallback(Py_BuildValue("(ss)", \
681 a.c_str(), b.c_str())); \
683 rval = PCLASS::CBNAME(a, b); \
684 wxPySaveThread(doSave); \
687 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
688 return PCLASS::CBNAME(a, b); \
691 //---------------------------------------------------------------------------
693 #define DEC_PYCALLBACK_STRING_(CBNAME) \
695 wxString base_##CBNAME();
698 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
699 wxString CLASS::CBNAME() { \
701 bool doSave = wxPyRestoreThread(); \
702 if (m_myInst.findCallback(#CBNAME)) { \
704 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
705 rval = PyString_AsString(PyObject_Str(ro)); \
708 rval = PCLASS::CBNAME(); \
709 wxPySaveThread(doSave); \
712 wxString CLASS::base_##CBNAME() { \
713 return PCLASS::CBNAME(); \
716 //---------------------------------------------------------------------------
718 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
722 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
723 wxString CLASS::CBNAME() { \
725 bool doSave = wxPyRestoreThread(); \
726 if (m_myInst.findCallback(#CBNAME)) { \
728 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
729 rval = PyString_AsString(PyObject_Str(ro)); \
731 wxPySaveThread(doSave); \
735 //---------------------------------------------------------------------------
737 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
738 bool CBNAME(const wxHtmlTag& a); \
741 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
742 bool CLASS::CBNAME(const wxHtmlTag& a) { \
744 bool doSave = wxPyRestoreThread(); \
745 if (m_myInst.findCallback(#CBNAME)) \
746 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
747 wxPyConstructObject((void*)&a,"wxHtmlTag"))); \
748 wxPySaveThread(doSave); \
752 //---------------------------------------------------------------------------
754 #define DEC_PYCALLBACK___pure(CBNAME) \
758 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
759 void CLASS::CBNAME() { \
760 bool doSave = wxPyRestoreThread(); \
761 if (m_myInst.findCallback(#CBNAME)) \
762 m_myInst.callCallback(Py_BuildValue("()")); \
763 wxPySaveThread(doSave); \
766 //---------------------------------------------------------------------------
768 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
772 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
773 wxSize CLASS::CBNAME() { \
775 bool doSave = wxPyRestoreThread(); \
776 if (m_myInst.findCallback(#CBNAME)) { \
779 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
780 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
783 wxPySaveThread(doSave); \
787 //---------------------------------------------------------------------------
789 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
790 bool CBNAME(wxWindow* a); \
791 bool base_##CBNAME(wxWindow* a);
794 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
795 bool CLASS::CBNAME(wxWindow* a) { \
797 bool doSave = wxPyRestoreThread(); \
798 if (m_myInst.findCallback(#CBNAME)) \
799 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
800 wxPyConstructObject((void*)a,"wxWindow"))); \
802 rval = PCLASS::CBNAME(a); \
803 wxPySaveThread(doSave); \
806 bool CLASS::base_##CBNAME(wxWindow* a) { \
807 return PCLASS::CBNAME(a); \
810 //---------------------------------------------------------------------------
812 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
814 bool base_##CBNAME();
817 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
818 bool CLASS::CBNAME() { \
820 bool doSave = wxPyRestoreThread(); \
821 if (m_myInst.findCallback(#CBNAME)) \
822 rval = m_myInst.callCallback(Py_BuildValue("()")); \
824 rval = PCLASS::CBNAME(); \
825 wxPySaveThread(doSave); \
828 bool CLASS::base_##CBNAME() { \
829 return PCLASS::CBNAME(); \
832 //---------------------------------------------------------------------------
834 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
835 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
836 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
839 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
840 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
841 bool doSave = wxPyRestoreThread(); \
843 if (m_myInst.findCallback(#CBNAME)) \
844 rval = m_myInst.callCallback(Py_BuildValue("(iii)", a,b,c));\
846 rval = PCLASS::CBNAME(a, b, c); \
847 wxPySaveThread(doSave); \
848 return (wxDragResult)rval; \
850 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
851 return PCLASS::CBNAME(a, b, c); \
854 //---------------------------------------------------------------------------
856 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
857 bool CBNAME(wxDragResult a); \
858 bool base_##CBNAME(wxDragResult a);
861 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
862 bool CLASS::CBNAME(wxDragResult a) { \
863 bool doSave = wxPyRestoreThread(); \
865 if (m_myInst.findCallback(#CBNAME)) \
866 rval = m_myInst.callCallback(Py_BuildValue("(i)", a)); \
868 rval = PCLASS::CBNAME(a); \
869 wxPySaveThread(doSave); \
872 bool CLASS::base_##CBNAME(wxDragResult a) { \
873 return PCLASS::CBNAME(a); \
876 //---------------------------------------------------------------------------
878 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
879 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
882 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
883 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
884 bool doSave = wxPyRestoreThread(); \
886 if (m_myInst.findCallback(#CBNAME)) \
887 rval = m_myInst.callCallback(Py_BuildValue("(iii)", a,b,c));\
888 wxPySaveThread(doSave); \
889 return (wxDragResult)rval; \
892 //---------------------------------------------------------------------------
894 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
895 bool CBNAME(int a, int b, const wxString& c);
898 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
899 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
901 bool doSave = wxPyRestoreThread(); \
902 if (m_myInst.findCallback(#CBNAME)) \
903 rval = m_myInst.callCallback(Py_BuildValue("(iis)",a,b,c.c_str()));\
904 wxPySaveThread(doSave); \
908 //---------------------------------------------------------------------------
910 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
912 size_t base_##CBNAME();
915 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
916 size_t CLASS::CBNAME() { \
918 bool doSave = wxPyRestoreThread(); \
919 if (m_myInst.findCallback(#CBNAME)) \
920 rval = m_myInst.callCallback(Py_BuildValue("()")); \
922 rval = PCLASS::CBNAME(); \
923 wxPySaveThread(doSave); \
926 size_t CLASS::base_##CBNAME() { \
927 return PCLASS::CBNAME(); \
930 //---------------------------------------------------------------------------
932 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
933 wxDataFormat CBNAME(); \
934 wxDataFormat base_##CBNAME();
937 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
938 wxDataFormat CLASS::CBNAME(size_t a) { \
940 bool doSave = wxPyRestoreThread(); \
941 if (m_myInst.findCallback(#CBNAME)) { \
944 ro = m_myInst.callCallbackObj(Py_BuildValue("(i)", a)); \
945 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
949 rval = PCLASS::CBNAME(a); \
950 wxPySaveThread(doSave); \
953 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
954 return PCLASS::CBNAME(a); \
957 //---------------------------------------------------------------------------
958 //---------------------------------------------------------------------------
959 //---------------------------------------------------------------------------