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
;
185 //---------------------------------------------------------------------------
186 //---------------------------------------------------------------------------
187 // These classes can be derived from in Python and passed through the event
188 // system without loosing anything. They do this by keeping a reference to
189 // themselves and some special case handling in wxPyCallback::EventThunker.
192 class wxPyEvtSelfRef
{
197 void SetSelf(PyObject
* self
, bool clone
=FALSE
);
198 PyObject
* GetSelf() const;
206 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
207 DECLARE_DYNAMIC_CLASS(wxPyEvent
)
212 void CopyObject(wxObject
& dest
) const;
216 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
217 DECLARE_DYNAMIC_CLASS(wxPyCommandEvent
)
219 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
222 void CopyObject(wxObject
& dest
) const;
226 //---------------------------------------------------------------------------
227 // These macros are used to implement the virtual methods that should
228 // redirect to a Python method if one exists. The names designate the
229 // return type, if any, as well as any parameter types.
230 //---------------------------------------------------------------------------
233 void _setSelf(PyObject* self, int incref=TRUE) { \
234 m_myInst.setSelf(self, incref); \
236 private: wxPyCallbackHelper m_myInst;
238 //---------------------------------------------------------------------------
240 #define DEC_PYCALLBACK__(CBNAME) \
242 void base_##CBNAME();
245 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
246 void CLASS::CBNAME() { \
247 bool doSave = wxPyRestoreThread(); \
248 if (m_myInst.findCallback(#CBNAME)) \
249 m_myInst.callCallback(Py_BuildValue("()")); \
252 wxPySaveThread(doSave); \
254 void CLASS::base_##CBNAME() { \
258 //---------------------------------------------------------------------------
260 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
261 bool CBNAME(int a, int b); \
262 bool base_##CBNAME(int a, int b);
265 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
266 bool CLASS::CBNAME(int a, int b) { \
268 bool doSave = wxPyRestoreThread(); \
269 if (m_myInst.findCallback(#CBNAME)) \
270 rval = m_myInst.callCallback(Py_BuildValue("(ii)",a,b)); \
272 rval = PCLASS::CBNAME(a,b); \
273 wxPySaveThread(doSave); \
276 bool CLASS::base_##CBNAME(int a, int b) { \
277 return PCLASS::CBNAME(a,b); \
280 //---------------------------------------------------------------------------
282 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
283 bool CBNAME(int a); \
284 bool base_##CBNAME(int a);
287 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
288 bool CLASS::CBNAME(int a) { \
290 bool doSave = wxPyRestoreThread(); \
291 if (m_myInst.findCallback(#CBNAME)) \
292 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
294 rval = PCLASS::CBNAME(a); \
295 wxPySaveThread(doSave); \
298 bool CLASS::base_##CBNAME(int a) { \
299 return PCLASS::CBNAME(a); \
302 //---------------------------------------------------------------------------
304 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
308 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
309 bool CLASS::CBNAME(int a) { \
311 bool doSave = wxPyRestoreThread(); \
312 if (m_myInst.findCallback(#CBNAME)) \
313 rval = m_myInst.callCallback(Py_BuildValue("(i)",a)); \
315 wxPySaveThread(doSave); \
320 //---------------------------------------------------------------------------
322 #define DEC_PYCALLBACK__DC(CBNAME) \
323 void CBNAME(wxDC& a); \
324 void base_##CBNAME(wxDC& a);
327 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
328 void CLASS::CBNAME(wxDC& a) { \
329 bool doSave = wxPyRestoreThread(); \
330 if (m_myInst.findCallback(#CBNAME)) \
331 m_myInst.callCallback(Py_BuildValue("(O)", \
332 wxPyConstructObject(&a, "wxDC"))); \
335 wxPySaveThread(doSave); \
337 void CLASS::base_##CBNAME(wxDC& a) { \
343 //---------------------------------------------------------------------------
345 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
346 void CBNAME(wxDC& a, bool b); \
347 void base_##CBNAME(wxDC& a, bool b);
350 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
351 void CLASS::CBNAME(wxDC& a, bool b) { \
352 bool doSave = wxPyRestoreThread(); \
353 if (m_myInst.findCallback(#CBNAME)) \
354 m_myInst.callCallback(Py_BuildValue("(Oi)", \
355 wxPyConstructObject(&a, "wxDC"), (int)b)); \
357 PCLASS::CBNAME(a, b); \
358 wxPySaveThread(doSave); \
360 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
361 PCLASS::CBNAME(a, b); \
364 //---------------------------------------------------------------------------
366 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
367 void CBNAME(wxDC& a, bool b); \
368 void base_##CBNAME(wxDC& a, bool b);
371 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
372 void CLASS::CBNAME(wxDC& a, bool b) { \
373 bool doSave = wxPyRestoreThread(); \
374 if (m_myInst.findCallback(#CBNAME)) \
375 m_myInst.callCallback(Py_BuildValue("(Oi)", \
376 wxPyConstructObject(&a, "wxDC"), (int)b)); \
378 PCLASS::CBNAME(a, b); \
379 wxPySaveThread(doSave); \
381 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
382 PCLASS::CBNAME(a, b); \
385 //---------------------------------------------------------------------------
387 #define DEC_PYCALLBACK__2DBL(CBNAME) \
388 void CBNAME(double a, double b); \
389 void base_##CBNAME(double a, double b);
392 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
393 void CLASS::CBNAME(double a, double b) { \
394 bool doSave = wxPyRestoreThread(); \
395 if (m_myInst.findCallback(#CBNAME)) \
396 m_myInst.callCallback(Py_BuildValue("(dd)",a,b)); \
398 PCLASS::CBNAME(a, b); \
399 wxPySaveThread(doSave); \
401 void CLASS::base_##CBNAME(double a, double b) { \
402 PCLASS::CBNAME(a, b); \
405 //---------------------------------------------------------------------------
407 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
408 void CBNAME(double a, double b, int c, int d); \
409 void base_##CBNAME(double a, double b, int c, int d);
412 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
413 void CLASS::CBNAME(double a, double b, int c, int d) { \
414 bool doSave = wxPyRestoreThread(); \
415 if (m_myInst.findCallback(#CBNAME)) \
416 m_myInst.callCallback(Py_BuildValue("(ddii)", \
419 PCLASS::CBNAME(a, b, c, d); \
420 wxPySaveThread(doSave); \
422 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
423 PCLASS::CBNAME(a, b, c, d); \
426 //---------------------------------------------------------------------------
428 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
429 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
430 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
433 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
434 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
435 bool doSave = wxPyRestoreThread(); \
436 if (m_myInst.findCallback(#CBNAME)) \
437 m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
438 wxPyConstructObject(&a, "wxDC"), \
439 b, c, d, e, (int)f)); \
441 PCLASS::CBNAME(a, b, c, d, e, f); \
442 wxPySaveThread(doSave); \
444 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
445 PCLASS::CBNAME(a, b, c, d, e, f); \
448 //---------------------------------------------------------------------------
450 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
451 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
452 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f);
455 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
456 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
457 bool doSave = wxPyRestoreThread(); \
459 if (m_myInst.findCallback(#CBNAME)) \
460 rval = m_myInst.callCallback(Py_BuildValue("(Oddddi)", \
461 wxPyConstructObject(&a, "wxDC"), \
462 b, c, d, e, (int)f)); \
464 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
465 wxPySaveThread(doSave); \
468 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
469 return PCLASS::CBNAME(a, b, c, d, e, f); \
472 //---------------------------------------------------------------------------
474 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
475 void CBNAME(bool a, double b, double c, int d, int e); \
476 void base_##CBNAME(bool a, double b, double c, int d, int e);
479 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
480 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
481 bool doSave = wxPyRestoreThread(); \
482 if (m_myInst.findCallback(#CBNAME)) \
483 m_myInst.callCallback(Py_BuildValue("(idii)", \
486 PCLASS::CBNAME(a, b, c, d, e); \
487 wxPySaveThread(doSave); \
489 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
490 PCLASS::CBNAME(a, b, c, d, e); \
493 //---------------------------------------------------------------------------
495 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
496 void CBNAME(wxDC& a, double b, double c, double d, double e); \
497 void base_##CBNAME(wxDC& a, double b, double c, double d, double e);
500 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
501 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
502 bool doSave = wxPyRestoreThread(); \
503 if (m_myInst.findCallback(#CBNAME)) \
504 m_myInst.callCallback(Py_BuildValue("(Odddd)", \
505 wxPyConstructObject(&a, "wxDC"), \
508 PCLASS::CBNAME(a, b, c, d, e); \
509 wxPySaveThread(doSave); \
511 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
512 PCLASS::CBNAME(a, b, c, d, e); \
515 //---------------------------------------------------------------------------
517 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
518 void CBNAME(wxDC& a, bool b); \
519 void base_##CBNAME(wxDC& a, bool b);
522 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
523 void CLASS::CBNAME(wxDC& a, bool b) { \
524 bool doSave = wxPyRestoreThread(); \
525 if (m_myInst.findCallback(#CBNAME)) \
526 m_myInst.callCallback(Py_BuildValue("(Oi)", \
527 wxPyConstructObject(&a, "wxDC"), \
530 PCLASS::CBNAME(a, b); \
531 wxPySaveThread(doSave); \
533 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
534 PCLASS::CBNAME(a, b); \
537 //---------------------------------------------------------------------------
539 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
540 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
541 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);
544 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
545 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
547 bool doSave = wxPyRestoreThread(); \
548 if (m_myInst.findCallback(#CBNAME)) \
549 m_myInst.callCallback(Py_BuildValue("(Oiddii)", \
550 wxPyConstructObject(a, "wxPyControlPoint"), \
551 (int)b, c, d, e, f)); \
553 PCLASS::CBNAME(a, b, c, d, e, f); \
554 wxPySaveThread(doSave); \
556 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
558 PCLASS::CBNAME(a, b, c, d, e, f); \
561 //---------------------------------------------------------------------------
563 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
564 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
565 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e);
568 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
569 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
570 bool doSave = wxPyRestoreThread(); \
571 if (m_myInst.findCallback(#CBNAME)) \
572 m_myInst.callCallback(Py_BuildValue("(Oddii)", \
573 wxPyConstructObject(a, "wxPyControlPoint"), \
576 PCLASS::CBNAME(a, b, c, d, e); \
577 wxPySaveThread(doSave); \
579 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
581 PCLASS::CBNAME(a, b, c, d, e); \
584 //---------------------------------------------------------------------------
586 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
587 void CBNAME(double a, double b, int c); \
588 void base_##CBNAME(double a, double b, int c);
591 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
592 void CLASS::CBNAME(double a, double b, int c) { \
593 bool doSave = wxPyRestoreThread(); \
594 if (m_myInst.findCallback(#CBNAME)) \
595 m_myInst.callCallback(Py_BuildValue("(ddi)", a,b,c)); \
597 PCLASS::CBNAME(a, b, c); \
598 wxPySaveThread(doSave); \
600 void CLASS::base_##CBNAME(double a, double b, int c) { \
601 PCLASS::CBNAME(a, b, c); \
604 //---------------------------------------------------------------------------
606 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
607 void CBNAME(bool a, double b, double c, int d); \
608 void base_##CBNAME(bool a, double b, double c, int d);
611 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
612 void CLASS::CBNAME(bool a, double b, double c, int d) { \
613 bool doSave = wxPyRestoreThread(); \
614 if (m_myInst.findCallback(#CBNAME)) \
615 m_myInst.callCallback(Py_BuildValue("(iddi)", (int)a,b,c,d)); \
617 PCLASS::CBNAME(a, b, c, d); \
618 wxPySaveThread(doSave); \
620 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
621 PCLASS::CBNAME(a, b, c, d); \
624 //---------------------------------------------------------------------------
625 //---------------------------------------------------------------------------
627 #define DEC_PYCALLBACK__STRING(CBNAME) \
628 void CBNAME(const wxString& a); \
629 void base_##CBNAME(const wxString& a);
632 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
633 void CLASS::CBNAME(const wxString& a) { \
634 bool doSave = wxPyRestoreThread(); \
635 if (m_myInst.findCallback(#CBNAME)) \
636 m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
639 wxPySaveThread(doSave); \
641 void CLASS::base_##CBNAME(const wxString& a) { \
645 //---------------------------------------------------------------------------
647 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
648 bool CBNAME(const wxString& a); \
649 bool base_##CBNAME(const wxString& a);
652 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
653 bool CLASS::CBNAME(const wxString& a) { \
655 bool doSave = wxPyRestoreThread(); \
656 if (m_myInst.findCallback(#CBNAME)) \
657 rval = m_myInst.callCallback(Py_BuildValue("(s)", a.c_str())); \
659 rval = PCLASS::CBNAME(a); \
660 wxPySaveThread(doSave); \
663 bool CLASS::base_##CBNAME(const wxString& a) { \
664 return PCLASS::CBNAME(a); \
667 //---------------------------------------------------------------------------
669 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
670 bool CBNAME(const wxString& a, const wxString& b); \
671 bool base_##CBNAME(const wxString& a, const wxString& b);
674 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
675 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
677 bool doSave = wxPyRestoreThread(); \
678 if (m_myInst.findCallback(#CBNAME)) \
679 rval = m_myInst.callCallback(Py_BuildValue("(ss)", \
680 a.c_str(), b.c_str())); \
682 rval = PCLASS::CBNAME(a, b); \
683 wxPySaveThread(doSave); \
686 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
687 return PCLASS::CBNAME(a, b); \
690 //---------------------------------------------------------------------------
692 #define DEC_PYCALLBACK_STRING_(CBNAME) \
694 wxString base_##CBNAME();
697 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
698 wxString CLASS::CBNAME() { \
700 bool doSave = wxPyRestoreThread(); \
701 if (m_myInst.findCallback(#CBNAME)) { \
703 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
704 rval = PyString_AsString(PyObject_Str(ro)); \
707 rval = PCLASS::CBNAME(); \
708 wxPySaveThread(doSave); \
711 wxString CLASS::base_##CBNAME() { \
712 return PCLASS::CBNAME(); \
715 //---------------------------------------------------------------------------
717 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
721 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
722 wxString CLASS::CBNAME() { \
724 bool doSave = wxPyRestoreThread(); \
725 if (m_myInst.findCallback(#CBNAME)) { \
727 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
728 rval = PyString_AsString(PyObject_Str(ro)); \
730 wxPySaveThread(doSave); \
734 //---------------------------------------------------------------------------
736 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
737 bool CBNAME(const wxHtmlTag& a); \
740 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
741 bool CLASS::CBNAME(const wxHtmlTag& a) { \
743 bool doSave = wxPyRestoreThread(); \
744 if (m_myInst.findCallback(#CBNAME)) \
745 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
746 wxPyConstructObject((void*)&a,"wxHtmlTag"))); \
747 wxPySaveThread(doSave); \
751 //---------------------------------------------------------------------------
753 #define DEC_PYCALLBACK___pure(CBNAME) \
757 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
758 void CLASS::CBNAME() { \
759 bool doSave = wxPyRestoreThread(); \
760 if (m_myInst.findCallback(#CBNAME)) \
761 m_myInst.callCallback(Py_BuildValue("()")); \
762 wxPySaveThread(doSave); \
765 //---------------------------------------------------------------------------
767 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
771 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
772 wxSize CLASS::CBNAME() { \
774 bool doSave = wxPyRestoreThread(); \
775 if (m_myInst.findCallback(#CBNAME)) { \
778 ro = m_myInst.callCallbackObj(Py_BuildValue("()")); \
779 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p")) \
782 wxPySaveThread(doSave); \
786 //---------------------------------------------------------------------------
788 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
789 bool CBNAME(wxWindow* a); \
790 bool base_##CBNAME(wxWindow* a);
793 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
794 bool CLASS::CBNAME(wxWindow* a) { \
796 bool doSave = wxPyRestoreThread(); \
797 if (m_myInst.findCallback(#CBNAME)) \
798 rval = m_myInst.callCallback(Py_BuildValue("(O)", \
799 wxPyConstructObject((void*)a,"wxWindow"))); \
801 rval = PCLASS::CBNAME(a); \
802 wxPySaveThread(doSave); \
805 bool CLASS::base_##CBNAME(wxWindow* a) { \
806 return PCLASS::CBNAME(a); \
809 //---------------------------------------------------------------------------
811 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
813 bool base_##CBNAME();
816 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
817 bool CLASS::CBNAME() { \
819 bool doSave = wxPyRestoreThread(); \
820 if (m_myInst.findCallback(#CBNAME)) \
821 rval = m_myInst.callCallback(Py_BuildValue("()")); \
823 rval = PCLASS::CBNAME(); \
824 wxPySaveThread(doSave); \
827 bool CLASS::base_##CBNAME() { \
828 return PCLASS::CBNAME(); \
831 //---------------------------------------------------------------------------
833 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
834 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
835 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def);
838 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
839 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
840 bool doSave = wxPyRestoreThread(); \
842 if (m_myInst.findCallback(#CBNAME)) \
843 rval = m_myInst.callCallback(Py_BuildValue("(iii)", a,b,c));\
845 rval = PCLASS::CBNAME(a, b, c); \
846 wxPySaveThread(doSave); \
847 return (wxDragResult)rval; \
849 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
850 return PCLASS::CBNAME(a, b, c); \
853 //---------------------------------------------------------------------------
855 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
856 bool CBNAME(wxDragResult a); \
857 bool base_##CBNAME(wxDragResult a);
860 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
861 bool CLASS::CBNAME(wxDragResult a) { \
862 bool doSave = wxPyRestoreThread(); \
864 if (m_myInst.findCallback(#CBNAME)) \
865 rval = m_myInst.callCallback(Py_BuildValue("(i)", a)); \
867 rval = PCLASS::CBNAME(a); \
868 wxPySaveThread(doSave); \
871 bool CLASS::base_##CBNAME(wxDragResult a) { \
872 return PCLASS::CBNAME(a); \
875 //---------------------------------------------------------------------------
877 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
878 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);
881 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
882 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
883 bool doSave = wxPyRestoreThread(); \
885 if (m_myInst.findCallback(#CBNAME)) \
886 rval = m_myInst.callCallback(Py_BuildValue("(iii)", a,b,c));\
887 wxPySaveThread(doSave); \
888 return (wxDragResult)rval; \
891 //---------------------------------------------------------------------------
893 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
894 bool CBNAME(int a, int b, const wxString& c);
897 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
898 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
900 bool doSave = wxPyRestoreThread(); \
901 if (m_myInst.findCallback(#CBNAME)) \
902 rval = m_myInst.callCallback(Py_BuildValue("(iis)",a,b,c.c_str()));\
903 wxPySaveThread(doSave); \
907 //---------------------------------------------------------------------------
909 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
911 size_t base_##CBNAME();
914 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
915 size_t CLASS::CBNAME() { \
917 bool doSave = wxPyRestoreThread(); \
918 if (m_myInst.findCallback(#CBNAME)) \
919 rval = m_myInst.callCallback(Py_BuildValue("()")); \
921 rval = PCLASS::CBNAME(); \
922 wxPySaveThread(doSave); \
925 size_t CLASS::base_##CBNAME() { \
926 return PCLASS::CBNAME(); \
929 //---------------------------------------------------------------------------
931 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
932 wxDataFormat CBNAME(); \
933 wxDataFormat base_##CBNAME();
936 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
937 wxDataFormat CLASS::CBNAME(size_t a) { \
939 bool doSave = wxPyRestoreThread(); \
940 if (m_myInst.findCallback(#CBNAME)) { \
943 ro = m_myInst.callCallbackObj(Py_BuildValue("(i)", a)); \
944 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p")) \
948 rval = PCLASS::CBNAME(a); \
949 wxPySaveThread(doSave); \
952 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
953 return PCLASS::CBNAME(a); \
956 //---------------------------------------------------------------------------
957 //---------------------------------------------------------------------------
958 //---------------------------------------------------------------------------