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>
76 #include <wx/pickerbase.h>
77 #include <wx/clrpicker.h>
78 #include <wx/filepicker.h>
79 #include <wx/fontpicker.h>
83 # pragma warning(disable:4800)
84 # pragma warning(disable:4190)
87 #ifdef __WXMAC__ // avoid a bug in Carbon headers
91 //---------------------------------------------------------------------------
93 #ifndef wxHAS_POWER_EVENTS
94 class wxPowerEvent
: public wxEvent
97 wxPowerEvent(wxEventType evtType
) : wxEvent(wxID_NONE
, evtType
) {}
99 bool IsVetoed() const { return false; }
100 virtual wxEvent
*Clone() const { return new wxPowerEvent(*this); }
104 //---------------------------------------------------------------------------
105 typedef unsigned char byte
;
106 typedef wxPoint2DDouble wxPoint2D
;
108 #ifndef SWIG_TYPE_TABLE
109 #define SWIG_TYPE_TABLE wxPython_type_table
113 #define wxDEFAULT_STATUSBAR_STYLE wxST_SIZEGRIP|wxFULL_REPAINT_ON_RESIZE
115 #define wxDEFAULT_STATUSBAR_STYLE wxST_SIZEGRIP
119 #ifndef wxPyUSE_EXPORTED_API
121 void __wxPyPreStart(PyObject
*);
122 void __wxPyCleanup();
123 PyObject
* __wxPySetDictionary(PyObject
*, PyObject
* args
);
125 void wxSetDefaultPyEncoding(const char* encoding
);
126 const char* wxGetDefaultPyEncoding();
129 void wxPyEventThunker(wxObject
*, wxEvent
& event
);
132 bool wxPyCheckSwigType(const wxChar
* className
);
133 PyObject
* wxPyConstructObject(void* ptr
,
134 const wxChar
* className
,
136 bool wxPyConvertSwigPtr(PyObject
* obj
, void **ptr
,
137 const wxChar
* className
);
138 PyObject
* wxPyMakeSwigPtr(void* ptr
, const wxChar
* classname
);
141 PyObject
* wx2PyString(const wxString
& src
);
142 wxString
Py2wxString(PyObject
* source
);
144 PyObject
* wxPyMake_wxObject(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
=true);
145 PyObject
* wxPyMake_wxSizer(wxSizer
* source
, bool setThisOwn
);
146 void wxPyPtrTypeMap_Add(const char* commonName
, const char* ptrName
);
148 PyObject
* wxPy_ConvertList(wxListBase
* list
);
149 long wxPyGetWinHandle(wxWindow
* win
);
151 void wxPy_ReinitStockObjects(int pass
);
153 bool wxPyInstance_Check(PyObject
* obj
);
154 bool wxPySwigInstance_Check(PyObject
* obj
);
157 #endif // wxPyUSE_EXPORTED_API
158 //---------------------------------------------------------------------------
160 // if we want to handle threads and Python threads are available...
161 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
162 #define WXP_WITH_THREAD
163 #else // no Python threads...
164 #undef WXP_WITH_THREAD
168 // In Python 2.3 and later there are the PyGILState_* APIs that we can use for
169 // blocking threads when calling back into Python. Using them instead of my
170 // home-grown hacks greatly simplifies wxPyBeginBlockThreads and
171 // wxPyEndBlockThreads.
173 // Unfortunatly there is a bug somewhere when using these new APIs on Python
174 // 2.3. It manifests in Boa Constructor's debugger where it is unable to stop
175 // at breakpoints located in event handlers. I think that the cause may be
176 // something like the original PyThreadState for the main thread is not being
177 // restored for the callbacks, but I can't see where that could be
178 // happening... So we'll only activate this new change for Python 2.4+ :-(
180 #if PY_VERSION_HEX < 0x02040000
181 #define wxPyUSE_GIL_STATE 0
182 typedef bool wxPyBlock_t
;
184 #define wxPyUSE_GIL_STATE 1
185 typedef PyGILState_STATE wxPyBlock_t
;
189 // Python 2.5 changes the type of some API parameter and return types. Using
190 // this typedef for versions < 2.5 will help with the transition...
191 #if PY_VERSION_HEX < 0x02050000
192 typedef int Py_ssize_t
;
196 #ifndef wxPyUSE_EXPORTED_API
198 // For Python --> C++
199 PyThreadState
* wxPyBeginAllowThreads();
200 void wxPyEndAllowThreads(PyThreadState
* state
);
202 // For C++ --> Python
203 wxPyBlock_t
wxPyBeginBlockThreads();
204 void wxPyEndBlockThreads(wxPyBlock_t blocked
);
206 #endif // wxPyUSE_EXPORTED_API
209 // A macro that will help to execute simple statments wrapped in
210 // StartBlock/EndBlockThreads calls
211 #define wxPyBLOCK_THREADS(stmt) \
212 { wxPyBlock_t blocked = wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads(blocked); }
214 // Raise the NotImplementedError exception (blocking threads)
215 #define wxPyRaiseNotImplemented() \
216 wxPyBLOCK_THREADS(PyErr_SetNone(PyExc_NotImplementedError))
218 // Raise any exception with a string value (blocking threads)
219 #define wxPyErr_SetString(err, str) \
220 wxPyBLOCK_THREADS(PyErr_SetString(err, str))
223 //---------------------------------------------------------------------------
224 // These are helpers used by the typemaps
226 #ifndef wxPyUSE_EXPORTED_API
228 wxString
* wxString_in_helper(PyObject
* source
);
230 byte
* byte_LIST_helper(PyObject
* source
);
231 int* int_LIST_helper(PyObject
* source
);
232 long* long_LIST_helper(PyObject
* source
);
233 char** string_LIST_helper(PyObject
* source
);
234 wxPoint
* wxPoint_LIST_helper(PyObject
* source
, int* npoints
);
235 wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
236 wxString
* wxString_LIST_helper(PyObject
* source
);
237 wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
238 wxPen
** wxPen_LIST_helper(PyObject
* source
);
240 bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
241 bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
242 bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
243 bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
244 bool wxColour_helper(PyObject
* source
, wxColour
** obj
);
245 bool wxPoint2D_helper(PyObject
* source
, wxPoint2D
** obj
);
248 bool wxPySimple_typecheck(PyObject
* source
, const wxChar
* classname
, int seqLen
);
249 bool wxColour_typecheck(PyObject
* source
);
251 bool wxPyCheckForApp();
254 // Other helpful stuff
255 bool wxPy2int_seq_helper(PyObject
* source
, int* i1
, int* i2
);
256 bool wxPy4int_seq_helper(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
258 PyObject
* wxArrayString2PyList_helper(const wxArrayString
& arr
);
259 PyObject
* wxArrayInt2PyList_helper(const wxArrayInt
& arr
);
261 #endif // wxPyUSE_EXPORTED_API
263 //---------------------------------------------------------------------------
265 #if PYTHON_API_VERSION < 1009
266 #define PySequence_Fast_GET_ITEM(o, i) \
267 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
270 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
271 #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name)
272 #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val)
274 //---------------------------------------------------------------------------
276 #ifndef wxPyUSE_EXPORTED_API
278 class wxPyCallback
: public wxObject
{
279 DECLARE_ABSTRACT_CLASS(wxPyCallback
)
281 wxPyCallback(PyObject
* func
);
282 wxPyCallback(const wxPyCallback
& other
);
285 void EventThunker(wxEvent
& event
);
290 #endif // wxPyUSE_EXPORTED_API
291 //---------------------------------------------------------------------------
292 //---------------------------------------------------------------------------
293 // These Event classes can be derived from in Python and passed through the
294 // event system without loosing anything. They do this by keeping a reference
295 // to themselves and some special case handling in wxPyCallback::EventThunker.
299 class wxPyEvtSelfRef
{
304 void SetSelf(PyObject
* self
, bool clone
=false);
305 PyObject
* GetSelf() const;
306 bool GetCloned() const { return m_cloned
; }
314 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
315 DECLARE_ABSTRACT_CLASS(wxPyEvent
)
317 wxPyEvent(int winid
=0, wxEventType commandType
= wxEVT_NULL
);
318 wxPyEvent(const wxPyEvent
& evt
);
321 virtual wxEvent
* Clone() const { return new wxPyEvent(*this); }
325 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
326 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent
)
328 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
329 wxPyCommandEvent(const wxPyCommandEvent
& evt
);
332 virtual wxEvent
* Clone() const { return new wxPyCommandEvent(*this); }
337 //----------------------------------------------------------------------
338 // Forward decalre a few things used in the exported API
339 class wxPyClientData
;
341 class wxPyOORClientData
;
342 class wxPyCBInputStream
;
344 void wxPyClientData_dtor(wxPyClientData
* self
);
345 void wxPyUserData_dtor(wxPyUserData
* self
);
346 void wxPyOORClientData_dtor(wxPyOORClientData
* self
);
347 wxPyCBInputStream
* wxPyCBInputStream_create(PyObject
*py
, bool block
);
348 wxPyCBInputStream
* wxPyCBInputStream_copy(wxPyCBInputStream
* other
);
350 //---------------------------------------------------------------------------
351 // Export a C API in a struct. Other modules will be able to load this from
352 // the wx.core module and will then have safe access to these functions, even if
353 // in another shared library.
355 class wxPyCallbackHelper
;
359 bool (*p_wxPyCheckSwigType
)(const wxChar
* className
);
360 PyObject
* (*p_wxPyConstructObject
)(void* ptr
, const wxChar
* className
, int setThisOwn
);
361 bool (*p_wxPyConvertSwigPtr
)(PyObject
* obj
, void **ptr
, const wxChar
* className
);
362 PyObject
* (*p_wxPyMakeSwigPtr
)(void* ptr
, const wxChar
* className
);
364 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
365 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
366 wxPyBlock_t (*p_wxPyBeginBlockThreads
)();
367 void (*p_wxPyEndBlockThreads
)(wxPyBlock_t blocked
);
369 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
);
371 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
372 wxString (*p_Py2wxString
)(PyObject
* source
);
373 PyObject
* (*p_wx2PyString
)(const wxString
& src
);
375 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
376 int* (*p_int_LIST_helper
)(PyObject
* source
);
377 long* (*p_long_LIST_helper
)(PyObject
* source
);
378 char** (*p_string_LIST_helper
)(PyObject
* source
);
379 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
380 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
381 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
382 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
384 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
385 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
386 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
387 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
388 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
389 bool (*p_wxPoint2D_helper
)(PyObject
* source
, wxPoint2DDouble
** obj
);
392 bool (*p_wxPySimple_typecheck
)(PyObject
* source
, const wxChar
* classname
, int seqLen
);
393 bool (*p_wxColour_typecheck
)(PyObject
* source
);
395 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
396 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
);
397 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
398 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
399 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
401 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
);
402 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
, bool setThisOwn
);
403 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
404 bool (*p_wxPy2int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
);
405 bool (*p_wxPy4int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
406 PyObject
* (*p_wxArrayString2PyList_helper
)(const wxArrayString
& arr
);
407 PyObject
* (*p_wxArrayInt2PyList_helper
)(const wxArrayInt
& arr
);
409 void (*p_wxPyClientData_dtor
)(wxPyClientData
*);
410 void (*p_wxPyUserData_dtor
)(wxPyUserData
*);
411 void (*p_wxPyOORClientData_dtor
)(wxPyOORClientData
*);
413 wxPyCBInputStream
* (*p_wxPyCBInputStream_create
)(PyObject
*py
, bool block
);
414 wxPyCBInputStream
* (*p_wxPyCBInputStream_copy
)(wxPyCBInputStream
* other
);
416 bool (*p_wxPyInstance_Check
)(PyObject
* obj
);
417 bool (*p_wxPySwigInstance_Check
)(PyObject
* obj
);
419 bool (*p_wxPyCheckForApp
)();
423 #ifdef wxPyUSE_EXPORTED_API
424 // Notice that this is static, not extern. This is by design, each module
425 // needs one, but doesn't have to use it.
426 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
;
427 inline wxPyCoreAPI
* wxPyGetCoreAPIPtr();
428 #endif // wxPyUSE_EXPORTED_API
430 //---------------------------------------------------------------------------
432 // A wxObject that holds a reference to a Python object
433 class wxPyUserData
: public wxObject
{
435 wxPyUserData(PyObject
* obj
) {
441 #ifdef wxPyUSE_EXPORTED_API
442 wxPyGetCoreAPIPtr()->p_wxPyUserData_dtor(this);
444 wxPyUserData_dtor(this);
451 // A wxClientData that holds a refernece to a Python object
452 class wxPyClientData
: public wxClientData
{
454 wxPyClientData(PyObject
* obj
, bool incref
=true) {
462 #ifdef wxPyUSE_EXPORTED_API
463 wxPyGetCoreAPIPtr()->p_wxPyClientData_dtor(this);
465 wxPyClientData_dtor(this);
473 // Just like wxPyClientData, except when this object is destroyed it does some
474 // OOR magic on the Python Object.
475 class wxPyOORClientData
: public wxPyClientData
{
477 wxPyOORClientData(PyObject
* obj
, bool incref
=true)
478 : wxPyClientData(obj
, incref
) {}
479 ~wxPyOORClientData() {
481 #ifdef wxPyUSE_EXPORTED_API
482 wxPyGetCoreAPIPtr()->p_wxPyOORClientData_dtor(this);
484 wxPyOORClientData_dtor(this);
490 //---------------------------------------------------------------------------
491 // A wxImageHandler that can be derived from in Python.
494 class wxPyImageHandler
: public wxImageHandler
{
498 // used for interning method names as PyStrings
499 static PyObject
* m_DoCanRead_Name
;
500 static PyObject
* m_GetImageCount_Name
;
501 static PyObject
* m_LoadFile_Name
;
502 static PyObject
* m_SaveFile_Name
;
504 // converstion helpers
505 PyObject
* py_InputStream(wxInputStream
* stream
);
506 PyObject
* py_Image(wxImage
* image
);
507 PyObject
* py_OutputStream(wxOutputStream
* stream
);
512 void _SetSelf(PyObject
*self
);
514 virtual bool LoadFile(wxImage
* image
, wxInputStream
& stream
,
515 bool verbose
=true, int index
=-1 );
516 virtual bool SaveFile(wxImage
* image
, wxOutputStream
& stream
,
518 virtual int GetImageCount(wxInputStream
& stream
);
519 virtual bool DoCanRead(wxInputStream
&stream
);
523 //---------------------------------------------------------------------------
524 // This class holds an instance of a Python Shadow Class object and assists
525 // with looking up and invoking Python callback methods from C++ virtual
526 // method redirections. For all classes which have virtuals which should be
527 // overridable in wxPython, a new subclass is created that contains a
528 // wxPyCallbackHelper.
531 class wxPyCallbackHelper
{
533 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
535 wxPyCallbackHelper() {
542 ~wxPyCallbackHelper() {
543 #ifdef wxPyUSE_EXPORTED_API
544 wxPyGetCoreAPIPtr()->p_wxPyCBH_delete(this);
546 wxPyCBH_delete(this);
550 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=true);
551 bool findCallback(const char* name
, bool setGuard
=true) const;
552 int callCallback(PyObject
* argTuple
) const;
553 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
554 PyObject
* GetLastFound() const { return m_lastFound
; }
556 void setRecursionGuard(PyObject
* method
) const;
557 void clearRecursionGuard(PyObject
* method
) const;
562 PyObject
* m_lastFound
;
565 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
569 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
570 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
=true);
571 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
572 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
573 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
578 //---------------------------------------------------------------------------
580 // This is used in C++ classes that need to be able to make callback to
581 // "overloaded" python methods
584 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
585 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
587 private: wxPyCallbackHelper m_myInst
590 //---------------------------------------------------------------------------
591 // The wxPythonApp class
594 wxPYAPP_ASSERT_SUPPRESS
= 1,
595 wxPYAPP_ASSERT_EXCEPTION
= 2,
596 wxPYAPP_ASSERT_DIALOG
= 4,
597 wxPYAPP_ASSERT_LOG
= 8
600 class wxPyApp
: public wxApp
602 DECLARE_ABSTRACT_CLASS(wxPyApp
)
610 int GetAssertMode() { return m_assertMode
; }
611 void SetAssertMode(int mode
) { m_assertMode
= mode
; }
613 virtual bool OnInitGui();
614 virtual int OnExit();
616 virtual void OnAssertFailure(const wxChar
*file
,
622 virtual void ExitMainLoop();
623 // virtual int FilterEvent(wxEvent& event); // This one too????
625 // For catching Apple Events
626 virtual void MacOpenFile(const wxString
&fileName
);
627 virtual void MacPrintFile(const wxString
&fileName
);
628 virtual void MacNewFile();
629 virtual void MacReopenApp();
631 static bool GetMacSupportPCMenuShortcuts();
632 static long GetMacAboutMenuItemId();
633 static long GetMacPreferencesMenuItemId();
634 static long GetMacExitMenuItemId();
635 static wxString
GetMacHelpMenuTitleName();
637 static void SetMacSupportPCMenuShortcuts(bool val
);
638 static void SetMacAboutMenuItemId(long val
);
639 static void SetMacPreferencesMenuItemId(long val
);
640 static void SetMacExitMenuItemId(long val
);
641 static void SetMacHelpMenuTitleName(const wxString
& val
);
644 void _BootstrapApp();
646 // implementation only
647 void SetStartupComplete(bool val
) { m_startupComplete
= val
; };
651 bool m_startupComplete
;
654 extern wxPyApp
*wxPythonApp
;
657 //----------------------------------------------------------------------
658 // These macros are used to implement the virtual methods that should
659 // redirect to a Python method if one exists. The names designate the
660 // return type, if any, as well as any parameter types.
661 //---------------------------------------------------------------------------
663 #define DEC_PYCALLBACK__(CBNAME) \
667 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
668 void CLASS::CBNAME() { \
670 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
671 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
672 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
673 wxPyEndBlockThreads(blocked); \
678 #define DEC_PYCALLBACK_VOID_(CBNAME) \
679 DEC_PYCALLBACK__(CBNAME)
681 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
682 IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME)
684 //---------------------------------------------------------------------------
686 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
687 bool CBNAME(int a, int b)
690 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
691 bool CLASS::CBNAME(int a, int b) { \
692 bool rval=false, found; \
693 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
694 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
695 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
696 wxPyEndBlockThreads(blocked); \
698 rval = PCLASS::CBNAME(a,b); \
702 //---------------------------------------------------------------------------
704 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
705 void CBNAME(int a, int b)
708 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
709 void CLASS::CBNAME(int a, int b) { \
711 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
712 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
713 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
714 wxPyEndBlockThreads(blocked); \
716 PCLASS::CBNAME(a,b); \
719 //---------------------------------------------------------------------------
721 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
725 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
726 void CLASS::CBNAME(int a) { \
728 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
729 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
730 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
731 wxPyEndBlockThreads(blocked); \
736 //---------------------------------------------------------------------------
738 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
739 void CBNAME(int a, int b, int c, int d)
742 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
743 void CLASS::CBNAME(int a, int b, int c, int d) { \
745 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
746 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
747 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
748 wxPyEndBlockThreads(blocked); \
750 PCLASS::CBNAME(a,b,c,d); \
753 //---------------------------------------------------------------------------
754 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
755 void CBNAME(int a, int b, int c, int d, int e)
758 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
759 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
761 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
762 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
763 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
764 wxPyEndBlockThreads(blocked); \
766 PCLASS::CBNAME(a,b,c,d,e); \
769 //---------------------------------------------------------------------------
771 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
772 void CBNAME(int* a, int* b) const
775 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
776 void CLASS::CBNAME(int* a, int* b) const { \
777 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
779 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
780 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
782 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
784 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
785 PyObject* o1 = PySequence_GetItem(ro, 0); \
786 PyObject* o2 = PySequence_GetItem(ro, 1); \
787 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
788 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
791 PyErr_SetString(PyExc_TypeError, errmsg); \
796 PyErr_SetString(PyExc_TypeError, errmsg); \
801 wxPyEndBlockThreads(blocked); \
803 PCLASS::CBNAME(a,b); \
806 //---------------------------------------------------------------------------
808 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
809 wxSize CBNAME() const
812 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
813 wxSize CLASS::CBNAME() const { \
814 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
815 bool found; wxSize rval(0,0); \
816 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
817 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
819 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
821 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
822 PyObject* o1 = PySequence_GetItem(ro, 0); \
823 PyObject* o2 = PySequence_GetItem(ro, 1); \
824 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
825 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
828 PyErr_SetString(PyExc_TypeError, errmsg); \
833 PyErr_SetString(PyExc_TypeError, errmsg); \
838 wxPyEndBlockThreads(blocked); \
840 return PCLASS::CBNAME(); \
845 //---------------------------------------------------------------------------
847 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
851 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
852 bool CLASS::CBNAME(bool a) { \
853 bool rval=false, found; \
854 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
855 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
856 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
857 wxPyEndBlockThreads(blocked); \
859 rval = PCLASS::CBNAME(a); \
863 //---------------------------------------------------------------------------
865 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
869 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
870 bool CLASS::CBNAME(int a) { \
871 bool rval=false, found; \
872 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
873 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
874 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
875 wxPyEndBlockThreads(blocked); \
877 rval = PCLASS::CBNAME(a); \
881 //---------------------------------------------------------------------------
883 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
887 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
888 bool CLASS::CBNAME(int a) { \
890 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
891 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
892 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
894 wxPyEndBlockThreads(blocked); \
899 //---------------------------------------------------------------------------
901 #define DEC_PYCALLBACK__DC(CBNAME) \
905 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
906 void CLASS::CBNAME(wxDC& a) { \
908 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
909 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
910 PyObject* obj = wxPyMake_wxObject(&a,false); \
911 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
914 wxPyEndBlockThreads(blocked); \
920 //---------------------------------------------------------------------------
922 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
923 void CBNAME(wxDC& a, bool b)
926 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
927 void CLASS::CBNAME(wxDC& a, bool b) { \
929 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
930 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
931 PyObject* obj = wxPyMake_wxObject(&a,false); \
932 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
935 wxPyEndBlockThreads(blocked); \
937 PCLASS::CBNAME(a, b); \
940 //---------------------------------------------------------------------------
942 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
943 void CBNAME(wxDC& a, bool b)
946 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
947 void CLASS::CBNAME(wxDC& a, bool b) { \
949 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
950 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
951 PyObject* obj = wxPyMake_wxObject(&a,false); \
952 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
955 wxPyEndBlockThreads(blocked); \
957 PCLASS::CBNAME(a, b); \
960 //---------------------------------------------------------------------------
962 #define DEC_PYCALLBACK__2DBL(CBNAME) \
963 void CBNAME(double a, double b)
966 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
967 void CLASS::CBNAME(double a, double b) { \
969 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
970 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
971 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
972 wxPyEndBlockThreads(blocked); \
974 PCLASS::CBNAME(a, b); \
977 //---------------------------------------------------------------------------
979 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
980 void CBNAME(double a, double b, int c, int d)
983 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
984 void CLASS::CBNAME(double a, double b, int c, int d) { \
986 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
987 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
988 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
990 wxPyEndBlockThreads(blocked); \
992 PCLASS::CBNAME(a, b, c, d); \
995 //---------------------------------------------------------------------------
997 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
998 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1001 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1002 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1004 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1005 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1006 PyObject* obj = wxPyMake_wxObject(&a,false); \
1007 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
1010 wxPyEndBlockThreads(blocked); \
1012 PCLASS::CBNAME(a, b, c, d, e, f); \
1015 //---------------------------------------------------------------------------
1017 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
1018 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1021 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1022 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1024 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1026 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1027 PyObject* obj = wxPyMake_wxObject(&a,false); \
1028 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1031 wxPyEndBlockThreads(blocked); \
1033 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1037 //---------------------------------------------------------------------------
1039 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1040 void CBNAME(bool a, double b, double c, int d, int e)
1043 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1044 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1046 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1047 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1048 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1050 wxPyEndBlockThreads(blocked); \
1052 PCLASS::CBNAME(a, b, c, d, e); \
1055 //---------------------------------------------------------------------------
1057 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1058 void CBNAME(wxDC& a, double b, double c, double d, double e)
1061 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1062 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1064 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1065 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1066 PyObject* obj = wxPyMake_wxObject(&a,false); \
1067 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1070 wxPyEndBlockThreads(blocked); \
1072 PCLASS::CBNAME(a, b, c, d, e); \
1075 //---------------------------------------------------------------------------
1077 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1078 void CBNAME(wxDC& a, bool b)
1081 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1082 void CLASS::CBNAME(wxDC& a, bool b) { \
1084 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1085 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1086 PyObject* obj = wxPyMake_wxObject(&a,false); \
1087 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1090 wxPyEndBlockThreads(blocked); \
1092 PCLASS::CBNAME(a, b); \
1095 //---------------------------------------------------------------------------
1097 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1098 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1101 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1102 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1105 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1106 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1107 PyObject* obj = wxPyMake_wxObject(a,false); \
1108 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1111 wxPyEndBlockThreads(blocked); \
1113 PCLASS::CBNAME(a, b, c, d, e, f); \
1116 //---------------------------------------------------------------------------
1118 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1119 void CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1122 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1123 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1125 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1126 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1127 PyObject* obj = wxPyMake_wxObject(a,false); \
1128 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1131 wxPyEndBlockThreads(blocked); \
1133 PCLASS::CBNAME(a, b, c, d, e); \
1136 //---------------------------------------------------------------------------
1138 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1139 void CBNAME(double a, double b, int c)
1142 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1143 void CLASS::CBNAME(double a, double b, int c) { \
1145 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1146 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1147 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1148 wxPyEndBlockThreads(blocked); \
1150 PCLASS::CBNAME(a, b, c); \
1153 //---------------------------------------------------------------------------
1155 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1156 void CBNAME(bool a, double b, double c, int d)
1159 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1160 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1162 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1163 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1164 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1165 wxPyEndBlockThreads(blocked); \
1167 PCLASS::CBNAME(a, b, c, d); \
1170 //---------------------------------------------------------------------------
1171 //---------------------------------------------------------------------------
1173 #define DEC_PYCALLBACK__STRING(CBNAME) \
1174 void CBNAME(const wxString& a)
1176 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1177 void CLASS::CBNAME(const wxString& a) { \
1179 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1180 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1181 PyObject* s = wx2PyString(a); \
1182 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1185 wxPyEndBlockThreads(blocked); \
1187 PCLASS::CBNAME(a); \
1190 //---------------------------------------------------------------------------
1192 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1193 bool CBNAME(const wxString& a)
1195 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1196 bool CLASS::CBNAME(const wxString& a) { \
1199 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1200 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1201 PyObject* s = wx2PyString(a); \
1202 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1205 wxPyEndBlockThreads(blocked); \
1207 rval = PCLASS::CBNAME(a); \
1211 //---------------------------------------------------------------------------
1213 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1214 bool CBNAME(const wxString& a)
1216 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1217 bool CLASS::CBNAME(const wxString& a) { \
1219 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1220 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1221 PyObject* s = wx2PyString(a); \
1222 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1225 wxPyEndBlockThreads(blocked); \
1229 //---------------------------------------------------------------------------
1231 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1232 wxString CBNAME(const wxString& a)
1234 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1235 wxString CLASS::CBNAME(const wxString& a) { \
1237 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1238 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1240 PyObject* s = wx2PyString(a); \
1241 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1244 rval = Py2wxString(ro); \
1248 wxPyEndBlockThreads(blocked); \
1252 //---------------------------------------------------------------------------
1254 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1255 wxString CBNAME(const wxString& a)
1257 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1258 wxString CLASS::CBNAME(const wxString& a) { \
1261 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1262 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1264 PyObject* s = wx2PyString(a); \
1265 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1268 rval = Py2wxString(ro); \
1273 rval = PCLASS::CBNAME(a); \
1274 wxPyEndBlockThreads(blocked); \
1278 //---------------------------------------------------------------------------
1280 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1281 wxString CBNAME(const wxString& a,int b)
1283 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1284 wxString CLASS::CBNAME(const wxString& a,int b) { \
1286 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1287 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1289 PyObject* s = wx2PyString(a); \
1290 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1293 rval = Py2wxString(ro); \
1297 wxPyEndBlockThreads(blocked); \
1301 //---------------------------------------------------------------------------
1303 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1304 bool CBNAME(const wxString& a, const wxString& b)
1306 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1307 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1310 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1311 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1312 PyObject* s1 = wx2PyString(a); \
1313 PyObject* s2 = wx2PyString(b); \
1314 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1318 wxPyEndBlockThreads(blocked); \
1320 rval = PCLASS::CBNAME(a, b); \
1324 //---------------------------------------------------------------------------
1326 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1329 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1330 wxString CLASS::CBNAME() { \
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__const(CBNAME) \
1351 wxString CBNAME() const
1353 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1354 wxString CLASS::CBNAME() const { \
1357 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1358 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1360 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1362 rval = Py2wxString(ro); \
1366 wxPyEndBlockThreads(blocked); \
1368 rval = PCLASS::CBNAME(); \
1372 //---------------------------------------------------------------------------
1374 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1377 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1378 wxString CLASS::CBNAME() { \
1380 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1381 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1383 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1385 rval = Py2wxString(ro); \
1389 wxPyEndBlockThreads(blocked); \
1393 //---------------------------------------------------------------------------
1395 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1396 wxString CBNAME() const;
1398 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1399 wxString CLASS::CBNAME() const { \
1401 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1402 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1404 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1406 rval = Py2wxString(ro); \
1410 wxPyEndBlockThreads(blocked); \
1414 //---------------------------------------------------------------------------
1416 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1417 bool CBNAME(const wxHtmlTag& a)
1420 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1421 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1423 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1424 if (wxPyCBH_findCallback2(m_myInst, #CBNAME, false)) { \
1425 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
1426 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1429 wxPyEndBlockThreads(blocked); \
1433 //---------------------------------------------------------------------------
1435 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1436 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1438 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1439 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1441 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1442 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1443 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1444 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1447 wxPyEndBlockThreads(blocked); \
1449 PCLASS::CBNAME(cell, x, y); \
1452 //---------------------------------------------------------------------------
1454 #define DEC_PYCALLBACK__COLOUR(CBNAME) \
1455 void CBNAME(const wxColour& c);
1457 #define IMP_PYCALLBACK__COLOUR(CLASS, PCLASS, CBNAME) \
1458 void CLASS::CBNAME(const wxColour& c) { \
1460 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1461 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1462 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1463 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1466 wxPyEndBlockThreads(blocked); \
1468 PCLASS::CBNAME(c); \
1471 //---------------------------------------------------------------------------
1473 #define DEC_PYCALLBACK_BOOL_CELLINTINTME(CBNAME) \
1474 bool CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1476 #define IMP_PYCALLBACK_BOOL_CELLINTINTME(CLASS, PCLASS, CBNAME) \
1477 bool CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1478 bool rval=false, found; \
1479 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1480 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1481 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1482 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1483 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1487 wxPyEndBlockThreads(blocked); \
1489 rval = PCLASS::CBNAME(cell, x, y, e); \
1494 //---------------------------------------------------------------------------
1496 #define DEC_PYCALLBACK___pure(CBNAME) \
1500 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1501 void CLASS::CBNAME() { \
1502 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1503 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1504 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1505 wxPyEndBlockThreads(blocked); \
1508 //---------------------------------------------------------------------------
1510 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1514 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1515 wxSize CLASS::CBNAME() { \
1516 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1518 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1519 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1522 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1524 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1526 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1528 PyObject* o1 = PySequence_GetItem(ro, 0); \
1529 PyObject* o2 = PySequence_GetItem(ro, 1); \
1530 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1531 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1533 PyErr_SetString(PyExc_TypeError, errmsg); \
1538 PyErr_SetString(PyExc_TypeError, errmsg); \
1543 wxPyEndBlockThreads(blocked); \
1547 //---------------------------------------------------------------------------
1549 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1550 bool CBNAME(wxWindow* a)
1553 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1554 bool CLASS::CBNAME(wxWindow* a) { \
1557 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1558 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1559 PyObject* obj = wxPyMake_wxObject(a,false); \
1560 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1563 wxPyEndBlockThreads(blocked); \
1565 rval = PCLASS::CBNAME(a); \
1569 //---------------------------------------------------------------------------
1571 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1572 bool CBNAME(wxWindow* a, wxDC& b)
1575 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1576 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1579 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1580 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1581 PyObject* win = wxPyMake_wxObject(a,false); \
1582 PyObject* dc = wxPyMake_wxObject(&b,false); \
1583 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1587 wxPyEndBlockThreads(blocked); \
1589 rval = PCLASS::CBNAME(a, b); \
1593 //---------------------------------------------------------------------------
1595 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1596 void CBNAME(wxWindowBase* a)
1599 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1600 void CLASS::CBNAME(wxWindowBase* a) { \
1602 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1603 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1604 PyObject* obj = wxPyMake_wxObject(a,false); \
1605 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1608 wxPyEndBlockThreads(blocked); \
1610 PCLASS::CBNAME(a); \
1613 //---------------------------------------------------------------------------
1615 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1619 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1620 bool CLASS::CBNAME() { \
1623 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1624 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1625 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1626 wxPyEndBlockThreads(blocked); \
1628 rval = PCLASS::CBNAME(); \
1632 //---------------------------------------------------------------------------
1634 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1638 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1639 bool CLASS::CBNAME() const { \
1642 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1643 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1644 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1645 wxPyEndBlockThreads(blocked); \
1647 rval = PCLASS::CBNAME(); \
1651 //---------------------------------------------------------------------------
1653 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1654 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1657 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1658 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1661 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1662 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1663 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1664 wxPyEndBlockThreads(blocked); \
1666 rval = PCLASS::CBNAME(a, b, c); \
1667 return (wxDragResult)rval; \
1670 //---------------------------------------------------------------------------
1672 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1673 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1675 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1676 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1677 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1679 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1681 PyObject* obj = wxPyMake_wxObject(&a,false); \
1682 PyObject* s = wx2PyString(b); \
1683 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1686 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
1687 /* release ownership of the C++ wx.FSFile object. */ \
1688 PyObject_SetAttrString(ro, "thisown", Py_False); \
1694 wxPyEndBlockThreads(blocked); \
1698 //---------------------------------------------------------------------------
1700 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1701 bool CBNAME(wxDragResult a)
1704 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1705 bool CLASS::CBNAME(wxDragResult a) { \
1708 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1709 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1710 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1711 wxPyEndBlockThreads(blocked); \
1713 rval = PCLASS::CBNAME(a); \
1717 //---------------------------------------------------------------------------
1719 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1720 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1723 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1724 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1725 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1727 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1728 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1729 wxPyEndBlockThreads(blocked); \
1730 return (wxDragResult)rval; \
1733 //---------------------------------------------------------------------------
1735 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1736 bool CBNAME(int a, int b, const wxString& c)
1738 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1739 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1741 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1742 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1743 PyObject* s = wx2PyString(c); \
1744 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1747 wxPyEndBlockThreads(blocked); \
1751 //---------------------------------------------------------------------------
1753 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1757 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1758 size_t CLASS::CBNAME() { \
1761 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1762 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1763 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1764 wxPyEndBlockThreads(blocked); \
1766 rval = PCLASS::CBNAME(); \
1770 //---------------------------------------------------------------------------
1772 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1773 size_t CBNAME() const
1776 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1777 size_t CLASS::CBNAME() const { \
1780 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1781 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1782 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1783 wxPyEndBlockThreads(blocked); \
1785 rval = PCLASS::CBNAME(); \
1789 //---------------------------------------------------------------------------
1791 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1792 wxDataFormat CBNAME(size_t a)
1795 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1796 wxDataFormat CLASS::CBNAME(size_t a) { \
1797 wxDataFormat rval=0; \
1799 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1800 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1802 wxDataFormat* ptr; \
1803 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1805 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1810 wxPyEndBlockThreads(blocked); \
1812 rval = PCLASS::CBNAME(a); \
1816 //---------------------------------------------------------------------------
1818 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1819 void CBNAME(const Type& a)
1822 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1823 void CLASS::CBNAME(const Type& a) { \
1825 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1826 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1827 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1828 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1831 wxPyEndBlockThreads(blocked); \
1833 PCLASS::CBNAME(a); \
1837 //---------------------------------------------------------------------------
1839 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1840 void CBNAME(Type& a)
1843 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1844 void CLASS::CBNAME(Type& a) { \
1846 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1847 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1848 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1849 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1852 wxPyEndBlockThreads(blocked); \
1854 PCLASS::CBNAME(a); \
1857 //---------------------------------------------------------------------------
1859 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1860 bool CBNAME(Type& a)
1863 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1864 bool CLASS::CBNAME(Type& a) { \
1867 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1868 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1869 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1870 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1873 wxPyEndBlockThreads(blocked); \
1875 rv = PCLASS::CBNAME(a); \
1879 //---------------------------------------------------------------------------
1881 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
1882 bool CBNAME(Type& a)
1885 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
1886 bool CLASS::CBNAME(Type& a) { \
1888 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1889 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1890 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1891 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1894 wxPyEndBlockThreads(blocked); \
1898 //---------------------------------------------------------------------------
1900 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1901 wxString CBNAME(long a, long b) const
1903 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1904 wxString CLASS::CBNAME(long a, long b) const { \
1907 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1908 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1910 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1912 rval = Py2wxString(ro); \
1916 wxPyEndBlockThreads(blocked); \
1918 rval = PCLASS::CBNAME(a,b); \
1922 //---------------------------------------------------------------------------
1924 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1925 int CBNAME(long a) const
1928 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1929 int CLASS::CBNAME(long a) const { \
1932 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1933 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1935 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1937 rval = PyInt_AsLong(ro); \
1941 wxPyEndBlockThreads(blocked); \
1943 rval = PCLASS::CBNAME(a); \
1948 #define DEC_PYCALLBACK_INT_LONG_virtual(CBNAME) \
1949 int CBNAME(long a) const;
1952 #define IMP_PYCALLBACK_INT_LONG_virtual(CLASS, PCLASS, CBNAME) \
1953 int CLASS::CBNAME(long a) const { \
1954 int rval=-1; /* this rval is important for OnGetItemImage */ \
1956 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1957 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1959 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1961 rval = PyInt_AsLong(ro); \
1965 wxPyEndBlockThreads(blocked); \
1970 //---------------------------------------------------------------------------
1972 #define DEC_PYCALLBACK_INT_LONGLONG(CBNAME) \
1973 int CBNAME(long a, long b) const
1976 #define IMP_PYCALLBACK_INT_LONGLONG(CLASS, PCLASS, CBNAME) \
1977 int CLASS::CBNAME(long a, long b) const { \
1980 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1981 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1983 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1985 rval = PyInt_AsLong(ro); \
1989 wxPyEndBlockThreads(blocked); \
1991 rval = PCLASS::CBNAME(a, b); \
1996 #define DEC_PYCALLBACK_INT_LONGLONG_virtual(CBNAME) \
1997 int CBNAME(long a, long b) const;
2000 #define IMP_PYCALLBACK_INT_LONGLONG_virtual(CLASS, PCLASS, CBNAME) \
2001 int CLASS::CBNAME(long a, long b) const { \
2002 int rval=-1; /* this rval is important for OnGetItemImage */ \
2004 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2005 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2007 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2009 rval = PyInt_AsLong(ro); \
2013 wxPyEndBlockThreads(blocked); \
2018 //---------------------------------------------------------------------------
2020 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2021 wxListItemAttr* CBNAME(long a) const
2024 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2025 wxListItemAttr *CLASS::CBNAME(long a) const { \
2026 wxListItemAttr *rval = NULL; \
2028 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2029 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2031 wxListItemAttr* ptr; \
2032 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2034 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2039 wxPyEndBlockThreads(blocked); \
2041 rval = PCLASS::CBNAME(a); \
2045 //---------------------------------------------------------------------------
2047 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2048 bool CBNAME(wxMouseEvent& e)
2050 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2051 bool CLASS::CBNAME(wxMouseEvent& e) { \
2054 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2055 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2057 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2058 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2060 rval = PyInt_AsLong(ro); \
2065 wxPyEndBlockThreads(blocked); \
2067 return PCLASS::CBNAME(e); \
2071 //---------------------------------------------------------------------------
2073 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2074 wxWizardPage* CBNAME() const
2076 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2077 wxWizardPage* CLASS::CBNAME() const { \
2078 wxWizardPage* rv = NULL; \
2079 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2080 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2082 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2084 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2088 wxPyEndBlockThreads(blocked); \
2092 //---------------------------------------------------------------------------
2094 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2095 wxBitmap CBNAME() const
2097 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2098 wxBitmap CLASS::CBNAME() const { \
2100 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2101 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2104 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2106 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2111 wxPyEndBlockThreads(blocked); \
2115 //---------------------------------------------------------------------------
2117 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2120 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2121 wxObject* CLASS::CBNAME() { \
2122 wxObject* rv = NULL; \
2123 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2124 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2126 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2128 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2132 wxPyEndBlockThreads(blocked); \
2136 //---------------------------------------------------------------------------
2138 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2139 wxObject* CBNAME(const wxString& a)
2141 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2142 wxObject* CLASS::CBNAME(const wxString& a) { \
2143 wxObject* rv = NULL; \
2144 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2145 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2146 PyObject* so = wx2PyString(a); \
2148 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2150 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2155 wxPyEndBlockThreads(blocked); \
2159 //---------------------------------------------------------------------------
2161 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2162 bool CBNAME(wxXmlNode* a)
2165 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2166 bool CLASS::CBNAME(wxXmlNode* a) { \
2168 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2169 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2170 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2171 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2174 wxPyEndBlockThreads(blocked); \
2178 //---------------------------------------------------------------------------
2180 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2181 wxCoord CBNAME(size_t a) const
2184 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2185 wxCoord CLASS::CBNAME(size_t a) const { \
2188 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2189 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2190 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2192 wxPyEndBlockThreads(blocked); \
2196 //---------------------------------------------------------------------------
2198 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2199 void CBNAME(size_t a, size_t b) const
2202 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2203 void CLASS::CBNAME(size_t a, size_t b) const { \
2205 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2206 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2207 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2208 wxPyEndBlockThreads(blocked); \
2210 PCLASS::CBNAME(a,b); \
2212 //---------------------------------------------------------------------------
2214 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2215 wxCoord CBNAME() const
2218 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2219 wxCoord CLASS::CBNAME() const { \
2222 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2223 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2224 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2225 wxPyEndBlockThreads(blocked); \
2227 rval = PCLASS::CBNAME(); \
2231 //---------------------------------------------------------------------------
2233 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2234 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2236 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2237 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2239 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2240 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2241 PyObject* obj = wxPyMake_wxObject(&a,false); \
2242 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2243 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2246 wxPyEndBlockThreads(blocked); \
2251 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2252 void CBNAME(wxDC& a, const wxRect& b, size_t c) const
2254 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2255 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2257 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2258 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2259 PyObject* obj = wxPyMake_wxObject(&a,false); \
2260 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2261 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2264 wxPyEndBlockThreads(blocked); \
2266 PCLASS::CBNAME(a,b,c); \
2270 //---------------------------------------------------------------------------
2271 // Same as the above set, but the wxRect is not const
2273 #define DEC_PYCALLBACK__DCRECTSIZET2_constpure(CBNAME) \
2274 void CBNAME(wxDC& a, wxRect& b, size_t c) const;
2276 #define IMP_PYCALLBACK__DCRECTSIZET2_constpure(CLASS, PCLASS, CBNAME) \
2277 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2279 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2280 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2281 PyObject* obj = wxPyMake_wxObject(&a,false); \
2282 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2283 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2286 wxPyEndBlockThreads(blocked); \
2291 #define DEC_PYCALLBACK__DCRECTSIZET2_const(CBNAME) \
2292 void CBNAME(wxDC& a, wxRect& b, size_t c) const
2294 #define IMP_PYCALLBACK__DCRECTSIZET2_const(CLASS, PCLASS, CBNAME) \
2295 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2297 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2298 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2299 PyObject* obj = wxPyMake_wxObject(&a,false); \
2300 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2301 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2304 wxPyEndBlockThreads(blocked); \
2306 PCLASS::CBNAME(a,b,c); \
2311 //---------------------------------------------------------------------------
2315 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2316 wxString CBNAME(size_t a) const
2318 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2319 wxString CLASS::CBNAME(size_t a) const { \
2322 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2323 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2325 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2327 rval = Py2wxString(ro); \
2331 wxPyEndBlockThreads(blocked); \
2333 rval = PCLASS::CBNAME(a); \
2337 //---------------------------------------------------------------------------
2339 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2340 wxString CBNAME(size_t a) const
2342 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2343 wxString CLASS::CBNAME(size_t a) const { \
2346 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2347 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2349 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2351 rval = Py2wxString(ro); \
2355 wxPyEndBlockThreads(blocked); \
2359 //---------------------------------------------------------------------------
2361 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2362 wxVisualAttributes CBNAME() const
2365 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2366 wxVisualAttributes CLASS::CBNAME() const { \
2367 wxVisualAttributes rval; \
2369 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2370 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2372 wxVisualAttributes* ptr; \
2373 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2375 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2380 wxPyEndBlockThreads(blocked); \
2382 rval = PCLASS::CBNAME(); \
2386 //---------------------------------------------------------------------------