1 ////////////////////////////////////////////////////////////////////////////
2 // Name: wxPython_int.h (int == internal)
3 // Purpose: Helper functions/classes for the wxPython extension module
4 // This header should only be inclued directly by those source
5 // modules included in the wx._core module. All others should
6 // include wx/wxPython/wxPython.h instead.
10 // Created: 1-July-1997
12 // Copyright: (c) 1998 by Total Control Software
13 // Licence: wxWindows license
14 /////////////////////////////////////////////////////////////////////////////
16 #ifndef __wxp_helpers__
17 #define __wxp_helpers__
21 #include <wx/busyinfo.h>
23 #include <wx/clipbrd.h>
24 #include <wx/colordlg.h>
25 #include <wx/config.h>
26 #include <wx/cshelp.h>
27 #include <wx/dcmirror.h>
29 #include <wx/dirctrl.h>
30 #include <wx/dirdlg.h>
32 #include <wx/docview.h>
33 #include <wx/encconv.h>
34 #include <wx/fdrepdlg.h>
35 #include <wx/fileconf.h>
36 #include <wx/filesys.h>
37 #include <wx/fontdlg.h>
38 #include <wx/fs_inet.h>
39 #include <wx/fs_mem.h>
40 #include <wx/fs_zip.h>
41 #include <wx/gbsizer.h>
42 #include <wx/geometry.h>
43 #include <wx/htmllbox.h>
45 #include <wx/imaglist.h>
47 #include <wx/laywin.h>
48 #include <wx/listbook.h>
49 #include <wx/minifram.h>
50 #include <wx/notebook.h>
52 #include <wx/printdlg.h>
53 #include <wx/process.h>
54 #include <wx/progdlg.h>
55 #include <wx/sashwin.h>
56 #include <wx/spinbutt.h>
57 #include <wx/spinctrl.h>
58 #include <wx/splash.h>
59 #include <wx/splitter.h>
60 #include <wx/statline.h>
61 #include <wx/stream.h>
62 #include <wx/sysopt.h>
63 #include <wx/taskbar.h>
64 #include <wx/tglbtn.h>
65 #include <wx/tipwin.h>
66 #include <wx/tooltip.h>
68 #include <wx/vscroll.h>
72 # pragma warning(disable:4800)
73 # pragma warning(disable:4190)
76 #ifdef __WXMAC__ // avoid a bug in Carbon headers
80 //---------------------------------------------------------------------------
82 typedef unsigned char byte
;
83 typedef wxPoint2DDouble wxPoint2D
;
85 const bool True
= true;
86 const bool False
= false;
89 #ifndef wxPyUSE_EXPORTED_API
91 void __wxPyPreStart(PyObject
*);
93 PyObject
* __wxPySetDictionary(PyObject
*, PyObject
* args
);
94 PyObject
* __wxPyFixStockObjects(PyObject
*, PyObject
* args
);
97 void wxPyEventThunker(wxObject
*, wxEvent
& event
);
100 bool wxPyCheckSwigType(const wxChar
* className
);
101 PyObject
* wxPyConstructObject(void* ptr
,
102 const wxChar
* className
,
104 bool wxPyConvertSwigPtr(PyObject
* obj
, void **ptr
,
105 const wxChar
* className
);
106 PyObject
* wxPyMakeSwigPtr(void* ptr
, const wxChar
* classname
);
109 PyObject
* wx2PyString(const wxString
& src
);
110 wxString
Py2wxString(PyObject
* source
);
112 PyObject
* wxPyMake_wxObject(wxObject
* source
, bool checkEvtHandler
=True
);
113 PyObject
* wxPyMake_wxSizer(wxSizer
* source
);
114 void wxPyPtrTypeMap_Add(const char* commonName
, const char* ptrName
);
116 PyObject
* wxPy_ConvertList(wxListBase
* list
);
117 long wxPyGetWinHandle(wxWindow
* win
);
119 void wxPy_ReinitStockObjects(int pass
);
121 bool wxPyInstance_Check(PyObject
* obj
);
122 bool wxPySwigInstance_Check(PyObject
* obj
);
125 #endif // wxPyUSE_EXPORTED_API
126 //---------------------------------------------------------------------------
128 // if we want to handle threads and Python threads are available...
129 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
130 #define WXP_WITH_THREAD
131 #else // no Python threads...
132 #undef WXP_WITH_THREAD
135 #ifndef wxPyUSE_EXPORTED_API
137 // For Python --> C++
138 PyThreadState
* wxPyBeginAllowThreads();
139 void wxPyEndAllowThreads(PyThreadState
* state
);
141 // For C++ --> Python
142 bool wxPyBeginBlockThreads();
143 void wxPyEndBlockThreads(bool blocked
);
145 #endif // wxPyUSE_EXPORTED_API
148 // A macro that will help to execute simple statments wrapped in
149 // StartBlock/EndBlockThreads calls
150 #define wxPyBLOCK_THREADS(stmt) \
151 { bool blocked = wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads(blocked); }
153 // Raise the NotImplementedError exception (blocking threads)
154 #define wxPyRaiseNotImplemented() \
155 wxPyBLOCK_THREADS(PyErr_SetNone(PyExc_NotImplementedError))
157 // Raise any exception witha string value (blocking threads)
158 #define wxPyErr_SetString(err, str) \
159 wxPyBLOCK_THREADS(PyErr_SetString(err, str))
162 //---------------------------------------------------------------------------
163 // These are helpers used by the typemaps
165 #ifndef wxPyUSE_EXPORTED_API
167 wxString
* wxString_in_helper(PyObject
* source
);
169 byte
* byte_LIST_helper(PyObject
* source
);
170 int* int_LIST_helper(PyObject
* source
);
171 long* long_LIST_helper(PyObject
* source
);
172 char** string_LIST_helper(PyObject
* source
);
173 wxPoint
* wxPoint_LIST_helper(PyObject
* source
, int* npoints
);
174 wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
175 wxString
* wxString_LIST_helper(PyObject
* source
);
176 wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
177 wxPen
** wxPen_LIST_helper(PyObject
* source
);
179 bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
180 bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
181 bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
182 bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
183 bool wxColour_helper(PyObject
* source
, wxColour
** obj
);
184 bool wxPoint2D_helper(PyObject
* source
, wxPoint2D
** obj
);
187 bool wxPySimple_typecheck(PyObject
* source
, const wxChar
* classname
, int seqLen
);
188 bool wxColour_typecheck(PyObject
* source
);
190 bool wxPyCheckForApp();
194 bool wxPyTwoIntItem_helper(PyObject
* source
, T
** obj
, const wxChar
* name
)
196 // If source is an object instance then it may already be the right type
197 if (wxPySwigInstance_Check(source
)) {
199 if (! wxPyConvertSwigPtr(source
, (void **)&ptr
, name
))
204 // otherwise a 2-tuple of integers is expected
205 else if (PySequence_Check(source
) && PyObject_Length(source
) == 2) {
206 PyObject
* o1
= PySequence_GetItem(source
, 0);
207 PyObject
* o2
= PySequence_GetItem(source
, 1);
208 if (!PyNumber_Check(o1
) || !PyNumber_Check(o2
)) {
213 **obj
= T(PyInt_AsLong(o1
), PyInt_AsLong(o2
));
221 msg
.Printf(wxT("Expected a 2-tuple of integers or a %s object."), name
);
222 PyErr_SetString(PyExc_TypeError
, msg
.mb_str());
228 // Other helpful stuff
229 bool wxPy2int_seq_helper(PyObject
* source
, int* i1
, int* i2
);
230 bool wxPy4int_seq_helper(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
232 PyObject
* wxArrayString2PyList_helper(const wxArrayString
& arr
);
233 PyObject
* wxArrayInt2PyList_helper(const wxArrayInt
& arr
);
235 #endif // wxPyUSE_EXPORTED_API
237 //---------------------------------------------------------------------------
239 #if PYTHON_API_VERSION < 1009
240 #define PySequence_Fast_GET_ITEM(o, i) \
241 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
244 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
245 #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name)
246 #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val)
248 //---------------------------------------------------------------------------
250 #ifndef wxPyUSE_EXPORTED_API
252 class wxPyCallback
: public wxObject
{
253 DECLARE_ABSTRACT_CLASS(wxPyCallback
);
255 wxPyCallback(PyObject
* func
);
256 wxPyCallback(const wxPyCallback
& other
);
259 void EventThunker(wxEvent
& event
);
264 #endif // wxPyUSE_EXPORTED_API
265 //---------------------------------------------------------------------------
266 //---------------------------------------------------------------------------
267 // These Event classes can be derived from in Python and passed through the
268 // event system without loosing anything. They do this by keeping a reference
269 // to themselves and some special case handling in wxPyCallback::EventThunker.
273 class wxPyEvtSelfRef
{
278 void SetSelf(PyObject
* self
, bool clone
=False
);
279 PyObject
* GetSelf() const;
280 bool GetCloned() const { return m_cloned
; }
288 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
289 DECLARE_ABSTRACT_CLASS(wxPyEvent
)
291 wxPyEvent(int winid
=0, wxEventType commandType
= wxEVT_NULL
);
292 wxPyEvent(const wxPyEvent
& evt
);
295 virtual wxEvent
* Clone() const { return new wxPyEvent(*this); }
299 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
300 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent
)
302 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
303 wxPyCommandEvent(const wxPyCommandEvent
& evt
);
306 virtual wxEvent
* Clone() const { return new wxPyCommandEvent(*this); }
311 //----------------------------------------------------------------------
312 // Forward decalre a few things used in the exported API
313 class wxPyClientData
;
315 class wxPyOORClientData
;
316 class wxPyCBInputStream
;
318 void wxPyClientData_dtor(wxPyClientData
* self
);
319 void wxPyUserData_dtor(wxPyUserData
* self
);
320 void wxPyOORClientData_dtor(wxPyOORClientData
* self
);
321 wxPyCBInputStream
* wxPyCBInputStream_create(PyObject
*py
, bool block
);
324 //---------------------------------------------------------------------------
325 // Export a C API in a struct. Other modules will be able to load this from
326 // the wx.core module and will then have safe access to these functions, even if
327 // in another shared library.
329 class wxPyCallbackHelper
;
330 struct swig_type_info
;
331 struct swig_const_info
;
333 typedef double (*py_objasdbl_conv
)(PyObject
*obj
);
335 // Make SunCC happy and make typedef's for these that are extern "C"
336 typedef swig_type_info
* (*p_SWIG_Python_TypeRegister_t
)(swig_type_info
*);
337 typedef swig_type_info
* (*p_SWIG_Python_TypeCheck_t
)(char *c
, swig_type_info
*);
338 typedef void* (*p_SWIG_Python_TypeCast_t
)(swig_type_info
*, void *);
339 typedef swig_type_info
* (*p_SWIG_Python_TypeDynamicCast_t
)(swig_type_info
*, void **);
340 typedef const char* (*p_SWIG_Python_TypeName_t
)(const swig_type_info
*);
341 typedef swig_type_info
* (*p_SWIG_Python_TypeQuery_t
)(const char *);
342 typedef void (*p_SWIG_Python_TypeClientData_t
)(swig_type_info
*, void *);
343 typedef PyObject
* (*p_SWIG_Python_newvarlink_t
)(void);
344 typedef void (*p_SWIG_Python_addvarlink_t
)(PyObject
*, char *, PyObject
*(*)(void), int (*)(PyObject
*));
345 typedef int (*p_SWIG_Python_ConvertPtr_t
)(PyObject
*, void **, swig_type_info
*, int);
346 typedef int (*p_SWIG_Python_ConvertPacked_t
)(PyObject
*, void *, int sz
, swig_type_info
*, int);
347 typedef char* (*p_SWIG_Python_PackData_t
)(char *c
, void *, int);
348 typedef char* (*p_SWIG_Python_UnpackData_t
)(char *c
, void *, int);
349 typedef PyObject
* (*p_SWIG_Python_NewPointerObj_t
)(void *, swig_type_info
*,int own
);
350 typedef PyObject
* (*p_SWIG_Python_NewPackedObj_t
)(void *, int sz
, swig_type_info
*);
351 typedef void (*p_SWIG_Python_InstallConstants_t
)(PyObject
*d
, swig_const_info constants
[]);
352 typedef void* (*p_SWIG_Python_MustGetPtr_t
)(PyObject
*, swig_type_info
*, int, int);
357 p_SWIG_Python_TypeRegister_t p_SWIG_Python_TypeRegister
;
358 p_SWIG_Python_TypeCheck_t p_SWIG_Python_TypeCheck
;
359 p_SWIG_Python_TypeCast_t p_SWIG_Python_TypeCast
;
360 p_SWIG_Python_TypeDynamicCast_t p_SWIG_Python_TypeDynamicCast
;
361 p_SWIG_Python_TypeName_t p_SWIG_Python_TypeName
;
362 p_SWIG_Python_TypeQuery_t p_SWIG_Python_TypeQuery
;
363 p_SWIG_Python_TypeClientData_t p_SWIG_Python_TypeClientData
;
364 p_SWIG_Python_newvarlink_t p_SWIG_Python_newvarlink
;
365 p_SWIG_Python_addvarlink_t p_SWIG_Python_addvarlink
;
366 p_SWIG_Python_ConvertPtr_t p_SWIG_Python_ConvertPtr
;
367 p_SWIG_Python_ConvertPacked_t p_SWIG_Python_ConvertPacked
;
368 p_SWIG_Python_PackData_t p_SWIG_Python_PackData
;
369 p_SWIG_Python_UnpackData_t p_SWIG_Python_UnpackData
;
370 p_SWIG_Python_NewPointerObj_t p_SWIG_Python_NewPointerObj
;
371 p_SWIG_Python_NewPackedObj_t p_SWIG_Python_NewPackedObj
;
372 p_SWIG_Python_InstallConstants_t p_SWIG_Python_InstallConstants
;
373 p_SWIG_Python_MustGetPtr_t p_SWIG_Python_MustGetPtr
;
375 bool (*p_wxPyCheckSwigType
)(const wxChar
* className
);
376 PyObject
* (*p_wxPyConstructObject
)(void* ptr
, const wxChar
* className
, int setThisOwn
);
377 bool (*p_wxPyConvertSwigPtr
)(PyObject
* obj
, void **ptr
, const wxChar
* className
);
378 PyObject
* (*p_wxPyMakeSwigPtr
)(void* ptr
, const wxChar
* className
);
380 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
381 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
382 bool (*p_wxPyBeginBlockThreads
)();
383 void (*p_wxPyEndBlockThreads
)(bool blocked
);
385 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
);
387 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
388 wxString (*p_Py2wxString
)(PyObject
* source
);
389 PyObject
* (*p_wx2PyString
)(const wxString
& src
);
391 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
392 int* (*p_int_LIST_helper
)(PyObject
* source
);
393 long* (*p_long_LIST_helper
)(PyObject
* source
);
394 char** (*p_string_LIST_helper
)(PyObject
* source
);
395 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
396 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
397 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
398 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
400 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
401 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
402 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
403 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
404 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
405 bool (*p_wxPoint2D_helper
)(PyObject
* source
, wxPoint2DDouble
** obj
);
408 bool (*p_wxPySimple_typecheck
)(PyObject
* source
, const wxChar
* classname
, int seqLen
);
409 bool (*p_wxColour_typecheck
)(PyObject
* source
);
411 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
412 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
);
413 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
414 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
415 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
417 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool checkEvtHandler
);
418 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
);
419 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
420 bool (*p_wxPy2int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
);
421 bool (*p_wxPy4int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
422 PyObject
* (*p_wxArrayString2PyList_helper
)(const wxArrayString
& arr
);
423 PyObject
* (*p_wxArrayInt2PyList_helper
)(const wxArrayInt
& arr
);
425 void (*p_wxPyClientData_dtor
)(wxPyClientData
*);
426 void (*p_wxPyUserData_dtor
)(wxPyUserData
*);
427 void (*p_wxPyOORClientData_dtor
)(wxPyOORClientData
*);
429 wxPyCBInputStream
* (*p_wxPyCBInputStream_create
)(PyObject
*py
, bool block
);
431 bool (*p_wxPyInstance_Check
)(PyObject
* obj
);
432 bool (*p_wxPySwigInstance_Check
)(PyObject
* obj
);
434 bool (*p_wxPyCheckForApp
)();
438 #ifdef wxPyUSE_EXPORTED_API
439 // Notice that this is static, not extern. This is by design, each module
440 // needs one, but doesn't have to use it.
441 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
;
442 #endif // wxPyUSE_EXPORTED_API
444 //---------------------------------------------------------------------------
446 // A wxObject that holds a reference to a Python object
447 class wxPyUserData
: public wxObject
{
449 wxPyUserData(PyObject
* obj
) {
455 #ifdef wxPyUSE_EXPORTED_API
456 wxPyCoreAPIPtr
->p_wxPyUserData_dtor(this);
458 wxPyUserData_dtor(this);
465 // A wxClientData that holds a refernece to a Python object
466 class wxPyClientData
: public wxClientData
{
468 wxPyClientData(PyObject
* obj
) {
474 #ifdef wxPyUSE_EXPORTED_API
475 wxPyCoreAPIPtr
->p_wxPyClientData_dtor(this);
477 wxPyClientData_dtor(this);
484 // Just like wxPyClientData, except when this object is destroyed it does some
485 // OOR magic on the Python Object.
486 class wxPyOORClientData
: public wxPyClientData
{
488 wxPyOORClientData(PyObject
* obj
)
489 : wxPyClientData(obj
) {}
491 ~wxPyOORClientData() {
492 #ifdef wxPyUSE_EXPORTED_API
493 wxPyCoreAPIPtr
->p_wxPyOORClientData_dtor(this);
495 wxPyOORClientData_dtor(this);
501 //---------------------------------------------------------------------------
502 // This class holds an instance of a Python Shadow Class object and assists
503 // with looking up and invoking Python callback methods from C++ virtual
504 // method redirections. For all classes which have virtuals which should be
505 // overridable in wxPython, a new subclass is created that contains a
506 // wxPyCallbackHelper.
509 class wxPyCallbackHelper
{
511 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
513 wxPyCallbackHelper() {
520 ~wxPyCallbackHelper() {
521 #ifdef wxPyUSE_EXPORTED_API
522 wxPyCoreAPIPtr
->p_wxPyCBH_delete(this);
524 wxPyCBH_delete(this);
528 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=True
);
529 bool findCallback(const char* name
) const;
530 int callCallback(PyObject
* argTuple
) const;
531 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
532 PyObject
* GetLastFound() const { return m_lastFound
; }
537 PyObject
* m_lastFound
;
540 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
544 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
545 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
);
546 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
547 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
548 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
553 //---------------------------------------------------------------------------
555 // This is used in C++ classes that need to be able to make callback to
556 // "overloaded" python methods
559 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
560 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
562 private: wxPyCallbackHelper m_myInst
565 //---------------------------------------------------------------------------
566 // The wxPythonApp class
569 wxPYAPP_ASSERT_SUPPRESS
= 1,
570 wxPYAPP_ASSERT_EXCEPTION
= 2,
571 wxPYAPP_ASSERT_DIALOG
= 4,
572 wxPYAPP_ASSERT_LOG
= 8
575 class wxPyApp
: public wxApp
577 DECLARE_ABSTRACT_CLASS(wxPyApp
);
585 int GetAssertMode() { return m_assertMode
; }
586 void SetAssertMode(int mode
) { m_assertMode
= mode
; }
588 virtual bool OnInitGui();
589 virtual int OnExit();
591 virtual void OnAssert(const wxChar
*file
,
596 // virtual int FilterEvent(wxEvent& event); // This one too????
598 // For catching Apple Events
599 virtual void MacOpenFile(const wxString
&fileName
);
600 virtual void MacPrintFile(const wxString
&fileName
);
601 virtual void MacNewFile();
602 virtual void MacReopenApp();
604 static bool GetMacSupportPCMenuShortcuts();
605 static long GetMacAboutMenuItemId();
606 static long GetMacPreferencesMenuItemId();
607 static long GetMacExitMenuItemId();
608 static wxString
GetMacHelpMenuTitleName();
610 static void SetMacSupportPCMenuShortcuts(bool val
);
611 static void SetMacAboutMenuItemId(long val
);
612 static void SetMacPreferencesMenuItemId(long val
);
613 static void SetMacExitMenuItemId(long val
);
614 static void SetMacHelpMenuTitleName(const wxString
& val
);
617 void _BootstrapApp();
619 // implementation only
620 void SetStartupComplete(bool val
) { m_startupComplete
= val
; };
624 bool m_startupComplete
;
627 extern wxPyApp
*wxPythonApp
;
630 //----------------------------------------------------------------------
631 // These macros are used to implement the virtual methods that should
632 // redirect to a Python method if one exists. The names designate the
633 // return type, if any, as well as any parameter types.
634 //---------------------------------------------------------------------------
636 #define DEC_PYCALLBACK__(CBNAME) \
641 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
642 void CLASS::CBNAME() { \
644 bool blocked = wxPyBeginBlockThreads(); \
645 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
646 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
647 wxPyEndBlockThreads(blocked); \
651 void CLASS::base_##CBNAME() { \
655 //---------------------------------------------------------------------------
657 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
658 bool CBNAME(int a, int b); \
659 bool base_##CBNAME(int a, int b)
662 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
663 bool CLASS::CBNAME(int a, int b) { \
664 bool rval=False, found; \
665 bool blocked = wxPyBeginBlockThreads(); \
666 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
667 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
668 wxPyEndBlockThreads(blocked); \
670 rval = PCLASS::CBNAME(a,b); \
673 bool CLASS::base_##CBNAME(int a, int b) { \
674 return PCLASS::CBNAME(a,b); \
677 //---------------------------------------------------------------------------
679 #define DEC_PYCALLBACK_VOID_(CBNAME) \
684 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
685 void CLASS::CBNAME() { \
687 bool blocked = wxPyBeginBlockThreads(); \
688 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
689 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
690 wxPyEndBlockThreads(blocked); \
694 void CLASS::base_##CBNAME() { \
698 //---------------------------------------------------------------------------
700 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
701 void CBNAME(int a, int b); \
702 void base_##CBNAME(int a, int b)
705 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
706 void CLASS::CBNAME(int a, int b) { \
708 bool blocked = wxPyBeginBlockThreads(); \
709 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
710 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
711 wxPyEndBlockThreads(blocked); \
713 PCLASS::CBNAME(a,b); \
715 void CLASS::base_##CBNAME(int a, int b) { \
716 PCLASS::CBNAME(a,b); \
719 //---------------------------------------------------------------------------
721 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
722 void CBNAME(int a); \
723 void base_##CBNAME(int a)
726 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
727 void CLASS::CBNAME(int a) { \
729 bool blocked = wxPyBeginBlockThreads(); \
730 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
731 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
732 wxPyEndBlockThreads(blocked); \
736 void CLASS::base_##CBNAME(int a) { \
740 //---------------------------------------------------------------------------
742 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
743 void CBNAME(int a, int b, int c, int d); \
744 void base_##CBNAME(int a, int b, int c, int d)
747 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
748 void CLASS::CBNAME(int a, int b, int c, int d) { \
750 bool blocked = wxPyBeginBlockThreads(); \
751 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
752 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
753 wxPyEndBlockThreads(blocked); \
755 PCLASS::CBNAME(a,b,c,d); \
757 void CLASS::base_##CBNAME(int a, int b, int c, int d) { \
758 PCLASS::CBNAME(a,b,c,d); \
761 //---------------------------------------------------------------------------
762 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
763 void CBNAME(int a, int b, int c, int d, int e); \
764 void base_##CBNAME(int a, int b, int c, int d, int e)
767 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
768 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
770 bool blocked = wxPyBeginBlockThreads(); \
771 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
772 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
773 wxPyEndBlockThreads(blocked); \
775 PCLASS::CBNAME(a,b,c,d,e); \
777 void CLASS::base_##CBNAME(int a, int b, int c, int d, int e) { \
778 PCLASS::CBNAME(a,b,c,d,e); \
781 //---------------------------------------------------------------------------
783 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
784 void CBNAME(int* a, int* b) const; \
785 void base_##CBNAME(int* a, int* b) const
788 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
789 void CLASS::CBNAME(int* a, int* b) const { \
790 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
792 bool blocked = wxPyBeginBlockThreads(); \
793 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
795 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
797 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
798 PyObject* o1 = PySequence_GetItem(ro, 0); \
799 PyObject* o2 = PySequence_GetItem(ro, 1); \
800 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
801 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
804 PyErr_SetString(PyExc_TypeError, errmsg); \
809 PyErr_SetString(PyExc_TypeError, errmsg); \
814 wxPyEndBlockThreads(blocked); \
816 PCLASS::CBNAME(a,b); \
818 void CLASS::base_##CBNAME(int* a, int* b) const { \
819 PCLASS::CBNAME(a,b); \
823 //---------------------------------------------------------------------------
825 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
826 wxSize CBNAME() const; \
827 wxSize base_##CBNAME() const
830 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
831 wxSize CLASS::CBNAME() const { \
832 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
833 bool found; wxSize rval(0,0); \
834 bool blocked = wxPyBeginBlockThreads(); \
835 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
837 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
839 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
840 PyObject* o1 = PySequence_GetItem(ro, 0); \
841 PyObject* o2 = PySequence_GetItem(ro, 1); \
842 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
843 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
846 PyErr_SetString(PyExc_TypeError, errmsg); \
851 PyErr_SetString(PyExc_TypeError, errmsg); \
856 wxPyEndBlockThreads(blocked); \
858 return PCLASS::CBNAME(); \
862 wxSize CLASS::base_##CBNAME() const { \
863 return PCLASS::CBNAME(); \
867 //---------------------------------------------------------------------------
869 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
870 bool CBNAME(bool a); \
871 bool base_##CBNAME(bool a)
874 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
875 bool CLASS::CBNAME(bool a) { \
876 bool rval=False, found; \
877 bool blocked = wxPyBeginBlockThreads(); \
878 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
879 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
880 wxPyEndBlockThreads(blocked); \
882 rval = PCLASS::CBNAME(a); \
885 bool CLASS::base_##CBNAME(bool a) { \
886 return PCLASS::CBNAME(a); \
889 //---------------------------------------------------------------------------
891 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
892 bool CBNAME(int a); \
893 bool base_##CBNAME(int a)
896 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
897 bool CLASS::CBNAME(int a) { \
898 bool rval=False, found; \
899 bool blocked = wxPyBeginBlockThreads(); \
900 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
901 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
902 wxPyEndBlockThreads(blocked); \
904 rval = PCLASS::CBNAME(a); \
907 bool CLASS::base_##CBNAME(int a) { \
908 return PCLASS::CBNAME(a); \
911 //---------------------------------------------------------------------------
913 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
917 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
918 bool CLASS::CBNAME(int a) { \
920 bool blocked = wxPyBeginBlockThreads(); \
921 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
922 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
924 wxPyEndBlockThreads(blocked); \
929 //---------------------------------------------------------------------------
931 #define DEC_PYCALLBACK__DC(CBNAME) \
932 void CBNAME(wxDC& a); \
933 void base_##CBNAME(wxDC& a)
936 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
937 void CLASS::CBNAME(wxDC& a) { \
939 bool blocked = wxPyBeginBlockThreads(); \
940 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
941 PyObject* obj = wxPyMake_wxObject(&a); \
942 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
945 wxPyEndBlockThreads(blocked); \
949 void CLASS::base_##CBNAME(wxDC& a) { \
955 //---------------------------------------------------------------------------
957 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
958 void CBNAME(wxDC& a, bool b); \
959 void base_##CBNAME(wxDC& a, bool b)
962 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
963 void CLASS::CBNAME(wxDC& a, bool b) { \
965 bool blocked = wxPyBeginBlockThreads(); \
966 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
967 PyObject* obj = wxPyMake_wxObject(&a); \
968 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
971 wxPyEndBlockThreads(blocked); \
973 PCLASS::CBNAME(a, b); \
975 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
976 PCLASS::CBNAME(a, b); \
979 //---------------------------------------------------------------------------
981 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
982 void CBNAME(wxDC& a, bool b); \
983 void base_##CBNAME(wxDC& a, bool b)
986 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
987 void CLASS::CBNAME(wxDC& a, bool b) { \
989 bool blocked = wxPyBeginBlockThreads(); \
990 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
991 PyObject* obj = wxPyMake_wxObject(&a); \
992 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
995 wxPyEndBlockThreads(blocked); \
997 PCLASS::CBNAME(a, b); \
999 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
1000 PCLASS::CBNAME(a, b); \
1003 //---------------------------------------------------------------------------
1005 #define DEC_PYCALLBACK__2DBL(CBNAME) \
1006 void CBNAME(double a, double b); \
1007 void base_##CBNAME(double a, double b)
1010 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
1011 void CLASS::CBNAME(double a, double b) { \
1013 bool blocked = wxPyBeginBlockThreads(); \
1014 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1015 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
1016 wxPyEndBlockThreads(blocked); \
1018 PCLASS::CBNAME(a, b); \
1020 void CLASS::base_##CBNAME(double a, double b) { \
1021 PCLASS::CBNAME(a, b); \
1024 //---------------------------------------------------------------------------
1026 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
1027 void CBNAME(double a, double b, int c, int d); \
1028 void base_##CBNAME(double a, double b, int c, int d)
1031 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
1032 void CLASS::CBNAME(double a, double b, int c, int d) { \
1034 bool blocked = wxPyBeginBlockThreads(); \
1035 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1036 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
1038 wxPyEndBlockThreads(blocked); \
1040 PCLASS::CBNAME(a, b, c, d); \
1042 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
1043 PCLASS::CBNAME(a, b, c, d); \
1046 //---------------------------------------------------------------------------
1048 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
1049 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
1050 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1053 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1054 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1056 bool blocked = wxPyBeginBlockThreads(); \
1057 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1058 PyObject* obj = wxPyMake_wxObject(&a); \
1059 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
1062 wxPyEndBlockThreads(blocked); \
1064 PCLASS::CBNAME(a, b, c, d, e, f); \
1066 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
1067 PCLASS::CBNAME(a, b, c, d, e, f); \
1070 //---------------------------------------------------------------------------
1072 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
1073 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
1074 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1077 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1078 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1080 bool blocked = wxPyBeginBlockThreads(); \
1082 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1083 PyObject* obj = wxPyMake_wxObject(&a); \
1084 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1087 wxPyEndBlockThreads(blocked); \
1089 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1092 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
1093 return PCLASS::CBNAME(a, b, c, d, e, f); \
1096 //---------------------------------------------------------------------------
1098 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1099 void CBNAME(bool a, double b, double c, int d, int e); \
1100 void base_##CBNAME(bool a, double b, double c, int d, int e)
1103 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1104 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1106 bool blocked = wxPyBeginBlockThreads(); \
1107 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1108 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1110 wxPyEndBlockThreads(blocked); \
1112 PCLASS::CBNAME(a, b, c, d, e); \
1114 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
1115 PCLASS::CBNAME(a, b, c, d, e); \
1118 //---------------------------------------------------------------------------
1120 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1121 void CBNAME(wxDC& a, double b, double c, double d, double e); \
1122 void base_##CBNAME(wxDC& a, double b, double c, double d, double e)
1125 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1126 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1128 bool blocked = wxPyBeginBlockThreads(); \
1129 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1130 PyObject* obj = wxPyMake_wxObject(&a); \
1131 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1134 wxPyEndBlockThreads(blocked); \
1136 PCLASS::CBNAME(a, b, c, d, e); \
1138 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
1139 PCLASS::CBNAME(a, b, c, d, e); \
1142 //---------------------------------------------------------------------------
1144 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1145 void CBNAME(wxDC& a, bool b); \
1146 void base_##CBNAME(wxDC& a, bool b)
1149 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1150 void CLASS::CBNAME(wxDC& a, bool b) { \
1152 bool blocked = wxPyBeginBlockThreads(); \
1153 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1154 PyObject* obj = wxPyMake_wxObject(&a); \
1155 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1158 wxPyEndBlockThreads(blocked); \
1160 PCLASS::CBNAME(a, b); \
1162 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
1163 PCLASS::CBNAME(a, b); \
1166 //---------------------------------------------------------------------------
1168 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1169 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
1170 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1173 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1174 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1177 bool blocked = wxPyBeginBlockThreads(); \
1178 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1179 PyObject* obj = wxPyMake_wxObject(a); \
1180 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1183 wxPyEndBlockThreads(blocked); \
1185 PCLASS::CBNAME(a, b, c, d, e, f); \
1187 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
1189 PCLASS::CBNAME(a, b, c, d, e, f); \
1192 //---------------------------------------------------------------------------
1194 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1195 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
1196 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1199 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1200 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1202 bool blocked = wxPyBeginBlockThreads(); \
1203 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1204 PyObject* obj = wxPyMake_wxObject(a); \
1205 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1208 wxPyEndBlockThreads(blocked); \
1210 PCLASS::CBNAME(a, b, c, d, e); \
1212 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
1214 PCLASS::CBNAME(a, b, c, d, e); \
1217 //---------------------------------------------------------------------------
1219 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1220 void CBNAME(double a, double b, int c); \
1221 void base_##CBNAME(double a, double b, int c)
1224 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1225 void CLASS::CBNAME(double a, double b, int c) { \
1227 bool blocked = wxPyBeginBlockThreads(); \
1228 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1229 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1230 wxPyEndBlockThreads(blocked); \
1232 PCLASS::CBNAME(a, b, c); \
1234 void CLASS::base_##CBNAME(double a, double b, int c) { \
1235 PCLASS::CBNAME(a, b, c); \
1238 //---------------------------------------------------------------------------
1240 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1241 void CBNAME(bool a, double b, double c, int d); \
1242 void base_##CBNAME(bool a, double b, double c, int d)
1245 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1246 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1248 bool blocked = wxPyBeginBlockThreads(); \
1249 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1250 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1251 wxPyEndBlockThreads(blocked); \
1253 PCLASS::CBNAME(a, b, c, d); \
1255 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
1256 PCLASS::CBNAME(a, b, c, d); \
1259 //---------------------------------------------------------------------------
1260 //---------------------------------------------------------------------------
1262 #define DEC_PYCALLBACK__STRING(CBNAME) \
1263 void CBNAME(const wxString& a); \
1264 void base_##CBNAME(const wxString& a)
1266 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1267 void CLASS::CBNAME(const wxString& a) { \
1269 bool blocked = wxPyBeginBlockThreads(); \
1270 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1271 PyObject* s = wx2PyString(a); \
1272 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1275 wxPyEndBlockThreads(blocked); \
1277 PCLASS::CBNAME(a); \
1279 void CLASS::base_##CBNAME(const wxString& a) { \
1280 PCLASS::CBNAME(a); \
1283 //---------------------------------------------------------------------------
1285 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1286 bool CBNAME(const wxString& a); \
1287 bool base_##CBNAME(const wxString& a)
1289 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1290 bool CLASS::CBNAME(const wxString& a) { \
1293 bool blocked = wxPyBeginBlockThreads(); \
1294 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1295 PyObject* s = wx2PyString(a); \
1296 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1299 wxPyEndBlockThreads(blocked); \
1301 rval = PCLASS::CBNAME(a); \
1304 bool CLASS::base_##CBNAME(const wxString& a) { \
1305 return PCLASS::CBNAME(a); \
1308 //---------------------------------------------------------------------------
1310 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1311 bool CBNAME(const wxString& a)
1313 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1314 bool CLASS::CBNAME(const wxString& a) { \
1316 bool blocked = wxPyBeginBlockThreads(); \
1317 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1318 PyObject* s = wx2PyString(a); \
1319 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1322 wxPyEndBlockThreads(blocked); \
1326 //---------------------------------------------------------------------------
1328 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1329 wxString CBNAME(const wxString& a)
1331 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1332 wxString CLASS::CBNAME(const wxString& a) { \
1334 bool blocked = wxPyBeginBlockThreads(); \
1335 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1337 PyObject* s = wx2PyString(a); \
1338 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1341 rval = Py2wxString(ro); \
1345 wxPyEndBlockThreads(blocked); \
1349 //---------------------------------------------------------------------------
1351 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1352 wxString CBNAME(const wxString& a); \
1353 wxString base_##CBNAME(const wxString& a)
1355 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1356 wxString CLASS::CBNAME(const wxString& a) { \
1359 bool blocked = wxPyBeginBlockThreads(); \
1360 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1362 PyObject* s = wx2PyString(a); \
1363 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1366 rval = Py2wxString(ro); \
1371 rval = PCLASS::CBNAME(a); \
1372 wxPyEndBlockThreads(blocked); \
1376 //---------------------------------------------------------------------------
1378 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1379 wxString CBNAME(const wxString& a,int b)
1381 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1382 wxString CLASS::CBNAME(const wxString& a,int b) { \
1384 bool blocked = wxPyBeginBlockThreads(); \
1385 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1387 PyObject* s = wx2PyString(a); \
1388 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1391 rval = Py2wxString(ro); \
1395 wxPyEndBlockThreads(blocked); \
1399 //---------------------------------------------------------------------------
1401 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1402 bool CBNAME(const wxString& a, const wxString& b); \
1403 bool base_##CBNAME(const wxString& a, const wxString& b)
1405 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1406 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1409 bool blocked = wxPyBeginBlockThreads(); \
1410 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1411 PyObject* s1 = wx2PyString(a); \
1412 PyObject* s2 = wx2PyString(b); \
1413 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1417 wxPyEndBlockThreads(blocked); \
1419 rval = PCLASS::CBNAME(a, b); \
1422 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
1423 return PCLASS::CBNAME(a, b); \
1426 //---------------------------------------------------------------------------
1428 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1429 wxString CBNAME(); \
1430 wxString base_##CBNAME()
1432 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1433 wxString CLASS::CBNAME() { \
1436 bool blocked = wxPyBeginBlockThreads(); \
1437 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1439 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1441 rval = Py2wxString(ro); \
1445 wxPyEndBlockThreads(blocked); \
1447 rval = PCLASS::CBNAME(); \
1450 wxString CLASS::base_##CBNAME() { \
1451 return PCLASS::CBNAME(); \
1454 //---------------------------------------------------------------------------
1456 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1457 wxString CBNAME() const; \
1458 wxString base_##CBNAME() const;
1460 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1461 wxString CLASS::CBNAME() const { \
1464 bool blocked = wxPyBeginBlockThreads(); \
1465 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1467 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1469 rval = Py2wxString(ro); \
1473 wxPyEndBlockThreads(blocked); \
1475 rval = PCLASS::CBNAME(); \
1478 wxString CLASS::base_##CBNAME() const { \
1479 return PCLASS::CBNAME(); \
1482 //---------------------------------------------------------------------------
1484 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1487 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1488 wxString CLASS::CBNAME() { \
1490 bool blocked = wxPyBeginBlockThreads(); \
1491 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1493 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1495 rval = Py2wxString(ro); \
1499 wxPyEndBlockThreads(blocked); \
1503 //---------------------------------------------------------------------------
1505 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1506 wxString CBNAME() const;
1508 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1509 wxString CLASS::CBNAME() const { \
1511 bool blocked = wxPyBeginBlockThreads(); \
1512 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1514 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1516 rval = Py2wxString(ro); \
1520 wxPyEndBlockThreads(blocked); \
1524 //---------------------------------------------------------------------------
1526 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1527 bool CBNAME(const wxHtmlTag& a)
1530 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1531 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1533 bool blocked = wxPyBeginBlockThreads(); \
1534 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1535 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
1536 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1539 wxPyEndBlockThreads(blocked); \
1543 //---------------------------------------------------------------------------
1545 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1546 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \
1547 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1549 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1550 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1552 bool blocked = wxPyBeginBlockThreads(); \
1553 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1554 PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \
1555 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1558 wxPyEndBlockThreads(blocked); \
1560 PCLASS::CBNAME(cell, x, y); \
1562 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1563 PCLASS::CBNAME(cell, x, y); \
1566 //---------------------------------------------------------------------------
1568 #define DEC_PYCALLBACK__COLOUR(CBNAME) \
1569 void CBNAME(const wxColour& c); \
1570 void base_##CBNAME(const wxColour& c)
1572 #define IMP_PYCALLBACK__COLOUR(CLASS, PCLASS, CBNAME) \
1573 void CLASS::CBNAME(const wxColour& c) { \
1575 bool blocked = wxPyBeginBlockThreads(); \
1576 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1577 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1578 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1581 wxPyEndBlockThreads(blocked); \
1583 PCLASS::CBNAME(c); \
1585 void CLASS::base_##CBNAME(const wxColour& c) { \
1586 PCLASS::CBNAME(c); \
1589 //---------------------------------------------------------------------------
1591 #define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \
1592 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \
1593 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1595 #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \
1596 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1598 bool blocked = wxPyBeginBlockThreads(); \
1599 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1600 PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \
1601 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1602 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1606 wxPyEndBlockThreads(blocked); \
1608 PCLASS::CBNAME(cell, x, y, e); \
1610 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) {\
1611 PCLASS::CBNAME(cell, x, y, e); \
1616 //---------------------------------------------------------------------------
1618 #define DEC_PYCALLBACK___pure(CBNAME) \
1622 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1623 void CLASS::CBNAME() { \
1624 bool blocked = wxPyBeginBlockThreads(); \
1625 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1626 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1627 wxPyEndBlockThreads(blocked); \
1630 //---------------------------------------------------------------------------
1632 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1636 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1637 wxSize CLASS::CBNAME() { \
1638 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1640 bool blocked = wxPyBeginBlockThreads(); \
1641 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1644 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1646 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1648 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1649 PyObject* o1 = PySequence_GetItem(ro, 0); \
1650 PyObject* o2 = PySequence_GetItem(ro, 1); \
1651 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1652 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1654 PyErr_SetString(PyExc_TypeError, errmsg); \
1659 PyErr_SetString(PyExc_TypeError, errmsg); \
1664 wxPyEndBlockThreads(blocked); \
1668 //---------------------------------------------------------------------------
1670 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1671 bool CBNAME(wxWindow* a); \
1672 bool base_##CBNAME(wxWindow* a)
1675 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1676 bool CLASS::CBNAME(wxWindow* a) { \
1679 bool blocked = wxPyBeginBlockThreads(); \
1680 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1681 PyObject* obj = wxPyMake_wxObject(a); \
1682 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1685 wxPyEndBlockThreads(blocked); \
1687 rval = PCLASS::CBNAME(a); \
1690 bool CLASS::base_##CBNAME(wxWindow* a) { \
1691 return PCLASS::CBNAME(a); \
1694 //---------------------------------------------------------------------------
1696 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1697 bool CBNAME(wxWindow* a, wxDC& b); \
1698 bool base_##CBNAME(wxWindow* a, wxDC& b)
1701 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1702 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1705 bool blocked = wxPyBeginBlockThreads(); \
1706 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1707 PyObject* win = wxPyMake_wxObject(a); \
1708 PyObject* dc = wxPyMake_wxObject(&b); \
1709 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1713 wxPyEndBlockThreads(blocked); \
1715 rval = PCLASS::CBNAME(a, b); \
1718 bool CLASS::base_##CBNAME(wxWindow* a, wxDC& b) { \
1719 return PCLASS::CBNAME(a, b); \
1722 //---------------------------------------------------------------------------
1724 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1725 void CBNAME(wxWindowBase* a); \
1726 void base_##CBNAME(wxWindowBase* a)
1729 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1730 void CLASS::CBNAME(wxWindowBase* a) { \
1732 bool blocked = wxPyBeginBlockThreads(); \
1733 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1734 PyObject* obj = wxPyMake_wxObject(a); \
1735 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1738 wxPyEndBlockThreads(blocked); \
1740 PCLASS::CBNAME(a); \
1742 void CLASS::base_##CBNAME(wxWindowBase* a) { \
1743 PCLASS::CBNAME(a); \
1746 //---------------------------------------------------------------------------
1748 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1750 bool base_##CBNAME()
1753 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1754 bool CLASS::CBNAME() { \
1757 bool blocked = wxPyBeginBlockThreads(); \
1758 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1759 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1760 wxPyEndBlockThreads(blocked); \
1762 rval = PCLASS::CBNAME(); \
1765 bool CLASS::base_##CBNAME() { \
1766 return PCLASS::CBNAME(); \
1769 //---------------------------------------------------------------------------
1771 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1772 bool CBNAME() const; \
1773 bool base_##CBNAME() const
1776 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1777 bool CLASS::CBNAME() const { \
1780 bool blocked = wxPyBeginBlockThreads(); \
1781 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1782 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1783 wxPyEndBlockThreads(blocked); \
1785 rval = PCLASS::CBNAME(); \
1788 bool CLASS::base_##CBNAME() const { \
1789 return PCLASS::CBNAME(); \
1792 //---------------------------------------------------------------------------
1794 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1795 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
1796 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1799 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1800 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1803 bool blocked = wxPyBeginBlockThreads(); \
1804 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1805 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1806 wxPyEndBlockThreads(blocked); \
1808 rval = PCLASS::CBNAME(a, b, c); \
1809 return (wxDragResult)rval; \
1811 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1812 return PCLASS::CBNAME(a, b, c); \
1815 //---------------------------------------------------------------------------
1817 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1818 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1820 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1821 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1822 bool blocked = wxPyBeginBlockThreads(); \
1824 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1826 PyObject* obj = wxPyMake_wxObject(&a); \
1827 PyObject* s = wx2PyString(b); \
1828 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1831 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFILE")); \
1837 wxPyEndBlockThreads(blocked); \
1841 //---------------------------------------------------------------------------
1843 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1844 bool CBNAME(wxDragResult a); \
1845 bool base_##CBNAME(wxDragResult a)
1848 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1849 bool CLASS::CBNAME(wxDragResult a) { \
1852 bool blocked = wxPyBeginBlockThreads(); \
1853 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1854 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1855 wxPyEndBlockThreads(blocked); \
1857 rval = PCLASS::CBNAME(a); \
1860 bool CLASS::base_##CBNAME(wxDragResult a) { \
1861 return PCLASS::CBNAME(a); \
1864 //---------------------------------------------------------------------------
1866 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1867 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1870 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1871 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1872 bool blocked = wxPyBeginBlockThreads(); \
1874 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1875 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1876 wxPyEndBlockThreads(blocked); \
1877 return (wxDragResult)rval; \
1880 //---------------------------------------------------------------------------
1882 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1883 bool CBNAME(int a, int b, const wxString& c)
1885 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1886 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1888 bool blocked = wxPyBeginBlockThreads(); \
1889 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1890 PyObject* s = wx2PyString(c); \
1891 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1894 wxPyEndBlockThreads(blocked); \
1898 //---------------------------------------------------------------------------
1900 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1902 size_t base_##CBNAME()
1905 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1906 size_t CLASS::CBNAME() { \
1909 bool blocked = wxPyBeginBlockThreads(); \
1910 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1911 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1912 wxPyEndBlockThreads(blocked); \
1914 rval = PCLASS::CBNAME(); \
1917 size_t CLASS::base_##CBNAME() { \
1918 return PCLASS::CBNAME(); \
1921 //---------------------------------------------------------------------------
1923 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1924 size_t CBNAME() const; \
1925 size_t base_##CBNAME() const
1928 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1929 size_t CLASS::CBNAME() const { \
1932 bool blocked = wxPyBeginBlockThreads(); \
1933 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1934 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1935 wxPyEndBlockThreads(blocked); \
1937 rval = PCLASS::CBNAME(); \
1940 size_t CLASS::base_##CBNAME() const { \
1941 return PCLASS::CBNAME(); \
1944 //---------------------------------------------------------------------------
1946 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1947 wxDataFormat CBNAME(size_t a); \
1948 wxDataFormat base_##CBNAME(size_t a)
1951 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1952 wxDataFormat CLASS::CBNAME(size_t a) { \
1953 wxDataFormat rval=0; \
1955 bool blocked = wxPyBeginBlockThreads(); \
1956 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1958 wxDataFormat* ptr; \
1959 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1961 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1966 wxPyEndBlockThreads(blocked); \
1968 rval = PCLASS::CBNAME(a); \
1971 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1972 return PCLASS::CBNAME(a); \
1975 //---------------------------------------------------------------------------
1977 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1978 void CBNAME(const Type& a); \
1979 void base_##CBNAME(const Type& a)
1982 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1983 void CLASS::CBNAME(const Type& a) { \
1985 bool blocked = wxPyBeginBlockThreads(); \
1986 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1987 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1988 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1991 wxPyEndBlockThreads(blocked); \
1993 PCLASS::CBNAME(a); \
1995 void CLASS::base_##CBNAME(const Type& a) { \
1996 PCLASS::CBNAME(a); \
2000 //---------------------------------------------------------------------------
2002 #define DEC_PYCALLBACK__any(CBNAME, Type) \
2003 void CBNAME(Type& a); \
2004 void base_##CBNAME(Type& a)
2007 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
2008 void CLASS::CBNAME(Type& a) { \
2010 bool blocked = wxPyBeginBlockThreads(); \
2011 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2012 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2013 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2016 wxPyEndBlockThreads(blocked); \
2018 PCLASS::CBNAME(a); \
2020 void CLASS::base_##CBNAME(Type& a) { \
2021 PCLASS::CBNAME(a); \
2024 //---------------------------------------------------------------------------
2026 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
2027 bool CBNAME(Type& a); \
2028 bool base_##CBNAME(Type& a)
2031 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
2032 bool CLASS::CBNAME(Type& a) { \
2035 bool blocked = wxPyBeginBlockThreads(); \
2036 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2037 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2038 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2041 wxPyEndBlockThreads(blocked); \
2043 rv = PCLASS::CBNAME(a); \
2046 bool CLASS::base_##CBNAME(Type& a) { \
2047 return PCLASS::CBNAME(a); \
2050 //---------------------------------------------------------------------------
2052 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
2053 bool CBNAME(Type& a)
2056 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
2057 bool CLASS::CBNAME(Type& a) { \
2059 bool blocked = wxPyBeginBlockThreads(); \
2060 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2061 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2062 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2065 wxPyEndBlockThreads(blocked); \
2069 //---------------------------------------------------------------------------
2071 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
2072 wxString CBNAME(long a, long b) const; \
2073 wxString base_##CBNAME(long a, long b) const
2075 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
2076 wxString CLASS::CBNAME(long a, long b) const { \
2079 bool blocked = wxPyBeginBlockThreads(); \
2080 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2082 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2084 rval = Py2wxString(ro); \
2088 wxPyEndBlockThreads(blocked); \
2090 rval = PCLASS::CBNAME(a,b); \
2093 wxString CLASS::base_##CBNAME(long a, long b) const { \
2094 return PCLASS::CBNAME(a,b); \
2097 //---------------------------------------------------------------------------
2099 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
2100 int CBNAME(long a) const; \
2101 int base_##CBNAME(long a) const
2104 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
2105 int CLASS::CBNAME(long a) const { \
2108 bool blocked = wxPyBeginBlockThreads(); \
2109 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2111 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2113 rval = PyInt_AsLong(ro); \
2117 wxPyEndBlockThreads(blocked); \
2119 rval = PCLASS::CBNAME(a); \
2122 int CLASS::base_##CBNAME(long a) const { \
2123 return PCLASS::CBNAME(a); \
2127 //---------------------------------------------------------------------------
2129 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2130 wxListItemAttr* CBNAME(long a) const; \
2131 wxListItemAttr* base_##CBNAME(long a) const
2134 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2135 wxListItemAttr *CLASS::CBNAME(long a) const { \
2136 wxListItemAttr *rval = NULL; \
2138 bool blocked = wxPyBeginBlockThreads(); \
2139 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2141 wxListItemAttr* ptr; \
2142 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2144 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2149 wxPyEndBlockThreads(blocked); \
2151 rval = PCLASS::CBNAME(a); \
2154 wxListItemAttr *CLASS::base_##CBNAME(long a) const { \
2155 return PCLASS::CBNAME(a); \
2158 //---------------------------------------------------------------------------
2160 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2161 bool CBNAME(wxMouseEvent& e); \
2162 bool base_##CBNAME(wxMouseEvent& e)
2164 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2165 bool CLASS::CBNAME(wxMouseEvent& e) { \
2168 bool blocked = wxPyBeginBlockThreads(); \
2169 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2171 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2172 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2174 rval = PyInt_AsLong(ro); \
2179 wxPyEndBlockThreads(blocked); \
2181 return PCLASS::CBNAME(e); \
2184 bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
2185 return PCLASS::CBNAME(e); \
2189 //---------------------------------------------------------------------------
2191 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2192 wxWizardPage* CBNAME() const
2194 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2195 wxWizardPage* CLASS::CBNAME() const { \
2196 wxWizardPage* rv = NULL; \
2197 bool blocked = wxPyBeginBlockThreads(); \
2198 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2200 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2202 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2206 wxPyEndBlockThreads(blocked); \
2210 //---------------------------------------------------------------------------
2212 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2213 wxBitmap CBNAME() const
2215 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2216 wxBitmap CLASS::CBNAME() const { \
2218 bool blocked = wxPyBeginBlockThreads(); \
2219 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2222 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2224 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2229 wxPyEndBlockThreads(blocked); \
2233 //---------------------------------------------------------------------------
2235 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2238 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2239 wxObject* CLASS::CBNAME() { \
2240 wxObject* rv = NULL; \
2241 bool blocked = wxPyBeginBlockThreads(); \
2242 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2244 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2246 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2250 wxPyEndBlockThreads(blocked); \
2254 //---------------------------------------------------------------------------
2256 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2257 wxObject* CBNAME(const wxString& a)
2259 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2260 wxObject* CLASS::CBNAME(const wxString& a) { \
2261 wxObject* rv = NULL; \
2262 bool blocked = wxPyBeginBlockThreads(); \
2263 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2264 PyObject* so = wx2PyString(a); \
2266 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2268 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2273 wxPyEndBlockThreads(blocked); \
2277 //---------------------------------------------------------------------------
2279 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2280 bool CBNAME(wxXmlNode* a)
2283 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2284 bool CLASS::CBNAME(wxXmlNode* a) { \
2286 bool blocked = wxPyBeginBlockThreads(); \
2287 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2288 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2289 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2292 wxPyEndBlockThreads(blocked); \
2296 //---------------------------------------------------------------------------
2298 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2299 wxCoord CBNAME(size_t a) const
2302 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2303 wxCoord CLASS::CBNAME(size_t a) const { \
2306 bool blocked = wxPyBeginBlockThreads(); \
2307 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2308 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2310 wxPyEndBlockThreads(blocked); \
2314 //---------------------------------------------------------------------------
2316 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2317 void CBNAME(size_t a, size_t b) const; \
2318 void base_##CBNAME(size_t a, size_t b) const
2321 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2322 void CLASS::CBNAME(size_t a, size_t b) const { \
2324 bool blocked = wxPyBeginBlockThreads(); \
2325 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2326 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2327 wxPyEndBlockThreads(blocked); \
2329 PCLASS::CBNAME(a,b); \
2331 void CLASS::base_##CBNAME(size_t a, size_t b) const { \
2332 PCLASS::CBNAME(a,b); \
2335 //---------------------------------------------------------------------------
2337 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2338 wxCoord CBNAME() const; \
2339 wxCoord base_##CBNAME() const
2342 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2343 wxCoord CLASS::CBNAME() const { \
2346 bool blocked = wxPyBeginBlockThreads(); \
2347 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2348 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2349 wxPyEndBlockThreads(blocked); \
2351 rval = PCLASS::CBNAME(); \
2354 wxCoord CLASS::base_##CBNAME() const { \
2355 return PCLASS::CBNAME(); \
2358 //---------------------------------------------------------------------------
2360 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2361 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2364 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2365 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2367 bool blocked = wxPyBeginBlockThreads(); \
2368 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2369 PyObject* obj = wxPyMake_wxObject(&a); \
2370 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2371 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2374 wxPyEndBlockThreads(blocked); \
2377 //---------------------------------------------------------------------------
2379 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2380 void CBNAME(wxDC& a, const wxRect& b, size_t c) const; \
2381 void base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const
2384 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2385 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2387 bool blocked = wxPyBeginBlockThreads(); \
2388 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2389 PyObject* obj = wxPyMake_wxObject(&a); \
2390 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2391 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2394 wxPyEndBlockThreads(blocked); \
2396 PCLASS::CBNAME(a,b,c); \
2398 void CLASS::base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2399 PCLASS::CBNAME(a,b,c); \
2402 //---------------------------------------------------------------------------
2405 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2406 wxString CBNAME(size_t a) const; \
2407 wxString base_##CBNAME(size_t a) const
2409 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2410 wxString CLASS::CBNAME(size_t a) const { \
2413 bool blocked = wxPyBeginBlockThreads(); \
2414 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2416 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2418 rval = Py2wxString(ro); \
2422 wxPyEndBlockThreads(blocked); \
2424 rval = PCLASS::CBNAME(a); \
2427 wxString CLASS::base_##CBNAME(size_t a) const { \
2428 return PCLASS::CBNAME(a); \
2431 //---------------------------------------------------------------------------
2433 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2434 wxString CBNAME(size_t a) const
2436 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2437 wxString CLASS::CBNAME(size_t a) const { \
2440 bool blocked = wxPyBeginBlockThreads(); \
2441 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2443 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2445 rval = Py2wxString(ro); \
2449 wxPyEndBlockThreads(blocked); \
2453 //---------------------------------------------------------------------------
2455 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2456 wxVisualAttributes CBNAME() const; \
2457 wxVisualAttributes base_##CBNAME()
2460 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2461 wxVisualAttributes CLASS::CBNAME() const { \
2462 wxVisualAttributes rval; \
2464 bool blocked = wxPyBeginBlockThreads(); \
2465 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2467 wxVisualAttributes* ptr; \
2468 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2470 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2475 wxPyEndBlockThreads(blocked); \
2477 rval = PCLASS::CBNAME(); \
2480 wxVisualAttributes CLASS::base_##CBNAME() { \
2481 return PCLASS::CBNAME(); \
2484 //---------------------------------------------------------------------------