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
);
254 bool wxPyCheckForApp();
257 // Other helpful stuff
258 bool wxPy2int_seq_helper(PyObject
* source
, int* i1
, int* i2
);
259 bool wxPy4int_seq_helper(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
261 PyObject
* wxArrayString2PyList_helper(const wxArrayString
& arr
);
262 PyObject
* wxArrayInt2PyList_helper(const wxArrayInt
& arr
);
264 #endif // wxPyUSE_EXPORTED_API
266 //---------------------------------------------------------------------------
268 #if PYTHON_API_VERSION < 1009
269 #define PySequence_Fast_GET_ITEM(o, i) \
270 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
273 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
274 #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name)
275 #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val)
277 //---------------------------------------------------------------------------
279 #ifndef wxPyUSE_EXPORTED_API
281 class wxPyCallback
: public wxObject
{
282 DECLARE_ABSTRACT_CLASS(wxPyCallback
)
284 wxPyCallback(PyObject
* func
);
285 wxPyCallback(const wxPyCallback
& other
);
288 void EventThunker(wxEvent
& event
);
293 #endif // wxPyUSE_EXPORTED_API
294 //---------------------------------------------------------------------------
295 //---------------------------------------------------------------------------
296 // These Event classes can be derived from in Python and passed through the
297 // event system without loosing anything. They do this by keeping a reference
298 // to themselves and some special case handling in wxPyCallback::EventThunker.
302 class wxPyEvtSelfRef
{
307 void SetSelf(PyObject
* self
, bool clone
=false);
308 PyObject
* GetSelf() const;
309 bool GetCloned() const { return m_cloned
; }
317 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
318 DECLARE_ABSTRACT_CLASS(wxPyEvent
)
320 wxPyEvent(int winid
=0, wxEventType commandType
= wxEVT_NULL
);
321 wxPyEvent(const wxPyEvent
& evt
);
324 virtual wxEvent
* Clone() const { return new wxPyEvent(*this); }
328 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
329 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent
)
331 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
332 wxPyCommandEvent(const wxPyCommandEvent
& evt
);
335 virtual wxEvent
* Clone() const { return new wxPyCommandEvent(*this); }
340 //----------------------------------------------------------------------
341 // Forward decalre a few things used in the exported API
342 class wxPyClientData
;
344 class wxPyOORClientData
;
345 class wxPyCBInputStream
;
347 void wxPyClientData_dtor(wxPyClientData
* self
);
348 void wxPyUserData_dtor(wxPyUserData
* self
);
349 void wxPyOORClientData_dtor(wxPyOORClientData
* self
);
350 wxPyCBInputStream
* wxPyCBInputStream_create(PyObject
*py
, bool block
);
351 wxPyCBInputStream
* wxPyCBInputStream_copy(wxPyCBInputStream
* other
);
353 //---------------------------------------------------------------------------
354 // Export a C API in a struct. Other modules will be able to load this from
355 // the wx.core module and will then have safe access to these functions, even if
356 // in another shared library.
358 class wxPyCallbackHelper
;
362 bool (*p_wxPyCheckSwigType
)(const wxChar
* className
);
363 PyObject
* (*p_wxPyConstructObject
)(void* ptr
, const wxChar
* className
, int setThisOwn
);
364 bool (*p_wxPyConvertSwigPtr
)(PyObject
* obj
, void **ptr
, const wxChar
* className
);
365 PyObject
* (*p_wxPyMakeSwigPtr
)(void* ptr
, const wxChar
* className
);
367 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
368 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
369 wxPyBlock_t (*p_wxPyBeginBlockThreads
)();
370 void (*p_wxPyEndBlockThreads
)(wxPyBlock_t blocked
);
372 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
);
374 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
375 wxString (*p_Py2wxString
)(PyObject
* source
);
376 PyObject
* (*p_wx2PyString
)(const wxString
& src
);
378 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
379 int* (*p_int_LIST_helper
)(PyObject
* source
);
380 long* (*p_long_LIST_helper
)(PyObject
* source
);
381 char** (*p_string_LIST_helper
)(PyObject
* source
);
382 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
383 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
384 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
385 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
387 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
388 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
389 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
390 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
391 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
392 bool (*p_wxPoint2D_helper
)(PyObject
* source
, wxPoint2DDouble
** obj
);
395 bool (*p_wxPySimple_typecheck
)(PyObject
* source
, const wxChar
* classname
, int seqLen
);
396 bool (*p_wxColour_typecheck
)(PyObject
* source
);
398 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
399 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
);
400 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
401 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
402 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
404 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
);
405 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
, bool setThisOwn
);
406 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
407 bool (*p_wxPy2int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
);
408 bool (*p_wxPy4int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
409 PyObject
* (*p_wxArrayString2PyList_helper
)(const wxArrayString
& arr
);
410 PyObject
* (*p_wxArrayInt2PyList_helper
)(const wxArrayInt
& arr
);
412 void (*p_wxPyClientData_dtor
)(wxPyClientData
*);
413 void (*p_wxPyUserData_dtor
)(wxPyUserData
*);
414 void (*p_wxPyOORClientData_dtor
)(wxPyOORClientData
*);
416 wxPyCBInputStream
* (*p_wxPyCBInputStream_create
)(PyObject
*py
, bool block
);
417 wxPyCBInputStream
* (*p_wxPyCBInputStream_copy
)(wxPyCBInputStream
* other
);
419 bool (*p_wxPyInstance_Check
)(PyObject
* obj
);
420 bool (*p_wxPySwigInstance_Check
)(PyObject
* obj
);
422 bool (*p_wxPyCheckForApp
)();
426 #ifdef wxPyUSE_EXPORTED_API
427 // Notice that this is static, not extern. This is by design, each module
428 // needs one, but doesn't have to use it.
429 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
;
430 inline wxPyCoreAPI
* wxPyGetCoreAPIPtr();
431 #endif // wxPyUSE_EXPORTED_API
433 //---------------------------------------------------------------------------
435 // A wxObject that holds a reference to a Python object
436 class wxPyUserData
: public wxObject
{
438 wxPyUserData(PyObject
* obj
) {
444 #ifdef wxPyUSE_EXPORTED_API
445 wxPyGetCoreAPIPtr()->p_wxPyUserData_dtor(this);
447 wxPyUserData_dtor(this);
454 // A wxClientData that holds a refernece to a Python object
455 class wxPyClientData
: public wxClientData
{
457 wxPyClientData(PyObject
* obj
, bool incref
=true) {
465 #ifdef wxPyUSE_EXPORTED_API
466 wxPyGetCoreAPIPtr()->p_wxPyClientData_dtor(this);
468 wxPyClientData_dtor(this);
476 // Just like wxPyClientData, except when this object is destroyed it does some
477 // OOR magic on the Python Object.
478 class wxPyOORClientData
: public wxPyClientData
{
480 wxPyOORClientData(PyObject
* obj
, bool incref
=true)
481 : wxPyClientData(obj
, incref
) {}
482 ~wxPyOORClientData() {
484 #ifdef wxPyUSE_EXPORTED_API
485 wxPyGetCoreAPIPtr()->p_wxPyOORClientData_dtor(this);
487 wxPyOORClientData_dtor(this);
493 //---------------------------------------------------------------------------
494 // A wxImageHandler that can be derived from in Python.
497 class wxPyImageHandler
: public wxImageHandler
{
501 // used for interning method names as PyStrings
502 static PyObject
* m_DoCanRead_Name
;
503 static PyObject
* m_GetImageCount_Name
;
504 static PyObject
* m_LoadFile_Name
;
505 static PyObject
* m_SaveFile_Name
;
507 // converstion helpers
508 PyObject
* py_InputStream(wxInputStream
* stream
);
509 PyObject
* py_Image(wxImage
* image
);
510 PyObject
* py_OutputStream(wxOutputStream
* stream
);
515 void _SetSelf(PyObject
*self
);
517 virtual bool LoadFile(wxImage
* image
, wxInputStream
& stream
,
518 bool verbose
=true, int index
=-1 );
519 virtual bool SaveFile(wxImage
* image
, wxOutputStream
& stream
,
521 virtual int GetImageCount(wxInputStream
& stream
);
522 virtual bool DoCanRead(wxInputStream
&stream
);
526 //---------------------------------------------------------------------------
527 // This class holds an instance of a Python Shadow Class object and assists
528 // with looking up and invoking Python callback methods from C++ virtual
529 // method redirections. For all classes which have virtuals which should be
530 // overridable in wxPython, a new subclass is created that contains a
531 // wxPyCallbackHelper.
534 class wxPyCallbackHelper
{
536 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
538 wxPyCallbackHelper() {
545 ~wxPyCallbackHelper() {
546 #ifdef wxPyUSE_EXPORTED_API
547 wxPyGetCoreAPIPtr()->p_wxPyCBH_delete(this);
549 wxPyCBH_delete(this);
553 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=true);
554 bool findCallback(const char* name
, bool setGuard
=true) const;
555 int callCallback(PyObject
* argTuple
) const;
556 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
557 PyObject
* GetLastFound() const { return m_lastFound
; }
559 void setRecursionGuard(PyObject
* method
) const;
560 void clearRecursionGuard(PyObject
* method
) const;
565 PyObject
* m_lastFound
;
568 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
572 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
573 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
=true);
574 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
575 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
576 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
581 //---------------------------------------------------------------------------
583 // This is used in C++ classes that need to be able to make callback to
584 // "overloaded" python methods
587 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
588 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
590 private: wxPyCallbackHelper m_myInst
593 //---------------------------------------------------------------------------
594 // The wxPythonApp class
597 wxPYAPP_ASSERT_SUPPRESS
= 1,
598 wxPYAPP_ASSERT_EXCEPTION
= 2,
599 wxPYAPP_ASSERT_DIALOG
= 4,
600 wxPYAPP_ASSERT_LOG
= 8
603 class wxPyApp
: public wxApp
605 DECLARE_ABSTRACT_CLASS(wxPyApp
)
613 int GetAssertMode() { return m_assertMode
; }
614 void SetAssertMode(int mode
) { m_assertMode
= mode
; }
616 virtual bool OnInitGui();
617 virtual int OnExit();
619 virtual void OnAssertFailure(const wxChar
*file
,
625 virtual void ExitMainLoop();
626 // virtual int FilterEvent(wxEvent& event); // This one too????
628 // For catching Apple Events
629 virtual void MacOpenFile(const wxString
&fileName
);
630 virtual void MacPrintFile(const wxString
&fileName
);
631 virtual void MacNewFile();
632 virtual void MacReopenApp();
634 static bool GetMacSupportPCMenuShortcuts();
635 static long GetMacAboutMenuItemId();
636 static long GetMacPreferencesMenuItemId();
637 static long GetMacExitMenuItemId();
638 static wxString
GetMacHelpMenuTitleName();
640 static void SetMacSupportPCMenuShortcuts(bool val
);
641 static void SetMacAboutMenuItemId(long val
);
642 static void SetMacPreferencesMenuItemId(long val
);
643 static void SetMacExitMenuItemId(long val
);
644 static void SetMacHelpMenuTitleName(const wxString
& val
);
647 void _BootstrapApp();
649 // implementation only
650 void SetStartupComplete(bool val
) { m_startupComplete
= val
; };
654 bool m_startupComplete
;
657 extern wxPyApp
*wxPythonApp
;
660 //----------------------------------------------------------------------
661 // These macros are used to implement the virtual methods that should
662 // redirect to a Python method if one exists. The names designate the
663 // return type, if any, as well as any parameter types.
664 //---------------------------------------------------------------------------
666 #define DEC_PYCALLBACK__(CBNAME) \
670 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
671 void CLASS::CBNAME() { \
673 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
674 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
675 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
676 wxPyEndBlockThreads(blocked); \
681 #define DEC_PYCALLBACK_VOID_(CBNAME) \
682 DEC_PYCALLBACK__(CBNAME)
684 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
685 IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME)
687 //---------------------------------------------------------------------------
689 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
690 bool CBNAME(int a, int b)
693 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
694 bool CLASS::CBNAME(int a, int b) { \
695 bool rval=false, found; \
696 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
697 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
698 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
699 wxPyEndBlockThreads(blocked); \
701 rval = PCLASS::CBNAME(a,b); \
705 //---------------------------------------------------------------------------
707 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
708 void CBNAME(int a, int b)
711 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
712 void CLASS::CBNAME(int a, int b) { \
714 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
715 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
716 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
717 wxPyEndBlockThreads(blocked); \
719 PCLASS::CBNAME(a,b); \
722 //---------------------------------------------------------------------------
724 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
728 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
729 void CLASS::CBNAME(int a) { \
731 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
732 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
733 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
734 wxPyEndBlockThreads(blocked); \
739 //---------------------------------------------------------------------------
741 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
742 void CBNAME(int a, int b, int c, int d)
745 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
746 void CLASS::CBNAME(int a, int b, int c, int d) { \
748 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
749 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
750 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
751 wxPyEndBlockThreads(blocked); \
753 PCLASS::CBNAME(a,b,c,d); \
756 //---------------------------------------------------------------------------
757 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
758 void CBNAME(int a, int b, int c, int d, int e)
761 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
762 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
764 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
765 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
766 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
767 wxPyEndBlockThreads(blocked); \
769 PCLASS::CBNAME(a,b,c,d,e); \
772 //---------------------------------------------------------------------------
774 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
775 void CBNAME(int* a, int* b) const
778 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
779 void CLASS::CBNAME(int* a, int* b) const { \
780 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
782 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
783 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
785 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
787 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
788 PyObject* o1 = PySequence_GetItem(ro, 0); \
789 PyObject* o2 = PySequence_GetItem(ro, 1); \
790 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
791 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
794 PyErr_SetString(PyExc_TypeError, errmsg); \
799 PyErr_SetString(PyExc_TypeError, errmsg); \
804 wxPyEndBlockThreads(blocked); \
806 PCLASS::CBNAME(a,b); \
809 //---------------------------------------------------------------------------
811 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
812 wxSize CBNAME() const
815 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
816 wxSize CLASS::CBNAME() const { \
817 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
818 bool found; wxSize rval(0,0); \
819 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
820 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
822 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
824 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
825 PyObject* o1 = PySequence_GetItem(ro, 0); \
826 PyObject* o2 = PySequence_GetItem(ro, 1); \
827 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
828 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
831 PyErr_SetString(PyExc_TypeError, errmsg); \
836 PyErr_SetString(PyExc_TypeError, errmsg); \
841 wxPyEndBlockThreads(blocked); \
843 return PCLASS::CBNAME(); \
848 //---------------------------------------------------------------------------
850 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
854 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
855 bool CLASS::CBNAME(bool a) { \
856 bool rval=false, found; \
857 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
858 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
859 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
860 wxPyEndBlockThreads(blocked); \
862 rval = PCLASS::CBNAME(a); \
866 //---------------------------------------------------------------------------
868 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
872 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
873 bool CLASS::CBNAME(int a) { \
874 bool rval=false, found; \
875 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
876 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
877 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
878 wxPyEndBlockThreads(blocked); \
880 rval = PCLASS::CBNAME(a); \
884 //---------------------------------------------------------------------------
886 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
890 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
891 bool CLASS::CBNAME(int a) { \
893 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
894 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
895 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
897 wxPyEndBlockThreads(blocked); \
902 //---------------------------------------------------------------------------
904 #define DEC_PYCALLBACK__DC(CBNAME) \
908 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
909 void CLASS::CBNAME(wxDC& a) { \
911 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
912 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
913 PyObject* obj = wxPyMake_wxObject(&a,false); \
914 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
917 wxPyEndBlockThreads(blocked); \
923 //---------------------------------------------------------------------------
925 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
926 void CBNAME(wxDC& a, bool b)
929 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
930 void CLASS::CBNAME(wxDC& a, bool b) { \
932 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
933 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
934 PyObject* obj = wxPyMake_wxObject(&a,false); \
935 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
938 wxPyEndBlockThreads(blocked); \
940 PCLASS::CBNAME(a, b); \
943 //---------------------------------------------------------------------------
945 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
946 void CBNAME(wxDC& a, bool b)
949 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
950 void CLASS::CBNAME(wxDC& a, bool b) { \
952 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
953 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
954 PyObject* obj = wxPyMake_wxObject(&a,false); \
955 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
958 wxPyEndBlockThreads(blocked); \
960 PCLASS::CBNAME(a, b); \
963 //---------------------------------------------------------------------------
965 #define DEC_PYCALLBACK__2DBL(CBNAME) \
966 void CBNAME(double a, double b)
969 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
970 void CLASS::CBNAME(double a, double b) { \
972 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
973 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
974 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
975 wxPyEndBlockThreads(blocked); \
977 PCLASS::CBNAME(a, b); \
980 //---------------------------------------------------------------------------
982 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
983 void CBNAME(double a, double b, int c, int d)
986 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
987 void CLASS::CBNAME(double a, double b, int c, int d) { \
989 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
990 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
991 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
993 wxPyEndBlockThreads(blocked); \
995 PCLASS::CBNAME(a, b, c, d); \
998 //---------------------------------------------------------------------------
1000 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
1001 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1004 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1005 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1007 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1008 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1009 PyObject* obj = wxPyMake_wxObject(&a,false); \
1010 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
1013 wxPyEndBlockThreads(blocked); \
1015 PCLASS::CBNAME(a, b, c, d, e, f); \
1018 //---------------------------------------------------------------------------
1020 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
1021 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1024 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1025 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1027 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1029 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1030 PyObject* obj = wxPyMake_wxObject(&a,false); \
1031 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1034 wxPyEndBlockThreads(blocked); \
1036 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1040 //---------------------------------------------------------------------------
1042 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1043 void CBNAME(bool a, double b, double c, int d, int e)
1046 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1047 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1049 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1050 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1051 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1053 wxPyEndBlockThreads(blocked); \
1055 PCLASS::CBNAME(a, b, c, d, e); \
1058 //---------------------------------------------------------------------------
1060 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1061 void CBNAME(wxDC& a, double b, double c, double d, double e)
1064 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1065 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1067 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1068 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1069 PyObject* obj = wxPyMake_wxObject(&a,false); \
1070 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1073 wxPyEndBlockThreads(blocked); \
1075 PCLASS::CBNAME(a, b, c, d, e); \
1078 //---------------------------------------------------------------------------
1080 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1081 void CBNAME(wxDC& a, bool b)
1084 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1085 void CLASS::CBNAME(wxDC& a, bool b) { \
1087 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1088 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1089 PyObject* obj = wxPyMake_wxObject(&a,false); \
1090 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1093 wxPyEndBlockThreads(blocked); \
1095 PCLASS::CBNAME(a, b); \
1098 //---------------------------------------------------------------------------
1100 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1101 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1104 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1105 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1108 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1109 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1110 PyObject* obj = wxPyMake_wxObject(a,false); \
1111 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1114 wxPyEndBlockThreads(blocked); \
1116 PCLASS::CBNAME(a, b, c, d, e, f); \
1119 //---------------------------------------------------------------------------
1121 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1122 void CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1125 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1126 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1128 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1129 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1130 PyObject* obj = wxPyMake_wxObject(a,false); \
1131 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1134 wxPyEndBlockThreads(blocked); \
1136 PCLASS::CBNAME(a, b, c, d, e); \
1139 //---------------------------------------------------------------------------
1141 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1142 void CBNAME(double a, double b, int c)
1145 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1146 void CLASS::CBNAME(double a, double b, int c) { \
1148 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1149 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1150 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1151 wxPyEndBlockThreads(blocked); \
1153 PCLASS::CBNAME(a, b, c); \
1156 //---------------------------------------------------------------------------
1158 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1159 void CBNAME(bool a, double b, double c, int d)
1162 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1163 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1165 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1166 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1167 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1168 wxPyEndBlockThreads(blocked); \
1170 PCLASS::CBNAME(a, b, c, d); \
1173 //---------------------------------------------------------------------------
1174 //---------------------------------------------------------------------------
1176 #define DEC_PYCALLBACK__STRING(CBNAME) \
1177 void CBNAME(const wxString& a)
1179 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1180 void CLASS::CBNAME(const wxString& a) { \
1182 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1183 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1184 PyObject* s = wx2PyString(a); \
1185 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1188 wxPyEndBlockThreads(blocked); \
1190 PCLASS::CBNAME(a); \
1193 //---------------------------------------------------------------------------
1195 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1196 bool CBNAME(const wxString& a)
1198 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1199 bool CLASS::CBNAME(const wxString& a) { \
1202 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1203 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1204 PyObject* s = wx2PyString(a); \
1205 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1208 wxPyEndBlockThreads(blocked); \
1210 rval = PCLASS::CBNAME(a); \
1214 //---------------------------------------------------------------------------
1216 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1217 bool CBNAME(const wxString& a)
1219 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1220 bool CLASS::CBNAME(const wxString& a) { \
1222 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1223 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1224 PyObject* s = wx2PyString(a); \
1225 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1228 wxPyEndBlockThreads(blocked); \
1232 //---------------------------------------------------------------------------
1234 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1235 wxString CBNAME(const wxString& a)
1237 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1238 wxString CLASS::CBNAME(const wxString& a) { \
1240 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1241 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1243 PyObject* s = wx2PyString(a); \
1244 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1247 rval = Py2wxString(ro); \
1251 wxPyEndBlockThreads(blocked); \
1255 //---------------------------------------------------------------------------
1257 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1258 wxString CBNAME(const wxString& a)
1260 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1261 wxString CLASS::CBNAME(const wxString& a) { \
1264 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1265 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1267 PyObject* s = wx2PyString(a); \
1268 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1271 rval = Py2wxString(ro); \
1276 rval = PCLASS::CBNAME(a); \
1277 wxPyEndBlockThreads(blocked); \
1281 //---------------------------------------------------------------------------
1283 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1284 wxString CBNAME(const wxString& a,int b)
1286 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1287 wxString CLASS::CBNAME(const wxString& a,int b) { \
1289 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1290 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1292 PyObject* s = wx2PyString(a); \
1293 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1296 rval = Py2wxString(ro); \
1300 wxPyEndBlockThreads(blocked); \
1304 //---------------------------------------------------------------------------
1306 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1307 bool CBNAME(const wxString& a, const wxString& b)
1309 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1310 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1313 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1314 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1315 PyObject* s1 = wx2PyString(a); \
1316 PyObject* s2 = wx2PyString(b); \
1317 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1321 wxPyEndBlockThreads(blocked); \
1323 rval = PCLASS::CBNAME(a, b); \
1327 //---------------------------------------------------------------------------
1329 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1332 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1333 wxString CLASS::CBNAME() { \
1336 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1337 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1339 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1341 rval = Py2wxString(ro); \
1345 wxPyEndBlockThreads(blocked); \
1347 rval = PCLASS::CBNAME(); \
1351 //---------------------------------------------------------------------------
1353 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1354 wxString CBNAME() const
1356 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1357 wxString CLASS::CBNAME() const { \
1360 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1361 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1363 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1365 rval = Py2wxString(ro); \
1369 wxPyEndBlockThreads(blocked); \
1371 rval = PCLASS::CBNAME(); \
1375 //---------------------------------------------------------------------------
1377 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1380 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1381 wxString CLASS::CBNAME() { \
1383 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1384 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1386 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1388 rval = Py2wxString(ro); \
1392 wxPyEndBlockThreads(blocked); \
1396 //---------------------------------------------------------------------------
1398 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1399 wxString CBNAME() const;
1401 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1402 wxString CLASS::CBNAME() const { \
1404 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1405 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1407 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1409 rval = Py2wxString(ro); \
1413 wxPyEndBlockThreads(blocked); \
1417 //---------------------------------------------------------------------------
1419 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1420 bool CBNAME(const wxHtmlTag& a)
1423 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1424 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1426 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1427 if (wxPyCBH_findCallback2(m_myInst, #CBNAME, false)) { \
1428 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
1429 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1432 wxPyEndBlockThreads(blocked); \
1436 //---------------------------------------------------------------------------
1438 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1439 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1441 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1442 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1444 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1445 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1446 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1447 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1450 wxPyEndBlockThreads(blocked); \
1452 PCLASS::CBNAME(cell, x, y); \
1455 //---------------------------------------------------------------------------
1457 #define DEC_PYCALLBACK__COLOUR(CBNAME) \
1458 void CBNAME(const wxColour& c);
1460 #define IMP_PYCALLBACK__COLOUR(CLASS, PCLASS, CBNAME) \
1461 void CLASS::CBNAME(const wxColour& c) { \
1463 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1464 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1465 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1466 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1469 wxPyEndBlockThreads(blocked); \
1471 PCLASS::CBNAME(c); \
1474 //---------------------------------------------------------------------------
1475 #define DEC_PYCALLBACK__INTCOLOUR(CBNAME) \
1476 void CBNAME(int a, const wxColour& c);
1478 #define IMP_PYCALLBACK__INTCOLOUR(CLASS, PCLASS, CBNAME) \
1479 void CLASS::CBNAME(int a, const wxColour& c) { \
1481 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1482 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1483 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1484 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)",a, obj)); \
1487 wxPyEndBlockThreads(blocked); \
1489 PCLASS::CBNAME(a, c); \
1492 //---------------------------------------------------------------------------
1494 #define DEC_PYCALLBACK__INTFONT(CBNAME) \
1495 void CBNAME(int a, const wxFont& c);
1497 #define IMP_PYCALLBACK__INTFONT(CLASS, PCLASS, CBNAME) \
1498 void CLASS::CBNAME(int a, const wxFont& c) { \
1500 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1501 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1502 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxFont"), 0); \
1503 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)",a, obj)); \
1506 wxPyEndBlockThreads(blocked); \
1508 PCLASS::CBNAME(a, c); \
1511 //---------------------------------------------------------------------------
1513 #define DEC_PYCALLBACK_BOOL_CELLINTINTME(CBNAME) \
1514 bool CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1516 #define IMP_PYCALLBACK_BOOL_CELLINTINTME(CLASS, PCLASS, CBNAME) \
1517 bool CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1518 bool rval=false, found; \
1519 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1520 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1521 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1522 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1523 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1527 wxPyEndBlockThreads(blocked); \
1529 rval = PCLASS::CBNAME(cell, x, y, e); \
1534 //---------------------------------------------------------------------------
1536 #define DEC_PYCALLBACK___pure(CBNAME) \
1540 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1541 void CLASS::CBNAME() { \
1542 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1543 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1544 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1545 wxPyEndBlockThreads(blocked); \
1548 //---------------------------------------------------------------------------
1550 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1554 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1555 wxSize CLASS::CBNAME() { \
1556 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1558 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1559 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1562 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1564 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1566 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1568 PyObject* o1 = PySequence_GetItem(ro, 0); \
1569 PyObject* o2 = PySequence_GetItem(ro, 1); \
1570 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1571 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1573 PyErr_SetString(PyExc_TypeError, errmsg); \
1578 PyErr_SetString(PyExc_TypeError, errmsg); \
1583 wxPyEndBlockThreads(blocked); \
1587 //---------------------------------------------------------------------------
1589 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1590 bool CBNAME(wxWindow* a)
1593 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1594 bool CLASS::CBNAME(wxWindow* a) { \
1597 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1598 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1599 PyObject* obj = wxPyMake_wxObject(a,false); \
1600 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1603 wxPyEndBlockThreads(blocked); \
1605 rval = PCLASS::CBNAME(a); \
1609 //---------------------------------------------------------------------------
1611 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1612 bool CBNAME(wxWindow* a, wxDC& b)
1615 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1616 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1619 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1620 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1621 PyObject* win = wxPyMake_wxObject(a,false); \
1622 PyObject* dc = wxPyMake_wxObject(&b,false); \
1623 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1627 wxPyEndBlockThreads(blocked); \
1629 rval = PCLASS::CBNAME(a, b); \
1633 //---------------------------------------------------------------------------
1635 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1636 void CBNAME(wxWindowBase* a)
1639 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1640 void CLASS::CBNAME(wxWindowBase* a) { \
1642 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1643 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1644 PyObject* obj = wxPyMake_wxObject(a,false); \
1645 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1648 wxPyEndBlockThreads(blocked); \
1650 PCLASS::CBNAME(a); \
1653 //---------------------------------------------------------------------------
1655 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1659 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1660 bool CLASS::CBNAME() { \
1663 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1664 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1665 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1666 wxPyEndBlockThreads(blocked); \
1668 rval = PCLASS::CBNAME(); \
1672 //---------------------------------------------------------------------------
1674 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1678 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1679 bool CLASS::CBNAME() const { \
1682 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1683 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1684 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1685 wxPyEndBlockThreads(blocked); \
1687 rval = PCLASS::CBNAME(); \
1691 //---------------------------------------------------------------------------
1693 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1694 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1697 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1698 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1701 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1702 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1703 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1704 wxPyEndBlockThreads(blocked); \
1706 rval = PCLASS::CBNAME(a, b, c); \
1707 return (wxDragResult)rval; \
1710 //---------------------------------------------------------------------------
1712 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1713 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1715 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1716 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1717 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1719 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1721 PyObject* obj = wxPyMake_wxObject(&a,false); \
1722 PyObject* s = wx2PyString(b); \
1723 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1726 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
1727 /* release ownership of the C++ wx.FSFile object. */ \
1728 PyObject_SetAttrString(ro, "thisown", Py_False); \
1734 wxPyEndBlockThreads(blocked); \
1738 //---------------------------------------------------------------------------
1740 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1741 bool CBNAME(wxDragResult a)
1744 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1745 bool CLASS::CBNAME(wxDragResult a) { \
1748 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1749 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1750 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1751 wxPyEndBlockThreads(blocked); \
1753 rval = PCLASS::CBNAME(a); \
1757 //---------------------------------------------------------------------------
1759 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1760 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1763 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1764 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1765 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1767 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1768 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1769 wxPyEndBlockThreads(blocked); \
1770 return (wxDragResult)rval; \
1773 //---------------------------------------------------------------------------
1775 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1776 bool CBNAME(int a, int b, const wxString& c)
1778 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1779 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1781 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1782 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1783 PyObject* s = wx2PyString(c); \
1784 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1787 wxPyEndBlockThreads(blocked); \
1791 //---------------------------------------------------------------------------
1793 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1797 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1798 size_t CLASS::CBNAME() { \
1801 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1802 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1803 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1804 wxPyEndBlockThreads(blocked); \
1806 rval = PCLASS::CBNAME(); \
1810 //---------------------------------------------------------------------------
1812 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1813 size_t CBNAME() const
1816 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1817 size_t CLASS::CBNAME() const { \
1820 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1821 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1822 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1823 wxPyEndBlockThreads(blocked); \
1825 rval = PCLASS::CBNAME(); \
1829 //---------------------------------------------------------------------------
1831 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1832 wxDataFormat CBNAME(size_t a)
1835 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1836 wxDataFormat CLASS::CBNAME(size_t a) { \
1837 wxDataFormat rval=0; \
1839 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1840 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1842 wxDataFormat* ptr; \
1843 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1845 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1850 wxPyEndBlockThreads(blocked); \
1852 rval = PCLASS::CBNAME(a); \
1856 //---------------------------------------------------------------------------
1858 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1859 void CBNAME(const Type& a)
1862 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1863 void CLASS::CBNAME(const Type& a) { \
1865 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1866 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1867 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1868 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1871 wxPyEndBlockThreads(blocked); \
1873 PCLASS::CBNAME(a); \
1877 //---------------------------------------------------------------------------
1879 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1880 void CBNAME(Type& a)
1883 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1884 void CLASS::CBNAME(Type& a) { \
1886 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1887 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1888 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1889 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1892 wxPyEndBlockThreads(blocked); \
1894 PCLASS::CBNAME(a); \
1897 //---------------------------------------------------------------------------
1899 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1900 bool CBNAME(Type& a)
1903 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1904 bool CLASS::CBNAME(Type& a) { \
1907 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1908 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1909 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1910 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1913 wxPyEndBlockThreads(blocked); \
1915 rv = PCLASS::CBNAME(a); \
1919 //---------------------------------------------------------------------------
1921 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
1922 bool CBNAME(Type& a)
1925 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
1926 bool CLASS::CBNAME(Type& a) { \
1928 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1929 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1930 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1931 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1934 wxPyEndBlockThreads(blocked); \
1938 //---------------------------------------------------------------------------
1940 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1941 wxString CBNAME(long a, long b) const
1943 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1944 wxString CLASS::CBNAME(long a, long b) const { \
1947 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1948 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1950 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1952 rval = Py2wxString(ro); \
1956 wxPyEndBlockThreads(blocked); \
1958 rval = PCLASS::CBNAME(a,b); \
1962 //---------------------------------------------------------------------------
1964 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1965 int CBNAME(long a) const
1968 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1969 int CLASS::CBNAME(long a) const { \
1972 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1973 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1975 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
1977 rval = PyInt_AsLong(ro); \
1981 wxPyEndBlockThreads(blocked); \
1983 rval = PCLASS::CBNAME(a); \
1988 #define DEC_PYCALLBACK_INT_LONG_virtual(CBNAME) \
1989 int CBNAME(long a) const;
1992 #define IMP_PYCALLBACK_INT_LONG_virtual(CLASS, PCLASS, CBNAME) \
1993 int CLASS::CBNAME(long a) const { \
1994 int rval=-1; /* this rval is important for OnGetItemImage */ \
1996 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1997 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1999 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2001 rval = PyInt_AsLong(ro); \
2005 wxPyEndBlockThreads(blocked); \
2010 //---------------------------------------------------------------------------
2012 #define DEC_PYCALLBACK_INT_INT(CBNAME) \
2016 #define IMP_PYCALLBACK_INT_INT(CLASS, PCLASS, CBNAME) \
2017 int CLASS::CBNAME(int a) { \
2020 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2021 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2023 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a)); \
2025 rval = PyInt_AsLong(ro); \
2029 wxPyEndBlockThreads(blocked); \
2031 rval = PCLASS::CBNAME(a); \
2035 //---------------------------------------------------------------------------
2037 #define DEC_PYCALLBACK_INT_LONGLONG(CBNAME) \
2038 int CBNAME(long a, long b) const
2041 #define IMP_PYCALLBACK_INT_LONGLONG(CLASS, PCLASS, CBNAME) \
2042 int CLASS::CBNAME(long a, long b) const { \
2045 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2046 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2048 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2050 rval = PyInt_AsLong(ro); \
2054 wxPyEndBlockThreads(blocked); \
2056 rval = PCLASS::CBNAME(a, b); \
2061 #define DEC_PYCALLBACK_INT_LONGLONG_virtual(CBNAME) \
2062 int CBNAME(long a, long b) const;
2065 #define IMP_PYCALLBACK_INT_LONGLONG_virtual(CLASS, PCLASS, CBNAME) \
2066 int CLASS::CBNAME(long a, long b) const { \
2067 int rval=-1; /* this rval is important for OnGetItemImage */ \
2069 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2070 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2072 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2074 rval = PyInt_AsLong(ro); \
2078 wxPyEndBlockThreads(blocked); \
2083 //---------------------------------------------------------------------------
2085 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2086 wxListItemAttr* CBNAME(long a) const
2089 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2090 wxListItemAttr *CLASS::CBNAME(long a) const { \
2091 wxListItemAttr *rval = NULL; \
2093 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2094 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2096 wxListItemAttr* ptr; \
2097 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2099 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2104 wxPyEndBlockThreads(blocked); \
2106 rval = PCLASS::CBNAME(a); \
2110 //---------------------------------------------------------------------------
2112 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2113 bool CBNAME(wxMouseEvent& e)
2115 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2116 bool CLASS::CBNAME(wxMouseEvent& e) { \
2119 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2120 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2122 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2123 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2125 rval = PyInt_AsLong(ro); \
2130 wxPyEndBlockThreads(blocked); \
2132 return PCLASS::CBNAME(e); \
2136 //---------------------------------------------------------------------------
2138 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2139 wxWizardPage* CBNAME() const
2141 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2142 wxWizardPage* CLASS::CBNAME() const { \
2143 wxWizardPage* rv = NULL; \
2144 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2145 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2147 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2149 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2153 wxPyEndBlockThreads(blocked); \
2157 //---------------------------------------------------------------------------
2159 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2160 wxBitmap CBNAME() const
2162 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2163 wxBitmap CLASS::CBNAME() const { \
2165 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2166 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2169 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2171 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2176 wxPyEndBlockThreads(blocked); \
2180 //---------------------------------------------------------------------------
2182 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2185 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2186 wxObject* CLASS::CBNAME() { \
2187 wxObject* rv = NULL; \
2188 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2189 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2191 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2193 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2197 wxPyEndBlockThreads(blocked); \
2201 //---------------------------------------------------------------------------
2203 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2204 wxObject* CBNAME(const wxString& a)
2206 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2207 wxObject* CLASS::CBNAME(const wxString& a) { \
2208 wxObject* rv = NULL; \
2209 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2210 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2211 PyObject* so = wx2PyString(a); \
2213 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2215 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2220 wxPyEndBlockThreads(blocked); \
2224 //---------------------------------------------------------------------------
2226 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2227 bool CBNAME(wxXmlNode* a)
2230 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2231 bool CLASS::CBNAME(wxXmlNode* a) { \
2233 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2234 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2235 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2236 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2239 wxPyEndBlockThreads(blocked); \
2243 //---------------------------------------------------------------------------
2245 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2246 wxCoord CBNAME(size_t a) const
2249 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2250 wxCoord CLASS::CBNAME(size_t a) const { \
2253 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2254 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2255 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2257 wxPyEndBlockThreads(blocked); \
2261 //---------------------------------------------------------------------------
2263 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2264 void CBNAME(size_t a, size_t b) const
2267 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2268 void CLASS::CBNAME(size_t a, size_t b) const { \
2270 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2271 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2272 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2273 wxPyEndBlockThreads(blocked); \
2275 PCLASS::CBNAME(a,b); \
2277 //---------------------------------------------------------------------------
2279 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2280 wxCoord CBNAME() const
2283 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2284 wxCoord CLASS::CBNAME() const { \
2287 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2288 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2289 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2290 wxPyEndBlockThreads(blocked); \
2292 rval = PCLASS::CBNAME(); \
2296 //---------------------------------------------------------------------------
2298 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2299 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2301 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2302 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2304 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2305 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2306 PyObject* obj = wxPyMake_wxObject(&a,false); \
2307 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2308 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2309 Py_DECREF(obj); Py_DECREF(ro); \
2311 wxPyEndBlockThreads(blocked); \
2316 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2317 void CBNAME(wxDC& a, const wxRect& b, size_t c) const
2319 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2320 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2322 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2323 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2324 PyObject* obj = wxPyMake_wxObject(&a,false); \
2325 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2326 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2327 Py_DECREF(obj); Py_DECREF(ro); \
2329 wxPyEndBlockThreads(blocked); \
2331 PCLASS::CBNAME(a,b,c); \
2335 //---------------------------------------------------------------------------
2336 // Same as the above set, but the wxRect is not const
2338 #define DEC_PYCALLBACK__DCRECTSIZET2_constpure(CBNAME) \
2339 void CBNAME(wxDC& a, wxRect& b, size_t c) const;
2341 #define IMP_PYCALLBACK__DCRECTSIZET2_constpure(CLASS, PCLASS, CBNAME) \
2342 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2344 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2345 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2346 PyObject* obj = wxPyMake_wxObject(&a,false); \
2347 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2348 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2349 Py_DECREF(obj); Py_DECREF(ro); \
2351 wxPyEndBlockThreads(blocked); \
2356 #define DEC_PYCALLBACK__DCRECTSIZET2_const(CBNAME) \
2357 void CBNAME(wxDC& a, wxRect& b, size_t c) const
2359 #define IMP_PYCALLBACK__DCRECTSIZET2_const(CLASS, PCLASS, CBNAME) \
2360 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2362 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2363 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2364 PyObject* obj = wxPyMake_wxObject(&a,false); \
2365 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2366 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2367 Py_DECREF(obj); Py_DECREF(ro); \
2369 wxPyEndBlockThreads(blocked); \
2371 PCLASS::CBNAME(a,b,c); \
2374 //---------------------------------------------------------------------------
2376 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2377 wxString CBNAME(size_t a) const
2379 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2380 wxString CLASS::CBNAME(size_t a) const { \
2383 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2384 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2386 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2388 rval = Py2wxString(ro); \
2392 wxPyEndBlockThreads(blocked); \
2394 rval = PCLASS::CBNAME(a); \
2398 //---------------------------------------------------------------------------
2400 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2401 wxString CBNAME(size_t a) const
2403 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2404 wxString CLASS::CBNAME(size_t a) const { \
2407 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2408 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2410 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2412 rval = Py2wxString(ro); \
2416 wxPyEndBlockThreads(blocked); \
2420 //---------------------------------------------------------------------------
2422 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2423 wxVisualAttributes CBNAME() const
2426 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2427 wxVisualAttributes CLASS::CBNAME() const { \
2428 wxVisualAttributes rval; \
2430 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2431 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2433 wxVisualAttributes* ptr; \
2434 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2436 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2441 wxPyEndBlockThreads(blocked); \
2443 rval = PCLASS::CBNAME(); \
2447 //---------------------------------------------------------------------------
2449 #define DEC_PYCALLBACK_FONT_INT(CBNAME) \
2450 wxFont CBNAME(int a)
2452 #define IMP_PYCALLBACK_FONT_INT(CLASS, PCLASS, CBNAME) \
2453 wxFont CLASS::CBNAME(int a) { \
2456 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2457 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2460 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2462 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxFont"))) \
2467 wxPyEndBlockThreads(blocked); \
2469 rv = PCLASS::CBNAME(a); \
2473 //---------------------------------------------------------------------------
2475 #define DEC_PYCALLBACK_COLOUR_INT(CBNAME) \
2476 wxColour CBNAME(int a)
2478 #define IMP_PYCALLBACK_COLOUR_INT(CLASS, PCLASS, CBNAME) \
2479 wxColour CLASS::CBNAME(int a) { \
2482 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2483 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2486 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2488 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxColour"))) \
2493 wxPyEndBlockThreads(blocked); \
2495 rv = PCLASS::CBNAME(a); \
2499 //---------------------------------------------------------------------------