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__ 
  18 //---------------------------------------------------------------------- 
  20 // if we want to handle threads and Python threads are available... 
  21 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD) 
  23 #define WXP_WITH_THREAD 
  24 #define wxPy_BEGIN_ALLOW_THREADS  Py_BEGIN_ALLOW_THREADS 
  25 #define wxPy_END_ALLOW_THREADS    Py_END_ALLOW_THREADS 
  27 #else  // no Python threads... 
  28 #undef WXP_WITH_THREAD 
  29 #define wxPy_BEGIN_ALLOW_THREADS 
  30 #define wxPy_END_ALLOW_THREADS 
  34 //--------------------------------------------------------------------------- 
  36 typedef unsigned char byte
; 
  39 class wxPyApp
: public wxApp
 
  47 extern wxPyApp 
*wxPythonApp
; 
  49 //---------------------------------------------------------------------- 
  52 PyObject
* __wxStart(PyObject
*, PyObject
* args
); 
  55 //extern PyObject* wxPython_dict; 
  56 PyObject
* __wxSetDictionary(PyObject
*, PyObject
* args
); 
  58 void wxPyEventThunker(wxObject
*, wxEvent
& event
); 
  60 PyObject
* wxPyConstructObject(void* ptr
, 
  61                               const char* className
, 
  63 PyObject
* wxPyConstructObject(void* ptr
, 
  64                               const char* className
, 
  67 PyObject
*  wxPyClassExists(const char* className
); 
  68 PyObject
*  wxPyMake_wxObject(wxObject
* source
); 
  69 void       wxPyPtrTypeMap_Add(const char* commonName
, const char* ptrName
); 
  71 PyObject
* wxPy_ConvertList(wxListBase
* list
, const char* className
); 
  72 long wxPyGetWinHandle(wxWindow
* win
); 
  74 //---------------------------------------------------------------------- 
  77     PyThreadState
* newState
; 
  78     PyThreadState
* prevState
; 
  80     wxPyTState() : newState(NULL
), prevState(NULL
) {} 
  84 wxPyTState
* wxPyBeginBlockThreads(); 
  85 void        wxPyEndBlockThreads(wxPyTState
* state
); 
  88 //---------------------------------------------------------------------- 
  89 // Handle wxInputStreams by Joerg Baumann 
  90 // See stream.i for implementations 
  92 // list class for return list of strings, e.g. readlines() 
  93 WX_DECLARE_LIST(wxString
, wxStringPtrList
); 
  96 // C++ class wxPyInputStream to act as base for python class wxInputStream 
  97 // Use it in python like a python file object 
  98 class wxPyInputStream 
{ 
 100     // underlying wxInputStream 
 104     wxPyInputStream(wxInputStream
* wxi_
) : wxi(wxi_
) {} 
 107     // python file object interface for input files (most of it) 
 111     wxString
* read(int size
=-1); 
 112     wxString
* readline(int size
=-1); 
 113     wxStringPtrList
* readlines(int sizehint
=-1); 
 114     void seek(int offset
, int whence
=0); 
 119       void truncate(int size=-1); 
 120       void write(wxString data); 
 121       void writelines(wxStringPtrList); 
 126 //---------------------------------------------------------------------- 
 127 // These are helpers used by the typemaps 
 129 byte
* byte_LIST_helper(PyObject
* source
); 
 130 int* int_LIST_helper(PyObject
* source
); 
 131 long* long_LIST_helper(PyObject
* source
); 
 132 char** string_LIST_helper(PyObject
* source
); 
 133 wxPoint
* wxPoint_LIST_helper(PyObject
* source
, int* npoints
); 
 134 wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
); 
 135 wxString
* wxString_LIST_helper(PyObject
* source
); 
 136 wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
); 
 138 bool wxSize_helper(PyObject
* source
, wxSize
** obj
); 
 139 bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
); 
 140 bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
); 
 141 bool wxRect_helper(PyObject
* source
, wxRect
** obj
); 
 142 bool wxColour_helper(PyObject
* source
, wxColour
** obj
); 
 144 //---------------------------------------------------------------------- 
 147 extern "C" void SWIG_MakePtr(char *, void *, char *); 
 148 extern "C" char *SWIG_GetPtr(char *, void **, char *); 
 149 extern "C" char *SWIG_GetPtrObj(PyObject 
*obj
, void **ptr
, char *type
); 
 154 # pragma warning(disable:4800) 
 155 # pragma warning(disable:4190) 
 158 //---------------------------------------------------------------------- 
 160 class wxPyCallback 
