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/clipbrd.h>
24 #include <wx/colordlg.h>
25 #include <wx/config.h>
26 #include <wx/cshelp.h>
27 #include <wx/dcbuffer.h>
28 #include <wx/dcmirror.h>
30 #include <wx/dirctrl.h>
31 #include <wx/dirdlg.h>
33 #include <wx/docview.h>
34 #include <wx/encconv.h>
35 #include <wx/fdrepdlg.h>
36 #include <wx/fileconf.h>
37 #include <wx/filesys.h>
38 #include <wx/fontdlg.h>
39 #include <wx/fs_inet.h>
40 #include <wx/fs_mem.h>
41 #include <wx/fs_zip.h>
42 #include <wx/gbsizer.h>
43 #include <wx/geometry.h>
44 #include <wx/htmllbox.h>
46 #include <wx/imaglist.h>
48 #include <wx/laywin.h>
49 #include <wx/listbook.h>
50 #include <wx/minifram.h>
51 #include <wx/notebook.h>
53 #include <wx/printdlg.h>
54 #include <wx/process.h>
55 #include <wx/progdlg.h>
56 #include <wx/sashwin.h>
57 #include <wx/spinbutt.h>
58 #include <wx/spinctrl.h>
59 #include <wx/splash.h>
60 #include <wx/splitter.h>
61 #include <wx/statline.h>
62 #include <wx/stream.h>
63 #include <wx/sysopt.h>
64 #include <wx/taskbar.h>
65 #include <wx/tglbtn.h>
66 #include <wx/tipwin.h>
67 #include <wx/tooltip.h>
69 #include <wx/vscroll.h>
73 # pragma warning(disable:4800)
74 # pragma warning(disable:4190)
77 #ifdef __WXMAC__ // avoid a bug in Carbon headers
81 //---------------------------------------------------------------------------
83 typedef unsigned char byte
;
84 typedef wxPoint2DDouble wxPoint2D
;
86 const bool True
= true;
87 const bool False
= false;
90 #ifndef wxPyUSE_EXPORTED_API
92 void __wxPyPreStart(PyObject
*);
94 PyObject
* __wxPySetDictionary(PyObject
*, PyObject
* args
);
95 PyObject
* __wxPyFixStockObjects(PyObject
*, PyObject
* args
);
98 void wxPyEventThunker(wxObject
*, wxEvent
& event
);
101 bool wxPyCheckSwigType(const wxChar
* className
);
102 PyObject
* wxPyConstructObject(void* ptr
,
103 const wxChar
* className
,
105 bool wxPyConvertSwigPtr(PyObject
* obj
, void **ptr
,
106 const wxChar
* className
);
107 PyObject
* wxPyMakeSwigPtr(void* ptr
, const wxChar
* classname
);
110 PyObject
* wx2PyString(const wxString
& src
);
111 wxString
Py2wxString(PyObject
* source
);
113 PyObject
* wxPyMake_wxObject(wxObject
* source
, bool checkEvtHandler
=True
);
114 PyObject
* wxPyMake_wxSizer(wxSizer
* source
);
115 void wxPyPtrTypeMap_Add(const char* commonName
, const char* ptrName
);
117 PyObject
* wxPy_ConvertList(wxListBase
* list
);
118 long wxPyGetWinHandle(wxWindow
* win
);
120 void wxPy_ReinitStockObjects(int pass
);
122 bool wxPyInstance_Check(PyObject
* obj
);
123 bool wxPySwigInstance_Check(PyObject
* obj
);
126 #endif // wxPyUSE_EXPORTED_API
127 //---------------------------------------------------------------------------
129 // if we want to handle threads and Python threads are available...
130 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
131 #define WXP_WITH_THREAD
132 #else // no Python threads...
133 #undef WXP_WITH_THREAD
136 #ifndef wxPyUSE_EXPORTED_API
138 // For Python --> C++
139 PyThreadState
* wxPyBeginAllowThreads();
140 void wxPyEndAllowThreads(PyThreadState
* state
);
142 // For C++ --> Python
143 void wxPyBeginBlockThreads();
144 void wxPyEndBlockThreads();
146 #endif // wxPyUSE_EXPORTED_API
148 #define wxPyBLOCK_THREADS(stmt) { wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads(); }
149 #define wxPyRaiseNotImplemented() wxPyBLOCK_THREADS(PyErr_SetNone(PyExc_NotImplementedError))
151 //---------------------------------------------------------------------------
152 // These are helpers used by the typemaps
154 #ifndef wxPyUSE_EXPORTED_API
156 wxString
* wxString_in_helper(PyObject
* source
);
158 byte
* byte_LIST_helper(PyObject
* source
);
159 int* int_LIST_helper(PyObject
* source
);
160 long* long_LIST_helper(PyObject
* source
);
161 char** string_LIST_helper(PyObject
* source
);
162 wxPoint
* wxPoint_LIST_helper(PyObject
* source
, int* npoints
);
163 wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
164 wxString
* wxString_LIST_helper(PyObject
* source
);
165 wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
166 wxPen
** wxPen_LIST_helper(PyObject
* source
);
168 bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
169 bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
170 bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
171 bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
172 bool wxColour_helper(PyObject
* source
, wxColour
** obj
);
173 bool wxPoint2D_helper(PyObject
* source
, wxPoint2D
** obj
);
176 bool wxPySimple_typecheck(PyObject
* source
, const wxChar
* classname
, int seqLen
);
177 bool wxColour_typecheck(PyObject
* source
);
181 bool wxPyTwoIntItem_helper(PyObject
* source
, T
** obj
, const wxChar
* name
)
183 // If source is an object instance then it may already be the right type
184 if (wxPySwigInstance_Check(source
)) {
186 if (! wxPyConvertSwigPtr(source
, (void **)&ptr
, name
))
191 // otherwise a 2-tuple of integers is expected
192 else if (PySequence_Check(source
) && PyObject_Length(source
) == 2) {
193 PyObject
* o1
= PySequence_GetItem(source
, 0);
194 PyObject
* o2
= PySequence_GetItem(source
, 1);
195 if (!PyNumber_Check(o1
) || !PyNumber_Check(o2
)) {
200 **obj
= T(PyInt_AsLong(o1
), PyInt_AsLong(o2
));
208 msg
.Printf(wxT("Expected a 2-tuple of integers or a %s object."), name
);
209 PyErr_SetString(PyExc_TypeError
, msg
.mb_str());
215 // Other helpful stuff
216 bool wxPy2int_seq_helper(PyObject
* source
, int* i1
, int* i2
);
217 bool wxPy4int_seq_helper(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
219 PyObject
* wxArrayString2PyList_helper(const wxArrayString
& arr
);
220 PyObject
* wxArrayInt2PyList_helper(const wxArrayInt
& arr
);
222 #endif // wxPyUSE_EXPORTED_API
224 //---------------------------------------------------------------------------
226 #if PYTHON_API_VERSION < 1009
227 #define PySequence_Fast_GET_ITEM(o, i) \
228 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
231 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
232 #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name)
233 #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val)
235 //---------------------------------------------------------------------------
237 #ifndef wxPyUSE_EXPORTED_API
239 class wxPyCallback
: public wxObject
{
240 DECLARE_ABSTRACT_CLASS(wxPyCallback
);
242 wxPyCallback(PyObject
* func
);
243 wxPyCallback(const wxPyCallback
& other
);
246 void EventThunker(wxEvent
& event
);
251 #endif // wxPyUSE_EXPORTED_API
252 //---------------------------------------------------------------------------
253 //---------------------------------------------------------------------------
254 // These Event classes can be derived from in Python and passed through the
255 // event system without loosing anything. They do this by keeping a reference
256 // to themselves and some special case handling in wxPyCallback::EventThunker.
260 class wxPyEvtSelfRef
{
265 void SetSelf(PyObject
* self
, bool clone
=False
);
266 PyObject
* GetSelf() const;
267 bool GetCloned() const { return m_cloned
; }
275 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
276 DECLARE_ABSTRACT_CLASS(wxPyEvent
)
278 wxPyEvent(int winid
=0, wxEventType commandType
= wxEVT_NULL
);
279 wxPyEvent(const wxPyEvent
& evt
);
282 virtual wxEvent
* Clone() const { return new wxPyEvent(*this); }
286 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
287 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent
)
289 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
290 wxPyCommandEvent(const wxPyCommandEvent
& evt
);
293 virtual wxEvent
* Clone() const { return new wxPyCommandEvent(*this); }
298 //----------------------------------------------------------------------
299 // Forward decalre a few things used in the exported API
300 class wxPyClientData
;
302 class wxPyOORClientData
;
303 class wxPyCBInputStream
;
305 void wxPyClientData_dtor(wxPyClientData
* self
);
306 void wxPyUserData_dtor(wxPyUserData
* self
);
307 void wxPyOORClientData_dtor(wxPyOORClientData
* self
);
308 wxPyCBInputStream
* wxPyCBInputStream_create(PyObject
*py
, bool block
);
311 //---------------------------------------------------------------------------
312 // Export a C API in a struct. Other modules will be able to load this from
313 // the wx.core module and will then have safe access to these functions, even if
314 // in another shared library.
316 class wxPyCallbackHelper
;
317 struct swig_type_info
;
318 struct swig_const_info
;
320 typedef double (*py_objasdbl_conv
)(PyObject
*obj
);
322 // Make SunCC happy and make typedef's for these that are extern "C"
323 typedef swig_type_info
* (*p_SWIG_Python_TypeRegister_t
)(swig_type_info
*);
324 typedef swig_type_info
* (*p_SWIG_Python_TypeCheck_t
)(char *c
, swig_type_info
*);
325 typedef void* (*p_SWIG_Python_TypeCast_t
)(swig_type_info
*, void *);
326 typedef swig_type_info
* (*p_SWIG_Python_TypeDynamicCast_t
)(swig_type_info
*, void **);
327 typedef const char* (*p_SWIG_Python_TypeName_t
)(const swig_type_info
*);
328 typedef swig_type_info
* (*p_SWIG_Python_TypeQuery_t
)(const char *);
329 typedef void (*p_SWIG_Python_TypeClientData_t
)(swig_type_info
*, void *);
330 typedef PyObject
* (*p_SWIG_Python_newvarlink_t
)(void);
331 typedef void (*p_SWIG_Python_addvarlink_t
)(PyObject
*, char *, PyObject
*(*)(void), int (*)(PyObject
*));
332 typedef int (*p_SWIG_Python_ConvertPtr_t
)(PyObject
*, void **, swig_type_info
*, int);
333 typedef int (*p_SWIG_Python_ConvertPacked_t
)(PyObject
*, void *, int sz
, swig_type_info
*, int);
334 typedef char* (*p_SWIG_Python_PackData_t
)(char *c
, void *, int);
335 typedef char* (*p_SWIG_Python_UnpackData_t
)(char *c
, void *, int);
336 typedef PyObject
* (*p_SWIG_Python_NewPointerObj_t
)(void *, swig_type_info
*,int own
);
337 typedef PyObject
* (*p_SWIG_Python_NewPackedObj_t
)(void *, int sz
, swig_type_info
*);
338 typedef void (*p_SWIG_Python_InstallConstants_t
)(PyObject
*d
, swig_const_info constants
[]);
339 typedef void* (*p_SWIG_Python_MustGetPtr_t
)(PyObject
*, swig_type_info
*, int, int);
341 typedef char* (*p_SWIG_PyObj_AsCharPtr_t
)(PyObject
*obj
, swig_type_info
* pchar_info
);
342 typedef PyObject
* (*p_SWIG_PyObj_FromCharPtr_t
)(const char* cptr
);
343 typedef unsigned long (*p_SWIG_PyObj_AsUnsignedLong_t
)(PyObject
* obj
);
344 typedef long (*p_SWIG_PyObj_AsLongInRange_t
)(PyObject
* obj
, const char* type
,
345 long min_value
, long max_value
);
346 typedef unsigned long (*p_SWIG_PyObj_AsUnsignedLongInRange_t
)(PyObject
*obj
, const char* type
,
347 unsigned long max_value
);
348 typedef char * (*p_SWIG_PyObj_AsNewCharPtr_t
)(PyObject
*obj
, swig_type_info
* pchar_info
);
349 typedef void (*p_SWIG_PyObj_AsCharPtrAndSize_t
)(PyObject
*obj
, swig_type_info
* pchar_info
,
350 char** cptr
, size_t* size
);
351 typedef void (*p_SWIG_PyObj_AsCharArray_t
)(PyObject
*obj
, swig_type_info
* pchar_info
,
352 char* carray
, size_t size
);
353 typedef PyObject
* (*p_SWIG_PyObj_FromCharArray_t
)(const char* carray
, size_t size
);
354 typedef float (*p_SWIG_PyObj_AsFloatConv_t
)(PyObject
*obj
, py_objasdbl_conv pyconv
);
361 p_SWIG_Python_TypeRegister_t p_SWIG_Python_TypeRegister
;
362 p_SWIG_Python_TypeCheck_t p_SWIG_Python_TypeCheck
;
363 p_SWIG_Python_TypeCast_t p_SWIG_Python_TypeCast
;
364 p_SWIG_Python_TypeDynamicCast_t p_SWIG_Python_TypeDynamicCast
;
365 p_SWIG_Python_TypeName_t p_SWIG_Python_TypeName
;
366 p_SWIG_Python_TypeQuery_t p_SWIG_Python_TypeQuery
;
367 p_SWIG_Python_TypeClientData_t p_SWIG_Python_TypeClientData
;
368 p_SWIG_Python_newvarlink_t p_SWIG_Python_newvarlink
;
369 p_SWIG_Python_addvarlink_t p_SWIG_Python_addvarlink
;
370 p_SWIG_Python_ConvertPtr_t p_SWIG_Python_ConvertPtr
;
371 p_SWIG_Python_ConvertPacked_t p_SWIG_Python_ConvertPacked
;
372 p_SWIG_Python_PackData_t p_SWIG_Python_PackData
;
373 p_SWIG_Python_UnpackData_t p_SWIG_Python_UnpackData
;
374 p_SWIG_Python_NewPointerObj_t p_SWIG_Python_NewPointerObj
;
375 p_SWIG_Python_NewPackedObj_t p_SWIG_Python_NewPackedObj
;
376 p_SWIG_Python_InstallConstants_t p_SWIG_Python_InstallConstants
;
377 p_SWIG_Python_MustGetPtr_t p_SWIG_Python_MustGetPtr
;
379 p_SWIG_PyObj_AsCharPtr_t p_SWIG_PyObj_AsCharPtr
;
380 p_SWIG_PyObj_FromCharPtr_t p_SWIG_PyObj_FromCharPtr
;
381 p_SWIG_PyObj_AsUnsignedLong_t p_SWIG_PyObj_AsUnsignedLong
;
382 p_SWIG_PyObj_AsLongInRange_t p_SWIG_PyObj_AsLongInRange
;
383 p_SWIG_PyObj_AsUnsignedLongInRange_t p_SWIG_PyObj_AsUnsignedLongInRange
;
384 p_SWIG_PyObj_AsNewCharPtr_t p_SWIG_PyObj_AsNewCharPtr
;
385 p_SWIG_PyObj_AsCharPtrAndSize_t p_SWIG_PyObj_AsCharPtrAndSize
;
386 p_SWIG_PyObj_AsCharArray_t p_SWIG_PyObj_AsCharArray
;
387 p_SWIG_PyObj_FromCharArray_t p_SWIG_PyObj_FromCharArray
;
388 p_SWIG_PyObj_AsFloatConv_t p_SWIG_PyObj_AsFloatConv
;
390 bool (*p_wxPyCheckSwigType
)(const wxChar
* className
);
391 PyObject
* (*p_wxPyConstructObject
)(void* ptr
, const wxChar
* className
, int setThisOwn
);
392 bool (*p_wxPyConvertSwigPtr
)(PyObject
* obj
, void **ptr
, const wxChar
* className
);
393 PyObject
* (*p_wxPyMakeSwigPtr
)(void* ptr
, const wxChar
* className
);
395 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
396 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
397 void (*p_wxPyBeginBlockThreads
)();
398 void (*p_wxPyEndBlockThreads
)();
400 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
);
402 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
403 wxString (*p_Py2wxString
)(PyObject
* source
);
404 PyObject
* (*p_wx2PyString
)(const wxString
& src
);
406 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
407 int* (*p_int_LIST_helper
)(PyObject
* source
);
408 long* (*p_long_LIST_helper
)(PyObject
* source
);
409 char** (*p_string_LIST_helper
)(PyObject
* source
);
410 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
411 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
412 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
413 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
415 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
416 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
417 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
418 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
419 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
420 bool (*p_wxPoint2D_helper
)(PyObject
* source
, wxPoint2DDouble
** obj
);
423 bool (*p_wxPySimple_typecheck
)(PyObject
* source
, const wxChar
* classname
, int seqLen
);
424 bool (*p_wxColour_typecheck
)(PyObject
* source
);
426 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
427 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
);
428 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
429 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
430 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
432 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool checkEvtHandler
);
433 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
);
434 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
435 bool (*p_wxPy2int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
);
436 bool (*p_wxPy4int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
437 PyObject
* (*p_wxArrayString2PyList_helper
)(const wxArrayString
& arr
);
438 PyObject
* (*p_wxArrayInt2PyList_helper
)(const wxArrayInt
& arr
);
440 void (*p_wxPyClientData_dtor
)(wxPyClientData
*);
441 void (*p_wxPyUserData_dtor
)(wxPyUserData
*);
442 void (*p_wxPyOORClientData_dtor
)(wxPyOORClientData
*);
444 wxPyCBInputStream
* (*p_wxPyCBInputStream_create
)(PyObject
*py
, bool block
);
446 bool (*p_wxPyInstance_Check
)(PyObject
* obj
);
447 bool (*p_wxPySwigInstance_Check
)(PyObject
* obj
);
451 #ifdef wxPyUSE_EXPORTED_API
452 // Notice that this is static, not extern. This is by design, each module
453 // needs one, but doesn't have to use it.
454 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
;
455 #endif // wxPyUSE_EXPORTED_API
457 //---------------------------------------------------------------------------
459 // A wxObject that holds a reference to a Python object
460 class wxPyUserData
: public wxObject
{
462 wxPyUserData(PyObject
* obj
) {
468 #ifdef wxPyUSE_EXPORTED_API
469 wxPyCoreAPIPtr
->p_wxPyUserData_dtor(this);
471 wxPyUserData_dtor(this);
478 // A wxClientData that holds a refernece to a Python object
479 class wxPyClientData
: public wxClientData
{
481 wxPyClientData(PyObject
* obj
) {
487 #ifdef wxPyUSE_EXPORTED_API
488 wxPyCoreAPIPtr
->p_wxPyClientData_dtor(this);
490 wxPyClientData_dtor(this);
497 // Just like wxPyClientData, except when this object is destroyed it does some
498 // OOR magic on the Python Object.
499 class wxPyOORClientData
: public wxPyClientData
{
501 wxPyOORClientData(PyObject
* obj
)
502 : wxPyClientData(obj
) {}
504 ~wxPyOORClientData() {
505 #ifdef wxPyUSE_EXPORTED_API
506 wxPyCoreAPIPtr
->p_wxPyOORClientData_dtor(this);
508 wxPyOORClientData_dtor(this);
514 //---------------------------------------------------------------------------
515 // This class holds an instance of a Python Shadow Class object and assists
516 // with looking up and invoking Python callback methods from C++ virtual
517 // method redirections. For all classes which have virtuals which should be
518 // overridable in wxPython, a new subclass is created that contains a
519 // wxPyCallbackHelper.
522 class wxPyCallbackHelper
{
524 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
526 wxPyCallbackHelper() {
533 ~wxPyCallbackHelper() {
534 #ifdef wxPyUSE_EXPORTED_API
535 wxPyCoreAPIPtr
->p_wxPyCBH_delete(this);
537 wxPyCBH_delete(this);
541 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=True
);
542 bool findCallback(const char* name
) const;
543 int callCallback(PyObject
* argTuple
) const;
544 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
545 PyObject
* GetLastFound() const { return m_lastFound
; }
550 PyObject
* m_lastFound
;
553 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
557 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
558 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
);
559 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
560 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
561 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
566 //---------------------------------------------------------------------------
568 // This is used in C++ classes that need to be able to make callback to
569 // "overloaded" python methods
572 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
573 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
575 private: wxPyCallbackHelper m_myInst
578 //---------------------------------------------------------------------------
579 // The wxPythonApp class
582 wxPYAPP_ASSERT_SUPPRESS
= 1,
583 wxPYAPP_ASSERT_EXCEPTION
= 2,
584 wxPYAPP_ASSERT_DIALOG
= 4,
585 wxPYAPP_ASSERT_LOG
= 8
588 class wxPyApp
: public wxApp
590 DECLARE_ABSTRACT_CLASS(wxPyApp
);
598 int GetAssertMode() { return m_assertMode
; }
599 void SetAssertMode(int mode
) { m_assertMode
= mode
; }
601 virtual bool OnInitGui();
602 virtual int OnExit();
604 virtual void OnAssert(const wxChar
*file
,
609 // virtual int FilterEvent(wxEvent& event); // This one too????
612 static bool GetMacSupportPCMenuShortcuts();
613 static long GetMacAboutMenuItemId();
614 static long GetMacPreferencesMenuItemId();
615 static long GetMacExitMenuItemId();
616 static wxString
GetMacHelpMenuTitleName();
618 static void SetMacSupportPCMenuShortcuts(bool val
);
619 static void SetMacAboutMenuItemId(long val
);
620 static void SetMacPreferencesMenuItemId(long val
);
621 static void SetMacExitMenuItemId(long val
);
622 static void SetMacHelpMenuTitleName(const wxString
& val
);
625 void _BootstrapApp();
627 // implementation only
628 void SetStartupComplete(bool val
) { m_startupComplete
= val
; };
632 bool m_startupComplete
;
635 extern wxPyApp
*wxPythonApp
;
638 //----------------------------------------------------------------------
639 // These macros are used to implement the virtual methods that should
640 // redirect to a Python method if one exists. The names designate the
641 // return type, if any, as well as any parameter types.
642 //---------------------------------------------------------------------------
644 #define DEC_PYCALLBACK__(CBNAME) \
649 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
650 void CLASS::CBNAME() { \
652 wxPyBeginBlockThreads(); \
653 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
654 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
655 wxPyEndBlockThreads(); \
659 void CLASS::base_##CBNAME() { \
663 //---------------------------------------------------------------------------
665 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
666 bool CBNAME(int a, int b); \
667 bool base_##CBNAME(int a, int b)
670 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
671 bool CLASS::CBNAME(int a, int b) { \
672 bool rval=False, found; \
673 wxPyBeginBlockThreads(); \
674 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
675 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
676 wxPyEndBlockThreads(); \
678 rval = PCLASS::CBNAME(a,b); \
681 bool CLASS::base_##CBNAME(int a, int b) { \
682 return PCLASS::CBNAME(a,b); \
685 //---------------------------------------------------------------------------
687 #define DEC_PYCALLBACK_VOID_(CBNAME) \
692 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
693 void CLASS::CBNAME() { \
695 wxPyBeginBlockThreads(); \
696 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
697 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
698 wxPyEndBlockThreads(); \
702 void CLASS::base_##CBNAME() { \
706 //---------------------------------------------------------------------------
708 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
709 void CBNAME(int a, int b); \
710 void base_##CBNAME(int a, int b)
713 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
714 void CLASS::CBNAME(int a, int b) { \
716 wxPyBeginBlockThreads(); \
717 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
718 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
719 wxPyEndBlockThreads(); \
721 PCLASS::CBNAME(a,b); \
723 void CLASS::base_##CBNAME(int a, int b) { \
724 PCLASS::CBNAME(a,b); \
727 //---------------------------------------------------------------------------
729 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
730 void CBNAME(int a); \
731 void base_##CBNAME(int a)
734 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
735 void CLASS::CBNAME(int a) { \
737 wxPyBeginBlockThreads(); \
738 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
739 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
740 wxPyEndBlockThreads(); \
744 void CLASS::base_##CBNAME(int a) { \
748 //---------------------------------------------------------------------------
750 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
751 void CBNAME(int a, int b, int c, int d); \
752 void base_##CBNAME(int a, int b, int c, int d)
755 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
756 void CLASS::CBNAME(int a, int b, int c, int d) { \
758 wxPyBeginBlockThreads(); \
759 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
760 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
761 wxPyEndBlockThreads(); \
763 PCLASS::CBNAME(a,b,c,d); \
765 void CLASS::base_##CBNAME(int a, int b, int c, int d) { \
766 PCLASS::CBNAME(a,b,c,d); \
769 //---------------------------------------------------------------------------
770 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
771 void CBNAME(int a, int b, int c, int d, int e); \
772 void base_##CBNAME(int a, int b, int c, int d, int e)
775 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
776 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
778 wxPyBeginBlockThreads(); \
779 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
780 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
781 wxPyEndBlockThreads(); \
783 PCLASS::CBNAME(a,b,c,d,e); \
785 void CLASS::base_##CBNAME(int a, int b, int c, int d, int e) { \
786 PCLASS::CBNAME(a,b,c,d,e); \
789 //---------------------------------------------------------------------------
791 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
792 void CBNAME(int* a, int* b) const; \
793 void base_##CBNAME(int* a, int* b) const
796 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
797 void CLASS::CBNAME(int* a, int* b) const { \
798 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
800 wxPyBeginBlockThreads(); \
801 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
803 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
805 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
806 PyObject* o1 = PySequence_GetItem(ro, 0); \
807 PyObject* o2 = PySequence_GetItem(ro, 1); \
808 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
809 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
812 PyErr_SetString(PyExc_TypeError, errmsg); \
817 PyErr_SetString(PyExc_TypeError, errmsg); \
822 wxPyEndBlockThreads(); \
824 PCLASS::CBNAME(a,b); \
826 void CLASS::base_##CBNAME(int* a, int* b) const { \
827 PCLASS::CBNAME(a,b); \
831 //---------------------------------------------------------------------------
833 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
834 wxSize CBNAME() const; \
835 wxSize base_##CBNAME() const
838 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
839 wxSize CLASS::CBNAME() const { \
840 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
841 bool found; wxSize rval(0,0); \
842 wxPyBeginBlockThreads(); \
843 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
845 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
847 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
848 PyObject* o1 = PySequence_GetItem(ro, 0); \
849 PyObject* o2 = PySequence_GetItem(ro, 1); \
850 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
851 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
854 PyErr_SetString(PyExc_TypeError, errmsg); \
859 PyErr_SetString(PyExc_TypeError, errmsg); \
864 wxPyEndBlockThreads(); \
866 return PCLASS::CBNAME(); \
870 wxSize CLASS::base_##CBNAME() const { \
871 return PCLASS::CBNAME(); \
875 //---------------------------------------------------------------------------
877 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
878 bool CBNAME(bool a); \
879 bool base_##CBNAME(bool a)
882 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
883 bool CLASS::CBNAME(bool a) { \
884 bool rval=False, found; \
885 wxPyBeginBlockThreads(); \
886 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
887 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
888 wxPyEndBlockThreads(); \
890 rval = PCLASS::CBNAME(a); \
893 bool CLASS::base_##CBNAME(bool a) { \
894 return PCLASS::CBNAME(a); \
897 //---------------------------------------------------------------------------
899 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
900 bool CBNAME(int a); \
901 bool base_##CBNAME(int a)
904 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
905 bool CLASS::CBNAME(int a) { \
906 bool rval=False, found; \
907 wxPyBeginBlockThreads(); \
908 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
909 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
910 wxPyEndBlockThreads(); \
912 rval = PCLASS::CBNAME(a); \
915 bool CLASS::base_##CBNAME(int a) { \
916 return PCLASS::CBNAME(a); \
919 //---------------------------------------------------------------------------
921 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
925 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
926 bool CLASS::CBNAME(int a) { \
928 wxPyBeginBlockThreads(); \
929 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
930 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
932 wxPyEndBlockThreads(); \
937 //---------------------------------------------------------------------------
939 #define DEC_PYCALLBACK__DC(CBNAME) \
940 void CBNAME(wxDC& a); \
941 void base_##CBNAME(wxDC& a)
944 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
945 void CLASS::CBNAME(wxDC& a) { \
947 wxPyBeginBlockThreads(); \
948 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
949 PyObject* obj = wxPyMake_wxObject(&a); \
950 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
953 wxPyEndBlockThreads(); \
957 void CLASS::base_##CBNAME(wxDC& a) { \
963 //---------------------------------------------------------------------------
965 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
966 void CBNAME(wxDC& a, bool b); \
967 void base_##CBNAME(wxDC& a, bool b)
970 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
971 void CLASS::CBNAME(wxDC& a, bool b) { \
973 wxPyBeginBlockThreads(); \
974 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
975 PyObject* obj = wxPyMake_wxObject(&a); \
976 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
979 wxPyEndBlockThreads(); \
981 PCLASS::CBNAME(a, b); \
983 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
984 PCLASS::CBNAME(a, b); \
987 //---------------------------------------------------------------------------
989 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
990 void CBNAME(wxDC& a, bool b); \
991 void base_##CBNAME(wxDC& a, bool b)
994 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
995 void CLASS::CBNAME(wxDC& a, bool b) { \
997 wxPyBeginBlockThreads(); \
998 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
999 PyObject* obj = wxPyMake_wxObject(&a); \
1000 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1003 wxPyEndBlockThreads(); \
1005 PCLASS::CBNAME(a, b); \
1007 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
1008 PCLASS::CBNAME(a, b); \
1011 //---------------------------------------------------------------------------
1013 #define DEC_PYCALLBACK__2DBL(CBNAME) \
1014 void CBNAME(double a, double b); \
1015 void base_##CBNAME(double a, double b)
1018 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
1019 void CLASS::CBNAME(double a, double b) { \
1021 wxPyBeginBlockThreads(); \
1022 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1023 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
1024 wxPyEndBlockThreads(); \
1026 PCLASS::CBNAME(a, b); \
1028 void CLASS::base_##CBNAME(double a, double b) { \
1029 PCLASS::CBNAME(a, b); \
1032 //---------------------------------------------------------------------------
1034 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
1035 void CBNAME(double a, double b, int c, int d); \
1036 void base_##CBNAME(double a, double b, int c, int d)
1039 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
1040 void CLASS::CBNAME(double a, double b, int c, int d) { \
1042 wxPyBeginBlockThreads(); \
1043 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1044 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
1046 wxPyEndBlockThreads(); \
1048 PCLASS::CBNAME(a, b, c, d); \
1050 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
1051 PCLASS::CBNAME(a, b, c, d); \
1054 //---------------------------------------------------------------------------
1056 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
1057 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
1058 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1061 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1062 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1064 wxPyBeginBlockThreads(); \
1065 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1066 PyObject* obj = wxPyMake_wxObject(&a); \
1067 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
1070 wxPyEndBlockThreads(); \
1072 PCLASS::CBNAME(a, b, c, d, e, f); \
1074 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
1075 PCLASS::CBNAME(a, b, c, d, e, f); \
1078 //---------------------------------------------------------------------------
1080 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
1081 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
1082 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1085 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1086 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1088 wxPyBeginBlockThreads(); \
1090 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1091 PyObject* obj = wxPyMake_wxObject(&a); \
1092 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1095 wxPyEndBlockThreads(); \
1097 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1100 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
1101 return PCLASS::CBNAME(a, b, c, d, e, f); \
1104 //---------------------------------------------------------------------------
1106 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1107 void CBNAME(bool a, double b, double c, int d, int e); \
1108 void base_##CBNAME(bool a, double b, double c, int d, int e)
1111 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1112 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1114 wxPyBeginBlockThreads(); \
1115 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1116 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1118 wxPyEndBlockThreads(); \
1120 PCLASS::CBNAME(a, b, c, d, e); \
1122 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
1123 PCLASS::CBNAME(a, b, c, d, e); \
1126 //---------------------------------------------------------------------------
1128 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1129 void CBNAME(wxDC& a, double b, double c, double d, double e); \
1130 void base_##CBNAME(wxDC& a, double b, double c, double d, double e)
1133 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1134 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1136 wxPyBeginBlockThreads(); \
1137 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1138 PyObject* obj = wxPyMake_wxObject(&a); \
1139 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1142 wxPyEndBlockThreads(); \
1144 PCLASS::CBNAME(a, b, c, d, e); \
1146 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
1147 PCLASS::CBNAME(a, b, c, d, e); \
1150 //---------------------------------------------------------------------------
1152 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1153 void CBNAME(wxDC& a, bool b); \
1154 void base_##CBNAME(wxDC& a, bool b)
1157 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1158 void CLASS::CBNAME(wxDC& a, bool b) { \
1160 wxPyBeginBlockThreads(); \
1161 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1162 PyObject* obj = wxPyMake_wxObject(&a); \
1163 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1166 wxPyEndBlockThreads(); \
1168 PCLASS::CBNAME(a, b); \
1170 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
1171 PCLASS::CBNAME(a, b); \
1174 //---------------------------------------------------------------------------
1176 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1177 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
1178 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1181 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1182 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1185 wxPyBeginBlockThreads(); \
1186 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1187 PyObject* obj = wxPyMake_wxObject(a); \
1188 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1191 wxPyEndBlockThreads(); \
1193 PCLASS::CBNAME(a, b, c, d, e, f); \
1195 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
1197 PCLASS::CBNAME(a, b, c, d, e, f); \
1200 //---------------------------------------------------------------------------
1202 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1203 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
1204 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1207 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1208 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1210 wxPyBeginBlockThreads(); \
1211 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1212 PyObject* obj = wxPyMake_wxObject(a); \
1213 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1216 wxPyEndBlockThreads(); \
1218 PCLASS::CBNAME(a, b, c, d, e); \
1220 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
1222 PCLASS::CBNAME(a, b, c, d, e); \
1225 //---------------------------------------------------------------------------
1227 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1228 void CBNAME(double a, double b, int c); \
1229 void base_##CBNAME(double a, double b, int c)
1232 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1233 void CLASS::CBNAME(double a, double b, int c) { \
1235 wxPyBeginBlockThreads(); \
1236 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1237 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1238 wxPyEndBlockThreads(); \
1240 PCLASS::CBNAME(a, b, c); \
1242 void CLASS::base_##CBNAME(double a, double b, int c) { \
1243 PCLASS::CBNAME(a, b, c); \
1246 //---------------------------------------------------------------------------
1248 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1249 void CBNAME(bool a, double b, double c, int d); \
1250 void base_##CBNAME(bool a, double b, double c, int d)
1253 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1254 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1256 wxPyBeginBlockThreads(); \
1257 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1258 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1259 wxPyEndBlockThreads(); \
1261 PCLASS::CBNAME(a, b, c, d); \
1263 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
1264 PCLASS::CBNAME(a, b, c, d); \
1267 //---------------------------------------------------------------------------
1268 //---------------------------------------------------------------------------
1270 #define DEC_PYCALLBACK__STRING(CBNAME) \
1271 void CBNAME(const wxString& a); \
1272 void base_##CBNAME(const wxString& a)
1274 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1275 void CLASS::CBNAME(const wxString& a) { \
1277 wxPyBeginBlockThreads(); \
1278 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1279 PyObject* s = wx2PyString(a); \
1280 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1283 wxPyEndBlockThreads(); \
1285 PCLASS::CBNAME(a); \
1287 void CLASS::base_##CBNAME(const wxString& a) { \
1288 PCLASS::CBNAME(a); \
1291 //---------------------------------------------------------------------------
1293 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1294 bool CBNAME(const wxString& a); \
1295 bool base_##CBNAME(const wxString& a)
1297 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1298 bool CLASS::CBNAME(const wxString& a) { \
1301 wxPyBeginBlockThreads(); \
1302 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1303 PyObject* s = wx2PyString(a); \
1304 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1307 wxPyEndBlockThreads(); \
1309 rval = PCLASS::CBNAME(a); \
1312 bool CLASS::base_##CBNAME(const wxString& a) { \
1313 return PCLASS::CBNAME(a); \
1316 //---------------------------------------------------------------------------
1318 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1319 bool CBNAME(const wxString& a)
1321 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1322 bool CLASS::CBNAME(const wxString& a) { \
1324 wxPyBeginBlockThreads(); \
1325 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1326 PyObject* s = wx2PyString(a); \
1327 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1330 wxPyEndBlockThreads(); \
1334 //---------------------------------------------------------------------------
1336 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1337 wxString CBNAME(const wxString& a)
1339 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1340 wxString CLASS::CBNAME(const wxString& a) { \
1342 wxPyBeginBlockThreads(); \
1343 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1345 PyObject* s = wx2PyString(a); \
1346 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1349 rval = Py2wxString(ro); \
1353 wxPyEndBlockThreads(); \
1357 //---------------------------------------------------------------------------
1359 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1360 wxString CBNAME(const wxString& a); \
1361 wxString base_##CBNAME(const wxString& a)
1363 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1364 wxString CLASS::CBNAME(const wxString& a) { \
1367 wxPyBeginBlockThreads(); \
1368 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1370 PyObject* s = wx2PyString(a); \
1371 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1374 rval = Py2wxString(ro); \
1379 rval = PCLASS::CBNAME(a); \
1380 wxPyEndBlockThreads(); \
1384 //---------------------------------------------------------------------------
1386 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1387 wxString CBNAME(const wxString& a,int b)
1389 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1390 wxString CLASS::CBNAME(const wxString& a,int b) { \
1392 wxPyBeginBlockThreads(); \
1393 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1395 PyObject* s = wx2PyString(a); \
1396 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1399 rval = Py2wxString(ro); \
1403 wxPyEndBlockThreads(); \
1407 //---------------------------------------------------------------------------
1409 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1410 bool CBNAME(const wxString& a, const wxString& b); \
1411 bool base_##CBNAME(const wxString& a, const wxString& b)
1413 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1414 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1417 wxPyBeginBlockThreads(); \
1418 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1419 PyObject* s1 = wx2PyString(a); \
1420 PyObject* s2 = wx2PyString(b); \
1421 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1425 wxPyEndBlockThreads(); \
1427 rval = PCLASS::CBNAME(a, b); \
1430 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
1431 return PCLASS::CBNAME(a, b); \
1434 //---------------------------------------------------------------------------
1436 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1437 wxString CBNAME(); \
1438 wxString base_##CBNAME()
1440 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1441 wxString CLASS::CBNAME() { \
1444 wxPyBeginBlockThreads(); \
1445 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1447 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1449 rval = Py2wxString(ro); \
1453 wxPyEndBlockThreads(); \
1455 rval = PCLASS::CBNAME(); \
1458 wxString CLASS::base_##CBNAME() { \
1459 return PCLASS::CBNAME(); \
1462 //---------------------------------------------------------------------------
1464 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1465 wxString CBNAME() const; \
1466 wxString base_##CBNAME() const;
1468 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1469 wxString CLASS::CBNAME() const { \
1472 wxPyBeginBlockThreads(); \
1473 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1475 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1477 rval = Py2wxString(ro); \
1481 wxPyEndBlockThreads(); \
1483 rval = PCLASS::CBNAME(); \
1486 wxString CLASS::base_##CBNAME() const { \
1487 return PCLASS::CBNAME(); \
1490 //---------------------------------------------------------------------------
1492 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1495 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1496 wxString CLASS::CBNAME() { \
1498 wxPyBeginBlockThreads(); \
1499 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1501 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1503 rval = Py2wxString(ro); \
1507 wxPyEndBlockThreads(); \
1511 //---------------------------------------------------------------------------
1513 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1514 wxString CBNAME() const;
1516 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1517 wxString CLASS::CBNAME() const { \
1519 wxPyBeginBlockThreads(); \
1520 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1522 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1524 rval = Py2wxString(ro); \
1528 wxPyEndBlockThreads(); \
1532 //---------------------------------------------------------------------------
1534 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1535 bool CBNAME(const wxHtmlTag& a)
1538 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1539 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1541 wxPyBeginBlockThreads(); \
1542 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1543 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0); \
1544 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1547 wxPyEndBlockThreads(); \
1551 //---------------------------------------------------------------------------
1553 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1554 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \
1555 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1557 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1558 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1560 wxPyBeginBlockThreads(); \
1561 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1562 PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \
1563 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1566 wxPyEndBlockThreads(); \
1568 PCLASS::CBNAME(cell, x, y); \
1570 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1571 PCLASS::CBNAME(cell, x, y); \
1575 //---------------------------------------------------------------------------
1577 #define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \
1578 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \
1579 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1581 #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \
1582 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1584 wxPyBeginBlockThreads(); \
1585 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1586 PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \
1587 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1588 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1592 wxPyEndBlockThreads(); \
1594 PCLASS::CBNAME(cell, x, y, e); \
1596 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1597 PCLASS::CBNAME(cell, x, y, e); \
1602 //---------------------------------------------------------------------------
1604 #define DEC_PYCALLBACK___pure(CBNAME) \
1608 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1609 void CLASS::CBNAME() { \
1610 wxPyBeginBlockThreads(); \
1611 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1612 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1613 wxPyEndBlockThreads(); \
1616 //---------------------------------------------------------------------------
1618 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1622 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1623 wxSize CLASS::CBNAME() { \
1624 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1626 wxPyBeginBlockThreads(); \
1627 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1630 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1632 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1634 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1635 PyObject* o1 = PySequence_GetItem(ro, 0); \
1636 PyObject* o2 = PySequence_GetItem(ro, 1); \
1637 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1638 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1640 PyErr_SetString(PyExc_TypeError, errmsg); \
1645 PyErr_SetString(PyExc_TypeError, errmsg); \
1650 wxPyEndBlockThreads(); \
1654 //---------------------------------------------------------------------------
1656 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1657 bool CBNAME(wxWindow* a); \
1658 bool base_##CBNAME(wxWindow* a)
1661 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1662 bool CLASS::CBNAME(wxWindow* a) { \
1665 wxPyBeginBlockThreads(); \
1666 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1667 PyObject* obj = wxPyMake_wxObject(a); \
1668 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1671 wxPyEndBlockThreads(); \
1673 rval = PCLASS::CBNAME(a); \
1676 bool CLASS::base_##CBNAME(wxWindow* a) { \
1677 return PCLASS::CBNAME(a); \
1680 //---------------------------------------------------------------------------
1682 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1683 bool CBNAME(wxWindow* a, wxDC& b); \
1684 bool base_##CBNAME(wxWindow* a, wxDC& b)
1687 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1688 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1691 wxPyBeginBlockThreads(); \
1692 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1693 PyObject* win = wxPyMake_wxObject(a); \
1694 PyObject* dc = wxPyMake_wxObject(&b); \
1695 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1699 wxPyEndBlockThreads(); \
1701 rval = PCLASS::CBNAME(a, b); \
1704 bool CLASS::base_##CBNAME(wxWindow* a, wxDC& b) { \
1705 return PCLASS::CBNAME(a, b); \
1708 //---------------------------------------------------------------------------
1710 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1711 void CBNAME(wxWindowBase* a); \
1712 void base_##CBNAME(wxWindowBase* a)
1715 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1716 void CLASS::CBNAME(wxWindowBase* a) { \
1718 wxPyBeginBlockThreads(); \
1719 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1720 PyObject* obj = wxPyMake_wxObject(a); \
1721 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1724 wxPyEndBlockThreads(); \
1726 PCLASS::CBNAME(a); \
1728 void CLASS::base_##CBNAME(wxWindowBase* a) { \
1729 PCLASS::CBNAME(a); \
1732 //---------------------------------------------------------------------------
1734 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1736 bool base_##CBNAME()
1739 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1740 bool CLASS::CBNAME() { \
1743 wxPyBeginBlockThreads(); \
1744 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1745 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1746 wxPyEndBlockThreads(); \
1748 rval = PCLASS::CBNAME(); \
1751 bool CLASS::base_##CBNAME() { \
1752 return PCLASS::CBNAME(); \
1755 //---------------------------------------------------------------------------
1757 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1758 bool CBNAME() const; \
1759 bool base_##CBNAME() const
1762 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1763 bool CLASS::CBNAME() const { \
1766 wxPyBeginBlockThreads(); \
1767 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1768 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1769 wxPyEndBlockThreads(); \
1771 rval = PCLASS::CBNAME(); \
1774 bool CLASS::base_##CBNAME() const { \
1775 return PCLASS::CBNAME(); \
1778 //---------------------------------------------------------------------------
1780 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1781 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
1782 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1785 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1786 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1789 wxPyBeginBlockThreads(); \
1790 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1791 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1792 wxPyEndBlockThreads(); \
1794 rval = PCLASS::CBNAME(a, b, c); \
1795 return (wxDragResult)rval; \
1797 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1798 return PCLASS::CBNAME(a, b, c); \
1801 //---------------------------------------------------------------------------
1803 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1804 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1806 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1807 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1808 wxPyBeginBlockThreads(); \
1810 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1812 PyObject* obj = wxPyMake_wxObject(&a); \
1813 PyObject* s = wx2PyString(b); \
1814 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)",\
1817 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFILE"));\
1823 wxPyEndBlockThreads(); \
1827 //---------------------------------------------------------------------------
1829 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1830 bool CBNAME(wxDragResult a); \
1831 bool base_##CBNAME(wxDragResult a)
1834 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1835 bool CLASS::CBNAME(wxDragResult a) { \
1838 wxPyBeginBlockThreads(); \
1839 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1840 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));\
1841 wxPyEndBlockThreads(); \
1843 rval = PCLASS::CBNAME(a); \
1846 bool CLASS::base_##CBNAME(wxDragResult a) { \
1847 return PCLASS::CBNAME(a); \
1850 //---------------------------------------------------------------------------
1852 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1853 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1856 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1857 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1858 wxPyBeginBlockThreads(); \
1860 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1861 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1862 wxPyEndBlockThreads(); \
1863 return (wxDragResult)rval; \
1866 //---------------------------------------------------------------------------
1868 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1869 bool CBNAME(int a, int b, const wxString& c)
1871 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1872 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1874 wxPyBeginBlockThreads(); \
1875 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1876 PyObject* s = wx2PyString(c); \
1877 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1880 wxPyEndBlockThreads(); \
1884 //---------------------------------------------------------------------------
1886 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1888 size_t base_##CBNAME()
1891 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1892 size_t CLASS::CBNAME() { \
1895 wxPyBeginBlockThreads(); \
1896 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1897 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1898 wxPyEndBlockThreads(); \
1900 rval = PCLASS::CBNAME(); \
1903 size_t CLASS::base_##CBNAME() { \
1904 return PCLASS::CBNAME(); \
1907 //---------------------------------------------------------------------------
1909 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1910 size_t CBNAME() const; \
1911 size_t base_##CBNAME() const
1914 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1915 size_t CLASS::CBNAME() const { \
1918 wxPyBeginBlockThreads(); \
1919 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1920 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1921 wxPyEndBlockThreads(); \
1923 rval = PCLASS::CBNAME(); \
1926 size_t CLASS::base_##CBNAME() const { \
1927 return PCLASS::CBNAME(); \
1930 //---------------------------------------------------------------------------
1932 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1933 wxDataFormat CBNAME(size_t a); \
1934 wxDataFormat base_##CBNAME(size_t a)
1937 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1938 wxDataFormat CLASS::CBNAME(size_t a) { \
1939 wxDataFormat rval=0; \
1941 wxPyBeginBlockThreads(); \
1942 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1944 wxDataFormat* ptr; \
1945 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1947 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1952 wxPyEndBlockThreads(); \
1954 rval = PCLASS::CBNAME(a); \
1957 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1958 return PCLASS::CBNAME(a); \
1961 //---------------------------------------------------------------------------
1963 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1964 void CBNAME(const Type& a); \
1965 void base_##CBNAME(const Type& a)
1968 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1969 void CLASS::CBNAME(const Type& a) { \
1971 wxPyBeginBlockThreads(); \
1972 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1973 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1974 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1977 wxPyEndBlockThreads(); \
1979 PCLASS::CBNAME(a); \
1981 void CLASS::base_##CBNAME(const Type& a) { \
1982 PCLASS::CBNAME(a); \
1986 //---------------------------------------------------------------------------
1988 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1989 void CBNAME(Type& a); \
1990 void base_##CBNAME(Type& a)
1993 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1994 void CLASS::CBNAME(Type& a) { \
1996 wxPyBeginBlockThreads(); \
1997 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1998 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1999 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2002 wxPyEndBlockThreads(); \
2004 PCLASS::CBNAME(a); \
2006 void CLASS::base_##CBNAME(Type& a) { \
2007 PCLASS::CBNAME(a); \
2010 //---------------------------------------------------------------------------
2012 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
2013 bool CBNAME(Type& a); \
2014 bool base_##CBNAME(Type& a)
2017 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
2018 bool CLASS::CBNAME(Type& a) { \
2021 wxPyBeginBlockThreads(); \
2022 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2023 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2024 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2027 wxPyEndBlockThreads(); \
2029 rv = PCLASS::CBNAME(a); \
2032 bool CLASS::base_##CBNAME(Type& a) { \
2033 return PCLASS::CBNAME(a); \
2036 //---------------------------------------------------------------------------
2038 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
2039 bool CBNAME(Type& a)
2042 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
2043 bool CLASS::CBNAME(Type& a) { \
2045 wxPyBeginBlockThreads(); \
2046 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2047 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2048 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2051 wxPyEndBlockThreads(); \
2055 //---------------------------------------------------------------------------
2057 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
2058 wxString CBNAME(long a, long b) const; \
2059 wxString base_##CBNAME(long a, long b) const
2061 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
2062 wxString CLASS::CBNAME(long a, long b) const { \
2065 wxPyBeginBlockThreads(); \
2066 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2068 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2070 rval = Py2wxString(ro); \
2074 wxPyEndBlockThreads(); \
2076 rval = PCLASS::CBNAME(a,b); \
2079 wxString CLASS::base_##CBNAME(long a, long b) const { \
2080 return PCLASS::CBNAME(a,b); \
2083 //---------------------------------------------------------------------------
2085 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
2086 int CBNAME(long a) const; \
2087 int base_##CBNAME(long a) const
2090 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
2091 int CLASS::CBNAME(long a) const { \
2094 wxPyBeginBlockThreads(); \
2095 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2097 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2099 rval = PyInt_AsLong(ro); \
2103 wxPyEndBlockThreads(); \
2105 rval = PCLASS::CBNAME(a); \
2108 int CLASS::base_##CBNAME(long a) const { \
2109 return PCLASS::CBNAME(a); \
2113 //---------------------------------------------------------------------------
2115 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2116 wxListItemAttr* CBNAME(long a) const; \
2117 wxListItemAttr* base_##CBNAME(long a) const
2120 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2121 wxListItemAttr *CLASS::CBNAME(long a) const { \
2122 wxListItemAttr *rval = NULL; \
2124 wxPyBeginBlockThreads(); \
2125 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2127 wxListItemAttr* ptr; \
2128 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2130 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2135 wxPyEndBlockThreads(); \
2137 rval = PCLASS::CBNAME(a); \
2140 wxListItemAttr *CLASS::base_##CBNAME(long a) const { \
2141 return PCLASS::CBNAME(a); \
2144 //---------------------------------------------------------------------------
2146 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2147 bool CBNAME(wxMouseEvent& e); \
2148 bool base_##CBNAME(wxMouseEvent& e)
2150 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2151 bool CLASS::CBNAME(wxMouseEvent& e) { \
2154 wxPyBeginBlockThreads(); \
2155 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2157 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2158 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2160 rval = PyInt_AsLong(ro); \
2165 wxPyEndBlockThreads(); \
2167 return PCLASS::CBNAME(e); \
2170 bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
2171 return PCLASS::CBNAME(e); \
2175 //---------------------------------------------------------------------------
2177 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2178 wxWizardPage* CBNAME() const
2180 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2181 wxWizardPage* CLASS::CBNAME() const { \
2182 wxWizardPage* rv = NULL; \
2183 wxPyBeginBlockThreads(); \
2184 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2186 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2188 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2192 wxPyEndBlockThreads(); \
2196 //---------------------------------------------------------------------------
2198 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2199 wxBitmap CBNAME() const
2201 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2202 wxBitmap CLASS::CBNAME() const { \
2204 wxPyBeginBlockThreads(); \
2205 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2208 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2210 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2215 wxPyEndBlockThreads(); \
2219 //---------------------------------------------------------------------------
2221 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2224 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2225 wxObject* CLASS::CBNAME() { \
2226 wxObject* rv = NULL; \
2227 wxPyBeginBlockThreads(); \
2228 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2230 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2232 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2236 wxPyEndBlockThreads(); \
2240 //---------------------------------------------------------------------------
2242 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2243 wxObject* CBNAME(const wxString& a)
2245 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2246 wxObject* CLASS::CBNAME(const wxString& a) { \
2247 wxObject* rv = NULL; \
2248 wxPyBeginBlockThreads(); \
2249 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2250 PyObject* so = wx2PyString(a); \
2252 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2254 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2259 wxPyEndBlockThreads(); \
2263 //---------------------------------------------------------------------------
2265 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2266 bool CBNAME(wxXmlNode* a)
2269 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2270 bool CLASS::CBNAME(wxXmlNode* a) { \
2272 wxPyBeginBlockThreads(); \
2273 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2274 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2275 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2278 wxPyEndBlockThreads(); \
2282 //---------------------------------------------------------------------------
2284 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2285 wxCoord CBNAME(size_t a) const
2288 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2289 wxCoord CLASS::CBNAME(size_t a) const { \
2292 wxPyBeginBlockThreads(); \
2293 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2294 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2296 wxPyEndBlockThreads(); \
2300 //---------------------------------------------------------------------------
2302 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2303 void CBNAME(size_t a, size_t b) const; \
2304 void base_##CBNAME(size_t a, size_t b) const
2307 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2308 void CLASS::CBNAME(size_t a, size_t b) const { \
2310 wxPyBeginBlockThreads(); \
2311 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2312 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2313 wxPyEndBlockThreads(); \
2315 PCLASS::CBNAME(a,b); \
2317 void CLASS::base_##CBNAME(size_t a, size_t b) const { \
2318 PCLASS::CBNAME(a,b); \
2321 //---------------------------------------------------------------------------
2323 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2324 wxCoord CBNAME() const; \
2325 wxCoord base_##CBNAME() const
2328 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2329 wxCoord CLASS::CBNAME() const { \
2332 wxPyBeginBlockThreads(); \
2333 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2334 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2335 wxPyEndBlockThreads(); \
2337 rval = PCLASS::CBNAME(); \
2340 wxCoord CLASS::base_##CBNAME() const { \
2341 return PCLASS::CBNAME(); \
2344 //---------------------------------------------------------------------------
2346 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2347 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2350 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2351 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2353 wxPyBeginBlockThreads(); \
2354 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2355 PyObject* obj = wxPyMake_wxObject(&a); \
2356 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2357 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2360 wxPyEndBlockThreads(); \
2363 //---------------------------------------------------------------------------
2365 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2366 void CBNAME(wxDC& a, const wxRect& b, size_t c) const; \
2367 void base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const
2370 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2371 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2373 wxPyBeginBlockThreads(); \
2374 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2375 PyObject* obj = wxPyMake_wxObject(&a); \
2376 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2377 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2380 wxPyEndBlockThreads(); \
2382 PCLASS::CBNAME(a,b,c); \
2384 void CLASS::base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2385 PCLASS::CBNAME(a,b,c); \
2388 //---------------------------------------------------------------------------
2391 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2392 wxString CBNAME(size_t a) const; \
2393 wxString base_##CBNAME(size_t a) const
2395 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2396 wxString CLASS::CBNAME(size_t a) const { \
2399 wxPyBeginBlockThreads(); \
2400 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2402 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2404 rval = Py2wxString(ro); \
2408 wxPyEndBlockThreads(); \
2410 rval = PCLASS::CBNAME(a); \
2413 wxString CLASS::base_##CBNAME(size_t a) const { \
2414 return PCLASS::CBNAME(a); \
2417 //---------------------------------------------------------------------------
2419 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2420 wxString CBNAME(size_t a) const
2422 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2423 wxString CLASS::CBNAME(size_t a) const { \
2426 wxPyBeginBlockThreads(); \
2427 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2429 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2431 rval = Py2wxString(ro); \
2435 wxPyEndBlockThreads(); \
2439 //---------------------------------------------------------------------------