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
, char* className
);
70 HELPEREXPORT
bool wxPyRestoreThread();
71 HELPEREXPORT
void wxPySaveThread(bool doSave
);
72 HELPEREXPORT PyObject
* wxPy_ConvertList(wxListBase
* list
, 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 // These macros are used to implement the virtual methods that should
188 // redirect to a Python method if one exists. The names designate the
189 // return type, if any as well as any parameter types.
190 //---------------------------------------------------------------------------
193 void _setSelf(PyObject* self, int incref=TRUE) { \
194 m_myInst.setSelf(self, incref); \
196 private: wxPyCallbackHelper m_myInst;
198 //---------------------------------------------------------------------------
200 #define DEC_PYCALLBACK__(CBNAME) \
202 void base_##CBNAME();
205 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
206 void CLASS::CBNAME() { \
207 bool doSave = wxPyRestoreThread(); \
208 if (m_myInst.findCallback(#CBNAME)) \
209 m_myInst.callCallback(Py_BuildValue("()")); \
212 wxPySaveThread(doSave); \
214 void CLASS::base_##CBNAME() { \
218 //---------------------------------------------------------------------------
220 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
221 bool CBNAME(int a, int b); \
222 bool base_##CBNAME(int a, int b);
225 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
226 bool CLASS::CBNAME(int a, int b) { \
228 bool doSave = wxPyRestoreThread(); \
229 if (m_myInst.findCallback(#CBNAME)) \
230 rval = m_myInst.callCallback(Py_BuildValue("(ii)",a,b)); \
232 rval = PCLASS::CBNAME(a,b); \
233 wxPySaveThread(doSave); \
236 bool CLASS::base_##CBNAME(int a, int b) { \
237 return PCLASS::CBNAME(a,b); \
240 //---------------------------------------------------------------------------
242 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
243 bool CBNAME(int a); \
244 bool base_##CBNAME(int a);
247 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
248 bool CLASS::CBNAME(int a) { \
250 bool doSave = wxPyRestoreThread(); \
251 if (m_myInst.findCallback(#CBNAME)) \
252 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
254 rval = PCLASS::CBNAME(a); \
255 wxPySaveThread(doSave); \
258 bool CLASS::base_##CBNAME(int a) { \
259 return PCLASS::CBNAME(a); \
262 //---------------------------------------------------------------------------
264 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
268 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
269 bool CLASS::CBNAME(int a) { \
271 bool doSave = wxPyRestoreThread(); \
272 if (m_myInst.findCallback(#CBNAME)) \
273 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
275 wxPySaveThread(doSave); \
280 //---------------------------------------------------------------------------
282 #define DEC_PYCALLBACK__DC(CBNAME) \
283 void CBNAME(wxDC& a); \
284 void base_##CBNAME(wxDC& a);
287 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
288 void CLASS::CBNAME(wxDC& a) { \
289 bool doSave = wxPyRestoreThread(); \
290 if (m_myInst.findCallback(#CBNAME)) \
291 m_myInst.callCallback(Py_BuildValue("(O)", \
292 wxPyConstructObject(&a, "wxDC"))); \
295 wxPySaveThread(doSave); \
297 void CLASS::base_##CBNAME(wxDC& a) { \
303 //---------------------------------------------------------------------------
305 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
306 void CBNAME(wxDC& a, bool b); \
307 void base_##CBNAME(wxDC& a, bool b);
310 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
311 void CLASS::CBNAME(wxDC& a, bool b) { \
312 bool doSave = wxPyRestoreThread(); \
313 if (m_myInst.findCallback(#CBNAME)) \
314 m_myInst.callCallback(Py_BuildValue("(Oi)", \
315 wxPyConstructObject(&a, "wxDC"), (int)b)); \
317 PCLASS::CBNAME(a, b); \
318 wxPySaveThread(doSave); \
320 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
321 PCLASS::CBNAME(a, b); \
324 //---------------------------------------------------------------------------
326 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
327 void CBNAME(wxDC& a, bool b); \
328 void base_##CBNAME(wxDC& a, bool b);
331 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
332 void CLASS::CBNAME(wxDC& a, bool b) { \
333 bool doSave = wxPyRestoreThread(); \
334 if (m_myInst.findCallback(#CBNAME)) \
335 m_myInst.callCallback(Py_BuildValue("(Oi)", \
336 wxPyConstructObject(&a, "wxDC"), (int)b)); \
338 PCLASS::CBNAME(a, b); \
339 wxPySaveThread(doSave); \
341 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
342 PCLASS::CBNAME(a, b); \
345 //---------------------------------------------------------------------------
347 #define DEC_PYCALLBACK__2DBL(CBNAME) \
348 void CBNAME(double a, double b); \
349 void base_##CBNAME(double a, double b);
352 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
353 void CLASS::CBNAME(double a, double b) { \
354 bool doSave = wxPyRestoreThread(); \
355 if (m_myInst.findCallback(#CBNAME)) \
356 m_myInst.callCallback(Py_BuildValue("(dd)",a,b)); \
358 PCLASS::CBNAME(a, b); \
359 wxPySaveThread(doSave); \
361 void CLASS::base_##CBNAME(double a, double b) { \
362 PCLASS::CBNAME(a, b); \
365 //---------------------------------------------------------------------------
367 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
368 void CBNAME(double a, double b, int c, int d); \
369 void base_##CBNAME(double a, double b, int c, int d);
372 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
373 void CLASS::CBNAME(double a, double b, int c, int d) { \
374 bool doSave = wxPyRestoreThread(); \
375 if (m_myInst.findCallback(#CBNAME)) \
376 m_myInst.callCallback(Py_BuildValue("(ddii)", \
379 PCLASS::CBNAME(a, b, c, d); \
380 wxPySaveThread(doSave); \
382 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
383 PCLASS::CBNAME(a, b, c, d); \
386 //---------------------------------------------------------------------------
388 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
389 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
390 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
393 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
394 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
395 bool doSave = wxPyRestoreThread(); \
396 if (m_myInst.findCallback(#CBNAME)) \
397 m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
398 wxPyConstructObject(&a, "wxDC"), \
399 b, c, d, e, (int)f)); \
401 PCLASS::CBNAME(a, b, c, d, e, f); \
402 wxPySaveThread(doSave); \
404 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
405 PCLASS::CBNAME(a, b, c, d, e, f); \
408 //---------------------------------------------------------------------------
410 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
411 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
412 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
415 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
416 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
417 bool doSave = wxPyRestoreThread(); \
419 if (m_myInst.findCallback(#CBNAME)) \
420 rval = m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
421 wxPyConstructObject(&a, "wxDC"), \
422 b, c, d, e, (int)f)); \
424 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
425 wxPySaveThread(doSave); \
428 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
429 return PCLASS::CBNAME(a, b, c, d, e, f); \
432 //---------------------------------------------------------------------------
434 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
435 void CBNAME(bool a, double b, double c, int d, int e); \
436 void base_##CBNAME(bool a, double b, double c, int d, int e);
439 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
440 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
441 bool doSave = wxPyRestoreThread(); \
442 if (m_myInst.findCallback(#CBNAME)) \
443 m_myInst.callCallback(Py_BuildValue("(idii)", \
446 PCLASS::CBNAME(a, b, c, d, e); \
447 wxPySaveThread(doSave); \
449 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
450 PCLASS::CBNAME(a, b, c, d, e); \
453 //---------------------------------------------------------------------------
455 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
456 void CBNAME(wxDC& a, double b, double c, double d, double e); \
457 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
460 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
461 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
462 bool doSave = wxPyRestoreThread(); \
463 if (m_myInst.findCallback(#CBNAME)) \
464 m_myInst.callCallback(Py_BuildValue("(Odddd)", \
465 wxPyConstructObject(&a, "wxDC"), \
468 PCLASS::CBNAME(a, b, c, d, e); \
469 wxPySaveThread(doSave); \
471 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
472 PCLASS::CBNAME(a, b, c, d, e); \
475 //---------------------------------------------------------------------------
477 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
478 void CBNAME(wxDC& a, bool b); \
479 void base_##CBNAME(wxDC& a, bool b);
482 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
483 void CLASS::CBNAME(wxDC& a, bool b) { \
484 bool doSave = wxPyRestoreThread(); \
485 if (m_myInst.findCallback(#CBNAME)) \
486 m_myInst.callCallback(Py_BuildValue("(Oi)", \
487 wxPyConstructObject(&a, "wxDC"), \
490 PCLASS::CBNAME(a, b); \
491 wxPySaveThread(doSave); \
493 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
494 PCLASS::CBNAME(a, b); \
497 //---------------------------------------------------------------------------
499 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
500 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
501 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
504 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
505 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
507 bool doSave = wxPyRestoreThread(); \
508 if (m_myInst.findCallback(#CBNAME)) \
509 m_myInst.callCallback(Py_BuildValue("(Oiddii)", \
510 wxPyConstructObject(a, "wxPyControlPoint"), \
511 (int)b, c, d, e, f)); \
513 PCLASS::CBNAME(a, b, c, d, e, f); \
514 wxPySaveThread(doSave); \
516 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
518 PCLASS::CBNAME(a, b, c, d, e, f); \
521 //---------------------------------------------------------------------------
523 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
524 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
525 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
528 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
529 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
530 bool doSave = wxPyRestoreThread(); \
531 if (m_myInst.findCallback(#CBNAME)) \
532 m_myInst.callCallback(Py_BuildValue("(Oddii)", \
533 wxPyConstructObject(a, "wxPyControlPoint"), \
536 PCLASS::CBNAME(a, b, c, d, e); \
537 wxPySaveThread(doSave); \
539 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
541 PCLASS::CBNAME(a, b, c, d, e); \
544 //---------------------------------------------------------------------------
546 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
547 void CBNAME(double a, double b, int c); \
548 void base_##CBNAME(double a, double b, int c);
551 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
552 void CLASS::CBNAME(double a, double b, int c) { \
553 bool doSave = wxPyRestoreThread(); \
554 if (m_myInst.findCallback(#CBNAME)) \
555 m_myInst.callCallback(Py_BuildValue("(ddi)", a,b,c)); \
557 PCLASS::CBNAME(a, b, c); \
558 wxPySaveThread(doSave); \
560 void CLASS::base_##CBNAME(double a, double b, int c) { \
561 PCLASS::CBNAME(a, b, c); \
564 //---------------------------------------------------------------------------
566 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
567 void CBNAME(bool a, double b, double c, int d); \
568 void base_##CBNAME(bool a, double b, double c, int d);
571 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
572 void CLASS::CBNAME(bool a, double b, double c, int d) { \
573 bool doSave = wxPyRestoreThread(); \
574 if (m_myInst.findCallback(#CBNAME)) \
575 m_myInst.callCallback(Py_BuildValue("(iddi)", (int)a,b,c,d)); \
577 PCLASS::CBNAME(a, b, c, d); \
578 wxPySaveThread(doSave); \
580 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
581 PCLASS::CBNAME(a, b, c, d); \
584 //---------------------------------------------------------------------------
585 //---------------------------------------------------------------------------
587 #define DEC_PYCALLBACK__STRING(CBNAME) \
588 void CBNAME(const wxString& a); \
589 void base_##CBNAME(const wxString& a);
592 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
593 void CLASS::CBNAME(const wxString& a) { \
594 bool doSave = wxPyRestoreThread(); \
595 if (m_myInst.findCallback(#CBNAME)) \
596 m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
599 wxPySaveThread(doSave); \
601 void CLASS::base_##CBNAME(const wxString& a) { \
605 //---------------------------------------------------------------------------
607 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
608 bool CBNAME(const wxString& a); \
609 bool base_##CBNAME(const wxString& a);
612 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
613 bool CLASS::CBNAME(const wxString& a) { \
615 bool doSave = wxPyRestoreThread(); \
616 if (m_myInst.findCallback(#CBNAME)) \
617 rval = m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
619 rval = PCLASS::CBNAME(a); \
620 wxPySaveThread(doSave); \
623 bool CLASS::base_##CBNAME(const wxString& a) { \
624 return PCLASS::CBNAME(a); \
627 //---------------------------------------------------------------------------
629 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
630 bool CBNAME(const wxString& a, const wxString& b); \
631 bool base_##CBNAME(const wxString& a, const wxString& b);
634 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
635 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
637 bool doSave = wxPyRestoreThread(); \
638 if (m_myInst.findCallback(#CBNAME)) \
639 rval = m_myInst.callCallback(Py_BuildValue("(ss)", \
640 a.c_str(), b.c_str())); \
642 rval = PCLASS::CBNAME(a, b); \
643 wxPySaveThread(doSave); \
646 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
647 return PCLASS::CBNAME(a, b); \
650 //---------------------------------------------------------------------------
652 #define DEC_PYCALLBACK_STRING_(CBNAME) \
654 wxString base_##CBNAME();
657 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
658 wxString CLASS::CBNAME() { \
660 bool doSave = wxPyRestoreThread(); \
661 if (m_myInst.findCallback(#CBNAME)) { \
663 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
664 rval = PyString_AsString(PyObject_Str(ro)); \
667 rval = PCLASS::CBNAME(a); \
668 wxPySaveThread(doSave); \
671 bool CLASS::base_##CBNAME(const wxString& a) { \
672 return PCLASS::CBNAME(a); \
675 //---------------------------------------------------------------------------
677 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
681 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
682 wxString CLASS::CBNAME() { \
684 bool doSave = wxPyRestoreThread(); \
685 if (m_myInst.findCallback(#CBNAME)) { \
687 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
688 rval = PyString_AsString(PyObject_Str(ro)); \
690 wxPySaveThread(doSave); \
694 //---------------------------------------------------------------------------
696 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
697 bool CBNAME(const wxHtmlTag& a); \
700 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
701 bool CLASS::CBNAME(const wxHtmlTag& a) { \
703 bool doSave = wxPyRestoreThread(); \
704 if (m_myInst.findCallback(#CBNAME)) \
705 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
706 wxPyConstructObject((void*)&a,"wxHtmlTag"))); \
707 wxPySaveThread(doSave); \
711 //---------------------------------------------------------------------------
713 #define DEC_PYCALLBACK___pure(CBNAME) \
717 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
718 void CLASS::CBNAME() { \
719 bool doSave = wxPyRestoreThread(); \
720 if (m_myInst.findCallback(#CBNAME)) \
721 m_myInst.callCallback(Py_BuildValue("()")); \
722 wxPySaveThread(doSave); \
725 //---------------------------------------------------------------------------
727 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
731 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
732 wxSize CLASS::CBNAME() { \
734 bool doSave = wxPyRestoreThread(); \
735 if (m_myInst.findCallback(#CBNAME)) { \
738 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
739 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
742 wxPySaveThread(doSave); \
746 //---------------------------------------------------------------------------
748 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
749 bool CBNAME(wxWindow* a); \
750 bool base_##CBNAME(wxWindow* a);
753 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
754 bool CLASS::CBNAME(wxWindow* a) { \
756 bool doSave = wxPyRestoreThread(); \
757 if (m_myInst.findCallback(#CBNAME)) \
758 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
759 wxPyConstructObject((void*)a,"wxWindow"))); \
761 rval = PCLASS::CBNAME(a); \
762 wxPySaveThread(doSave); \
765 bool CLASS::base_##CBNAME(wxWindow* a) { \
766 return PCLASS::CBNAME(a); \
769 //---------------------------------------------------------------------------
771 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
773 bool base_##CBNAME();
776 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
777 bool CLASS::CBNAME() { \
779 bool doSave = wxPyRestoreThread(); \
780 if (m_myInst.findCallback(#CBNAME)) \
781 rval = m_myInst.callCallback(Py_BuildValue("()")); \
783 rval = PCLASS::CBNAME(); \
784 wxPySaveThread(doSave); \
787 bool CLASS::base_##CBNAME() { \
788 return PCLASS::CBNAME(); \
791 //---------------------------------------------------------------------------
792 //---------------------------------------------------------------------------
793 //---------------------------------------------------------------------------