: public wxObject 
{ 
 161     DECLARE_ABSTRACT_CLASS(wxPyCallback
); 
 163     wxPyCallback(PyObject
* func
); 
 164     wxPyCallback(const wxPyCallback
& other
); 
 167     void EventThunker(wxEvent
& event
); 
 172 //--------------------------------------------------------------------------- 
 174 class wxPyTimer 
: public wxTimer 
{ 
 176     wxPyTimer(PyObject
* callback
); 
 185 //--------------------------------------------------------------------------- 
 186 //--------------------------------------------------------------------------- 
 187 // These Event classes can be derived from in Python and passed through the 
 188 // event system without loosing anything.  They do this by keeping a reference 
 189 // to 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 // Export a C API in a struct.  Other modules will be able to load this from 
 228 // the wxc module and will then have safe access to these functions, even if 
 229 // in another shared library. 
 231 class wxPyCallbackHelper
; 
 235     void        (*p_SWIG_MakePtr
)(char*, void*, char*); 
 236     char*       (*p_SWIG_GetPtr
)(char*, void**, char*); 
 237     char*       (*p_SWIG_GetPtrObj
)(PyObject
*, void**, char*); 
 238     void        (*p_SWIG_RegisterMapping
)(char*, char*, void *(*cast
)(void *)); 
 239     void        (*p_SWIG_addvarlink
)(PyObject
*, char*, PyObject 
*(*get_attr
)(void), int (*set_attr
)(PyObject 
*p
)); 
 240     PyObject
*   (*p_SWIG_newvarlink
)(void); 
 242     wxPyTState
* (*p_wxPyBeginBlockThreads
)(); 
 243     void        (*p_wxPyEndBlockThreads
)(wxPyTState
* state
); 
 245     PyObject
*   (*p_wxPyConstructObject
)(void *, const char *, int); 
 246     PyObject
*   (*p_wxPy_ConvertList
)(wxListBase
* list
, const char* className
); 
 248     byte
*       (*p_byte_LIST_helper
)(PyObject
* source
); 
 249     int*        (*p_int_LIST_helper
)(PyObject
* source
); 
 250     long*       (*p_long_LIST_helper
)(PyObject
* source
); 
 251     char**      (*p_string_LIST_helper
)(PyObject
* source
); 
 252     wxPoint
*    (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
); 
 253     wxBitmap
**  (*p_wxBitmap_LIST_helper
)(PyObject
* source
); 
 254     wxString
*   (*p_wxString_LIST_helper
)(PyObject
* source
); 
 255     wxAcceleratorEntry
*   (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
); 
 257     bool        (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
); 
 258     bool        (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
); 
 259     bool        (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
); 
 260     bool        (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
); 
 261     bool        (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
); 
 263     void        (*p_wxPyCBH_setSelf
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
); 
 264     bool        (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
); 
 265     int         (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
); 
 266     PyObject
*   (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
); 
 267     void        (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
); 
 269     PyObject
*   (*p_wxPyClassExists
)(const char* className
); 
 270     PyObject
*   (*p_wxPyMake_wxObject
)(wxObject
* source
); 
 271     void        (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
); 
 275 #ifdef wxPyUSE_EXPORT 
 276 static wxPyCoreAPI
* wxPyCoreAPIPtr 
= NULL
;  // Each module needs one, but may not use it. 
 279 //--------------------------------------------------------------------------- 
 280 // This class holds an instance of a Python Shadow Class object and assists 
 281 // with looking up and invoking Python callback methods from C++ virtual 
 282 // method redirections.  For all classes which have virtuals which should be 
 283 // overridable in wxPython, a new subclass is created that contains a 
 284 // wxPyCallbackHelper. 
 287 class wxPyCallbackHelper 
{ 
 289     wxPyCallbackHelper(const wxPyCallbackHelper
& other
); 
 291     wxPyCallbackHelper() { 
 298     ~wxPyCallbackHelper() { 
 299 #ifdef wxPyUSE_EXPORT 
 300         wxPyCoreAPIPtr
->p_wxPyCBH_delete(this); 
 302         wxPyCBH_delete(this); 
 306     void        setSelf(PyObject
* self
, PyObject
* klass
, int incref
=TRUE
); 
 307     bool        findCallback(const char* name
) const; 
 308     int         callCallback(PyObject
* argTuple
) const; 
 309     PyObject
*   callCallbackObj(PyObject
* argTuple
) const; 
 314     PyObject
*   m_lastFound
; 
 317     friend      void wxPyCBH_delete(wxPyCallbackHelper
* cbh
); 
 321 void wxPyCBH_setSelf(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
); 
 322 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
); 
 323 int  wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
); 
 324 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
); 
 325 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
); 
 329 //---------------------------------------------------------------------- 
 331 class wxPyUserData 
: public wxObject 
{ 
 333     wxPyUserData(PyObject
* obj
) { 
 339 #ifdef wxPyUSE_EXPORT 
 340         wxPyTState
* state 
= wxPyCoreAPIPtr
->p_wxPyBeginBlockThreads(); 
 342         wxPyCoreAPIPtr
->p_wxPyEndBlockThreads(state
); 
 344         wxPyTState
* state 
= wxPyBeginBlockThreads(); 
 346         wxPyEndBlockThreads(state
); 
 354 //--------------------------------------------------------------------------- 
 355 // These macros are used to implement the virtual methods that should 
 356 // redirect to a Python method if one exists.  The names designate the 
 357 // return type, if any, as well as any parameter types. 
 358 //--------------------------------------------------------------------------- 
 361     void _setSelf(PyObject* self, PyObject* _class, int incref=1) {     \ 
 362         wxPyCBH_setSelf(m_myInst, self, _class, incref);                \ 
 364     private: wxPyCallbackHelper m_myInst 
 366 //--------------------------------------------------------------------------- 
 368 #define DEC_PYCALLBACK__(CBNAME)                        \ 
 370     void base_##CBNAME(); 
 373 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME)                         \ 
 374     void CLASS::CBNAME() {                                              \ 
 376         wxPyTState* state = wxPyBeginBlockThreads();                    \ 
 377         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))          \ 
 378             wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));        \ 
 379         wxPyEndBlockThreads(state);                                     \ 
 383     void CLASS::base_##CBNAME() {                                       \ 
 387 //--------------------------------------------------------------------------- 
 389 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME)                      \ 
 390     bool CBNAME(int a, int b);                                  \ 
 391     bool base_##CBNAME(int a, int b); 
 394 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME)               \ 
 395     bool CLASS::CBNAME(int a, int b) {                                  \ 
 397         wxPyTState* state = wxPyBeginBlockThreads();                    \ 
 398         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))          \ 
 399             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b));    \ 
 400         wxPyEndBlockThreads(state);                                     \ 
 402             rval = PCLASS::CBNAME(a,b);                                 \ 
 405     bool CLASS::base_##CBNAME(int a, int b) {                           \ 
 406         return PCLASS::CBNAME(a,b);                                     \ 
 409 //--------------------------------------------------------------------------- 
 411 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME)                      \ 
 412     void CBNAME(int a, int b);                                  \ 
 413     void base_##CBNAME(int a, int b); 
 416 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME)               \ 
 417     void CLASS::CBNAME(int a, int b) {                                  \ 
 419         wxPyTState* state = wxPyBeginBlockThreads();                    \ 
 420         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))          \ 
 421             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b));  \ 
 422         wxPyEndBlockThreads(state);                                     \ 
 424             PCLASS::CBNAME(a,b);                                        \ 
 426     void CLASS::base_##CBNAME(int a, int b) {                           \ 
 427         PCLASS::CBNAME(a,b);                                            \ 
 430 //--------------------------------------------------------------------------- 
 432 #define DEC_PYCALLBACK_BOOL_INT(CBNAME)                         \ 
 433     bool CBNAME(int a);                                         \ 
 434     bool base_##CBNAME(int a); 
 437 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME)                  \ 
 438     bool CLASS::CBNAME(int a) {                                         \ 
 440         wxPyTState* state = wxPyBeginBlockThreads();                    \ 
 441         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))          \ 
 442             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));       \ 
 443         wxPyEndBlockThreads(state);                                     \ 
 445             rval = PCLASS::CBNAME(a);                                   \ 
 448     bool CLASS::base_##CBNAME(int a) {                                  \ 
 449         return PCLASS::CBNAME(a);                                       \ 
 452 //--------------------------------------------------------------------------- 
 454 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME)            \ 
 458 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME)             \ 
 459     bool CLASS::CBNAME(int a) {                                         \ 
 461         wxPyTState* state = wxPyBeginBlockThreads();                    \ 
 462         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                    \ 
 463             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));       \ 
 465         wxPyEndBlockThreads(state);                                     \ 
 470 //--------------------------------------------------------------------------- 
 472 #define DEC_PYCALLBACK__DC(CBNAME)                      \ 
 473     void CBNAME(wxDC& a);                               \ 
 474     void base_##CBNAME(wxDC& a); 
 477 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME)                       \ 
 478     void CLASS::CBNAME(wxDC& a) {                                       \ 
 480         wxPyTState* state = wxPyBeginBlockThreads();                    \ 
 481         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {        \ 
 482             PyObject* obj = wxPyMake_wxObject(&a);                      \ 
 483             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));  \ 
 486         wxPyEndBlockThreads(state);                                     \ 
 490     void CLASS::base_##CBNAME(wxDC& a) {                                \ 
 496 //--------------------------------------------------------------------------- 
 498 #define DEC_PYCALLBACK__DCBOOL(CBNAME)                  \ 
 499     void CBNAME(wxDC& a, bool b);                       \ 
 500     void base_##CBNAME(wxDC& a, bool b); 
 503 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME)                   \ 
 504     void CLASS::CBNAME(wxDC& a, bool b) {                               \ 
 506         wxPyTState* state = wxPyBeginBlockThreads();                    \ 
 507         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {        \ 
 508             PyObject* obj = wxPyMake_wxObject(&a);                      \ 
 509             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b));  \ 
 512         wxPyEndBlockThreads(state);                                     \ 
 514             PCLASS::CBNAME(a, b);                                       \ 
 516     void CLASS::base_##CBNAME(wxDC& a, bool b) {                        \ 
 517         PCLASS::CBNAME(a, b);                                           \ 
 520 //--------------------------------------------------------------------------- 
 522 #define DEC_PYCALLBACK__DCBOOL(CBNAME)                          \ 
 523     void CBNAME(wxDC& a, bool b);                               \ 
 524     void base_##CBNAME(wxDC& a, bool b); 
 527 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME)                   \ 
 528     void CLASS::CBNAME(wxDC& a, bool b) {                               \ 
 530         wxPyTState* state = wxPyBeginBlockThreads();                    \ 
 531         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {        \ 
 532             PyObject* obj = wxPyMake_wxObject(&a);                      \ 
 533             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b));  \ 
 536         wxPyEndBlockThreads(state);                                     \ 
 538             PCLASS::CBNAME(a, b);                                       \ 
 540     void CLASS::base_##CBNAME(wxDC& a, bool b) {                        \ 
 541         PCLASS::CBNAME(a, b);                                           \ 
 544 //--------------------------------------------------------------------------- 
 546 #define DEC_PYCALLBACK__2DBL(CBNAME)                    \ 
 547     void CBNAME(double a, double b);                    \ 
 548     void base_##CBNAME(double a, double b); 
 551 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME)                     \ 
 552     void CLASS::CBNAME(double a, double b) {                            \ 
 554         wxPyTState* state = wxPyBeginBlockThreads();                    \ 
 555         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))          \ 
 556             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b));  \ 
 557         wxPyEndBlockThreads(state);                                     \ 
 559             PCLASS::CBNAME(a, b);                                       \ 
 561     void CLASS::base_##CBNAME(double a, double b) {                     \ 
 562         PCLASS::CBNAME(a, b);                                           \ 
 565 //--------------------------------------------------------------------------- 
 567 #define DEC_PYCALLBACK__2DBL2INT(CBNAME)                        \ 
 568     void CBNAME(double a, double b, int c, int d);              \ 
 569     void base_##CBNAME(double a, double b, int c, int d); 
 572 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME)                 \ 
 573     void CLASS::CBNAME(double a, double b, int c, int d) {              \ 
 575         wxPyTState* state = wxPyBeginBlockThreads();                    \ 
 576         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))          \ 
 577             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)",      \ 
 579         wxPyEndBlockThreads(state);                                     \ 
 581             PCLASS::CBNAME(a, b, c, d);                                 \ 
 583     void CLASS::base_##CBNAME(double a, double b, int c, int d) {       \ 
 584         PCLASS::CBNAME(a, b, c, d);                                     \ 
 587 //--------------------------------------------------------------------------- 
 589 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME)                                      \ 
 590     void CBNAME(wxDC& a, double b, double c, double d, double e, bool f);       \ 
 591     void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f); 
 594 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME)                               \ 
 595     void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {       \ 
 597         wxPyTState* state = wxPyBeginBlockThreads();                                    \ 
 598         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                        \ 
 599             PyObject* obj = wxPyMake_wxObject(&a);                                      \ 
 600             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));  \ 
 603         wxPyEndBlockThreads(state);                                                     \ 
 605             PCLASS::CBNAME(a, b, c, d, e, f);                                           \ 
 607     void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\ 
 608         PCLASS::CBNAME(a, b, c, d, e, f);                                               \ 
 611 //--------------------------------------------------------------------------- 
 613 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME)                                  \ 
 614     bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f);       \ 
 615     bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f); 
 618 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME)                           \ 
 619     bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {       \ 
 621         wxPyTState* state = wxPyBeginBlockThreads();                                    \ 
 623         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                        \ 
 624             PyObject* obj = wxPyMake_wxObject(&a);                                      \ 
 625             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\ 
 628         wxPyEndBlockThreads(state);                                                     \ 
 630             rval = PCLASS::CBNAME(a, b, c, d, e, f);                                    \ 
 633     bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\ 
 634         return PCLASS::CBNAME(a, b, c, d, e, f);                                        \ 
 637 //--------------------------------------------------------------------------- 
 639 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME)                            \ 
 640     void CBNAME(bool a, double b, double c, int d, int e);              \ 
 641     void base_##CBNAME(bool a, double b, double c, int d, int e); 
 644 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME)                     \ 
 645     void CLASS::CBNAME(bool a, double b, double c, int d, int e) {              \ 
 647         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
 648         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \ 
 649             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)",             \ 
 651         wxPyEndBlockThreads(state);                                             \ 
 653             PCLASS::CBNAME(a, b, c, d, e);                                      \ 
 655     void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) {       \ 
 656         PCLASS::CBNAME(a, b, c, d, e);                                          \ 
 659 //--------------------------------------------------------------------------- 
 661 #define DEC_PYCALLBACK__DC4DBL(CBNAME)                                          \ 
 662     void CBNAME(wxDC& a, double b, double c, double d, double e);               \ 
 663     void base_##CBNAME(wxDC& a, double b, double c, double d, double e); 
 666 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME)                           \ 
 667     void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) {       \ 
 669         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
 670         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \ 
 671             PyObject* obj = wxPyMake_wxObject(&a);                              \ 
 672             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e));   \ 
 675         wxPyEndBlockThreads(state);                                             \ 
 677             PCLASS::CBNAME(a, b, c, d, e);                                      \ 
 679     void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\ 
 680         PCLASS::CBNAME(a, b, c, d, e);                                          \ 
 683 //--------------------------------------------------------------------------- 
 685 #define DEC_PYCALLBACK__DCBOOL(CBNAME)                  \ 
 686     void CBNAME(wxDC& a, bool b);                       \ 
 687     void base_##CBNAME(wxDC& a, bool b); 
 690 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME)                           \ 
 691     void CLASS::CBNAME(wxDC& a, bool b) {                                       \ 
 693         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
 694         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \ 
 695             PyObject* obj = wxPyMake_wxObject(&a);                              \ 
 696             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \ 
 699         wxPyEndBlockThreads(state);                                             \ 
 701             PCLASS::CBNAME(a, b);                                               \ 
 703     void CLASS::base_##CBNAME(wxDC& a, bool b) {                                \ 
 704         PCLASS::CBNAME(a, b);                                                   \ 
 707 //--------------------------------------------------------------------------- 
 709 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME)                                \ 
 710     void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f);   \ 
 711     void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); 
 714 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME)                 \ 
 715     void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d,           \ 
 718         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
 719         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \ 
 720             PyObject* obj = wxPyMake_wxObject(a);                               \ 
 721             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\ 
 724         wxPyEndBlockThreads(state);                                             \ 
 726             PCLASS::CBNAME(a, b, c, d, e, f);                                   \ 
 728     void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d,    \ 
 730         PCLASS::CBNAME(a, b, c, d, e, f);                                       \ 
 733 //--------------------------------------------------------------------------- 
 735 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME)                                    \ 
 736     void CBNAME(wxControlPoint* a, double b, double c, int d, int e);           \ 
 737     void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e); 
 740 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME)                     \ 
 741     void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) {   \ 
 743         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
 744         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \ 
 745             PyObject* obj = wxPyMake_wxObject(a);                               \ 
 746             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e));   \ 
 749         wxPyEndBlockThreads(state);                                             \ 
 751             PCLASS::CBNAME(a, b, c, d, e);                                      \ 
 753     void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c,            \ 
 755         PCLASS::CBNAME(a, b, c, d, e);                                          \ 
 758 //--------------------------------------------------------------------------- 
 760 #define DEC_PYCALLBACK__2DBLINT(CBNAME)                 \ 
 761     void CBNAME(double a, double b, int c);             \ 
 762     void base_##CBNAME(double a, double b, int c); 
 765 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME)                          \ 
 766     void CLASS::CBNAME(double a, double b, int c) {                             \ 
 768         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
 769         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \ 
 770             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c));      \ 
 771         wxPyEndBlockThreads(state);                                             \ 
 773             PCLASS::CBNAME(a, b, c);                                            \ 
 775     void CLASS::base_##CBNAME(double a, double b, int c) {                      \ 
 776         PCLASS::CBNAME(a, b, c);                                                \ 
 779 //--------------------------------------------------------------------------- 
 781 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME)                     \ 
 782     void CBNAME(bool a, double b, double c, int d);             \ 
 783     void base_##CBNAME(bool a, double b, double c, int d); 
 786 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME)                      \ 
 787     void CLASS::CBNAME(bool a, double b, double c, int d) {                     \ 
 789         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
 790         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \ 
 791             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\ 
 792         wxPyEndBlockThreads(state);                                             \ 
 794             PCLASS::CBNAME(a, b, c, d);                                         \ 
 796     void CLASS::base_##CBNAME(bool a, double b, double c, int d) {              \ 
 797         PCLASS::CBNAME(a, b, c, d);                                             \ 
 800 //--------------------------------------------------------------------------- 
 801 //--------------------------------------------------------------------------- 
 803 #define DEC_PYCALLBACK__STRING(CBNAME)                  \ 
 804     void CBNAME(const wxString& a);                     \ 
 805     void base_##CBNAME(const wxString& a); 
 808 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME)                           \ 
 809     void CLASS::CBNAME(const wxString& a)  {                                    \ 
 811         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
 812         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \ 
 813             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str()));    \ 
 814         wxPyEndBlockThreads(state);                                             \ 
 818     void CLASS::base_##CBNAME(const wxString& a) {                              \ 
 822 //--------------------------------------------------------------------------- 
 824 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME)              \ 
 825     bool CBNAME(const wxString& a);                     \ 
 826     bool base_##CBNAME(const wxString& a); 
 829 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME)                       \ 
 830     bool CLASS::CBNAME(const wxString& a)  {                                    \ 
 833         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
 834         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \ 
 835             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str()));\ 
 836         wxPyEndBlockThreads(state);                                             \ 
 838             rval = PCLASS::CBNAME(a);                                           \ 
 841     bool CLASS::base_##CBNAME(const wxString& a) {                              \ 
 842         return PCLASS::CBNAME(a);                                               \ 
 845 //--------------------------------------------------------------------------- 
 847 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME)         \ 
 848     bool CBNAME(const wxString& a); 
 850 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME)                          \ 
 851     bool CLASS::CBNAME(const wxString& a)  {                                            \ 
 853         wxPyTState* state = wxPyBeginBlockThreads();                                    \ 
 854         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                                    \ 
 855             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(s)", a.c_str()));     \ 
 856         wxPyEndBlockThreads(state);                                                     \ 
 860 //--------------------------------------------------------------------------- 
 862 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME)                               \ 
 863     wxString CBNAME(const wxString& a);                                         \ 
 865 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME)                \ 
 866     wxString CLASS::CBNAME(const wxString& a)  {                                \ 
 868         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
 869         if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                          \ 
 871             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(s)", a.c_str()));\ 
 873                 PyObject* str = PyObject_Str(ro);                               \ 
 874                 rval = PyString_AsString(str);                                  \ 
 875                 Py_DECREF(ro);   Py_DECREF(str);                                \ 
 878         wxPyEndBlockThreads(state);                                             \ 
 882 //--------------------------------------------------------------------------- 
 884 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME)                            \ 
 885     wxString CBNAME(const wxString& a,int b);                                   \ 
 887 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME)             \ 
 888     wxString CLASS::CBNAME(const wxString& a,int b)  {                          \ 
 890         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
 891         if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                          \ 
 893             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(si)", a.c_str(),b));  \ 
 895                 PyObject* str = PyObject_Str(ro);                               \ 
 896                 rval = PyString_AsString(str);                                  \ 
 897                 Py_DECREF(ro);   Py_DECREF(str);                                \ 
 900         wxPyEndBlockThreads(state);                                             \ 
 904 //--------------------------------------------------------------------------- 
 906 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME)              \ 
 907     bool CBNAME(const wxString& a, const wxString& b);        \ 
 908     bool base_##CBNAME(const wxString& a, const wxString& b); 
 911 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME)                 \ 
 912     bool CLASS::CBNAME(const wxString& a, const wxString& b) {                  \ 
 915         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
 916         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \ 
 917             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ss)",         \ 
 918                                                        a.c_str(), b.c_str()));  \ 
 919         wxPyEndBlockThreads(state);                                             \ 
 921             rval = PCLASS::CBNAME(a, b);                                        \ 
 924     bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) {           \ 
 925         return PCLASS::CBNAME(a, b);                                            \ 
 928 //--------------------------------------------------------------------------- 
 930 #define DEC_PYCALLBACK_STRING_(CBNAME)                  \ 
 932     wxString base_##CBNAME(); 
 935 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME)                           \ 
 936     wxString CLASS::CBNAME() {                                                  \ 
 939         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
 940         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \ 
 942             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));        \ 
 944                 PyObject* str = PyObject_Str(ro);                               \ 
 945                 rval = PyString_AsString(str);                                  \ 
 946                 Py_DECREF(ro);  Py_DECREF(str);                                 \ 
 949         wxPyEndBlockThreads(state);                                             \ 
 951             rval = PCLASS::CBNAME();                                            \ 
 954     wxString CLASS::base_##CBNAME() {                                           \ 
 955         return PCLASS::CBNAME();                                                \ 
 958 //--------------------------------------------------------------------------- 
 960 #define DEC_PYCALLBACK_STRING__pure(CBNAME)             \ 
 964 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME)                      \ 
 965     wxString CLASS::CBNAME() {                                                  \ 
 967         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
 968         if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                          \ 
 970             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));        \ 
 972                 PyObject* str = PyObject_Str(ro);                               \ 
 973                 rval = PyString_AsString(str);                                  \ 
 974                 Py_DECREF(ro);   Py_DECREF(str);                                \ 
 977         wxPyEndBlockThreads(state);                                             \ 
 981 //--------------------------------------------------------------------------- 
 983 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME)                  \ 
 984     bool CBNAME(const wxHtmlTag& a);                          \ 
 987 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME)                     \ 
 988     bool CLASS::CBNAME(const wxHtmlTag& a)  {                                   \ 
 990         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
 991         if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                          \ 
 992             PyObject* obj = wxPyConstructObject((void*)&a, "wxHtmlTag", 0);     \ 
 993             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));   \ 
 996         wxPyEndBlockThreads(state);                                             \ 
