1 ////////////////////////////////////////////////////////////////////////////
2 // Name: wxPython_int.h (int == internal)
3 // Purpose: Helper functions/classes for the wxPython extension module
4 // This header should only be inclued directly by those source
5 // modules included in the wx._core module. All others should
6 // include wx/wxPython/wxPython.h instead.
10 // Created: 1-July-1997
12 // Copyright: (c) 1998 by Total Control Software
13 // Licence: wxWindows license
14 /////////////////////////////////////////////////////////////////////////////
16 #ifndef __wxp_helpers__
17 #define __wxp_helpers__
21 #include <wx/busyinfo.h>
23 #include <wx/choicebk.h>
24 #include <wx/clipbrd.h>
25 #include <wx/colordlg.h>
26 #include <wx/config.h>
27 #include <wx/cshelp.h>
28 #include <wx/dcmirror.h>
30 #include <wx/dirctrl.h>
31 #include <wx/dirdlg.h>
33 #include <wx/docview.h>
34 #include <wx/encconv.h>
35 #include <wx/fdrepdlg.h>
36 #include <wx/fileconf.h>
37 #include <wx/filesys.h>
38 #include <wx/fontdlg.h>
39 #include <wx/fs_inet.h>
40 #include <wx/fs_mem.h>
41 #include <wx/fs_zip.h>
42 #include <wx/gbsizer.h>
43 #include <wx/geometry.h>
44 #include <wx/htmllbox.h>
46 #include <wx/imaglist.h>
48 #include <wx/laywin.h>
49 #include <wx/listbook.h>
50 #include <wx/minifram.h>
51 #include <wx/notebook.h>
53 #include <wx/printdlg.h>
54 #include <wx/process.h>
55 #include <wx/progdlg.h>
56 #include <wx/sashwin.h>
57 #include <wx/spinbutt.h>
58 #include <wx/spinctrl.h>
59 #include <wx/splash.h>
60 #include <wx/splitter.h>
61 #include <wx/statline.h>
62 #include <wx/stream.h>
63 #include <wx/sysopt.h>
64 #include <wx/taskbar.h>
65 #include <wx/tglbtn.h>
66 #include <wx/tipwin.h>
67 #include <wx/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
;
87 #ifndef wxPyUSE_EXPORTED_API
89 void __wxPyPreStart(PyObject
*);
91 PyObject
* __wxPySetDictionary(PyObject
*, PyObject
* args
);
92 PyObject
* __wxPyFixStockObjects(PyObject
*, PyObject
* args
);
94 void wxSetDefaultPyEncoding(const char* encoding
);
95 const char* wxGetDefaultPyEncoding();
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 setThisOwn
, bool checkEvtHandler
=true);
114 PyObject
* wxPyMake_wxSizer(wxSizer
* source
, bool setThisOwn
);
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 bool wxPyBeginBlockThreads();
144 void wxPyEndBlockThreads(bool blocked
);
146 #endif // wxPyUSE_EXPORTED_API
149 // A macro that will help to execute simple statments wrapped in
150 // StartBlock/EndBlockThreads calls
151 #define wxPyBLOCK_THREADS(stmt) \
152 { bool blocked = wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads(blocked); }
154 // Raise the NotImplementedError exception (blocking threads)
155 #define wxPyRaiseNotImplemented() \
156 wxPyBLOCK_THREADS(PyErr_SetNone(PyExc_NotImplementedError))
158 // Raise any exception witha string value (blocking threads)
159 #define wxPyErr_SetString(err, str) \
160 wxPyBLOCK_THREADS(PyErr_SetString(err, str))
163 //---------------------------------------------------------------------------
164 // These are helpers used by the typemaps
166 #ifndef wxPyUSE_EXPORTED_API
168 wxString
* wxString_in_helper(PyObject
* source
);
170 byte
* byte_LIST_helper(PyObject
* source
);
171 int* int_LIST_helper(PyObject
* source
);
172 long* long_LIST_helper(PyObject
* source
);
173 char** string_LIST_helper(PyObject
* source
);
174 wxPoint
* wxPoint_LIST_helper(PyObject
* source
, int* npoints
);
175 wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
176 wxString
* wxString_LIST_helper(PyObject
* source
);
177 wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
178 wxPen
** wxPen_LIST_helper(PyObject
* source
);
180 bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
181 bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
182 bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
183 bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
184 bool wxColour_helper(PyObject
* source
, wxColour
** obj
);
185 bool wxPoint2D_helper(PyObject
* source
, wxPoint2D
** obj
);
188 bool wxPySimple_typecheck(PyObject
* source
, const wxChar
* classname
, int seqLen
);
189 bool wxColour_typecheck(PyObject
* source
);
191 bool wxPyCheckForApp();
195 bool wxPyTwoIntItem_helper(PyObject
* source
, T
** obj
, const wxChar
* name
)
197 // If source is an object instance then it may already be the right type
198 if (wxPySwigInstance_Check(source
)) {
200 if (! wxPyConvertSwigPtr(source
, (void **)&ptr
, name
))
205 // otherwise a 2-tuple of integers is expected
206 else if (PySequence_Check(source
) && PyObject_Length(source
) == 2) {
207 PyObject
* o1
= PySequence_GetItem(source
, 0);
208 PyObject
* o2
= PySequence_GetItem(source
, 1);
209 if (!PyNumber_Check(o1
) || !PyNumber_Check(o2
)) {
214 **obj
= T(PyInt_AsLong(o1
), PyInt_AsLong(o2
));
222 msg
.Printf(wxT("Expected a 2-tuple of integers or a %s object."), name
);
223 PyErr_SetString(PyExc_TypeError
, msg
.mb_str());
229 // Other helpful stuff
230 bool wxPy2int_seq_helper(PyObject
* source
, int* i1
, int* i2
);
231 bool wxPy4int_seq_helper(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
233 PyObject
* wxArrayString2PyList_helper(const wxArrayString
& arr
);
234 PyObject
* wxArrayInt2PyList_helper(const wxArrayInt
& arr
);
236 #endif // wxPyUSE_EXPORTED_API
238 //---------------------------------------------------------------------------
240 #if PYTHON_API_VERSION < 1009
241 #define PySequence_Fast_GET_ITEM(o, i) \
242 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
245 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
246 #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name)
247 #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val)
249 //---------------------------------------------------------------------------
251 #ifndef wxPyUSE_EXPORTED_API
253 class wxPyCallback
: public wxObject
{
254 DECLARE_ABSTRACT_CLASS(wxPyCallback
);
256 wxPyCallback(PyObject
* func
);
257 wxPyCallback(const wxPyCallback
& other
);
260 void EventThunker(wxEvent
& event
);
265 #endif // wxPyUSE_EXPORTED_API
266 //---------------------------------------------------------------------------
267 //---------------------------------------------------------------------------
268 // These Event classes can be derived from in Python and passed through the
269 // event system without loosing anything. They do this by keeping a reference
270 // to themselves and some special case handling in wxPyCallback::EventThunker.
274 class wxPyEvtSelfRef
{
279 void SetSelf(PyObject
* self
, bool clone
=false);
280 PyObject
* GetSelf() const;
281 bool GetCloned() const { return m_cloned
; }
289 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
290 DECLARE_ABSTRACT_CLASS(wxPyEvent
)
292 wxPyEvent(int winid
=0, wxEventType commandType
= wxEVT_NULL
);
293 wxPyEvent(const wxPyEvent
& evt
);
296 virtual wxEvent
* Clone() const { return new wxPyEvent(*this); }
300 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
301 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent
)
303 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
304 wxPyCommandEvent(const wxPyCommandEvent
& evt
);
307 virtual wxEvent
* Clone() const { return new wxPyCommandEvent(*this); }
312 //----------------------------------------------------------------------
313 // Forward decalre a few things used in the exported API
314 class wxPyClientData
;
316 class wxPyOORClientData
;
317 class wxPyCBInputStream
;
319 void wxPyClientData_dtor(wxPyClientData
* self
);
320 void wxPyUserData_dtor(wxPyUserData
* self
);
321 void wxPyOORClientData_dtor(wxPyOORClientData
* self
);
322 wxPyCBInputStream
* wxPyCBInputStream_create(PyObject
*py
, bool block
);
325 //---------------------------------------------------------------------------
326 // Export a C API in a struct. Other modules will be able to load this from
327 // the wx.core module and will then have safe access to these functions, even if
328 // in another shared library.
330 class wxPyCallbackHelper
;
331 struct swig_type_info
;
332 struct swig_const_info
;
334 // Make SunCC happy and make typedef's for these that are extern "C"
335 typedef swig_type_info
* (*p_SWIG_Python_TypeRegister_t
)(swig_type_info
*);
336 typedef swig_type_info
* (*p_SWIG_Python_TypeCheck_t
)(char *c
, swig_type_info
*);
337 typedef void* (*p_SWIG_Python_TypeCast_t
)(swig_type_info
*, void *);
338 typedef swig_type_info
* (*p_SWIG_Python_TypeDynamicCast_t
)(swig_type_info
*, void **);
339 typedef const char* (*p_SWIG_Python_TypeName_t
)(const swig_type_info
*);
340 typedef const char * (*p_SWIG_Python_TypePrettyName_t
)(const swig_type_info
*);
341 typedef swig_type_info
* (*p_SWIG_Python_TypeQuery_t
)(const char *);
342 typedef void (*p_SWIG_Python_TypeClientData_t
)(swig_type_info
*, void *);
343 typedef PyObject
* (*p_SWIG_Python_newvarlink_t
)(void);
344 typedef void (*p_SWIG_Python_addvarlink_t
)(PyObject
*, char *, PyObject
*(*)(void), int (*)(PyObject
*));
345 typedef int (*p_SWIG_Python_ConvertPtr_t
)(PyObject
*, void **, swig_type_info
*, int);
346 typedef int (*p_SWIG_Python_ConvertPacked_t
)(PyObject
*, void *, int sz
, swig_type_info
*, int);
347 typedef char* (*p_SWIG_Python_PackData_t
)(char *c
, void *, int);
348 typedef char* (*p_SWIG_Python_UnpackData_t
)(char *c
, void *, int);
349 typedef PyObject
* (*p_SWIG_Python_NewPointerObj_t
)(void *, swig_type_info
*,int own
);
350 typedef PyObject
* (*p_SWIG_Python_NewPackedObj_t
)(void *, int sz
, swig_type_info
*);
351 typedef void (*p_SWIG_Python_InstallConstants_t
)(PyObject
*d
, swig_const_info constants
[]);
352 typedef void* (*p_SWIG_Python_MustGetPtr_t
)(PyObject
*, swig_type_info
*, int, int);
357 p_SWIG_Python_TypeRegister_t p_SWIG_Python_TypeRegister
;
358 p_SWIG_Python_TypeCheck_t p_SWIG_Python_TypeCheck
;
359 p_SWIG_Python_TypeCast_t p_SWIG_Python_TypeCast
;
360 p_SWIG_Python_TypeDynamicCast_t p_SWIG_Python_TypeDynamicCast
;
361 p_SWIG_Python_TypeName_t p_SWIG_Python_TypeName
;
362 p_SWIG_Python_TypePrettyName_t p_SWIG_Python_TypePrettyName
;
363 p_SWIG_Python_TypeQuery_t p_SWIG_Python_TypeQuery
;
364 p_SWIG_Python_TypeClientData_t p_SWIG_Python_TypeClientData
;
365 p_SWIG_Python_newvarlink_t p_SWIG_Python_newvarlink
;
366 p_SWIG_Python_addvarlink_t p_SWIG_Python_addvarlink
;
367 p_SWIG_Python_ConvertPtr_t p_SWIG_Python_ConvertPtr
;
368 p_SWIG_Python_ConvertPacked_t p_SWIG_Python_ConvertPacked
;
369 p_SWIG_Python_PackData_t p_SWIG_Python_PackData
;
370 p_SWIG_Python_UnpackData_t p_SWIG_Python_UnpackData
;
371 p_SWIG_Python_NewPointerObj_t p_SWIG_Python_NewPointerObj
;
372 p_SWIG_Python_NewPackedObj_t p_SWIG_Python_NewPackedObj
;
373 p_SWIG_Python_InstallConstants_t p_SWIG_Python_InstallConstants
;
374 p_SWIG_Python_MustGetPtr_t p_SWIG_Python_MustGetPtr
;
376 bool (*p_wxPyCheckSwigType
)(const wxChar
* className
);
377 PyObject
* (*p_wxPyConstructObject
)(void* ptr
, const wxChar
* className
, int setThisOwn
);
378 bool (*p_wxPyConvertSwigPtr
)(PyObject
* obj
, void **ptr
, const wxChar
* className
);
379 PyObject
* (*p_wxPyMakeSwigPtr
)(void* ptr
, const wxChar
* className
);
381 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
382 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
383 bool (*p_wxPyBeginBlockThreads
)();
384 void (*p_wxPyEndBlockThreads
)(bool blocked
);
386 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
);
388 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
389 wxString (*p_Py2wxString
)(PyObject
* source
);
390 PyObject
* (*p_wx2PyString
)(const wxString
& src
);
392 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
393 int* (*p_int_LIST_helper
)(PyObject
* source
);
394 long* (*p_long_LIST_helper
)(PyObject
* source
);
395 char** (*p_string_LIST_helper
)(PyObject
* source
);
396 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
397 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
398 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
399 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
401 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
402 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
403 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
404 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
405 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
406 bool (*p_wxPoint2D_helper
)(PyObject
* source
, wxPoint2DDouble
** obj
);
409 bool (*p_wxPySimple_typecheck
)(PyObject
* source
, const wxChar
* classname
, int seqLen
);
410 bool (*p_wxColour_typecheck
)(PyObject
* source
);
412 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
413 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
);
414 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
415 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
416 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
418 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
);
419 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
, bool setThisOwn
);
420 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
421 bool (*p_wxPy2int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
);
422 bool (*p_wxPy4int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
423 PyObject
* (*p_wxArrayString2PyList_helper
)(const wxArrayString
& arr
);
424 PyObject
* (*p_wxArrayInt2PyList_helper
)(const wxArrayInt
& arr
);
426 void (*p_wxPyClientData_dtor
)(wxPyClientData
*);
427 void (*p_wxPyUserData_dtor
)(wxPyUserData
*);
428 void (*p_wxPyOORClientData_dtor
)(wxPyOORClientData
*);
430 wxPyCBInputStream
* (*p_wxPyCBInputStream_create
)(PyObject
*py
, bool block
);
432 bool (*p_wxPyInstance_Check
)(PyObject
* obj
);
433 bool (*p_wxPySwigInstance_Check
)(PyObject
* obj
);
435 bool (*p_wxPyCheckForApp
)();
439 #ifdef wxPyUSE_EXPORTED_API
440 // Notice that this is static, not extern. This is by design, each module
441 // needs one, but doesn't have to use it.
442 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
;
443 inline wxPyCoreAPI
* wxPyGetCoreAPIPtr();
444 #endif // wxPyUSE_EXPORTED_API
446 //---------------------------------------------------------------------------
448 // A wxObject that holds a reference to a Python object
449 class wxPyUserData
: public wxObject
{
451 wxPyUserData(PyObject
* obj
) {
457 #ifdef wxPyUSE_EXPORTED_API
458 wxPyGetCoreAPIPtr()->p_wxPyUserData_dtor(this);
460 wxPyUserData_dtor(this);
467 // A wxClientData that holds a refernece to a Python object
468 class wxPyClientData
: public wxClientData
{
470 wxPyClientData(PyObject
* obj
) {
476 #ifdef wxPyUSE_EXPORTED_API
477 wxPyGetCoreAPIPtr()->p_wxPyClientData_dtor(this);
479 wxPyClientData_dtor(this);
486 // Just like wxPyClientData, except when this object is destroyed it does some
487 // OOR magic on the Python Object.
488 class wxPyOORClientData
: public wxPyClientData
{
490 wxPyOORClientData(PyObject
* obj
)
491 : wxPyClientData(obj
) {}
493 ~wxPyOORClientData() {
494 #ifdef wxPyUSE_EXPORTED_API
495 wxPyGetCoreAPIPtr()->p_wxPyOORClientData_dtor(this);
497 wxPyOORClientData_dtor(this);
503 //---------------------------------------------------------------------------
504 // This class holds an instance of a Python Shadow Class object and assists
505 // with looking up and invoking Python callback methods from C++ virtual
506 // method redirections. For all classes which have virtuals which should be
507 // overridable in wxPython, a new subclass is created that contains a
508 // wxPyCallbackHelper.
511 class wxPyCallbackHelper
{
513 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
515 wxPyCallbackHelper() {
522 ~wxPyCallbackHelper() {
523 #ifdef wxPyUSE_EXPORTED_API
524 wxPyGetCoreAPIPtr()->p_wxPyCBH_delete(this);
526 wxPyCBH_delete(this);
530 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=true);
531 bool findCallback(const char* name
) const;
532 int callCallback(PyObject
* argTuple
) const;
533 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
534 PyObject
* GetLastFound() const { return m_lastFound
; }
539 PyObject
* m_lastFound
;
542 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
546 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
547 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
);
548 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
549 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
550 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
555 //---------------------------------------------------------------------------
557 // This is used in C++ classes that need to be able to make callback to
558 // "overloaded" python methods
561 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
562 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
564 private: wxPyCallbackHelper m_myInst
567 //---------------------------------------------------------------------------
568 // The wxPythonApp class
571 wxPYAPP_ASSERT_SUPPRESS
= 1,
572 wxPYAPP_ASSERT_EXCEPTION
= 2,
573 wxPYAPP_ASSERT_DIALOG
= 4,
574 wxPYAPP_ASSERT_LOG
= 8
577 class wxPyApp
: public wxApp
579 DECLARE_ABSTRACT_CLASS(wxPyApp
);
587 int GetAssertMode() { return m_assertMode
; }
588 void SetAssertMode(int mode
) { m_assertMode
= mode
; }
590 virtual bool OnInitGui();
591 virtual int OnExit();
593 virtual void OnAssert(const wxChar
*file
,
598 // virtual int FilterEvent(wxEvent& event); // This one too????
600 // For catching Apple Events
601 virtual void MacOpenFile(const wxString
&fileName
);
602 virtual void MacPrintFile(const wxString
&fileName
);
603 virtual void MacNewFile();
604 virtual void MacReopenApp();
606 static bool GetMacSupportPCMenuShortcuts();
607 static long GetMacAboutMenuItemId();
608 static long GetMacPreferencesMenuItemId();
609 static long GetMacExitMenuItemId();
610 static wxString
GetMacHelpMenuTitleName();
612 static void SetMacSupportPCMenuShortcuts(bool val
);
613 static void SetMacAboutMenuItemId(long val
);
614 static void SetMacPreferencesMenuItemId(long val
);
615 static void SetMacExitMenuItemId(long val
);
616 static void SetMacHelpMenuTitleName(const wxString
& val
);
619 void _BootstrapApp();
621 // implementation only
622 void SetStartupComplete(bool val
) { m_startupComplete
= val
; };
626 bool m_startupComplete
;
629 extern wxPyApp
*wxPythonApp
;
632 //----------------------------------------------------------------------
633 // These macros are used to implement the virtual methods that should
634 // redirect to a Python method if one exists. The names designate the
635 // return type, if any, as well as any parameter types.
636 //---------------------------------------------------------------------------
638 #define DEC_PYCALLBACK__(CBNAME) \
643 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
644 void CLASS::CBNAME() { \
646 bool blocked = wxPyBeginBlockThreads(); \
647 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
648 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
649 wxPyEndBlockThreads(blocked); \
653 void CLASS::base_##CBNAME() { \
657 //---------------------------------------------------------------------------
659 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
660 bool CBNAME(int a, int b); \
661 bool base_##CBNAME(int a, int b)
664 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
665 bool CLASS::CBNAME(int a, int b) { \
666 bool rval=false, found; \
667 bool blocked = wxPyBeginBlockThreads(); \
668 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
669 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
670 wxPyEndBlockThreads(blocked); \
672 rval = PCLASS::CBNAME(a,b); \
675 bool CLASS::base_##CBNAME(int a, int b) { \
676 return PCLASS::CBNAME(a,b); \
679 //---------------------------------------------------------------------------
681 #define DEC_PYCALLBACK_VOID_(CBNAME) \
686 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
687 void CLASS::CBNAME() { \
689 bool blocked = wxPyBeginBlockThreads(); \
690 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
691 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
692 wxPyEndBlockThreads(blocked); \
696 void CLASS::base_##CBNAME() { \
700 //---------------------------------------------------------------------------
702 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
703 void CBNAME(int a, int b); \
704 void base_##CBNAME(int a, int b)
707 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
708 void CLASS::CBNAME(int a, int b) { \
710 bool blocked = wxPyBeginBlockThreads(); \
711 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
712 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
713 wxPyEndBlockThreads(blocked); \
715 PCLASS::CBNAME(a,b); \
717 void CLASS::base_##CBNAME(int a, int b) { \
718 PCLASS::CBNAME(a,b); \
721 //---------------------------------------------------------------------------
723 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
724 void CBNAME(int a); \
725 void base_##CBNAME(int a)
728 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
729 void CLASS::CBNAME(int a) { \
731 bool blocked = wxPyBeginBlockThreads(); \
732 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
733 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
734 wxPyEndBlockThreads(blocked); \
738 void CLASS::base_##CBNAME(int a) { \
742 //---------------------------------------------------------------------------
744 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
745 void CBNAME(int a, int b, int c, int d); \
746 void base_##CBNAME(int a, int b, int c, int d)
749 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
750 void CLASS::CBNAME(int a, int b, int c, int d) { \
752 bool blocked = wxPyBeginBlockThreads(); \
753 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
754 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
755 wxPyEndBlockThreads(blocked); \
757 PCLASS::CBNAME(a,b,c,d); \
759 void CLASS::base_##CBNAME(int a, int b, int c, int d) { \
760 PCLASS::CBNAME(a,b,c,d); \
763 //---------------------------------------------------------------------------
764 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
765 void CBNAME(int a, int b, int c, int d, int e); \
766 void base_##CBNAME(int a, int b, int c, int d, int e)
769 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
770 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
772 bool blocked = wxPyBeginBlockThreads(); \
773 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
774 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
775 wxPyEndBlockThreads(blocked); \
777 PCLASS::CBNAME(a,b,c,d,e); \
779 void CLASS::base_##CBNAME(int a, int b, int c, int d, int e) { \
780 PCLASS::CBNAME(a,b,c,d,e); \
783 //---------------------------------------------------------------------------
785 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
786 void CBNAME(int* a, int* b) const; \
787 void base_##CBNAME(int* a, int* b) const
790 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
791 void CLASS::CBNAME(int* a, int* b) const { \
792 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
794 bool blocked = wxPyBeginBlockThreads(); \
795 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
797 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
799 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
800 PyObject* o1 = PySequence_GetItem(ro, 0); \
801 PyObject* o2 = PySequence_GetItem(ro, 1); \
802 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
803 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
806 PyErr_SetString(PyExc_TypeError, errmsg); \
811 PyErr_SetString(PyExc_TypeError, errmsg); \
816 wxPyEndBlockThreads(blocked); \
818 PCLASS::CBNAME(a,b); \
820 void CLASS::base_##CBNAME(int* a, int* b) const { \
821 PCLASS::CBNAME(a,b); \
825 //---------------------------------------------------------------------------
827 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
828 wxSize CBNAME() const; \
829 wxSize base_##CBNAME() const
832 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
833 wxSize CLASS::CBNAME() const { \
834 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
835 bool found; wxSize rval(0,0); \
836 bool blocked = wxPyBeginBlockThreads(); \
837 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
839 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
841 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
842 PyObject* o1 = PySequence_GetItem(ro, 0); \
843 PyObject* o2 = PySequence_GetItem(ro, 1); \
844 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
845 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
848 PyErr_SetString(PyExc_TypeError, errmsg); \
853 PyErr_SetString(PyExc_TypeError, errmsg); \
858 wxPyEndBlockThreads(blocked); \
860 return PCLASS::CBNAME(); \
864 wxSize CLASS::base_##CBNAME() const { \
865 return PCLASS::CBNAME(); \
869 //---------------------------------------------------------------------------
871 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
872 bool CBNAME(bool a); \
873 bool base_##CBNAME(bool a)
876 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
877 bool CLASS::CBNAME(bool a) { \
878 bool rval=false, found; \
879 bool blocked = wxPyBeginBlockThreads(); \
880 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
881 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
882 wxPyEndBlockThreads(blocked); \
884 rval = PCLASS::CBNAME(a); \
887 bool CLASS::base_##CBNAME(bool a) { \
888 return PCLASS::CBNAME(a); \
891 //---------------------------------------------------------------------------
893 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
894 bool CBNAME(int a); \
895 bool base_##CBNAME(int a)
898 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
899 bool CLASS::CBNAME(int a) { \
900 bool rval=false, found; \
901 bool blocked = wxPyBeginBlockThreads(); \
902 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
903 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
904 wxPyEndBlockThreads(blocked); \
906 rval = PCLASS::CBNAME(a); \
909 bool CLASS::base_##CBNAME(int a) { \
910 return PCLASS::CBNAME(a); \
913 //---------------------------------------------------------------------------
915 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
919 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
920 bool CLASS::CBNAME(int a) { \
922 bool blocked = wxPyBeginBlockThreads(); \
923 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
924 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
926 wxPyEndBlockThreads(blocked); \
931 //---------------------------------------------------------------------------
933 #define DEC_PYCALLBACK__DC(CBNAME) \
934 void CBNAME(wxDC& a); \
935 void base_##CBNAME(wxDC& a)
938 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
939 void CLASS::CBNAME(wxDC& a) { \
941 bool blocked = wxPyBeginBlockThreads(); \
942 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
943 PyObject* obj = wxPyMake_wxObject(&a,false); \
944 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
947 wxPyEndBlockThreads(blocked); \
951 void CLASS::base_##CBNAME(wxDC& a) { \
957 //---------------------------------------------------------------------------
959 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
960 void CBNAME(wxDC& a, bool b); \
961 void base_##CBNAME(wxDC& a, bool b)
964 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
965 void CLASS::CBNAME(wxDC& a, bool b) { \
967 bool blocked = wxPyBeginBlockThreads(); \
968 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
969 PyObject* obj = wxPyMake_wxObject(&a,false); \
970 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
973 wxPyEndBlockThreads(blocked); \
975 PCLASS::CBNAME(a, b); \
977 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
978 PCLASS::CBNAME(a, b); \
981 //---------------------------------------------------------------------------
983 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
984 void CBNAME(wxDC& a, bool b); \
985 void base_##CBNAME(wxDC& a, bool b)
988 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
989 void CLASS::CBNAME(wxDC& a, bool b) { \
991 bool blocked = wxPyBeginBlockThreads(); \
992 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
993 PyObject* obj = wxPyMake_wxObject(&a,false); \
994 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
997 wxPyEndBlockThreads(blocked); \
999 PCLASS::CBNAME(a, b); \
1001 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
1002 PCLASS::CBNAME(a, b); \
1005 //---------------------------------------------------------------------------
1007 #define DEC_PYCALLBACK__2DBL(CBNAME) \
1008 void CBNAME(double a, double b); \
1009 void base_##CBNAME(double a, double b)
1012 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
1013 void CLASS::CBNAME(double a, double b) { \
1015 bool blocked = wxPyBeginBlockThreads(); \
1016 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1017 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
1018 wxPyEndBlockThreads(blocked); \
1020 PCLASS::CBNAME(a, b); \
1022 void CLASS::base_##CBNAME(double a, double b) { \
1023 PCLASS::CBNAME(a, b); \
1026 //---------------------------------------------------------------------------
1028 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
1029 void CBNAME(double a, double b, int c, int d); \
1030 void base_##CBNAME(double a, double b, int c, int d)
1033 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
1034 void CLASS::CBNAME(double a, double b, int c, int d) { \
1036 bool blocked = wxPyBeginBlockThreads(); \
1037 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1038 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
1040 wxPyEndBlockThreads(blocked); \
1042 PCLASS::CBNAME(a, b, c, d); \
1044 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
1045 PCLASS::CBNAME(a, b, c, d); \
1048 //---------------------------------------------------------------------------
1050 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
1051 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
1052 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1055 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1056 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1058 bool blocked = wxPyBeginBlockThreads(); \
1059 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1060 PyObject* obj = wxPyMake_wxObject(&a,false); \
1061 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
1064 wxPyEndBlockThreads(blocked); \
1066 PCLASS::CBNAME(a, b, c, d, e, f); \
1068 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
1069 PCLASS::CBNAME(a, b, c, d, e, f); \
1072 //---------------------------------------------------------------------------
1074 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
1075 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
1076 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1079 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1080 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1082 bool blocked = wxPyBeginBlockThreads(); \
1084 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1085 PyObject* obj = wxPyMake_wxObject(&a,false); \
1086 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1089 wxPyEndBlockThreads(blocked); \
1091 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1094 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
1095 return PCLASS::CBNAME(a, b, c, d, e, f); \
1098 //---------------------------------------------------------------------------
1100 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1101 void CBNAME(bool a, double b, double c, int d, int e); \
1102 void base_##CBNAME(bool a, double b, double c, int d, int e)
1105 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1106 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1108 bool blocked = wxPyBeginBlockThreads(); \
1109 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1110 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1112 wxPyEndBlockThreads(blocked); \
1114 PCLASS::CBNAME(a, b, c, d, e); \
1116 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
1117 PCLASS::CBNAME(a, b, c, d, e); \
1120 //---------------------------------------------------------------------------
1122 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1123 void CBNAME(wxDC& a, double b, double c, double d, double e); \
1124 void base_##CBNAME(wxDC& a, double b, double c, double d, double e)
1127 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1128 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1130 bool blocked = wxPyBeginBlockThreads(); \
1131 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1132 PyObject* obj = wxPyMake_wxObject(&a,false); \
1133 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1136 wxPyEndBlockThreads(blocked); \
1138 PCLASS::CBNAME(a, b, c, d, e); \
1140 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
1141 PCLASS::CBNAME(a, b, c, d, e); \
1144 //---------------------------------------------------------------------------
1146 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1147 void CBNAME(wxDC& a, bool b); \
1148 void base_##CBNAME(wxDC& a, bool b)
1151 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1152 void CLASS::CBNAME(wxDC& a, bool b) { \
1154 bool blocked = wxPyBeginBlockThreads(); \
1155 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1156 PyObject* obj = wxPyMake_wxObject(&a,false); \
1157 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1160 wxPyEndBlockThreads(blocked); \
1162 PCLASS::CBNAME(a, b); \
1164 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
1165 PCLASS::CBNAME(a, b); \
1168 //---------------------------------------------------------------------------
1170 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1171 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
1172 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1175 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1176 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1179 bool blocked = wxPyBeginBlockThreads(); \
1180 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1181 PyObject* obj = wxPyMake_wxObject(a,false); \
1182 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1185 wxPyEndBlockThreads(blocked); \
1187 PCLASS::CBNAME(a, b, c, d, e, f); \
1189 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
1191 PCLASS::CBNAME(a, b, c, d, e, f); \
1194 //---------------------------------------------------------------------------
1196 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1197 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
1198 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1201 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1202 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1204 bool blocked = wxPyBeginBlockThreads(); \
1205 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1206 PyObject* obj = wxPyMake_wxObject(a,false); \
1207 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1210 wxPyEndBlockThreads(blocked); \
1212 PCLASS::CBNAME(a, b, c, d, e); \
1214 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
1216 PCLASS::CBNAME(a, b, c, d, e); \
1219 //---------------------------------------------------------------------------
1221 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1222 void CBNAME(double a, double b, int c); \
1223 void base_##CBNAME(double a, double b, int c)
1226 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1227 void CLASS::CBNAME(double a, double b, int c) { \
1229 bool blocked = wxPyBeginBlockThreads(); \
1230 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1231 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1232 wxPyEndBlockThreads(blocked); \
1234 PCLASS::CBNAME(a, b, c); \
1236 void CLASS::base_##CBNAME(double a, double b, int c) { \
1237 PCLASS::CBNAME(a, b, c); \
1240 //---------------------------------------------------------------------------
1242 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1243 void CBNAME(bool a, double b, double c, int d); \
1244 void base_##CBNAME(bool a, double b, double c, int d)
1247 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1248 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1250 bool blocked = wxPyBeginBlockThreads(); \
1251 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1252 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1253 wxPyEndBlockThreads(blocked); \
1255 PCLASS::CBNAME(a, b, c, d); \
1257 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
1258 PCLASS::CBNAME(a, b, c, d); \
1261 //---------------------------------------------------------------------------
1262 //---------------------------------------------------------------------------
1264 #define DEC_PYCALLBACK__STRING(CBNAME) \
1265 void CBNAME(const wxString& a); \
1266 void base_##CBNAME(const wxString& a)
1268 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1269 void CLASS::CBNAME(const wxString& a) { \
1271 bool blocked = wxPyBeginBlockThreads(); \
1272 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1273 PyObject* s = wx2PyString(a); \
1274 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1277 wxPyEndBlockThreads(blocked); \
1279 PCLASS::CBNAME(a); \
1281 void CLASS::base_##CBNAME(const wxString& a) { \
1282 PCLASS::CBNAME(a); \
1285 //---------------------------------------------------------------------------
1287 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1288 bool CBNAME(const wxString& a); \
1289 bool base_##CBNAME(const wxString& a)
1291 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1292 bool CLASS::CBNAME(const wxString& a) { \
1295 bool blocked = wxPyBeginBlockThreads(); \
1296 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1297 PyObject* s = wx2PyString(a); \
1298 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1301 wxPyEndBlockThreads(blocked); \
1303 rval = PCLASS::CBNAME(a); \
1306 bool CLASS::base_##CBNAME(const wxString& a) { \
1307 return PCLASS::CBNAME(a); \
1310 //---------------------------------------------------------------------------
1312 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1313 bool CBNAME(const wxString& a)
1315 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1316 bool CLASS::CBNAME(const wxString& a) { \
1318 bool blocked = wxPyBeginBlockThreads(); \
1319 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1320 PyObject* s = wx2PyString(a); \
1321 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1324 wxPyEndBlockThreads(blocked); \
1328 //---------------------------------------------------------------------------
1330 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1331 wxString CBNAME(const wxString& a)
1333 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1334 wxString CLASS::CBNAME(const wxString& a) { \
1336 bool blocked = wxPyBeginBlockThreads(); \
1337 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1339 PyObject* s = wx2PyString(a); \
1340 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1343 rval = Py2wxString(ro); \
1347 wxPyEndBlockThreads(blocked); \
1351 //---------------------------------------------------------------------------
1353 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1354 wxString CBNAME(const wxString& a); \
1355 wxString base_##CBNAME(const wxString& a)
1357 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1358 wxString CLASS::CBNAME(const wxString& a) { \
1361 bool blocked = wxPyBeginBlockThreads(); \
1362 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1364 PyObject* s = wx2PyString(a); \
1365 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1368 rval = Py2wxString(ro); \
1373 rval = PCLASS::CBNAME(a); \
1374 wxPyEndBlockThreads(blocked); \
1378 //---------------------------------------------------------------------------
1380 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1381 wxString CBNAME(const wxString& a,int b)
1383 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1384 wxString CLASS::CBNAME(const wxString& a,int b) { \
1386 bool blocked = wxPyBeginBlockThreads(); \
1387 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1389 PyObject* s = wx2PyString(a); \
1390 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1393 rval = Py2wxString(ro); \
1397 wxPyEndBlockThreads(blocked); \
1401 //---------------------------------------------------------------------------
1403 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1404 bool CBNAME(const wxString& a, const wxString& b); \
1405 bool base_##CBNAME(const wxString& a, const wxString& b)
1407 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1408 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1411 bool blocked = wxPyBeginBlockThreads(); \
1412 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1413 PyObject* s1 = wx2PyString(a); \
1414 PyObject* s2 = wx2PyString(b); \
1415 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1419 wxPyEndBlockThreads(blocked); \
1421 rval = PCLASS::CBNAME(a, b); \
1424 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
1425 return PCLASS::CBNAME(a, b); \
1428 //---------------------------------------------------------------------------
1430 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1431 wxString CBNAME(); \
1432 wxString base_##CBNAME()
1434 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1435 wxString CLASS::CBNAME() { \
1438 bool blocked = wxPyBeginBlockThreads(); \
1439 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1441 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1443 rval = Py2wxString(ro); \
1447 wxPyEndBlockThreads(blocked); \
1449 rval = PCLASS::CBNAME(); \
1452 wxString CLASS::base_##CBNAME() { \
1453 return PCLASS::CBNAME(); \
1456 //---------------------------------------------------------------------------
1458 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1459 wxString CBNAME() const; \
1460 wxString base_##CBNAME() const;
1462 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1463 wxString CLASS::CBNAME() const { \
1466 bool blocked = wxPyBeginBlockThreads(); \
1467 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1469 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1471 rval = Py2wxString(ro); \
1475 wxPyEndBlockThreads(blocked); \
1477 rval = PCLASS::CBNAME(); \
1480 wxString CLASS::base_##CBNAME() const { \
1481 return PCLASS::CBNAME(); \
1484 //---------------------------------------------------------------------------
1486 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1489 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1490 wxString CLASS::CBNAME() { \
1492 bool blocked = wxPyBeginBlockThreads(); \
1493 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1495 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1497 rval = Py2wxString(ro); \
1501 wxPyEndBlockThreads(blocked); \
1505 //---------------------------------------------------------------------------
1507 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1508 wxString CBNAME() const;
1510 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1511 wxString CLASS::CBNAME() const { \
1513 bool blocked = wxPyBeginBlockThreads(); \
1514 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1516 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1518 rval = Py2wxString(ro); \
1522 wxPyEndBlockThreads(blocked); \
1526 //---------------------------------------------------------------------------
1528 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1529 bool CBNAME(const wxHtmlTag& a)
1532 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1533 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1535 bool blocked = wxPyBeginBlockThreads(); \
1536 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1537 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
1538 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1541 wxPyEndBlockThreads(blocked); \
1545 //---------------------------------------------------------------------------
1547 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1548 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \
1549 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1551 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1552 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1554 bool blocked = wxPyBeginBlockThreads(); \
1555 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1556 PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \
1557 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1560 wxPyEndBlockThreads(blocked); \
1562 PCLASS::CBNAME(cell, x, y); \
1564 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1565 PCLASS::CBNAME(cell, x, y); \
1568 //---------------------------------------------------------------------------
1570 #define DEC_PYCALLBACK__COLOUR(CBNAME) \
1571 void CBNAME(const wxColour& c); \
1572 void base_##CBNAME(const wxColour& c)
1574 #define IMP_PYCALLBACK__COLOUR(CLASS, PCLASS, CBNAME) \
1575 void CLASS::CBNAME(const wxColour& c) { \
1577 bool blocked = wxPyBeginBlockThreads(); \
1578 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1579 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1580 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1583 wxPyEndBlockThreads(blocked); \
1585 PCLASS::CBNAME(c); \
1587 void CLASS::base_##CBNAME(const wxColour& c) { \
1588 PCLASS::CBNAME(c); \
1591 //---------------------------------------------------------------------------
1593 #define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \
1594 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \
1595 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1597 #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \
1598 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1600 bool blocked = wxPyBeginBlockThreads(); \
1601 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1602 PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \
1603 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1604 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1608 wxPyEndBlockThreads(blocked); \
1610 PCLASS::CBNAME(cell, x, y, e); \
1612 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) {\
1613 PCLASS::CBNAME(cell, x, y, e); \
1618 //---------------------------------------------------------------------------
1620 #define DEC_PYCALLBACK___pure(CBNAME) \
1624 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1625 void CLASS::CBNAME() { \
1626 bool blocked = wxPyBeginBlockThreads(); \
1627 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1628 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1629 wxPyEndBlockThreads(blocked); \
1632 //---------------------------------------------------------------------------
1634 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1638 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1639 wxSize CLASS::CBNAME() { \
1640 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1642 bool blocked = wxPyBeginBlockThreads(); \
1643 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1646 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1648 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1650 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1651 PyObject* o1 = PySequence_GetItem(ro, 0); \
1652 PyObject* o2 = PySequence_GetItem(ro, 1); \
1653 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1654 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1656 PyErr_SetString(PyExc_TypeError, errmsg); \
1661 PyErr_SetString(PyExc_TypeError, errmsg); \
1666 wxPyEndBlockThreads(blocked); \
1670 //---------------------------------------------------------------------------
1672 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1673 bool CBNAME(wxWindow* a); \
1674 bool base_##CBNAME(wxWindow* a)
1677 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1678 bool CLASS::CBNAME(wxWindow* a) { \
1681 bool blocked = wxPyBeginBlockThreads(); \
1682 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1683 PyObject* obj = wxPyMake_wxObject(a,false); \
1684 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1687 wxPyEndBlockThreads(blocked); \
1689 rval = PCLASS::CBNAME(a); \
1692 bool CLASS::base_##CBNAME(wxWindow* a) { \
1693 return PCLASS::CBNAME(a); \
1696 //---------------------------------------------------------------------------
1698 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1699 bool CBNAME(wxWindow* a, wxDC& b); \
1700 bool base_##CBNAME(wxWindow* a, wxDC& b)
1703 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1704 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1707 bool blocked = wxPyBeginBlockThreads(); \
1708 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1709 PyObject* win = wxPyMake_wxObject(a,false); \
1710 PyObject* dc = wxPyMake_wxObject(&b,false); \
1711 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1715 wxPyEndBlockThreads(blocked); \
1717 rval = PCLASS::CBNAME(a, b); \
1720 bool CLASS::base_##CBNAME(wxWindow* a, wxDC& b) { \
1721 return PCLASS::CBNAME(a, b); \
1724 //---------------------------------------------------------------------------
1726 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1727 void CBNAME(wxWindowBase* a); \
1728 void base_##CBNAME(wxWindowBase* a)
1731 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1732 void CLASS::CBNAME(wxWindowBase* a) { \
1734 bool blocked = wxPyBeginBlockThreads(); \
1735 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1736 PyObject* obj = wxPyMake_wxObject(a,false); \
1737 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1740 wxPyEndBlockThreads(blocked); \
1742 PCLASS::CBNAME(a); \
1744 void CLASS::base_##CBNAME(wxWindowBase* a) { \
1745 PCLASS::CBNAME(a); \
1748 //---------------------------------------------------------------------------
1750 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1752 bool base_##CBNAME()
1755 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1756 bool CLASS::CBNAME() { \
1759 bool blocked = wxPyBeginBlockThreads(); \
1760 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1761 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1762 wxPyEndBlockThreads(blocked); \
1764 rval = PCLASS::CBNAME(); \
1767 bool CLASS::base_##CBNAME() { \
1768 return PCLASS::CBNAME(); \
1771 //---------------------------------------------------------------------------
1773 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1774 bool CBNAME() const; \
1775 bool base_##CBNAME() const
1778 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1779 bool CLASS::CBNAME() const { \
1782 bool blocked = wxPyBeginBlockThreads(); \
1783 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1784 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1785 wxPyEndBlockThreads(blocked); \
1787 rval = PCLASS::CBNAME(); \
1790 bool CLASS::base_##CBNAME() const { \
1791 return PCLASS::CBNAME(); \
1794 //---------------------------------------------------------------------------
1796 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1797 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
1798 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1801 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1802 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1805 bool blocked = wxPyBeginBlockThreads(); \
1806 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1807 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1808 wxPyEndBlockThreads(blocked); \
1810 rval = PCLASS::CBNAME(a, b, c); \
1811 return (wxDragResult)rval; \
1813 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1814 return PCLASS::CBNAME(a, b, c); \
1817 //---------------------------------------------------------------------------
1819 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1820 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1822 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1823 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1824 bool blocked = wxPyBeginBlockThreads(); \
1826 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1828 PyObject* obj = wxPyMake_wxObject(&a,false); \
1829 PyObject* s = wx2PyString(b); \
1830 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1833 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
1839 wxPyEndBlockThreads(blocked); \
1843 //---------------------------------------------------------------------------
1845 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1846 bool CBNAME(wxDragResult a); \
1847 bool base_##CBNAME(wxDragResult a)
1850 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1851 bool CLASS::CBNAME(wxDragResult a) { \
1854 bool blocked = wxPyBeginBlockThreads(); \
1855 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1856 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1857 wxPyEndBlockThreads(blocked); \
1859 rval = PCLASS::CBNAME(a); \
1862 bool CLASS::base_##CBNAME(wxDragResult a) { \
1863 return PCLASS::CBNAME(a); \
1866 //---------------------------------------------------------------------------
1868 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1869 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1872 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1873 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1874 bool blocked = wxPyBeginBlockThreads(); \
1876 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1877 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1878 wxPyEndBlockThreads(blocked); \
1879 return (wxDragResult)rval; \
1882 //---------------------------------------------------------------------------
1884 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1885 bool CBNAME(int a, int b, const wxString& c)
1887 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1888 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1890 bool blocked = wxPyBeginBlockThreads(); \
1891 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1892 PyObject* s = wx2PyString(c); \
1893 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1896 wxPyEndBlockThreads(blocked); \
1900 //---------------------------------------------------------------------------
1902 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1904 size_t base_##CBNAME()
1907 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1908 size_t CLASS::CBNAME() { \
1911 bool blocked = wxPyBeginBlockThreads(); \
1912 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1913 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1914 wxPyEndBlockThreads(blocked); \
1916 rval = PCLASS::CBNAME(); \
1919 size_t CLASS::base_##CBNAME() { \
1920 return PCLASS::CBNAME(); \
1923 //---------------------------------------------------------------------------
1925 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1926 size_t CBNAME() const; \
1927 size_t base_##CBNAME() const
1930 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1931 size_t CLASS::CBNAME() const { \
1934 bool blocked = wxPyBeginBlockThreads(); \
1935 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1936 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1937 wxPyEndBlockThreads(blocked); \
1939 rval = PCLASS::CBNAME(); \
1942 size_t CLASS::base_##CBNAME() const { \
1943 return PCLASS::CBNAME(); \
1946 //---------------------------------------------------------------------------
1948 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1949 wxDataFormat CBNAME(size_t a); \
1950 wxDataFormat base_##CBNAME(size_t a)
1953 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1954 wxDataFormat CLASS::CBNAME(size_t a) { \
1955 wxDataFormat rval=0; \
1957 bool blocked = wxPyBeginBlockThreads(); \
1958 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1960 wxDataFormat* ptr; \
1961 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1963 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1968 wxPyEndBlockThreads(blocked); \
1970 rval = PCLASS::CBNAME(a); \
1973 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1974 return PCLASS::CBNAME(a); \
1977 //---------------------------------------------------------------------------
1979 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1980 void CBNAME(const Type& a); \
1981 void base_##CBNAME(const Type& a)
1984 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1985 void CLASS::CBNAME(const Type& a) { \
1987 bool blocked = wxPyBeginBlockThreads(); \
1988 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1989 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1990 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1993 wxPyEndBlockThreads(blocked); \
1995 PCLASS::CBNAME(a); \
1997 void CLASS::base_##CBNAME(const Type& a) { \
1998 PCLASS::CBNAME(a); \
2002 //---------------------------------------------------------------------------
2004 #define DEC_PYCALLBACK__any(CBNAME, Type) \
2005 void CBNAME(Type& a); \
2006 void base_##CBNAME(Type& a)
2009 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
2010 void CLASS::CBNAME(Type& a) { \
2012 bool blocked = wxPyBeginBlockThreads(); \
2013 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2014 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2015 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2018 wxPyEndBlockThreads(blocked); \
2020 PCLASS::CBNAME(a); \
2022 void CLASS::base_##CBNAME(Type& a) { \
2023 PCLASS::CBNAME(a); \
2026 //---------------------------------------------------------------------------
2028 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
2029 bool CBNAME(Type& a); \
2030 bool base_##CBNAME(Type& a)
2033 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
2034 bool CLASS::CBNAME(Type& a) { \
2037 bool blocked = wxPyBeginBlockThreads(); \
2038 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2039 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2040 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2043 wxPyEndBlockThreads(blocked); \
2045 rv = PCLASS::CBNAME(a); \
2048 bool CLASS::base_##CBNAME(Type& a) { \
2049 return PCLASS::CBNAME(a); \
2052 //---------------------------------------------------------------------------
2054 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
2055 bool CBNAME(Type& a)
2058 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
2059 bool CLASS::CBNAME(Type& a) { \
2061 bool blocked = wxPyBeginBlockThreads(); \
2062 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2063 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2064 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2067 wxPyEndBlockThreads(blocked); \
2071 //---------------------------------------------------------------------------
2073 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
2074 wxString CBNAME(long a, long b) const; \
2075 wxString base_##CBNAME(long a, long b) const
2077 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
2078 wxString CLASS::CBNAME(long a, long b) const { \
2081 bool blocked = wxPyBeginBlockThreads(); \
2082 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2084 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2086 rval = Py2wxString(ro); \
2090 wxPyEndBlockThreads(blocked); \
2092 rval = PCLASS::CBNAME(a,b); \
2095 wxString CLASS::base_##CBNAME(long a, long b) const { \
2096 return PCLASS::CBNAME(a,b); \
2099 //---------------------------------------------------------------------------
2101 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
2102 int CBNAME(long a) const; \
2103 int base_##CBNAME(long a) const
2106 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
2107 int CLASS::CBNAME(long a) const { \
2110 bool blocked = wxPyBeginBlockThreads(); \
2111 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2113 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2115 rval = PyInt_AsLong(ro); \
2119 wxPyEndBlockThreads(blocked); \
2121 rval = PCLASS::CBNAME(a); \
2124 int CLASS::base_##CBNAME(long a) const { \
2125 return PCLASS::CBNAME(a); \
2131 #define DEC_PYCALLBACK_INT_LONG_virtual(CBNAME) \
2132 int CBNAME(long a) const;
2135 #define IMP_PYCALLBACK_INT_LONG_virtual(CLASS, PCLASS, CBNAME) \
2136 int CLASS::CBNAME(long a) const { \
2137 int rval=-1; /* this rval is important for OnGetItemImage */ \
2139 bool blocked = wxPyBeginBlockThreads(); \
2140 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2142 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2144 rval = PyInt_AsLong(ro); \
2148 wxPyEndBlockThreads(blocked); \
2153 //---------------------------------------------------------------------------
2155 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2156 wxListItemAttr* CBNAME(long a) const; \
2157 wxListItemAttr* base_##CBNAME(long a) const
2160 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2161 wxListItemAttr *CLASS::CBNAME(long a) const { \
2162 wxListItemAttr *rval = NULL; \
2164 bool blocked = wxPyBeginBlockThreads(); \
2165 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2167 wxListItemAttr* ptr; \
2168 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2170 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2175 wxPyEndBlockThreads(blocked); \
2177 rval = PCLASS::CBNAME(a); \
2180 wxListItemAttr *CLASS::base_##CBNAME(long a) const { \
2181 return PCLASS::CBNAME(a); \
2184 //---------------------------------------------------------------------------
2186 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2187 bool CBNAME(wxMouseEvent& e); \
2188 bool base_##CBNAME(wxMouseEvent& e)
2190 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2191 bool CLASS::CBNAME(wxMouseEvent& e) { \
2194 bool blocked = wxPyBeginBlockThreads(); \
2195 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2197 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2198 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2200 rval = PyInt_AsLong(ro); \
2205 wxPyEndBlockThreads(blocked); \
2207 return PCLASS::CBNAME(e); \
2210 bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
2211 return PCLASS::CBNAME(e); \
2215 //---------------------------------------------------------------------------
2217 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2218 wxWizardPage* CBNAME() const
2220 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2221 wxWizardPage* CLASS::CBNAME() const { \
2222 wxWizardPage* rv = NULL; \
2223 bool blocked = wxPyBeginBlockThreads(); \
2224 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2226 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2228 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2232 wxPyEndBlockThreads(blocked); \
2236 //---------------------------------------------------------------------------
2238 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2239 wxBitmap CBNAME() const
2241 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2242 wxBitmap CLASS::CBNAME() const { \
2244 bool blocked = wxPyBeginBlockThreads(); \
2245 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2248 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2250 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2255 wxPyEndBlockThreads(blocked); \
2259 //---------------------------------------------------------------------------
2261 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2264 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2265 wxObject* CLASS::CBNAME() { \
2266 wxObject* rv = NULL; \
2267 bool blocked = wxPyBeginBlockThreads(); \
2268 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2270 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2272 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2276 wxPyEndBlockThreads(blocked); \
2280 //---------------------------------------------------------------------------
2282 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2283 wxObject* CBNAME(const wxString& a)
2285 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2286 wxObject* CLASS::CBNAME(const wxString& a) { \
2287 wxObject* rv = NULL; \
2288 bool blocked = wxPyBeginBlockThreads(); \
2289 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2290 PyObject* so = wx2PyString(a); \
2292 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2294 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2299 wxPyEndBlockThreads(blocked); \
2303 //---------------------------------------------------------------------------
2305 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2306 bool CBNAME(wxXmlNode* a)
2309 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2310 bool CLASS::CBNAME(wxXmlNode* a) { \
2312 bool blocked = wxPyBeginBlockThreads(); \
2313 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2314 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2315 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2318 wxPyEndBlockThreads(blocked); \
2322 //---------------------------------------------------------------------------
2324 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2325 wxCoord CBNAME(size_t a) const
2328 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2329 wxCoord CLASS::CBNAME(size_t a) const { \
2332 bool blocked = wxPyBeginBlockThreads(); \
2333 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2334 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2336 wxPyEndBlockThreads(blocked); \
2340 //---------------------------------------------------------------------------
2342 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2343 void CBNAME(size_t a, size_t b) const; \
2344 void base_##CBNAME(size_t a, size_t b) const
2347 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2348 void CLASS::CBNAME(size_t a, size_t b) const { \
2350 bool blocked = wxPyBeginBlockThreads(); \
2351 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2352 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2353 wxPyEndBlockThreads(blocked); \
2355 PCLASS::CBNAME(a,b); \
2357 void CLASS::base_##CBNAME(size_t a, size_t b) const { \
2358 PCLASS::CBNAME(a,b); \
2361 //---------------------------------------------------------------------------
2363 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2364 wxCoord CBNAME() const; \
2365 wxCoord base_##CBNAME() const
2368 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2369 wxCoord CLASS::CBNAME() const { \
2372 bool blocked = wxPyBeginBlockThreads(); \
2373 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2374 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2375 wxPyEndBlockThreads(blocked); \
2377 rval = PCLASS::CBNAME(); \
2380 wxCoord CLASS::base_##CBNAME() const { \
2381 return PCLASS::CBNAME(); \
2384 //---------------------------------------------------------------------------
2386 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2387 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2390 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2391 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2393 bool blocked = wxPyBeginBlockThreads(); \
2394 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2395 PyObject* obj = wxPyMake_wxObject(&a,false); \
2396 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2397 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2400 wxPyEndBlockThreads(blocked); \
2403 //---------------------------------------------------------------------------
2405 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2406 void CBNAME(wxDC& a, const wxRect& b, size_t c) const; \
2407 void base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const
2410 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2411 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2413 bool blocked = wxPyBeginBlockThreads(); \
2414 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2415 PyObject* obj = wxPyMake_wxObject(&a,false); \
2416 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2417 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2420 wxPyEndBlockThreads(blocked); \
2422 PCLASS::CBNAME(a,b,c); \
2424 void CLASS::base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2425 PCLASS::CBNAME(a,b,c); \
2428 //---------------------------------------------------------------------------
2431 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2432 wxString CBNAME(size_t a) const; \
2433 wxString base_##CBNAME(size_t a) const
2435 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2436 wxString CLASS::CBNAME(size_t a) const { \
2439 bool blocked = wxPyBeginBlockThreads(); \
2440 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2442 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2444 rval = Py2wxString(ro); \
2448 wxPyEndBlockThreads(blocked); \
2450 rval = PCLASS::CBNAME(a); \
2453 wxString CLASS::base_##CBNAME(size_t a) const { \
2454 return PCLASS::CBNAME(a); \
2457 //---------------------------------------------------------------------------
2459 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2460 wxString CBNAME(size_t a) const
2462 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2463 wxString CLASS::CBNAME(size_t a) const { \
2466 bool blocked = wxPyBeginBlockThreads(); \
2467 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2469 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2471 rval = Py2wxString(ro); \
2475 wxPyEndBlockThreads(blocked); \
2479 //---------------------------------------------------------------------------
2481 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2482 wxVisualAttributes CBNAME() const; \
2483 wxVisualAttributes base_##CBNAME()
2486 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2487 wxVisualAttributes CLASS::CBNAME() const { \
2488 wxVisualAttributes rval; \
2490 bool blocked = wxPyBeginBlockThreads(); \
2491 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2493 wxVisualAttributes* ptr; \
2494 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2496 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2501 wxPyEndBlockThreads(blocked); \
2503 rval = PCLASS::CBNAME(); \
2506 wxVisualAttributes CLASS::base_##CBNAME() { \
2507 return PCLASS::CBNAME(); \
2510 //---------------------------------------------------------------------------