1 ////////////////////////////////////////////////////////////////////////////
2 // Name: wxPython_int.h (int == internal)
3 // Purpose: Helper functions/classes for the wxPython extension module
4 // This header should only be inclued directly by those source
5 // modules included in the wx._core module. All others should
6 // include wx/wxPython/wxPython.h instead.
10 // Created: 1-July-1997
12 // Copyright: (c) 1998 by Total Control Software
13 // Licence: wxWindows license
14 /////////////////////////////////////////////////////////////////////////////
16 #ifndef __wxp_helpers__
17 #define __wxp_helpers__
21 #include <wx/busyinfo.h>
23 #include <wx/choicebk.h>
24 #include <wx/clipbrd.h>
25 #include <wx/colordlg.h>
26 #include <wx/config.h>
27 #include <wx/cshelp.h>
28 #include <wx/dcmirror.h>
30 #include <wx/dirctrl.h>
31 #include <wx/dirdlg.h>
32 #include <wx/numdlg.h>
34 #include <wx/docview.h>
35 #include <wx/encconv.h>
36 #include <wx/fdrepdlg.h>
37 #include <wx/fileconf.h>
38 #include <wx/filesys.h>
39 #include <wx/fontdlg.h>
40 #include <wx/fs_inet.h>
41 #include <wx/fs_mem.h>
42 #include <wx/fs_zip.h>
43 #include <wx/gbsizer.h>
44 #include <wx/geometry.h>
45 #include <wx/htmllbox.h>
47 #include <wx/imaglist.h>
49 #include <wx/laywin.h>
50 #include <wx/listbook.h>
51 #include <wx/minifram.h>
52 #include <wx/notebook.h>
54 #include <wx/printdlg.h>
55 #include <wx/process.h>
56 #include <wx/progdlg.h>
57 #include <wx/sashwin.h>
58 #include <wx/spinbutt.h>
59 #include <wx/spinctrl.h>
60 #include <wx/splash.h>
61 #include <wx/splitter.h>
62 #include <wx/statline.h>
63 #include <wx/stream.h>
64 #include <wx/sysopt.h>
65 #include <wx/taskbar.h>
66 #include <wx/tglbtn.h>
67 #include <wx/tipwin.h>
68 #include <wx/toolbook.h>
69 #include <wx/tooltip.h>
70 #include <wx/treebook.h>
72 #include <wx/vscroll.h>
73 #include <wx/dateevt.h>
74 #include <wx/datectrl.h>
76 #include <wx/hyperlink.h>
77 #include <wx/pickerbase.h>
78 #include <wx/clrpicker.h>
79 #include <wx/filepicker.h>
80 #include <wx/fontpicker.h>
84 # pragma warning(disable:4800)
85 # pragma warning(disable:4190)
88 #ifdef __WXMAC__ // avoid a bug in Carbon headers
92 //---------------------------------------------------------------------------
94 #ifndef wxHAS_POWER_EVENTS
95 class wxPowerEvent
: public wxEvent
98 wxPowerEvent(wxEventType evtType
) : wxEvent(wxID_NONE
, evtType
) {}
100 bool IsVetoed() const { return false; }
101 virtual wxEvent
*Clone() const { return new wxPowerEvent(*this); }
105 //---------------------------------------------------------------------------
106 typedef unsigned char byte
;
107 typedef unsigned char* buffer
;
109 typedef wxPoint2DDouble wxPoint2D
;
111 #ifndef SWIG_TYPE_TABLE
112 #define SWIG_TYPE_TABLE wxPython_type_table
116 #define wxDEFAULT_STATUSBAR_STYLE wxST_SIZEGRIP|wxFULL_REPAINT_ON_RESIZE
118 #define wxDEFAULT_STATUSBAR_STYLE wxST_SIZEGRIP
122 #ifndef wxPyUSE_EXPORTED_API
124 void __wxPyPreStart(PyObject
*);
125 void __wxPyCleanup();
126 PyObject
* __wxPySetDictionary(PyObject
*, PyObject
* args
);
128 void wxSetDefaultPyEncoding(const char* encoding
);
129 const char* wxGetDefaultPyEncoding();
132 void wxPyEventThunker(wxObject
*, wxEvent
& event
);
135 bool wxPyCheckSwigType(const wxChar
* className
);
136 PyObject
* wxPyConstructObject(void* ptr
,
137 const wxChar
* className
,
139 bool wxPyConvertSwigPtr(PyObject
* obj
, void **ptr
,
140 const wxChar
* className
);
141 PyObject
* wxPyMakeSwigPtr(void* ptr
, const wxChar
* classname
);
144 PyObject
* wx2PyString(const wxString
& src
);
145 wxString
Py2wxString(PyObject
* source
);
147 PyObject
* wxPyMake_wxObject(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
=true);
148 PyObject
* wxPyMake_wxSizer(wxSizer
* source
, bool setThisOwn
);
149 void wxPyPtrTypeMap_Add(const char* commonName
, const char* ptrName
);
151 PyObject
* wxPy_ConvertList(wxListBase
* list
);
152 long wxPyGetWinHandle(wxWindow
* win
);
154 void wxPy_ReinitStockObjects(int pass
);
156 bool wxPyInstance_Check(PyObject
* obj
);
157 bool wxPySwigInstance_Check(PyObject
* obj
);
160 #endif // wxPyUSE_EXPORTED_API
161 //---------------------------------------------------------------------------
163 // if we want to handle threads and Python threads are available...
164 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
165 #define WXP_WITH_THREAD
166 #else // no Python threads...
167 #undef WXP_WITH_THREAD
171 // In Python 2.3 and later there are the PyGILState_* APIs that we can use for
172 // blocking threads when calling back into Python. Using them instead of my
173 // home-grown hacks greatly simplifies wxPyBeginBlockThreads and
174 // wxPyEndBlockThreads.
176 // Unfortunatly there is a bug somewhere when using these new APIs on Python
177 // 2.3. It manifests in Boa Constructor's debugger where it is unable to stop
178 // at breakpoints located in event handlers. I think that the cause may be
179 // something like the original PyThreadState for the main thread is not being
180 // restored for the callbacks, but I can't see where that could be
181 // happening... So we'll only activate this new change for Python 2.4+ :-(
183 #if PY_VERSION_HEX < 0x02040000
184 #define wxPyUSE_GIL_STATE 0
185 typedef bool wxPyBlock_t
;
187 #define wxPyUSE_GIL_STATE 1
188 typedef PyGILState_STATE wxPyBlock_t
;
192 // Python 2.5 changes the type of some API parameter and return types. Using
193 // this typedef for versions < 2.5 will help with the transition...
194 #if PY_VERSION_HEX < 0x02050000
195 typedef int Py_ssize_t
;
199 #ifndef wxPyUSE_EXPORTED_API
201 // For Python --> C++
202 PyThreadState
* wxPyBeginAllowThreads();
203 void wxPyEndAllowThreads(PyThreadState
* state
);
205 // For C++ --> Python
206 wxPyBlock_t
wxPyBeginBlockThreads();
207 void wxPyEndBlockThreads(wxPyBlock_t blocked
);
209 #endif // wxPyUSE_EXPORTED_API
212 // A macro that will help to execute simple statments wrapped in
213 // StartBlock/EndBlockThreads calls
214 #define wxPyBLOCK_THREADS(stmt) \
215 { wxPyBlock_t blocked = wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads(blocked); }
217 // Raise the NotImplementedError exception (blocking threads)
218 #define wxPyRaiseNotImplemented() \
219 wxPyBLOCK_THREADS(PyErr_SetNone(PyExc_NotImplementedError))
221 // Raise any exception with a string value (blocking threads)
222 #define wxPyErr_SetString(err, str) \
223 wxPyBLOCK_THREADS(PyErr_SetString(err, str))
226 //---------------------------------------------------------------------------
227 // These are helpers used by the typemaps
229 #ifndef wxPyUSE_EXPORTED_API
231 wxString
* wxString_in_helper(PyObject
* source
);
233 byte
* byte_LIST_helper(PyObject
* source
);
234 int* int_LIST_helper(PyObject
* source
);
235 long* long_LIST_helper(PyObject
* source
);
236 char** string_LIST_helper(PyObject
* source
);
237 wxPoint
* wxPoint_LIST_helper(PyObject
* source
, int* npoints
);
238 wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
239 wxString
* wxString_LIST_helper(PyObject
* source
);
240 wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
241 wxPen
** wxPen_LIST_helper(PyObject
* source
);
243 bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
244 bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
245 bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
246 bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
247 bool wxColour_helper(PyObject
* source
, wxColour
** obj
);
248 bool wxPoint2D_helper(PyObject
* source
, wxPoint2D
** obj
);
251 bool wxPySimple_typecheck(PyObject
* source
, const wxChar
* classname
, int seqLen
);
252 bool wxColour_typecheck(PyObject
* source
);
255 // Other helpful stuff
256 bool wxPyCheckForApp();
257 bool wxPyTestDisplayAvailable();
259 bool wxPy2int_seq_helper(PyObject
* source
, int* i1
, int* i2
);
260 bool wxPy4int_seq_helper(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
262 PyObject
* wxArrayString2PyList_helper(const wxArrayString
& arr
);
263 PyObject
* wxArrayInt2PyList_helper(const wxArrayInt
& arr
);
265 #endif // wxPyUSE_EXPORTED_API
267 //---------------------------------------------------------------------------
269 #if PYTHON_API_VERSION < 1009
270 #define PySequence_Fast_GET_ITEM(o, i) \
271 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
274 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
275 #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name)
276 #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val)
278 //---------------------------------------------------------------------------
280 #ifndef wxPyUSE_EXPORTED_API
282 class wxPyCallback
: public wxObject
{
283 DECLARE_ABSTRACT_CLASS(wxPyCallback
)
285 wxPyCallback(PyObject
* func
);
286 wxPyCallback(const wxPyCallback
& other
);
289 void EventThunker(wxEvent
& event
);
294 #endif // wxPyUSE_EXPORTED_API
295 //---------------------------------------------------------------------------
296 //---------------------------------------------------------------------------
297 // These Event classes can be derived from in Python and passed through the
298 // event system without loosing anything. They do this by keeping a reference
299 // to themselves and some special case handling in wxPyCallback::EventThunker.
303 class wxPyEvtSelfRef
{
308 void SetSelf(PyObject
* self
, bool clone
=false);
309 PyObject
* GetSelf() const;
310 bool GetCloned() const { return m_cloned
; }
318 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
319 DECLARE_ABSTRACT_CLASS(wxPyEvent
)
321 wxPyEvent(int winid
=0, wxEventType commandType
= wxEVT_NULL
);
322 wxPyEvent(const wxPyEvent
& evt
);
325 virtual wxEvent
* Clone() const { return new wxPyEvent(*this); }
329 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
330 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent
)
332 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
333 wxPyCommandEvent(const wxPyCommandEvent
& evt
);
336 virtual wxEvent
* Clone() const { return new wxPyCommandEvent(*this); }
341 //----------------------------------------------------------------------
342 // Forward decalre a few things used in the exported API
343 class wxPyClientData
;
345 class wxPyOORClientData
;
346 class wxPyCBInputStream
;
348 void wxPyClientData_dtor(wxPyClientData
* self
);
349 void wxPyUserData_dtor(wxPyUserData
* self
);
350 void wxPyOORClientData_dtor(wxPyOORClientData
* self
);
351 wxPyCBInputStream
* wxPyCBInputStream_create(PyObject
*py
, bool block
);
352 wxPyCBInputStream
* wxPyCBInputStream_copy(wxPyCBInputStream
* other
);
354 //---------------------------------------------------------------------------
355 // Export a C API in a struct. Other modules will be able to load this from
356 // the wx.core module and will then have safe access to these functions, even if
357 // in another shared library.
359 class wxPyCallbackHelper
;
363 bool (*p_wxPyCheckSwigType
)(const wxChar
* className
);
364 PyObject
* (*p_wxPyConstructObject
)(void* ptr
, const wxChar
* className
, int setThisOwn
);
365 bool (*p_wxPyConvertSwigPtr
)(PyObject
* obj
, void **ptr
, const wxChar
* className
);
366 PyObject
* (*p_wxPyMakeSwigPtr
)(void* ptr
, const wxChar
* className
);
368 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
369 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
370 wxPyBlock_t (*p_wxPyBeginBlockThreads
)();
371 void (*p_wxPyEndBlockThreads
)(wxPyBlock_t blocked
);
373 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
);
375 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
376 wxString (*p_Py2wxString
)(PyObject
* source
);
377 PyObject
* (*p_wx2PyString
)(const wxString
& src
);
379 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
380 int* (*p_int_LIST_helper
)(PyObject
* source
);
381 long* (*p_long_LIST_helper
)(PyObject
* source
);
382 char** (*p_string_LIST_helper
)(PyObject
* source
);
383 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
384 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
385 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
386 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
388 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
389 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
390 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
391 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
392 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
393 bool (*p_wxPoint2D_helper
)(PyObject
* source
, wxPoint2DDouble
** obj
);
396 bool (*p_wxPySimple_typecheck
)(PyObject
* source
, const wxChar
* classname
, int seqLen
);
397 bool (*p_wxColour_typecheck
)(PyObject
* source
);
399 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
400 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
);
401 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
402 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
403 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
405 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
);
406 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
, bool setThisOwn
);
407 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
408 bool (*p_wxPy2int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
);
409 bool (*p_wxPy4int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
410 PyObject
* (*p_wxArrayString2PyList_helper
)(const wxArrayString
& arr
);
411 PyObject
* (*p_wxArrayInt2PyList_helper
)(const wxArrayInt
& arr
);
413 void (*p_wxPyClientData_dtor
)(wxPyClientData
*);
414 void (*p_wxPyUserData_dtor
)(wxPyUserData
*);
415 void (*p_wxPyOORClientData_dtor
)(wxPyOORClientData
*);
417 wxPyCBInputStream
* (*p_wxPyCBInputStream_create
)(PyObject
*py
, bool block
);
418 wxPyCBInputStream
* (*p_wxPyCBInputStream_copy
)(wxPyCBInputStream
* other
);
420 bool (*p_wxPyInstance_Check
)(PyObject
* obj
);
421 bool (*p_wxPySwigInstance_Check
)(PyObject
* obj
);
423 bool (*p_wxPyCheckForApp
)();
427 #ifdef wxPyUSE_EXPORTED_API
428 // Notice that this is static, not extern. This is by design, each module
429 // needs one, but doesn't have to use it.
430 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
;
431 inline wxPyCoreAPI
* wxPyGetCoreAPIPtr();
432 #endif // wxPyUSE_EXPORTED_API
434 //---------------------------------------------------------------------------
436 // A wxObject that holds a reference to a Python object
437 class wxPyUserData
: public wxObject
{
439 wxPyUserData(PyObject
* obj
) {
445 #ifdef wxPyUSE_EXPORTED_API
446 wxPyGetCoreAPIPtr()->p_wxPyUserData_dtor(this);
448 wxPyUserData_dtor(this);
455 // A wxClientData that holds a refernece to a Python object
456 class wxPyClientData
: public wxClientData
{
458 wxPyClientData(PyObject
* obj
, bool incref
=true) {
466 #ifdef wxPyUSE_EXPORTED_API
467 wxPyGetCoreAPIPtr()->p_wxPyClientData_dtor(this);
469 wxPyClientData_dtor(this);
477 // Just like wxPyClientData, except when this object is destroyed it does some
478 // OOR magic on the Python Object.
479 class wxPyOORClientData
: public wxPyClientData
{
481 wxPyOORClientData(PyObject
* obj
, bool incref
=true)
482 : wxPyClientData(obj
, incref
) {}
483 ~wxPyOORClientData() {
485 #ifdef wxPyUSE_EXPORTED_API
486 wxPyGetCoreAPIPtr()->p_wxPyOORClientData_dtor(this);
488 wxPyOORClientData_dtor(this);
494 //---------------------------------------------------------------------------
495 // A wxImageHandler that can be derived from in Python.
498 class wxPyImageHandler
: public wxImageHandler
{
502 // used for interning method names as PyStrings
503 static PyObject
* m_DoCanRead_Name
;
504 static PyObject
* m_GetImageCount_Name
;
505 static PyObject
* m_LoadFile_Name
;
506 static PyObject
* m_SaveFile_Name
;
508 // converstion helpers
509 PyObject
* py_InputStream(wxInputStream
* stream
);
510 PyObject
* py_Image(wxImage
* image
);
511 PyObject
* py_OutputStream(wxOutputStream
* stream
);
516 void _SetSelf(PyObject
*self
);
518 virtual bool LoadFile(wxImage
* image
, wxInputStream
& stream
,
519 bool verbose
=true, int index
=-1 );
520 virtual bool SaveFile(wxImage
* image
, wxOutputStream
& stream
,
522 virtual int GetImageCount(wxInputStream
& stream
);
523 virtual bool DoCanRead(wxInputStream
&stream
);
527 //---------------------------------------------------------------------------
528 // This class holds an instance of a Python Shadow Class object and assists
529 // with looking up and invoking Python callback methods from C++ virtual
530 // method redirections. For all classes which have virtuals which should be
531 // overridable in wxPython, a new subclass is created that contains a
532 // wxPyCallbackHelper.
535 class wxPyCallbackHelper
{
537 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
539 wxPyCallbackHelper() {
546 ~wxPyCallbackHelper() {
547 #ifdef wxPyUSE_EXPORTED_API
548 wxPyGetCoreAPIPtr()->p_wxPyCBH_delete(this);
550 wxPyCBH_delete(this);
554 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=true);
555 bool findCallback(const char* name
, bool setGuard
=true) const;
556 int callCallback(PyObject
* argTuple
) const;
557 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
558 PyObject
* GetLastFound() const { return m_lastFound
; }
560 void setRecursionGuard(PyObject
* method
) const;
561 void clearRecursionGuard(PyObject
* method
) const;
566 PyObject
* m_lastFound
;
569 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
573 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
574 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
=true);
575 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
576 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
577 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
582 //---------------------------------------------------------------------------
584 // This is used in C++ classes that need to be able to make callback to
585 // "overloaded" python methods
588 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
589 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
591 private: wxPyCallbackHelper m_myInst
594 //---------------------------------------------------------------------------
595 // The wxPythonApp class
598 wxPYAPP_ASSERT_SUPPRESS
= 1,
599 wxPYAPP_ASSERT_EXCEPTION
= 2,
600 wxPYAPP_ASSERT_DIALOG
= 4,
601 wxPYAPP_ASSERT_LOG
= 8
604 class wxPyApp
: public wxApp
606 DECLARE_ABSTRACT_CLASS(wxPyApp
)
614 int GetAssertMode() { return m_assertMode
; }
615 void SetAssertMode(int mode
) { m_assertMode
= mode
; }
617 virtual bool OnInitGui();
618 virtual int OnExit();
620 virtual void OnAssertFailure(const wxChar
*file
,
626 virtual void ExitMainLoop();
627 // virtual int FilterEvent(wxEvent& event); // This one too????
629 // For catching Apple Events
630 virtual void MacOpenFile(const wxString
&fileName
);
631 virtual void MacPrintFile(const wxString
&fileName
);
632 virtual void MacNewFile();
633 virtual void MacReopenApp();
635 static bool GetMacSupportPCMenuShortcuts();
636 static long GetMacAboutMenuItemId();
637 static long GetMacPreferencesMenuItemId();
638 static long GetMacExitMenuItemId();
639 static wxString
GetMacHelpMenuTitleName();
641 static void SetMacSupportPCMenuShortcuts(bool val
);
642 static void SetMacAboutMenuItemId(long val
);
643 static void SetMacPreferencesMenuItemId(long val
);
644 static void SetMacExitMenuItemId(long val
);
645 static void SetMacHelpMenuTitleName(const wxString
& val
);
648 void _BootstrapApp();
650 // implementation only
651 void SetStartupComplete(bool val
) { m_startupComplete
= val
; };
655 bool m_startupComplete
;
658 extern wxPyApp
*wxPythonApp
;
661 //----------------------------------------------------------------------
662 // These macros are used to implement the virtual methods that should
663 // redirect to a Python method if one exists. The names designate the
664 // return type, if any, as well as any parameter types.
665 //---------------------------------------------------------------------------
667 #define DEC_PYCALLBACK__(CBNAME) \
671 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
672 void CLASS::CBNAME() { \
674 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
675 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
676 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
677 wxPyEndBlockThreads(blocked); \
682 #define DEC_PYCALLBACK_VOID_(CBNAME) \
683 DEC_PYCALLBACK__(CBNAME)
685 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
686 IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME)
688 //---------------------------------------------------------------------------
690 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
691 bool CBNAME(int a, int b)
694 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
695 bool CLASS::CBNAME(int a, int b) { \
696 bool rval=false, found; \
697 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
698 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
699 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
700 wxPyEndBlockThreads(blocked); \
702 rval = PCLASS::CBNAME(a,b); \
706 //---------------------------------------------------------------------------
708 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
709 void CBNAME(int a, int b)
712 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
713 void CLASS::CBNAME(int a, int b) { \
715 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
716 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
717 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
718 wxPyEndBlockThreads(blocked); \
720 PCLASS::CBNAME(a,b); \
723 //---------------------------------------------------------------------------
725 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
729 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
730 void CLASS::CBNAME(int a) { \
732 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
733 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
734 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
735 wxPyEndBlockThreads(blocked); \
740 //---------------------------------------------------------------------------
742 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
743 void CBNAME(int a, int b, int c, int d)
746 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
747 void CLASS::CBNAME(int a, int b, int c, int d) { \
749 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
750 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
751 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
752 wxPyEndBlockThreads(blocked); \
754 PCLASS::CBNAME(a,b,c,d); \
757 //---------------------------------------------------------------------------
758 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
759 void CBNAME(int a, int b, int c, int d, int e)
762 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
763 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
765 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
766 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
767 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
768 wxPyEndBlockThreads(blocked); \
770 PCLASS::CBNAME(a,b,c,d,e); \
773 //---------------------------------------------------------------------------
775 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
776 void CBNAME(int* a, int* b) const
779 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
780 void CLASS::CBNAME(int* a, int* b) const { \
781 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
783 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
784 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
786 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
788 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
789 PyObject* o1 = PySequence_GetItem(ro, 0); \
790 PyObject* o2 = PySequence_GetItem(ro, 1); \
791 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
792 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
795 PyErr_SetString(PyExc_TypeError, errmsg); \
800 PyErr_SetString(PyExc_TypeError, errmsg); \
805 wxPyEndBlockThreads(blocked); \
807 PCLASS::CBNAME(a,b); \
810 //---------------------------------------------------------------------------
812 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
813 wxSize CBNAME() const
816 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
817 wxSize CLASS::CBNAME() const { \
818 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
819 bool found; wxSize rval(0,0); \
820 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
821 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
823 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
825 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
826 PyObject* o1 = PySequence_GetItem(ro, 0); \
827 PyObject* o2 = PySequence_GetItem(ro, 1); \
828 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
829 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
832 PyErr_SetString(PyExc_TypeError, errmsg); \
837 PyErr_SetString(PyExc_TypeError, errmsg); \
842 wxPyEndBlockThreads(blocked); \
844 return PCLASS::CBNAME(); \
849 //---------------------------------------------------------------------------
851 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
855 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
856 bool CLASS::CBNAME(bool a) { \
857 bool rval=false, found; \
858 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
859 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
860 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
861 wxPyEndBlockThreads(blocked); \
863 rval = PCLASS::CBNAME(a); \
867 //---------------------------------------------------------------------------
869 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
873 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
874 bool CLASS::CBNAME(int a) { \
875 bool rval=false, found; \
876 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
877 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
878 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
879 wxPyEndBlockThreads(blocked); \
881 rval = PCLASS::CBNAME(a); \
885 //---------------------------------------------------------------------------
887 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
891 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
892 bool CLASS::CBNAME(int a) { \
894 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
895 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
896 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
898 wxPyEndBlockThreads(blocked); \
903 //---------------------------------------------------------------------------
905 #define DEC_PYCALLBACK__DC(CBNAME) \
909 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
910 void CLASS::CBNAME(wxDC& a) { \
912 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
913 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
914 PyObject* obj = wxPyMake_wxObject(&a,false); \
915 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
918 wxPyEndBlockThreads(blocked); \
924 //---------------------------------------------------------------------------
926 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
927 void CBNAME(wxDC& a, bool b)
930 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
931 void CLASS::CBNAME(wxDC& a, bool b) { \
933 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
934 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
935 PyObject* obj = wxPyMake_wxObject(&a,false); \
936 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
939 wxPyEndBlockThreads(blocked); \
941 PCLASS::CBNAME(a, b); \
944 //---------------------------------------------------------------------------
946 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
947 void CBNAME(wxDC& a, bool b)
950 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
951 void CLASS::CBNAME(wxDC& a, bool b) { \
953 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
954 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
955 PyObject* obj = wxPyMake_wxObject(&a,false); \
956 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
959 wxPyEndBlockThreads(blocked); \
961 PCLASS::CBNAME(a, b); \
964 //---------------------------------------------------------------------------
966 #define DEC_PYCALLBACK__2DBL(CBNAME) \
967 void CBNAME(double a, double b)
970 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
971 void CLASS::CBNAME(double a, double b) { \
973 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
974 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
975 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
976 wxPyEndBlockThreads(blocked); \
978 PCLASS::CBNAME(a, b); \
981 //---------------------------------------------------------------------------
983 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
984 void CBNAME(double a, double b, int c, int d)
987 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
988 void CLASS::CBNAME(double a, double b, int c, int d) { \
990 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
991 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
992 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
994 wxPyEndBlockThreads(blocked); \
996 PCLASS::CBNAME(a, b, c, d); \
999 //---------------------------------------------------------------------------
1001 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
1002 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1005 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1006 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1008 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1009 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1010 PyObject* obj = wxPyMake_wxObject(&a,false); \
1011 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
1014 wxPyEndBlockThreads(blocked); \
1016 PCLASS::CBNAME(a, b, c, d, e, f); \
1019 //---------------------------------------------------------------------------
1021 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
1022 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1025 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1026 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1028 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1030 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1031 PyObject* obj = wxPyMake_wxObject(&a,false); \
1032 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1035 wxPyEndBlockThreads(blocked); \
1037 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1041 //---------------------------------------------------------------------------
1043 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1044 void CBNAME(bool a, double b, double c, int d, int e)
1047 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1048 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1050 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1051 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1052 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1054 wxPyEndBlockThreads(blocked); \
1056 PCLASS::CBNAME(a, b, c, d, e); \
1059 //---------------------------------------------------------------------------
1061 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1062 void CBNAME(wxDC& a, double b, double c, double d, double e)
1065 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1066 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1068 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1069 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1070 PyObject* obj = wxPyMake_wxObject(&a,false); \
1071 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1074 wxPyEndBlockThreads(blocked); \
1076 PCLASS::CBNAME(a, b, c, d, e); \
1079 //---------------------------------------------------------------------------
1081 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1082 void CBNAME(wxDC& a, bool b)
1085 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1086 void CLASS::CBNAME(wxDC& a, bool b) { \
1088 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1089 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1090 PyObject* obj = wxPyMake_wxObject(&a,false); \
1091 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1094 wxPyEndBlockThreads(blocked); \
1096 PCLASS::CBNAME(a, b); \
1099 //---------------------------------------------------------------------------
1101 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1102 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1105 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1106 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1109 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1110 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1111 PyObject* obj = wxPyMake_wxObject(a,false); \
1112 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1115 wxPyEndBlockThreads(blocked); \
1117 PCLASS::CBNAME(a, b, c, d, e, f); \
1120 //---------------------------------------------------------------------------
1122 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1123 void CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1126 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1127 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1129 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1130 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1131 PyObject* obj = wxPyMake_wxObject(a,false); \
1132 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1135 wxPyEndBlockThreads(blocked); \
1137 PCLASS::CBNAME(a, b, c, d, e); \
1140 //---------------------------------------------------------------------------
1142 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1143 void CBNAME(double a, double b, int c)
1146 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1147 void CLASS::CBNAME(double a, double b, int c) { \
1149 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1150 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1151 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1152 wxPyEndBlockThreads(blocked); \
1154 PCLASS::CBNAME(a, b, c); \
1157 //---------------------------------------------------------------------------
1159 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1160 void CBNAME(bool a, double b, double c, int d)
1163 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1164 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1166 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1167 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1168 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1169 wxPyEndBlockThreads(blocked); \
1171 PCLASS::CBNAME(a, b, c, d); \
1174 //---------------------------------------------------------------------------
1175 //---------------------------------------------------------------------------
1177 #define DEC_PYCALLBACK__STRING(CBNAME) \
1178 void CBNAME(const wxString& a)
1180 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1181 void CLASS::CBNAME(const wxString& a) { \
1183 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1184 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1185 PyObject* s = wx2PyString(a); \
1186 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1189 wxPyEndBlockThreads(blocked); \
1191 PCLASS::CBNAME(a); \
1194 //---------------------------------------------------------------------------
1196 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1197 bool CBNAME(const wxString& a)
1199 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1200 bool CLASS::CBNAME(const wxString& a) { \
1203 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1204 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1205 PyObject* s = wx2PyString(a); \
1206 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1209 wxPyEndBlockThreads(blocked); \
1211 rval = PCLASS::CBNAME(a); \
1215 //---------------------------------------------------------------------------
1217 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1218 bool CBNAME(const wxString& a)
1220 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1221 bool CLASS::CBNAME(const wxString& a) { \
1223 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1224 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1225 PyObject* s = wx2PyString(a); \
1226 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1229 wxPyEndBlockThreads(blocked); \
1233 //---------------------------------------------------------------------------
1235 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1236 wxString CBNAME(const wxString& a)
1238 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1239 wxString CLASS::CBNAME(const wxString& a) { \
1241 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1242 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1244 PyObject* s = wx2PyString(a); \
1245 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1248 rval = Py2wxString(ro); \
1252 wxPyEndBlockThreads(blocked); \
1256 //---------------------------------------------------------------------------
1258 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1259 wxString CBNAME(const wxString& a)
1261 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1262 wxString CLASS::CBNAME(const wxString& a) { \
1265 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1266 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1268 PyObject* s = wx2PyString(a); \
1269 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1272 rval = Py2wxString(ro); \
1276 wxPyEndBlockThreads(blocked); \
1278 rval = PCLASS::CBNAME(a); \
1282 //---------------------------------------------------------------------------
1284 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1285 wxString CBNAME(const wxString& a,int b)
1287 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1288 wxString CLASS::CBNAME(const wxString& a,int b) { \
1290 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1291 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1293 PyObject* s = wx2PyString(a); \
1294 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1297 rval = Py2wxString(ro); \
1301 wxPyEndBlockThreads(blocked); \
1305 //---------------------------------------------------------------------------
1307 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1308 bool CBNAME(const wxString& a, const wxString& b)
1310 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1311 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1314 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1315 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1316 PyObject* s1 = wx2PyString(a); \
1317 PyObject* s2 = wx2PyString(b); \
1318 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1322 wxPyEndBlockThreads(blocked); \
1324 rval = PCLASS::CBNAME(a, b); \
1328 //---------------------------------------------------------------------------
1330 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1333 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1334 wxString CLASS::CBNAME() { \
1337 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1338 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1340 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1342 rval = Py2wxString(ro); \
1346 wxPyEndBlockThreads(blocked); \
1348 rval = PCLASS::CBNAME(); \
1352 //---------------------------------------------------------------------------
1354 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1355 wxString CBNAME() const
1357 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1358 wxString CLASS::CBNAME() const { \
1361 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1362 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1364 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1366 rval = Py2wxString(ro); \
1370 wxPyEndBlockThreads(blocked); \
1372 rval = PCLASS::CBNAME(); \
1376 //---------------------------------------------------------------------------
1378 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1381 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1382 wxString CLASS::CBNAME() { \
1384 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1385 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1387 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1389 rval = Py2wxString(ro); \
1393 wxPyEndBlockThreads(blocked); \
1397 //---------------------------------------------------------------------------
1399 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1400 wxString CBNAME() const;
1402 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1403 wxString CLASS::CBNAME() const { \
1405 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1406 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1408 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1410 rval = Py2wxString(ro); \
1414 wxPyEndBlockThreads(blocked); \
1418 //---------------------------------------------------------------------------
1420 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1421 bool CBNAME(const wxHtmlTag& a)
1424 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1425 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1427 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1428 if (wxPyCBH_findCallback2(m_myInst, #CBNAME, false)) { \
1429 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
1430 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1433 wxPyEndBlockThreads(blocked); \
1437 //---------------------------------------------------------------------------
1439 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1440 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1442 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1443 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1445 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1446 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1447 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1448 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1451 wxPyEndBlockThreads(blocked); \
1453 PCLASS::CBNAME(cell, x, y); \
1456 //---------------------------------------------------------------------------
1458 #define DEC_PYCALLBACK__COLOUR(CBNAME) \
1459 void CBNAME(const wxColour& c);
1461 #define IMP_PYCALLBACK__COLOUR(CLASS, PCLASS, CBNAME) \
1462 void CLASS::CBNAME(const wxColour& c) { \
1464 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1465 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1466 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1467 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1470 wxPyEndBlockThreads(blocked); \
1472 PCLASS::CBNAME(c); \
1475 //---------------------------------------------------------------------------
1476 #define DEC_PYCALLBACK__INTCOLOUR(CBNAME) \
1477 void CBNAME(int a, const wxColour& c);
1479 #define IMP_PYCALLBACK__INTCOLOUR(CLASS, PCLASS, CBNAME) \
1480 void CLASS::CBNAME(int a, const wxColour& c) { \
1482 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1483 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1484 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1485 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)",a, obj)); \
1488 wxPyEndBlockThreads(blocked); \
1490 PCLASS::CBNAME(a, c); \
1493 //---------------------------------------------------------------------------
1495 #define DEC_PYCALLBACK__INTFONT(CBNAME) \
1496 void CBNAME(int a, const wxFont& c);
1498 #define IMP_PYCALLBACK__INTFONT(CLASS, PCLASS, CBNAME) \
1499 void CLASS::CBNAME(int a, const wxFont& c) { \
1501 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1502 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1503 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxFont"), 0); \
1504 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)",a, obj)); \
1507 wxPyEndBlockThreads(blocked); \
1509 PCLASS::CBNAME(a, c); \
1512 //---------------------------------------------------------------------------
1514 #define DEC_PYCALLBACK_BOOL_CELLINTINTME(CBNAME) \
1515 bool CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1517 #define IMP_PYCALLBACK_BOOL_CELLINTINTME(CLASS, PCLASS, CBNAME) \
1518 bool CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1519 bool rval=false, found; \
1520 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1521 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1522 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1523 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1524 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1528 wxPyEndBlockThreads(blocked); \
1530 rval = PCLASS::CBNAME(cell, x, y, e); \
1535 //---------------------------------------------------------------------------
1537 #define DEC_PYCALLBACK___pure(CBNAME) \
1541 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1542 void CLASS::CBNAME() { \
1543 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1544 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1545 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1546 wxPyEndBlockThreads(blocked); \
1549 //---------------------------------------------------------------------------
1551 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1555 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1556 wxSize CLASS::CBNAME() { \
1557 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1559 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1560 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1563 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1565 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1567 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1569 PyObject* o1 = PySequence_GetItem(ro, 0); \
1570 PyObject* o2 = PySequence_GetItem(ro, 1); \
1571 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1572 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1574 PyErr_SetString(PyExc_TypeError, errmsg); \
1579 PyErr_SetString(PyExc_TypeError, errmsg); \
1584 wxPyEndBlockThreads(blocked); \
1588 //---------------------------------------------------------------------------
1590 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1591 bool CBNAME(wxWindow* a)
1594 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1595 bool CLASS::CBNAME(wxWindow* a) { \
1598 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1599 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1600 PyObject* obj = wxPyMake_wxObject(a,false); \
1601 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1604 wxPyEndBlockThreads(blocked); \
1606 rval = PCLASS::CBNAME(a); \
1610 //---------------------------------------------------------------------------
1612 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1613 bool CBNAME(wxWindow* a, wxDC& b)
1616 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1617 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1620 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1621 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1622 PyObject* win = wxPyMake_wxObject(a,false); \
1623 PyObject* dc = wxPyMake_wxObject(&b,false); \
1624 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1628 wxPyEndBlockThreads(blocked); \
1630 rval = PCLASS::CBNAME(a, b); \
1634 //---------------------------------------------------------------------------
1636 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1637 void CBNAME(wxWindowBase* a)
1640 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1641 void CLASS::CBNAME(wxWindowBase* a) { \
1643 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1644 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1645 PyObject* obj = wxPyMake_wxObject(a,false); \
1646 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1649 wxPyEndBlockThreads(blocked); \
1651 PCLASS::CBNAME(a); \
1654 //---------------------------------------------------------------------------
1656 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1660 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1661 bool CLASS::CBNAME() { \
1664 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1665 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1666 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1667 wxPyEndBlockThreads(blocked); \
1669 rval = PCLASS::CBNAME(); \
1673 //---------------------------------------------------------------------------
1675 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1679 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1680 bool CLASS::CBNAME() const { \
1683 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1684 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1685 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1686 wxPyEndBlockThreads(blocked); \
1688 rval = PCLASS::CBNAME(); \
1692 //---------------------------------------------------------------------------
1694 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1695 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1698 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1699 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1702 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1703 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1704 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1705 wxPyEndBlockThreads(blocked); \
1707 rval = PCLASS::CBNAME(a, b, c); \
1708 return (wxDragResult)rval; \
1711 //---------------------------------------------------------------------------
1713 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1714 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1716 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1717 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1718 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1720 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1722 PyObject* obj = wxPyMake_wxObject(&a,false); \
1723 PyObject* s = wx2PyString(b); \
1724 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1727 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
1728 /* release ownership of the C++ wx.FSFile object. */ \
1729 PyObject_SetAttrString(ro, "thisown", Py_False); \
1735 wxPyEndBlockThreads(blocked); \
1739 //---------------------------------------------------------------------------
1741 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1742 bool CBNAME(wxDragResult a)
1745 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1746 bool CLASS::CBNAME(wxDragResult a) { \
1749 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1750 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1751 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1752 wxPyEndBlockThreads(blocked); \
1754 rval = PCLASS::CBNAME(a); \
1758 //---------------------------------------------------------------------------
1760 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1761 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1764 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1765 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1766 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1768 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1769 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1770 wxPyEndBlockThreads(blocked); \
1771 return (wxDragResult)rval; \
1774 //---------------------------------------------------------------------------
1776 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1777 bool CBNAME(int a, int b, const wxString& c)
1779 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1780 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1782 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1783 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1784 PyObject* s = wx2PyString(c); \
1785 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1788 wxPyEndBlockThreads(blocked); \
1792 //---------------------------------------------------------------------------
1794 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1798 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1799 size_t CLASS::CBNAME() { \
1802 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1803 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1804 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1805 wxPyEndBlockThreads(blocked); \
1807 rval = PCLASS::CBNAME(); \
1811 //---------------------------------------------------------------------------
1813 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1814 size_t CBNAME() const
1817 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1818 size_t CLASS::CBNAME() const { \
1821 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1822 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1823 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1824 wxPyEndBlockThreads(blocked); \
1826 rval = PCLASS::CBNAME(); \
1830 //---------------------------------------------------------------------------
1832 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1833 wxDataFormat CBNAME(size_t a)
1836 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1837 wxDataFormat CLASS::CBNAME(size_t a) { \
1838 wxDataFormat rval=0; \
1840 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1841 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1843 wxDataFormat* ptr; \
1844 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1846 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1851 wxPyEndBlockThreads(blocked); \
1853 rval = PCLASS::CBNAME(a); \
1857 //---------------------------------------------------------------------------
1859 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1860 void CBNAME(const Type& a)
1863 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1864 void CLASS::CBNAME(const Type& a) { \
1866 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1867 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1868 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1869 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1872 wxPyEndBlockThreads(blocked); \
1874 PCLASS::CBNAME(a); \
1878 //---------------------------------------------------------------------------
1880 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1881 void CBNAME(Type& a)
1884 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1885 void CLASS::CBNAME(Type& a) { \
1887 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1888 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1889 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1890 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1893 wxPyEndBlockThreads(blocked); \
1895 PCLASS::CBNAME(a); \
1898 //---------------------------------------------------------------------------
1900 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1901 bool CBNAME(Type& a)
1904 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1905 bool CLASS::CBNAME(Type& a) { \
1908 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1909 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1910 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1911 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1914 wxPyEndBlockThreads(blocked); \
1916 rv = PCLASS::CBNAME(a); \
1920 //---------------------------------------------------------------------------
1922 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
1923 bool CBNAME(Type& a)
1926 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
1927 bool CLASS::CBNAME(Type& a) { \
1929 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1930 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1931 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1932 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1935 wxPyEndBlockThreads(blocked); \
1939 //---------------------------------------------------------------------------
1941 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1942 wxString CBNAME(long a, long b) const
1944 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1945 wxString CLASS::CBNAME(long a, long b) const { \
1948 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1949 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1951 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1953 rval = Py2wxString(ro); \
1957 wxPyEndBlockThreads(blocked); \
1959 rval = PCLASS::CBNAME(a,b); \
1963 //---------------------------------------------------------------------------
1965 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1966 int CBNAME(long a) const
1969 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1970 int CLASS::CBNAME(long a) const { \
1973 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1974 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1976 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1978 rval = PyInt_AsLong(ro); \
1982 wxPyEndBlockThreads(blocked); \
1984 rval = PCLASS::CBNAME(a); \
1989 #define DEC_PYCALLBACK_INT_LONG_virtual(CBNAME) \
1990 int CBNAME(long a) const;
1993 #define IMP_PYCALLBACK_INT_LONG_virtual(CLASS, PCLASS, CBNAME) \
1994 int CLASS::CBNAME(long a) const { \
1995 int rval=-1; /* this rval is important for OnGetItemImage */ \
1997 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1998 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2000 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2002 rval = PyInt_AsLong(ro); \
2006 wxPyEndBlockThreads(blocked); \
2011 //---------------------------------------------------------------------------
2013 #define DEC_PYCALLBACK_INT_INT(CBNAME) \
2017 #define IMP_PYCALLBACK_INT_INT(CLASS, PCLASS, CBNAME) \
2018 int CLASS::CBNAME(int a) { \
2021 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2022 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2024 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a)); \
2026 rval = PyInt_AsLong(ro); \
2030 wxPyEndBlockThreads(blocked); \
2032 rval = PCLASS::CBNAME(a); \
2036 //---------------------------------------------------------------------------
2038 #define DEC_PYCALLBACK_INT_LONGLONG(CBNAME) \
2039 int CBNAME(long a, long b) const
2042 #define IMP_PYCALLBACK_INT_LONGLONG(CLASS, PCLASS, CBNAME) \
2043 int CLASS::CBNAME(long a, long b) const { \
2046 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2047 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2049 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2051 rval = PyInt_AsLong(ro); \
2055 wxPyEndBlockThreads(blocked); \
2057 rval = PCLASS::CBNAME(a, b); \
2062 #define DEC_PYCALLBACK_INT_LONGLONG_virtual(CBNAME) \
2063 int CBNAME(long a, long b) const;
2066 #define IMP_PYCALLBACK_INT_LONGLONG_virtual(CLASS, PCLASS, CBNAME) \
2067 int CLASS::CBNAME(long a, long b) const { \
2068 int rval=-1; /* this rval is important for OnGetItemImage */ \
2070 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2071 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2073 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2075 rval = PyInt_AsLong(ro); \
2079 wxPyEndBlockThreads(blocked); \
2084 //---------------------------------------------------------------------------
2086 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2087 wxListItemAttr* CBNAME(long a) const
2090 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2091 wxListItemAttr *CLASS::CBNAME(long a) const { \
2092 wxListItemAttr *rval = NULL; \
2094 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2095 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2097 wxListItemAttr* ptr; \
2098 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2100 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2105 wxPyEndBlockThreads(blocked); \
2107 rval = PCLASS::CBNAME(a); \
2111 //---------------------------------------------------------------------------
2113 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2114 bool CBNAME(wxMouseEvent& e)
2116 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2117 bool CLASS::CBNAME(wxMouseEvent& e) { \
2120 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2121 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2123 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2124 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2126 rval = PyInt_AsLong(ro); \
2131 wxPyEndBlockThreads(blocked); \
2133 return PCLASS::CBNAME(e); \
2137 //---------------------------------------------------------------------------
2139 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2140 wxWizardPage* CBNAME() const
2142 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2143 wxWizardPage* CLASS::CBNAME() const { \
2144 wxWizardPage* rv = NULL; \
2145 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2146 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2148 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2150 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2154 wxPyEndBlockThreads(blocked); \
2158 //---------------------------------------------------------------------------
2160 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2161 wxBitmap CBNAME() const
2163 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2164 wxBitmap CLASS::CBNAME() const { \
2166 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2167 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2170 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2172 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2177 wxPyEndBlockThreads(blocked); \
2181 //---------------------------------------------------------------------------
2183 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2186 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2187 wxObject* CLASS::CBNAME() { \
2188 wxObject* rv = NULL; \
2189 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2190 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2192 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2194 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2198 wxPyEndBlockThreads(blocked); \
2202 //---------------------------------------------------------------------------
2204 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2205 wxObject* CBNAME(const wxString& a)
2207 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2208 wxObject* CLASS::CBNAME(const wxString& a) { \
2209 wxObject* rv = NULL; \
2210 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2211 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2212 PyObject* so = wx2PyString(a); \
2214 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2216 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2221 wxPyEndBlockThreads(blocked); \
2225 //---------------------------------------------------------------------------
2227 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2228 bool CBNAME(wxXmlNode* a)
2231 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2232 bool CLASS::CBNAME(wxXmlNode* a) { \
2234 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2235 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2236 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2237 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2240 wxPyEndBlockThreads(blocked); \
2244 //---------------------------------------------------------------------------
2246 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2247 wxCoord CBNAME(size_t a) const
2250 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2251 wxCoord CLASS::CBNAME(size_t a) const { \
2254 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2255 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2256 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2258 wxPyEndBlockThreads(blocked); \
2262 //---------------------------------------------------------------------------
2264 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2265 void CBNAME(size_t a, size_t b) const
2268 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2269 void CLASS::CBNAME(size_t a, size_t b) const { \
2271 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2272 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2273 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2274 wxPyEndBlockThreads(blocked); \
2276 PCLASS::CBNAME(a,b); \
2278 //---------------------------------------------------------------------------
2280 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2281 wxCoord CBNAME() const
2284 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2285 wxCoord CLASS::CBNAME() const { \
2288 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2289 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2290 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2291 wxPyEndBlockThreads(blocked); \
2293 rval = PCLASS::CBNAME(); \
2297 //---------------------------------------------------------------------------
2299 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2300 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2302 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2303 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2305 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2306 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2307 PyObject* obj = wxPyMake_wxObject(&a,false); \
2308 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2309 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2310 Py_DECREF(obj); Py_DECREF(ro); \
2312 wxPyEndBlockThreads(blocked); \
2317 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2318 void CBNAME(wxDC& a, const wxRect& b, size_t c) const
2320 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2321 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2323 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2324 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2325 PyObject* obj = wxPyMake_wxObject(&a,false); \
2326 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2327 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2328 Py_DECREF(obj); Py_DECREF(ro); \
2330 wxPyEndBlockThreads(blocked); \
2332 PCLASS::CBNAME(a,b,c); \
2336 //---------------------------------------------------------------------------
2337 // Same as the above set, but the wxRect is not const
2339 #define DEC_PYCALLBACK__DCRECTSIZET2_constpure(CBNAME) \
2340 void CBNAME(wxDC& a, wxRect& b, size_t c) const;
2342 #define IMP_PYCALLBACK__DCRECTSIZET2_constpure(CLASS, PCLASS, CBNAME) \
2343 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2345 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2346 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2347 PyObject* obj = wxPyMake_wxObject(&a,false); \
2348 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2349 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2350 Py_DECREF(obj); Py_DECREF(ro); \
2352 wxPyEndBlockThreads(blocked); \
2357 #define DEC_PYCALLBACK__DCRECTSIZET2_const(CBNAME) \
2358 void CBNAME(wxDC& a, wxRect& b, size_t c) const
2360 #define IMP_PYCALLBACK__DCRECTSIZET2_const(CLASS, PCLASS, CBNAME) \
2361 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2363 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2364 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2365 PyObject* obj = wxPyMake_wxObject(&a,false); \
2366 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2367 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2368 Py_DECREF(obj); Py_DECREF(ro); \
2370 wxPyEndBlockThreads(blocked); \
2372 PCLASS::CBNAME(a,b,c); \
2375 //---------------------------------------------------------------------------
2377 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2378 wxString CBNAME(size_t a) const
2380 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2381 wxString CLASS::CBNAME(size_t a) const { \
2384 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2385 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2387 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2389 rval = Py2wxString(ro); \
2393 wxPyEndBlockThreads(blocked); \
2395 rval = PCLASS::CBNAME(a); \
2399 //---------------------------------------------------------------------------
2401 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2402 wxString CBNAME(size_t a) const
2404 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2405 wxString CLASS::CBNAME(size_t a) const { \
2408 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2409 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2411 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2413 rval = Py2wxString(ro); \
2417 wxPyEndBlockThreads(blocked); \
2421 //---------------------------------------------------------------------------
2423 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2424 wxVisualAttributes CBNAME() const
2427 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2428 wxVisualAttributes CLASS::CBNAME() const { \
2429 wxVisualAttributes rval; \
2431 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2432 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2434 wxVisualAttributes* ptr; \
2435 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2437 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2442 wxPyEndBlockThreads(blocked); \
2444 rval = PCLASS::CBNAME(); \
2448 //---------------------------------------------------------------------------
2450 #define DEC_PYCALLBACK_FONT_INT(CBNAME) \
2451 wxFont CBNAME(int a)
2453 #define IMP_PYCALLBACK_FONT_INT(CLASS, PCLASS, CBNAME) \
2454 wxFont CLASS::CBNAME(int a) { \
2457 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2458 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2461 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2463 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxFont"))) \
2468 wxPyEndBlockThreads(blocked); \
2470 rv = PCLASS::CBNAME(a); \
2474 //---------------------------------------------------------------------------
2476 #define DEC_PYCALLBACK_COLOUR_INT(CBNAME) \
2477 wxColour CBNAME(int a)
2479 #define IMP_PYCALLBACK_COLOUR_INT(CLASS, PCLASS, CBNAME) \
2480 wxColour CLASS::CBNAME(int a) { \
2483 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2484 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2487 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2489 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxColour"))) \
2494 wxPyEndBlockThreads(blocked); \
2496 rv = PCLASS::CBNAME(a); \
2500 //---------------------------------------------------------------------------