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(); \
418 if (m_myInst.findCallback(#CBNAME)) \
419 return m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
420 wxPyConstructObject(&a, "wxDC"), \
421 b, c, d, e, (int)f)); \
423 return PCLASS::CBNAME(a, b, c, d, e, f); \
424 wxPySaveThread(doSave); \
426 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
427 return PCLASS::CBNAME(a, b, c, d, e, f); \
430 //---------------------------------------------------------------------------
432 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
433 void CBNAME(bool a, double b, double c, int d, int e); \
434 void base_##CBNAME(bool a, double b, double c, int d, int e);
437 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
438 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
439 bool doSave = wxPyRestoreThread(); \
440 if (m_myInst.findCallback(#CBNAME)) \
441 m_myInst.callCallback(Py_BuildValue("(idii)", \
444 PCLASS::CBNAME(a, b, c, d, e); \
445 wxPySaveThread(doSave); \
447 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
448 PCLASS::CBNAME(a, b, c, d, e); \
451 //---------------------------------------------------------------------------
453 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
454 void CBNAME(wxDC& a, double b, double c, double d, double e); \
455 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
458 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
459 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
460 bool doSave = wxPyRestoreThread(); \
461 if (m_myInst.findCallback(#CBNAME)) \
462 m_myInst.callCallback(Py_BuildValue("(Odddd)", \
463 wxPyConstructObject(&a, "wxDC"), \
466 PCLASS::CBNAME(a, b, c, d, e); \
467 wxPySaveThread(doSave); \
469 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
470 PCLASS::CBNAME(a, b, c, d, e); \
473 //---------------------------------------------------------------------------
475 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
476 void CBNAME(wxDC& a, bool b); \
477 void base_##CBNAME(wxDC& a, bool b);
480 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
481 void CLASS::CBNAME(wxDC& a, bool b) { \
482 bool doSave = wxPyRestoreThread(); \
483 if (m_myInst.findCallback(#CBNAME)) \
484 m_myInst.callCallback(Py_BuildValue("(Oi)", \
485 wxPyConstructObject(&a, "wxDC"), \
488 PCLASS::CBNAME(a, b); \
489 wxPySaveThread(doSave); \
491 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
492 PCLASS::CBNAME(a, b); \
495 //---------------------------------------------------------------------------
497 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
498 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
499 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
502 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
503 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
505 bool doSave = wxPyRestoreThread(); \
506 if (m_myInst.findCallback(#CBNAME)) \
507 m_myInst.callCallback(Py_BuildValue("(Oiddii)", \
508 wxPyConstructObject(a, "wxPyControlPoint"), \
509 (int)b, c, d, e, f)); \
511 PCLASS::CBNAME(a, b, c, d, e, f); \
512 wxPySaveThread(doSave); \
514 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
516 PCLASS::CBNAME(a, b, c, d, e, f); \
519 //---------------------------------------------------------------------------
521 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
522 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
523 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
526 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
527 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
528 bool doSave = wxPyRestoreThread(); \
529 if (m_myInst.findCallback(#CBNAME)) \
530 m_myInst.callCallback(Py_BuildValue("(Oddii)", \
531 wxPyConstructObject(a, "wxPyControlPoint"), \
534 PCLASS::CBNAME(a, b, c, d, e); \
535 wxPySaveThread(doSave); \
537 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
539 PCLASS::CBNAME(a, b, c, d, e); \
542 //---------------------------------------------------------------------------
544 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
545 void CBNAME(double a, double b, int c); \
546 void base_##CBNAME(double a, double b, int c);
549 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
550 void CLASS::CBNAME(double a, double b, int c) { \
551 bool doSave = wxPyRestoreThread(); \
552 if (m_myInst.findCallback(#CBNAME)) \
553 m_myInst.callCallback(Py_BuildValue("(ddi)", a,b,c)); \
555 PCLASS::CBNAME(a, b, c); \
556 wxPySaveThread(doSave); \
558 void CLASS::base_##CBNAME(double a, double b, int c) { \
559 PCLASS::CBNAME(a, b, c); \
562 //---------------------------------------------------------------------------
564 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
565 void CBNAME(bool a, double b, double c, int d); \
566 void base_##CBNAME(bool a, double b, double c, int d);
569 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
570 void CLASS::CBNAME(bool a, double b, double c, int d) { \
571 bool doSave = wxPyRestoreThread(); \
572 if (m_myInst.findCallback(#CBNAME)) \
573 m_myInst.callCallback(Py_BuildValue("(iddi)", (int)a,b,c,d)); \
575 PCLASS::CBNAME(a, b, c, d); \
576 wxPySaveThread(doSave); \
578 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
579 PCLASS::CBNAME(a, b, c, d); \
582 //---------------------------------------------------------------------------
583 //---------------------------------------------------------------------------
585 #define DEC_PYCALLBACK__STRING(CBNAME) \
586 void CBNAME(const wxString& a); \
587 void base_##CBNAME(const wxString& a);
590 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
591 void CLASS::CBNAME(const wxString& a) { \
592 bool doSave = wxPyRestoreThread(); \
593 if (m_myInst.findCallback(#CBNAME)) \
594 m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
597 wxPySaveThread(doSave); \
599 void CLASS::base_##CBNAME(const wxString& a) { \
603 //---------------------------------------------------------------------------
605 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
606 bool CBNAME(const wxString& a); \
607 bool base_##CBNAME(const wxString& a);
610 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
611 bool CLASS::CBNAME(const wxString& a) { \
613 bool doSave = wxPyRestoreThread(); \
614 if (m_myInst.findCallback(#CBNAME)) \
615 rval = m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
617 rval = PCLASS::CBNAME(a); \
618 wxPySaveThread(doSave); \
621 bool CLASS::base_##CBNAME(const wxString& a) { \
622 return PCLASS::CBNAME(a); \
625 //---------------------------------------------------------------------------
627 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
628 bool CBNAME(const wxString& a, const wxString& b); \
629 bool base_##CBNAME(const wxString& a, const wxString& b);
632 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
633 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
635 bool doSave = wxPyRestoreThread(); \
636 if (m_myInst.findCallback(#CBNAME)) \
637 rval = m_myInst.callCallback(Py_BuildValue("(ss)", \
638 a.c_str(), b.c_str())); \
640 rval = PCLASS::CBNAME(a, b); \
641 wxPySaveThread(doSave); \
644 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
645 return PCLASS::CBNAME(a, b); \
648 //---------------------------------------------------------------------------
650 #define DEC_PYCALLBACK_STRING_(CBNAME) \
652 wxString base_##CBNAME();
655 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
656 wxString CLASS::CBNAME() { \
658 bool doSave = wxPyRestoreThread(); \
659 if (m_myInst.findCallback(#CBNAME)) { \
661 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
662 rval = PyString_AsString(PyObject_Str(ro)); \
665 rval = PCLASS::CBNAME(a); \
666 wxPySaveThread(doSave); \
669 bool CLASS::base_##CBNAME(const wxString& a) { \
670 return PCLASS::CBNAME(a); \
673 //---------------------------------------------------------------------------
675 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
679 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
680 wxString CLASS::CBNAME() { \
682 bool doSave = wxPyRestoreThread(); \
683 if (m_myInst.findCallback(#CBNAME)) { \
685 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
686 rval = PyString_AsString(PyObject_Str(ro)); \
688 wxPySaveThread(doSave); \
692 //---------------------------------------------------------------------------
694 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
695 bool CBNAME(const wxHtmlTag& a); \
698 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
699 bool CLASS::CBNAME(const wxHtmlTag& a) { \
701 bool doSave = wxPyRestoreThread(); \
702 if (m_myInst.findCallback(#CBNAME)) \
703 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
704 wxPyConstructObject((void*)&a,"wxHtmlTag"))); \
705 wxPySaveThread(doSave); \
709 //---------------------------------------------------------------------------
711 #define DEC_PYCALLBACK___pure(CBNAME) \
715 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
716 void CLASS::CBNAME() { \
717 bool doSave = wxPyRestoreThread(); \
718 if (m_myInst.findCallback(#CBNAME)) \
719 m_myInst.callCallback(Py_BuildValue("()")); \
720 wxPySaveThread(doSave); \
723 //---------------------------------------------------------------------------
725 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
729 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
730 wxSize CLASS::CBNAME() { \
732 bool doSave = wxPyRestoreThread(); \
733 if (m_myInst.findCallback(#CBNAME)) { \
736 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
737 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
740 wxPySaveThread(doSave); \
744 //---------------------------------------------------------------------------
746 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
747 bool CBNAME(wxWindow* a); \
748 bool base_##CBNAME(wxWindow* a);
751 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
752 bool CLASS::CBNAME(wxWindow* a) { \
754 bool doSave = wxPyRestoreThread(); \
755 if (m_myInst.findCallback(#CBNAME)) \
756 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
757 wxPyConstructObject((void*)a,"wxWindow"))); \
759 rval = PCLASS::CBNAME(a); \
760 wxPySaveThread(doSave); \
763 bool CLASS::base_##CBNAME(wxWindow* a) { \
764 return PCLASS::CBNAME(a); \
767 //---------------------------------------------------------------------------
769 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
771 bool base_##CBNAME();
774 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
775 bool CLASS::CBNAME() { \
777 bool doSave = wxPyRestoreThread(); \
778 if (m_myInst.findCallback(#CBNAME)) \
779 rval = m_myInst.callCallback(Py_BuildValue("()")); \
781 rval = PCLASS::CBNAME(); \
782 wxPySaveThread(doSave); \
785 bool CLASS::base_##CBNAME() { \
786 return PCLASS::CBNAME(); \
789 //---------------------------------------------------------------------------
790 //---------------------------------------------------------------------------
791 //---------------------------------------------------------------------------