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>
75 #include <wx/hyperlink.h>
79 # pragma warning(disable:4800)
80 # pragma warning(disable:4190)
83 #ifdef __WXMAC__ // avoid a bug in Carbon headers
87 //---------------------------------------------------------------------------
89 typedef unsigned char byte
;
90 typedef wxPoint2DDouble wxPoint2D
;
92 #ifndef SWIG_TYPE_TABLE
93 #define SWIG_TYPE_TABLE wxPython_type_table
97 #define wxDEFAULT_STATUSBAR_STYLE wxST_SIZEGRIP|wxFULL_REPAINT_ON_RESIZE
99 #define wxDEFAULT_STATUSBAR_STYLE wxST_SIZEGRIP
103 #ifndef wxPyUSE_EXPORTED_API
105 void __wxPyPreStart(PyObject
*);
106 void __wxPyCleanup();
107 PyObject
* __wxPySetDictionary(PyObject
*, PyObject
* args
);
109 void wxSetDefaultPyEncoding(const char* encoding
);
110 const char* wxGetDefaultPyEncoding();
113 void wxPyEventThunker(wxObject
*, wxEvent
& event
);
116 bool wxPyCheckSwigType(const wxChar
* className
);
117 PyObject
* wxPyConstructObject(void* ptr
,
118 const wxChar
* className
,
120 bool wxPyConvertSwigPtr(PyObject
* obj
, void **ptr
,
121 const wxChar
* className
);
122 PyObject
* wxPyMakeSwigPtr(void* ptr
, const wxChar
* classname
);
125 PyObject
* wx2PyString(const wxString
& src
);
126 wxString
Py2wxString(PyObject
* source
);
128 PyObject
* wxPyMake_wxObject(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
=true);
129 PyObject
* wxPyMake_wxSizer(wxSizer
* source
, bool setThisOwn
);
130 void wxPyPtrTypeMap_Add(const char* commonName
, const char* ptrName
);
132 PyObject
* wxPy_ConvertList(wxListBase
* list
);
133 long wxPyGetWinHandle(wxWindow
* win
);
135 void wxPy_ReinitStockObjects(int pass
);
137 bool wxPyInstance_Check(PyObject
* obj
);
138 bool wxPySwigInstance_Check(PyObject
* obj
);
141 #endif // wxPyUSE_EXPORTED_API
142 //---------------------------------------------------------------------------
144 // if we want to handle threads and Python threads are available...
145 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
146 #define WXP_WITH_THREAD
147 #else // no Python threads...
148 #undef WXP_WITH_THREAD
152 // In Python 2.3 and later there are the PyGILState_* APIs that we can use for
153 // blocking threads when calling back into Python. Using them instead of my
154 // home-grown hacks greatly simplifies wxPyBeginBlockThreads and
155 // wxPyEndBlockThreads.
157 // Unfortunatly there is a bug somewhere when using these new APIs on Python
158 // 2.3. It manifests in Boa Constructor's debugger where it is unable to stop
159 // at breakpoints located in event handlers. I think that the cause may be
160 // something like the original PyThreadState for the main thread is not being
161 // restored for the callbacks, but I can't see where that could be
162 // happening... So we'll only activate this new change for Python 2.4+ :-(
164 #if PY_VERSION_HEX < 0x02040000
165 #define wxPyUSE_GIL_STATE 0
166 typedef bool wxPyBlock_t
;
168 #define wxPyUSE_GIL_STATE 1
169 typedef PyGILState_STATE wxPyBlock_t
;
173 #ifndef wxPyUSE_EXPORTED_API
175 // For Python --> C++
176 PyThreadState
* wxPyBeginAllowThreads();
177 void wxPyEndAllowThreads(PyThreadState
* state
);
179 // For C++ --> Python
180 wxPyBlock_t
wxPyBeginBlockThreads();
181 void wxPyEndBlockThreads(wxPyBlock_t blocked
);
183 #endif // wxPyUSE_EXPORTED_API
186 // A macro that will help to execute simple statments wrapped in
187 // StartBlock/EndBlockThreads calls
188 #define wxPyBLOCK_THREADS(stmt) \
189 { wxPyBlock_t blocked = wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads(blocked); }
191 // Raise the NotImplementedError exception (blocking threads)
192 #define wxPyRaiseNotImplemented() \
193 wxPyBLOCK_THREADS(PyErr_SetNone(PyExc_NotImplementedError))
195 // Raise any exception with a string value (blocking threads)
196 #define wxPyErr_SetString(err, str) \
197 wxPyBLOCK_THREADS(PyErr_SetString(err, str))
200 //---------------------------------------------------------------------------
201 // These are helpers used by the typemaps
203 #ifndef wxPyUSE_EXPORTED_API
205 wxString
* wxString_in_helper(PyObject
* source
);
207 byte
* byte_LIST_helper(PyObject
* source
);
208 int* int_LIST_helper(PyObject
* source
);
209 long* long_LIST_helper(PyObject
* source
);
210 char** string_LIST_helper(PyObject
* source
);
211 wxPoint
* wxPoint_LIST_helper(PyObject
* source
, int* npoints
);
212 wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
213 wxString
* wxString_LIST_helper(PyObject
* source
);
214 wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
215 wxPen
** wxPen_LIST_helper(PyObject
* source
);
217 bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
218 bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
219 bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
220 bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
221 bool wxColour_helper(PyObject
* source
, wxColour
** obj
);
222 bool wxPoint2D_helper(PyObject
* source
, wxPoint2D
** obj
);
225 bool wxPySimple_typecheck(PyObject
* source
, const wxChar
* classname
, int seqLen
);
226 bool wxColour_typecheck(PyObject
* source
);
228 bool wxPyCheckForApp();
231 // Other helpful stuff
232 bool wxPy2int_seq_helper(PyObject
* source
, int* i1
, int* i2
);
233 bool wxPy4int_seq_helper(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
235 PyObject
* wxArrayString2PyList_helper(const wxArrayString
& arr
);
236 PyObject
* wxArrayInt2PyList_helper(const wxArrayInt
& arr
);
238 #endif // wxPyUSE_EXPORTED_API
240 //---------------------------------------------------------------------------
242 #if PYTHON_API_VERSION < 1009
243 #define PySequence_Fast_GET_ITEM(o, i) \
244 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
247 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
248 #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name)
249 #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val)
251 //---------------------------------------------------------------------------
253 #ifndef wxPyUSE_EXPORTED_API
255 class wxPyCallback
: public wxObject
{
256 DECLARE_ABSTRACT_CLASS(wxPyCallback
)
258 wxPyCallback(PyObject
* func
);
259 wxPyCallback(const wxPyCallback
& other
);
262 void EventThunker(wxEvent
& event
);
267 #endif // wxPyUSE_EXPORTED_API
268 //---------------------------------------------------------------------------
269 //---------------------------------------------------------------------------
270 // These Event classes can be derived from in Python and passed through the
271 // event system without loosing anything. They do this by keeping a reference
272 // to themselves and some special case handling in wxPyCallback::EventThunker.
276 class wxPyEvtSelfRef
{
281 void SetSelf(PyObject
* self
, bool clone
=false);
282 PyObject
* GetSelf() const;
283 bool GetCloned() const { return m_cloned
; }
291 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
292 DECLARE_ABSTRACT_CLASS(wxPyEvent
)
294 wxPyEvent(int winid
=0, wxEventType commandType
= wxEVT_NULL
);
295 wxPyEvent(const wxPyEvent
& evt
);
298 virtual wxEvent
* Clone() const { return new wxPyEvent(*this); }
302 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
303 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent
)
305 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
306 wxPyCommandEvent(const wxPyCommandEvent
& evt
);
309 virtual wxEvent
* Clone() const { return new wxPyCommandEvent(*this); }
314 //----------------------------------------------------------------------
315 // Forward decalre a few things used in the exported API
316 class wxPyClientData
;
318 class wxPyOORClientData
;
319 class wxPyCBInputStream
;
321 void wxPyClientData_dtor(wxPyClientData
* self
);
322 void wxPyUserData_dtor(wxPyUserData
* self
);
323 void wxPyOORClientData_dtor(wxPyOORClientData
* self
);
324 wxPyCBInputStream
* wxPyCBInputStream_create(PyObject
*py
, bool block
);
325 wxPyCBInputStream
* wxPyCBInputStream_copy(wxPyCBInputStream
* other
);
327 //---------------------------------------------------------------------------
328 // Export a C API in a struct. Other modules will be able to load this from
329 // the wx.core module and will then have safe access to these functions, even if
330 // in another shared library.
332 class wxPyCallbackHelper
;
336 bool (*p_wxPyCheckSwigType
)(const wxChar
* className
);
337 PyObject
* (*p_wxPyConstructObject
)(void* ptr
, const wxChar
* className
, int setThisOwn
);
338 bool (*p_wxPyConvertSwigPtr
)(PyObject
* obj
, void **ptr
, const wxChar
* className
);
339 PyObject
* (*p_wxPyMakeSwigPtr
)(void* ptr
, const wxChar
* className
);
341 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
342 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
343 wxPyBlock_t (*p_wxPyBeginBlockThreads
)();
344 void (*p_wxPyEndBlockThreads
)(wxPyBlock_t blocked
);
346 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
);
348 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
349 wxString (*p_Py2wxString
)(PyObject
* source
);
350 PyObject
* (*p_wx2PyString
)(const wxString
& src
);
352 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
353 int* (*p_int_LIST_helper
)(PyObject
* source
);
354 long* (*p_long_LIST_helper
)(PyObject
* source
);
355 char** (*p_string_LIST_helper
)(PyObject
* source
);
356 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
357 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
358 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
359 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
361 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
362 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
363 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
364 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
365 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
366 bool (*p_wxPoint2D_helper
)(PyObject
* source
, wxPoint2DDouble
** obj
);
369 bool (*p_wxPySimple_typecheck
)(PyObject
* source
, const wxChar
* classname
, int seqLen
);
370 bool (*p_wxColour_typecheck
)(PyObject
* source
);
372 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
373 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
);
374 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
375 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
376 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
378 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
);
379 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
, bool setThisOwn
);
380 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
381 bool (*p_wxPy2int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
);
382 bool (*p_wxPy4int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
383 PyObject
* (*p_wxArrayString2PyList_helper
)(const wxArrayString
& arr
);
384 PyObject
* (*p_wxArrayInt2PyList_helper
)(const wxArrayInt
& arr
);
386 void (*p_wxPyClientData_dtor
)(wxPyClientData
*);
387 void (*p_wxPyUserData_dtor
)(wxPyUserData
*);
388 void (*p_wxPyOORClientData_dtor
)(wxPyOORClientData
*);
390 wxPyCBInputStream
* (*p_wxPyCBInputStream_create
)(PyObject
*py
, bool block
);
391 wxPyCBInputStream
* (*p_wxPyCBInputStream_copy
)(wxPyCBInputStream
* other
);
393 bool (*p_wxPyInstance_Check
)(PyObject
* obj
);
394 bool (*p_wxPySwigInstance_Check
)(PyObject
* obj
);
396 bool (*p_wxPyCheckForApp
)();
400 #ifdef wxPyUSE_EXPORTED_API
401 // Notice that this is static, not extern. This is by design, each module
402 // needs one, but doesn't have to use it.
403 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
;
404 inline wxPyCoreAPI
* wxPyGetCoreAPIPtr();
405 #endif // wxPyUSE_EXPORTED_API
407 //---------------------------------------------------------------------------
409 // A wxObject that holds a reference to a Python object
410 class wxPyUserData
: public wxObject
{
412 wxPyUserData(PyObject
* obj
) {
418 #ifdef wxPyUSE_EXPORTED_API
419 wxPyGetCoreAPIPtr()->p_wxPyUserData_dtor(this);
421 wxPyUserData_dtor(this);
428 // A wxClientData that holds a refernece to a Python object
429 class wxPyClientData
: public wxClientData
{
431 wxPyClientData(PyObject
* obj
, bool incref
=true) {
439 #ifdef wxPyUSE_EXPORTED_API
440 wxPyGetCoreAPIPtr()->p_wxPyClientData_dtor(this);
442 wxPyClientData_dtor(this);
450 // Just like wxPyClientData, except when this object is destroyed it does some
451 // OOR magic on the Python Object.
452 class wxPyOORClientData
: public wxPyClientData
{
454 wxPyOORClientData(PyObject
* obj
, bool incref
=true)
455 : wxPyClientData(obj
, incref
) {}
456 ~wxPyOORClientData() {
458 #ifdef wxPyUSE_EXPORTED_API
459 wxPyGetCoreAPIPtr()->p_wxPyOORClientData_dtor(this);
461 wxPyOORClientData_dtor(this);
467 //---------------------------------------------------------------------------
468 // A wxImageHandler that can be derived from in Python.
471 class wxPyImageHandler
: public wxImageHandler
{
475 // used for interning method names as PyStrings
476 static PyObject
* m_DoCanRead_Name
;
477 static PyObject
* m_GetImageCount_Name
;
478 static PyObject
* m_LoadFile_Name
;
479 static PyObject
* m_SaveFile_Name
;
481 // converstion helpers
482 PyObject
* py_InputStream(wxInputStream
* stream
);
483 PyObject
* py_Image(wxImage
* image
);
484 PyObject
* py_OutputStream(wxOutputStream
* stream
);
489 void _SetSelf(PyObject
*self
);
491 virtual bool LoadFile(wxImage
* image
, wxInputStream
& stream
,
492 bool verbose
=true, int index
=-1 );
493 virtual bool SaveFile(wxImage
* image
, wxOutputStream
& stream
,
495 virtual int GetImageCount(wxInputStream
& stream
);
496 virtual bool DoCanRead(wxInputStream
&stream
);
500 //---------------------------------------------------------------------------
501 // This class holds an instance of a Python Shadow Class object and assists
502 // with looking up and invoking Python callback methods from C++ virtual
503 // method redirections. For all classes which have virtuals which should be
504 // overridable in wxPython, a new subclass is created that contains a
505 // wxPyCallbackHelper.
508 class wxPyCallbackHelper
{
510 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
512 wxPyCallbackHelper() {
519 ~wxPyCallbackHelper() {
520 #ifdef wxPyUSE_EXPORTED_API
521 wxPyGetCoreAPIPtr()->p_wxPyCBH_delete(this);
523 wxPyCBH_delete(this);
527 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=true);
528 bool findCallback(const char* name
, bool setGuard
=true) const;
529 int callCallback(PyObject
* argTuple
) const;
530 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
531 PyObject
* GetLastFound() const { return m_lastFound
; }
533 void setRecursionGuard(PyObject
* method
) const;
534 void clearRecursionGuard(PyObject
* method
) const;
539 PyObject
* m_lastFound
;
542 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
546 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
547 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
=true);
548 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
549 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
550 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
555 //---------------------------------------------------------------------------
557 // This is used in C++ classes that need to be able to make callback to
558 // "overloaded" python methods
561 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
562 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
564 private: wxPyCallbackHelper m_myInst
567 //---------------------------------------------------------------------------
568 // The wxPythonApp class
571 wxPYAPP_ASSERT_SUPPRESS
= 1,
572 wxPYAPP_ASSERT_EXCEPTION
= 2,
573 wxPYAPP_ASSERT_DIALOG
= 4,
574 wxPYAPP_ASSERT_LOG
= 8
577 class wxPyApp
: public wxApp
579 DECLARE_ABSTRACT_CLASS(wxPyApp
)
587 int GetAssertMode() { return m_assertMode
; }
588 void SetAssertMode(int mode
) { m_assertMode
= mode
; }
590 virtual bool OnInitGui();
591 virtual int OnExit();
593 virtual void OnAssert(const wxChar
*file
,
598 virtual void ExitMainLoop();
599 // virtual int FilterEvent(wxEvent& event); // This one too????
601 // For catching Apple Events
602 virtual void MacOpenFile(const wxString
&fileName
);
603 virtual void MacPrintFile(const wxString
&fileName
);
604 virtual void MacNewFile();
605 virtual void MacReopenApp();
607 static bool GetMacSupportPCMenuShortcuts();
608 static long GetMacAboutMenuItemId();
609 static long GetMacPreferencesMenuItemId();
610 static long GetMacExitMenuItemId();
611 static wxString
GetMacHelpMenuTitleName();
613 static void SetMacSupportPCMenuShortcuts(bool val
);
614 static void SetMacAboutMenuItemId(long val
);
615 static void SetMacPreferencesMenuItemId(long val
);
616 static void SetMacExitMenuItemId(long val
);
617 static void SetMacHelpMenuTitleName(const wxString
& val
);
620 void _BootstrapApp();
622 // implementation only
623 void SetStartupComplete(bool val
) { m_startupComplete
= val
; };
627 bool m_startupComplete
;
630 extern wxPyApp
*wxPythonApp
;
633 //----------------------------------------------------------------------
634 // These macros are used to implement the virtual methods that should
635 // redirect to a Python method if one exists. The names designate the
636 // return type, if any, as well as any parameter types.
637 //---------------------------------------------------------------------------
639 #define DEC_PYCALLBACK__(CBNAME) \
643 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
644 void CLASS::CBNAME() { \
646 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
647 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
648 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
649 wxPyEndBlockThreads(blocked); \
654 #define DEC_PYCALLBACK_VOID_(CBNAME) \
655 DEC_PYCALLBACK__(CBNAME)
657 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
658 IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME)
660 //---------------------------------------------------------------------------
662 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
663 bool CBNAME(int a, int b)
666 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
667 bool CLASS::CBNAME(int a, int b) { \
668 bool rval=false, found; \
669 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
670 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
671 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
672 wxPyEndBlockThreads(blocked); \
674 rval = PCLASS::CBNAME(a,b); \
678 //---------------------------------------------------------------------------
680 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
681 void CBNAME(int a, int b)
684 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
685 void CLASS::CBNAME(int a, int b) { \
687 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
688 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
689 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
690 wxPyEndBlockThreads(blocked); \
692 PCLASS::CBNAME(a,b); \
695 //---------------------------------------------------------------------------
697 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
701 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
702 void CLASS::CBNAME(int a) { \
704 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
705 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
706 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
707 wxPyEndBlockThreads(blocked); \
712 //---------------------------------------------------------------------------
714 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
715 void CBNAME(int a, int b, int c, int d)
718 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
719 void CLASS::CBNAME(int a, int b, int c, int d) { \
721 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
722 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
723 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
724 wxPyEndBlockThreads(blocked); \
726 PCLASS::CBNAME(a,b,c,d); \
729 //---------------------------------------------------------------------------
730 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
731 void CBNAME(int a, int b, int c, int d, int e)
734 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
735 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
737 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
738 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
739 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
740 wxPyEndBlockThreads(blocked); \
742 PCLASS::CBNAME(a,b,c,d,e); \
745 //---------------------------------------------------------------------------
747 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
748 void CBNAME(int* a, int* b) const
751 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
752 void CLASS::CBNAME(int* a, int* b) const { \
753 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
755 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
756 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
758 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
760 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
761 PyObject* o1 = PySequence_GetItem(ro, 0); \
762 PyObject* o2 = PySequence_GetItem(ro, 1); \
763 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
764 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
767 PyErr_SetString(PyExc_TypeError, errmsg); \
772 PyErr_SetString(PyExc_TypeError, errmsg); \
777 wxPyEndBlockThreads(blocked); \
779 PCLASS::CBNAME(a,b); \
782 //---------------------------------------------------------------------------
784 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
785 wxSize CBNAME() const
788 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
789 wxSize CLASS::CBNAME() const { \
790 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
791 bool found; wxSize rval(0,0); \
792 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
793 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
795 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
797 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
798 PyObject* o1 = PySequence_GetItem(ro, 0); \
799 PyObject* o2 = PySequence_GetItem(ro, 1); \
800 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
801 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
804 PyErr_SetString(PyExc_TypeError, errmsg); \
809 PyErr_SetString(PyExc_TypeError, errmsg); \
814 wxPyEndBlockThreads(blocked); \
816 return PCLASS::CBNAME(); \
821 //---------------------------------------------------------------------------
823 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
827 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
828 bool CLASS::CBNAME(bool a) { \
829 bool rval=false, found; \
830 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
831 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
832 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
833 wxPyEndBlockThreads(blocked); \
835 rval = PCLASS::CBNAME(a); \
839 //---------------------------------------------------------------------------
841 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
845 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
846 bool CLASS::CBNAME(int a) { \
847 bool rval=false, found; \
848 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
849 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
850 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
851 wxPyEndBlockThreads(blocked); \
853 rval = PCLASS::CBNAME(a); \
857 //---------------------------------------------------------------------------
859 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
863 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
864 bool CLASS::CBNAME(int a) { \
866 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
867 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
868 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
870 wxPyEndBlockThreads(blocked); \
875 //---------------------------------------------------------------------------
877 #define DEC_PYCALLBACK__DC(CBNAME) \
881 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
882 void CLASS::CBNAME(wxDC& a) { \
884 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
885 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
886 PyObject* obj = wxPyMake_wxObject(&a,false); \
887 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
890 wxPyEndBlockThreads(blocked); \
896 //---------------------------------------------------------------------------
898 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
899 void CBNAME(wxDC& a, bool b)
902 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
903 void CLASS::CBNAME(wxDC& a, bool b) { \
905 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
906 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
907 PyObject* obj = wxPyMake_wxObject(&a,false); \
908 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
911 wxPyEndBlockThreads(blocked); \
913 PCLASS::CBNAME(a, b); \
916 //---------------------------------------------------------------------------
918 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
919 void CBNAME(wxDC& a, bool b)
922 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
923 void CLASS::CBNAME(wxDC& a, bool b) { \
925 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
926 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
927 PyObject* obj = wxPyMake_wxObject(&a,false); \
928 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
931 wxPyEndBlockThreads(blocked); \
933 PCLASS::CBNAME(a, b); \
936 //---------------------------------------------------------------------------
938 #define DEC_PYCALLBACK__2DBL(CBNAME) \
939 void CBNAME(double a, double b)
942 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
943 void CLASS::CBNAME(double a, double b) { \
945 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
946 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
947 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
948 wxPyEndBlockThreads(blocked); \
950 PCLASS::CBNAME(a, b); \
953 //---------------------------------------------------------------------------
955 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
956 void CBNAME(double a, double b, int c, int d)
959 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
960 void CLASS::CBNAME(double a, double b, int c, int d) { \
962 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
963 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
964 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
966 wxPyEndBlockThreads(blocked); \
968 PCLASS::CBNAME(a, b, c, d); \
971 //---------------------------------------------------------------------------
973 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
974 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
977 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
978 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
980 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
981 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
982 PyObject* obj = wxPyMake_wxObject(&a,false); \
983 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
986 wxPyEndBlockThreads(blocked); \
988 PCLASS::CBNAME(a, b, c, d, e, f); \
991 //---------------------------------------------------------------------------
993 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
994 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
997 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
998 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1000 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1002 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1003 PyObject* obj = wxPyMake_wxObject(&a,false); \
1004 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1007 wxPyEndBlockThreads(blocked); \
1009 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1013 //---------------------------------------------------------------------------
1015 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1016 void CBNAME(bool a, double b, double c, int d, int e)
1019 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1020 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1022 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1023 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1024 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1026 wxPyEndBlockThreads(blocked); \
1028 PCLASS::CBNAME(a, b, c, d, e); \
1031 //---------------------------------------------------------------------------
1033 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1034 void CBNAME(wxDC& a, double b, double c, double d, double e)
1037 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1038 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1040 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1041 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1042 PyObject* obj = wxPyMake_wxObject(&a,false); \
1043 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1046 wxPyEndBlockThreads(blocked); \
1048 PCLASS::CBNAME(a, b, c, d, e); \
1051 //---------------------------------------------------------------------------
1053 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1054 void CBNAME(wxDC& a, bool b)
1057 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1058 void CLASS::CBNAME(wxDC& a, bool b) { \
1060 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1061 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1062 PyObject* obj = wxPyMake_wxObject(&a,false); \
1063 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1066 wxPyEndBlockThreads(blocked); \
1068 PCLASS::CBNAME(a, b); \
1071 //---------------------------------------------------------------------------
1073 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1074 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1077 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1078 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1081 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1082 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1083 PyObject* obj = wxPyMake_wxObject(a,false); \
1084 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1087 wxPyEndBlockThreads(blocked); \
1089 PCLASS::CBNAME(a, b, c, d, e, f); \
1092 //---------------------------------------------------------------------------
1094 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1095 void CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1098 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1099 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1101 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1102 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1103 PyObject* obj = wxPyMake_wxObject(a,false); \
1104 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1107 wxPyEndBlockThreads(blocked); \
1109 PCLASS::CBNAME(a, b, c, d, e); \
1112 //---------------------------------------------------------------------------
1114 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1115 void CBNAME(double a, double b, int c)
1118 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1119 void CLASS::CBNAME(double a, double b, int c) { \
1121 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1122 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1123 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1124 wxPyEndBlockThreads(blocked); \
1126 PCLASS::CBNAME(a, b, c); \
1129 //---------------------------------------------------------------------------
1131 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1132 void CBNAME(bool a, double b, double c, int d)
1135 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1136 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1138 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1139 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1140 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1141 wxPyEndBlockThreads(blocked); \
1143 PCLASS::CBNAME(a, b, c, d); \
1146 //---------------------------------------------------------------------------
1147 //---------------------------------------------------------------------------
1149 #define DEC_PYCALLBACK__STRING(CBNAME) \
1150 void CBNAME(const wxString& a)
1152 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1153 void CLASS::CBNAME(const wxString& a) { \
1155 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1156 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1157 PyObject* s = wx2PyString(a); \
1158 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1161 wxPyEndBlockThreads(blocked); \
1163 PCLASS::CBNAME(a); \
1166 //---------------------------------------------------------------------------
1168 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1169 bool CBNAME(const wxString& a)
1171 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1172 bool CLASS::CBNAME(const wxString& a) { \
1175 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1176 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1177 PyObject* s = wx2PyString(a); \
1178 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1181 wxPyEndBlockThreads(blocked); \
1183 rval = PCLASS::CBNAME(a); \
1187 //---------------------------------------------------------------------------
1189 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1190 bool CBNAME(const wxString& a)
1192 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1193 bool CLASS::CBNAME(const wxString& a) { \
1195 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1196 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1197 PyObject* s = wx2PyString(a); \
1198 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1201 wxPyEndBlockThreads(blocked); \
1205 //---------------------------------------------------------------------------
1207 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1208 wxString CBNAME(const wxString& a)
1210 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1211 wxString CLASS::CBNAME(const wxString& a) { \
1213 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1214 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1216 PyObject* s = wx2PyString(a); \
1217 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1220 rval = Py2wxString(ro); \
1224 wxPyEndBlockThreads(blocked); \
1228 //---------------------------------------------------------------------------
1230 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1231 wxString CBNAME(const wxString& a)
1233 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1234 wxString CLASS::CBNAME(const wxString& a) { \
1237 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1238 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1240 PyObject* s = wx2PyString(a); \
1241 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1244 rval = Py2wxString(ro); \
1249 rval = PCLASS::CBNAME(a); \
1250 wxPyEndBlockThreads(blocked); \
1254 //---------------------------------------------------------------------------
1256 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1257 wxString CBNAME(const wxString& a,int b)
1259 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1260 wxString CLASS::CBNAME(const wxString& a,int b) { \
1262 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1263 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1265 PyObject* s = wx2PyString(a); \
1266 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1269 rval = Py2wxString(ro); \
1273 wxPyEndBlockThreads(blocked); \
1277 //---------------------------------------------------------------------------
1279 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1280 bool CBNAME(const wxString& a, const wxString& b)
1282 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1283 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1286 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1287 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1288 PyObject* s1 = wx2PyString(a); \
1289 PyObject* s2 = wx2PyString(b); \
1290 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1294 wxPyEndBlockThreads(blocked); \
1296 rval = PCLASS::CBNAME(a, b); \
1300 //---------------------------------------------------------------------------
1302 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1305 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1306 wxString CLASS::CBNAME() { \
1309 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1310 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1312 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1314 rval = Py2wxString(ro); \
1318 wxPyEndBlockThreads(blocked); \
1320 rval = PCLASS::CBNAME(); \
1324 //---------------------------------------------------------------------------
1326 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1327 wxString CBNAME() const
1329 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1330 wxString CLASS::CBNAME() const { \
1333 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1334 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1336 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1338 rval = Py2wxString(ro); \
1342 wxPyEndBlockThreads(blocked); \
1344 rval = PCLASS::CBNAME(); \
1348 //---------------------------------------------------------------------------
1350 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1353 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1354 wxString CLASS::CBNAME() { \
1356 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1357 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1359 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1361 rval = Py2wxString(ro); \
1365 wxPyEndBlockThreads(blocked); \
1369 //---------------------------------------------------------------------------
1371 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1372 wxString CBNAME() const;
1374 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1375 wxString CLASS::CBNAME() const { \
1377 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1378 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1380 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1382 rval = Py2wxString(ro); \
1386 wxPyEndBlockThreads(blocked); \
1390 //---------------------------------------------------------------------------
1392 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1393 bool CBNAME(const wxHtmlTag& a)
1396 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1397 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1399 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1400 if (wxPyCBH_findCallback2(m_myInst, #CBNAME, false)) { \
1401 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
1402 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1405 wxPyEndBlockThreads(blocked); \
1409 //---------------------------------------------------------------------------
1411 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1412 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1414 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1415 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1417 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1418 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1419 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1420 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1423 wxPyEndBlockThreads(blocked); \
1425 PCLASS::CBNAME(cell, x, y); \
1428 //---------------------------------------------------------------------------
1430 #define DEC_PYCALLBACK__COLOUR(CBNAME) \
1431 void CBNAME(const wxColour& c);
1433 #define IMP_PYCALLBACK__COLOUR(CLASS, PCLASS, CBNAME) \
1434 void CLASS::CBNAME(const wxColour& c) { \
1436 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1437 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1438 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1439 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1442 wxPyEndBlockThreads(blocked); \
1444 PCLASS::CBNAME(c); \
1447 //---------------------------------------------------------------------------
1449 #define DEC_PYCALLBACK_BOOL_CELLINTINTME(CBNAME) \
1450 bool CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1452 #define IMP_PYCALLBACK_BOOL_CELLINTINTME(CLASS, PCLASS, CBNAME) \
1453 bool CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1454 bool rval=false, found; \
1455 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1456 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1457 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1458 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1459 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1463 wxPyEndBlockThreads(blocked); \
1465 rval = PCLASS::CBNAME(cell, x, y, e); \
1470 //---------------------------------------------------------------------------
1472 #define DEC_PYCALLBACK___pure(CBNAME) \
1476 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1477 void CLASS::CBNAME() { \
1478 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1479 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1480 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1481 wxPyEndBlockThreads(blocked); \
1484 //---------------------------------------------------------------------------
1486 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1490 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1491 wxSize CLASS::CBNAME() { \
1492 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1494 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1495 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1498 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1500 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1502 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1504 PyObject* o1 = PySequence_GetItem(ro, 0); \
1505 PyObject* o2 = PySequence_GetItem(ro, 1); \
1506 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1507 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1509 PyErr_SetString(PyExc_TypeError, errmsg); \
1514 PyErr_SetString(PyExc_TypeError, errmsg); \
1519 wxPyEndBlockThreads(blocked); \
1523 //---------------------------------------------------------------------------
1525 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1526 bool CBNAME(wxWindow* a)
1529 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1530 bool CLASS::CBNAME(wxWindow* a) { \
1533 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1534 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1535 PyObject* obj = wxPyMake_wxObject(a,false); \
1536 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1539 wxPyEndBlockThreads(blocked); \
1541 rval = PCLASS::CBNAME(a); \
1545 //---------------------------------------------------------------------------
1547 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1548 bool CBNAME(wxWindow* a, wxDC& b)
1551 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1552 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1555 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1556 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1557 PyObject* win = wxPyMake_wxObject(a,false); \
1558 PyObject* dc = wxPyMake_wxObject(&b,false); \
1559 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1563 wxPyEndBlockThreads(blocked); \
1565 rval = PCLASS::CBNAME(a, b); \
1569 //---------------------------------------------------------------------------
1571 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1572 void CBNAME(wxWindowBase* a)
1575 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1576 void CLASS::CBNAME(wxWindowBase* a) { \
1578 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1579 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1580 PyObject* obj = wxPyMake_wxObject(a,false); \
1581 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1584 wxPyEndBlockThreads(blocked); \
1586 PCLASS::CBNAME(a); \
1589 //---------------------------------------------------------------------------
1591 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1595 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1596 bool CLASS::CBNAME() { \
1599 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1600 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1601 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1602 wxPyEndBlockThreads(blocked); \
1604 rval = PCLASS::CBNAME(); \
1608 //---------------------------------------------------------------------------
1610 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1614 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1615 bool CLASS::CBNAME() const { \
1618 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1619 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1620 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1621 wxPyEndBlockThreads(blocked); \
1623 rval = PCLASS::CBNAME(); \
1627 //---------------------------------------------------------------------------
1629 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1630 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1633 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1634 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1637 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1638 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1639 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1640 wxPyEndBlockThreads(blocked); \
1642 rval = PCLASS::CBNAME(a, b, c); \
1643 return (wxDragResult)rval; \
1646 //---------------------------------------------------------------------------
1648 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1649 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1651 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1652 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1653 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1655 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1657 PyObject* obj = wxPyMake_wxObject(&a,false); \
1658 PyObject* s = wx2PyString(b); \
1659 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1662 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
1668 wxPyEndBlockThreads(blocked); \
1672 //---------------------------------------------------------------------------
1674 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1675 bool CBNAME(wxDragResult a)
1678 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1679 bool CLASS::CBNAME(wxDragResult a) { \
1682 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1683 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1684 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1685 wxPyEndBlockThreads(blocked); \
1687 rval = PCLASS::CBNAME(a); \
1691 //---------------------------------------------------------------------------
1693 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1694 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1697 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1698 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1699 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1701 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1702 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1703 wxPyEndBlockThreads(blocked); \
1704 return (wxDragResult)rval; \
1707 //---------------------------------------------------------------------------
1709 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1710 bool CBNAME(int a, int b, const wxString& c)
1712 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1713 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1715 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1716 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1717 PyObject* s = wx2PyString(c); \
1718 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1721 wxPyEndBlockThreads(blocked); \
1725 //---------------------------------------------------------------------------
1727 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1731 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1732 size_t CLASS::CBNAME() { \
1735 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1736 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1737 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1738 wxPyEndBlockThreads(blocked); \
1740 rval = PCLASS::CBNAME(); \
1744 //---------------------------------------------------------------------------
1746 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1747 size_t CBNAME() const
1750 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1751 size_t CLASS::CBNAME() const { \
1754 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1755 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1756 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1757 wxPyEndBlockThreads(blocked); \
1759 rval = PCLASS::CBNAME(); \
1763 //---------------------------------------------------------------------------
1765 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1766 wxDataFormat CBNAME(size_t a)
1769 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1770 wxDataFormat CLASS::CBNAME(size_t a) { \
1771 wxDataFormat rval=0; \
1773 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1774 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1776 wxDataFormat* ptr; \
1777 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1779 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1784 wxPyEndBlockThreads(blocked); \
1786 rval = PCLASS::CBNAME(a); \
1790 //---------------------------------------------------------------------------
1792 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1793 void CBNAME(const Type& a)
1796 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1797 void CLASS::CBNAME(const Type& a) { \
1799 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1800 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1801 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1802 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1805 wxPyEndBlockThreads(blocked); \
1807 PCLASS::CBNAME(a); \
1811 //---------------------------------------------------------------------------
1813 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1814 void CBNAME(Type& a)
1817 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1818 void CLASS::CBNAME(Type& a) { \
1820 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1821 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1822 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1823 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1826 wxPyEndBlockThreads(blocked); \
1828 PCLASS::CBNAME(a); \
1831 //---------------------------------------------------------------------------
1833 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1834 bool CBNAME(Type& a)
1837 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1838 bool CLASS::CBNAME(Type& a) { \
1841 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1842 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1843 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1844 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1847 wxPyEndBlockThreads(blocked); \
1849 rv = PCLASS::CBNAME(a); \
1853 //---------------------------------------------------------------------------
1855 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
1856 bool CBNAME(Type& a)
1859 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
1860 bool CLASS::CBNAME(Type& a) { \
1862 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1863 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1864 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1865 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1868 wxPyEndBlockThreads(blocked); \
1872 //---------------------------------------------------------------------------
1874 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1875 wxString CBNAME(long a, long b) const
1877 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1878 wxString CLASS::CBNAME(long a, long b) const { \
1881 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1882 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1884 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1886 rval = Py2wxString(ro); \
1890 wxPyEndBlockThreads(blocked); \
1892 rval = PCLASS::CBNAME(a,b); \
1896 //---------------------------------------------------------------------------
1898 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1899 int CBNAME(long a) const
1902 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1903 int CLASS::CBNAME(long a) const { \
1906 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1907 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1909 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1911 rval = PyInt_AsLong(ro); \
1915 wxPyEndBlockThreads(blocked); \
1917 rval = PCLASS::CBNAME(a); \
1922 #define DEC_PYCALLBACK_INT_LONG_virtual(CBNAME) \
1923 int CBNAME(long a) const;
1926 #define IMP_PYCALLBACK_INT_LONG_virtual(CLASS, PCLASS, CBNAME) \
1927 int CLASS::CBNAME(long a) const { \
1928 int rval=-1; /* this rval is important for OnGetItemImage */ \
1930 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1931 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1933 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1935 rval = PyInt_AsLong(ro); \
1939 wxPyEndBlockThreads(blocked); \
1944 //---------------------------------------------------------------------------
1946 #define DEC_PYCALLBACK_INT_LONGLONG(CBNAME) \
1947 int CBNAME(long a, long b) const
1950 #define IMP_PYCALLBACK_INT_LONGLONG(CLASS, PCLASS, CBNAME) \
1951 int CLASS::CBNAME(long a, long b) const { \
1954 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1955 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1957 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1959 rval = PyInt_AsLong(ro); \
1963 wxPyEndBlockThreads(blocked); \
1965 rval = PCLASS::CBNAME(a, b); \
1970 #define DEC_PYCALLBACK_INT_LONGLONG_virtual(CBNAME) \
1971 int CBNAME(long a, long b) const;
1974 #define IMP_PYCALLBACK_INT_LONGLONG_virtual(CLASS, PCLASS, CBNAME) \
1975 int CLASS::CBNAME(long a, long b) const { \
1976 int rval=-1; /* this rval is important for OnGetItemImage */ \
1978 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1979 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1981 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1983 rval = PyInt_AsLong(ro); \
1987 wxPyEndBlockThreads(blocked); \
1992 //---------------------------------------------------------------------------
1994 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
1995 wxListItemAttr* CBNAME(long a) const
1998 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
1999 wxListItemAttr *CLASS::CBNAME(long a) const { \
2000 wxListItemAttr *rval = NULL; \
2002 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2003 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2005 wxListItemAttr* ptr; \
2006 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2008 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2013 wxPyEndBlockThreads(blocked); \
2015 rval = PCLASS::CBNAME(a); \
2019 //---------------------------------------------------------------------------
2021 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2022 bool CBNAME(wxMouseEvent& e)
2024 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2025 bool CLASS::CBNAME(wxMouseEvent& e) { \
2028 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2029 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2031 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2032 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2034 rval = PyInt_AsLong(ro); \
2039 wxPyEndBlockThreads(blocked); \
2041 return PCLASS::CBNAME(e); \
2045 //---------------------------------------------------------------------------
2047 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2048 wxWizardPage* CBNAME() const
2050 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2051 wxWizardPage* CLASS::CBNAME() const { \
2052 wxWizardPage* rv = NULL; \
2053 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2054 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2056 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2058 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2062 wxPyEndBlockThreads(blocked); \
2066 //---------------------------------------------------------------------------
2068 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2069 wxBitmap CBNAME() const
2071 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2072 wxBitmap CLASS::CBNAME() const { \
2074 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2075 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2078 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2080 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2085 wxPyEndBlockThreads(blocked); \
2089 //---------------------------------------------------------------------------
2091 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2094 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2095 wxObject* CLASS::CBNAME() { \
2096 wxObject* rv = NULL; \
2097 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2098 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2100 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2102 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2106 wxPyEndBlockThreads(blocked); \
2110 //---------------------------------------------------------------------------
2112 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2113 wxObject* CBNAME(const wxString& a)
2115 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2116 wxObject* CLASS::CBNAME(const wxString& a) { \
2117 wxObject* rv = NULL; \
2118 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2119 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2120 PyObject* so = wx2PyString(a); \
2122 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2124 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2129 wxPyEndBlockThreads(blocked); \
2133 //---------------------------------------------------------------------------
2135 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2136 bool CBNAME(wxXmlNode* a)
2139 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2140 bool CLASS::CBNAME(wxXmlNode* a) { \
2142 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2143 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2144 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2145 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2148 wxPyEndBlockThreads(blocked); \
2152 //---------------------------------------------------------------------------
2154 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2155 wxCoord CBNAME(size_t a) const
2158 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2159 wxCoord CLASS::CBNAME(size_t a) const { \
2162 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2163 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2164 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2166 wxPyEndBlockThreads(blocked); \
2170 //---------------------------------------------------------------------------
2172 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2173 void CBNAME(size_t a, size_t b) const
2176 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2177 void CLASS::CBNAME(size_t a, size_t b) const { \
2179 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2180 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2181 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2182 wxPyEndBlockThreads(blocked); \
2184 PCLASS::CBNAME(a,b); \
2186 //---------------------------------------------------------------------------
2188 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2189 wxCoord CBNAME() const
2192 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2193 wxCoord CLASS::CBNAME() const { \
2196 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2197 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2198 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2199 wxPyEndBlockThreads(blocked); \
2201 rval = PCLASS::CBNAME(); \
2205 //---------------------------------------------------------------------------
2207 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2208 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2210 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2211 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2213 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2214 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2215 PyObject* obj = wxPyMake_wxObject(&a,false); \
2216 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2217 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2220 wxPyEndBlockThreads(blocked); \
2225 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2226 void CBNAME(wxDC& a, const wxRect& b, size_t c) const
2228 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2229 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2231 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2232 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2233 PyObject* obj = wxPyMake_wxObject(&a,false); \
2234 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2235 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2238 wxPyEndBlockThreads(blocked); \
2240 PCLASS::CBNAME(a,b,c); \
2244 //---------------------------------------------------------------------------
2245 // Same as the above set, but the wxRect is not const
2247 #define DEC_PYCALLBACK__DCRECTSIZET2_constpure(CBNAME) \
2248 void CBNAME(wxDC& a, wxRect& b, size_t c) const;
2250 #define IMP_PYCALLBACK__DCRECTSIZET2_constpure(CLASS, PCLASS, CBNAME) \
2251 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2253 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2254 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2255 PyObject* obj = wxPyMake_wxObject(&a,false); \
2256 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2257 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2260 wxPyEndBlockThreads(blocked); \
2265 #define DEC_PYCALLBACK__DCRECTSIZET2_const(CBNAME) \
2266 void CBNAME(wxDC& a, wxRect& b, size_t c) const
2268 #define IMP_PYCALLBACK__DCRECTSIZET2_const(CLASS, PCLASS, CBNAME) \
2269 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2271 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2272 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2273 PyObject* obj = wxPyMake_wxObject(&a,false); \
2274 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2275 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2278 wxPyEndBlockThreads(blocked); \
2280 PCLASS::CBNAME(a,b,c); \
2285 //---------------------------------------------------------------------------
2289 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2290 wxString CBNAME(size_t a) const
2292 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2293 wxString CLASS::CBNAME(size_t a) const { \
2296 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2297 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2299 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2301 rval = Py2wxString(ro); \
2305 wxPyEndBlockThreads(blocked); \
2307 rval = PCLASS::CBNAME(a); \
2311 //---------------------------------------------------------------------------
2313 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2314 wxString CBNAME(size_t a) const
2316 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2317 wxString CLASS::CBNAME(size_t a) const { \
2320 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2321 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2323 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2325 rval = Py2wxString(ro); \
2329 wxPyEndBlockThreads(blocked); \
2333 //---------------------------------------------------------------------------
2335 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2336 wxVisualAttributes CBNAME() const
2339 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2340 wxVisualAttributes CLASS::CBNAME() const { \
2341 wxVisualAttributes rval; \
2343 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2344 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2346 wxVisualAttributes* ptr; \
2347 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2349 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2354 wxPyEndBlockThreads(blocked); \
2356 rval = PCLASS::CBNAME(); \
2360 //---------------------------------------------------------------------------