1 ////////////////////////////////////////////////////////////////////////////
2 // Name: wxPython_int.h (int == internal)
3 // Purpose: Helper functions/classes for the wxPython extension module
4 // This header should only be inclued directly by those source
5 // modules included in the wx._core module. All others should
6 // include wx/wxPython/wxPython.h instead.
10 // Created: 1-July-1997
12 // Copyright: (c) 1998 by Total Control Software
13 // Licence: wxWindows license
14 /////////////////////////////////////////////////////////////////////////////
16 #ifndef __wxp_helpers__
17 #define __wxp_helpers__
21 #include <wx/busyinfo.h>
23 #include <wx/choicebk.h>
24 #include <wx/clipbrd.h>
25 #include <wx/colordlg.h>
26 #include <wx/config.h>
27 #include <wx/cshelp.h>
28 #include <wx/dcmirror.h>
30 #include <wx/dirctrl.h>
31 #include <wx/dirdlg.h>
33 #include <wx/docview.h>
34 #include <wx/encconv.h>
35 #include <wx/fdrepdlg.h>
36 #include <wx/fileconf.h>
37 #include <wx/filesys.h>
38 #include <wx/fontdlg.h>
39 #include <wx/fs_inet.h>
40 #include <wx/fs_mem.h>
41 #include <wx/fs_zip.h>
42 #include <wx/gbsizer.h>
43 #include <wx/geometry.h>
44 #include <wx/htmllbox.h>
46 #include <wx/imaglist.h>
48 #include <wx/laywin.h>
49 #include <wx/listbook.h>
50 #include <wx/minifram.h>
51 #include <wx/notebook.h>
53 #include <wx/printdlg.h>
54 #include <wx/process.h>
55 #include <wx/progdlg.h>
56 #include <wx/sashwin.h>
57 #include <wx/spinbutt.h>
58 #include <wx/spinctrl.h>
59 #include <wx/splash.h>
60 #include <wx/splitter.h>
61 #include <wx/statline.h>
62 #include <wx/stream.h>
63 #include <wx/sysopt.h>
64 #include <wx/taskbar.h>
65 #include <wx/tglbtn.h>
66 #include <wx/tipwin.h>
67 #include <wx/toolbook.h>
68 #include <wx/tooltip.h>
69 #include <wx/treebook.h>
71 #include <wx/vscroll.h>
72 #include <wx/dateevt.h>
73 #include <wx/datectrl.h>
75 #include <wx/hyperlink.h>
79 # pragma warning(disable:4800)
80 # pragma warning(disable:4190)
83 #ifdef __WXMAC__ // avoid a bug in Carbon headers
87 //---------------------------------------------------------------------------
89 #ifndef wxHAS_POWER_EVENTS
90 class wxPowerEvent
: public wxEvent
93 wxPowerEvent(wxEventType evtType
) : wxEvent(wxID_NONE
, evtType
) {}
95 bool IsVetoed() const { return false; }
96 virtual wxEvent
*Clone() const { return new wxPowerEvent(*this); }
100 //---------------------------------------------------------------------------
101 typedef unsigned char byte
;
102 typedef wxPoint2DDouble wxPoint2D
;
104 #ifndef SWIG_TYPE_TABLE
105 #define SWIG_TYPE_TABLE wxPython_type_table
109 #define wxDEFAULT_STATUSBAR_STYLE wxST_SIZEGRIP|wxFULL_REPAINT_ON_RESIZE
111 #define wxDEFAULT_STATUSBAR_STYLE wxST_SIZEGRIP
115 #ifndef wxPyUSE_EXPORTED_API
117 void __wxPyPreStart(PyObject
*);
118 void __wxPyCleanup();
119 PyObject
* __wxPySetDictionary(PyObject
*, PyObject
* args
);
121 void wxSetDefaultPyEncoding(const char* encoding
);
122 const char* wxGetDefaultPyEncoding();
125 void wxPyEventThunker(wxObject
*, wxEvent
& event
);
128 bool wxPyCheckSwigType(const wxChar
* className
);
129 PyObject
* wxPyConstructObject(void* ptr
,
130 const wxChar
* className
,
132 bool wxPyConvertSwigPtr(PyObject
* obj
, void **ptr
,
133 const wxChar
* className
);
134 PyObject
* wxPyMakeSwigPtr(void* ptr
, const wxChar
* classname
);
137 PyObject
* wx2PyString(const wxString
& src
);
138 wxString
Py2wxString(PyObject
* source
);
140 PyObject
* wxPyMake_wxObject(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
=true);
141 PyObject
* wxPyMake_wxSizer(wxSizer
* source
, bool setThisOwn
);
142 void wxPyPtrTypeMap_Add(const char* commonName
, const char* ptrName
);
144 PyObject
* wxPy_ConvertList(wxListBase
* list
);
145 long wxPyGetWinHandle(wxWindow
* win
);
147 void wxPy_ReinitStockObjects(int pass
);
149 bool wxPyInstance_Check(PyObject
* obj
);
150 bool wxPySwigInstance_Check(PyObject
* obj
);
153 #endif // wxPyUSE_EXPORTED_API
154 //---------------------------------------------------------------------------
156 // if we want to handle threads and Python threads are available...
157 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
158 #define WXP_WITH_THREAD
159 #else // no Python threads...
160 #undef WXP_WITH_THREAD
164 // In Python 2.3 and later there are the PyGILState_* APIs that we can use for
165 // blocking threads when calling back into Python. Using them instead of my
166 // home-grown hacks greatly simplifies wxPyBeginBlockThreads and
167 // wxPyEndBlockThreads.
169 // Unfortunatly there is a bug somewhere when using these new APIs on Python
170 // 2.3. It manifests in Boa Constructor's debugger where it is unable to stop
171 // at breakpoints located in event handlers. I think that the cause may be
172 // something like the original PyThreadState for the main thread is not being
173 // restored for the callbacks, but I can't see where that could be
174 // happening... So we'll only activate this new change for Python 2.4+ :-(
176 #if PY_VERSION_HEX < 0x02040000
177 #define wxPyUSE_GIL_STATE 0
178 typedef bool wxPyBlock_t
;
180 #define wxPyUSE_GIL_STATE 1
181 typedef PyGILState_STATE wxPyBlock_t
;
185 #ifndef wxPyUSE_EXPORTED_API
187 // For Python --> C++
188 PyThreadState
* wxPyBeginAllowThreads();
189 void wxPyEndAllowThreads(PyThreadState
* state
);
191 // For C++ --> Python
192 wxPyBlock_t
wxPyBeginBlockThreads();
193 void wxPyEndBlockThreads(wxPyBlock_t blocked
);
195 #endif // wxPyUSE_EXPORTED_API
198 // A macro that will help to execute simple statments wrapped in
199 // StartBlock/EndBlockThreads calls
200 #define wxPyBLOCK_THREADS(stmt) \
201 { wxPyBlock_t blocked = wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads(blocked); }
203 // Raise the NotImplementedError exception (blocking threads)
204 #define wxPyRaiseNotImplemented() \
205 wxPyBLOCK_THREADS(PyErr_SetNone(PyExc_NotImplementedError))
207 // Raise any exception with a string value (blocking threads)
208 #define wxPyErr_SetString(err, str) \
209 wxPyBLOCK_THREADS(PyErr_SetString(err, str))
212 //---------------------------------------------------------------------------
213 // These are helpers used by the typemaps
215 #ifndef wxPyUSE_EXPORTED_API
217 wxString
* wxString_in_helper(PyObject
* source
);
219 byte
* byte_LIST_helper(PyObject
* source
);
220 int* int_LIST_helper(PyObject
* source
);
221 long* long_LIST_helper(PyObject
* source
);
222 char** string_LIST_helper(PyObject
* source
);
223 wxPoint
* wxPoint_LIST_helper(PyObject
* source
, int* npoints
);
224 wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
225 wxString
* wxString_LIST_helper(PyObject
* source
);
226 wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
227 wxPen
** wxPen_LIST_helper(PyObject
* source
);
229 bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
230 bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
231 bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
232 bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
233 bool wxColour_helper(PyObject
* source
, wxColour
** obj
);
234 bool wxPoint2D_helper(PyObject
* source
, wxPoint2D
** obj
);
237 bool wxPySimple_typecheck(PyObject
* source
, const wxChar
* classname
, int seqLen
);
238 bool wxColour_typecheck(PyObject
* source
);
240 bool wxPyCheckForApp();
243 // Other helpful stuff
244 bool wxPy2int_seq_helper(PyObject
* source
, int* i1
, int* i2
);
245 bool wxPy4int_seq_helper(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
247 PyObject
* wxArrayString2PyList_helper(const wxArrayString
& arr
);
248 PyObject
* wxArrayInt2PyList_helper(const wxArrayInt
& arr
);
250 #endif // wxPyUSE_EXPORTED_API
252 //---------------------------------------------------------------------------
254 #if PYTHON_API_VERSION < 1009
255 #define PySequence_Fast_GET_ITEM(o, i) \
256 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
259 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
260 #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name)
261 #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val)
263 //---------------------------------------------------------------------------
265 #ifndef wxPyUSE_EXPORTED_API
267 class wxPyCallback
: public wxObject
{
268 DECLARE_ABSTRACT_CLASS(wxPyCallback
)
270 wxPyCallback(PyObject
* func
);
271 wxPyCallback(const wxPyCallback
& other
);
274 void EventThunker(wxEvent
& event
);
279 #endif // wxPyUSE_EXPORTED_API
280 //---------------------------------------------------------------------------
281 //---------------------------------------------------------------------------
282 // These Event classes can be derived from in Python and passed through the
283 // event system without loosing anything. They do this by keeping a reference
284 // to themselves and some special case handling in wxPyCallback::EventThunker.
288 class wxPyEvtSelfRef
{
293 void SetSelf(PyObject
* self
, bool clone
=false);
294 PyObject
* GetSelf() const;
295 bool GetCloned() const { return m_cloned
; }
303 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
304 DECLARE_ABSTRACT_CLASS(wxPyEvent
)
306 wxPyEvent(int winid
=0, wxEventType commandType
= wxEVT_NULL
);
307 wxPyEvent(const wxPyEvent
& evt
);
310 virtual wxEvent
* Clone() const { return new wxPyEvent(*this); }
314 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
315 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent
)
317 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
318 wxPyCommandEvent(const wxPyCommandEvent
& evt
);
321 virtual wxEvent
* Clone() const { return new wxPyCommandEvent(*this); }
326 //----------------------------------------------------------------------
327 // Forward decalre a few things used in the exported API
328 class wxPyClientData
;
330 class wxPyOORClientData
;
331 class wxPyCBInputStream
;
333 void wxPyClientData_dtor(wxPyClientData
* self
);
334 void wxPyUserData_dtor(wxPyUserData
* self
);
335 void wxPyOORClientData_dtor(wxPyOORClientData
* self
);
336 wxPyCBInputStream
* wxPyCBInputStream_create(PyObject
*py
, bool block
);
337 wxPyCBInputStream
* wxPyCBInputStream_copy(wxPyCBInputStream
* other
);
339 //---------------------------------------------------------------------------
340 // Export a C API in a struct. Other modules will be able to load this from
341 // the wx.core module and will then have safe access to these functions, even if
342 // in another shared library.
344 class wxPyCallbackHelper
;
348 bool (*p_wxPyCheckSwigType
)(const wxChar
* className
);
349 PyObject
* (*p_wxPyConstructObject
)(void* ptr
, const wxChar
* className
, int setThisOwn
);
350 bool (*p_wxPyConvertSwigPtr
)(PyObject
* obj
, void **ptr
, const wxChar
* className
);
351 PyObject
* (*p_wxPyMakeSwigPtr
)(void* ptr
, const wxChar
* className
);
353 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
354 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
355 wxPyBlock_t (*p_wxPyBeginBlockThreads
)();
356 void (*p_wxPyEndBlockThreads
)(wxPyBlock_t blocked
);
358 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
);
360 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
361 wxString (*p_Py2wxString
)(PyObject
* source
);
362 PyObject
* (*p_wx2PyString
)(const wxString
& src
);
364 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
365 int* (*p_int_LIST_helper
)(PyObject
* source
);
366 long* (*p_long_LIST_helper
)(PyObject
* source
);
367 char** (*p_string_LIST_helper
)(PyObject
* source
);
368 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
369 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
370 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
371 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
373 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
374 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
375 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
376 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
377 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
378 bool (*p_wxPoint2D_helper
)(PyObject
* source
, wxPoint2DDouble
** obj
);
381 bool (*p_wxPySimple_typecheck
)(PyObject
* source
, const wxChar
* classname
, int seqLen
);
382 bool (*p_wxColour_typecheck
)(PyObject
* source
);
384 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
385 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
);
386 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
387 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
388 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
390 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
);
391 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
, bool setThisOwn
);
392 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
393 bool (*p_wxPy2int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
);
394 bool (*p_wxPy4int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
395 PyObject
* (*p_wxArrayString2PyList_helper
)(const wxArrayString
& arr
);
396 PyObject
* (*p_wxArrayInt2PyList_helper
)(const wxArrayInt
& arr
);
398 void (*p_wxPyClientData_dtor
)(wxPyClientData
*);
399 void (*p_wxPyUserData_dtor
)(wxPyUserData
*);
400 void (*p_wxPyOORClientData_dtor
)(wxPyOORClientData
*);
402 wxPyCBInputStream
* (*p_wxPyCBInputStream_create
)(PyObject
*py
, bool block
);
403 wxPyCBInputStream
* (*p_wxPyCBInputStream_copy
)(wxPyCBInputStream
* other
);
405 bool (*p_wxPyInstance_Check
)(PyObject
* obj
);
406 bool (*p_wxPySwigInstance_Check
)(PyObject
* obj
);
408 bool (*p_wxPyCheckForApp
)();
412 #ifdef wxPyUSE_EXPORTED_API
413 // Notice that this is static, not extern. This is by design, each module
414 // needs one, but doesn't have to use it.
415 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
;
416 inline wxPyCoreAPI
* wxPyGetCoreAPIPtr();
417 #endif // wxPyUSE_EXPORTED_API
419 //---------------------------------------------------------------------------
421 // A wxObject that holds a reference to a Python object
422 class wxPyUserData
: public wxObject
{
424 wxPyUserData(PyObject
* obj
) {
430 #ifdef wxPyUSE_EXPORTED_API
431 wxPyGetCoreAPIPtr()->p_wxPyUserData_dtor(this);
433 wxPyUserData_dtor(this);
440 // A wxClientData that holds a refernece to a Python object
441 class wxPyClientData
: public wxClientData
{
443 wxPyClientData(PyObject
* obj
, bool incref
=true) {
451 #ifdef wxPyUSE_EXPORTED_API
452 wxPyGetCoreAPIPtr()->p_wxPyClientData_dtor(this);
454 wxPyClientData_dtor(this);
462 // Just like wxPyClientData, except when this object is destroyed it does some
463 // OOR magic on the Python Object.
464 class wxPyOORClientData
: public wxPyClientData
{
466 wxPyOORClientData(PyObject
* obj
, bool incref
=true)
467 : wxPyClientData(obj
, incref
) {}
468 ~wxPyOORClientData() {
470 #ifdef wxPyUSE_EXPORTED_API
471 wxPyGetCoreAPIPtr()->p_wxPyOORClientData_dtor(this);
473 wxPyOORClientData_dtor(this);
479 //---------------------------------------------------------------------------
480 // A wxImageHandler that can be derived from in Python.
483 class wxPyImageHandler
: public wxImageHandler
{
487 // used for interning method names as PyStrings
488 static PyObject
* m_DoCanRead_Name
;
489 static PyObject
* m_GetImageCount_Name
;
490 static PyObject
* m_LoadFile_Name
;
491 static PyObject
* m_SaveFile_Name
;
493 // converstion helpers
494 PyObject
* py_InputStream(wxInputStream
* stream
);
495 PyObject
* py_Image(wxImage
* image
);
496 PyObject
* py_OutputStream(wxOutputStream
* stream
);
501 void _SetSelf(PyObject
*self
);
503 virtual bool LoadFile(wxImage
* image
, wxInputStream
& stream
,
504 bool verbose
=true, int index
=-1 );
505 virtual bool SaveFile(wxImage
* image
, wxOutputStream
& stream
,
507 virtual int GetImageCount(wxInputStream
& stream
);
508 virtual bool DoCanRead(wxInputStream
&stream
);
512 //---------------------------------------------------------------------------
513 // This class holds an instance of a Python Shadow Class object and assists
514 // with looking up and invoking Python callback methods from C++ virtual
515 // method redirections. For all classes which have virtuals which should be
516 // overridable in wxPython, a new subclass is created that contains a
517 // wxPyCallbackHelper.
520 class wxPyCallbackHelper
{
522 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
524 wxPyCallbackHelper() {
531 ~wxPyCallbackHelper() {
532 #ifdef wxPyUSE_EXPORTED_API
533 wxPyGetCoreAPIPtr()->p_wxPyCBH_delete(this);
535 wxPyCBH_delete(this);
539 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=true);
540 bool findCallback(const char* name
, bool setGuard
=true) const;
541 int callCallback(PyObject
* argTuple
) const;
542 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
543 PyObject
* GetLastFound() const { return m_lastFound
; }
545 void setRecursionGuard(PyObject
* method
) const;
546 void clearRecursionGuard(PyObject
* method
) const;
551 PyObject
* m_lastFound
;
554 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
558 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
559 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
=true);
560 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
561 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
562 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
567 //---------------------------------------------------------------------------
569 // This is used in C++ classes that need to be able to make callback to
570 // "overloaded" python methods
573 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
574 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
576 private: wxPyCallbackHelper m_myInst
579 //---------------------------------------------------------------------------
580 // The wxPythonApp class
583 wxPYAPP_ASSERT_SUPPRESS
= 1,
584 wxPYAPP_ASSERT_EXCEPTION
= 2,
585 wxPYAPP_ASSERT_DIALOG
= 4,
586 wxPYAPP_ASSERT_LOG
= 8
589 class wxPyApp
: public wxApp
591 DECLARE_ABSTRACT_CLASS(wxPyApp
)
599 int GetAssertMode() { return m_assertMode
; }
600 void SetAssertMode(int mode
) { m_assertMode
= mode
; }
602 virtual bool OnInitGui();
603 virtual int OnExit();
605 virtual void OnAssert(const wxChar
*file
,
610 virtual void ExitMainLoop();
611 // virtual int FilterEvent(wxEvent& event); // This one too????
613 // For catching Apple Events
614 virtual void MacOpenFile(const wxString
&fileName
);
615 virtual void MacPrintFile(const wxString
&fileName
);
616 virtual void MacNewFile();
617 virtual void MacReopenApp();
619 static bool GetMacSupportPCMenuShortcuts();
620 static long GetMacAboutMenuItemId();
621 static long GetMacPreferencesMenuItemId();
622 static long GetMacExitMenuItemId();
623 static wxString
GetMacHelpMenuTitleName();
625 static void SetMacSupportPCMenuShortcuts(bool val
);
626 static void SetMacAboutMenuItemId(long val
);
627 static void SetMacPreferencesMenuItemId(long val
);
628 static void SetMacExitMenuItemId(long val
);
629 static void SetMacHelpMenuTitleName(const wxString
& val
);
632 void _BootstrapApp();
634 // implementation only
635 void SetStartupComplete(bool val
) { m_startupComplete
= val
; };
639 bool m_startupComplete
;
642 extern wxPyApp
*wxPythonApp
;
645 //----------------------------------------------------------------------
646 // These macros are used to implement the virtual methods that should
647 // redirect to a Python method if one exists. The names designate the
648 // return type, if any, as well as any parameter types.
649 //---------------------------------------------------------------------------
651 #define DEC_PYCALLBACK__(CBNAME) \
655 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
656 void CLASS::CBNAME() { \
658 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
659 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
660 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
661 wxPyEndBlockThreads(blocked); \
666 #define DEC_PYCALLBACK_VOID_(CBNAME) \
667 DEC_PYCALLBACK__(CBNAME)
669 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
670 IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME)
672 //---------------------------------------------------------------------------
674 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
675 bool CBNAME(int a, int b)
678 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
679 bool CLASS::CBNAME(int a, int b) { \
680 bool rval=false, found; \
681 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
682 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
683 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
684 wxPyEndBlockThreads(blocked); \
686 rval = PCLASS::CBNAME(a,b); \
690 //---------------------------------------------------------------------------
692 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
693 void CBNAME(int a, int b)
696 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
697 void CLASS::CBNAME(int a, int b) { \
699 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
700 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
701 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
702 wxPyEndBlockThreads(blocked); \
704 PCLASS::CBNAME(a,b); \
707 //---------------------------------------------------------------------------
709 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
713 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
714 void CLASS::CBNAME(int a) { \
716 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
717 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
718 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
719 wxPyEndBlockThreads(blocked); \
724 //---------------------------------------------------------------------------
726 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
727 void CBNAME(int a, int b, int c, int d)
730 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
731 void CLASS::CBNAME(int a, int b, int c, int d) { \
733 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
734 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
735 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
736 wxPyEndBlockThreads(blocked); \
738 PCLASS::CBNAME(a,b,c,d); \
741 //---------------------------------------------------------------------------
742 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
743 void CBNAME(int a, int b, int c, int d, int e)
746 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
747 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
749 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
750 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
751 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
752 wxPyEndBlockThreads(blocked); \
754 PCLASS::CBNAME(a,b,c,d,e); \
757 //---------------------------------------------------------------------------
759 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
760 void CBNAME(int* a, int* b) const
763 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
764 void CLASS::CBNAME(int* a, int* b) const { \
765 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
767 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
768 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
770 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
772 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
773 PyObject* o1 = PySequence_GetItem(ro, 0); \
774 PyObject* o2 = PySequence_GetItem(ro, 1); \
775 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
776 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
779 PyErr_SetString(PyExc_TypeError, errmsg); \
784 PyErr_SetString(PyExc_TypeError, errmsg); \
789 wxPyEndBlockThreads(blocked); \
791 PCLASS::CBNAME(a,b); \
794 //---------------------------------------------------------------------------
796 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
797 wxSize CBNAME() const
800 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
801 wxSize CLASS::CBNAME() const { \
802 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
803 bool found; wxSize rval(0,0); \
804 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
805 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
807 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
809 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
810 PyObject* o1 = PySequence_GetItem(ro, 0); \
811 PyObject* o2 = PySequence_GetItem(ro, 1); \
812 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
813 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
816 PyErr_SetString(PyExc_TypeError, errmsg); \
821 PyErr_SetString(PyExc_TypeError, errmsg); \
826 wxPyEndBlockThreads(blocked); \
828 return PCLASS::CBNAME(); \
833 //---------------------------------------------------------------------------
835 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
839 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
840 bool CLASS::CBNAME(bool a) { \
841 bool rval=false, found; \
842 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
843 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
844 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
845 wxPyEndBlockThreads(blocked); \
847 rval = PCLASS::CBNAME(a); \
851 //---------------------------------------------------------------------------
853 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
857 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
858 bool CLASS::CBNAME(int a) { \
859 bool rval=false, found; \
860 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
861 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
862 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
863 wxPyEndBlockThreads(blocked); \
865 rval = PCLASS::CBNAME(a); \
869 //---------------------------------------------------------------------------
871 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
875 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
876 bool CLASS::CBNAME(int a) { \
878 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
879 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
880 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
882 wxPyEndBlockThreads(blocked); \
887 //---------------------------------------------------------------------------
889 #define DEC_PYCALLBACK__DC(CBNAME) \
893 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
894 void CLASS::CBNAME(wxDC& a) { \
896 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
897 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
898 PyObject* obj = wxPyMake_wxObject(&a,false); \
899 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
902 wxPyEndBlockThreads(blocked); \
908 //---------------------------------------------------------------------------
910 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
911 void CBNAME(wxDC& a, bool b)
914 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
915 void CLASS::CBNAME(wxDC& a, bool b) { \
917 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
918 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
919 PyObject* obj = wxPyMake_wxObject(&a,false); \
920 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
923 wxPyEndBlockThreads(blocked); \
925 PCLASS::CBNAME(a, b); \
928 //---------------------------------------------------------------------------
930 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
931 void CBNAME(wxDC& a, bool b)
934 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
935 void CLASS::CBNAME(wxDC& a, bool b) { \
937 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
938 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
939 PyObject* obj = wxPyMake_wxObject(&a,false); \
940 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
943 wxPyEndBlockThreads(blocked); \
945 PCLASS::CBNAME(a, b); \
948 //---------------------------------------------------------------------------
950 #define DEC_PYCALLBACK__2DBL(CBNAME) \
951 void CBNAME(double a, double b)
954 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
955 void CLASS::CBNAME(double a, double b) { \
957 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
958 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
959 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
960 wxPyEndBlockThreads(blocked); \
962 PCLASS::CBNAME(a, b); \
965 //---------------------------------------------------------------------------
967 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
968 void CBNAME(double a, double b, int c, int d)
971 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
972 void CLASS::CBNAME(double a, double b, int c, int d) { \
974 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
975 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
976 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
978 wxPyEndBlockThreads(blocked); \
980 PCLASS::CBNAME(a, b, c, d); \
983 //---------------------------------------------------------------------------
985 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
986 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
989 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
990 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
992 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
993 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
994 PyObject* obj = wxPyMake_wxObject(&a,false); \
995 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
998 wxPyEndBlockThreads(blocked); \
1000 PCLASS::CBNAME(a, b, c, d, e, f); \
1003 //---------------------------------------------------------------------------
1005 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
1006 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1009 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1010 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1012 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1014 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1015 PyObject* obj = wxPyMake_wxObject(&a,false); \
1016 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1019 wxPyEndBlockThreads(blocked); \
1021 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1025 //---------------------------------------------------------------------------
1027 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1028 void CBNAME(bool a, double b, double c, int d, int e)
1031 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1032 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1034 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1035 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1036 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1038 wxPyEndBlockThreads(blocked); \
1040 PCLASS::CBNAME(a, b, c, d, e); \
1043 //---------------------------------------------------------------------------
1045 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1046 void CBNAME(wxDC& a, double b, double c, double d, double e)
1049 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1050 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1052 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1053 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1054 PyObject* obj = wxPyMake_wxObject(&a,false); \
1055 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1058 wxPyEndBlockThreads(blocked); \
1060 PCLASS::CBNAME(a, b, c, d, e); \
1063 //---------------------------------------------------------------------------
1065 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1066 void CBNAME(wxDC& a, bool b)
1069 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1070 void CLASS::CBNAME(wxDC& a, bool b) { \
1072 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1073 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1074 PyObject* obj = wxPyMake_wxObject(&a,false); \
1075 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1078 wxPyEndBlockThreads(blocked); \
1080 PCLASS::CBNAME(a, b); \
1083 //---------------------------------------------------------------------------
1085 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1086 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1089 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1090 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1093 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1094 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1095 PyObject* obj = wxPyMake_wxObject(a,false); \
1096 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1099 wxPyEndBlockThreads(blocked); \
1101 PCLASS::CBNAME(a, b, c, d, e, f); \
1104 //---------------------------------------------------------------------------
1106 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1107 void CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1110 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1111 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1113 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1114 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1115 PyObject* obj = wxPyMake_wxObject(a,false); \
1116 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1119 wxPyEndBlockThreads(blocked); \
1121 PCLASS::CBNAME(a, b, c, d, e); \
1124 //---------------------------------------------------------------------------
1126 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1127 void CBNAME(double a, double b, int c)
1130 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1131 void CLASS::CBNAME(double a, double b, int c) { \
1133 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1134 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1135 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1136 wxPyEndBlockThreads(blocked); \
1138 PCLASS::CBNAME(a, b, c); \
1141 //---------------------------------------------------------------------------
1143 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1144 void CBNAME(bool a, double b, double c, int d)
1147 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1148 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1150 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1151 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1152 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1153 wxPyEndBlockThreads(blocked); \
1155 PCLASS::CBNAME(a, b, c, d); \
1158 //---------------------------------------------------------------------------
1159 //---------------------------------------------------------------------------
1161 #define DEC_PYCALLBACK__STRING(CBNAME) \
1162 void CBNAME(const wxString& a)
1164 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1165 void CLASS::CBNAME(const wxString& a) { \
1167 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1168 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1169 PyObject* s = wx2PyString(a); \
1170 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1173 wxPyEndBlockThreads(blocked); \
1175 PCLASS::CBNAME(a); \
1178 //---------------------------------------------------------------------------
1180 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1181 bool CBNAME(const wxString& a)
1183 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1184 bool CLASS::CBNAME(const wxString& a) { \
1187 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1188 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1189 PyObject* s = wx2PyString(a); \
1190 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1193 wxPyEndBlockThreads(blocked); \
1195 rval = PCLASS::CBNAME(a); \
1199 //---------------------------------------------------------------------------
1201 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1202 bool CBNAME(const wxString& a)
1204 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1205 bool CLASS::CBNAME(const wxString& a) { \
1207 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1208 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1209 PyObject* s = wx2PyString(a); \
1210 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1213 wxPyEndBlockThreads(blocked); \
1217 //---------------------------------------------------------------------------
1219 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1220 wxString CBNAME(const wxString& a)
1222 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1223 wxString CLASS::CBNAME(const wxString& a) { \
1225 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1226 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1228 PyObject* s = wx2PyString(a); \
1229 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1232 rval = Py2wxString(ro); \
1236 wxPyEndBlockThreads(blocked); \
1240 //---------------------------------------------------------------------------
1242 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1243 wxString CBNAME(const wxString& a)
1245 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1246 wxString CLASS::CBNAME(const wxString& a) { \
1249 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1250 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1252 PyObject* s = wx2PyString(a); \
1253 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1256 rval = Py2wxString(ro); \
1261 rval = PCLASS::CBNAME(a); \
1262 wxPyEndBlockThreads(blocked); \
1266 //---------------------------------------------------------------------------
1268 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1269 wxString CBNAME(const wxString& a,int b)
1271 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1272 wxString CLASS::CBNAME(const wxString& a,int b) { \
1274 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1275 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1277 PyObject* s = wx2PyString(a); \
1278 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1281 rval = Py2wxString(ro); \
1285 wxPyEndBlockThreads(blocked); \
1289 //---------------------------------------------------------------------------
1291 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1292 bool CBNAME(const wxString& a, const wxString& b)
1294 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1295 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1298 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1299 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1300 PyObject* s1 = wx2PyString(a); \
1301 PyObject* s2 = wx2PyString(b); \
1302 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1306 wxPyEndBlockThreads(blocked); \
1308 rval = PCLASS::CBNAME(a, b); \
1312 //---------------------------------------------------------------------------
1314 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1317 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1318 wxString CLASS::CBNAME() { \
1321 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1322 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1324 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1326 rval = Py2wxString(ro); \
1330 wxPyEndBlockThreads(blocked); \
1332 rval = PCLASS::CBNAME(); \
1336 //---------------------------------------------------------------------------
1338 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1339 wxString CBNAME() const
1341 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1342 wxString CLASS::CBNAME() const { \
1345 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1346 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1348 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1350 rval = Py2wxString(ro); \
1354 wxPyEndBlockThreads(blocked); \
1356 rval = PCLASS::CBNAME(); \
1360 //---------------------------------------------------------------------------
1362 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1365 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1366 wxString CLASS::CBNAME() { \
1368 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1369 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1371 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1373 rval = Py2wxString(ro); \
1377 wxPyEndBlockThreads(blocked); \
1381 //---------------------------------------------------------------------------
1383 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1384 wxString CBNAME() const;
1386 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1387 wxString CLASS::CBNAME() const { \
1389 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1390 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1392 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1394 rval = Py2wxString(ro); \
1398 wxPyEndBlockThreads(blocked); \
1402 //---------------------------------------------------------------------------
1404 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1405 bool CBNAME(const wxHtmlTag& a)
1408 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1409 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1411 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1412 if (wxPyCBH_findCallback2(m_myInst, #CBNAME, false)) { \
1413 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
1414 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1417 wxPyEndBlockThreads(blocked); \
1421 //---------------------------------------------------------------------------
1423 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1424 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1426 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1427 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1429 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1430 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1431 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1432 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1435 wxPyEndBlockThreads(blocked); \
1437 PCLASS::CBNAME(cell, x, y); \
1440 //---------------------------------------------------------------------------
1442 #define DEC_PYCALLBACK__COLOUR(CBNAME) \
1443 void CBNAME(const wxColour& c);
1445 #define IMP_PYCALLBACK__COLOUR(CLASS, PCLASS, CBNAME) \
1446 void CLASS::CBNAME(const wxColour& c) { \
1448 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1449 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1450 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1451 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1454 wxPyEndBlockThreads(blocked); \
1456 PCLASS::CBNAME(c); \
1459 //---------------------------------------------------------------------------
1461 #define DEC_PYCALLBACK_BOOL_CELLINTINTME(CBNAME) \
1462 bool CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1464 #define IMP_PYCALLBACK_BOOL_CELLINTINTME(CLASS, PCLASS, CBNAME) \
1465 bool CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1466 bool rval=false, found; \
1467 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1468 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1469 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1470 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1471 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1475 wxPyEndBlockThreads(blocked); \
1477 rval = PCLASS::CBNAME(cell, x, y, e); \
1482 //---------------------------------------------------------------------------
1484 #define DEC_PYCALLBACK___pure(CBNAME) \
1488 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1489 void CLASS::CBNAME() { \
1490 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1491 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1492 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1493 wxPyEndBlockThreads(blocked); \
1496 //---------------------------------------------------------------------------
1498 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1502 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1503 wxSize CLASS::CBNAME() { \
1504 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1506 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1507 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1510 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1512 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1514 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1516 PyObject* o1 = PySequence_GetItem(ro, 0); \
1517 PyObject* o2 = PySequence_GetItem(ro, 1); \
1518 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1519 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1521 PyErr_SetString(PyExc_TypeError, errmsg); \
1526 PyErr_SetString(PyExc_TypeError, errmsg); \
1531 wxPyEndBlockThreads(blocked); \
1535 //---------------------------------------------------------------------------
1537 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1538 bool CBNAME(wxWindow* a)
1541 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1542 bool CLASS::CBNAME(wxWindow* a) { \
1545 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1546 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1547 PyObject* obj = wxPyMake_wxObject(a,false); \
1548 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1551 wxPyEndBlockThreads(blocked); \
1553 rval = PCLASS::CBNAME(a); \
1557 //---------------------------------------------------------------------------
1559 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1560 bool CBNAME(wxWindow* a, wxDC& b)
1563 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1564 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1567 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1568 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1569 PyObject* win = wxPyMake_wxObject(a,false); \
1570 PyObject* dc = wxPyMake_wxObject(&b,false); \
1571 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1575 wxPyEndBlockThreads(blocked); \
1577 rval = PCLASS::CBNAME(a, b); \
1581 //---------------------------------------------------------------------------
1583 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1584 void CBNAME(wxWindowBase* a)
1587 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1588 void CLASS::CBNAME(wxWindowBase* a) { \
1590 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1591 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1592 PyObject* obj = wxPyMake_wxObject(a,false); \
1593 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1596 wxPyEndBlockThreads(blocked); \
1598 PCLASS::CBNAME(a); \
1601 //---------------------------------------------------------------------------
1603 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1607 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1608 bool CLASS::CBNAME() { \
1611 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1612 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1613 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1614 wxPyEndBlockThreads(blocked); \
1616 rval = PCLASS::CBNAME(); \
1620 //---------------------------------------------------------------------------
1622 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1626 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1627 bool CLASS::CBNAME() const { \
1630 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1631 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1632 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1633 wxPyEndBlockThreads(blocked); \
1635 rval = PCLASS::CBNAME(); \
1639 //---------------------------------------------------------------------------
1641 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1642 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1645 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1646 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1649 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1650 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1651 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1652 wxPyEndBlockThreads(blocked); \
1654 rval = PCLASS::CBNAME(a, b, c); \
1655 return (wxDragResult)rval; \
1658 //---------------------------------------------------------------------------
1660 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1661 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1663 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1664 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1665 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1667 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1669 PyObject* obj = wxPyMake_wxObject(&a,false); \
1670 PyObject* s = wx2PyString(b); \
1671 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1674 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
1680 wxPyEndBlockThreads(blocked); \
1684 //---------------------------------------------------------------------------
1686 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1687 bool CBNAME(wxDragResult a)
1690 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1691 bool CLASS::CBNAME(wxDragResult a) { \
1694 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1695 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1696 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1697 wxPyEndBlockThreads(blocked); \
1699 rval = PCLASS::CBNAME(a); \
1703 //---------------------------------------------------------------------------
1705 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1706 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1709 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1710 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1711 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1713 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1714 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1715 wxPyEndBlockThreads(blocked); \
1716 return (wxDragResult)rval; \
1719 //---------------------------------------------------------------------------
1721 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1722 bool CBNAME(int a, int b, const wxString& c)
1724 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1725 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1727 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1728 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1729 PyObject* s = wx2PyString(c); \
1730 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1733 wxPyEndBlockThreads(blocked); \
1737 //---------------------------------------------------------------------------
1739 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1743 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1744 size_t CLASS::CBNAME() { \
1747 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1748 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1749 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1750 wxPyEndBlockThreads(blocked); \
1752 rval = PCLASS::CBNAME(); \
1756 //---------------------------------------------------------------------------
1758 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1759 size_t CBNAME() const
1762 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1763 size_t CLASS::CBNAME() const { \
1766 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1767 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1768 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1769 wxPyEndBlockThreads(blocked); \
1771 rval = PCLASS::CBNAME(); \
1775 //---------------------------------------------------------------------------
1777 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1778 wxDataFormat CBNAME(size_t a)
1781 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1782 wxDataFormat CLASS::CBNAME(size_t a) { \
1783 wxDataFormat rval=0; \
1785 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1786 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1788 wxDataFormat* ptr; \
1789 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1791 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1796 wxPyEndBlockThreads(blocked); \
1798 rval = PCLASS::CBNAME(a); \
1802 //---------------------------------------------------------------------------
1804 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1805 void CBNAME(const Type& a)
1808 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1809 void CLASS::CBNAME(const Type& a) { \
1811 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1812 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1813 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1814 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1817 wxPyEndBlockThreads(blocked); \
1819 PCLASS::CBNAME(a); \
1823 //---------------------------------------------------------------------------
1825 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1826 void CBNAME(Type& a)
1829 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1830 void CLASS::CBNAME(Type& a) { \
1832 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1833 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1834 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1835 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1838 wxPyEndBlockThreads(blocked); \
1840 PCLASS::CBNAME(a); \
1843 //---------------------------------------------------------------------------
1845 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1846 bool CBNAME(Type& a)
1849 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1850 bool CLASS::CBNAME(Type& a) { \
1853 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1854 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1855 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1856 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1859 wxPyEndBlockThreads(blocked); \
1861 rv = PCLASS::CBNAME(a); \
1865 //---------------------------------------------------------------------------
1867 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
1868 bool CBNAME(Type& a)
1871 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
1872 bool CLASS::CBNAME(Type& a) { \
1874 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1875 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1876 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1877 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1880 wxPyEndBlockThreads(blocked); \
1884 //---------------------------------------------------------------------------
1886 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1887 wxString CBNAME(long a, long b) const
1889 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1890 wxString CLASS::CBNAME(long a, long b) const { \
1893 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1894 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1896 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1898 rval = Py2wxString(ro); \
1902 wxPyEndBlockThreads(blocked); \
1904 rval = PCLASS::CBNAME(a,b); \
1908 //---------------------------------------------------------------------------
1910 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1911 int CBNAME(long a) const
1914 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1915 int CLASS::CBNAME(long a) const { \
1918 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1919 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1921 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1923 rval = PyInt_AsLong(ro); \
1927 wxPyEndBlockThreads(blocked); \
1929 rval = PCLASS::CBNAME(a); \
1934 #define DEC_PYCALLBACK_INT_LONG_virtual(CBNAME) \
1935 int CBNAME(long a) const;
1938 #define IMP_PYCALLBACK_INT_LONG_virtual(CLASS, PCLASS, CBNAME) \
1939 int CLASS::CBNAME(long a) const { \
1940 int rval=-1; /* this rval is important for OnGetItemImage */ \
1942 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1943 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1945 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1947 rval = PyInt_AsLong(ro); \
1951 wxPyEndBlockThreads(blocked); \
1956 //---------------------------------------------------------------------------
1958 #define DEC_PYCALLBACK_INT_LONGLONG(CBNAME) \
1959 int CBNAME(long a, long b) const
1962 #define IMP_PYCALLBACK_INT_LONGLONG(CLASS, PCLASS, CBNAME) \
1963 int CLASS::CBNAME(long a, long b) const { \
1966 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1967 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1969 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1971 rval = PyInt_AsLong(ro); \
1975 wxPyEndBlockThreads(blocked); \
1977 rval = PCLASS::CBNAME(a, b); \
1982 #define DEC_PYCALLBACK_INT_LONGLONG_virtual(CBNAME) \
1983 int CBNAME(long a, long b) const;
1986 #define IMP_PYCALLBACK_INT_LONGLONG_virtual(CLASS, PCLASS, CBNAME) \
1987 int CLASS::CBNAME(long a, long b) const { \
1988 int rval=-1; /* this rval is important for OnGetItemImage */ \
1990 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1991 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1993 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1995 rval = PyInt_AsLong(ro); \
1999 wxPyEndBlockThreads(blocked); \
2004 //---------------------------------------------------------------------------
2006 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2007 wxListItemAttr* CBNAME(long a) const
2010 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2011 wxListItemAttr *CLASS::CBNAME(long a) const { \
2012 wxListItemAttr *rval = NULL; \
2014 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2015 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2017 wxListItemAttr* ptr; \
2018 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2020 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2025 wxPyEndBlockThreads(blocked); \
2027 rval = PCLASS::CBNAME(a); \
2031 //---------------------------------------------------------------------------
2033 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2034 bool CBNAME(wxMouseEvent& e)
2036 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2037 bool CLASS::CBNAME(wxMouseEvent& e) { \
2040 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2041 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2043 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2044 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2046 rval = PyInt_AsLong(ro); \
2051 wxPyEndBlockThreads(blocked); \
2053 return PCLASS::CBNAME(e); \
2057 //---------------------------------------------------------------------------
2059 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2060 wxWizardPage* CBNAME() const
2062 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2063 wxWizardPage* CLASS::CBNAME() const { \
2064 wxWizardPage* rv = NULL; \
2065 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2066 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2068 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2070 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2074 wxPyEndBlockThreads(blocked); \
2078 //---------------------------------------------------------------------------
2080 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2081 wxBitmap CBNAME() const
2083 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2084 wxBitmap CLASS::CBNAME() const { \
2086 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2087 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2090 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2092 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2097 wxPyEndBlockThreads(blocked); \
2101 //---------------------------------------------------------------------------
2103 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2106 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2107 wxObject* CLASS::CBNAME() { \
2108 wxObject* rv = NULL; \
2109 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2110 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2112 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2114 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2118 wxPyEndBlockThreads(blocked); \
2122 //---------------------------------------------------------------------------
2124 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2125 wxObject* CBNAME(const wxString& a)
2127 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2128 wxObject* CLASS::CBNAME(const wxString& a) { \
2129 wxObject* rv = NULL; \
2130 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2131 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2132 PyObject* so = wx2PyString(a); \
2134 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2136 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2141 wxPyEndBlockThreads(blocked); \
2145 //---------------------------------------------------------------------------
2147 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2148 bool CBNAME(wxXmlNode* a)
2151 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2152 bool CLASS::CBNAME(wxXmlNode* a) { \
2154 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2155 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2156 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2157 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2160 wxPyEndBlockThreads(blocked); \
2164 //---------------------------------------------------------------------------
2166 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2167 wxCoord CBNAME(size_t a) const
2170 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2171 wxCoord CLASS::CBNAME(size_t a) const { \
2174 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2175 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2176 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2178 wxPyEndBlockThreads(blocked); \
2182 //---------------------------------------------------------------------------
2184 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2185 void CBNAME(size_t a, size_t b) const
2188 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2189 void CLASS::CBNAME(size_t a, size_t b) const { \
2191 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2192 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2193 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2194 wxPyEndBlockThreads(blocked); \
2196 PCLASS::CBNAME(a,b); \
2198 //---------------------------------------------------------------------------
2200 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2201 wxCoord CBNAME() const
2204 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2205 wxCoord CLASS::CBNAME() const { \
2208 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2209 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2210 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2211 wxPyEndBlockThreads(blocked); \
2213 rval = PCLASS::CBNAME(); \
2217 //---------------------------------------------------------------------------
2219 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2220 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2222 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2223 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2225 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2226 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2227 PyObject* obj = wxPyMake_wxObject(&a,false); \
2228 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2229 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2232 wxPyEndBlockThreads(blocked); \
2237 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2238 void CBNAME(wxDC& a, const wxRect& b, size_t c) const
2240 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2241 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2243 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2244 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2245 PyObject* obj = wxPyMake_wxObject(&a,false); \
2246 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2247 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2250 wxPyEndBlockThreads(blocked); \
2252 PCLASS::CBNAME(a,b,c); \
2256 //---------------------------------------------------------------------------
2257 // Same as the above set, but the wxRect is not const
2259 #define DEC_PYCALLBACK__DCRECTSIZET2_constpure(CBNAME) \
2260 void CBNAME(wxDC& a, wxRect& b, size_t c) const;
2262 #define IMP_PYCALLBACK__DCRECTSIZET2_constpure(CLASS, PCLASS, CBNAME) \
2263 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2265 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2266 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2267 PyObject* obj = wxPyMake_wxObject(&a,false); \
2268 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2269 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2272 wxPyEndBlockThreads(blocked); \
2277 #define DEC_PYCALLBACK__DCRECTSIZET2_const(CBNAME) \
2278 void CBNAME(wxDC& a, wxRect& b, size_t c) const
2280 #define IMP_PYCALLBACK__DCRECTSIZET2_const(CLASS, PCLASS, CBNAME) \
2281 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2283 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2284 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2285 PyObject* obj = wxPyMake_wxObject(&a,false); \
2286 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2287 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2290 wxPyEndBlockThreads(blocked); \
2292 PCLASS::CBNAME(a,b,c); \
2297 //---------------------------------------------------------------------------
2301 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2302 wxString CBNAME(size_t a) const
2304 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2305 wxString CLASS::CBNAME(size_t a) const { \
2308 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2309 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2311 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2313 rval = Py2wxString(ro); \
2317 wxPyEndBlockThreads(blocked); \
2319 rval = PCLASS::CBNAME(a); \
2323 //---------------------------------------------------------------------------
2325 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2326 wxString CBNAME(size_t a) const
2328 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2329 wxString CLASS::CBNAME(size_t a) const { \
2332 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2333 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2335 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2337 rval = Py2wxString(ro); \
2341 wxPyEndBlockThreads(blocked); \
2345 //---------------------------------------------------------------------------
2347 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2348 wxVisualAttributes CBNAME() const
2351 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2352 wxVisualAttributes CLASS::CBNAME() const { \
2353 wxVisualAttributes rval; \
2355 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2356 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2358 wxVisualAttributes* ptr; \
2359 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2361 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2366 wxPyEndBlockThreads(blocked); \
2368 rval = PCLASS::CBNAME(); \
2372 //---------------------------------------------------------------------------