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 OnAssertFailure(const wxChar
*file
,
611 virtual void ExitMainLoop();
612 // virtual int FilterEvent(wxEvent& event); // This one too????
614 // For catching Apple Events
615 virtual void MacOpenFile(const wxString
&fileName
);
616 virtual void MacPrintFile(const wxString
&fileName
);
617 virtual void MacNewFile();
618 virtual void MacReopenApp();
620 static bool GetMacSupportPCMenuShortcuts();
621 static long GetMacAboutMenuItemId();
622 static long GetMacPreferencesMenuItemId();
623 static long GetMacExitMenuItemId();
624 static wxString
GetMacHelpMenuTitleName();
626 static void SetMacSupportPCMenuShortcuts(bool val
);
627 static void SetMacAboutMenuItemId(long val
);
628 static void SetMacPreferencesMenuItemId(long val
);
629 static void SetMacExitMenuItemId(long val
);
630 static void SetMacHelpMenuTitleName(const wxString
& val
);
633 void _BootstrapApp();
635 // implementation only
636 void SetStartupComplete(bool val
) { m_startupComplete
= val
; };
640 bool m_startupComplete
;
643 extern wxPyApp
*wxPythonApp
;
646 //----------------------------------------------------------------------
647 // These macros are used to implement the virtual methods that should
648 // redirect to a Python method if one exists. The names designate the
649 // return type, if any, as well as any parameter types.
650 //---------------------------------------------------------------------------
652 #define DEC_PYCALLBACK__(CBNAME) \
656 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
657 void CLASS::CBNAME() { \
659 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
660 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
661 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
662 wxPyEndBlockThreads(blocked); \
667 #define DEC_PYCALLBACK_VOID_(CBNAME) \
668 DEC_PYCALLBACK__(CBNAME)
670 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
671 IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME)
673 //---------------------------------------------------------------------------
675 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
676 bool CBNAME(int a, int b)
679 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
680 bool CLASS::CBNAME(int a, int b) { \
681 bool rval=false, found; \
682 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
683 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
684 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
685 wxPyEndBlockThreads(blocked); \
687 rval = PCLASS::CBNAME(a,b); \
691 //---------------------------------------------------------------------------
693 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
694 void CBNAME(int a, int b)
697 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
698 void CLASS::CBNAME(int a, int b) { \
700 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
701 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
702 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
703 wxPyEndBlockThreads(blocked); \
705 PCLASS::CBNAME(a,b); \
708 //---------------------------------------------------------------------------
710 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
714 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
715 void CLASS::CBNAME(int a) { \
717 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
718 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
719 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
720 wxPyEndBlockThreads(blocked); \
725 //---------------------------------------------------------------------------
727 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
728 void CBNAME(int a, int b, int c, int d)
731 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
732 void CLASS::CBNAME(int a, int b, int c, int d) { \
734 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
735 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
736 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
737 wxPyEndBlockThreads(blocked); \
739 PCLASS::CBNAME(a,b,c,d); \
742 //---------------------------------------------------------------------------
743 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
744 void CBNAME(int a, int b, int c, int d, int e)
747 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
748 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
750 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
751 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
752 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
753 wxPyEndBlockThreads(blocked); \
755 PCLASS::CBNAME(a,b,c,d,e); \
758 //---------------------------------------------------------------------------
760 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
761 void CBNAME(int* a, int* b) const
764 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
765 void CLASS::CBNAME(int* a, int* b) const { \
766 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
768 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
769 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
771 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
773 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
774 PyObject* o1 = PySequence_GetItem(ro, 0); \
775 PyObject* o2 = PySequence_GetItem(ro, 1); \
776 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
777 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
780 PyErr_SetString(PyExc_TypeError, errmsg); \
785 PyErr_SetString(PyExc_TypeError, errmsg); \
790 wxPyEndBlockThreads(blocked); \
792 PCLASS::CBNAME(a,b); \
795 //---------------------------------------------------------------------------
797 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
798 wxSize CBNAME() const
801 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
802 wxSize CLASS::CBNAME() const { \
803 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
804 bool found; wxSize rval(0,0); \
805 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
806 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
808 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
810 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
811 PyObject* o1 = PySequence_GetItem(ro, 0); \
812 PyObject* o2 = PySequence_GetItem(ro, 1); \
813 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
814 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
817 PyErr_SetString(PyExc_TypeError, errmsg); \
822 PyErr_SetString(PyExc_TypeError, errmsg); \
827 wxPyEndBlockThreads(blocked); \
829 return PCLASS::CBNAME(); \
834 //---------------------------------------------------------------------------
836 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
840 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
841 bool CLASS::CBNAME(bool a) { \
842 bool rval=false, found; \
843 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
844 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
845 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
846 wxPyEndBlockThreads(blocked); \
848 rval = PCLASS::CBNAME(a); \
852 //---------------------------------------------------------------------------
854 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
858 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
859 bool CLASS::CBNAME(int a) { \
860 bool rval=false, found; \
861 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
862 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
863 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
864 wxPyEndBlockThreads(blocked); \
866 rval = PCLASS::CBNAME(a); \
870 //---------------------------------------------------------------------------
872 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
876 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
877 bool CLASS::CBNAME(int a) { \
879 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
880 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
881 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
883 wxPyEndBlockThreads(blocked); \
888 //---------------------------------------------------------------------------
890 #define DEC_PYCALLBACK__DC(CBNAME) \
894 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
895 void CLASS::CBNAME(wxDC& a) { \
897 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
898 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
899 PyObject* obj = wxPyMake_wxObject(&a,false); \
900 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
903 wxPyEndBlockThreads(blocked); \
909 //---------------------------------------------------------------------------
911 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
912 void CBNAME(wxDC& a, bool b)
915 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
916 void CLASS::CBNAME(wxDC& a, bool b) { \
918 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
919 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
920 PyObject* obj = wxPyMake_wxObject(&a,false); \
921 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
924 wxPyEndBlockThreads(blocked); \
926 PCLASS::CBNAME(a, b); \
929 //---------------------------------------------------------------------------
931 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
932 void CBNAME(wxDC& a, bool b)
935 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
936 void CLASS::CBNAME(wxDC& a, bool b) { \
938 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
939 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
940 PyObject* obj = wxPyMake_wxObject(&a,false); \
941 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
944 wxPyEndBlockThreads(blocked); \
946 PCLASS::CBNAME(a, b); \
949 //---------------------------------------------------------------------------
951 #define DEC_PYCALLBACK__2DBL(CBNAME) \
952 void CBNAME(double a, double b)
955 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
956 void CLASS::CBNAME(double a, double b) { \
958 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
959 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
960 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
961 wxPyEndBlockThreads(blocked); \
963 PCLASS::CBNAME(a, b); \
966 //---------------------------------------------------------------------------
968 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
969 void CBNAME(double a, double b, int c, int d)
972 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
973 void CLASS::CBNAME(double a, double b, int c, int d) { \
975 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
976 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
977 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
979 wxPyEndBlockThreads(blocked); \
981 PCLASS::CBNAME(a, b, c, d); \
984 //---------------------------------------------------------------------------
986 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
987 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
990 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
991 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
993 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
994 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
995 PyObject* obj = wxPyMake_wxObject(&a,false); \
996 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
999 wxPyEndBlockThreads(blocked); \
1001 PCLASS::CBNAME(a, b, c, d, e, f); \
1004 //---------------------------------------------------------------------------
1006 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
1007 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1010 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1011 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1013 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1015 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1016 PyObject* obj = wxPyMake_wxObject(&a,false); \
1017 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1020 wxPyEndBlockThreads(blocked); \
1022 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1026 //---------------------------------------------------------------------------
1028 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1029 void CBNAME(bool a, double b, double c, int d, int e)
1032 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1033 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1035 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1036 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1037 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1039 wxPyEndBlockThreads(blocked); \
1041 PCLASS::CBNAME(a, b, c, d, e); \
1044 //---------------------------------------------------------------------------
1046 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1047 void CBNAME(wxDC& a, double b, double c, double d, double e)
1050 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1051 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1053 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1054 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1055 PyObject* obj = wxPyMake_wxObject(&a,false); \
1056 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1059 wxPyEndBlockThreads(blocked); \
1061 PCLASS::CBNAME(a, b, c, d, e); \
1064 //---------------------------------------------------------------------------
1066 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1067 void CBNAME(wxDC& a, bool b)
1070 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1071 void CLASS::CBNAME(wxDC& a, bool b) { \
1073 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1074 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1075 PyObject* obj = wxPyMake_wxObject(&a,false); \
1076 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1079 wxPyEndBlockThreads(blocked); \
1081 PCLASS::CBNAME(a, b); \
1084 //---------------------------------------------------------------------------
1086 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1087 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1090 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1091 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1094 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1095 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1096 PyObject* obj = wxPyMake_wxObject(a,false); \
1097 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1100 wxPyEndBlockThreads(blocked); \
1102 PCLASS::CBNAME(a, b, c, d, e, f); \
1105 //---------------------------------------------------------------------------
1107 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1108 void CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1111 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1112 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1114 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1115 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1116 PyObject* obj = wxPyMake_wxObject(a,false); \
1117 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1120 wxPyEndBlockThreads(blocked); \
1122 PCLASS::CBNAME(a, b, c, d, e); \
1125 //---------------------------------------------------------------------------
1127 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1128 void CBNAME(double a, double b, int c)
1131 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1132 void CLASS::CBNAME(double a, double b, int c) { \
1134 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1135 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1136 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1137 wxPyEndBlockThreads(blocked); \
1139 PCLASS::CBNAME(a, b, c); \
1142 //---------------------------------------------------------------------------
1144 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1145 void CBNAME(bool a, double b, double c, int d)
1148 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1149 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1151 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1152 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1153 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1154 wxPyEndBlockThreads(blocked); \
1156 PCLASS::CBNAME(a, b, c, d); \
1159 //---------------------------------------------------------------------------
1160 //---------------------------------------------------------------------------
1162 #define DEC_PYCALLBACK__STRING(CBNAME) \
1163 void CBNAME(const wxString& a)
1165 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1166 void CLASS::CBNAME(const wxString& a) { \
1168 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1169 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1170 PyObject* s = wx2PyString(a); \
1171 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1174 wxPyEndBlockThreads(blocked); \
1176 PCLASS::CBNAME(a); \
1179 //---------------------------------------------------------------------------
1181 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1182 bool CBNAME(const wxString& a)
1184 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1185 bool CLASS::CBNAME(const wxString& a) { \
1188 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1189 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1190 PyObject* s = wx2PyString(a); \
1191 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1194 wxPyEndBlockThreads(blocked); \
1196 rval = PCLASS::CBNAME(a); \
1200 //---------------------------------------------------------------------------
1202 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1203 bool CBNAME(const wxString& a)
1205 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1206 bool CLASS::CBNAME(const wxString& a) { \
1208 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1209 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1210 PyObject* s = wx2PyString(a); \
1211 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1214 wxPyEndBlockThreads(blocked); \
1218 //---------------------------------------------------------------------------
1220 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1221 wxString CBNAME(const wxString& a)
1223 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1224 wxString CLASS::CBNAME(const wxString& a) { \
1226 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1227 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1229 PyObject* s = wx2PyString(a); \
1230 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1233 rval = Py2wxString(ro); \
1237 wxPyEndBlockThreads(blocked); \
1241 //---------------------------------------------------------------------------
1243 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1244 wxString CBNAME(const wxString& a)
1246 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1247 wxString CLASS::CBNAME(const wxString& a) { \
1250 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1251 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1253 PyObject* s = wx2PyString(a); \
1254 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1257 rval = Py2wxString(ro); \
1262 rval = PCLASS::CBNAME(a); \
1263 wxPyEndBlockThreads(blocked); \
1267 //---------------------------------------------------------------------------
1269 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1270 wxString CBNAME(const wxString& a,int b)
1272 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1273 wxString CLASS::CBNAME(const wxString& a,int b) { \
1275 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1276 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1278 PyObject* s = wx2PyString(a); \
1279 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1282 rval = Py2wxString(ro); \
1286 wxPyEndBlockThreads(blocked); \
1290 //---------------------------------------------------------------------------
1292 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1293 bool CBNAME(const wxString& a, const wxString& b)
1295 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1296 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1299 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1300 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1301 PyObject* s1 = wx2PyString(a); \
1302 PyObject* s2 = wx2PyString(b); \
1303 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1307 wxPyEndBlockThreads(blocked); \
1309 rval = PCLASS::CBNAME(a, b); \
1313 //---------------------------------------------------------------------------
1315 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1318 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1319 wxString CLASS::CBNAME() { \
1322 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1323 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1325 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1327 rval = Py2wxString(ro); \
1331 wxPyEndBlockThreads(blocked); \
1333 rval = PCLASS::CBNAME(); \
1337 //---------------------------------------------------------------------------
1339 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1340 wxString CBNAME() const
1342 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1343 wxString CLASS::CBNAME() const { \
1346 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1347 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1349 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1351 rval = Py2wxString(ro); \
1355 wxPyEndBlockThreads(blocked); \
1357 rval = PCLASS::CBNAME(); \
1361 //---------------------------------------------------------------------------
1363 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1366 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1367 wxString CLASS::CBNAME() { \
1369 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1370 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1372 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1374 rval = Py2wxString(ro); \
1378 wxPyEndBlockThreads(blocked); \
1382 //---------------------------------------------------------------------------
1384 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1385 wxString CBNAME() const;
1387 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1388 wxString CLASS::CBNAME() const { \
1390 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1391 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1393 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1395 rval = Py2wxString(ro); \
1399 wxPyEndBlockThreads(blocked); \
1403 //---------------------------------------------------------------------------
1405 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1406 bool CBNAME(const wxHtmlTag& a)
1409 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1410 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1412 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1413 if (wxPyCBH_findCallback2(m_myInst, #CBNAME, false)) { \
1414 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
1415 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1418 wxPyEndBlockThreads(blocked); \
1422 //---------------------------------------------------------------------------
1424 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1425 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1427 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1428 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1430 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1431 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1432 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1433 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1436 wxPyEndBlockThreads(blocked); \
1438 PCLASS::CBNAME(cell, x, y); \
1441 //---------------------------------------------------------------------------
1443 #define DEC_PYCALLBACK__COLOUR(CBNAME) \
1444 void CBNAME(const wxColour& c);
1446 #define IMP_PYCALLBACK__COLOUR(CLASS, PCLASS, CBNAME) \
1447 void CLASS::CBNAME(const wxColour& c) { \
1449 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1450 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1451 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1452 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1455 wxPyEndBlockThreads(blocked); \
1457 PCLASS::CBNAME(c); \
1460 //---------------------------------------------------------------------------
1462 #define DEC_PYCALLBACK_BOOL_CELLINTINTME(CBNAME) \
1463 bool CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1465 #define IMP_PYCALLBACK_BOOL_CELLINTINTME(CLASS, PCLASS, CBNAME) \
1466 bool CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1467 bool rval=false, found; \
1468 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1469 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1470 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1471 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1472 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1476 wxPyEndBlockThreads(blocked); \
1478 rval = PCLASS::CBNAME(cell, x, y, e); \
1483 //---------------------------------------------------------------------------
1485 #define DEC_PYCALLBACK___pure(CBNAME) \
1489 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1490 void CLASS::CBNAME() { \
1491 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1492 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1493 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1494 wxPyEndBlockThreads(blocked); \
1497 //---------------------------------------------------------------------------
1499 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1503 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1504 wxSize CLASS::CBNAME() { \
1505 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1507 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1508 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1511 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1513 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1515 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1517 PyObject* o1 = PySequence_GetItem(ro, 0); \
1518 PyObject* o2 = PySequence_GetItem(ro, 1); \
1519 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1520 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1522 PyErr_SetString(PyExc_TypeError, errmsg); \
1527 PyErr_SetString(PyExc_TypeError, errmsg); \
1532 wxPyEndBlockThreads(blocked); \
1536 //---------------------------------------------------------------------------
1538 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1539 bool CBNAME(wxWindow* a)
1542 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1543 bool CLASS::CBNAME(wxWindow* a) { \
1546 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1547 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1548 PyObject* obj = wxPyMake_wxObject(a,false); \
1549 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1552 wxPyEndBlockThreads(blocked); \
1554 rval = PCLASS::CBNAME(a); \
1558 //---------------------------------------------------------------------------
1560 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1561 bool CBNAME(wxWindow* a, wxDC& b)
1564 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1565 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1568 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1569 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1570 PyObject* win = wxPyMake_wxObject(a,false); \
1571 PyObject* dc = wxPyMake_wxObject(&b,false); \
1572 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1576 wxPyEndBlockThreads(blocked); \
1578 rval = PCLASS::CBNAME(a, b); \
1582 //---------------------------------------------------------------------------
1584 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1585 void CBNAME(wxWindowBase* a)
1588 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1589 void CLASS::CBNAME(wxWindowBase* a) { \
1591 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1592 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1593 PyObject* obj = wxPyMake_wxObject(a,false); \
1594 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1597 wxPyEndBlockThreads(blocked); \
1599 PCLASS::CBNAME(a); \
1602 //---------------------------------------------------------------------------
1604 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1608 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1609 bool CLASS::CBNAME() { \
1612 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1613 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1614 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1615 wxPyEndBlockThreads(blocked); \
1617 rval = PCLASS::CBNAME(); \
1621 //---------------------------------------------------------------------------
1623 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1627 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1628 bool CLASS::CBNAME() const { \
1631 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1632 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1633 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1634 wxPyEndBlockThreads(blocked); \
1636 rval = PCLASS::CBNAME(); \
1640 //---------------------------------------------------------------------------
1642 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1643 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1646 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1647 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1650 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1651 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1652 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1653 wxPyEndBlockThreads(blocked); \
1655 rval = PCLASS::CBNAME(a, b, c); \
1656 return (wxDragResult)rval; \
1659 //---------------------------------------------------------------------------
1661 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1662 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1664 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1665 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1666 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1668 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1670 PyObject* obj = wxPyMake_wxObject(&a,false); \
1671 PyObject* s = wx2PyString(b); \
1672 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1675 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
1676 /* release ownership of the C++ wx.FSFile object. */ \
1677 PyObject_SetAttrString(ro, "thisown", Py_False); \
1683 wxPyEndBlockThreads(blocked); \
1687 //---------------------------------------------------------------------------
1689 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1690 bool CBNAME(wxDragResult a)
1693 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1694 bool CLASS::CBNAME(wxDragResult a) { \
1697 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1698 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1699 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1700 wxPyEndBlockThreads(blocked); \
1702 rval = PCLASS::CBNAME(a); \
1706 //---------------------------------------------------------------------------
1708 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1709 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1712 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1713 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1714 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1716 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1717 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1718 wxPyEndBlockThreads(blocked); \
1719 return (wxDragResult)rval; \
1722 //---------------------------------------------------------------------------
1724 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1725 bool CBNAME(int a, int b, const wxString& c)
1727 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1728 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1730 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1731 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1732 PyObject* s = wx2PyString(c); \
1733 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1736 wxPyEndBlockThreads(blocked); \
1740 //---------------------------------------------------------------------------
1742 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1746 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1747 size_t CLASS::CBNAME() { \
1750 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1751 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1752 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1753 wxPyEndBlockThreads(blocked); \
1755 rval = PCLASS::CBNAME(); \
1759 //---------------------------------------------------------------------------
1761 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1762 size_t CBNAME() const
1765 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1766 size_t CLASS::CBNAME() const { \
1769 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1770 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1771 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1772 wxPyEndBlockThreads(blocked); \
1774 rval = PCLASS::CBNAME(); \
1778 //---------------------------------------------------------------------------
1780 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1781 wxDataFormat CBNAME(size_t a)
1784 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1785 wxDataFormat CLASS::CBNAME(size_t a) { \
1786 wxDataFormat rval=0; \
1788 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1789 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1791 wxDataFormat* ptr; \
1792 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1794 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1799 wxPyEndBlockThreads(blocked); \
1801 rval = PCLASS::CBNAME(a); \
1805 //---------------------------------------------------------------------------
1807 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1808 void CBNAME(const Type& a)
1811 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1812 void CLASS::CBNAME(const Type& a) { \
1814 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1815 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1816 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1817 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1820 wxPyEndBlockThreads(blocked); \
1822 PCLASS::CBNAME(a); \
1826 //---------------------------------------------------------------------------
1828 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1829 void CBNAME(Type& a)
1832 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1833 void CLASS::CBNAME(Type& a) { \
1835 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1836 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1837 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1838 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1841 wxPyEndBlockThreads(blocked); \
1843 PCLASS::CBNAME(a); \
1846 //---------------------------------------------------------------------------
1848 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1849 bool CBNAME(Type& a)
1852 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1853 bool CLASS::CBNAME(Type& a) { \
1856 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1857 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1858 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1859 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1862 wxPyEndBlockThreads(blocked); \
1864 rv = PCLASS::CBNAME(a); \
1868 //---------------------------------------------------------------------------
1870 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
1871 bool CBNAME(Type& a)
1874 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
1875 bool CLASS::CBNAME(Type& a) { \
1877 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1878 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1879 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1880 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1883 wxPyEndBlockThreads(blocked); \
1887 //---------------------------------------------------------------------------
1889 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1890 wxString CBNAME(long a, long b) const
1892 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1893 wxString CLASS::CBNAME(long a, long b) const { \
1896 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1897 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1899 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1901 rval = Py2wxString(ro); \
1905 wxPyEndBlockThreads(blocked); \
1907 rval = PCLASS::CBNAME(a,b); \
1911 //---------------------------------------------------------------------------
1913 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1914 int CBNAME(long a) const
1917 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1918 int CLASS::CBNAME(long a) const { \
1921 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1922 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1924 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1926 rval = PyInt_AsLong(ro); \
1930 wxPyEndBlockThreads(blocked); \
1932 rval = PCLASS::CBNAME(a); \
1937 #define DEC_PYCALLBACK_INT_LONG_virtual(CBNAME) \
1938 int CBNAME(long a) const;
1941 #define IMP_PYCALLBACK_INT_LONG_virtual(CLASS, PCLASS, CBNAME) \
1942 int CLASS::CBNAME(long a) const { \
1943 int rval=-1; /* this rval is important for OnGetItemImage */ \
1945 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1946 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1948 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1950 rval = PyInt_AsLong(ro); \
1954 wxPyEndBlockThreads(blocked); \
1959 //---------------------------------------------------------------------------
1961 #define DEC_PYCALLBACK_INT_LONGLONG(CBNAME) \
1962 int CBNAME(long a, long b) const
1965 #define IMP_PYCALLBACK_INT_LONGLONG(CLASS, PCLASS, CBNAME) \
1966 int CLASS::CBNAME(long a, long b) const { \
1969 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1970 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1972 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1974 rval = PyInt_AsLong(ro); \
1978 wxPyEndBlockThreads(blocked); \
1980 rval = PCLASS::CBNAME(a, b); \
1985 #define DEC_PYCALLBACK_INT_LONGLONG_virtual(CBNAME) \
1986 int CBNAME(long a, long b) const;
1989 #define IMP_PYCALLBACK_INT_LONGLONG_virtual(CLASS, PCLASS, CBNAME) \
1990 int CLASS::CBNAME(long a, long b) const { \
1991 int rval=-1; /* this rval is important for OnGetItemImage */ \
1993 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1994 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1996 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1998 rval = PyInt_AsLong(ro); \
2002 wxPyEndBlockThreads(blocked); \
2007 //---------------------------------------------------------------------------
2009 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2010 wxListItemAttr* CBNAME(long a) const
2013 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2014 wxListItemAttr *CLASS::CBNAME(long a) const { \
2015 wxListItemAttr *rval = NULL; \
2017 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2018 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2020 wxListItemAttr* ptr; \
2021 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2023 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2028 wxPyEndBlockThreads(blocked); \
2030 rval = PCLASS::CBNAME(a); \
2034 //---------------------------------------------------------------------------
2036 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2037 bool CBNAME(wxMouseEvent& e)
2039 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2040 bool CLASS::CBNAME(wxMouseEvent& e) { \
2043 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2044 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2046 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2047 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2049 rval = PyInt_AsLong(ro); \
2054 wxPyEndBlockThreads(blocked); \
2056 return PCLASS::CBNAME(e); \
2060 //---------------------------------------------------------------------------
2062 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2063 wxWizardPage* CBNAME() const
2065 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2066 wxWizardPage* CLASS::CBNAME() const { \
2067 wxWizardPage* rv = NULL; \
2068 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2069 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2071 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2073 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2077 wxPyEndBlockThreads(blocked); \
2081 //---------------------------------------------------------------------------
2083 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2084 wxBitmap CBNAME() const
2086 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2087 wxBitmap CLASS::CBNAME() const { \
2089 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2090 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2093 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2095 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2100 wxPyEndBlockThreads(blocked); \
2104 //---------------------------------------------------------------------------
2106 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2109 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2110 wxObject* CLASS::CBNAME() { \
2111 wxObject* rv = NULL; \
2112 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2113 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2115 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2117 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2121 wxPyEndBlockThreads(blocked); \
2125 //---------------------------------------------------------------------------
2127 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2128 wxObject* CBNAME(const wxString& a)
2130 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2131 wxObject* CLASS::CBNAME(const wxString& a) { \
2132 wxObject* rv = NULL; \
2133 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2134 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2135 PyObject* so = wx2PyString(a); \
2137 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2139 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2144 wxPyEndBlockThreads(blocked); \
2148 //---------------------------------------------------------------------------
2150 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2151 bool CBNAME(wxXmlNode* a)
2154 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2155 bool CLASS::CBNAME(wxXmlNode* a) { \
2157 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2158 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2159 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2160 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2163 wxPyEndBlockThreads(blocked); \
2167 //---------------------------------------------------------------------------
2169 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2170 wxCoord CBNAME(size_t a) const
2173 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2174 wxCoord CLASS::CBNAME(size_t a) const { \
2177 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2178 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2179 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2181 wxPyEndBlockThreads(blocked); \
2185 //---------------------------------------------------------------------------
2187 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2188 void CBNAME(size_t a, size_t b) const
2191 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2192 void CLASS::CBNAME(size_t a, size_t b) const { \
2194 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2195 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2196 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2197 wxPyEndBlockThreads(blocked); \
2199 PCLASS::CBNAME(a,b); \
2201 //---------------------------------------------------------------------------
2203 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2204 wxCoord CBNAME() const
2207 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2208 wxCoord CLASS::CBNAME() const { \
2211 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2212 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2213 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2214 wxPyEndBlockThreads(blocked); \
2216 rval = PCLASS::CBNAME(); \
2220 //---------------------------------------------------------------------------
2222 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2223 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2225 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2226 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2228 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2229 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2230 PyObject* obj = wxPyMake_wxObject(&a,false); \
2231 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2232 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2235 wxPyEndBlockThreads(blocked); \
2240 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2241 void CBNAME(wxDC& a, const wxRect& b, size_t c) const
2243 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2244 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2246 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2247 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2248 PyObject* obj = wxPyMake_wxObject(&a,false); \
2249 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2250 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2253 wxPyEndBlockThreads(blocked); \
2255 PCLASS::CBNAME(a,b,c); \
2259 //---------------------------------------------------------------------------
2260 // Same as the above set, but the wxRect is not const
2262 #define DEC_PYCALLBACK__DCRECTSIZET2_constpure(CBNAME) \
2263 void CBNAME(wxDC& a, wxRect& b, size_t c) const;
2265 #define IMP_PYCALLBACK__DCRECTSIZET2_constpure(CLASS, PCLASS, CBNAME) \
2266 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2268 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2269 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2270 PyObject* obj = wxPyMake_wxObject(&a,false); \
2271 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2272 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2275 wxPyEndBlockThreads(blocked); \
2280 #define DEC_PYCALLBACK__DCRECTSIZET2_const(CBNAME) \
2281 void CBNAME(wxDC& a, wxRect& b, size_t c) const
2283 #define IMP_PYCALLBACK__DCRECTSIZET2_const(CLASS, PCLASS, CBNAME) \
2284 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2286 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2287 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2288 PyObject* obj = wxPyMake_wxObject(&a,false); \
2289 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2290 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2293 wxPyEndBlockThreads(blocked); \
2295 PCLASS::CBNAME(a,b,c); \
2300 //---------------------------------------------------------------------------
2304 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2305 wxString CBNAME(size_t a) const
2307 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2308 wxString CLASS::CBNAME(size_t a) const { \
2311 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2312 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2314 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2316 rval = Py2wxString(ro); \
2320 wxPyEndBlockThreads(blocked); \
2322 rval = PCLASS::CBNAME(a); \
2326 //---------------------------------------------------------------------------
2328 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2329 wxString CBNAME(size_t a) const
2331 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2332 wxString CLASS::CBNAME(size_t a) const { \
2335 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2336 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2338 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2340 rval = Py2wxString(ro); \
2344 wxPyEndBlockThreads(blocked); \
2348 //---------------------------------------------------------------------------
2350 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2351 wxVisualAttributes CBNAME() const
2354 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2355 wxVisualAttributes CLASS::CBNAME() const { \
2356 wxVisualAttributes rval; \
2358 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2359 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2361 wxVisualAttributes* ptr; \
2362 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2364 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2369 wxPyEndBlockThreads(blocked); \
2371 rval = PCLASS::CBNAME(); \
2375 //---------------------------------------------------------------------------