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/toolbook.h>
68 #include <wx/tooltip.h>
69 #include <wx/treebook.h>
71 #include <wx/vscroll.h>
72 #include <wx/dateevt.h>
73 #include <wx/datectrl.h>
78 # pragma warning(disable:4800)
79 # pragma warning(disable:4190)
82 #ifdef __WXMAC__ // avoid a bug in Carbon headers
86 //---------------------------------------------------------------------------
88 typedef unsigned char byte
;
89 typedef wxPoint2DDouble wxPoint2D
;
91 #ifndef SWIG_TYPE_TABLE
92 #define SWIG_TYPE_TABLE wxPython_type_table
96 #define wxDEFAULT_STATUSBAR_STYLE wxST_SIZEGRIP|wxFULL_REPAINT_ON_RESIZE
98 #define wxDEFAULT_STATUSBAR_STYLE wxST_SIZEGRIP
102 #ifndef wxPyUSE_EXPORTED_API
104 void __wxPyPreStart(PyObject
*);
105 void __wxPyCleanup();
106 PyObject
* __wxPySetDictionary(PyObject
*, PyObject
* args
);
108 void wxSetDefaultPyEncoding(const char* encoding
);
109 const char* wxGetDefaultPyEncoding();
112 void wxPyEventThunker(wxObject
*, wxEvent
& event
);
115 bool wxPyCheckSwigType(const wxChar
* className
);
116 PyObject
* wxPyConstructObject(void* ptr
,
117 const wxChar
* className
,
119 bool wxPyConvertSwigPtr(PyObject
* obj
, void **ptr
,
120 const wxChar
* className
);
121 PyObject
* wxPyMakeSwigPtr(void* ptr
, const wxChar
* classname
);
124 PyObject
* wx2PyString(const wxString
& src
);
125 wxString
Py2wxString(PyObject
* source
);
127 PyObject
* wxPyMake_wxObject(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
=true);
128 PyObject
* wxPyMake_wxSizer(wxSizer
* source
, bool setThisOwn
);
129 void wxPyPtrTypeMap_Add(const char* commonName
, const char* ptrName
);
131 PyObject
* wxPy_ConvertList(wxListBase
* list
);
132 long wxPyGetWinHandle(wxWindow
* win
);
134 void wxPy_ReinitStockObjects(int pass
);
136 bool wxPyInstance_Check(PyObject
* obj
);
137 bool wxPySwigInstance_Check(PyObject
* obj
);
140 #endif // wxPyUSE_EXPORTED_API
141 //---------------------------------------------------------------------------
143 // if we want to handle threads and Python threads are available...
144 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
145 #define WXP_WITH_THREAD
146 #else // no Python threads...
147 #undef WXP_WITH_THREAD
151 // In Python 2.3 and later there are the PyGILState_* APIs that we can use for
152 // blocking threads when calling back into Python. Using them instead of my
153 // home-grown hacks greatly simplifies wxPyBeginBlockThreads and
154 // wxPyEndBlockThreads.
156 // Unfortunatly there is a bug somewhere when using these new APIs on Python
157 // 2.3. It manifests in Boa Constructor's debugger where it is unable to stop
158 // at breakpoints located in event handlers. I think that the cause may be
159 // something like the original PyThreadState for the main thread is not being
160 // restored for the callbacks, but I can't see where that could be
161 // happening... So we'll only activate this new change for Python 2.4+ :-(
163 #if PY_VERSION_HEX < 0x02040000
164 #define wxPyUSE_GIL_STATE 0
165 typedef bool wxPyBlock_t
;
167 #define wxPyUSE_GIL_STATE 1
168 typedef PyGILState_STATE wxPyBlock_t
;
172 #ifndef wxPyUSE_EXPORTED_API
174 // For Python --> C++
175 PyThreadState
* wxPyBeginAllowThreads();
176 void wxPyEndAllowThreads(PyThreadState
* state
);
178 // For C++ --> Python
179 wxPyBlock_t
wxPyBeginBlockThreads();
180 void wxPyEndBlockThreads(wxPyBlock_t blocked
);
182 #endif // wxPyUSE_EXPORTED_API
185 // A macro that will help to execute simple statments wrapped in
186 // StartBlock/EndBlockThreads calls
187 #define wxPyBLOCK_THREADS(stmt) \
188 { wxPyBlock_t blocked = wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads(blocked); }
190 // Raise the NotImplementedError exception (blocking threads)
191 #define wxPyRaiseNotImplemented() \
192 wxPyBLOCK_THREADS(PyErr_SetNone(PyExc_NotImplementedError))
194 // Raise any exception with a string value (blocking threads)
195 #define wxPyErr_SetString(err, str) \
196 wxPyBLOCK_THREADS(PyErr_SetString(err, str))
199 //---------------------------------------------------------------------------
200 // These are helpers used by the typemaps
202 #ifndef wxPyUSE_EXPORTED_API
204 wxString
* wxString_in_helper(PyObject
* source
);
206 byte
* byte_LIST_helper(PyObject
* source
);
207 int* int_LIST_helper(PyObject
* source
);
208 long* long_LIST_helper(PyObject
* source
);
209 char** string_LIST_helper(PyObject
* source
);
210 wxPoint
* wxPoint_LIST_helper(PyObject
* source
, int* npoints
);
211 wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
212 wxString
* wxString_LIST_helper(PyObject
* source
);
213 wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
214 wxPen
** wxPen_LIST_helper(PyObject
* source
);
216 bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
217 bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
218 bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
219 bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
220 bool wxColour_helper(PyObject
* source
, wxColour
** obj
);
221 bool wxPoint2D_helper(PyObject
* source
, wxPoint2D
** obj
);
224 bool wxPySimple_typecheck(PyObject
* source
, const wxChar
* classname
, int seqLen
);
225 bool wxColour_typecheck(PyObject
* source
);
227 bool wxPyCheckForApp();
231 bool wxPyTwoIntItem_helper(PyObject
* source
, T
** obj
, const wxChar
* name
)
233 // If source is an object instance then it may already be the right type
234 if (wxPySwigInstance_Check(source
)) {
236 if (! wxPyConvertSwigPtr(source
, (void **)&ptr
, name
))
241 // otherwise a 2-tuple of integers is expected
242 else if (PySequence_Check(source
) && PyObject_Length(source
) == 2) {
243 PyObject
* o1
= PySequence_GetItem(source
, 0);
244 PyObject
* o2
= PySequence_GetItem(source
, 1);
245 if (!PyNumber_Check(o1
) || !PyNumber_Check(o2
)) {
250 **obj
= T(PyInt_AsLong(o1
), PyInt_AsLong(o2
));
258 msg
.Printf(wxT("Expected a 2-tuple of integers or a %s object."), name
);
259 PyErr_SetString(PyExc_TypeError
, msg
.mb_str());
265 // Other helpful stuff
266 bool wxPy2int_seq_helper(PyObject
* source
, int* i1
, int* i2
);
267 bool wxPy4int_seq_helper(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
269 PyObject
* wxArrayString2PyList_helper(const wxArrayString
& arr
);
270 PyObject
* wxArrayInt2PyList_helper(const wxArrayInt
& arr
);
272 #endif // wxPyUSE_EXPORTED_API
274 //---------------------------------------------------------------------------
276 #if PYTHON_API_VERSION < 1009
277 #define PySequence_Fast_GET_ITEM(o, i) \
278 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
281 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
282 #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name)
283 #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val)
285 //---------------------------------------------------------------------------
287 #ifndef wxPyUSE_EXPORTED_API
289 class wxPyCallback
: public wxObject
{
290 DECLARE_ABSTRACT_CLASS(wxPyCallback
)
292 wxPyCallback(PyObject
* func
);
293 wxPyCallback(const wxPyCallback
& other
);
296 void EventThunker(wxEvent
& event
);
301 #endif // wxPyUSE_EXPORTED_API
302 //---------------------------------------------------------------------------
303 //---------------------------------------------------------------------------
304 // These Event classes can be derived from in Python and passed through the
305 // event system without loosing anything. They do this by keeping a reference
306 // to themselves and some special case handling in wxPyCallback::EventThunker.
310 class wxPyEvtSelfRef
{
315 void SetSelf(PyObject
* self
, bool clone
=false);
316 PyObject
* GetSelf() const;
317 bool GetCloned() const { return m_cloned
; }
325 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
326 DECLARE_ABSTRACT_CLASS(wxPyEvent
)
328 wxPyEvent(int winid
=0, wxEventType commandType
= wxEVT_NULL
);
329 wxPyEvent(const wxPyEvent
& evt
);
332 virtual wxEvent
* Clone() const { return new wxPyEvent(*this); }
336 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
337 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent
)
339 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
340 wxPyCommandEvent(const wxPyCommandEvent
& evt
);
343 virtual wxEvent
* Clone() const { return new wxPyCommandEvent(*this); }
348 //----------------------------------------------------------------------
349 // Forward decalre a few things used in the exported API
350 class wxPyClientData
;
352 class wxPyOORClientData
;
353 class wxPyCBInputStream
;
355 void wxPyClientData_dtor(wxPyClientData
* self
);
356 void wxPyUserData_dtor(wxPyUserData
* self
);
357 void wxPyOORClientData_dtor(wxPyOORClientData
* self
);
358 wxPyCBInputStream
* wxPyCBInputStream_create(PyObject
*py
, bool block
);
359 wxPyCBInputStream
* wxPyCBInputStream_copy(wxPyCBInputStream
* other
);
361 //---------------------------------------------------------------------------
362 // Export a C API in a struct. Other modules will be able to load this from
363 // the wx.core module and will then have safe access to these functions, even if
364 // in another shared library.
366 class wxPyCallbackHelper
;
370 bool (*p_wxPyCheckSwigType
)(const wxChar
* className
);
371 PyObject
* (*p_wxPyConstructObject
)(void* ptr
, const wxChar
* className
, int setThisOwn
);
372 bool (*p_wxPyConvertSwigPtr
)(PyObject
* obj
, void **ptr
, const wxChar
* className
);
373 PyObject
* (*p_wxPyMakeSwigPtr
)(void* ptr
, const wxChar
* className
);
375 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
376 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
377 wxPyBlock_t (*p_wxPyBeginBlockThreads
)();
378 void (*p_wxPyEndBlockThreads
)(wxPyBlock_t blocked
);
380 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
);
382 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
383 wxString (*p_Py2wxString
)(PyObject
* source
);
384 PyObject
* (*p_wx2PyString
)(const wxString
& src
);
386 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
387 int* (*p_int_LIST_helper
)(PyObject
* source
);
388 long* (*p_long_LIST_helper
)(PyObject
* source
);
389 char** (*p_string_LIST_helper
)(PyObject
* source
);
390 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
391 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
392 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
393 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
395 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
396 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
397 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
398 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
399 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
400 bool (*p_wxPoint2D_helper
)(PyObject
* source
, wxPoint2DDouble
** obj
);
403 bool (*p_wxPySimple_typecheck
)(PyObject
* source
, const wxChar
* classname
, int seqLen
);
404 bool (*p_wxColour_typecheck
)(PyObject
* source
);
406 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
407 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
);
408 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
409 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
410 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
412 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
);
413 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
, bool setThisOwn
);
414 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
415 bool (*p_wxPy2int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
);
416 bool (*p_wxPy4int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
417 PyObject
* (*p_wxArrayString2PyList_helper
)(const wxArrayString
& arr
);
418 PyObject
* (*p_wxArrayInt2PyList_helper
)(const wxArrayInt
& arr
);
420 void (*p_wxPyClientData_dtor
)(wxPyClientData
*);
421 void (*p_wxPyUserData_dtor
)(wxPyUserData
*);
422 void (*p_wxPyOORClientData_dtor
)(wxPyOORClientData
*);
424 wxPyCBInputStream
* (*p_wxPyCBInputStream_create
)(PyObject
*py
, bool block
);
425 wxPyCBInputStream
* (*p_wxPyCBInputStream_copy
)(wxPyCBInputStream
* other
);
427 bool (*p_wxPyInstance_Check
)(PyObject
* obj
);
428 bool (*p_wxPySwigInstance_Check
)(PyObject
* obj
);
430 bool (*p_wxPyCheckForApp
)();
434 #ifdef wxPyUSE_EXPORTED_API
435 // Notice that this is static, not extern. This is by design, each module
436 // needs one, but doesn't have to use it.
437 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
;
438 inline wxPyCoreAPI
* wxPyGetCoreAPIPtr();
439 #endif // wxPyUSE_EXPORTED_API
441 //---------------------------------------------------------------------------
443 // A wxObject that holds a reference to a Python object
444 class wxPyUserData
: public wxObject
{
446 wxPyUserData(PyObject
* obj
) {
452 #ifdef wxPyUSE_EXPORTED_API
453 wxPyGetCoreAPIPtr()->p_wxPyUserData_dtor(this);
455 wxPyUserData_dtor(this);
462 // A wxClientData that holds a refernece to a Python object
463 class wxPyClientData
: public wxClientData
{
465 wxPyClientData(PyObject
* obj
, bool incref
=true) {
473 #ifdef wxPyUSE_EXPORTED_API
474 wxPyGetCoreAPIPtr()->p_wxPyClientData_dtor(this);
476 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
, bool incref
=true)
489 : wxPyClientData(obj
, incref
) {}
490 ~wxPyOORClientData() {
492 #ifdef wxPyUSE_EXPORTED_API
493 wxPyGetCoreAPIPtr()->p_wxPyOORClientData_dtor(this);
495 wxPyOORClientData_dtor(this);
501 //---------------------------------------------------------------------------
502 // A wxImageHandler that can be derived from in Python.
505 class wxPyImageHandler
: public wxImageHandler
{
509 // used for interning method names as PyStrings
510 static PyObject
* m_DoCanRead_Name
;
511 static PyObject
* m_GetImageCount_Name
;
512 static PyObject
* m_LoadFile_Name
;
513 static PyObject
* m_SaveFile_Name
;
515 // converstion helpers
516 PyObject
* py_InputStream(wxInputStream
* stream
);
517 PyObject
* py_Image(wxImage
* image
);
518 PyObject
* py_OutputStream(wxOutputStream
* stream
);
523 void _SetSelf(PyObject
*self
);
525 virtual bool LoadFile(wxImage
* image
, wxInputStream
& stream
,
526 bool verbose
=true, int index
=-1 );
527 virtual bool SaveFile(wxImage
* image
, wxOutputStream
& stream
,
529 virtual int GetImageCount(wxInputStream
& stream
);
530 virtual bool DoCanRead(wxInputStream
&stream
);
534 //---------------------------------------------------------------------------
535 // This class holds an instance of a Python Shadow Class object and assists
536 // with looking up and invoking Python callback methods from C++ virtual
537 // method redirections. For all classes which have virtuals which should be
538 // overridable in wxPython, a new subclass is created that contains a
539 // wxPyCallbackHelper.
542 class wxPyCallbackHelper
{
544 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
546 wxPyCallbackHelper() {
553 ~wxPyCallbackHelper() {
554 #ifdef wxPyUSE_EXPORTED_API
555 wxPyGetCoreAPIPtr()->p_wxPyCBH_delete(this);
557 wxPyCBH_delete(this);
561 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=true);
562 bool findCallback(const char* name
, bool setGuard
=true) const;
563 int callCallback(PyObject
* argTuple
) const;
564 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
565 PyObject
* GetLastFound() const { return m_lastFound
; }
567 void setRecursionGuard(PyObject
* method
) const;
568 void clearRecursionGuard(PyObject
* method
) const;
573 PyObject
* m_lastFound
;
576 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
580 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
581 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
=true);
582 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
583 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
584 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
589 //---------------------------------------------------------------------------
591 // This is used in C++ classes that need to be able to make callback to
592 // "overloaded" python methods
595 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
596 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
598 private: wxPyCallbackHelper m_myInst
601 //---------------------------------------------------------------------------
602 // The wxPythonApp class
605 wxPYAPP_ASSERT_SUPPRESS
= 1,
606 wxPYAPP_ASSERT_EXCEPTION
= 2,
607 wxPYAPP_ASSERT_DIALOG
= 4,
608 wxPYAPP_ASSERT_LOG
= 8
611 class wxPyApp
: public wxApp
613 DECLARE_ABSTRACT_CLASS(wxPyApp
)
621 int GetAssertMode() { return m_assertMode
; }
622 void SetAssertMode(int mode
) { m_assertMode
= mode
; }
624 virtual bool OnInitGui();
625 virtual int OnExit();
627 virtual void OnAssert(const wxChar
*file
,
632 virtual void ExitMainLoop();
633 // virtual int FilterEvent(wxEvent& event); // This one too????
635 // For catching Apple Events
636 virtual void MacOpenFile(const wxString
&fileName
);
637 virtual void MacPrintFile(const wxString
&fileName
);
638 virtual void MacNewFile();
639 virtual void MacReopenApp();
641 static bool GetMacSupportPCMenuShortcuts();
642 static long GetMacAboutMenuItemId();
643 static long GetMacPreferencesMenuItemId();
644 static long GetMacExitMenuItemId();
645 static wxString
GetMacHelpMenuTitleName();
647 static void SetMacSupportPCMenuShortcuts(bool val
);
648 static void SetMacAboutMenuItemId(long val
);
649 static void SetMacPreferencesMenuItemId(long val
);
650 static void SetMacExitMenuItemId(long val
);
651 static void SetMacHelpMenuTitleName(const wxString
& val
);
654 void _BootstrapApp();
656 // implementation only
657 void SetStartupComplete(bool val
) { m_startupComplete
= val
; };
661 bool m_startupComplete
;
664 extern wxPyApp
*wxPythonApp
;
667 //----------------------------------------------------------------------
668 // These macros are used to implement the virtual methods that should
669 // redirect to a Python method if one exists. The names designate the
670 // return type, if any, as well as any parameter types.
671 //---------------------------------------------------------------------------
673 #define DEC_PYCALLBACK__(CBNAME) \
677 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
678 void CLASS::CBNAME() { \
680 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
681 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
682 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
683 wxPyEndBlockThreads(blocked); \
688 #define DEC_PYCALLBACK_VOID_(CBNAME) \
689 DEC_PYCALLBACK__(CBNAME)
691 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
692 IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME)
694 //---------------------------------------------------------------------------
696 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
697 bool CBNAME(int a, int b)
700 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
701 bool CLASS::CBNAME(int a, int b) { \
702 bool rval=false, found; \
703 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
704 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
705 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
706 wxPyEndBlockThreads(blocked); \
708 rval = PCLASS::CBNAME(a,b); \
712 //---------------------------------------------------------------------------
714 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
715 void CBNAME(int a, int b)
718 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
719 void CLASS::CBNAME(int a, int b) { \
721 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
722 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
723 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
724 wxPyEndBlockThreads(blocked); \
726 PCLASS::CBNAME(a,b); \
729 //---------------------------------------------------------------------------
731 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
735 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
736 void CLASS::CBNAME(int a) { \
738 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
739 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
740 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
741 wxPyEndBlockThreads(blocked); \
746 //---------------------------------------------------------------------------
748 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
749 void CBNAME(int a, int b, int c, int d)
752 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
753 void CLASS::CBNAME(int a, int b, int c, int d) { \
755 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
756 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
757 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
758 wxPyEndBlockThreads(blocked); \
760 PCLASS::CBNAME(a,b,c,d); \
763 //---------------------------------------------------------------------------
764 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
765 void CBNAME(int a, int b, int c, int d, int e)
768 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
769 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
771 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
772 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
773 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
774 wxPyEndBlockThreads(blocked); \
776 PCLASS::CBNAME(a,b,c,d,e); \
779 //---------------------------------------------------------------------------
781 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
782 void CBNAME(int* a, int* b) const
785 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
786 void CLASS::CBNAME(int* a, int* b) const { \
787 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
789 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
790 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
792 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
794 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
795 PyObject* o1 = PySequence_GetItem(ro, 0); \
796 PyObject* o2 = PySequence_GetItem(ro, 1); \
797 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
798 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
801 PyErr_SetString(PyExc_TypeError, errmsg); \
806 PyErr_SetString(PyExc_TypeError, errmsg); \
811 wxPyEndBlockThreads(blocked); \
813 PCLASS::CBNAME(a,b); \
816 //---------------------------------------------------------------------------
818 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
819 wxSize CBNAME() const
822 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
823 wxSize CLASS::CBNAME() const { \
824 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
825 bool found; wxSize rval(0,0); \
826 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
827 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
829 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
831 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
832 PyObject* o1 = PySequence_GetItem(ro, 0); \
833 PyObject* o2 = PySequence_GetItem(ro, 1); \
834 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
835 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
838 PyErr_SetString(PyExc_TypeError, errmsg); \
843 PyErr_SetString(PyExc_TypeError, errmsg); \
848 wxPyEndBlockThreads(blocked); \
850 return PCLASS::CBNAME(); \
855 //---------------------------------------------------------------------------
857 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
861 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
862 bool CLASS::CBNAME(bool a) { \
863 bool rval=false, found; \
864 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
865 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
866 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
867 wxPyEndBlockThreads(blocked); \
869 rval = PCLASS::CBNAME(a); \
873 //---------------------------------------------------------------------------
875 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
879 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
880 bool CLASS::CBNAME(int a) { \
881 bool rval=false, found; \
882 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
883 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
884 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
885 wxPyEndBlockThreads(blocked); \
887 rval = PCLASS::CBNAME(a); \
891 //---------------------------------------------------------------------------
893 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
897 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
898 bool CLASS::CBNAME(int a) { \
900 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
901 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
902 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
904 wxPyEndBlockThreads(blocked); \
909 //---------------------------------------------------------------------------
911 #define DEC_PYCALLBACK__DC(CBNAME) \
915 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
916 void CLASS::CBNAME(wxDC& a) { \
918 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
919 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
920 PyObject* obj = wxPyMake_wxObject(&a,false); \
921 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
924 wxPyEndBlockThreads(blocked); \
930 //---------------------------------------------------------------------------
932 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
933 void CBNAME(wxDC& a, bool b)
936 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
937 void CLASS::CBNAME(wxDC& a, bool b) { \
939 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
940 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
941 PyObject* obj = wxPyMake_wxObject(&a,false); \
942 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
945 wxPyEndBlockThreads(blocked); \
947 PCLASS::CBNAME(a, b); \
950 //---------------------------------------------------------------------------
952 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
953 void CBNAME(wxDC& a, bool b)
956 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
957 void CLASS::CBNAME(wxDC& a, bool b) { \
959 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
960 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
961 PyObject* obj = wxPyMake_wxObject(&a,false); \
962 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
965 wxPyEndBlockThreads(blocked); \
967 PCLASS::CBNAME(a, b); \
970 //---------------------------------------------------------------------------
972 #define DEC_PYCALLBACK__2DBL(CBNAME) \
973 void CBNAME(double a, double b)
976 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
977 void CLASS::CBNAME(double a, double b) { \
979 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
980 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
981 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
982 wxPyEndBlockThreads(blocked); \
984 PCLASS::CBNAME(a, b); \
987 //---------------------------------------------------------------------------
989 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
990 void CBNAME(double a, double b, int c, int d)
993 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
994 void CLASS::CBNAME(double a, double b, int c, int d) { \
996 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
997 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
998 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
1000 wxPyEndBlockThreads(blocked); \
1002 PCLASS::CBNAME(a, b, c, d); \
1005 //---------------------------------------------------------------------------
1007 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
1008 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1011 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1012 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1014 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1015 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1016 PyObject* obj = wxPyMake_wxObject(&a,false); \
1017 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
1020 wxPyEndBlockThreads(blocked); \
1022 PCLASS::CBNAME(a, b, c, d, e, f); \
1025 //---------------------------------------------------------------------------
1027 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
1028 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1031 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1032 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1034 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1036 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1037 PyObject* obj = wxPyMake_wxObject(&a,false); \
1038 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1041 wxPyEndBlockThreads(blocked); \
1043 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1047 //---------------------------------------------------------------------------
1049 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1050 void CBNAME(bool a, double b, double c, int d, int e)
1053 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1054 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1056 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1057 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1058 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1060 wxPyEndBlockThreads(blocked); \
1062 PCLASS::CBNAME(a, b, c, d, e); \
1065 //---------------------------------------------------------------------------
1067 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1068 void CBNAME(wxDC& a, double b, double c, double d, double e)
1071 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1072 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1074 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1075 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1076 PyObject* obj = wxPyMake_wxObject(&a,false); \
1077 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1080 wxPyEndBlockThreads(blocked); \
1082 PCLASS::CBNAME(a, b, c, d, e); \
1085 //---------------------------------------------------------------------------
1087 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1088 void CBNAME(wxDC& a, bool b)
1091 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1092 void CLASS::CBNAME(wxDC& a, bool b) { \
1094 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1095 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1096 PyObject* obj = wxPyMake_wxObject(&a,false); \
1097 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1100 wxPyEndBlockThreads(blocked); \
1102 PCLASS::CBNAME(a, b); \
1105 //---------------------------------------------------------------------------
1107 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1108 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1111 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1112 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1115 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1116 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1117 PyObject* obj = wxPyMake_wxObject(a,false); \
1118 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1121 wxPyEndBlockThreads(blocked); \
1123 PCLASS::CBNAME(a, b, c, d, e, f); \
1126 //---------------------------------------------------------------------------
1128 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1129 void CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1132 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1133 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1135 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1136 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1137 PyObject* obj = wxPyMake_wxObject(a,false); \
1138 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1141 wxPyEndBlockThreads(blocked); \
1143 PCLASS::CBNAME(a, b, c, d, e); \
1146 //---------------------------------------------------------------------------
1148 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1149 void CBNAME(double a, double b, int c)
1152 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1153 void CLASS::CBNAME(double a, double b, int c) { \
1155 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1156 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1157 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1158 wxPyEndBlockThreads(blocked); \
1160 PCLASS::CBNAME(a, b, c); \
1163 //---------------------------------------------------------------------------
1165 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1166 void CBNAME(bool a, double b, double c, int d)
1169 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1170 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1172 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1173 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1174 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1175 wxPyEndBlockThreads(blocked); \
1177 PCLASS::CBNAME(a, b, c, d); \
1180 //---------------------------------------------------------------------------
1181 //---------------------------------------------------------------------------
1183 #define DEC_PYCALLBACK__STRING(CBNAME) \
1184 void CBNAME(const wxString& a)
1186 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1187 void CLASS::CBNAME(const wxString& a) { \
1189 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1190 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1191 PyObject* s = wx2PyString(a); \
1192 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1195 wxPyEndBlockThreads(blocked); \
1197 PCLASS::CBNAME(a); \
1200 //---------------------------------------------------------------------------
1202 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1203 bool CBNAME(const wxString& a)
1205 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1206 bool CLASS::CBNAME(const wxString& a) { \
1209 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1210 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1211 PyObject* s = wx2PyString(a); \
1212 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1215 wxPyEndBlockThreads(blocked); \
1217 rval = PCLASS::CBNAME(a); \
1221 //---------------------------------------------------------------------------
1223 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1224 bool CBNAME(const wxString& a)
1226 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1227 bool CLASS::CBNAME(const wxString& a) { \
1229 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1230 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1231 PyObject* s = wx2PyString(a); \
1232 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1235 wxPyEndBlockThreads(blocked); \
1239 //---------------------------------------------------------------------------
1241 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1242 wxString CBNAME(const wxString& a)
1244 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1245 wxString CLASS::CBNAME(const wxString& a) { \
1247 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1248 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1250 PyObject* s = wx2PyString(a); \
1251 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1254 rval = Py2wxString(ro); \
1258 wxPyEndBlockThreads(blocked); \
1262 //---------------------------------------------------------------------------
1264 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1265 wxString CBNAME(const wxString& a)
1267 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1268 wxString CLASS::CBNAME(const wxString& a) { \
1271 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1272 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1274 PyObject* s = wx2PyString(a); \
1275 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1278 rval = Py2wxString(ro); \
1283 rval = PCLASS::CBNAME(a); \
1284 wxPyEndBlockThreads(blocked); \
1288 //---------------------------------------------------------------------------
1290 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1291 wxString CBNAME(const wxString& a,int b)
1293 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1294 wxString CLASS::CBNAME(const wxString& a,int b) { \
1296 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1297 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1299 PyObject* s = wx2PyString(a); \
1300 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1303 rval = Py2wxString(ro); \
1307 wxPyEndBlockThreads(blocked); \
1311 //---------------------------------------------------------------------------
1313 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1314 bool CBNAME(const wxString& a, const wxString& b)
1316 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1317 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1320 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1321 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1322 PyObject* s1 = wx2PyString(a); \
1323 PyObject* s2 = wx2PyString(b); \
1324 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1328 wxPyEndBlockThreads(blocked); \
1330 rval = PCLASS::CBNAME(a, b); \
1334 //---------------------------------------------------------------------------
1336 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1339 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1340 wxString CLASS::CBNAME() { \
1343 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1344 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1346 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1348 rval = Py2wxString(ro); \
1352 wxPyEndBlockThreads(blocked); \
1354 rval = PCLASS::CBNAME(); \
1358 //---------------------------------------------------------------------------
1360 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1361 wxString CBNAME() const
1363 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1364 wxString CLASS::CBNAME() const { \
1367 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1368 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1370 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1372 rval = Py2wxString(ro); \
1376 wxPyEndBlockThreads(blocked); \
1378 rval = PCLASS::CBNAME(); \
1382 //---------------------------------------------------------------------------
1384 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1387 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1388 wxString CLASS::CBNAME() { \
1390 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1391 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1393 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1395 rval = Py2wxString(ro); \
1399 wxPyEndBlockThreads(blocked); \
1403 //---------------------------------------------------------------------------
1405 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1406 wxString CBNAME() const;
1408 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1409 wxString CLASS::CBNAME() const { \
1411 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1412 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1414 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1416 rval = Py2wxString(ro); \
1420 wxPyEndBlockThreads(blocked); \
1424 //---------------------------------------------------------------------------
1426 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1427 bool CBNAME(const wxHtmlTag& a)
1430 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1431 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1433 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1434 if (wxPyCBH_findCallback2(m_myInst, #CBNAME, false)) { \
1435 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
1436 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1439 wxPyEndBlockThreads(blocked); \
1443 //---------------------------------------------------------------------------
1445 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1446 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1448 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1449 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1451 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1452 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1453 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1454 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1457 wxPyEndBlockThreads(blocked); \
1459 PCLASS::CBNAME(cell, x, y); \
1462 //---------------------------------------------------------------------------
1464 #define DEC_PYCALLBACK__COLOUR(CBNAME) \
1465 void CBNAME(const wxColour& c);
1467 #define IMP_PYCALLBACK__COLOUR(CLASS, PCLASS, CBNAME) \
1468 void CLASS::CBNAME(const wxColour& c) { \
1470 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1471 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1472 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1473 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1476 wxPyEndBlockThreads(blocked); \
1478 PCLASS::CBNAME(c); \
1481 //---------------------------------------------------------------------------
1483 #define DEC_PYCALLBACK_BOOL_CELLINTINTME(CBNAME) \
1484 bool CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1486 #define IMP_PYCALLBACK_BOOL_CELLINTINTME(CLASS, PCLASS, CBNAME) \
1487 bool CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1488 bool rval=false, found; \
1489 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1490 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1491 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1492 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1493 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1497 wxPyEndBlockThreads(blocked); \
1499 rval = PCLASS::CBNAME(cell, x, y, e); \
1504 //---------------------------------------------------------------------------
1506 #define DEC_PYCALLBACK___pure(CBNAME) \
1510 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1511 void CLASS::CBNAME() { \
1512 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1513 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1514 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1515 wxPyEndBlockThreads(blocked); \
1518 //---------------------------------------------------------------------------
1520 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1524 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1525 wxSize CLASS::CBNAME() { \
1526 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1528 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1529 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1532 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1534 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1536 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1538 PyObject* o1 = PySequence_GetItem(ro, 0); \
1539 PyObject* o2 = PySequence_GetItem(ro, 1); \
1540 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1541 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1543 PyErr_SetString(PyExc_TypeError, errmsg); \
1548 PyErr_SetString(PyExc_TypeError, errmsg); \
1553 wxPyEndBlockThreads(blocked); \
1557 //---------------------------------------------------------------------------
1559 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1560 bool CBNAME(wxWindow* a)
1563 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1564 bool CLASS::CBNAME(wxWindow* a) { \
1567 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1568 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1569 PyObject* obj = wxPyMake_wxObject(a,false); \
1570 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1573 wxPyEndBlockThreads(blocked); \
1575 rval = PCLASS::CBNAME(a); \
1579 //---------------------------------------------------------------------------
1581 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1582 bool CBNAME(wxWindow* a, wxDC& b)
1585 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1586 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1589 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1590 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1591 PyObject* win = wxPyMake_wxObject(a,false); \
1592 PyObject* dc = wxPyMake_wxObject(&b,false); \
1593 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1597 wxPyEndBlockThreads(blocked); \
1599 rval = PCLASS::CBNAME(a, b); \
1603 //---------------------------------------------------------------------------
1605 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1606 void CBNAME(wxWindowBase* a)
1609 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1610 void CLASS::CBNAME(wxWindowBase* a) { \
1612 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1613 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1614 PyObject* obj = wxPyMake_wxObject(a,false); \
1615 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1618 wxPyEndBlockThreads(blocked); \
1620 PCLASS::CBNAME(a); \
1623 //---------------------------------------------------------------------------
1625 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1629 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1630 bool CLASS::CBNAME() { \
1633 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1634 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1635 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1636 wxPyEndBlockThreads(blocked); \
1638 rval = PCLASS::CBNAME(); \
1642 //---------------------------------------------------------------------------
1644 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1648 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1649 bool CLASS::CBNAME() const { \
1652 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1653 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1654 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1655 wxPyEndBlockThreads(blocked); \
1657 rval = PCLASS::CBNAME(); \
1661 //---------------------------------------------------------------------------
1663 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1664 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1667 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1668 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1671 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1672 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1673 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1674 wxPyEndBlockThreads(blocked); \
1676 rval = PCLASS::CBNAME(a, b, c); \
1677 return (wxDragResult)rval; \
1680 //---------------------------------------------------------------------------
1682 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1683 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1685 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1686 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1687 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1689 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1691 PyObject* obj = wxPyMake_wxObject(&a,false); \
1692 PyObject* s = wx2PyString(b); \
1693 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1696 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
1702 wxPyEndBlockThreads(blocked); \
1706 //---------------------------------------------------------------------------
1708 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1709 bool CBNAME(wxDragResult a)
1712 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1713 bool CLASS::CBNAME(wxDragResult a) { \
1716 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1717 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1718 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1719 wxPyEndBlockThreads(blocked); \
1721 rval = PCLASS::CBNAME(a); \
1725 //---------------------------------------------------------------------------
1727 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1728 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1731 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1732 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1733 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1735 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1736 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1737 wxPyEndBlockThreads(blocked); \
1738 return (wxDragResult)rval; \
1741 //---------------------------------------------------------------------------
1743 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1744 bool CBNAME(int a, int b, const wxString& c)
1746 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1747 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1749 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1750 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1751 PyObject* s = wx2PyString(c); \
1752 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1755 wxPyEndBlockThreads(blocked); \
1759 //---------------------------------------------------------------------------
1761 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1765 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1766 size_t CLASS::CBNAME() { \
1769 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1770 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1771 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1772 wxPyEndBlockThreads(blocked); \
1774 rval = PCLASS::CBNAME(); \
1778 //---------------------------------------------------------------------------
1780 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1781 size_t CBNAME() const
1784 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1785 size_t CLASS::CBNAME() const { \
1788 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1789 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1790 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1791 wxPyEndBlockThreads(blocked); \
1793 rval = PCLASS::CBNAME(); \
1797 //---------------------------------------------------------------------------
1799 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1800 wxDataFormat CBNAME(size_t a)
1803 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1804 wxDataFormat CLASS::CBNAME(size_t a) { \
1805 wxDataFormat rval=0; \
1807 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1808 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1810 wxDataFormat* ptr; \
1811 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1813 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1818 wxPyEndBlockThreads(blocked); \
1820 rval = PCLASS::CBNAME(a); \
1824 //---------------------------------------------------------------------------
1826 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1827 void CBNAME(const Type& a)
1830 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1831 void CLASS::CBNAME(const Type& a) { \
1833 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1834 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1835 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1836 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1839 wxPyEndBlockThreads(blocked); \
1841 PCLASS::CBNAME(a); \
1845 //---------------------------------------------------------------------------
1847 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1848 void CBNAME(Type& a)
1851 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1852 void CLASS::CBNAME(Type& a) { \
1854 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1855 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1856 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1857 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1860 wxPyEndBlockThreads(blocked); \
1862 PCLASS::CBNAME(a); \
1865 //---------------------------------------------------------------------------
1867 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1868 bool CBNAME(Type& a)
1871 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1872 bool CLASS::CBNAME(Type& a) { \
1875 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1876 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1877 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1878 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1881 wxPyEndBlockThreads(blocked); \
1883 rv = PCLASS::CBNAME(a); \
1887 //---------------------------------------------------------------------------
1889 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
1890 bool CBNAME(Type& a)
1893 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
1894 bool CLASS::CBNAME(Type& a) { \
1896 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1897 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1898 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1899 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1902 wxPyEndBlockThreads(blocked); \
1906 //---------------------------------------------------------------------------
1908 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1909 wxString CBNAME(long a, long b) const
1911 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1912 wxString CLASS::CBNAME(long a, long b) const { \
1915 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1916 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1918 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1920 rval = Py2wxString(ro); \
1924 wxPyEndBlockThreads(blocked); \
1926 rval = PCLASS::CBNAME(a,b); \
1930 //---------------------------------------------------------------------------
1932 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1933 int CBNAME(long a) const
1936 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1937 int CLASS::CBNAME(long a) const { \
1940 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1941 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1943 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1945 rval = PyInt_AsLong(ro); \
1949 wxPyEndBlockThreads(blocked); \
1951 rval = PCLASS::CBNAME(a); \
1956 #define DEC_PYCALLBACK_INT_LONG_virtual(CBNAME) \
1957 int CBNAME(long a) const;
1960 #define IMP_PYCALLBACK_INT_LONG_virtual(CLASS, PCLASS, CBNAME) \
1961 int CLASS::CBNAME(long a) const { \
1962 int rval=-1; /* this rval is important for OnGetItemImage */ \
1964 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1965 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1967 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1969 rval = PyInt_AsLong(ro); \
1973 wxPyEndBlockThreads(blocked); \
1978 //---------------------------------------------------------------------------
1980 #define DEC_PYCALLBACK_INT_LONGLONG(CBNAME) \
1981 int CBNAME(long a, long b) const
1984 #define IMP_PYCALLBACK_INT_LONGLONG(CLASS, PCLASS, CBNAME) \
1985 int CLASS::CBNAME(long a, long b) const { \
1988 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1989 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1991 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1993 rval = PyInt_AsLong(ro); \
1997 wxPyEndBlockThreads(blocked); \
1999 rval = PCLASS::CBNAME(a, b); \
2004 #define DEC_PYCALLBACK_INT_LONGLONG_virtual(CBNAME) \
2005 int CBNAME(long a, long b) const;
2008 #define IMP_PYCALLBACK_INT_LONGLONG_virtual(CLASS, PCLASS, CBNAME) \
2009 int CLASS::CBNAME(long a, long b) const { \
2010 int rval=-1; /* this rval is important for OnGetItemImage */ \
2012 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2013 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2015 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2017 rval = PyInt_AsLong(ro); \
2021 wxPyEndBlockThreads(blocked); \
2026 //---------------------------------------------------------------------------
2028 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2029 wxListItemAttr* CBNAME(long a) const
2032 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2033 wxListItemAttr *CLASS::CBNAME(long a) const { \
2034 wxListItemAttr *rval = NULL; \
2036 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2037 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2039 wxListItemAttr* ptr; \
2040 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2042 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2047 wxPyEndBlockThreads(blocked); \
2049 rval = PCLASS::CBNAME(a); \
2053 //---------------------------------------------------------------------------
2055 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2056 bool CBNAME(wxMouseEvent& e)
2058 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2059 bool CLASS::CBNAME(wxMouseEvent& e) { \
2062 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2063 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2065 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2066 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2068 rval = PyInt_AsLong(ro); \
2073 wxPyEndBlockThreads(blocked); \
2075 return PCLASS::CBNAME(e); \
2079 //---------------------------------------------------------------------------
2081 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2082 wxWizardPage* CBNAME() const
2084 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2085 wxWizardPage* CLASS::CBNAME() const { \
2086 wxWizardPage* rv = NULL; \
2087 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2088 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2090 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2092 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2096 wxPyEndBlockThreads(blocked); \
2100 //---------------------------------------------------------------------------
2102 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2103 wxBitmap CBNAME() const
2105 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2106 wxBitmap CLASS::CBNAME() const { \
2108 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2109 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2112 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2114 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2119 wxPyEndBlockThreads(blocked); \
2123 //---------------------------------------------------------------------------
2125 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2128 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2129 wxObject* CLASS::CBNAME() { \
2130 wxObject* rv = NULL; \
2131 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2132 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2134 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2136 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2140 wxPyEndBlockThreads(blocked); \
2144 //---------------------------------------------------------------------------
2146 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2147 wxObject* CBNAME(const wxString& a)
2149 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2150 wxObject* CLASS::CBNAME(const wxString& a) { \
2151 wxObject* rv = NULL; \
2152 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2153 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2154 PyObject* so = wx2PyString(a); \
2156 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2158 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2163 wxPyEndBlockThreads(blocked); \
2167 //---------------------------------------------------------------------------
2169 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2170 bool CBNAME(wxXmlNode* a)
2173 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2174 bool CLASS::CBNAME(wxXmlNode* a) { \
2176 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2177 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2178 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2179 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2182 wxPyEndBlockThreads(blocked); \
2186 //---------------------------------------------------------------------------
2188 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2189 wxCoord CBNAME(size_t a) const
2192 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2193 wxCoord CLASS::CBNAME(size_t a) const { \
2196 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2197 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2198 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2200 wxPyEndBlockThreads(blocked); \
2204 //---------------------------------------------------------------------------
2206 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2207 void CBNAME(size_t a, size_t b) const
2210 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2211 void CLASS::CBNAME(size_t a, size_t b) const { \
2213 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2214 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2215 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2216 wxPyEndBlockThreads(blocked); \
2218 PCLASS::CBNAME(a,b); \
2220 //---------------------------------------------------------------------------
2222 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2223 wxCoord CBNAME() const
2226 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2227 wxCoord CLASS::CBNAME() const { \
2230 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2231 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2232 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2233 wxPyEndBlockThreads(blocked); \
2235 rval = PCLASS::CBNAME(); \
2239 //---------------------------------------------------------------------------
2241 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2242 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2244 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2245 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2247 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2248 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2249 PyObject* obj = wxPyMake_wxObject(&a,false); \
2250 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2251 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2254 wxPyEndBlockThreads(blocked); \
2259 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2260 void CBNAME(wxDC& a, const wxRect& b, size_t c) const
2262 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2263 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2265 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2266 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2267 PyObject* obj = wxPyMake_wxObject(&a,false); \
2268 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2269 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2272 wxPyEndBlockThreads(blocked); \
2274 PCLASS::CBNAME(a,b,c); \
2278 //---------------------------------------------------------------------------
2279 // Same as the above set, but the wxRect is not const
2281 #define DEC_PYCALLBACK__DCRECTSIZET2_constpure(CBNAME) \
2282 void CBNAME(wxDC& a, wxRect& b, size_t c) const;
2284 #define IMP_PYCALLBACK__DCRECTSIZET2_constpure(CLASS, PCLASS, CBNAME) \
2285 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2287 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2288 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2289 PyObject* obj = wxPyMake_wxObject(&a,false); \
2290 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2291 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2294 wxPyEndBlockThreads(blocked); \
2299 #define DEC_PYCALLBACK__DCRECTSIZET2_const(CBNAME) \
2300 void CBNAME(wxDC& a, wxRect& b, size_t c) const
2302 #define IMP_PYCALLBACK__DCRECTSIZET2_const(CLASS, PCLASS, CBNAME) \
2303 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2305 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2306 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2307 PyObject* obj = wxPyMake_wxObject(&a,false); \
2308 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2309 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2312 wxPyEndBlockThreads(blocked); \
2314 PCLASS::CBNAME(a,b,c); \
2319 //---------------------------------------------------------------------------
2323 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2324 wxString CBNAME(size_t a) const
2326 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2327 wxString CLASS::CBNAME(size_t a) const { \
2330 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2331 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2333 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2335 rval = Py2wxString(ro); \
2339 wxPyEndBlockThreads(blocked); \
2341 rval = PCLASS::CBNAME(a); \
2345 //---------------------------------------------------------------------------
2347 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2348 wxString CBNAME(size_t a) const
2350 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2351 wxString CLASS::CBNAME(size_t a) const { \
2354 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2355 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2357 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2359 rval = Py2wxString(ro); \
2363 wxPyEndBlockThreads(blocked); \
2367 //---------------------------------------------------------------------------
2369 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2370 wxVisualAttributes CBNAME() const
2373 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2374 wxVisualAttributes CLASS::CBNAME() const { \
2375 wxVisualAttributes rval; \
2377 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2378 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2380 wxVisualAttributes* ptr; \
2381 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2383 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2388 wxPyEndBlockThreads(blocked); \
2390 rval = PCLASS::CBNAME(); \
2394 //---------------------------------------------------------------------------