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>
32 #include <wx/numdlg.h>
34 #include <wx/docview.h>
35 #include <wx/encconv.h>
36 #include <wx/fdrepdlg.h>
37 #include <wx/fileconf.h>
38 #include <wx/filesys.h>
39 #include <wx/fontdlg.h>
40 #include <wx/fs_inet.h>
41 #include <wx/fs_mem.h>
42 #include <wx/fs_zip.h>
43 #include <wx/gbsizer.h>
44 #include <wx/geometry.h>
45 #include <wx/htmllbox.h>
47 #include <wx/imaglist.h>
49 #include <wx/laywin.h>
50 #include <wx/listbook.h>
51 #include <wx/minifram.h>
52 #include <wx/notebook.h>
54 #include <wx/printdlg.h>
55 #include <wx/process.h>
56 #include <wx/progdlg.h>
57 #include <wx/sashwin.h>
58 #include <wx/spinbutt.h>
59 #include <wx/spinctrl.h>
60 #include <wx/splash.h>
61 #include <wx/splitter.h>
62 #include <wx/statline.h>
63 #include <wx/stream.h>
64 #include <wx/sysopt.h>
65 #include <wx/taskbar.h>
66 #include <wx/tglbtn.h>
67 #include <wx/tipwin.h>
68 #include <wx/toolbook.h>
69 #include <wx/tooltip.h>
70 #include <wx/treebook.h>
72 #include <wx/vscroll.h>
73 #include <wx/dateevt.h>
74 #include <wx/datectrl.h>
76 #include <wx/hyperlink.h>
77 #include <wx/pickerbase.h>
78 #include <wx/clrpicker.h>
79 #include <wx/filepicker.h>
80 #include <wx/fontpicker.h>
84 # pragma warning(disable:4800)
85 # pragma warning(disable:4190)
88 #ifdef __WXMAC__ // avoid a bug in Carbon headers
92 //---------------------------------------------------------------------------
94 #ifndef wxHAS_POWER_EVENTS
95 class wxPowerEvent
: public wxEvent
98 wxPowerEvent(wxEventType evtType
) : wxEvent(wxID_NONE
, evtType
) {}
100 bool IsVetoed() const { return false; }
101 virtual wxEvent
*Clone() const { return new wxPowerEvent(*this); }
105 //---------------------------------------------------------------------------
106 typedef unsigned char byte
;
107 typedef wxPoint2DDouble wxPoint2D
;
109 #ifndef SWIG_TYPE_TABLE
110 #define SWIG_TYPE_TABLE wxPython_type_table
114 #define wxDEFAULT_STATUSBAR_STYLE wxST_SIZEGRIP|wxFULL_REPAINT_ON_RESIZE
116 #define wxDEFAULT_STATUSBAR_STYLE wxST_SIZEGRIP
120 #ifndef wxPyUSE_EXPORTED_API
122 void __wxPyPreStart(PyObject
*);
123 void __wxPyCleanup();
124 PyObject
* __wxPySetDictionary(PyObject
*, PyObject
* args
);
126 void wxSetDefaultPyEncoding(const char* encoding
);
127 const char* wxGetDefaultPyEncoding();
130 void wxPyEventThunker(wxObject
*, wxEvent
& event
);
133 bool wxPyCheckSwigType(const wxChar
* className
);
134 PyObject
* wxPyConstructObject(void* ptr
,
135 const wxChar
* className
,
137 bool wxPyConvertSwigPtr(PyObject
* obj
, void **ptr
,
138 const wxChar
* className
);
139 PyObject
* wxPyMakeSwigPtr(void* ptr
, const wxChar
* classname
);
142 PyObject
* wx2PyString(const wxString
& src
);
143 wxString
Py2wxString(PyObject
* source
);
145 PyObject
* wxPyMake_wxObject(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
=true);
146 PyObject
* wxPyMake_wxSizer(wxSizer
* source
, bool setThisOwn
);
147 void wxPyPtrTypeMap_Add(const char* commonName
, const char* ptrName
);
149 PyObject
* wxPy_ConvertList(wxListBase
* list
);
150 long wxPyGetWinHandle(wxWindow
* win
);
152 void wxPy_ReinitStockObjects(int pass
);
154 bool wxPyInstance_Check(PyObject
* obj
);
155 bool wxPySwigInstance_Check(PyObject
* obj
);
158 #endif // wxPyUSE_EXPORTED_API
159 //---------------------------------------------------------------------------
161 // if we want to handle threads and Python threads are available...
162 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
163 #define WXP_WITH_THREAD
164 #else // no Python threads...
165 #undef WXP_WITH_THREAD
169 // In Python 2.3 and later there are the PyGILState_* APIs that we can use for
170 // blocking threads when calling back into Python. Using them instead of my
171 // home-grown hacks greatly simplifies wxPyBeginBlockThreads and
172 // wxPyEndBlockThreads.
174 // Unfortunatly there is a bug somewhere when using these new APIs on Python
175 // 2.3. It manifests in Boa Constructor's debugger where it is unable to stop
176 // at breakpoints located in event handlers. I think that the cause may be
177 // something like the original PyThreadState for the main thread is not being
178 // restored for the callbacks, but I can't see where that could be
179 // happening... So we'll only activate this new change for Python 2.4+ :-(
181 #if PY_VERSION_HEX < 0x02040000
182 #define wxPyUSE_GIL_STATE 0
183 typedef bool wxPyBlock_t
;
185 #define wxPyUSE_GIL_STATE 1
186 typedef PyGILState_STATE wxPyBlock_t
;
190 // Python 2.5 changes the type of some API parameter and return types. Using
191 // this typedef for versions < 2.5 will help with the transition...
192 #if PY_VERSION_HEX < 0x02050000
193 typedef int Py_ssize_t
;
197 #ifndef wxPyUSE_EXPORTED_API
199 // For Python --> C++
200 PyThreadState
* wxPyBeginAllowThreads();
201 void wxPyEndAllowThreads(PyThreadState
* state
);
203 // For C++ --> Python
204 wxPyBlock_t
wxPyBeginBlockThreads();
205 void wxPyEndBlockThreads(wxPyBlock_t blocked
);
207 #endif // wxPyUSE_EXPORTED_API
210 // A macro that will help to execute simple statments wrapped in
211 // StartBlock/EndBlockThreads calls
212 #define wxPyBLOCK_THREADS(stmt) \
213 { wxPyBlock_t blocked = wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads(blocked); }
215 // Raise the NotImplementedError exception (blocking threads)
216 #define wxPyRaiseNotImplemented() \
217 wxPyBLOCK_THREADS(PyErr_SetNone(PyExc_NotImplementedError))
219 // Raise any exception with a string value (blocking threads)
220 #define wxPyErr_SetString(err, str) \
221 wxPyBLOCK_THREADS(PyErr_SetString(err, str))
224 //---------------------------------------------------------------------------
225 // These are helpers used by the typemaps
227 #ifndef wxPyUSE_EXPORTED_API
229 wxString
* wxString_in_helper(PyObject
* source
);
231 byte
* byte_LIST_helper(PyObject
* source
);
232 int* int_LIST_helper(PyObject
* source
);
233 long* long_LIST_helper(PyObject
* source
);
234 char** string_LIST_helper(PyObject
* source
);
235 wxPoint
* wxPoint_LIST_helper(PyObject
* source
, int* npoints
);
236 wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
237 wxString
* wxString_LIST_helper(PyObject
* source
);
238 wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
239 wxPen
** wxPen_LIST_helper(PyObject
* source
);
241 bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
242 bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
243 bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
244 bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
245 bool wxColour_helper(PyObject
* source
, wxColour
** obj
);
246 bool wxPoint2D_helper(PyObject
* source
, wxPoint2D
** obj
);
249 bool wxPySimple_typecheck(PyObject
* source
, const wxChar
* classname
, int seqLen
);
250 bool wxColour_typecheck(PyObject
* source
);
252 bool wxPyCheckForApp();
255 // Other helpful stuff
256 bool wxPy2int_seq_helper(PyObject
* source
, int* i1
, int* i2
);
257 bool wxPy4int_seq_helper(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
259 PyObject
* wxArrayString2PyList_helper(const wxArrayString
& arr
);
260 PyObject
* wxArrayInt2PyList_helper(const wxArrayInt
& arr
);
262 #endif // wxPyUSE_EXPORTED_API
264 //---------------------------------------------------------------------------
266 #if PYTHON_API_VERSION < 1009
267 #define PySequence_Fast_GET_ITEM(o, i) \
268 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
271 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
272 #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name)
273 #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val)
275 //---------------------------------------------------------------------------
277 #ifndef wxPyUSE_EXPORTED_API
279 class wxPyCallback
: public wxObject
{
280 DECLARE_ABSTRACT_CLASS(wxPyCallback
)
282 wxPyCallback(PyObject
* func
);
283 wxPyCallback(const wxPyCallback
& other
);
286 void EventThunker(wxEvent
& event
);
291 #endif // wxPyUSE_EXPORTED_API
292 //---------------------------------------------------------------------------
293 //---------------------------------------------------------------------------
294 // These Event classes can be derived from in Python and passed through the
295 // event system without loosing anything. They do this by keeping a reference
296 // to themselves and some special case handling in wxPyCallback::EventThunker.
300 class wxPyEvtSelfRef
{
305 void SetSelf(PyObject
* self
, bool clone
=false);
306 PyObject
* GetSelf() const;
307 bool GetCloned() const { return m_cloned
; }
315 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
316 DECLARE_ABSTRACT_CLASS(wxPyEvent
)
318 wxPyEvent(int winid
=0, wxEventType commandType
= wxEVT_NULL
);
319 wxPyEvent(const wxPyEvent
& evt
);
322 virtual wxEvent
* Clone() const { return new wxPyEvent(*this); }
326 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
327 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent
)
329 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
330 wxPyCommandEvent(const wxPyCommandEvent
& evt
);
333 virtual wxEvent
* Clone() const { return new wxPyCommandEvent(*this); }
338 //----------------------------------------------------------------------
339 // Forward decalre a few things used in the exported API
340 class wxPyClientData
;
342 class wxPyOORClientData
;
343 class wxPyCBInputStream
;
345 void wxPyClientData_dtor(wxPyClientData
* self
);
346 void wxPyUserData_dtor(wxPyUserData
* self
);
347 void wxPyOORClientData_dtor(wxPyOORClientData
* self
);
348 wxPyCBInputStream
* wxPyCBInputStream_create(PyObject
*py
, bool block
);
349 wxPyCBInputStream
* wxPyCBInputStream_copy(wxPyCBInputStream
* other
);
351 //---------------------------------------------------------------------------
352 // Export a C API in a struct. Other modules will be able to load this from
353 // the wx.core module and will then have safe access to these functions, even if
354 // in another shared library.
356 class wxPyCallbackHelper
;
360 bool (*p_wxPyCheckSwigType
)(const wxChar
* className
);
361 PyObject
* (*p_wxPyConstructObject
)(void* ptr
, const wxChar
* className
, int setThisOwn
);
362 bool (*p_wxPyConvertSwigPtr
)(PyObject
* obj
, void **ptr
, const wxChar
* className
);
363 PyObject
* (*p_wxPyMakeSwigPtr
)(void* ptr
, const wxChar
* className
);
365 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
366 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
367 wxPyBlock_t (*p_wxPyBeginBlockThreads
)();
368 void (*p_wxPyEndBlockThreads
)(wxPyBlock_t blocked
);
370 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
);
372 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
373 wxString (*p_Py2wxString
)(PyObject
* source
);
374 PyObject
* (*p_wx2PyString
)(const wxString
& src
);
376 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
377 int* (*p_int_LIST_helper
)(PyObject
* source
);
378 long* (*p_long_LIST_helper
)(PyObject
* source
);
379 char** (*p_string_LIST_helper
)(PyObject
* source
);
380 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
381 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
382 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
383 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
385 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
386 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
387 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
388 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
389 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
390 bool (*p_wxPoint2D_helper
)(PyObject
* source
, wxPoint2DDouble
** obj
);
393 bool (*p_wxPySimple_typecheck
)(PyObject
* source
, const wxChar
* classname
, int seqLen
);
394 bool (*p_wxColour_typecheck
)(PyObject
* source
);
396 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
397 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
);
398 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
399 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
400 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
402 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
);
403 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
, bool setThisOwn
);
404 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
405 bool (*p_wxPy2int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
);
406 bool (*p_wxPy4int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
407 PyObject
* (*p_wxArrayString2PyList_helper
)(const wxArrayString
& arr
);
408 PyObject
* (*p_wxArrayInt2PyList_helper
)(const wxArrayInt
& arr
);
410 void (*p_wxPyClientData_dtor
)(wxPyClientData
*);
411 void (*p_wxPyUserData_dtor
)(wxPyUserData
*);
412 void (*p_wxPyOORClientData_dtor
)(wxPyOORClientData
*);
414 wxPyCBInputStream
* (*p_wxPyCBInputStream_create
)(PyObject
*py
, bool block
);
415 wxPyCBInputStream
* (*p_wxPyCBInputStream_copy
)(wxPyCBInputStream
* other
);
417 bool (*p_wxPyInstance_Check
)(PyObject
* obj
);
418 bool (*p_wxPySwigInstance_Check
)(PyObject
* obj
);
420 bool (*p_wxPyCheckForApp
)();
424 #ifdef wxPyUSE_EXPORTED_API
425 // Notice that this is static, not extern. This is by design, each module
426 // needs one, but doesn't have to use it.
427 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
;
428 inline wxPyCoreAPI
* wxPyGetCoreAPIPtr();
429 #endif // wxPyUSE_EXPORTED_API
431 //---------------------------------------------------------------------------
433 // A wxObject that holds a reference to a Python object
434 class wxPyUserData
: public wxObject
{
436 wxPyUserData(PyObject
* obj
) {
442 #ifdef wxPyUSE_EXPORTED_API
443 wxPyGetCoreAPIPtr()->p_wxPyUserData_dtor(this);
445 wxPyUserData_dtor(this);
452 // A wxClientData that holds a refernece to a Python object
453 class wxPyClientData
: public wxClientData
{
455 wxPyClientData(PyObject
* obj
, bool incref
=true) {
463 #ifdef wxPyUSE_EXPORTED_API
464 wxPyGetCoreAPIPtr()->p_wxPyClientData_dtor(this);
466 wxPyClientData_dtor(this);
474 // Just like wxPyClientData, except when this object is destroyed it does some
475 // OOR magic on the Python Object.
476 class wxPyOORClientData
: public wxPyClientData
{
478 wxPyOORClientData(PyObject
* obj
, bool incref
=true)
479 : wxPyClientData(obj
, incref
) {}
480 ~wxPyOORClientData() {
482 #ifdef wxPyUSE_EXPORTED_API
483 wxPyGetCoreAPIPtr()->p_wxPyOORClientData_dtor(this);
485 wxPyOORClientData_dtor(this);
491 //---------------------------------------------------------------------------
492 // A wxImageHandler that can be derived from in Python.
495 class wxPyImageHandler
: public wxImageHandler
{
499 // used for interning method names as PyStrings
500 static PyObject
* m_DoCanRead_Name
;
501 static PyObject
* m_GetImageCount_Name
;
502 static PyObject
* m_LoadFile_Name
;
503 static PyObject
* m_SaveFile_Name
;
505 // converstion helpers
506 PyObject
* py_InputStream(wxInputStream
* stream
);
507 PyObject
* py_Image(wxImage
* image
);
508 PyObject
* py_OutputStream(wxOutputStream
* stream
);
513 void _SetSelf(PyObject
*self
);
515 virtual bool LoadFile(wxImage
* image
, wxInputStream
& stream
,
516 bool verbose
=true, int index
=-1 );
517 virtual bool SaveFile(wxImage
* image
, wxOutputStream
& stream
,
519 virtual int GetImageCount(wxInputStream
& stream
);
520 virtual bool DoCanRead(wxInputStream
&stream
);
524 //---------------------------------------------------------------------------
525 // This class holds an instance of a Python Shadow Class object and assists
526 // with looking up and invoking Python callback methods from C++ virtual
527 // method redirections. For all classes which have virtuals which should be
528 // overridable in wxPython, a new subclass is created that contains a
529 // wxPyCallbackHelper.
532 class wxPyCallbackHelper
{
534 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
536 wxPyCallbackHelper() {
543 ~wxPyCallbackHelper() {
544 #ifdef wxPyUSE_EXPORTED_API
545 wxPyGetCoreAPIPtr()->p_wxPyCBH_delete(this);
547 wxPyCBH_delete(this);
551 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=true);
552 bool findCallback(const char* name
, bool setGuard
=true) const;
553 int callCallback(PyObject
* argTuple
) const;
554 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
555 PyObject
* GetLastFound() const { return m_lastFound
; }
557 void setRecursionGuard(PyObject
* method
) const;
558 void clearRecursionGuard(PyObject
* method
) const;
563 PyObject
* m_lastFound
;
566 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
570 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
571 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
=true);
572 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
573 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
574 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
579 //---------------------------------------------------------------------------
581 // This is used in C++ classes that need to be able to make callback to
582 // "overloaded" python methods
585 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
586 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
588 private: wxPyCallbackHelper m_myInst
591 //---------------------------------------------------------------------------
592 // The wxPythonApp class
595 wxPYAPP_ASSERT_SUPPRESS
= 1,
596 wxPYAPP_ASSERT_EXCEPTION
= 2,
597 wxPYAPP_ASSERT_DIALOG
= 4,
598 wxPYAPP_ASSERT_LOG
= 8
601 class wxPyApp
: public wxApp
603 DECLARE_ABSTRACT_CLASS(wxPyApp
)
611 int GetAssertMode() { return m_assertMode
; }
612 void SetAssertMode(int mode
) { m_assertMode
= mode
; }
614 virtual bool OnInitGui();
615 virtual int OnExit();
617 virtual void OnAssertFailure(const wxChar
*file
,
623 virtual void ExitMainLoop();
624 // virtual int FilterEvent(wxEvent& event); // This one too????
626 // For catching Apple Events
627 virtual void MacOpenFile(const wxString
&fileName
);
628 virtual void MacPrintFile(const wxString
&fileName
);
629 virtual void MacNewFile();
630 virtual void MacReopenApp();
632 static bool GetMacSupportPCMenuShortcuts();
633 static long GetMacAboutMenuItemId();
634 static long GetMacPreferencesMenuItemId();
635 static long GetMacExitMenuItemId();
636 static wxString
GetMacHelpMenuTitleName();
638 static void SetMacSupportPCMenuShortcuts(bool val
);
639 static void SetMacAboutMenuItemId(long val
);
640 static void SetMacPreferencesMenuItemId(long val
);
641 static void SetMacExitMenuItemId(long val
);
642 static void SetMacHelpMenuTitleName(const wxString
& val
);
645 void _BootstrapApp();
647 // implementation only
648 void SetStartupComplete(bool val
) { m_startupComplete
= val
; };
652 bool m_startupComplete
;
655 extern wxPyApp
*wxPythonApp
;
658 //----------------------------------------------------------------------
659 // These macros are used to implement the virtual methods that should
660 // redirect to a Python method if one exists. The names designate the
661 // return type, if any, as well as any parameter types.
662 //---------------------------------------------------------------------------
664 #define DEC_PYCALLBACK__(CBNAME) \
668 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
669 void CLASS::CBNAME() { \
671 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
672 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
673 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
674 wxPyEndBlockThreads(blocked); \
679 #define DEC_PYCALLBACK_VOID_(CBNAME) \
680 DEC_PYCALLBACK__(CBNAME)
682 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
683 IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME)
685 //---------------------------------------------------------------------------
687 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
688 bool CBNAME(int a, int b)
691 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
692 bool CLASS::CBNAME(int a, int b) { \
693 bool rval=false, found; \
694 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
695 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
696 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
697 wxPyEndBlockThreads(blocked); \
699 rval = PCLASS::CBNAME(a,b); \
703 //---------------------------------------------------------------------------
705 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
706 void CBNAME(int a, int b)
709 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
710 void CLASS::CBNAME(int a, int b) { \
712 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
713 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
714 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
715 wxPyEndBlockThreads(blocked); \
717 PCLASS::CBNAME(a,b); \
720 //---------------------------------------------------------------------------
722 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
726 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
727 void CLASS::CBNAME(int a) { \
729 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
730 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
731 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
732 wxPyEndBlockThreads(blocked); \
737 //---------------------------------------------------------------------------
739 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
740 void CBNAME(int a, int b, int c, int d)
743 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
744 void CLASS::CBNAME(int a, int b, int c, int d) { \
746 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
747 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
748 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
749 wxPyEndBlockThreads(blocked); \
751 PCLASS::CBNAME(a,b,c,d); \
754 //---------------------------------------------------------------------------
755 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
756 void CBNAME(int a, int b, int c, int d, int e)
759 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
760 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
762 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
763 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
764 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
765 wxPyEndBlockThreads(blocked); \
767 PCLASS::CBNAME(a,b,c,d,e); \
770 //---------------------------------------------------------------------------
772 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
773 void CBNAME(int* a, int* b) const
776 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
777 void CLASS::CBNAME(int* a, int* b) const { \
778 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
780 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
781 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
783 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
785 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
786 PyObject* o1 = PySequence_GetItem(ro, 0); \
787 PyObject* o2 = PySequence_GetItem(ro, 1); \
788 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
789 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
792 PyErr_SetString(PyExc_TypeError, errmsg); \
797 PyErr_SetString(PyExc_TypeError, errmsg); \
802 wxPyEndBlockThreads(blocked); \
804 PCLASS::CBNAME(a,b); \
807 //---------------------------------------------------------------------------
809 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
810 wxSize CBNAME() const
813 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
814 wxSize CLASS::CBNAME() const { \
815 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
816 bool found; wxSize rval(0,0); \
817 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
818 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
820 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
822 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
823 PyObject* o1 = PySequence_GetItem(ro, 0); \
824 PyObject* o2 = PySequence_GetItem(ro, 1); \
825 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
826 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
829 PyErr_SetString(PyExc_TypeError, errmsg); \
834 PyErr_SetString(PyExc_TypeError, errmsg); \
839 wxPyEndBlockThreads(blocked); \
841 return PCLASS::CBNAME(); \
846 //---------------------------------------------------------------------------
848 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
852 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
853 bool CLASS::CBNAME(bool a) { \
854 bool rval=false, found; \
855 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
856 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
857 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
858 wxPyEndBlockThreads(blocked); \
860 rval = PCLASS::CBNAME(a); \
864 //---------------------------------------------------------------------------
866 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
870 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
871 bool CLASS::CBNAME(int a) { \
872 bool rval=false, found; \
873 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
874 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
875 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
876 wxPyEndBlockThreads(blocked); \
878 rval = PCLASS::CBNAME(a); \
882 //---------------------------------------------------------------------------
884 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
888 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
889 bool CLASS::CBNAME(int a) { \
891 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
892 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
893 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
895 wxPyEndBlockThreads(blocked); \
900 //---------------------------------------------------------------------------
902 #define DEC_PYCALLBACK__DC(CBNAME) \
906 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
907 void CLASS::CBNAME(wxDC& a) { \
909 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
910 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
911 PyObject* obj = wxPyMake_wxObject(&a,false); \
912 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
915 wxPyEndBlockThreads(blocked); \
921 //---------------------------------------------------------------------------
923 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
924 void CBNAME(wxDC& a, bool b)
927 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
928 void CLASS::CBNAME(wxDC& a, bool b) { \
930 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
931 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
932 PyObject* obj = wxPyMake_wxObject(&a,false); \
933 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
936 wxPyEndBlockThreads(blocked); \
938 PCLASS::CBNAME(a, b); \
941 //---------------------------------------------------------------------------
943 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
944 void CBNAME(wxDC& a, bool b)
947 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
948 void CLASS::CBNAME(wxDC& a, bool b) { \
950 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
951 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
952 PyObject* obj = wxPyMake_wxObject(&a,false); \
953 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
956 wxPyEndBlockThreads(blocked); \
958 PCLASS::CBNAME(a, b); \
961 //---------------------------------------------------------------------------
963 #define DEC_PYCALLBACK__2DBL(CBNAME) \
964 void CBNAME(double a, double b)
967 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
968 void CLASS::CBNAME(double a, double b) { \
970 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
971 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
972 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
973 wxPyEndBlockThreads(blocked); \
975 PCLASS::CBNAME(a, b); \
978 //---------------------------------------------------------------------------
980 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
981 void CBNAME(double a, double b, int c, int d)
984 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
985 void CLASS::CBNAME(double a, double b, int c, int d) { \
987 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
988 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
989 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
991 wxPyEndBlockThreads(blocked); \
993 PCLASS::CBNAME(a, b, c, d); \
996 //---------------------------------------------------------------------------
998 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
999 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1002 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1003 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1005 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1006 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1007 PyObject* obj = wxPyMake_wxObject(&a,false); \
1008 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
1011 wxPyEndBlockThreads(blocked); \
1013 PCLASS::CBNAME(a, b, c, d, e, f); \
1016 //---------------------------------------------------------------------------
1018 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
1019 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1022 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1023 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1025 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1027 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1028 PyObject* obj = wxPyMake_wxObject(&a,false); \
1029 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1032 wxPyEndBlockThreads(blocked); \
1034 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1038 //---------------------------------------------------------------------------
1040 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1041 void CBNAME(bool a, double b, double c, int d, int e)
1044 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1045 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1047 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1048 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1049 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1051 wxPyEndBlockThreads(blocked); \
1053 PCLASS::CBNAME(a, b, c, d, e); \
1056 //---------------------------------------------------------------------------
1058 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1059 void CBNAME(wxDC& a, double b, double c, double d, double e)
1062 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1063 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1065 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1066 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1067 PyObject* obj = wxPyMake_wxObject(&a,false); \
1068 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1071 wxPyEndBlockThreads(blocked); \
1073 PCLASS::CBNAME(a, b, c, d, e); \
1076 //---------------------------------------------------------------------------
1078 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1079 void CBNAME(wxDC& a, bool b)
1082 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1083 void CLASS::CBNAME(wxDC& a, bool b) { \
1085 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1086 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1087 PyObject* obj = wxPyMake_wxObject(&a,false); \
1088 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1091 wxPyEndBlockThreads(blocked); \
1093 PCLASS::CBNAME(a, b); \
1096 //---------------------------------------------------------------------------
1098 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1099 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1102 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1103 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1106 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1107 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1108 PyObject* obj = wxPyMake_wxObject(a,false); \
1109 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1112 wxPyEndBlockThreads(blocked); \
1114 PCLASS::CBNAME(a, b, c, d, e, f); \
1117 //---------------------------------------------------------------------------
1119 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1120 void CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1123 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1124 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1126 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1127 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1128 PyObject* obj = wxPyMake_wxObject(a,false); \
1129 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1132 wxPyEndBlockThreads(blocked); \
1134 PCLASS::CBNAME(a, b, c, d, e); \
1137 //---------------------------------------------------------------------------
1139 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1140 void CBNAME(double a, double b, int c)
1143 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1144 void CLASS::CBNAME(double a, double b, int c) { \
1146 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1147 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1148 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1149 wxPyEndBlockThreads(blocked); \
1151 PCLASS::CBNAME(a, b, c); \
1154 //---------------------------------------------------------------------------
1156 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1157 void CBNAME(bool a, double b, double c, int d)
1160 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1161 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1163 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1164 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1165 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1166 wxPyEndBlockThreads(blocked); \
1168 PCLASS::CBNAME(a, b, c, d); \
1171 //---------------------------------------------------------------------------
1172 //---------------------------------------------------------------------------
1174 #define DEC_PYCALLBACK__STRING(CBNAME) \
1175 void CBNAME(const wxString& a)
1177 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1178 void CLASS::CBNAME(const wxString& a) { \
1180 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1181 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1182 PyObject* s = wx2PyString(a); \
1183 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1186 wxPyEndBlockThreads(blocked); \
1188 PCLASS::CBNAME(a); \
1191 //---------------------------------------------------------------------------
1193 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1194 bool CBNAME(const wxString& a)
1196 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1197 bool CLASS::CBNAME(const wxString& a) { \
1200 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1201 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1202 PyObject* s = wx2PyString(a); \
1203 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1206 wxPyEndBlockThreads(blocked); \
1208 rval = PCLASS::CBNAME(a); \
1212 //---------------------------------------------------------------------------
1214 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1215 bool CBNAME(const wxString& a)
1217 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1218 bool CLASS::CBNAME(const wxString& a) { \
1220 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1221 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1222 PyObject* s = wx2PyString(a); \
1223 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1226 wxPyEndBlockThreads(blocked); \
1230 //---------------------------------------------------------------------------
1232 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1233 wxString CBNAME(const wxString& a)
1235 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1236 wxString CLASS::CBNAME(const wxString& a) { \
1238 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1239 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1241 PyObject* s = wx2PyString(a); \
1242 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1245 rval = Py2wxString(ro); \
1249 wxPyEndBlockThreads(blocked); \
1253 //---------------------------------------------------------------------------
1255 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1256 wxString CBNAME(const wxString& a)
1258 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1259 wxString CLASS::CBNAME(const wxString& a) { \
1262 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1263 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1265 PyObject* s = wx2PyString(a); \
1266 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1269 rval = Py2wxString(ro); \
1274 rval = PCLASS::CBNAME(a); \
1275 wxPyEndBlockThreads(blocked); \
1279 //---------------------------------------------------------------------------
1281 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1282 wxString CBNAME(const wxString& a,int b)
1284 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1285 wxString CLASS::CBNAME(const wxString& a,int b) { \
1287 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1288 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1290 PyObject* s = wx2PyString(a); \
1291 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1294 rval = Py2wxString(ro); \
1298 wxPyEndBlockThreads(blocked); \
1302 //---------------------------------------------------------------------------
1304 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1305 bool CBNAME(const wxString& a, const wxString& b)
1307 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1308 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1311 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1312 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1313 PyObject* s1 = wx2PyString(a); \
1314 PyObject* s2 = wx2PyString(b); \
1315 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1319 wxPyEndBlockThreads(blocked); \
1321 rval = PCLASS::CBNAME(a, b); \
1325 //---------------------------------------------------------------------------
1327 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1330 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1331 wxString CLASS::CBNAME() { \
1334 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1335 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1337 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1339 rval = Py2wxString(ro); \
1343 wxPyEndBlockThreads(blocked); \
1345 rval = PCLASS::CBNAME(); \
1349 //---------------------------------------------------------------------------
1351 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1352 wxString CBNAME() const
1354 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1355 wxString CLASS::CBNAME() const { \
1358 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1359 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1361 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1363 rval = Py2wxString(ro); \
1367 wxPyEndBlockThreads(blocked); \
1369 rval = PCLASS::CBNAME(); \
1373 //---------------------------------------------------------------------------
1375 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1378 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1379 wxString CLASS::CBNAME() { \
1381 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1382 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1384 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1386 rval = Py2wxString(ro); \
1390 wxPyEndBlockThreads(blocked); \
1394 //---------------------------------------------------------------------------
1396 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1397 wxString CBNAME() const;
1399 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1400 wxString CLASS::CBNAME() const { \
1402 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1403 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1405 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1407 rval = Py2wxString(ro); \
1411 wxPyEndBlockThreads(blocked); \
1415 //---------------------------------------------------------------------------
1417 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1418 bool CBNAME(const wxHtmlTag& a)
1421 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1422 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1424 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1425 if (wxPyCBH_findCallback2(m_myInst, #CBNAME, false)) { \
1426 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
1427 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1430 wxPyEndBlockThreads(blocked); \
1434 //---------------------------------------------------------------------------
1436 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1437 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1439 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1440 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1442 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1443 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1444 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1445 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1448 wxPyEndBlockThreads(blocked); \
1450 PCLASS::CBNAME(cell, x, y); \
1453 //---------------------------------------------------------------------------
1455 #define DEC_PYCALLBACK__COLOUR(CBNAME) \
1456 void CBNAME(const wxColour& c);
1458 #define IMP_PYCALLBACK__COLOUR(CLASS, PCLASS, CBNAME) \
1459 void CLASS::CBNAME(const wxColour& c) { \
1461 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1462 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1463 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1464 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1467 wxPyEndBlockThreads(blocked); \
1469 PCLASS::CBNAME(c); \
1472 //---------------------------------------------------------------------------
1473 #define DEC_PYCALLBACK__INTCOLOUR(CBNAME) \
1474 void CBNAME(int a, const wxColour& c);
1476 #define IMP_PYCALLBACK__INTCOLOUR(CLASS, PCLASS, CBNAME) \
1477 void CLASS::CBNAME(int a, const wxColour& c) { \
1479 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1480 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1481 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1482 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)",a, obj)); \
1485 wxPyEndBlockThreads(blocked); \
1487 PCLASS::CBNAME(a, c); \
1490 //---------------------------------------------------------------------------
1492 #define DEC_PYCALLBACK__INTFONT(CBNAME) \
1493 void CBNAME(int a, const wxFont& c);
1495 #define IMP_PYCALLBACK__INTFONT(CLASS, PCLASS, CBNAME) \
1496 void CLASS::CBNAME(int a, const wxFont& c) { \
1498 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1499 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1500 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxFont"), 0); \
1501 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)",a, obj)); \
1504 wxPyEndBlockThreads(blocked); \
1506 PCLASS::CBNAME(a, c); \
1509 //---------------------------------------------------------------------------
1511 #define DEC_PYCALLBACK_BOOL_CELLINTINTME(CBNAME) \
1512 bool CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1514 #define IMP_PYCALLBACK_BOOL_CELLINTINTME(CLASS, PCLASS, CBNAME) \
1515 bool CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1516 bool rval=false, found; \
1517 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1518 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1519 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1520 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1521 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1525 wxPyEndBlockThreads(blocked); \
1527 rval = PCLASS::CBNAME(cell, x, y, e); \
1532 //---------------------------------------------------------------------------
1534 #define DEC_PYCALLBACK___pure(CBNAME) \
1538 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1539 void CLASS::CBNAME() { \
1540 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1541 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1542 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1543 wxPyEndBlockThreads(blocked); \
1546 //---------------------------------------------------------------------------
1548 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1552 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1553 wxSize CLASS::CBNAME() { \
1554 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1556 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1557 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1560 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1562 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1564 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1566 PyObject* o1 = PySequence_GetItem(ro, 0); \
1567 PyObject* o2 = PySequence_GetItem(ro, 1); \
1568 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1569 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1571 PyErr_SetString(PyExc_TypeError, errmsg); \
1576 PyErr_SetString(PyExc_TypeError, errmsg); \
1581 wxPyEndBlockThreads(blocked); \
1585 //---------------------------------------------------------------------------
1587 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1588 bool CBNAME(wxWindow* a)
1591 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1592 bool CLASS::CBNAME(wxWindow* a) { \
1595 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1596 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1597 PyObject* obj = wxPyMake_wxObject(a,false); \
1598 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1601 wxPyEndBlockThreads(blocked); \
1603 rval = PCLASS::CBNAME(a); \
1607 //---------------------------------------------------------------------------
1609 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1610 bool CBNAME(wxWindow* a, wxDC& b)
1613 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1614 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1617 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1618 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1619 PyObject* win = wxPyMake_wxObject(a,false); \
1620 PyObject* dc = wxPyMake_wxObject(&b,false); \
1621 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1625 wxPyEndBlockThreads(blocked); \
1627 rval = PCLASS::CBNAME(a, b); \
1631 //---------------------------------------------------------------------------
1633 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1634 void CBNAME(wxWindowBase* a)
1637 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1638 void CLASS::CBNAME(wxWindowBase* a) { \
1640 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1641 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1642 PyObject* obj = wxPyMake_wxObject(a,false); \
1643 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1646 wxPyEndBlockThreads(blocked); \
1648 PCLASS::CBNAME(a); \
1651 //---------------------------------------------------------------------------
1653 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1657 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1658 bool CLASS::CBNAME() { \
1661 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1662 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1663 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1664 wxPyEndBlockThreads(blocked); \
1666 rval = PCLASS::CBNAME(); \
1670 //---------------------------------------------------------------------------
1672 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1676 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1677 bool CLASS::CBNAME() const { \
1680 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1681 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1682 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1683 wxPyEndBlockThreads(blocked); \
1685 rval = PCLASS::CBNAME(); \
1689 //---------------------------------------------------------------------------
1691 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1692 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1695 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1696 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1699 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1700 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1701 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1702 wxPyEndBlockThreads(blocked); \
1704 rval = PCLASS::CBNAME(a, b, c); \
1705 return (wxDragResult)rval; \
1708 //---------------------------------------------------------------------------
1710 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1711 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1713 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1714 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1715 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1717 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1719 PyObject* obj = wxPyMake_wxObject(&a,false); \
1720 PyObject* s = wx2PyString(b); \
1721 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1724 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
1725 /* release ownership of the C++ wx.FSFile object. */ \
1726 PyObject_SetAttrString(ro, "thisown", Py_False); \
1732 wxPyEndBlockThreads(blocked); \
1736 //---------------------------------------------------------------------------
1738 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1739 bool CBNAME(wxDragResult a)
1742 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1743 bool CLASS::CBNAME(wxDragResult a) { \
1746 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1747 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1748 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1749 wxPyEndBlockThreads(blocked); \
1751 rval = PCLASS::CBNAME(a); \
1755 //---------------------------------------------------------------------------
1757 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1758 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1761 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1762 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1763 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1765 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1766 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1767 wxPyEndBlockThreads(blocked); \
1768 return (wxDragResult)rval; \
1771 //---------------------------------------------------------------------------
1773 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1774 bool CBNAME(int a, int b, const wxString& c)
1776 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1777 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1779 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1780 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1781 PyObject* s = wx2PyString(c); \
1782 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1785 wxPyEndBlockThreads(blocked); \
1789 //---------------------------------------------------------------------------
1791 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1795 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1796 size_t CLASS::CBNAME() { \
1799 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1800 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1801 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1802 wxPyEndBlockThreads(blocked); \
1804 rval = PCLASS::CBNAME(); \
1808 //---------------------------------------------------------------------------
1810 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1811 size_t CBNAME() const
1814 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1815 size_t CLASS::CBNAME() const { \
1818 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1819 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1820 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1821 wxPyEndBlockThreads(blocked); \
1823 rval = PCLASS::CBNAME(); \
1827 //---------------------------------------------------------------------------
1829 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1830 wxDataFormat CBNAME(size_t a)
1833 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1834 wxDataFormat CLASS::CBNAME(size_t a) { \
1835 wxDataFormat rval=0; \
1837 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1838 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1840 wxDataFormat* ptr; \
1841 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1843 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1848 wxPyEndBlockThreads(blocked); \
1850 rval = PCLASS::CBNAME(a); \
1854 //---------------------------------------------------------------------------
1856 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1857 void CBNAME(const Type& a)
1860 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1861 void CLASS::CBNAME(const Type& a) { \
1863 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1864 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1865 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1866 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1869 wxPyEndBlockThreads(blocked); \
1871 PCLASS::CBNAME(a); \
1875 //---------------------------------------------------------------------------
1877 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1878 void CBNAME(Type& a)
1881 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1882 void CLASS::CBNAME(Type& a) { \
1884 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1885 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1886 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1887 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1890 wxPyEndBlockThreads(blocked); \
1892 PCLASS::CBNAME(a); \
1895 //---------------------------------------------------------------------------
1897 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1898 bool CBNAME(Type& a)
1901 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1902 bool CLASS::CBNAME(Type& a) { \
1905 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1906 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1907 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1908 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1911 wxPyEndBlockThreads(blocked); \
1913 rv = PCLASS::CBNAME(a); \
1917 //---------------------------------------------------------------------------
1919 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
1920 bool CBNAME(Type& a)
1923 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
1924 bool CLASS::CBNAME(Type& a) { \
1926 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1927 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1928 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1929 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1932 wxPyEndBlockThreads(blocked); \
1936 //---------------------------------------------------------------------------
1938 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1939 wxString CBNAME(long a, long b) const
1941 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1942 wxString CLASS::CBNAME(long a, long b) const { \
1945 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1946 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1948 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1950 rval = Py2wxString(ro); \
1954 wxPyEndBlockThreads(blocked); \
1956 rval = PCLASS::CBNAME(a,b); \
1960 //---------------------------------------------------------------------------
1962 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1963 int CBNAME(long a) const
1966 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1967 int CLASS::CBNAME(long a) const { \
1970 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1971 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1973 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1975 rval = PyInt_AsLong(ro); \
1979 wxPyEndBlockThreads(blocked); \
1981 rval = PCLASS::CBNAME(a); \
1986 #define DEC_PYCALLBACK_INT_LONG_virtual(CBNAME) \
1987 int CBNAME(long a) const;
1990 #define IMP_PYCALLBACK_INT_LONG_virtual(CLASS, PCLASS, CBNAME) \
1991 int CLASS::CBNAME(long a) const { \
1992 int rval=-1; /* this rval is important for OnGetItemImage */ \
1994 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1995 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1997 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1999 rval = PyInt_AsLong(ro); \
2003 wxPyEndBlockThreads(blocked); \
2008 //---------------------------------------------------------------------------
2010 #define DEC_PYCALLBACK_INT_INT(CBNAME) \
2014 #define IMP_PYCALLBACK_INT_INT(CLASS, PCLASS, CBNAME) \
2015 int CLASS::CBNAME(int a) { \
2018 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2019 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2021 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a)); \
2023 rval = PyInt_AsLong(ro); \
2027 wxPyEndBlockThreads(blocked); \
2029 rval = PCLASS::CBNAME(a); \
2033 //---------------------------------------------------------------------------
2035 #define DEC_PYCALLBACK_INT_LONGLONG(CBNAME) \
2036 int CBNAME(long a, long b) const
2039 #define IMP_PYCALLBACK_INT_LONGLONG(CLASS, PCLASS, CBNAME) \
2040 int CLASS::CBNAME(long a, long b) const { \
2043 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2044 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2046 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2048 rval = PyInt_AsLong(ro); \
2052 wxPyEndBlockThreads(blocked); \
2054 rval = PCLASS::CBNAME(a, b); \
2059 #define DEC_PYCALLBACK_INT_LONGLONG_virtual(CBNAME) \
2060 int CBNAME(long a, long b) const;
2063 #define IMP_PYCALLBACK_INT_LONGLONG_virtual(CLASS, PCLASS, CBNAME) \
2064 int CLASS::CBNAME(long a, long b) const { \
2065 int rval=-1; /* this rval is important for OnGetItemImage */ \
2067 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2068 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2070 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2072 rval = PyInt_AsLong(ro); \
2076 wxPyEndBlockThreads(blocked); \
2081 //---------------------------------------------------------------------------
2083 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2084 wxListItemAttr* CBNAME(long a) const
2087 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2088 wxListItemAttr *CLASS::CBNAME(long a) const { \
2089 wxListItemAttr *rval = NULL; \
2091 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2092 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2094 wxListItemAttr* ptr; \
2095 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2097 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2102 wxPyEndBlockThreads(blocked); \
2104 rval = PCLASS::CBNAME(a); \
2108 //---------------------------------------------------------------------------
2110 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2111 bool CBNAME(wxMouseEvent& e)
2113 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2114 bool CLASS::CBNAME(wxMouseEvent& e) { \
2117 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2118 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2120 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2121 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2123 rval = PyInt_AsLong(ro); \
2128 wxPyEndBlockThreads(blocked); \
2130 return PCLASS::CBNAME(e); \
2134 //---------------------------------------------------------------------------
2136 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2137 wxWizardPage* CBNAME() const
2139 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2140 wxWizardPage* CLASS::CBNAME() const { \
2141 wxWizardPage* rv = NULL; \
2142 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2143 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2145 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2147 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2151 wxPyEndBlockThreads(blocked); \
2155 //---------------------------------------------------------------------------
2157 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2158 wxBitmap CBNAME() const
2160 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2161 wxBitmap CLASS::CBNAME() const { \
2163 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2164 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2167 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2169 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2174 wxPyEndBlockThreads(blocked); \
2178 //---------------------------------------------------------------------------
2180 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2183 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2184 wxObject* CLASS::CBNAME() { \
2185 wxObject* rv = NULL; \
2186 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2187 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2189 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2191 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2195 wxPyEndBlockThreads(blocked); \
2199 //---------------------------------------------------------------------------
2201 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2202 wxObject* CBNAME(const wxString& a)
2204 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2205 wxObject* CLASS::CBNAME(const wxString& a) { \
2206 wxObject* rv = NULL; \
2207 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2208 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2209 PyObject* so = wx2PyString(a); \
2211 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2213 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2218 wxPyEndBlockThreads(blocked); \
2222 //---------------------------------------------------------------------------
2224 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2225 bool CBNAME(wxXmlNode* a)
2228 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2229 bool CLASS::CBNAME(wxXmlNode* a) { \
2231 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2232 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2233 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2234 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2237 wxPyEndBlockThreads(blocked); \
2241 //---------------------------------------------------------------------------
2243 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2244 wxCoord CBNAME(size_t a) const
2247 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2248 wxCoord CLASS::CBNAME(size_t a) const { \
2251 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2252 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2253 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2255 wxPyEndBlockThreads(blocked); \
2259 //---------------------------------------------------------------------------
2261 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2262 void CBNAME(size_t a, size_t b) const
2265 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2266 void CLASS::CBNAME(size_t a, size_t b) const { \
2268 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2269 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2270 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2271 wxPyEndBlockThreads(blocked); \
2273 PCLASS::CBNAME(a,b); \
2275 //---------------------------------------------------------------------------
2277 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2278 wxCoord CBNAME() const
2281 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2282 wxCoord CLASS::CBNAME() const { \
2285 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2286 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2287 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2288 wxPyEndBlockThreads(blocked); \
2290 rval = PCLASS::CBNAME(); \
2294 //---------------------------------------------------------------------------
2296 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2297 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2299 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2300 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2302 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2303 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2304 PyObject* obj = wxPyMake_wxObject(&a,false); \
2305 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2306 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2307 Py_DECREF(obj); Py_DECREF(ro); \
2309 wxPyEndBlockThreads(blocked); \
2314 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2315 void CBNAME(wxDC& a, const wxRect& b, size_t c) const
2317 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2318 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2320 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2321 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2322 PyObject* obj = wxPyMake_wxObject(&a,false); \
2323 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2324 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2325 Py_DECREF(obj); Py_DECREF(ro); \
2327 wxPyEndBlockThreads(blocked); \
2329 PCLASS::CBNAME(a,b,c); \
2333 //---------------------------------------------------------------------------
2334 // Same as the above set, but the wxRect is not const
2336 #define DEC_PYCALLBACK__DCRECTSIZET2_constpure(CBNAME) \
2337 void CBNAME(wxDC& a, wxRect& b, size_t c) const;
2339 #define IMP_PYCALLBACK__DCRECTSIZET2_constpure(CLASS, PCLASS, CBNAME) \
2340 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2342 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2343 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2344 PyObject* obj = wxPyMake_wxObject(&a,false); \
2345 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2346 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2347 Py_DECREF(obj); Py_DECREF(ro); \
2349 wxPyEndBlockThreads(blocked); \
2354 #define DEC_PYCALLBACK__DCRECTSIZET2_const(CBNAME) \
2355 void CBNAME(wxDC& a, wxRect& b, size_t c) const
2357 #define IMP_PYCALLBACK__DCRECTSIZET2_const(CLASS, PCLASS, CBNAME) \
2358 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2360 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2361 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2362 PyObject* obj = wxPyMake_wxObject(&a,false); \
2363 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2364 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2365 Py_DECREF(obj); Py_DECREF(ro); \
2367 wxPyEndBlockThreads(blocked); \
2369 PCLASS::CBNAME(a,b,c); \
2372 //---------------------------------------------------------------------------
2374 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2375 wxString CBNAME(size_t a) const
2377 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2378 wxString CLASS::CBNAME(size_t a) const { \
2381 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2382 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2384 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2386 rval = Py2wxString(ro); \
2390 wxPyEndBlockThreads(blocked); \
2392 rval = PCLASS::CBNAME(a); \
2396 //---------------------------------------------------------------------------
2398 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2399 wxString CBNAME(size_t a) const
2401 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2402 wxString CLASS::CBNAME(size_t a) const { \
2405 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2406 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2408 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2410 rval = Py2wxString(ro); \
2414 wxPyEndBlockThreads(blocked); \
2418 //---------------------------------------------------------------------------
2420 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2421 wxVisualAttributes CBNAME() const
2424 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2425 wxVisualAttributes CLASS::CBNAME() const { \
2426 wxVisualAttributes rval; \
2428 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2429 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2431 wxVisualAttributes* ptr; \
2432 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2434 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2439 wxPyEndBlockThreads(blocked); \
2441 rval = PCLASS::CBNAME(); \
2445 //---------------------------------------------------------------------------
2447 #define DEC_PYCALLBACK_FONT_INT(CBNAME) \
2448 wxFont CBNAME(int a)
2450 #define IMP_PYCALLBACK_FONT_INT(CLASS, PCLASS, CBNAME) \
2451 wxFont CLASS::CBNAME(int a) { \
2454 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2455 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2458 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2460 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxFont"))) \
2465 wxPyEndBlockThreads(blocked); \
2467 rv = PCLASS::CBNAME(a); \
2471 //---------------------------------------------------------------------------
2473 #define DEC_PYCALLBACK_COLOUR_INT(CBNAME) \
2474 wxColour CBNAME(int a)
2476 #define IMP_PYCALLBACK_COLOUR_INT(CLASS, PCLASS, CBNAME) \
2477 wxColour CLASS::CBNAME(int a) { \
2480 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2481 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2484 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2486 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxColour"))) \
2491 wxPyEndBlockThreads(blocked); \
2493 rv = PCLASS::CBNAME(a); \
2497 //---------------------------------------------------------------------------