1000 //--------------------------------------------------------------------------- 
1002 #define DEC_PYCALLBACK___pure(CBNAME)                         \ 
1006 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME)                            \ 
1007     void CLASS::CBNAME() {                                                      \ 
1008         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
1009         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                            \ 
1010             wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));                \ 
1011         wxPyEndBlockThreads(state);                                             \ 
1014 //--------------------------------------------------------------------------- 
1016 #define DEC_PYCALLBACK_wxSize__pure(CBNAME)                         \ 
1020 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME)                      \ 
1021     wxSize CLASS::CBNAME() {                                                    \ 
1023         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
1024         if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                          \ 
1027             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));        \ 
1029                 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxSize_p"))           \ 
1034         wxPyEndBlockThreads(state);                                             \ 
1038 //--------------------------------------------------------------------------- 
1040 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME)                      \ 
1041     bool CBNAME(wxWindow* a);                                  \ 
1042     bool base_##CBNAME(wxWindow* a); 
1045 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME)                        \ 
1046     bool CLASS::CBNAME(wxWindow* a) {                                           \ 
1049         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
1050         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \ 
1051             PyObject* obj = wxPyMake_wxObject(a);                               \ 
1052             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));   \ 
1055         wxPyEndBlockThreads(state);                                             \ 
1057             rval = PCLASS::CBNAME(a);                                           \ 
1060     bool CLASS::base_##CBNAME(wxWindow* a) {                                    \ 
1061         return PCLASS::CBNAME(a);                                               \ 
1064 //--------------------------------------------------------------------------- 
1066 #define DEC_PYCALLBACK_BOOL_(CBNAME)                      \ 
1068     bool base_##CBNAME(); 
1071 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME)                             \ 
1072     bool CLASS::CBNAME() {                                                      \ 
1075         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
1076         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \ 
1077             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));         \ 
1078         wxPyEndBlockThreads(state);                                             \ 
1080             rval = PCLASS::CBNAME();                                            \ 
1083     bool CLASS::base_##CBNAME() {                                               \ 
1084         return PCLASS::CBNAME();                                                \ 
1087 //--------------------------------------------------------------------------- 
1089 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME)                                \ 
1090     wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def);        \ 
1091     wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def); 
1094 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME)                         \ 
1095     wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) {          \ 
1097         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
1099         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \ 
1100             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\ 
1101         wxPyEndBlockThreads(state);                                             \ 
1103             rval = PCLASS::CBNAME(a, b, c);                                     \ 
1104         return (wxDragResult)rval;                                              \ 
1106     wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) {   \ 
1107         return PCLASS::CBNAME(a, b, c);                                         \ 
1110 //--------------------------------------------------------------------------- 
1112 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME)                        \ 
1113     wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location);       \ 
1115 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME)         \ 
1116     wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) {        \ 
1117         wxPyTState* state = wxPyBeginBlockThreads();                    \ 
1119         if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                  \ 
1121             PyObject* obj = wxPyMake_wxObject(&a);                      \ 
1122             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Os)",\ 
1125                 SWIG_GetPtrObj(ro, (void **)&rval, "_wxFSFILE_p");      \ 
1130         wxPyEndBlockThreads(state);                                     \ 
1134 //--------------------------------------------------------------------------- 
1136 #define DEC_PYCALLBACK_BOOL_DR(CBNAME)                  \ 
1137     bool CBNAME(wxDragResult a);                        \ 
1138     bool base_##CBNAME(wxDragResult a); 
1141 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME)                   \ 
1142     bool CLASS::CBNAME(wxDragResult a) {                                \ 
1144         wxPyTState* state = wxPyBeginBlockThreads();                    \ 
1146         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))          \ 
1147             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\ 
1148         wxPyEndBlockThreads(state);                                     \ 
1150             rval = PCLASS::CBNAME(a);                                   \ 
1153     bool CLASS::base_##CBNAME(wxDragResult a) {                         \ 
1154         return PCLASS::CBNAME(a);                                       \ 
1157 //--------------------------------------------------------------------------- 
1159 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME)   \ 
1160     wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); 
1163 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME)            \ 
1164     wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) {  \ 
1165         wxPyTState* state = wxPyBeginBlockThreads();                    \ 
1167         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                    \ 
1168             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\ 
1169         wxPyEndBlockThreads(state);                                     \ 
1170         return (wxDragResult)rval;                                      \ 
1173 //--------------------------------------------------------------------------- 
1175 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME)                      \ 
1176     bool CBNAME(int a, int b, const wxString& c); 
1179 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME)       \ 
1180     bool CLASS::CBNAME(int a, int b, const wxString& c) {               \ 
1182         wxPyTState* state = wxPyBeginBlockThreads();                    \ 
1183         if (wxPyCBH_findCallback(m_myInst, #CBNAME))                    \ 
1184             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iis)",a,b,c.c_str()));\ 
1185         wxPyEndBlockThreads(state);                                     \ 
1189 //--------------------------------------------------------------------------- 
1191 #define DEC_PYCALLBACK_SIZET_(CBNAME)                  \ 
1193     size_t base_##CBNAME(); 
1196 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME)                            \ 
1197     size_t CLASS::CBNAME() {                                                    \ 
1200         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
1201         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \ 
1202             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));         \ 
1203         wxPyEndBlockThreads(state);                                             \ 
1205             rval = PCLASS::CBNAME();                                            \ 
1208     size_t CLASS::base_##CBNAME() {                                             \ 
1209         return PCLASS::CBNAME();                                                \ 
1212 //--------------------------------------------------------------------------- 
1214 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME)                                    \ 
1215     wxDataFormat  CBNAME(size_t a);                                             \ 
1216     wxDataFormat  base_##CBNAME(size_t a); 
1219 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME)                     \ 
1220     wxDataFormat CLASS::CBNAME(size_t a) {                                      \ 
1221         wxDataFormat rval;                                                      \ 
1223         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
1224         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \ 
1226             wxDataFormat* ptr;                                                  \ 
1227             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a));    \ 
1229                 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxDataFormat_p"))     \ 
1234         wxPyEndBlockThreads(state);                                             \ 
1236             rval = PCLASS::CBNAME(a);                                           \ 
1239     wxDataFormat  CLASS::base_##CBNAME(size_t a) {                              \ 
1240         return PCLASS::CBNAME(a);                                               \ 
1243 //--------------------------------------------------------------------------- 
1245 #define DEC_PYCALLBACK__constany(CBNAME, Type)          \ 
1246     void CBNAME(const Type& a);                         \ 
1247     void base_##CBNAME(const Type& a); 
1250 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type)                   \ 
1251     void CLASS::CBNAME(const Type& a) {                                         \ 
1253         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
1254         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \ 
1255             PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0);           \ 
1256             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));          \ 
1259         wxPyEndBlockThreads(state);                                             \ 
1261             PCLASS::CBNAME(a);                                                  \ 
1263     void CLASS::base_##CBNAME(const Type& a) {                                  \ 
1264         PCLASS::CBNAME(a);                                                      \ 
1268 //--------------------------------------------------------------------------- 
1270 #define DEC_PYCALLBACK__any(CBNAME, Type)          \ 
1271     void CBNAME(Type& a);                          \ 
1272     void base_##CBNAME(Type& a); 
1275 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type)                        \ 
1276     void CLASS::CBNAME(Type& a) {                                               \ 
1278         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
1279         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \ 
1280             PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0);           \ 
1281             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));          \ 
1284         wxPyEndBlockThreads(state);                                             \ 
1286             PCLASS::CBNAME(a);                                                  \ 
1288     void CLASS::base_##CBNAME(Type& a) {                                        \ 
1289         PCLASS::CBNAME(a);                                                      \ 
1292 //--------------------------------------------------------------------------- 
1294 #define DEC_PYCALLBACK_bool_any(CBNAME, Type)           \ 
1295     bool CBNAME(Type& a);                               \ 
1296     bool base_##CBNAME(Type& a); 
1299 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type)                    \ 
1300     bool CLASS::CBNAME(Type& a) {                                               \ 
1303         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
1304         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \ 
1305             PyObject* obj = wxPyConstructObject((void*)&a, #Type, 0);           \ 
1306             rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj));     \ 
1309         wxPyEndBlockThreads(state);                                             \ 
1311             rv = PCLASS::CBNAME(a);                                             \ 
1314     bool CLASS::base_##CBNAME(Type& a) {                                        \ 
1315         return PCLASS::CBNAME(a);                                               \ 
1318 //--------------------------------------------------------------------------- 
1320 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME)                                  \ 
1321     wxString CBNAME(long a, long b) const;                                      \ 
1322     wxString base_##CBNAME(long a, long b)const ; 
1325 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME)                   \ 
1326     wxString CLASS::CBNAME(long a, long b) const {                              \ 
1329         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
1330         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \ 
1332             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b));  \ 
1334                 PyObject* str = PyObject_Str(ro);                               \ 
1335                 rval = PyString_AsString(str);                                  \ 
1336                 Py_DECREF(ro);   Py_DECREF(str);                                \ 
1339         wxPyEndBlockThreads(state);                                             \ 
1341             rval = PCLASS::CBNAME(a,b);                                         \ 
1344     wxString CLASS::base_##CBNAME(long a, long b) const {                       \ 
1345         return PCLASS::CBNAME(a,b);                                             \ 
1348 //--------------------------------------------------------------------------- 
1350 #define DEC_PYCALLBACK_INT_LONG(CBNAME)                                         \ 
1351     int CBNAME(long a) const;                                                   \ 
1352     int base_##CBNAME(long a)const ; 
1355 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME)                          \ 
1356     int CLASS::CBNAME(long a) const {                                           \ 
1359         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
1360         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \ 
1362             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a));     \ 
1364                 rval = PyInt_AsLong(ro);                                        \ 
1368         wxPyEndBlockThreads(state);                                             \ 
1370             rval = PCLASS::CBNAME(a);                                           \ 
1373     int CLASS::base_##CBNAME(long a) const {                                    \ 
1374         return PCLASS::CBNAME(a);                                               \ 
1378 //--------------------------------------------------------------------------- 
1380 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME)                                    \ 
1381     wxListItemAttr*  CBNAME(long a) const;                                      \ 
1382     wxListItemAttr*  base_##CBNAME(long a); 
1385 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME)                     \ 
1386     wxListItemAttr *CLASS::CBNAME(long a) const {                               \ 
1387         wxListItemAttr *rval = NULL;                                            \ 
1389         wxPyTState* state = wxPyBeginBlockThreads();                            \ 
1390         if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \ 
1392             wxListItemAttr* ptr;                                                \ 
1393             ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a));    \ 
1395                 if (! SWIG_GetPtrObj(ro, (void **)&ptr, "_wxListItemAttr_p"))   \ 
1400         wxPyEndBlockThreads(state);                                             \ 
1402             rval = PCLASS::CBNAME(a);                                           \ 
1405     wxListItemAttr *CLASS::base_##CBNAME(long a) {                              \ 
1406         return PCLASS::CBNAME(a);                                               \ 
1409 //---------------------------------------------------------------------------