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/choicebk.h>
24 #include <wx/clipbrd.h>
25 #include <wx/colordlg.h>
26 #include <wx/config.h>
27 #include <wx/cshelp.h>
28 #include <wx/dcmirror.h>
30 #include <wx/dirctrl.h>
31 #include <wx/dirdlg.h>
33 #include <wx/docview.h>
34 #include <wx/encconv.h>
35 #include <wx/fdrepdlg.h>
36 #include <wx/fileconf.h>
37 #include <wx/filesys.h>
38 #include <wx/fontdlg.h>
39 #include <wx/fs_inet.h>
40 #include <wx/fs_mem.h>
41 #include <wx/fs_zip.h>
42 #include <wx/gbsizer.h>
43 #include <wx/geometry.h>
44 #include <wx/htmllbox.h>
46 #include <wx/imaglist.h>
48 #include <wx/laywin.h>
49 #include <wx/listbook.h>
50 #include <wx/minifram.h>
51 #include <wx/notebook.h>
53 #include <wx/printdlg.h>
54 #include <wx/process.h>
55 #include <wx/progdlg.h>
56 #include <wx/sashwin.h>
57 #include <wx/spinbutt.h>
58 #include <wx/spinctrl.h>
59 #include <wx/splash.h>
60 #include <wx/splitter.h>
61 #include <wx/statline.h>
62 #include <wx/stream.h>
63 #include <wx/sysopt.h>
64 #include <wx/taskbar.h>
65 #include <wx/tglbtn.h>
66 #include <wx/tipwin.h>
67 #include <wx/tooltip.h>
69 #include <wx/vscroll.h>
70 #include <wx/dateevt.h>
71 #include <wx/datectrl.h>
76 # pragma warning(disable:4800)
77 # pragma warning(disable:4190)
80 #ifdef __WXMAC__ // avoid a bug in Carbon headers
84 //---------------------------------------------------------------------------
86 typedef unsigned char byte
;
87 typedef wxPoint2DDouble wxPoint2D
;
90 #ifndef wxPyUSE_EXPORTED_API
92 void __wxPyPreStart(PyObject
*);
94 PyObject
* __wxPySetDictionary(PyObject
*, PyObject
* args
);
95 PyObject
* __wxPyFixStockObjects(PyObject
*, PyObject
* args
);
97 void wxSetDefaultPyEncoding(const char* encoding
);
98 const char* wxGetDefaultPyEncoding();
101 void wxPyEventThunker(wxObject
*, wxEvent
& event
);
104 bool wxPyCheckSwigType(const wxChar
* className
);
105 PyObject
* wxPyConstructObject(void* ptr
,
106 const wxChar
* className
,
108 bool wxPyConvertSwigPtr(PyObject
* obj
, void **ptr
,
109 const wxChar
* className
);
110 PyObject
* wxPyMakeSwigPtr(void* ptr
, const wxChar
* classname
);
113 PyObject
* wx2PyString(const wxString
& src
);
114 wxString
Py2wxString(PyObject
* source
);
116 PyObject
* wxPyMake_wxObject(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
=true);
117 PyObject
* wxPyMake_wxSizer(wxSizer
* source
, bool setThisOwn
);
118 void wxPyPtrTypeMap_Add(const char* commonName
, const char* ptrName
);
120 PyObject
* wxPy_ConvertList(wxListBase
* list
);
121 long wxPyGetWinHandle(wxWindow
* win
);
123 void wxPy_ReinitStockObjects(int pass
);
125 bool wxPyInstance_Check(PyObject
* obj
);
126 bool wxPySwigInstance_Check(PyObject
* obj
);
129 #endif // wxPyUSE_EXPORTED_API
130 //---------------------------------------------------------------------------
132 // if we want to handle threads and Python threads are available...
133 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
134 #define WXP_WITH_THREAD
135 #else // no Python threads...
136 #undef WXP_WITH_THREAD
140 // In Python 2.3 and later there are the PyGILState_* APIs that we can use for
141 // blocking threads when calling back into Python. Using them instead of my
142 // home-grown hacks greatly simplifies wxPyBeginBlockThreads and
143 // wxPyEndBlockThreads.
145 #if PY_VERSION_HEX < 0x02030000
146 #define wxPyUSE_GIL_STATE 0
147 typedef bool wxPyBlock_t
;
149 #define wxPyUSE_GIL_STATE 1
150 typedef PyGILState_STATE wxPyBlock_t
;
154 #ifndef wxPyUSE_EXPORTED_API
156 // For Python --> C++
157 PyThreadState
* wxPyBeginAllowThreads();
158 void wxPyEndAllowThreads(PyThreadState
* state
);
160 // For C++ --> Python
161 wxPyBlock_t
wxPyBeginBlockThreads();
162 void wxPyEndBlockThreads(wxPyBlock_t blocked
);
164 #endif // wxPyUSE_EXPORTED_API
167 // A macro that will help to execute simple statments wrapped in
168 // StartBlock/EndBlockThreads calls
169 #define wxPyBLOCK_THREADS(stmt) \
170 { wxPyBlock_t blocked = wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads(blocked); }
172 // Raise the NotImplementedError exception (blocking threads)
173 #define wxPyRaiseNotImplemented() \
174 wxPyBLOCK_THREADS(PyErr_SetNone(PyExc_NotImplementedError))
176 // Raise any exception with a string value (blocking threads)
177 #define wxPyErr_SetString(err, str) \
178 wxPyBLOCK_THREADS(PyErr_SetString(err, str))
181 //---------------------------------------------------------------------------
182 // These are helpers used by the typemaps
184 #ifndef wxPyUSE_EXPORTED_API
186 wxString
* wxString_in_helper(PyObject
* source
);
188 byte
* byte_LIST_helper(PyObject
* source
);
189 int* int_LIST_helper(PyObject
* source
);
190 long* long_LIST_helper(PyObject
* source
);
191 char** string_LIST_helper(PyObject
* source
);
192 wxPoint
* wxPoint_LIST_helper(PyObject
* source
, int* npoints
);
193 wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
194 wxString
* wxString_LIST_helper(PyObject
* source
);
195 wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
196 wxPen
** wxPen_LIST_helper(PyObject
* source
);
198 bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
199 bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
200 bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
201 bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
202 bool wxColour_helper(PyObject
* source
, wxColour
** obj
);
203 bool wxPoint2D_helper(PyObject
* source
, wxPoint2D
** obj
);
206 bool wxPySimple_typecheck(PyObject
* source
, const wxChar
* classname
, int seqLen
);
207 bool wxColour_typecheck(PyObject
* source
);
209 bool wxPyCheckForApp();
213 bool wxPyTwoIntItem_helper(PyObject
* source
, T
** obj
, const wxChar
* name
)
215 // If source is an object instance then it may already be the right type
216 if (wxPySwigInstance_Check(source
)) {
218 if (! wxPyConvertSwigPtr(source
, (void **)&ptr
, name
))
223 // otherwise a 2-tuple of integers is expected
224 else if (PySequence_Check(source
) && PyObject_Length(source
) == 2) {
225 PyObject
* o1
= PySequence_GetItem(source
, 0);
226 PyObject
* o2
= PySequence_GetItem(source
, 1);
227 if (!PyNumber_Check(o1
) || !PyNumber_Check(o2
)) {
232 **obj
= T(PyInt_AsLong(o1
), PyInt_AsLong(o2
));
240 msg
.Printf(wxT("Expected a 2-tuple of integers or a %s object."), name
);
241 PyErr_SetString(PyExc_TypeError
, msg
.mb_str());
247 // Other helpful stuff
248 bool wxPy2int_seq_helper(PyObject
* source
, int* i1
, int* i2
);
249 bool wxPy4int_seq_helper(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
251 PyObject
* wxArrayString2PyList_helper(const wxArrayString
& arr
);
252 PyObject
* wxArrayInt2PyList_helper(const wxArrayInt
& arr
);
254 #endif // wxPyUSE_EXPORTED_API
256 //---------------------------------------------------------------------------
258 #if PYTHON_API_VERSION < 1009
259 #define PySequence_Fast_GET_ITEM(o, i) \
260 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
263 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
264 #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name)
265 #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val)
267 //---------------------------------------------------------------------------
269 #ifndef wxPyUSE_EXPORTED_API
271 class wxPyCallback
: public wxObject
{
272 DECLARE_ABSTRACT_CLASS(wxPyCallback
);
274 wxPyCallback(PyObject
* func
);
275 wxPyCallback(const wxPyCallback
& other
);
278 void EventThunker(wxEvent
& event
);
283 #endif // wxPyUSE_EXPORTED_API
284 //---------------------------------------------------------------------------
285 //---------------------------------------------------------------------------
286 // These Event classes can be derived from in Python and passed through the
287 // event system without loosing anything. They do this by keeping a reference
288 // to themselves and some special case handling in wxPyCallback::EventThunker.
292 class wxPyEvtSelfRef
{
297 void SetSelf(PyObject
* self
, bool clone
=false);
298 PyObject
* GetSelf() const;
299 bool GetCloned() const { return m_cloned
; }
307 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
308 DECLARE_ABSTRACT_CLASS(wxPyEvent
)
310 wxPyEvent(int winid
=0, wxEventType commandType
= wxEVT_NULL
);
311 wxPyEvent(const wxPyEvent
& evt
);
314 virtual wxEvent
* Clone() const { return new wxPyEvent(*this); }
318 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
319 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent
)
321 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
322 wxPyCommandEvent(const wxPyCommandEvent
& evt
);
325 virtual wxEvent
* Clone() const { return new wxPyCommandEvent(*this); }
330 //----------------------------------------------------------------------
331 // Forward decalre a few things used in the exported API
332 class wxPyClientData
;
334 class wxPyOORClientData
;
335 class wxPyCBInputStream
;
337 void wxPyClientData_dtor(wxPyClientData
* self
);
338 void wxPyUserData_dtor(wxPyUserData
* self
);
339 void wxPyOORClientData_dtor(wxPyOORClientData
* self
);
340 wxPyCBInputStream
* wxPyCBInputStream_create(PyObject
*py
, bool block
);
341 wxPyCBInputStream
* wxPyCBInputStream_copy(wxPyCBInputStream
* other
);
343 //---------------------------------------------------------------------------
344 // Export a C API in a struct. Other modules will be able to load this from
345 // the wx.core module and will then have safe access to these functions, even if
346 // in another shared library.
348 class wxPyCallbackHelper
;
352 bool (*p_wxPyCheckSwigType
)(const wxChar
* className
);
353 PyObject
* (*p_wxPyConstructObject
)(void* ptr
, const wxChar
* className
, int setThisOwn
);
354 bool (*p_wxPyConvertSwigPtr
)(PyObject
* obj
, void **ptr
, const wxChar
* className
);
355 PyObject
* (*p_wxPyMakeSwigPtr
)(void* ptr
, const wxChar
* className
);
357 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
358 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
359 wxPyBlock_t (*p_wxPyBeginBlockThreads
)();
360 void (*p_wxPyEndBlockThreads
)(wxPyBlock_t blocked
);
362 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
);
364 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
365 wxString (*p_Py2wxString
)(PyObject
* source
);
366 PyObject
* (*p_wx2PyString
)(const wxString
& src
);
368 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
369 int* (*p_int_LIST_helper
)(PyObject
* source
);
370 long* (*p_long_LIST_helper
)(PyObject
* source
);
371 char** (*p_string_LIST_helper
)(PyObject
* source
);
372 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
373 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
374 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
375 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
377 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
378 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
379 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
380 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
381 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
382 bool (*p_wxPoint2D_helper
)(PyObject
* source
, wxPoint2DDouble
** obj
);
385 bool (*p_wxPySimple_typecheck
)(PyObject
* source
, const wxChar
* classname
, int seqLen
);
386 bool (*p_wxColour_typecheck
)(PyObject
* source
);
388 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
389 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
);
390 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
391 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
392 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
394 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
);
395 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
, bool setThisOwn
);
396 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
397 bool (*p_wxPy2int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
);
398 bool (*p_wxPy4int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
399 PyObject
* (*p_wxArrayString2PyList_helper
)(const wxArrayString
& arr
);
400 PyObject
* (*p_wxArrayInt2PyList_helper
)(const wxArrayInt
& arr
);
402 void (*p_wxPyClientData_dtor
)(wxPyClientData
*);
403 void (*p_wxPyUserData_dtor
)(wxPyUserData
*);
404 void (*p_wxPyOORClientData_dtor
)(wxPyOORClientData
*);
406 wxPyCBInputStream
* (*p_wxPyCBInputStream_create
)(PyObject
*py
, bool block
);
407 wxPyCBInputStream
* (*p_wxPyCBInputStream_copy
)(wxPyCBInputStream
* other
);
409 bool (*p_wxPyInstance_Check
)(PyObject
* obj
);
410 bool (*p_wxPySwigInstance_Check
)(PyObject
* obj
);
412 bool (*p_wxPyCheckForApp
)();
416 #ifdef wxPyUSE_EXPORTED_API
417 // Notice that this is static, not extern. This is by design, each module
418 // needs one, but doesn't have to use it.
419 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
;
420 inline wxPyCoreAPI
* wxPyGetCoreAPIPtr();
421 #endif // wxPyUSE_EXPORTED_API
423 //---------------------------------------------------------------------------
425 // A wxObject that holds a reference to a Python object
426 class wxPyUserData
: public wxObject
{
428 wxPyUserData(PyObject
* obj
) {
434 #ifdef wxPyUSE_EXPORTED_API
435 wxPyGetCoreAPIPtr()->p_wxPyUserData_dtor(this);
437 wxPyUserData_dtor(this);
444 // A wxClientData that holds a refernece to a Python object
445 class wxPyClientData
: public wxClientData
{
447 wxPyClientData(PyObject
* obj
, bool incref
=true) {
455 #ifdef wxPyUSE_EXPORTED_API
456 wxPyGetCoreAPIPtr()->p_wxPyClientData_dtor(this);
458 wxPyClientData_dtor(this);
466 // Just like wxPyClientData, except when this object is destroyed it does some
467 // OOR magic on the Python Object.
468 class wxPyOORClientData
: public wxPyClientData
{
470 wxPyOORClientData(PyObject
* obj
, bool incref
=true)
471 : wxPyClientData(obj
, incref
) {}
472 ~wxPyOORClientData() {
474 #ifdef wxPyUSE_EXPORTED_API
475 wxPyGetCoreAPIPtr()->p_wxPyOORClientData_dtor(this);
477 wxPyOORClientData_dtor(this);
483 //---------------------------------------------------------------------------
484 // This class holds an instance of a Python Shadow Class object and assists
485 // with looking up and invoking Python callback methods from C++ virtual
486 // method redirections. For all classes which have virtuals which should be
487 // overridable in wxPython, a new subclass is created that contains a
488 // wxPyCallbackHelper.
491 class wxPyCallbackHelper
{
493 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
495 wxPyCallbackHelper() {
502 ~wxPyCallbackHelper() {
503 #ifdef wxPyUSE_EXPORTED_API
504 wxPyGetCoreAPIPtr()->p_wxPyCBH_delete(this);
506 wxPyCBH_delete(this);
510 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=true);
511 bool findCallback(const char* name
) const;
512 int callCallback(PyObject
* argTuple
) const;
513 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
514 PyObject
* GetLastFound() const { return m_lastFound
; }
519 PyObject
* m_lastFound
;
522 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
526 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
527 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
);
528 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
529 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
530 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
535 //---------------------------------------------------------------------------
537 // This is used in C++ classes that need to be able to make callback to
538 // "overloaded" python methods
541 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
542 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
544 private: wxPyCallbackHelper m_myInst
547 //---------------------------------------------------------------------------
548 // The wxPythonApp class
551 wxPYAPP_ASSERT_SUPPRESS
= 1,
552 wxPYAPP_ASSERT_EXCEPTION
= 2,
553 wxPYAPP_ASSERT_DIALOG
= 4,
554 wxPYAPP_ASSERT_LOG
= 8
557 class wxPyApp
: public wxApp
559 DECLARE_ABSTRACT_CLASS(wxPyApp
);
567 int GetAssertMode() { return m_assertMode
; }
568 void SetAssertMode(int mode
) { m_assertMode
= mode
; }
570 virtual bool OnInitGui();
571 virtual int OnExit();
573 virtual void OnAssert(const wxChar
*file
,
578 // virtual int FilterEvent(wxEvent& event); // This one too????
580 // For catching Apple Events
581 virtual void MacOpenFile(const wxString
&fileName
);
582 virtual void MacPrintFile(const wxString
&fileName
);
583 virtual void MacNewFile();
584 virtual void MacReopenApp();
586 static bool GetMacSupportPCMenuShortcuts();
587 static long GetMacAboutMenuItemId();
588 static long GetMacPreferencesMenuItemId();
589 static long GetMacExitMenuItemId();
590 static wxString
GetMacHelpMenuTitleName();
592 static void SetMacSupportPCMenuShortcuts(bool val
);
593 static void SetMacAboutMenuItemId(long val
);
594 static void SetMacPreferencesMenuItemId(long val
);
595 static void SetMacExitMenuItemId(long val
);
596 static void SetMacHelpMenuTitleName(const wxString
& val
);
599 void _BootstrapApp();
601 // implementation only
602 void SetStartupComplete(bool val
) { m_startupComplete
= val
; };
606 bool m_startupComplete
;
609 extern wxPyApp
*wxPythonApp
;
612 //----------------------------------------------------------------------
613 // These macros are used to implement the virtual methods that should
614 // redirect to a Python method if one exists. The names designate the
615 // return type, if any, as well as any parameter types.
616 //---------------------------------------------------------------------------
618 #define DEC_PYCALLBACK__(CBNAME) \
623 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
624 void CLASS::CBNAME() { \
626 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
627 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
628 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
629 wxPyEndBlockThreads(blocked); \
633 void CLASS::base_##CBNAME() { \
637 //---------------------------------------------------------------------------
639 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
640 bool CBNAME(int a, int b); \
641 bool base_##CBNAME(int a, int b)
644 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
645 bool CLASS::CBNAME(int a, int b) { \
646 bool rval=false, found; \
647 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
648 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
649 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
650 wxPyEndBlockThreads(blocked); \
652 rval = PCLASS::CBNAME(a,b); \
655 bool CLASS::base_##CBNAME(int a, int b) { \
656 return PCLASS::CBNAME(a,b); \
659 //---------------------------------------------------------------------------
661 #define DEC_PYCALLBACK_VOID_(CBNAME) \
666 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
667 void CLASS::CBNAME() { \
669 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
670 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
671 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
672 wxPyEndBlockThreads(blocked); \
676 void CLASS::base_##CBNAME() { \
680 //---------------------------------------------------------------------------
682 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
683 void CBNAME(int a, int b); \
684 void base_##CBNAME(int a, int b)
687 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
688 void CLASS::CBNAME(int a, int b) { \
690 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
691 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
692 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
693 wxPyEndBlockThreads(blocked); \
695 PCLASS::CBNAME(a,b); \
697 void CLASS::base_##CBNAME(int a, int b) { \
698 PCLASS::CBNAME(a,b); \
701 //---------------------------------------------------------------------------
703 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
704 void CBNAME(int a); \
705 void base_##CBNAME(int a)
708 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
709 void CLASS::CBNAME(int a) { \
711 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
712 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
713 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
714 wxPyEndBlockThreads(blocked); \
718 void CLASS::base_##CBNAME(int a) { \
722 //---------------------------------------------------------------------------
724 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
725 void CBNAME(int a, int b, int c, int d); \
726 void base_##CBNAME(int a, int b, int c, int d)
729 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
730 void CLASS::CBNAME(int a, int b, int c, int d) { \
732 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
733 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
734 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
735 wxPyEndBlockThreads(blocked); \
737 PCLASS::CBNAME(a,b,c,d); \
739 void CLASS::base_##CBNAME(int a, int b, int c, int d) { \
740 PCLASS::CBNAME(a,b,c,d); \
743 //---------------------------------------------------------------------------
744 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
745 void CBNAME(int a, int b, int c, int d, int e); \
746 void base_##CBNAME(int a, int b, int c, int d, int e)
749 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
750 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
752 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
753 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
754 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
755 wxPyEndBlockThreads(blocked); \
757 PCLASS::CBNAME(a,b,c,d,e); \
759 void CLASS::base_##CBNAME(int a, int b, int c, int d, int e) { \
760 PCLASS::CBNAME(a,b,c,d,e); \
763 //---------------------------------------------------------------------------
765 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
766 void CBNAME(int* a, int* b) const; \
767 void base_##CBNAME(int* a, int* b) const
770 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
771 void CLASS::CBNAME(int* a, int* b) const { \
772 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
774 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
775 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
777 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
779 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
780 PyObject* o1 = PySequence_GetItem(ro, 0); \
781 PyObject* o2 = PySequence_GetItem(ro, 1); \
782 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
783 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
786 PyErr_SetString(PyExc_TypeError, errmsg); \
791 PyErr_SetString(PyExc_TypeError, errmsg); \
796 wxPyEndBlockThreads(blocked); \
798 PCLASS::CBNAME(a,b); \
800 void CLASS::base_##CBNAME(int* a, int* b) const { \
801 PCLASS::CBNAME(a,b); \
805 //---------------------------------------------------------------------------
807 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
808 wxSize CBNAME() const; \
809 wxSize base_##CBNAME() const
812 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
813 wxSize CLASS::CBNAME() const { \
814 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
815 bool found; wxSize rval(0,0); \
816 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
817 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
819 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
821 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
822 PyObject* o1 = PySequence_GetItem(ro, 0); \
823 PyObject* o2 = PySequence_GetItem(ro, 1); \
824 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
825 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
828 PyErr_SetString(PyExc_TypeError, errmsg); \
833 PyErr_SetString(PyExc_TypeError, errmsg); \
838 wxPyEndBlockThreads(blocked); \
840 return PCLASS::CBNAME(); \
844 wxSize CLASS::base_##CBNAME() const { \
845 return PCLASS::CBNAME(); \
849 //---------------------------------------------------------------------------
851 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
852 bool CBNAME(bool a); \
853 bool base_##CBNAME(bool a)
856 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
857 bool CLASS::CBNAME(bool a) { \
858 bool rval=false, found; \
859 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
860 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
861 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
862 wxPyEndBlockThreads(blocked); \
864 rval = PCLASS::CBNAME(a); \
867 bool CLASS::base_##CBNAME(bool a) { \
868 return PCLASS::CBNAME(a); \
871 //---------------------------------------------------------------------------
873 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
874 bool CBNAME(int a); \
875 bool base_##CBNAME(int a)
878 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
879 bool CLASS::CBNAME(int a) { \
880 bool rval=false, found; \
881 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
882 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
883 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
884 wxPyEndBlockThreads(blocked); \
886 rval = PCLASS::CBNAME(a); \
889 bool CLASS::base_##CBNAME(int a) { \
890 return PCLASS::CBNAME(a); \
893 //---------------------------------------------------------------------------
895 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
899 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
900 bool CLASS::CBNAME(int a) { \
902 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
903 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
904 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
906 wxPyEndBlockThreads(blocked); \
911 //---------------------------------------------------------------------------
913 #define DEC_PYCALLBACK__DC(CBNAME) \
914 void CBNAME(wxDC& a); \
915 void base_##CBNAME(wxDC& a)
918 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
919 void CLASS::CBNAME(wxDC& a) { \
921 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
922 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
923 PyObject* obj = wxPyMake_wxObject(&a,false); \
924 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
927 wxPyEndBlockThreads(blocked); \
931 void CLASS::base_##CBNAME(wxDC& a) { \
937 //---------------------------------------------------------------------------
939 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
940 void CBNAME(wxDC& a, bool b); \
941 void base_##CBNAME(wxDC& a, bool b)
944 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
945 void CLASS::CBNAME(wxDC& a, bool b) { \
947 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
948 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
949 PyObject* obj = wxPyMake_wxObject(&a,false); \
950 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
953 wxPyEndBlockThreads(blocked); \
955 PCLASS::CBNAME(a, b); \
957 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
958 PCLASS::CBNAME(a, b); \
961 //---------------------------------------------------------------------------
963 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
964 void CBNAME(wxDC& a, bool b); \
965 void base_##CBNAME(wxDC& a, bool b)
968 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
969 void CLASS::CBNAME(wxDC& a, bool b) { \
971 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
972 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
973 PyObject* obj = wxPyMake_wxObject(&a,false); \
974 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
977 wxPyEndBlockThreads(blocked); \
979 PCLASS::CBNAME(a, b); \
981 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
982 PCLASS::CBNAME(a, b); \
985 //---------------------------------------------------------------------------
987 #define DEC_PYCALLBACK__2DBL(CBNAME) \
988 void CBNAME(double a, double b); \
989 void base_##CBNAME(double a, double b)
992 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
993 void CLASS::CBNAME(double a, double b) { \
995 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
996 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
997 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
998 wxPyEndBlockThreads(blocked); \
1000 PCLASS::CBNAME(a, b); \
1002 void CLASS::base_##CBNAME(double a, double b) { \
1003 PCLASS::CBNAME(a, b); \
1006 //---------------------------------------------------------------------------
1008 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
1009 void CBNAME(double a, double b, int c, int d); \
1010 void base_##CBNAME(double a, double b, int c, int d)
1013 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
1014 void CLASS::CBNAME(double a, double b, int c, int d) { \
1016 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1017 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1018 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
1020 wxPyEndBlockThreads(blocked); \
1022 PCLASS::CBNAME(a, b, c, d); \
1024 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
1025 PCLASS::CBNAME(a, b, c, d); \
1028 //---------------------------------------------------------------------------
1030 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
1031 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
1032 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1035 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1036 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1038 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1039 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1040 PyObject* obj = wxPyMake_wxObject(&a,false); \
1041 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
1044 wxPyEndBlockThreads(blocked); \
1046 PCLASS::CBNAME(a, b, c, d, e, f); \
1048 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
1049 PCLASS::CBNAME(a, b, c, d, e, f); \
1052 //---------------------------------------------------------------------------
1054 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
1055 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
1056 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1059 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1060 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1062 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1064 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1065 PyObject* obj = wxPyMake_wxObject(&a,false); \
1066 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1069 wxPyEndBlockThreads(blocked); \
1071 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1074 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
1075 return PCLASS::CBNAME(a, b, c, d, e, f); \
1078 //---------------------------------------------------------------------------
1080 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1081 void CBNAME(bool a, double b, double c, int d, int e); \
1082 void base_##CBNAME(bool a, double b, double c, int d, int e)
1085 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1086 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1088 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1089 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1090 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1092 wxPyEndBlockThreads(blocked); \
1094 PCLASS::CBNAME(a, b, c, d, e); \
1096 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
1097 PCLASS::CBNAME(a, b, c, d, e); \
1100 //---------------------------------------------------------------------------
1102 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1103 void CBNAME(wxDC& a, double b, double c, double d, double e); \
1104 void base_##CBNAME(wxDC& a, double b, double c, double d, double e)
1107 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1108 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1110 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1111 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1112 PyObject* obj = wxPyMake_wxObject(&a,false); \
1113 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1116 wxPyEndBlockThreads(blocked); \
1118 PCLASS::CBNAME(a, b, c, d, e); \
1120 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
1121 PCLASS::CBNAME(a, b, c, d, e); \
1124 //---------------------------------------------------------------------------
1126 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1127 void CBNAME(wxDC& a, bool b); \
1128 void base_##CBNAME(wxDC& a, bool b)
1131 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1132 void CLASS::CBNAME(wxDC& a, bool b) { \
1134 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1135 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1136 PyObject* obj = wxPyMake_wxObject(&a,false); \
1137 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1140 wxPyEndBlockThreads(blocked); \
1142 PCLASS::CBNAME(a, b); \
1144 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
1145 PCLASS::CBNAME(a, b); \
1148 //---------------------------------------------------------------------------
1150 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1151 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
1152 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1155 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1156 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1159 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1160 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1161 PyObject* obj = wxPyMake_wxObject(a,false); \
1162 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1165 wxPyEndBlockThreads(blocked); \
1167 PCLASS::CBNAME(a, b, c, d, e, f); \
1169 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
1171 PCLASS::CBNAME(a, b, c, d, e, f); \
1174 //---------------------------------------------------------------------------
1176 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1177 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
1178 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1181 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1182 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1184 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1185 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1186 PyObject* obj = wxPyMake_wxObject(a,false); \
1187 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1190 wxPyEndBlockThreads(blocked); \
1192 PCLASS::CBNAME(a, b, c, d, e); \
1194 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
1196 PCLASS::CBNAME(a, b, c, d, e); \
1199 //---------------------------------------------------------------------------
1201 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1202 void CBNAME(double a, double b, int c); \
1203 void base_##CBNAME(double a, double b, int c)
1206 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1207 void CLASS::CBNAME(double a, double b, int c) { \
1209 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1210 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1211 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1212 wxPyEndBlockThreads(blocked); \
1214 PCLASS::CBNAME(a, b, c); \
1216 void CLASS::base_##CBNAME(double a, double b, int c) { \
1217 PCLASS::CBNAME(a, b, c); \
1220 //---------------------------------------------------------------------------
1222 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1223 void CBNAME(bool a, double b, double c, int d); \
1224 void base_##CBNAME(bool a, double b, double c, int d)
1227 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1228 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1230 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1231 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1232 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1233 wxPyEndBlockThreads(blocked); \
1235 PCLASS::CBNAME(a, b, c, d); \
1237 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
1238 PCLASS::CBNAME(a, b, c, d); \
1241 //---------------------------------------------------------------------------
1242 //---------------------------------------------------------------------------
1244 #define DEC_PYCALLBACK__STRING(CBNAME) \
1245 void CBNAME(const wxString& a); \
1246 void base_##CBNAME(const wxString& a)
1248 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1249 void CLASS::CBNAME(const wxString& a) { \
1251 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1252 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1253 PyObject* s = wx2PyString(a); \
1254 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1257 wxPyEndBlockThreads(blocked); \
1259 PCLASS::CBNAME(a); \
1261 void CLASS::base_##CBNAME(const wxString& a) { \
1262 PCLASS::CBNAME(a); \
1265 //---------------------------------------------------------------------------
1267 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1268 bool CBNAME(const wxString& a); \
1269 bool base_##CBNAME(const wxString& a)
1271 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1272 bool CLASS::CBNAME(const wxString& a) { \
1275 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1276 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1277 PyObject* s = wx2PyString(a); \
1278 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1281 wxPyEndBlockThreads(blocked); \
1283 rval = PCLASS::CBNAME(a); \
1286 bool CLASS::base_##CBNAME(const wxString& a) { \
1287 return PCLASS::CBNAME(a); \
1290 //---------------------------------------------------------------------------
1292 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1293 bool CBNAME(const wxString& a)
1295 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1296 bool CLASS::CBNAME(const wxString& a) { \
1298 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1299 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1300 PyObject* s = wx2PyString(a); \
1301 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1304 wxPyEndBlockThreads(blocked); \
1308 //---------------------------------------------------------------------------
1310 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1311 wxString CBNAME(const wxString& a)
1313 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1314 wxString CLASS::CBNAME(const wxString& a) { \
1316 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1317 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1319 PyObject* s = wx2PyString(a); \
1320 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1323 rval = Py2wxString(ro); \
1327 wxPyEndBlockThreads(blocked); \
1331 //---------------------------------------------------------------------------
1333 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1334 wxString CBNAME(const wxString& a); \
1335 wxString base_##CBNAME(const wxString& a)
1337 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1338 wxString CLASS::CBNAME(const wxString& a) { \
1341 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1342 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1344 PyObject* s = wx2PyString(a); \
1345 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1348 rval = Py2wxString(ro); \
1353 rval = PCLASS::CBNAME(a); \
1354 wxPyEndBlockThreads(blocked); \
1358 //---------------------------------------------------------------------------
1360 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1361 wxString CBNAME(const wxString& a,int b)
1363 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1364 wxString CLASS::CBNAME(const wxString& a,int b) { \
1366 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1367 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1369 PyObject* s = wx2PyString(a); \
1370 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1373 rval = Py2wxString(ro); \
1377 wxPyEndBlockThreads(blocked); \
1381 //---------------------------------------------------------------------------
1383 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1384 bool CBNAME(const wxString& a, const wxString& b); \
1385 bool base_##CBNAME(const wxString& a, const wxString& b)
1387 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1388 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1391 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1392 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1393 PyObject* s1 = wx2PyString(a); \
1394 PyObject* s2 = wx2PyString(b); \
1395 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1399 wxPyEndBlockThreads(blocked); \
1401 rval = PCLASS::CBNAME(a, b); \
1404 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
1405 return PCLASS::CBNAME(a, b); \
1408 //---------------------------------------------------------------------------
1410 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1411 wxString CBNAME(); \
1412 wxString base_##CBNAME()
1414 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1415 wxString CLASS::CBNAME() { \
1418 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1419 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1421 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1423 rval = Py2wxString(ro); \
1427 wxPyEndBlockThreads(blocked); \
1429 rval = PCLASS::CBNAME(); \
1432 wxString CLASS::base_##CBNAME() { \
1433 return PCLASS::CBNAME(); \
1436 //---------------------------------------------------------------------------
1438 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1439 wxString CBNAME() const; \
1440 wxString base_##CBNAME() const;
1442 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1443 wxString CLASS::CBNAME() const { \
1446 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1447 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1449 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1451 rval = Py2wxString(ro); \
1455 wxPyEndBlockThreads(blocked); \
1457 rval = PCLASS::CBNAME(); \
1460 wxString CLASS::base_##CBNAME() const { \
1461 return PCLASS::CBNAME(); \
1464 //---------------------------------------------------------------------------
1466 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1469 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1470 wxString CLASS::CBNAME() { \
1472 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1473 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1475 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1477 rval = Py2wxString(ro); \
1481 wxPyEndBlockThreads(blocked); \
1485 //---------------------------------------------------------------------------
1487 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1488 wxString CBNAME() const;
1490 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1491 wxString CLASS::CBNAME() const { \
1493 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1494 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1496 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1498 rval = Py2wxString(ro); \
1502 wxPyEndBlockThreads(blocked); \
1506 //---------------------------------------------------------------------------
1508 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1509 bool CBNAME(const wxHtmlTag& a)
1512 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1513 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1515 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1516 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1517 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
1518 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1521 wxPyEndBlockThreads(blocked); \
1525 //---------------------------------------------------------------------------
1527 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1528 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \
1529 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1531 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1532 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1534 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1535 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1536 PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \
1537 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1540 wxPyEndBlockThreads(blocked); \
1542 PCLASS::CBNAME(cell, x, y); \
1544 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1545 PCLASS::CBNAME(cell, x, y); \
1548 //---------------------------------------------------------------------------
1550 #define DEC_PYCALLBACK__COLOUR(CBNAME) \
1551 void CBNAME(const wxColour& c); \
1552 void base_##CBNAME(const wxColour& c)
1554 #define IMP_PYCALLBACK__COLOUR(CLASS, PCLASS, CBNAME) \
1555 void CLASS::CBNAME(const wxColour& c) { \
1557 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1558 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1559 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1560 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1563 wxPyEndBlockThreads(blocked); \
1565 PCLASS::CBNAME(c); \
1567 void CLASS::base_##CBNAME(const wxColour& c) { \
1568 PCLASS::CBNAME(c); \
1571 //---------------------------------------------------------------------------
1573 #define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \
1574 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \
1575 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1577 #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \
1578 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1580 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1581 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1582 PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \
1583 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1584 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1588 wxPyEndBlockThreads(blocked); \
1590 PCLASS::CBNAME(cell, x, y, e); \
1592 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) {\
1593 PCLASS::CBNAME(cell, x, y, e); \
1598 //---------------------------------------------------------------------------
1600 #define DEC_PYCALLBACK___pure(CBNAME) \
1604 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1605 void CLASS::CBNAME() { \
1606 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1607 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1608 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1609 wxPyEndBlockThreads(blocked); \
1612 //---------------------------------------------------------------------------
1614 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1618 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1619 wxSize CLASS::CBNAME() { \
1620 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1622 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1623 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1626 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1628 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1630 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1631 PyObject* o1 = PySequence_GetItem(ro, 0); \
1632 PyObject* o2 = PySequence_GetItem(ro, 1); \
1633 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1634 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1636 PyErr_SetString(PyExc_TypeError, errmsg); \
1641 PyErr_SetString(PyExc_TypeError, errmsg); \
1646 wxPyEndBlockThreads(blocked); \
1650 //---------------------------------------------------------------------------
1652 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1653 bool CBNAME(wxWindow* a); \
1654 bool base_##CBNAME(wxWindow* a)
1657 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1658 bool CLASS::CBNAME(wxWindow* a) { \
1661 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1662 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1663 PyObject* obj = wxPyMake_wxObject(a,false); \
1664 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1667 wxPyEndBlockThreads(blocked); \
1669 rval = PCLASS::CBNAME(a); \
1672 bool CLASS::base_##CBNAME(wxWindow* a) { \
1673 return PCLASS::CBNAME(a); \
1676 //---------------------------------------------------------------------------
1678 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1679 bool CBNAME(wxWindow* a, wxDC& b); \
1680 bool base_##CBNAME(wxWindow* a, wxDC& b)
1683 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1684 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1687 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1688 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1689 PyObject* win = wxPyMake_wxObject(a,false); \
1690 PyObject* dc = wxPyMake_wxObject(&b,false); \
1691 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1695 wxPyEndBlockThreads(blocked); \
1697 rval = PCLASS::CBNAME(a, b); \
1700 bool CLASS::base_##CBNAME(wxWindow* a, wxDC& b) { \
1701 return PCLASS::CBNAME(a, b); \
1704 //---------------------------------------------------------------------------
1706 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1707 void CBNAME(wxWindowBase* a); \
1708 void base_##CBNAME(wxWindowBase* a)
1711 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1712 void CLASS::CBNAME(wxWindowBase* a) { \
1714 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1715 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1716 PyObject* obj = wxPyMake_wxObject(a,false); \
1717 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1720 wxPyEndBlockThreads(blocked); \
1722 PCLASS::CBNAME(a); \
1724 void CLASS::base_##CBNAME(wxWindowBase* a) { \
1725 PCLASS::CBNAME(a); \
1728 //---------------------------------------------------------------------------
1730 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1732 bool base_##CBNAME()
1735 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1736 bool CLASS::CBNAME() { \
1739 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1740 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1741 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1742 wxPyEndBlockThreads(blocked); \
1744 rval = PCLASS::CBNAME(); \
1747 bool CLASS::base_##CBNAME() { \
1748 return PCLASS::CBNAME(); \
1751 //---------------------------------------------------------------------------
1753 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1754 bool CBNAME() const; \
1755 bool base_##CBNAME() const
1758 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1759 bool CLASS::CBNAME() const { \
1762 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1763 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1764 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1765 wxPyEndBlockThreads(blocked); \
1767 rval = PCLASS::CBNAME(); \
1770 bool CLASS::base_##CBNAME() const { \
1771 return PCLASS::CBNAME(); \
1774 //---------------------------------------------------------------------------
1776 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1777 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
1778 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1781 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1782 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1785 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1786 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1787 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1788 wxPyEndBlockThreads(blocked); \
1790 rval = PCLASS::CBNAME(a, b, c); \
1791 return (wxDragResult)rval; \
1793 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1794 return PCLASS::CBNAME(a, b, c); \
1797 //---------------------------------------------------------------------------
1799 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1800 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1802 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1803 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1804 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1806 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1808 PyObject* obj = wxPyMake_wxObject(&a,false); \
1809 PyObject* s = wx2PyString(b); \
1810 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1813 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
1819 wxPyEndBlockThreads(blocked); \
1823 //---------------------------------------------------------------------------
1825 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1826 bool CBNAME(wxDragResult a); \
1827 bool base_##CBNAME(wxDragResult a)
1830 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1831 bool CLASS::CBNAME(wxDragResult a) { \
1834 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1835 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1836 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1837 wxPyEndBlockThreads(blocked); \
1839 rval = PCLASS::CBNAME(a); \
1842 bool CLASS::base_##CBNAME(wxDragResult a) { \
1843 return PCLASS::CBNAME(a); \
1846 //---------------------------------------------------------------------------
1848 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1849 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1852 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1853 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1854 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1856 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1857 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1858 wxPyEndBlockThreads(blocked); \
1859 return (wxDragResult)rval; \
1862 //---------------------------------------------------------------------------
1864 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1865 bool CBNAME(int a, int b, const wxString& c)
1867 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1868 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1870 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1871 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1872 PyObject* s = wx2PyString(c); \
1873 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1876 wxPyEndBlockThreads(blocked); \
1880 //---------------------------------------------------------------------------
1882 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1884 size_t base_##CBNAME()
1887 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1888 size_t CLASS::CBNAME() { \
1891 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1892 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1893 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1894 wxPyEndBlockThreads(blocked); \
1896 rval = PCLASS::CBNAME(); \
1899 size_t CLASS::base_##CBNAME() { \
1900 return PCLASS::CBNAME(); \
1903 //---------------------------------------------------------------------------
1905 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1906 size_t CBNAME() const; \
1907 size_t base_##CBNAME() const
1910 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1911 size_t CLASS::CBNAME() const { \
1914 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1915 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1916 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1917 wxPyEndBlockThreads(blocked); \
1919 rval = PCLASS::CBNAME(); \
1922 size_t CLASS::base_##CBNAME() const { \
1923 return PCLASS::CBNAME(); \
1926 //---------------------------------------------------------------------------
1928 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1929 wxDataFormat CBNAME(size_t a); \
1930 wxDataFormat base_##CBNAME(size_t a)
1933 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1934 wxDataFormat CLASS::CBNAME(size_t a) { \
1935 wxDataFormat rval=0; \
1937 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1938 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1940 wxDataFormat* ptr; \
1941 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1943 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1948 wxPyEndBlockThreads(blocked); \
1950 rval = PCLASS::CBNAME(a); \
1953 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1954 return PCLASS::CBNAME(a); \
1957 //---------------------------------------------------------------------------
1959 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1960 void CBNAME(const Type& a); \
1961 void base_##CBNAME(const Type& a)
1964 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1965 void CLASS::CBNAME(const Type& a) { \
1967 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1968 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1969 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1970 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1973 wxPyEndBlockThreads(blocked); \
1975 PCLASS::CBNAME(a); \
1977 void CLASS::base_##CBNAME(const Type& a) { \
1978 PCLASS::CBNAME(a); \
1982 //---------------------------------------------------------------------------
1984 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1985 void CBNAME(Type& a); \
1986 void base_##CBNAME(Type& a)
1989 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1990 void CLASS::CBNAME(Type& a) { \
1992 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1993 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1994 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1995 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1998 wxPyEndBlockThreads(blocked); \
2000 PCLASS::CBNAME(a); \
2002 void CLASS::base_##CBNAME(Type& a) { \
2003 PCLASS::CBNAME(a); \
2006 //---------------------------------------------------------------------------
2008 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
2009 bool CBNAME(Type& a); \
2010 bool base_##CBNAME(Type& a)
2013 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
2014 bool CLASS::CBNAME(Type& a) { \
2017 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2018 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2019 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2020 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2023 wxPyEndBlockThreads(blocked); \
2025 rv = PCLASS::CBNAME(a); \
2028 bool CLASS::base_##CBNAME(Type& a) { \
2029 return PCLASS::CBNAME(a); \
2032 //---------------------------------------------------------------------------
2034 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
2035 bool CBNAME(Type& a)
2038 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
2039 bool CLASS::CBNAME(Type& a) { \
2041 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2042 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2043 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2044 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2047 wxPyEndBlockThreads(blocked); \
2051 //---------------------------------------------------------------------------
2053 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
2054 wxString CBNAME(long a, long b) const; \
2055 wxString base_##CBNAME(long a, long b) const
2057 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
2058 wxString CLASS::CBNAME(long a, long b) const { \
2061 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2062 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2064 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2066 rval = Py2wxString(ro); \
2070 wxPyEndBlockThreads(blocked); \
2072 rval = PCLASS::CBNAME(a,b); \
2075 wxString CLASS::base_##CBNAME(long a, long b) const { \
2076 return PCLASS::CBNAME(a,b); \
2079 //---------------------------------------------------------------------------
2081 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
2082 int CBNAME(long a) const; \
2083 int base_##CBNAME(long a) const
2086 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
2087 int CLASS::CBNAME(long a) const { \
2090 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2091 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2093 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2095 rval = PyInt_AsLong(ro); \
2099 wxPyEndBlockThreads(blocked); \
2101 rval = PCLASS::CBNAME(a); \
2104 int CLASS::base_##CBNAME(long a) const { \
2105 return PCLASS::CBNAME(a); \
2111 #define DEC_PYCALLBACK_INT_LONG_virtual(CBNAME) \
2112 int CBNAME(long a) const;
2115 #define IMP_PYCALLBACK_INT_LONG_virtual(CLASS, PCLASS, CBNAME) \
2116 int CLASS::CBNAME(long a) const { \
2117 int rval=-1; /* this rval is important for OnGetItemImage */ \
2119 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2120 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2122 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2124 rval = PyInt_AsLong(ro); \
2128 wxPyEndBlockThreads(blocked); \
2133 //---------------------------------------------------------------------------
2135 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2136 wxListItemAttr* CBNAME(long a) const; \
2137 wxListItemAttr* base_##CBNAME(long a) const
2140 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2141 wxListItemAttr *CLASS::CBNAME(long a) const { \
2142 wxListItemAttr *rval = NULL; \
2144 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2145 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2147 wxListItemAttr* ptr; \
2148 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2150 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2155 wxPyEndBlockThreads(blocked); \
2157 rval = PCLASS::CBNAME(a); \
2160 wxListItemAttr *CLASS::base_##CBNAME(long a) const { \
2161 return PCLASS::CBNAME(a); \
2164 //---------------------------------------------------------------------------
2166 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2167 bool CBNAME(wxMouseEvent& e); \
2168 bool base_##CBNAME(wxMouseEvent& e)
2170 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2171 bool CLASS::CBNAME(wxMouseEvent& e) { \
2174 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2175 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2177 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2178 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2180 rval = PyInt_AsLong(ro); \
2185 wxPyEndBlockThreads(blocked); \
2187 return PCLASS::CBNAME(e); \
2190 bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
2191 return PCLASS::CBNAME(e); \
2195 //---------------------------------------------------------------------------
2197 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2198 wxWizardPage* CBNAME() const
2200 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2201 wxWizardPage* CLASS::CBNAME() const { \
2202 wxWizardPage* rv = NULL; \
2203 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2204 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2206 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2208 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2212 wxPyEndBlockThreads(blocked); \
2216 //---------------------------------------------------------------------------
2218 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2219 wxBitmap CBNAME() const
2221 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2222 wxBitmap CLASS::CBNAME() const { \
2224 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2225 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2228 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2230 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2235 wxPyEndBlockThreads(blocked); \
2239 //---------------------------------------------------------------------------
2241 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2244 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2245 wxObject* CLASS::CBNAME() { \
2246 wxObject* rv = NULL; \
2247 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2248 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2250 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2252 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2256 wxPyEndBlockThreads(blocked); \
2260 //---------------------------------------------------------------------------
2262 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2263 wxObject* CBNAME(const wxString& a)
2265 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2266 wxObject* CLASS::CBNAME(const wxString& a) { \
2267 wxObject* rv = NULL; \
2268 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2269 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2270 PyObject* so = wx2PyString(a); \
2272 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2274 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2279 wxPyEndBlockThreads(blocked); \
2283 //---------------------------------------------------------------------------
2285 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2286 bool CBNAME(wxXmlNode* a)
2289 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2290 bool CLASS::CBNAME(wxXmlNode* a) { \
2292 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2293 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2294 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2295 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2298 wxPyEndBlockThreads(blocked); \
2302 //---------------------------------------------------------------------------
2304 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2305 wxCoord CBNAME(size_t a) const
2308 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2309 wxCoord CLASS::CBNAME(size_t a) const { \
2312 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2313 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2314 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2316 wxPyEndBlockThreads(blocked); \
2320 //---------------------------------------------------------------------------
2322 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2323 void CBNAME(size_t a, size_t b) const; \
2324 void base_##CBNAME(size_t a, size_t b) const
2327 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2328 void CLASS::CBNAME(size_t a, size_t b) const { \
2330 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2331 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2332 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2333 wxPyEndBlockThreads(blocked); \
2335 PCLASS::CBNAME(a,b); \
2337 void CLASS::base_##CBNAME(size_t a, size_t b) const { \
2338 PCLASS::CBNAME(a,b); \
2341 //---------------------------------------------------------------------------
2343 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2344 wxCoord CBNAME() const; \
2345 wxCoord base_##CBNAME() const
2348 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2349 wxCoord CLASS::CBNAME() const { \
2352 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2353 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2354 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2355 wxPyEndBlockThreads(blocked); \
2357 rval = PCLASS::CBNAME(); \
2360 wxCoord CLASS::base_##CBNAME() const { \
2361 return PCLASS::CBNAME(); \
2364 //---------------------------------------------------------------------------
2366 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2367 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2370 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2371 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2373 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2374 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2375 PyObject* obj = wxPyMake_wxObject(&a,false); \
2376 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2377 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2380 wxPyEndBlockThreads(blocked); \
2383 //---------------------------------------------------------------------------
2385 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2386 void CBNAME(wxDC& a, const wxRect& b, size_t c) const; \
2387 void base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const
2390 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2391 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2393 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2394 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2395 PyObject* obj = wxPyMake_wxObject(&a,false); \
2396 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2397 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2400 wxPyEndBlockThreads(blocked); \
2402 PCLASS::CBNAME(a,b,c); \
2404 void CLASS::base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2405 PCLASS::CBNAME(a,b,c); \
2408 //---------------------------------------------------------------------------
2411 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2412 wxString CBNAME(size_t a) const; \
2413 wxString base_##CBNAME(size_t a) const
2415 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2416 wxString CLASS::CBNAME(size_t a) const { \
2419 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2420 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2422 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2424 rval = Py2wxString(ro); \
2428 wxPyEndBlockThreads(blocked); \
2430 rval = PCLASS::CBNAME(a); \
2433 wxString CLASS::base_##CBNAME(size_t a) const { \
2434 return PCLASS::CBNAME(a); \
2437 //---------------------------------------------------------------------------
2439 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2440 wxString CBNAME(size_t a) const
2442 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2443 wxString CLASS::CBNAME(size_t a) const { \
2446 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2447 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2449 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2451 rval = Py2wxString(ro); \
2455 wxPyEndBlockThreads(blocked); \
2459 //---------------------------------------------------------------------------
2461 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2462 wxVisualAttributes CBNAME() const; \
2463 wxVisualAttributes base_##CBNAME()
2466 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2467 wxVisualAttributes CLASS::CBNAME() const { \
2468 wxVisualAttributes rval; \
2470 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2471 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2473 wxVisualAttributes* ptr; \
2474 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2476 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2481 wxPyEndBlockThreads(blocked); \
2483 rval = PCLASS::CBNAME(); \
2486 wxVisualAttributes CLASS::base_##CBNAME() { \
2487 return PCLASS::CBNAME(); \
2490 //---------------------------------------------------------------------------