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();
230 // Other helpful stuff
231 bool wxPy2int_seq_helper(PyObject
* source
, int* i1
, int* i2
);
232 bool wxPy4int_seq_helper(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
234 PyObject
* wxArrayString2PyList_helper(const wxArrayString
& arr
);
235 PyObject
* wxArrayInt2PyList_helper(const wxArrayInt
& arr
);
237 #endif // wxPyUSE_EXPORTED_API
239 //---------------------------------------------------------------------------
241 #if PYTHON_API_VERSION < 1009
242 #define PySequence_Fast_GET_ITEM(o, i) \
243 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
246 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
247 #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name)
248 #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val)
250 //---------------------------------------------------------------------------
252 #ifndef wxPyUSE_EXPORTED_API
254 class wxPyCallback
: public wxObject
{
255 DECLARE_ABSTRACT_CLASS(wxPyCallback
)
257 wxPyCallback(PyObject
* func
);
258 wxPyCallback(const wxPyCallback
& other
);
261 void EventThunker(wxEvent
& event
);
266 #endif // wxPyUSE_EXPORTED_API
267 //---------------------------------------------------------------------------
268 //---------------------------------------------------------------------------
269 // These Event classes can be derived from in Python and passed through the
270 // event system without loosing anything. They do this by keeping a reference
271 // to themselves and some special case handling in wxPyCallback::EventThunker.
275 class wxPyEvtSelfRef
{
280 void SetSelf(PyObject
* self
, bool clone
=false);
281 PyObject
* GetSelf() const;
282 bool GetCloned() const { return m_cloned
; }
290 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
291 DECLARE_ABSTRACT_CLASS(wxPyEvent
)
293 wxPyEvent(int winid
=0, wxEventType commandType
= wxEVT_NULL
);
294 wxPyEvent(const wxPyEvent
& evt
);
297 virtual wxEvent
* Clone() const { return new wxPyEvent(*this); }
301 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
302 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent
)
304 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
305 wxPyCommandEvent(const wxPyCommandEvent
& evt
);
308 virtual wxEvent
* Clone() const { return new wxPyCommandEvent(*this); }
313 //----------------------------------------------------------------------
314 // Forward decalre a few things used in the exported API
315 class wxPyClientData
;
317 class wxPyOORClientData
;
318 class wxPyCBInputStream
;
320 void wxPyClientData_dtor(wxPyClientData
* self
);
321 void wxPyUserData_dtor(wxPyUserData
* self
);
322 void wxPyOORClientData_dtor(wxPyOORClientData
* self
);
323 wxPyCBInputStream
* wxPyCBInputStream_create(PyObject
*py
, bool block
);
324 wxPyCBInputStream
* wxPyCBInputStream_copy(wxPyCBInputStream
* other
);
326 //---------------------------------------------------------------------------
327 // Export a C API in a struct. Other modules will be able to load this from
328 // the wx.core module and will then have safe access to these functions, even if
329 // in another shared library.
331 class wxPyCallbackHelper
;
335 bool (*p_wxPyCheckSwigType
)(const wxChar
* className
);
336 PyObject
* (*p_wxPyConstructObject
)(void* ptr
, const wxChar
* className
, int setThisOwn
);
337 bool (*p_wxPyConvertSwigPtr
)(PyObject
* obj
, void **ptr
, const wxChar
* className
);
338 PyObject
* (*p_wxPyMakeSwigPtr
)(void* ptr
, const wxChar
* className
);
340 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
341 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
342 wxPyBlock_t (*p_wxPyBeginBlockThreads
)();
343 void (*p_wxPyEndBlockThreads
)(wxPyBlock_t blocked
);
345 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
);
347 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
348 wxString (*p_Py2wxString
)(PyObject
* source
);
349 PyObject
* (*p_wx2PyString
)(const wxString
& src
);
351 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
352 int* (*p_int_LIST_helper
)(PyObject
* source
);
353 long* (*p_long_LIST_helper
)(PyObject
* source
);
354 char** (*p_string_LIST_helper
)(PyObject
* source
);
355 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
356 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
357 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
358 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
360 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
361 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
362 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
363 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
364 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
365 bool (*p_wxPoint2D_helper
)(PyObject
* source
, wxPoint2DDouble
** obj
);
368 bool (*p_wxPySimple_typecheck
)(PyObject
* source
, const wxChar
* classname
, int seqLen
);
369 bool (*p_wxColour_typecheck
)(PyObject
* source
);
371 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
372 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
);
373 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
374 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
375 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
377 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
);
378 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
, bool setThisOwn
);
379 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
380 bool (*p_wxPy2int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
);
381 bool (*p_wxPy4int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
382 PyObject
* (*p_wxArrayString2PyList_helper
)(const wxArrayString
& arr
);
383 PyObject
* (*p_wxArrayInt2PyList_helper
)(const wxArrayInt
& arr
);
385 void (*p_wxPyClientData_dtor
)(wxPyClientData
*);
386 void (*p_wxPyUserData_dtor
)(wxPyUserData
*);
387 void (*p_wxPyOORClientData_dtor
)(wxPyOORClientData
*);
389 wxPyCBInputStream
* (*p_wxPyCBInputStream_create
)(PyObject
*py
, bool block
);
390 wxPyCBInputStream
* (*p_wxPyCBInputStream_copy
)(wxPyCBInputStream
* other
);
392 bool (*p_wxPyInstance_Check
)(PyObject
* obj
);
393 bool (*p_wxPySwigInstance_Check
)(PyObject
* obj
);
395 bool (*p_wxPyCheckForApp
)();
399 #ifdef wxPyUSE_EXPORTED_API
400 // Notice that this is static, not extern. This is by design, each module
401 // needs one, but doesn't have to use it.
402 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
;
403 inline wxPyCoreAPI
* wxPyGetCoreAPIPtr();
404 #endif // wxPyUSE_EXPORTED_API
406 //---------------------------------------------------------------------------
408 // A wxObject that holds a reference to a Python object
409 class wxPyUserData
: public wxObject
{
411 wxPyUserData(PyObject
* obj
) {
417 #ifdef wxPyUSE_EXPORTED_API
418 wxPyGetCoreAPIPtr()->p_wxPyUserData_dtor(this);
420 wxPyUserData_dtor(this);
427 // A wxClientData that holds a refernece to a Python object
428 class wxPyClientData
: public wxClientData
{
430 wxPyClientData(PyObject
* obj
, bool incref
=true) {
438 #ifdef wxPyUSE_EXPORTED_API
439 wxPyGetCoreAPIPtr()->p_wxPyClientData_dtor(this);
441 wxPyClientData_dtor(this);
449 // Just like wxPyClientData, except when this object is destroyed it does some
450 // OOR magic on the Python Object.
451 class wxPyOORClientData
: public wxPyClientData
{
453 wxPyOORClientData(PyObject
* obj
, bool incref
=true)
454 : wxPyClientData(obj
, incref
) {}
455 ~wxPyOORClientData() {
457 #ifdef wxPyUSE_EXPORTED_API
458 wxPyGetCoreAPIPtr()->p_wxPyOORClientData_dtor(this);
460 wxPyOORClientData_dtor(this);
466 //---------------------------------------------------------------------------
467 // A wxImageHandler that can be derived from in Python.
470 class wxPyImageHandler
: public wxImageHandler
{
474 // used for interning method names as PyStrings
475 static PyObject
* m_DoCanRead_Name
;
476 static PyObject
* m_GetImageCount_Name
;
477 static PyObject
* m_LoadFile_Name
;
478 static PyObject
* m_SaveFile_Name
;
480 // converstion helpers
481 PyObject
* py_InputStream(wxInputStream
* stream
);
482 PyObject
* py_Image(wxImage
* image
);
483 PyObject
* py_OutputStream(wxOutputStream
* stream
);
488 void _SetSelf(PyObject
*self
);
490 virtual bool LoadFile(wxImage
* image
, wxInputStream
& stream
,
491 bool verbose
=true, int index
=-1 );
492 virtual bool SaveFile(wxImage
* image
, wxOutputStream
& stream
,
494 virtual int GetImageCount(wxInputStream
& stream
);
495 virtual bool DoCanRead(wxInputStream
&stream
);
499 //---------------------------------------------------------------------------
500 // This class holds an instance of a Python Shadow Class object and assists
501 // with looking up and invoking Python callback methods from C++ virtual
502 // method redirections. For all classes which have virtuals which should be
503 // overridable in wxPython, a new subclass is created that contains a
504 // wxPyCallbackHelper.
507 class wxPyCallbackHelper
{
509 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
511 wxPyCallbackHelper() {
518 ~wxPyCallbackHelper() {
519 #ifdef wxPyUSE_EXPORTED_API
520 wxPyGetCoreAPIPtr()->p_wxPyCBH_delete(this);
522 wxPyCBH_delete(this);
526 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=true);
527 bool findCallback(const char* name
, bool setGuard
=true) const;
528 int callCallback(PyObject
* argTuple
) const;
529 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
530 PyObject
* GetLastFound() const { return m_lastFound
; }
532 void setRecursionGuard(PyObject
* method
) const;
533 void clearRecursionGuard(PyObject
* method
) const;
538 PyObject
* m_lastFound
;
541 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
545 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
546 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
=true);
547 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
548 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
549 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
554 //---------------------------------------------------------------------------
556 // This is used in C++ classes that need to be able to make callback to
557 // "overloaded" python methods
560 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
561 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
563 private: wxPyCallbackHelper m_myInst
566 //---------------------------------------------------------------------------
567 // The wxPythonApp class
570 wxPYAPP_ASSERT_SUPPRESS
= 1,
571 wxPYAPP_ASSERT_EXCEPTION
= 2,
572 wxPYAPP_ASSERT_DIALOG
= 4,
573 wxPYAPP_ASSERT_LOG
= 8
576 class wxPyApp
: public wxApp
578 DECLARE_ABSTRACT_CLASS(wxPyApp
)
586 int GetAssertMode() { return m_assertMode
; }
587 void SetAssertMode(int mode
) { m_assertMode
= mode
; }
589 virtual bool OnInitGui();
590 virtual int OnExit();
592 virtual void OnAssert(const wxChar
*file
,
597 virtual void ExitMainLoop();
598 // virtual int FilterEvent(wxEvent& event); // This one too????
600 // For catching Apple Events
601 virtual void MacOpenFile(const wxString
&fileName
);
602 virtual void MacPrintFile(const wxString
&fileName
);
603 virtual void MacNewFile();
604 virtual void MacReopenApp();
606 static bool GetMacSupportPCMenuShortcuts();
607 static long GetMacAboutMenuItemId();
608 static long GetMacPreferencesMenuItemId();
609 static long GetMacExitMenuItemId();
610 static wxString
GetMacHelpMenuTitleName();
612 static void SetMacSupportPCMenuShortcuts(bool val
);
613 static void SetMacAboutMenuItemId(long val
);
614 static void SetMacPreferencesMenuItemId(long val
);
615 static void SetMacExitMenuItemId(long val
);
616 static void SetMacHelpMenuTitleName(const wxString
& val
);
619 void _BootstrapApp();
621 // implementation only
622 void SetStartupComplete(bool val
) { m_startupComplete
= val
; };
626 bool m_startupComplete
;
629 extern wxPyApp
*wxPythonApp
;
632 //----------------------------------------------------------------------
633 // These macros are used to implement the virtual methods that should
634 // redirect to a Python method if one exists. The names designate the
635 // return type, if any, as well as any parameter types.
636 //---------------------------------------------------------------------------
638 #define DEC_PYCALLBACK__(CBNAME) \
642 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
643 void CLASS::CBNAME() { \
645 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
646 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
647 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
648 wxPyEndBlockThreads(blocked); \
653 #define DEC_PYCALLBACK_VOID_(CBNAME) \
654 DEC_PYCALLBACK__(CBNAME)
656 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
657 IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME)
659 //---------------------------------------------------------------------------
661 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
662 bool CBNAME(int a, int b)
665 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
666 bool CLASS::CBNAME(int a, int b) { \
667 bool rval=false, found; \
668 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
669 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
670 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
671 wxPyEndBlockThreads(blocked); \
673 rval = PCLASS::CBNAME(a,b); \
677 //---------------------------------------------------------------------------
679 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
680 void CBNAME(int a, int b)
683 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
684 void CLASS::CBNAME(int a, int b) { \
686 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
687 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
688 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
689 wxPyEndBlockThreads(blocked); \
691 PCLASS::CBNAME(a,b); \
694 //---------------------------------------------------------------------------
696 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
700 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
701 void CLASS::CBNAME(int a) { \
703 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
704 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
705 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
706 wxPyEndBlockThreads(blocked); \
711 //---------------------------------------------------------------------------
713 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
714 void CBNAME(int a, int b, int c, int d)
717 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
718 void CLASS::CBNAME(int a, int b, int c, int d) { \
720 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
721 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
722 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
723 wxPyEndBlockThreads(blocked); \
725 PCLASS::CBNAME(a,b,c,d); \
728 //---------------------------------------------------------------------------
729 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
730 void CBNAME(int a, int b, int c, int d, int e)
733 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
734 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
736 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
737 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
738 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
739 wxPyEndBlockThreads(blocked); \
741 PCLASS::CBNAME(a,b,c,d,e); \
744 //---------------------------------------------------------------------------
746 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
747 void CBNAME(int* a, int* b) const
750 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
751 void CLASS::CBNAME(int* a, int* b) const { \
752 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
754 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
755 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
757 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
759 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
760 PyObject* o1 = PySequence_GetItem(ro, 0); \
761 PyObject* o2 = PySequence_GetItem(ro, 1); \
762 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
763 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
766 PyErr_SetString(PyExc_TypeError, errmsg); \
771 PyErr_SetString(PyExc_TypeError, errmsg); \
776 wxPyEndBlockThreads(blocked); \
778 PCLASS::CBNAME(a,b); \
781 //---------------------------------------------------------------------------
783 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
784 wxSize CBNAME() const
787 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
788 wxSize CLASS::CBNAME() const { \
789 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
790 bool found; wxSize rval(0,0); \
791 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
792 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
794 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
796 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
797 PyObject* o1 = PySequence_GetItem(ro, 0); \
798 PyObject* o2 = PySequence_GetItem(ro, 1); \
799 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
800 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
803 PyErr_SetString(PyExc_TypeError, errmsg); \
808 PyErr_SetString(PyExc_TypeError, errmsg); \
813 wxPyEndBlockThreads(blocked); \
815 return PCLASS::CBNAME(); \
820 //---------------------------------------------------------------------------
822 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
826 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
827 bool CLASS::CBNAME(bool a) { \
828 bool rval=false, found; \
829 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
830 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
831 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
832 wxPyEndBlockThreads(blocked); \
834 rval = PCLASS::CBNAME(a); \
838 //---------------------------------------------------------------------------
840 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
844 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
845 bool CLASS::CBNAME(int a) { \
846 bool rval=false, found; \
847 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
848 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
849 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
850 wxPyEndBlockThreads(blocked); \
852 rval = PCLASS::CBNAME(a); \
856 //---------------------------------------------------------------------------
858 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
862 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
863 bool CLASS::CBNAME(int a) { \
865 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
866 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
867 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
869 wxPyEndBlockThreads(blocked); \
874 //---------------------------------------------------------------------------
876 #define DEC_PYCALLBACK__DC(CBNAME) \
880 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
881 void CLASS::CBNAME(wxDC& a) { \
883 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
884 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
885 PyObject* obj = wxPyMake_wxObject(&a,false); \
886 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
889 wxPyEndBlockThreads(blocked); \
895 //---------------------------------------------------------------------------
897 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
898 void CBNAME(wxDC& a, bool b)
901 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
902 void CLASS::CBNAME(wxDC& a, bool b) { \
904 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
905 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
906 PyObject* obj = wxPyMake_wxObject(&a,false); \
907 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
910 wxPyEndBlockThreads(blocked); \
912 PCLASS::CBNAME(a, b); \
915 //---------------------------------------------------------------------------
917 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
918 void CBNAME(wxDC& a, bool b)
921 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
922 void CLASS::CBNAME(wxDC& a, bool b) { \
924 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
925 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
926 PyObject* obj = wxPyMake_wxObject(&a,false); \
927 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
930 wxPyEndBlockThreads(blocked); \
932 PCLASS::CBNAME(a, b); \
935 //---------------------------------------------------------------------------
937 #define DEC_PYCALLBACK__2DBL(CBNAME) \
938 void CBNAME(double a, double b)
941 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
942 void CLASS::CBNAME(double a, double b) { \
944 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
945 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
946 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
947 wxPyEndBlockThreads(blocked); \
949 PCLASS::CBNAME(a, b); \
952 //---------------------------------------------------------------------------
954 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
955 void CBNAME(double a, double b, int c, int d)
958 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
959 void CLASS::CBNAME(double a, double b, int c, int d) { \
961 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
962 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
963 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
965 wxPyEndBlockThreads(blocked); \
967 PCLASS::CBNAME(a, b, c, d); \
970 //---------------------------------------------------------------------------
972 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
973 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
976 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
977 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
979 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
980 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
981 PyObject* obj = wxPyMake_wxObject(&a,false); \
982 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
985 wxPyEndBlockThreads(blocked); \
987 PCLASS::CBNAME(a, b, c, d, e, f); \
990 //---------------------------------------------------------------------------
992 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
993 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
996 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
997 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
999 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1001 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1002 PyObject* obj = wxPyMake_wxObject(&a,false); \
1003 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1006 wxPyEndBlockThreads(blocked); \
1008 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1012 //---------------------------------------------------------------------------
1014 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1015 void CBNAME(bool a, double b, double c, int d, int e)
1018 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1019 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1021 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1022 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1023 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1025 wxPyEndBlockThreads(blocked); \
1027 PCLASS::CBNAME(a, b, c, d, e); \
1030 //---------------------------------------------------------------------------
1032 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1033 void CBNAME(wxDC& a, double b, double c, double d, double e)
1036 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1037 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1039 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1040 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1041 PyObject* obj = wxPyMake_wxObject(&a,false); \
1042 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1045 wxPyEndBlockThreads(blocked); \
1047 PCLASS::CBNAME(a, b, c, d, e); \
1050 //---------------------------------------------------------------------------
1052 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1053 void CBNAME(wxDC& a, bool b)
1056 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1057 void CLASS::CBNAME(wxDC& a, bool b) { \
1059 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1060 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1061 PyObject* obj = wxPyMake_wxObject(&a,false); \
1062 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1065 wxPyEndBlockThreads(blocked); \
1067 PCLASS::CBNAME(a, b); \
1070 //---------------------------------------------------------------------------
1072 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1073 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1076 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1077 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1080 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1081 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1082 PyObject* obj = wxPyMake_wxObject(a,false); \
1083 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1086 wxPyEndBlockThreads(blocked); \
1088 PCLASS::CBNAME(a, b, c, d, e, f); \
1091 //---------------------------------------------------------------------------
1093 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1094 void CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1097 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1098 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1100 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1101 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1102 PyObject* obj = wxPyMake_wxObject(a,false); \
1103 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1106 wxPyEndBlockThreads(blocked); \
1108 PCLASS::CBNAME(a, b, c, d, e); \
1111 //---------------------------------------------------------------------------
1113 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1114 void CBNAME(double a, double b, int c)
1117 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1118 void CLASS::CBNAME(double a, double b, int c) { \
1120 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1121 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1122 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1123 wxPyEndBlockThreads(blocked); \
1125 PCLASS::CBNAME(a, b, c); \
1128 //---------------------------------------------------------------------------
1130 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1131 void CBNAME(bool a, double b, double c, int d)
1134 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1135 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1137 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1138 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1139 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1140 wxPyEndBlockThreads(blocked); \
1142 PCLASS::CBNAME(a, b, c, d); \
1145 //---------------------------------------------------------------------------
1146 //---------------------------------------------------------------------------
1148 #define DEC_PYCALLBACK__STRING(CBNAME) \
1149 void CBNAME(const wxString& a)
1151 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1152 void CLASS::CBNAME(const wxString& a) { \
1154 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1155 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1156 PyObject* s = wx2PyString(a); \
1157 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1160 wxPyEndBlockThreads(blocked); \
1162 PCLASS::CBNAME(a); \
1165 //---------------------------------------------------------------------------
1167 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1168 bool CBNAME(const wxString& a)
1170 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1171 bool CLASS::CBNAME(const wxString& a) { \
1174 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1175 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1176 PyObject* s = wx2PyString(a); \
1177 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1180 wxPyEndBlockThreads(blocked); \
1182 rval = PCLASS::CBNAME(a); \
1186 //---------------------------------------------------------------------------
1188 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1189 bool CBNAME(const wxString& a)
1191 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1192 bool CLASS::CBNAME(const wxString& a) { \
1194 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1195 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1196 PyObject* s = wx2PyString(a); \
1197 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1200 wxPyEndBlockThreads(blocked); \
1204 //---------------------------------------------------------------------------
1206 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1207 wxString CBNAME(const wxString& a)
1209 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1210 wxString CLASS::CBNAME(const wxString& a) { \
1212 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1213 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1215 PyObject* s = wx2PyString(a); \
1216 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1219 rval = Py2wxString(ro); \
1223 wxPyEndBlockThreads(blocked); \
1227 //---------------------------------------------------------------------------
1229 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1230 wxString CBNAME(const wxString& a)
1232 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1233 wxString CLASS::CBNAME(const wxString& a) { \
1236 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1237 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1239 PyObject* s = wx2PyString(a); \
1240 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1243 rval = Py2wxString(ro); \
1248 rval = PCLASS::CBNAME(a); \
1249 wxPyEndBlockThreads(blocked); \
1253 //---------------------------------------------------------------------------
1255 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1256 wxString CBNAME(const wxString& a,int b)
1258 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1259 wxString CLASS::CBNAME(const wxString& a,int b) { \
1261 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1262 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1264 PyObject* s = wx2PyString(a); \
1265 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1268 rval = Py2wxString(ro); \
1272 wxPyEndBlockThreads(blocked); \
1276 //---------------------------------------------------------------------------
1278 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1279 bool CBNAME(const wxString& a, const wxString& b)
1281 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1282 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1285 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1286 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1287 PyObject* s1 = wx2PyString(a); \
1288 PyObject* s2 = wx2PyString(b); \
1289 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1293 wxPyEndBlockThreads(blocked); \
1295 rval = PCLASS::CBNAME(a, b); \
1299 //---------------------------------------------------------------------------
1301 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1304 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1305 wxString CLASS::CBNAME() { \
1308 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1309 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1311 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1313 rval = Py2wxString(ro); \
1317 wxPyEndBlockThreads(blocked); \
1319 rval = PCLASS::CBNAME(); \
1323 //---------------------------------------------------------------------------
1325 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1326 wxString CBNAME() const
1328 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1329 wxString CLASS::CBNAME() const { \
1332 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1333 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1335 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1337 rval = Py2wxString(ro); \
1341 wxPyEndBlockThreads(blocked); \
1343 rval = PCLASS::CBNAME(); \
1347 //---------------------------------------------------------------------------
1349 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1352 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1353 wxString CLASS::CBNAME() { \
1355 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1356 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1358 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1360 rval = Py2wxString(ro); \
1364 wxPyEndBlockThreads(blocked); \
1368 //---------------------------------------------------------------------------
1370 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1371 wxString CBNAME() const;
1373 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1374 wxString CLASS::CBNAME() const { \
1376 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1377 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1379 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1381 rval = Py2wxString(ro); \
1385 wxPyEndBlockThreads(blocked); \
1389 //---------------------------------------------------------------------------
1391 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1392 bool CBNAME(const wxHtmlTag& a)
1395 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1396 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1398 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1399 if (wxPyCBH_findCallback2(m_myInst, #CBNAME, false)) { \
1400 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
1401 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1404 wxPyEndBlockThreads(blocked); \
1408 //---------------------------------------------------------------------------
1410 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1411 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1413 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1414 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1416 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1417 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1418 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1419 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1422 wxPyEndBlockThreads(blocked); \
1424 PCLASS::CBNAME(cell, x, y); \
1427 //---------------------------------------------------------------------------
1429 #define DEC_PYCALLBACK__COLOUR(CBNAME) \
1430 void CBNAME(const wxColour& c);
1432 #define IMP_PYCALLBACK__COLOUR(CLASS, PCLASS, CBNAME) \
1433 void CLASS::CBNAME(const wxColour& c) { \
1435 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1436 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1437 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1438 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1441 wxPyEndBlockThreads(blocked); \
1443 PCLASS::CBNAME(c); \
1446 //---------------------------------------------------------------------------
1448 #define DEC_PYCALLBACK_BOOL_CELLINTINTME(CBNAME) \
1449 bool CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1451 #define IMP_PYCALLBACK_BOOL_CELLINTINTME(CLASS, PCLASS, CBNAME) \
1452 bool CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1453 bool rval=false, found; \
1454 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1455 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1456 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1457 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1458 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1462 wxPyEndBlockThreads(blocked); \
1464 rval = PCLASS::CBNAME(cell, x, y, e); \
1469 //---------------------------------------------------------------------------
1471 #define DEC_PYCALLBACK___pure(CBNAME) \
1475 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1476 void CLASS::CBNAME() { \
1477 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1478 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1479 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1480 wxPyEndBlockThreads(blocked); \
1483 //---------------------------------------------------------------------------
1485 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1489 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1490 wxSize CLASS::CBNAME() { \
1491 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1493 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1494 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1497 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1499 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1501 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1503 PyObject* o1 = PySequence_GetItem(ro, 0); \
1504 PyObject* o2 = PySequence_GetItem(ro, 1); \
1505 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1506 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1508 PyErr_SetString(PyExc_TypeError, errmsg); \
1513 PyErr_SetString(PyExc_TypeError, errmsg); \
1518 wxPyEndBlockThreads(blocked); \
1522 //---------------------------------------------------------------------------
1524 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1525 bool CBNAME(wxWindow* a)
1528 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1529 bool CLASS::CBNAME(wxWindow* a) { \
1532 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1533 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1534 PyObject* obj = wxPyMake_wxObject(a,false); \
1535 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1538 wxPyEndBlockThreads(blocked); \
1540 rval = PCLASS::CBNAME(a); \
1544 //---------------------------------------------------------------------------
1546 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1547 bool CBNAME(wxWindow* a, wxDC& b)
1550 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1551 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1554 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1555 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1556 PyObject* win = wxPyMake_wxObject(a,false); \
1557 PyObject* dc = wxPyMake_wxObject(&b,false); \
1558 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1562 wxPyEndBlockThreads(blocked); \
1564 rval = PCLASS::CBNAME(a, b); \
1568 //---------------------------------------------------------------------------
1570 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1571 void CBNAME(wxWindowBase* a)
1574 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1575 void CLASS::CBNAME(wxWindowBase* a) { \
1577 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1578 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1579 PyObject* obj = wxPyMake_wxObject(a,false); \
1580 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1583 wxPyEndBlockThreads(blocked); \
1585 PCLASS::CBNAME(a); \
1588 //---------------------------------------------------------------------------
1590 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1594 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1595 bool CLASS::CBNAME() { \
1598 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1599 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1600 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1601 wxPyEndBlockThreads(blocked); \
1603 rval = PCLASS::CBNAME(); \
1607 //---------------------------------------------------------------------------
1609 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1613 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1614 bool CLASS::CBNAME() const { \
1617 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1618 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1619 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1620 wxPyEndBlockThreads(blocked); \
1622 rval = PCLASS::CBNAME(); \
1626 //---------------------------------------------------------------------------
1628 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1629 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1632 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1633 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1636 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1637 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1638 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1639 wxPyEndBlockThreads(blocked); \
1641 rval = PCLASS::CBNAME(a, b, c); \
1642 return (wxDragResult)rval; \
1645 //---------------------------------------------------------------------------
1647 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1648 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1650 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1651 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1652 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1654 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1656 PyObject* obj = wxPyMake_wxObject(&a,false); \
1657 PyObject* s = wx2PyString(b); \
1658 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1661 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
1667 wxPyEndBlockThreads(blocked); \
1671 //---------------------------------------------------------------------------
1673 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1674 bool CBNAME(wxDragResult a)
1677 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1678 bool CLASS::CBNAME(wxDragResult a) { \
1681 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1682 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1683 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1684 wxPyEndBlockThreads(blocked); \
1686 rval = PCLASS::CBNAME(a); \
1690 //---------------------------------------------------------------------------
1692 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1693 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1696 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1697 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1698 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1700 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1701 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1702 wxPyEndBlockThreads(blocked); \
1703 return (wxDragResult)rval; \
1706 //---------------------------------------------------------------------------
1708 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1709 bool CBNAME(int a, int b, const wxString& c)
1711 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1712 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1714 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1715 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1716 PyObject* s = wx2PyString(c); \
1717 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1720 wxPyEndBlockThreads(blocked); \
1724 //---------------------------------------------------------------------------
1726 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1730 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1731 size_t CLASS::CBNAME() { \
1734 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1735 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1736 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1737 wxPyEndBlockThreads(blocked); \
1739 rval = PCLASS::CBNAME(); \
1743 //---------------------------------------------------------------------------
1745 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1746 size_t CBNAME() const
1749 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1750 size_t CLASS::CBNAME() const { \
1753 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1754 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1755 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1756 wxPyEndBlockThreads(blocked); \
1758 rval = PCLASS::CBNAME(); \
1762 //---------------------------------------------------------------------------
1764 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1765 wxDataFormat CBNAME(size_t a)
1768 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1769 wxDataFormat CLASS::CBNAME(size_t a) { \
1770 wxDataFormat rval=0; \
1772 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1773 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1775 wxDataFormat* ptr; \
1776 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1778 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1783 wxPyEndBlockThreads(blocked); \
1785 rval = PCLASS::CBNAME(a); \
1789 //---------------------------------------------------------------------------
1791 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1792 void CBNAME(const Type& a)
1795 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1796 void CLASS::CBNAME(const Type& a) { \
1798 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1799 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1800 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1801 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1804 wxPyEndBlockThreads(blocked); \
1806 PCLASS::CBNAME(a); \
1810 //---------------------------------------------------------------------------
1812 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1813 void CBNAME(Type& a)
1816 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1817 void CLASS::CBNAME(Type& a) { \
1819 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1820 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1821 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1822 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1825 wxPyEndBlockThreads(blocked); \
1827 PCLASS::CBNAME(a); \
1830 //---------------------------------------------------------------------------
1832 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1833 bool CBNAME(Type& a)
1836 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1837 bool CLASS::CBNAME(Type& a) { \
1840 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1841 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1842 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1843 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1846 wxPyEndBlockThreads(blocked); \
1848 rv = PCLASS::CBNAME(a); \
1852 //---------------------------------------------------------------------------
1854 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
1855 bool CBNAME(Type& a)
1858 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
1859 bool CLASS::CBNAME(Type& a) { \
1861 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1862 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1863 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1864 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1867 wxPyEndBlockThreads(blocked); \
1871 //---------------------------------------------------------------------------
1873 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1874 wxString CBNAME(long a, long b) const
1876 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1877 wxString CLASS::CBNAME(long a, long b) const { \
1880 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1881 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1883 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1885 rval = Py2wxString(ro); \
1889 wxPyEndBlockThreads(blocked); \
1891 rval = PCLASS::CBNAME(a,b); \
1895 //---------------------------------------------------------------------------
1897 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1898 int CBNAME(long a) const
1901 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1902 int CLASS::CBNAME(long a) const { \
1905 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1906 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1908 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1910 rval = PyInt_AsLong(ro); \
1914 wxPyEndBlockThreads(blocked); \
1916 rval = PCLASS::CBNAME(a); \
1921 #define DEC_PYCALLBACK_INT_LONG_virtual(CBNAME) \
1922 int CBNAME(long a) const;
1925 #define IMP_PYCALLBACK_INT_LONG_virtual(CLASS, PCLASS, CBNAME) \
1926 int CLASS::CBNAME(long a) const { \
1927 int rval=-1; /* this rval is important for OnGetItemImage */ \
1929 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1930 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1932 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1934 rval = PyInt_AsLong(ro); \
1938 wxPyEndBlockThreads(blocked); \
1943 //---------------------------------------------------------------------------
1945 #define DEC_PYCALLBACK_INT_LONGLONG(CBNAME) \
1946 int CBNAME(long a, long b) const
1949 #define IMP_PYCALLBACK_INT_LONGLONG(CLASS, PCLASS, CBNAME) \
1950 int CLASS::CBNAME(long a, long b) const { \
1953 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1954 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1956 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1958 rval = PyInt_AsLong(ro); \
1962 wxPyEndBlockThreads(blocked); \
1964 rval = PCLASS::CBNAME(a, b); \
1969 #define DEC_PYCALLBACK_INT_LONGLONG_virtual(CBNAME) \
1970 int CBNAME(long a, long b) const;
1973 #define IMP_PYCALLBACK_INT_LONGLONG_virtual(CLASS, PCLASS, CBNAME) \
1974 int CLASS::CBNAME(long a, long b) const { \
1975 int rval=-1; /* this rval is important for OnGetItemImage */ \
1977 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1978 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1980 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1982 rval = PyInt_AsLong(ro); \
1986 wxPyEndBlockThreads(blocked); \
1991 //---------------------------------------------------------------------------
1993 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
1994 wxListItemAttr* CBNAME(long a) const
1997 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
1998 wxListItemAttr *CLASS::CBNAME(long a) const { \
1999 wxListItemAttr *rval = NULL; \
2001 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2002 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2004 wxListItemAttr* ptr; \
2005 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2007 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2012 wxPyEndBlockThreads(blocked); \
2014 rval = PCLASS::CBNAME(a); \
2018 //---------------------------------------------------------------------------
2020 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2021 bool CBNAME(wxMouseEvent& e)
2023 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2024 bool CLASS::CBNAME(wxMouseEvent& e) { \
2027 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2028 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2030 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2031 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2033 rval = PyInt_AsLong(ro); \
2038 wxPyEndBlockThreads(blocked); \
2040 return PCLASS::CBNAME(e); \
2044 //---------------------------------------------------------------------------
2046 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2047 wxWizardPage* CBNAME() const
2049 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2050 wxWizardPage* CLASS::CBNAME() const { \
2051 wxWizardPage* rv = NULL; \
2052 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2053 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2055 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2057 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2061 wxPyEndBlockThreads(blocked); \
2065 //---------------------------------------------------------------------------
2067 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2068 wxBitmap CBNAME() const
2070 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2071 wxBitmap CLASS::CBNAME() const { \
2073 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2074 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2077 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2079 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2084 wxPyEndBlockThreads(blocked); \
2088 //---------------------------------------------------------------------------
2090 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2093 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2094 wxObject* CLASS::CBNAME() { \
2095 wxObject* rv = NULL; \
2096 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2097 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2099 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2101 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2105 wxPyEndBlockThreads(blocked); \
2109 //---------------------------------------------------------------------------
2111 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2112 wxObject* CBNAME(const wxString& a)
2114 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2115 wxObject* CLASS::CBNAME(const wxString& a) { \
2116 wxObject* rv = NULL; \
2117 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2118 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2119 PyObject* so = wx2PyString(a); \
2121 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2123 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2128 wxPyEndBlockThreads(blocked); \
2132 //---------------------------------------------------------------------------
2134 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2135 bool CBNAME(wxXmlNode* a)
2138 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2139 bool CLASS::CBNAME(wxXmlNode* a) { \
2141 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2142 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2143 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2144 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2147 wxPyEndBlockThreads(blocked); \
2151 //---------------------------------------------------------------------------
2153 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2154 wxCoord CBNAME(size_t a) const
2157 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2158 wxCoord CLASS::CBNAME(size_t a) const { \
2161 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2162 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2163 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2165 wxPyEndBlockThreads(blocked); \
2169 //---------------------------------------------------------------------------
2171 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2172 void CBNAME(size_t a, size_t b) const
2175 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2176 void CLASS::CBNAME(size_t a, size_t b) const { \
2178 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2179 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2180 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2181 wxPyEndBlockThreads(blocked); \
2183 PCLASS::CBNAME(a,b); \
2185 //---------------------------------------------------------------------------
2187 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2188 wxCoord CBNAME() const
2191 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2192 wxCoord CLASS::CBNAME() const { \
2195 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2196 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2197 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2198 wxPyEndBlockThreads(blocked); \
2200 rval = PCLASS::CBNAME(); \
2204 //---------------------------------------------------------------------------
2206 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2207 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2209 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2210 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2212 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2213 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2214 PyObject* obj = wxPyMake_wxObject(&a,false); \
2215 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2216 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2219 wxPyEndBlockThreads(blocked); \
2224 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2225 void CBNAME(wxDC& a, const wxRect& b, size_t c) const
2227 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2228 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2230 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2231 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2232 PyObject* obj = wxPyMake_wxObject(&a,false); \
2233 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2234 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2237 wxPyEndBlockThreads(blocked); \
2239 PCLASS::CBNAME(a,b,c); \
2243 //---------------------------------------------------------------------------
2244 // Same as the above set, but the wxRect is not const
2246 #define DEC_PYCALLBACK__DCRECTSIZET2_constpure(CBNAME) \
2247 void CBNAME(wxDC& a, wxRect& b, size_t c) const;
2249 #define IMP_PYCALLBACK__DCRECTSIZET2_constpure(CLASS, PCLASS, CBNAME) \
2250 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2252 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2253 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2254 PyObject* obj = wxPyMake_wxObject(&a,false); \
2255 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2256 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2259 wxPyEndBlockThreads(blocked); \
2264 #define DEC_PYCALLBACK__DCRECTSIZET2_const(CBNAME) \
2265 void CBNAME(wxDC& a, wxRect& b, size_t c) const
2267 #define IMP_PYCALLBACK__DCRECTSIZET2_const(CLASS, PCLASS, CBNAME) \
2268 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2270 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2271 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2272 PyObject* obj = wxPyMake_wxObject(&a,false); \
2273 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2274 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2277 wxPyEndBlockThreads(blocked); \
2279 PCLASS::CBNAME(a,b,c); \
2284 //---------------------------------------------------------------------------
2288 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2289 wxString CBNAME(size_t a) const
2291 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2292 wxString CLASS::CBNAME(size_t a) const { \
2295 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2296 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2298 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2300 rval = Py2wxString(ro); \
2304 wxPyEndBlockThreads(blocked); \
2306 rval = PCLASS::CBNAME(a); \
2310 //---------------------------------------------------------------------------
2312 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2313 wxString CBNAME(size_t a) const
2315 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2316 wxString CLASS::CBNAME(size_t a) const { \
2319 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2320 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2322 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2324 rval = Py2wxString(ro); \
2328 wxPyEndBlockThreads(blocked); \
2332 //---------------------------------------------------------------------------
2334 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2335 wxVisualAttributes CBNAME() const
2338 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2339 wxVisualAttributes CLASS::CBNAME() const { \
2340 wxVisualAttributes rval; \
2342 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2343 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2345 wxVisualAttributes* ptr; \
2346 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2348 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2353 wxPyEndBlockThreads(blocked); \
2355 rval = PCLASS::CBNAME(); \
2359 //---------------------------------------------------------------------------