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 //---------------------------------------------------------------------------
1474 #define DEC_PYCALLBACK_BOOL_CELLINTINTME(CBNAME) \
1475 bool CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1477 #define IMP_PYCALLBACK_BOOL_CELLINTINTME(CLASS, PCLASS, CBNAME) \
1478 bool CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1479 bool rval=false, found; \
1480 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1481 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1482 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1483 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1484 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1488 wxPyEndBlockThreads(blocked); \
1490 rval = PCLASS::CBNAME(cell, x, y, e); \
1495 //---------------------------------------------------------------------------
1497 #define DEC_PYCALLBACK___pure(CBNAME) \
1501 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1502 void CLASS::CBNAME() { \
1503 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1504 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1505 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1506 wxPyEndBlockThreads(blocked); \
1509 //---------------------------------------------------------------------------
1511 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1515 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1516 wxSize CLASS::CBNAME() { \
1517 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1519 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1520 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1523 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1525 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1527 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1529 PyObject* o1 = PySequence_GetItem(ro, 0); \
1530 PyObject* o2 = PySequence_GetItem(ro, 1); \
1531 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1532 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1534 PyErr_SetString(PyExc_TypeError, errmsg); \
1539 PyErr_SetString(PyExc_TypeError, errmsg); \
1544 wxPyEndBlockThreads(blocked); \
1548 //---------------------------------------------------------------------------
1550 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1551 bool CBNAME(wxWindow* a)
1554 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1555 bool CLASS::CBNAME(wxWindow* a) { \
1558 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1559 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1560 PyObject* obj = wxPyMake_wxObject(a,false); \
1561 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1564 wxPyEndBlockThreads(blocked); \
1566 rval = PCLASS::CBNAME(a); \
1570 //---------------------------------------------------------------------------
1572 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1573 bool CBNAME(wxWindow* a, wxDC& b)
1576 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1577 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1580 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1581 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1582 PyObject* win = wxPyMake_wxObject(a,false); \
1583 PyObject* dc = wxPyMake_wxObject(&b,false); \
1584 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1588 wxPyEndBlockThreads(blocked); \
1590 rval = PCLASS::CBNAME(a, b); \
1594 //---------------------------------------------------------------------------
1596 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1597 void CBNAME(wxWindowBase* a)
1600 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1601 void CLASS::CBNAME(wxWindowBase* a) { \
1603 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1604 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1605 PyObject* obj = wxPyMake_wxObject(a,false); \
1606 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1609 wxPyEndBlockThreads(blocked); \
1611 PCLASS::CBNAME(a); \
1614 //---------------------------------------------------------------------------
1616 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1620 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1621 bool CLASS::CBNAME() { \
1624 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1625 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1626 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1627 wxPyEndBlockThreads(blocked); \
1629 rval = PCLASS::CBNAME(); \
1633 //---------------------------------------------------------------------------
1635 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1639 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1640 bool CLASS::CBNAME() const { \
1643 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1644 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1645 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1646 wxPyEndBlockThreads(blocked); \
1648 rval = PCLASS::CBNAME(); \
1652 //---------------------------------------------------------------------------
1654 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1655 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1658 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1659 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1662 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1663 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1664 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1665 wxPyEndBlockThreads(blocked); \
1667 rval = PCLASS::CBNAME(a, b, c); \
1668 return (wxDragResult)rval; \
1671 //---------------------------------------------------------------------------
1673 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1674 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1676 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1677 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1678 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1680 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1682 PyObject* obj = wxPyMake_wxObject(&a,false); \
1683 PyObject* s = wx2PyString(b); \
1684 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1687 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
1688 /* release ownership of the C++ wx.FSFile object. */ \
1689 PyObject_SetAttrString(ro, "thisown", Py_False); \
1695 wxPyEndBlockThreads(blocked); \
1699 //---------------------------------------------------------------------------
1701 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1702 bool CBNAME(wxDragResult a)
1705 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1706 bool CLASS::CBNAME(wxDragResult a) { \
1709 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1710 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1711 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1712 wxPyEndBlockThreads(blocked); \
1714 rval = PCLASS::CBNAME(a); \
1718 //---------------------------------------------------------------------------
1720 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1721 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1724 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1725 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1726 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1728 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1729 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1730 wxPyEndBlockThreads(blocked); \
1731 return (wxDragResult)rval; \
1734 //---------------------------------------------------------------------------
1736 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1737 bool CBNAME(int a, int b, const wxString& c)
1739 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1740 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1742 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1743 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1744 PyObject* s = wx2PyString(c); \
1745 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1748 wxPyEndBlockThreads(blocked); \
1752 //---------------------------------------------------------------------------
1754 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1758 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1759 size_t CLASS::CBNAME() { \
1762 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1763 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1764 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1765 wxPyEndBlockThreads(blocked); \
1767 rval = PCLASS::CBNAME(); \
1771 //---------------------------------------------------------------------------
1773 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1774 size_t CBNAME() const
1777 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1778 size_t CLASS::CBNAME() const { \
1781 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1782 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1783 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1784 wxPyEndBlockThreads(blocked); \
1786 rval = PCLASS::CBNAME(); \
1790 //---------------------------------------------------------------------------
1792 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1793 wxDataFormat CBNAME(size_t a)
1796 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1797 wxDataFormat CLASS::CBNAME(size_t a) { \
1798 wxDataFormat rval=0; \
1800 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1801 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1803 wxDataFormat* ptr; \
1804 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1806 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1811 wxPyEndBlockThreads(blocked); \
1813 rval = PCLASS::CBNAME(a); \
1817 //---------------------------------------------------------------------------
1819 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1820 void CBNAME(const Type& a)
1823 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1824 void CLASS::CBNAME(const Type& a) { \
1826 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1827 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1828 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1829 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1832 wxPyEndBlockThreads(blocked); \
1834 PCLASS::CBNAME(a); \
1838 //---------------------------------------------------------------------------
1840 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1841 void CBNAME(Type& a)
1844 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1845 void CLASS::CBNAME(Type& a) { \
1847 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1848 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1849 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1850 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1853 wxPyEndBlockThreads(blocked); \
1855 PCLASS::CBNAME(a); \
1858 //---------------------------------------------------------------------------
1860 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1861 bool CBNAME(Type& a)
1864 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1865 bool CLASS::CBNAME(Type& a) { \
1868 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1869 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1870 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1871 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1874 wxPyEndBlockThreads(blocked); \
1876 rv = PCLASS::CBNAME(a); \
1880 //---------------------------------------------------------------------------
1882 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
1883 bool CBNAME(Type& a)
1886 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
1887 bool CLASS::CBNAME(Type& a) { \
1889 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1890 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1891 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1892 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1895 wxPyEndBlockThreads(blocked); \
1899 //---------------------------------------------------------------------------
1901 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1902 wxString CBNAME(long a, long b) const
1904 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1905 wxString CLASS::CBNAME(long a, long b) const { \
1908 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1909 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1911 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1913 rval = Py2wxString(ro); \
1917 wxPyEndBlockThreads(blocked); \
1919 rval = PCLASS::CBNAME(a,b); \
1923 //---------------------------------------------------------------------------
1925 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1926 int CBNAME(long a) const
1929 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1930 int CLASS::CBNAME(long a) const { \
1933 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1934 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1936 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1938 rval = PyInt_AsLong(ro); \
1942 wxPyEndBlockThreads(blocked); \
1944 rval = PCLASS::CBNAME(a); \
1949 #define DEC_PYCALLBACK_INT_LONG_virtual(CBNAME) \
1950 int CBNAME(long a) const;
1953 #define IMP_PYCALLBACK_INT_LONG_virtual(CLASS, PCLASS, CBNAME) \
1954 int CLASS::CBNAME(long a) const { \
1955 int rval=-1; /* this rval is important for OnGetItemImage */ \
1957 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1958 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1960 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1962 rval = PyInt_AsLong(ro); \
1966 wxPyEndBlockThreads(blocked); \
1971 //---------------------------------------------------------------------------
1973 #define DEC_PYCALLBACK_INT_LONGLONG(CBNAME) \
1974 int CBNAME(long a, long b) const
1977 #define IMP_PYCALLBACK_INT_LONGLONG(CLASS, PCLASS, CBNAME) \
1978 int CLASS::CBNAME(long a, long b) const { \
1981 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1982 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1984 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1986 rval = PyInt_AsLong(ro); \
1990 wxPyEndBlockThreads(blocked); \
1992 rval = PCLASS::CBNAME(a, b); \
1997 #define DEC_PYCALLBACK_INT_LONGLONG_virtual(CBNAME) \
1998 int CBNAME(long a, long b) const;
2001 #define IMP_PYCALLBACK_INT_LONGLONG_virtual(CLASS, PCLASS, CBNAME) \
2002 int CLASS::CBNAME(long a, long b) const { \
2003 int rval=-1; /* this rval is important for OnGetItemImage */ \
2005 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2006 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2008 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2010 rval = PyInt_AsLong(ro); \
2014 wxPyEndBlockThreads(blocked); \
2019 //---------------------------------------------------------------------------
2021 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2022 wxListItemAttr* CBNAME(long a) const
2025 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2026 wxListItemAttr *CLASS::CBNAME(long a) const { \
2027 wxListItemAttr *rval = NULL; \
2029 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2030 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2032 wxListItemAttr* ptr; \
2033 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2035 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2040 wxPyEndBlockThreads(blocked); \
2042 rval = PCLASS::CBNAME(a); \
2046 //---------------------------------------------------------------------------
2048 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2049 bool CBNAME(wxMouseEvent& e)
2051 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2052 bool CLASS::CBNAME(wxMouseEvent& e) { \
2055 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2056 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2058 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2059 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2061 rval = PyInt_AsLong(ro); \
2066 wxPyEndBlockThreads(blocked); \
2068 return PCLASS::CBNAME(e); \
2072 //---------------------------------------------------------------------------
2074 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2075 wxWizardPage* CBNAME() const
2077 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2078 wxWizardPage* CLASS::CBNAME() const { \
2079 wxWizardPage* rv = NULL; \
2080 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2081 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2083 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2085 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2089 wxPyEndBlockThreads(blocked); \
2093 //---------------------------------------------------------------------------
2095 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2096 wxBitmap CBNAME() const
2098 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2099 wxBitmap CLASS::CBNAME() const { \
2101 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2102 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2105 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2107 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2112 wxPyEndBlockThreads(blocked); \
2116 //---------------------------------------------------------------------------
2118 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2121 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2122 wxObject* CLASS::CBNAME() { \
2123 wxObject* rv = NULL; \
2124 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2125 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2127 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2129 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2133 wxPyEndBlockThreads(blocked); \
2137 //---------------------------------------------------------------------------
2139 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2140 wxObject* CBNAME(const wxString& a)
2142 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2143 wxObject* CLASS::CBNAME(const wxString& a) { \
2144 wxObject* rv = NULL; \
2145 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2146 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2147 PyObject* so = wx2PyString(a); \
2149 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2151 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2156 wxPyEndBlockThreads(blocked); \
2160 //---------------------------------------------------------------------------
2162 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2163 bool CBNAME(wxXmlNode* a)
2166 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2167 bool CLASS::CBNAME(wxXmlNode* a) { \
2169 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2170 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2171 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2172 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2175 wxPyEndBlockThreads(blocked); \
2179 //---------------------------------------------------------------------------
2181 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2182 wxCoord CBNAME(size_t a) const
2185 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2186 wxCoord CLASS::CBNAME(size_t a) const { \
2189 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2190 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2191 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2193 wxPyEndBlockThreads(blocked); \
2197 //---------------------------------------------------------------------------
2199 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2200 void CBNAME(size_t a, size_t b) const
2203 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2204 void CLASS::CBNAME(size_t a, size_t b) const { \
2206 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2207 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2208 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2209 wxPyEndBlockThreads(blocked); \
2211 PCLASS::CBNAME(a,b); \
2213 //---------------------------------------------------------------------------
2215 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2216 wxCoord CBNAME() const
2219 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2220 wxCoord CLASS::CBNAME() const { \
2223 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2224 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2225 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2226 wxPyEndBlockThreads(blocked); \
2228 rval = PCLASS::CBNAME(); \
2232 //---------------------------------------------------------------------------
2234 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2235 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2237 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2238 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2240 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2241 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2242 PyObject* obj = wxPyMake_wxObject(&a,false); \
2243 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2244 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2247 wxPyEndBlockThreads(blocked); \
2252 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2253 void CBNAME(wxDC& a, const wxRect& b, size_t c) const
2255 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2256 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2258 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2259 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2260 PyObject* obj = wxPyMake_wxObject(&a,false); \
2261 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2262 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2265 wxPyEndBlockThreads(blocked); \
2267 PCLASS::CBNAME(a,b,c); \
2271 //---------------------------------------------------------------------------
2272 // Same as the above set, but the wxRect is not const
2274 #define DEC_PYCALLBACK__DCRECTSIZET2_constpure(CBNAME) \
2275 void CBNAME(wxDC& a, wxRect& b, size_t c) const;
2277 #define IMP_PYCALLBACK__DCRECTSIZET2_constpure(CLASS, PCLASS, CBNAME) \
2278 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2280 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2281 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2282 PyObject* obj = wxPyMake_wxObject(&a,false); \
2283 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2284 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2287 wxPyEndBlockThreads(blocked); \
2292 #define DEC_PYCALLBACK__DCRECTSIZET2_const(CBNAME) \
2293 void CBNAME(wxDC& a, wxRect& b, size_t c) const
2295 #define IMP_PYCALLBACK__DCRECTSIZET2_const(CLASS, PCLASS, CBNAME) \
2296 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2298 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2299 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2300 PyObject* obj = wxPyMake_wxObject(&a,false); \
2301 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2302 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2305 wxPyEndBlockThreads(blocked); \
2307 PCLASS::CBNAME(a,b,c); \
2312 //---------------------------------------------------------------------------
2316 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2317 wxString CBNAME(size_t a) const
2319 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2320 wxString CLASS::CBNAME(size_t a) const { \
2323 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2324 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2326 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2328 rval = Py2wxString(ro); \
2332 wxPyEndBlockThreads(blocked); \
2334 rval = PCLASS::CBNAME(a); \
2338 //---------------------------------------------------------------------------
2340 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2341 wxString CBNAME(size_t a) const
2343 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2344 wxString CLASS::CBNAME(size_t a) const { \
2347 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2348 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2350 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2352 rval = Py2wxString(ro); \
2356 wxPyEndBlockThreads(blocked); \
2360 //---------------------------------------------------------------------------
2362 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2363 wxVisualAttributes CBNAME() const
2366 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2367 wxVisualAttributes CLASS::CBNAME() const { \
2368 wxVisualAttributes rval; \
2370 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2371 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2373 wxVisualAttributes* ptr; \
2374 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2376 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2381 wxPyEndBlockThreads(blocked); \
2383 rval = PCLASS::CBNAME(); \
2387 //---------------------------------------------------------------------------