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/dcmirror.h>
29 #include <wx/dirctrl.h>
30 #include <wx/dirdlg.h>
32 #include <wx/docview.h>
33 #include <wx/encconv.h>
34 #include <wx/fdrepdlg.h>
35 #include <wx/fileconf.h>
36 #include <wx/filesys.h>
37 #include <wx/fontdlg.h>
38 #include <wx/fs_inet.h>
39 #include <wx/fs_mem.h>
40 #include <wx/fs_zip.h>
41 #include <wx/gbsizer.h>
42 #include <wx/geometry.h>
43 #include <wx/htmllbox.h>
45 #include <wx/imaglist.h>
47 #include <wx/laywin.h>
48 #include <wx/listbook.h>
49 #include <wx/minifram.h>
50 #include <wx/notebook.h>
52 #include <wx/printdlg.h>
53 #include <wx/process.h>
54 #include <wx/progdlg.h>
55 #include <wx/sashwin.h>
56 #include <wx/spinbutt.h>
57 #include <wx/spinctrl.h>
58 #include <wx/splash.h>
59 #include <wx/splitter.h>
60 #include <wx/statline.h>
61 #include <wx/stream.h>
62 #include <wx/sysopt.h>
63 #include <wx/taskbar.h>
64 #include <wx/tglbtn.h>
65 #include <wx/tipwin.h>
66 #include <wx/tooltip.h>
68 #include <wx/vscroll.h>
72 # pragma warning(disable:4800)
73 # pragma warning(disable:4190)
76 #ifdef __WXMAC__ // avoid a bug in Carbon headers
80 //---------------------------------------------------------------------------
82 typedef unsigned char byte
;
83 typedef wxPoint2DDouble wxPoint2D
;
85 const bool True
= true;
86 const bool False
= false;
89 #ifndef wxPyUSE_EXPORTED_API
91 void __wxPyPreStart(PyObject
*);
93 PyObject
* __wxPySetDictionary(PyObject
*, PyObject
* args
);
94 PyObject
* __wxPyFixStockObjects(PyObject
*, PyObject
* args
);
97 void wxPyEventThunker(wxObject
*, wxEvent
& event
);
100 bool wxPyCheckSwigType(const wxChar
* className
);
101 PyObject
* wxPyConstructObject(void* ptr
,
102 const wxChar
* className
,
104 bool wxPyConvertSwigPtr(PyObject
* obj
, void **ptr
,
105 const wxChar
* className
);
106 PyObject
* wxPyMakeSwigPtr(void* ptr
, const wxChar
* classname
);
109 PyObject
* wx2PyString(const wxString
& src
);
110 wxString
Py2wxString(PyObject
* source
);
112 PyObject
* wxPyMake_wxObject(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
=True
);
113 PyObject
* wxPyMake_wxSizer(wxSizer
* source
, bool setThisOwn
);
114 void wxPyPtrTypeMap_Add(const char* commonName
, const char* ptrName
);
116 PyObject
* wxPy_ConvertList(wxListBase
* list
);
117 long wxPyGetWinHandle(wxWindow
* win
);
119 void wxPy_ReinitStockObjects(int pass
);
121 bool wxPyInstance_Check(PyObject
* obj
);
122 bool wxPySwigInstance_Check(PyObject
* obj
);
125 #endif // wxPyUSE_EXPORTED_API
126 //---------------------------------------------------------------------------
128 // if we want to handle threads and Python threads are available...
129 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
130 #define WXP_WITH_THREAD
131 #else // no Python threads...
132 #undef WXP_WITH_THREAD
135 #ifndef wxPyUSE_EXPORTED_API
137 // For Python --> C++
138 PyThreadState
* wxPyBeginAllowThreads();
139 void wxPyEndAllowThreads(PyThreadState
* state
);
141 // For C++ --> Python
142 bool wxPyBeginBlockThreads();
143 void wxPyEndBlockThreads(bool blocked
);
145 #endif // wxPyUSE_EXPORTED_API
148 // A macro that will help to execute simple statments wrapped in
149 // StartBlock/EndBlockThreads calls
150 #define wxPyBLOCK_THREADS(stmt) \
151 { bool blocked = wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads(blocked); }
153 // Raise the NotImplementedError exception (blocking threads)
154 #define wxPyRaiseNotImplemented() \
155 wxPyBLOCK_THREADS(PyErr_SetNone(PyExc_NotImplementedError))
157 // Raise any exception witha string value (blocking threads)
158 #define wxPyErr_SetString(err, str) \
159 wxPyBLOCK_THREADS(PyErr_SetString(err, str))
162 //---------------------------------------------------------------------------
163 // These are helpers used by the typemaps
165 #ifndef wxPyUSE_EXPORTED_API
167 wxString
* wxString_in_helper(PyObject
* source
);
169 byte
* byte_LIST_helper(PyObject
* source
);
170 int* int_LIST_helper(PyObject
* source
);
171 long* long_LIST_helper(PyObject
* source
);
172 char** string_LIST_helper(PyObject
* source
);
173 wxPoint
* wxPoint_LIST_helper(PyObject
* source
, int* npoints
);
174 wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
175 wxString
* wxString_LIST_helper(PyObject
* source
);
176 wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
177 wxPen
** wxPen_LIST_helper(PyObject
* source
);
179 bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
180 bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
181 bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
182 bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
183 bool wxColour_helper(PyObject
* source
, wxColour
** obj
);
184 bool wxPoint2D_helper(PyObject
* source
, wxPoint2D
** obj
);
187 bool wxPySimple_typecheck(PyObject
* source
, const wxChar
* classname
, int seqLen
);
188 bool wxColour_typecheck(PyObject
* source
);
190 bool wxPyCheckForApp();
194 bool wxPyTwoIntItem_helper(PyObject
* source
, T
** obj
, const wxChar
* name
)
196 // If source is an object instance then it may already be the right type
197 if (wxPySwigInstance_Check(source
)) {
199 if (! wxPyConvertSwigPtr(source
, (void **)&ptr
, name
))
204 // otherwise a 2-tuple of integers is expected
205 else if (PySequence_Check(source
) && PyObject_Length(source
) == 2) {
206 PyObject
* o1
= PySequence_GetItem(source
, 0);
207 PyObject
* o2
= PySequence_GetItem(source
, 1);
208 if (!PyNumber_Check(o1
) || !PyNumber_Check(o2
)) {
213 **obj
= T(PyInt_AsLong(o1
), PyInt_AsLong(o2
));
221 msg
.Printf(wxT("Expected a 2-tuple of integers or a %s object."), name
);
222 PyErr_SetString(PyExc_TypeError
, msg
.mb_str());
228 // Other helpful stuff
229 bool wxPy2int_seq_helper(PyObject
* source
, int* i1
, int* i2
);
230 bool wxPy4int_seq_helper(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
232 PyObject
* wxArrayString2PyList_helper(const wxArrayString
& arr
);
233 PyObject
* wxArrayInt2PyList_helper(const wxArrayInt
& arr
);
235 #endif // wxPyUSE_EXPORTED_API
237 //---------------------------------------------------------------------------
239 #if PYTHON_API_VERSION < 1009
240 #define PySequence_Fast_GET_ITEM(o, i) \
241 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
244 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
245 #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name)
246 #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val)
248 //---------------------------------------------------------------------------
250 #ifndef wxPyUSE_EXPORTED_API
252 class wxPyCallback
: public wxObject
{
253 DECLARE_ABSTRACT_CLASS(wxPyCallback
);
255 wxPyCallback(PyObject
* func
);
256 wxPyCallback(const wxPyCallback
& other
);
259 void EventThunker(wxEvent
& event
);
264 #endif // wxPyUSE_EXPORTED_API
265 //---------------------------------------------------------------------------
266 //---------------------------------------------------------------------------
267 // These Event classes can be derived from in Python and passed through the
268 // event system without loosing anything. They do this by keeping a reference
269 // to themselves and some special case handling in wxPyCallback::EventThunker.
273 class wxPyEvtSelfRef
{
278 void SetSelf(PyObject
* self
, bool clone
=False
);
279 PyObject
* GetSelf() const;
280 bool GetCloned() const { return m_cloned
; }
288 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
289 DECLARE_ABSTRACT_CLASS(wxPyEvent
)
291 wxPyEvent(int winid
=0, wxEventType commandType
= wxEVT_NULL
);
292 wxPyEvent(const wxPyEvent
& evt
);
295 virtual wxEvent
* Clone() const { return new wxPyEvent(*this); }
299 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
300 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent
)
302 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
303 wxPyCommandEvent(const wxPyCommandEvent
& evt
);
306 virtual wxEvent
* Clone() const { return new wxPyCommandEvent(*this); }
311 //----------------------------------------------------------------------
312 // Forward decalre a few things used in the exported API
313 class wxPyClientData
;
315 class wxPyOORClientData
;
316 class wxPyCBInputStream
;
318 void wxPyClientData_dtor(wxPyClientData
* self
);
319 void wxPyUserData_dtor(wxPyUserData
* self
);
320 void wxPyOORClientData_dtor(wxPyOORClientData
* self
);
321 wxPyCBInputStream
* wxPyCBInputStream_create(PyObject
*py
, bool block
);
324 //---------------------------------------------------------------------------
325 // Export a C API in a struct. Other modules will be able to load this from
326 // the wx.core module and will then have safe access to these functions, even if
327 // in another shared library.
329 class wxPyCallbackHelper
;
330 struct swig_type_info
;
331 struct swig_const_info
;
333 typedef double (*py_objasdbl_conv
)(PyObject
*obj
);
335 // Make SunCC happy and make typedef's for these that are extern "C"
336 typedef swig_type_info
* (*p_SWIG_Python_TypeRegister_t
)(swig_type_info
*);
337 typedef swig_type_info
* (*p_SWIG_Python_TypeCheck_t
)(char *c
, swig_type_info
*);
338 typedef void* (*p_SWIG_Python_TypeCast_t
)(swig_type_info
*, void *);
339 typedef swig_type_info
* (*p_SWIG_Python_TypeDynamicCast_t
)(swig_type_info
*, void **);
340 typedef const char* (*p_SWIG_Python_TypeName_t
)(const swig_type_info
*);
341 typedef const char * (*p_SWIG_Python_TypePrettyName_t
)(const swig_type_info
*);
342 typedef swig_type_info
* (*p_SWIG_Python_TypeQuery_t
)(const char *);
343 typedef void (*p_SWIG_Python_TypeClientData_t
)(swig_type_info
*, void *);
344 typedef PyObject
* (*p_SWIG_Python_newvarlink_t
)(void);
345 typedef void (*p_SWIG_Python_addvarlink_t
)(PyObject
*, char *, PyObject
*(*)(void), int (*)(PyObject
*));
346 typedef int (*p_SWIG_Python_ConvertPtr_t
)(PyObject
*, void **, swig_type_info
*, int);
347 typedef int (*p_SWIG_Python_ConvertPacked_t
)(PyObject
*, void *, int sz
, swig_type_info
*, int);
348 typedef char* (*p_SWIG_Python_PackData_t
)(char *c
, void *, int);
349 typedef char* (*p_SWIG_Python_UnpackData_t
)(char *c
, void *, int);
350 typedef PyObject
* (*p_SWIG_Python_NewPointerObj_t
)(void *, swig_type_info
*,int own
);
351 typedef PyObject
* (*p_SWIG_Python_NewPackedObj_t
)(void *, int sz
, swig_type_info
*);
352 typedef void (*p_SWIG_Python_InstallConstants_t
)(PyObject
*d
, swig_const_info constants
[]);
353 typedef void* (*p_SWIG_Python_MustGetPtr_t
)(PyObject
*, swig_type_info
*, int, int);
358 p_SWIG_Python_TypeRegister_t p_SWIG_Python_TypeRegister
;
359 p_SWIG_Python_TypeCheck_t p_SWIG_Python_TypeCheck
;
360 p_SWIG_Python_TypeCast_t p_SWIG_Python_TypeCast
;
361 p_SWIG_Python_TypeDynamicCast_t p_SWIG_Python_TypeDynamicCast
;
362 p_SWIG_Python_TypeName_t p_SWIG_Python_TypeName
;
363 p_SWIG_Python_TypePrettyName_t p_SWIG_Python_TypePrettyName
;
364 p_SWIG_Python_TypeQuery_t p_SWIG_Python_TypeQuery
;
365 p_SWIG_Python_TypeClientData_t p_SWIG_Python_TypeClientData
;
366 p_SWIG_Python_newvarlink_t p_SWIG_Python_newvarlink
;
367 p_SWIG_Python_addvarlink_t p_SWIG_Python_addvarlink
;
368 p_SWIG_Python_ConvertPtr_t p_SWIG_Python_ConvertPtr
;
369 p_SWIG_Python_ConvertPacked_t p_SWIG_Python_ConvertPacked
;
370 p_SWIG_Python_PackData_t p_SWIG_Python_PackData
;
371 p_SWIG_Python_UnpackData_t p_SWIG_Python_UnpackData
;
372 p_SWIG_Python_NewPointerObj_t p_SWIG_Python_NewPointerObj
;
373 p_SWIG_Python_NewPackedObj_t p_SWIG_Python_NewPackedObj
;
374 p_SWIG_Python_InstallConstants_t p_SWIG_Python_InstallConstants
;
375 p_SWIG_Python_MustGetPtr_t p_SWIG_Python_MustGetPtr
;
377 bool (*p_wxPyCheckSwigType
)(const wxChar
* className
);
378 PyObject
* (*p_wxPyConstructObject
)(void* ptr
, const wxChar
* className
, int setThisOwn
);
379 bool (*p_wxPyConvertSwigPtr
)(PyObject
* obj
, void **ptr
, const wxChar
* className
);
380 PyObject
* (*p_wxPyMakeSwigPtr
)(void* ptr
, const wxChar
* className
);
382 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
383 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
384 bool (*p_wxPyBeginBlockThreads
)();
385 void (*p_wxPyEndBlockThreads
)(bool blocked
);
387 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
);
389 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
390 wxString (*p_Py2wxString
)(PyObject
* source
);
391 PyObject
* (*p_wx2PyString
)(const wxString
& src
);
393 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
394 int* (*p_int_LIST_helper
)(PyObject
* source
);
395 long* (*p_long_LIST_helper
)(PyObject
* source
);
396 char** (*p_string_LIST_helper
)(PyObject
* source
);
397 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
398 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
399 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
400 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
402 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
403 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
404 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
405 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
406 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
407 bool (*p_wxPoint2D_helper
)(PyObject
* source
, wxPoint2DDouble
** obj
);
410 bool (*p_wxPySimple_typecheck
)(PyObject
* source
, const wxChar
* classname
, int seqLen
);
411 bool (*p_wxColour_typecheck
)(PyObject
* source
);
413 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
414 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
);
415 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
416 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
417 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
419 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
);
420 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
, bool setThisOwn
);
421 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
422 bool (*p_wxPy2int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
);
423 bool (*p_wxPy4int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
424 PyObject
* (*p_wxArrayString2PyList_helper
)(const wxArrayString
& arr
);
425 PyObject
* (*p_wxArrayInt2PyList_helper
)(const wxArrayInt
& arr
);
427 void (*p_wxPyClientData_dtor
)(wxPyClientData
*);
428 void (*p_wxPyUserData_dtor
)(wxPyUserData
*);
429 void (*p_wxPyOORClientData_dtor
)(wxPyOORClientData
*);
431 wxPyCBInputStream
* (*p_wxPyCBInputStream_create
)(PyObject
*py
, bool block
);
433 bool (*p_wxPyInstance_Check
)(PyObject
* obj
);
434 bool (*p_wxPySwigInstance_Check
)(PyObject
* obj
);
436 bool (*p_wxPyCheckForApp
)();
440 #ifdef wxPyUSE_EXPORTED_API
441 // Notice that this is static, not extern. This is by design, each module
442 // needs one, but doesn't have to use it.
443 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
;
444 inline wxPyCoreAPI
* wxPyGetCoreAPIPtr();
445 #endif // wxPyUSE_EXPORTED_API
447 //---------------------------------------------------------------------------
449 // A wxObject that holds a reference to a Python object
450 class wxPyUserData
: public wxObject
{
452 wxPyUserData(PyObject
* obj
) {
458 #ifdef wxPyUSE_EXPORTED_API
459 wxPyGetCoreAPIPtr()->p_wxPyUserData_dtor(this);
461 wxPyUserData_dtor(this);
468 // A wxClientData that holds a refernece to a Python object
469 class wxPyClientData
: public wxClientData
{
471 wxPyClientData(PyObject
* obj
) {
477 #ifdef wxPyUSE_EXPORTED_API
478 wxPyGetCoreAPIPtr()->p_wxPyClientData_dtor(this);
480 wxPyClientData_dtor(this);
487 // Just like wxPyClientData, except when this object is destroyed it does some
488 // OOR magic on the Python Object.
489 class wxPyOORClientData
: public wxPyClientData
{
491 wxPyOORClientData(PyObject
* obj
)
492 : wxPyClientData(obj
) {}
494 ~wxPyOORClientData() {
495 #ifdef wxPyUSE_EXPORTED_API
496 wxPyGetCoreAPIPtr()->p_wxPyOORClientData_dtor(this);
498 wxPyOORClientData_dtor(this);
504 //---------------------------------------------------------------------------
505 // This class holds an instance of a Python Shadow Class object and assists
506 // with looking up and invoking Python callback methods from C++ virtual
507 // method redirections. For all classes which have virtuals which should be
508 // overridable in wxPython, a new subclass is created that contains a
509 // wxPyCallbackHelper.
512 class wxPyCallbackHelper
{
514 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
516 wxPyCallbackHelper() {
523 ~wxPyCallbackHelper() {
524 #ifdef wxPyUSE_EXPORTED_API
525 wxPyGetCoreAPIPtr()->p_wxPyCBH_delete(this);
527 wxPyCBH_delete(this);
531 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=True
);
532 bool findCallback(const char* name
) const;
533 int callCallback(PyObject
* argTuple
) const;
534 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
535 PyObject
* GetLastFound() const { return m_lastFound
; }
540 PyObject
* m_lastFound
;
543 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
547 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
548 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
);
549 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
550 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
551 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
556 //---------------------------------------------------------------------------
558 // This is used in C++ classes that need to be able to make callback to
559 // "overloaded" python methods
562 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
563 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
565 private: wxPyCallbackHelper m_myInst
568 //---------------------------------------------------------------------------
569 // The wxPythonApp class
572 wxPYAPP_ASSERT_SUPPRESS
= 1,
573 wxPYAPP_ASSERT_EXCEPTION
= 2,
574 wxPYAPP_ASSERT_DIALOG
= 4,
575 wxPYAPP_ASSERT_LOG
= 8
578 class wxPyApp
: public wxApp
580 DECLARE_ABSTRACT_CLASS(wxPyApp
);
588 int GetAssertMode() { return m_assertMode
; }
589 void SetAssertMode(int mode
) { m_assertMode
= mode
; }
591 virtual bool OnInitGui();
592 virtual int OnExit();
594 virtual void OnAssert(const wxChar
*file
,
599 // virtual int FilterEvent(wxEvent& event); // This one too????
601 // For catching Apple Events
602 virtual void MacOpenFile(const wxString
&fileName
);
603 virtual void MacPrintFile(const wxString
&fileName
);
604 virtual void MacNewFile();
605 virtual void MacReopenApp();
607 static bool GetMacSupportPCMenuShortcuts();
608 static long GetMacAboutMenuItemId();
609 static long GetMacPreferencesMenuItemId();
610 static long GetMacExitMenuItemId();
611 static wxString
GetMacHelpMenuTitleName();
613 static void SetMacSupportPCMenuShortcuts(bool val
);
614 static void SetMacAboutMenuItemId(long val
);
615 static void SetMacPreferencesMenuItemId(long val
);
616 static void SetMacExitMenuItemId(long val
);
617 static void SetMacHelpMenuTitleName(const wxString
& val
);
620 void _BootstrapApp();
622 // implementation only
623 void SetStartupComplete(bool val
) { m_startupComplete
= val
; };
627 bool m_startupComplete
;
630 extern wxPyApp
*wxPythonApp
;
633 //----------------------------------------------------------------------
634 // These macros are used to implement the virtual methods that should
635 // redirect to a Python method if one exists. The names designate the
636 // return type, if any, as well as any parameter types.
637 //---------------------------------------------------------------------------
639 #define DEC_PYCALLBACK__(CBNAME) \
644 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
645 void CLASS::CBNAME() { \
647 bool blocked = wxPyBeginBlockThreads(); \
648 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
649 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
650 wxPyEndBlockThreads(blocked); \
654 void CLASS::base_##CBNAME() { \
658 //---------------------------------------------------------------------------
660 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
661 bool CBNAME(int a, int b); \
662 bool base_##CBNAME(int a, int b)
665 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
666 bool CLASS::CBNAME(int a, int b) { \
667 bool rval=False, found; \
668 bool blocked = wxPyBeginBlockThreads(); \
669 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
670 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
671 wxPyEndBlockThreads(blocked); \
673 rval = PCLASS::CBNAME(a,b); \
676 bool CLASS::base_##CBNAME(int a, int b) { \
677 return PCLASS::CBNAME(a,b); \
680 //---------------------------------------------------------------------------
682 #define DEC_PYCALLBACK_VOID_(CBNAME) \
687 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
688 void CLASS::CBNAME() { \
690 bool blocked = wxPyBeginBlockThreads(); \
691 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
692 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
693 wxPyEndBlockThreads(blocked); \
697 void CLASS::base_##CBNAME() { \
701 //---------------------------------------------------------------------------
703 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
704 void CBNAME(int a, int b); \
705 void base_##CBNAME(int a, int b)
708 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
709 void CLASS::CBNAME(int a, int b) { \
711 bool blocked = wxPyBeginBlockThreads(); \
712 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
713 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
714 wxPyEndBlockThreads(blocked); \
716 PCLASS::CBNAME(a,b); \
718 void CLASS::base_##CBNAME(int a, int b) { \
719 PCLASS::CBNAME(a,b); \
722 //---------------------------------------------------------------------------
724 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
725 void CBNAME(int a); \
726 void base_##CBNAME(int a)
729 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
730 void CLASS::CBNAME(int a) { \
732 bool blocked = wxPyBeginBlockThreads(); \
733 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
734 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
735 wxPyEndBlockThreads(blocked); \
739 void CLASS::base_##CBNAME(int a) { \
743 //---------------------------------------------------------------------------
745 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
746 void CBNAME(int a, int b, int c, int d); \
747 void base_##CBNAME(int a, int b, int c, int d)
750 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
751 void CLASS::CBNAME(int a, int b, int c, int d) { \
753 bool blocked = wxPyBeginBlockThreads(); \
754 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
755 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
756 wxPyEndBlockThreads(blocked); \
758 PCLASS::CBNAME(a,b,c,d); \
760 void CLASS::base_##CBNAME(int a, int b, int c, int d) { \
761 PCLASS::CBNAME(a,b,c,d); \
764 //---------------------------------------------------------------------------
765 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
766 void CBNAME(int a, int b, int c, int d, int e); \
767 void base_##CBNAME(int a, int b, int c, int d, int e)
770 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
771 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
773 bool blocked = wxPyBeginBlockThreads(); \
774 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
775 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
776 wxPyEndBlockThreads(blocked); \
778 PCLASS::CBNAME(a,b,c,d,e); \
780 void CLASS::base_##CBNAME(int a, int b, int c, int d, int e) { \
781 PCLASS::CBNAME(a,b,c,d,e); \
784 //---------------------------------------------------------------------------
786 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
787 void CBNAME(int* a, int* b) const; \
788 void base_##CBNAME(int* a, int* b) const
791 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
792 void CLASS::CBNAME(int* a, int* b) const { \
793 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
795 bool blocked = wxPyBeginBlockThreads(); \
796 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
798 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
800 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
801 PyObject* o1 = PySequence_GetItem(ro, 0); \
802 PyObject* o2 = PySequence_GetItem(ro, 1); \
803 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
804 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
807 PyErr_SetString(PyExc_TypeError, errmsg); \
812 PyErr_SetString(PyExc_TypeError, errmsg); \
817 wxPyEndBlockThreads(blocked); \
819 PCLASS::CBNAME(a,b); \
821 void CLASS::base_##CBNAME(int* a, int* b) const { \
822 PCLASS::CBNAME(a,b); \
826 //---------------------------------------------------------------------------
828 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
829 wxSize CBNAME() const; \
830 wxSize base_##CBNAME() const
833 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
834 wxSize CLASS::CBNAME() const { \
835 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
836 bool found; wxSize rval(0,0); \
837 bool blocked = wxPyBeginBlockThreads(); \
838 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
840 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
842 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
843 PyObject* o1 = PySequence_GetItem(ro, 0); \
844 PyObject* o2 = PySequence_GetItem(ro, 1); \
845 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
846 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
849 PyErr_SetString(PyExc_TypeError, errmsg); \
854 PyErr_SetString(PyExc_TypeError, errmsg); \
859 wxPyEndBlockThreads(blocked); \
861 return PCLASS::CBNAME(); \
865 wxSize CLASS::base_##CBNAME() const { \
866 return PCLASS::CBNAME(); \
870 //---------------------------------------------------------------------------
872 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
873 bool CBNAME(bool a); \
874 bool base_##CBNAME(bool a)
877 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
878 bool CLASS::CBNAME(bool a) { \
879 bool rval=False, found; \
880 bool blocked = wxPyBeginBlockThreads(); \
881 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
882 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
883 wxPyEndBlockThreads(blocked); \
885 rval = PCLASS::CBNAME(a); \
888 bool CLASS::base_##CBNAME(bool a) { \
889 return PCLASS::CBNAME(a); \
892 //---------------------------------------------------------------------------
894 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
895 bool CBNAME(int a); \
896 bool base_##CBNAME(int a)
899 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
900 bool CLASS::CBNAME(int a) { \
901 bool rval=False, found; \
902 bool blocked = wxPyBeginBlockThreads(); \
903 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
904 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
905 wxPyEndBlockThreads(blocked); \
907 rval = PCLASS::CBNAME(a); \
910 bool CLASS::base_##CBNAME(int a) { \
911 return PCLASS::CBNAME(a); \
914 //---------------------------------------------------------------------------
916 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
920 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
921 bool CLASS::CBNAME(int a) { \
923 bool blocked = wxPyBeginBlockThreads(); \
924 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
925 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
927 wxPyEndBlockThreads(blocked); \
932 //---------------------------------------------------------------------------
934 #define DEC_PYCALLBACK__DC(CBNAME) \
935 void CBNAME(wxDC& a); \
936 void base_##CBNAME(wxDC& a)
939 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
940 void CLASS::CBNAME(wxDC& a) { \
942 bool blocked = wxPyBeginBlockThreads(); \
943 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
944 PyObject* obj = wxPyMake_wxObject(&a,false); \
945 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
948 wxPyEndBlockThreads(blocked); \
952 void CLASS::base_##CBNAME(wxDC& a) { \
958 //---------------------------------------------------------------------------
960 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
961 void CBNAME(wxDC& a, bool b); \
962 void base_##CBNAME(wxDC& a, bool b)
965 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
966 void CLASS::CBNAME(wxDC& a, bool b) { \
968 bool blocked = wxPyBeginBlockThreads(); \
969 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
970 PyObject* obj = wxPyMake_wxObject(&a,false); \
971 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
974 wxPyEndBlockThreads(blocked); \
976 PCLASS::CBNAME(a, b); \
978 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
979 PCLASS::CBNAME(a, b); \
982 //---------------------------------------------------------------------------
984 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
985 void CBNAME(wxDC& a, bool b); \
986 void base_##CBNAME(wxDC& a, bool b)
989 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
990 void CLASS::CBNAME(wxDC& a, bool b) { \
992 bool blocked = wxPyBeginBlockThreads(); \
993 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
994 PyObject* obj = wxPyMake_wxObject(&a,false); \
995 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
998 wxPyEndBlockThreads(blocked); \
1000 PCLASS::CBNAME(a, b); \
1002 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
1003 PCLASS::CBNAME(a, b); \
1006 //---------------------------------------------------------------------------
1008 #define DEC_PYCALLBACK__2DBL(CBNAME) \
1009 void CBNAME(double a, double b); \
1010 void base_##CBNAME(double a, double b)
1013 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
1014 void CLASS::CBNAME(double a, double b) { \
1016 bool blocked = wxPyBeginBlockThreads(); \
1017 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1018 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
1019 wxPyEndBlockThreads(blocked); \
1021 PCLASS::CBNAME(a, b); \
1023 void CLASS::base_##CBNAME(double a, double b) { \
1024 PCLASS::CBNAME(a, b); \
1027 //---------------------------------------------------------------------------
1029 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
1030 void CBNAME(double a, double b, int c, int d); \
1031 void base_##CBNAME(double a, double b, int c, int d)
1034 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
1035 void CLASS::CBNAME(double a, double b, int c, int d) { \
1037 bool blocked = wxPyBeginBlockThreads(); \
1038 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1039 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
1041 wxPyEndBlockThreads(blocked); \
1043 PCLASS::CBNAME(a, b, c, d); \
1045 void CLASS::base_##CBNAME(double a, double b, int c, int d) { \
1046 PCLASS::CBNAME(a, b, c, d); \
1049 //---------------------------------------------------------------------------
1051 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
1052 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
1053 void base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1056 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1057 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1059 bool blocked = wxPyBeginBlockThreads(); \
1060 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1061 PyObject* obj = wxPyMake_wxObject(&a,false); \
1062 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
1065 wxPyEndBlockThreads(blocked); \
1067 PCLASS::CBNAME(a, b, c, d, e, f); \
1069 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
1070 PCLASS::CBNAME(a, b, c, d, e, f); \
1073 //---------------------------------------------------------------------------
1075 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
1076 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f); \
1077 bool base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1080 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1081 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1083 bool blocked = wxPyBeginBlockThreads(); \
1085 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1086 PyObject* obj = wxPyMake_wxObject(&a,false); \
1087 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1090 wxPyEndBlockThreads(blocked); \
1092 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1095 bool CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e, bool f) {\
1096 return PCLASS::CBNAME(a, b, c, d, e, f); \
1099 //---------------------------------------------------------------------------
1101 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1102 void CBNAME(bool a, double b, double c, int d, int e); \
1103 void base_##CBNAME(bool a, double b, double c, int d, int e)
1106 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1107 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1109 bool blocked = wxPyBeginBlockThreads(); \
1110 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1111 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1113 wxPyEndBlockThreads(blocked); \
1115 PCLASS::CBNAME(a, b, c, d, e); \
1117 void CLASS::base_##CBNAME(bool a, double b, double c, int d, int e) { \
1118 PCLASS::CBNAME(a, b, c, d, e); \
1121 //---------------------------------------------------------------------------
1123 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1124 void CBNAME(wxDC& a, double b, double c, double d, double e); \
1125 void base_##CBNAME(wxDC& a, double b, double c, double d, double e)
1128 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1129 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1131 bool blocked = wxPyBeginBlockThreads(); \
1132 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1133 PyObject* obj = wxPyMake_wxObject(&a,false); \
1134 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1137 wxPyEndBlockThreads(blocked); \
1139 PCLASS::CBNAME(a, b, c, d, e); \
1141 void CLASS::base_##CBNAME(wxDC& a, double b, double c, double d, double e) {\
1142 PCLASS::CBNAME(a, b, c, d, e); \
1145 //---------------------------------------------------------------------------
1147 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1148 void CBNAME(wxDC& a, bool b); \
1149 void base_##CBNAME(wxDC& a, bool b)
1152 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1153 void CLASS::CBNAME(wxDC& a, bool b) { \
1155 bool blocked = wxPyBeginBlockThreads(); \
1156 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1157 PyObject* obj = wxPyMake_wxObject(&a,false); \
1158 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1161 wxPyEndBlockThreads(blocked); \
1163 PCLASS::CBNAME(a, b); \
1165 void CLASS::base_##CBNAME(wxDC& a, bool b) { \
1166 PCLASS::CBNAME(a, b); \
1169 //---------------------------------------------------------------------------
1171 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1172 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f); \
1173 void base_##CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1176 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1177 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1180 bool blocked = wxPyBeginBlockThreads(); \
1181 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1182 PyObject* obj = wxPyMake_wxObject(a,false); \
1183 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1186 wxPyEndBlockThreads(blocked); \
1188 PCLASS::CBNAME(a, b, c, d, e, f); \
1190 void CLASS::base_##CBNAME(wxControlPoint* a, bool b, double c, double d, \
1192 PCLASS::CBNAME(a, b, c, d, e, f); \
1195 //---------------------------------------------------------------------------
1197 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1198 void CBNAME(wxControlPoint* a, double b, double c, int d, int e); \
1199 void base_##CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1202 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1203 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1205 bool blocked = wxPyBeginBlockThreads(); \
1206 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1207 PyObject* obj = wxPyMake_wxObject(a,false); \
1208 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1211 wxPyEndBlockThreads(blocked); \
1213 PCLASS::CBNAME(a, b, c, d, e); \
1215 void CLASS::base_##CBNAME(wxControlPoint* a, double b, double c, \
1217 PCLASS::CBNAME(a, b, c, d, e); \
1220 //---------------------------------------------------------------------------
1222 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1223 void CBNAME(double a, double b, int c); \
1224 void base_##CBNAME(double a, double b, int c)
1227 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1228 void CLASS::CBNAME(double a, double b, int c) { \
1230 bool blocked = wxPyBeginBlockThreads(); \
1231 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1232 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1233 wxPyEndBlockThreads(blocked); \
1235 PCLASS::CBNAME(a, b, c); \
1237 void CLASS::base_##CBNAME(double a, double b, int c) { \
1238 PCLASS::CBNAME(a, b, c); \
1241 //---------------------------------------------------------------------------
1243 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1244 void CBNAME(bool a, double b, double c, int d); \
1245 void base_##CBNAME(bool a, double b, double c, int d)
1248 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1249 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1251 bool blocked = wxPyBeginBlockThreads(); \
1252 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1253 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1254 wxPyEndBlockThreads(blocked); \
1256 PCLASS::CBNAME(a, b, c, d); \
1258 void CLASS::base_##CBNAME(bool a, double b, double c, int d) { \
1259 PCLASS::CBNAME(a, b, c, d); \
1262 //---------------------------------------------------------------------------
1263 //---------------------------------------------------------------------------
1265 #define DEC_PYCALLBACK__STRING(CBNAME) \
1266 void CBNAME(const wxString& a); \
1267 void base_##CBNAME(const wxString& a)
1269 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1270 void CLASS::CBNAME(const wxString& a) { \
1272 bool blocked = wxPyBeginBlockThreads(); \
1273 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1274 PyObject* s = wx2PyString(a); \
1275 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1278 wxPyEndBlockThreads(blocked); \
1280 PCLASS::CBNAME(a); \
1282 void CLASS::base_##CBNAME(const wxString& a) { \
1283 PCLASS::CBNAME(a); \
1286 //---------------------------------------------------------------------------
1288 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1289 bool CBNAME(const wxString& a); \
1290 bool base_##CBNAME(const wxString& a)
1292 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1293 bool CLASS::CBNAME(const wxString& a) { \
1296 bool blocked = wxPyBeginBlockThreads(); \
1297 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1298 PyObject* s = wx2PyString(a); \
1299 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1302 wxPyEndBlockThreads(blocked); \
1304 rval = PCLASS::CBNAME(a); \
1307 bool CLASS::base_##CBNAME(const wxString& a) { \
1308 return PCLASS::CBNAME(a); \
1311 //---------------------------------------------------------------------------
1313 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1314 bool CBNAME(const wxString& a)
1316 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1317 bool CLASS::CBNAME(const wxString& a) { \
1319 bool blocked = wxPyBeginBlockThreads(); \
1320 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1321 PyObject* s = wx2PyString(a); \
1322 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1325 wxPyEndBlockThreads(blocked); \
1329 //---------------------------------------------------------------------------
1331 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1332 wxString CBNAME(const wxString& a)
1334 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1335 wxString CLASS::CBNAME(const wxString& a) { \
1337 bool blocked = wxPyBeginBlockThreads(); \
1338 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1340 PyObject* s = wx2PyString(a); \
1341 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1344 rval = Py2wxString(ro); \
1348 wxPyEndBlockThreads(blocked); \
1352 //---------------------------------------------------------------------------
1354 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1355 wxString CBNAME(const wxString& a); \
1356 wxString base_##CBNAME(const wxString& a)
1358 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1359 wxString CLASS::CBNAME(const wxString& a) { \
1362 bool blocked = wxPyBeginBlockThreads(); \
1363 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1365 PyObject* s = wx2PyString(a); \
1366 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1369 rval = Py2wxString(ro); \
1374 rval = PCLASS::CBNAME(a); \
1375 wxPyEndBlockThreads(blocked); \
1379 //---------------------------------------------------------------------------
1381 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1382 wxString CBNAME(const wxString& a,int b)
1384 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1385 wxString CLASS::CBNAME(const wxString& a,int b) { \
1387 bool blocked = wxPyBeginBlockThreads(); \
1388 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1390 PyObject* s = wx2PyString(a); \
1391 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1394 rval = Py2wxString(ro); \
1398 wxPyEndBlockThreads(blocked); \
1402 //---------------------------------------------------------------------------
1404 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1405 bool CBNAME(const wxString& a, const wxString& b); \
1406 bool base_##CBNAME(const wxString& a, const wxString& b)
1408 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1409 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1412 bool blocked = wxPyBeginBlockThreads(); \
1413 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1414 PyObject* s1 = wx2PyString(a); \
1415 PyObject* s2 = wx2PyString(b); \
1416 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1420 wxPyEndBlockThreads(blocked); \
1422 rval = PCLASS::CBNAME(a, b); \
1425 bool CLASS::base_##CBNAME(const wxString& a, const wxString& b) { \
1426 return PCLASS::CBNAME(a, b); \
1429 //---------------------------------------------------------------------------
1431 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1432 wxString CBNAME(); \
1433 wxString base_##CBNAME()
1435 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1436 wxString CLASS::CBNAME() { \
1439 bool blocked = wxPyBeginBlockThreads(); \
1440 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1442 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1444 rval = Py2wxString(ro); \
1448 wxPyEndBlockThreads(blocked); \
1450 rval = PCLASS::CBNAME(); \
1453 wxString CLASS::base_##CBNAME() { \
1454 return PCLASS::CBNAME(); \
1457 //---------------------------------------------------------------------------
1459 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1460 wxString CBNAME() const; \
1461 wxString base_##CBNAME() const;
1463 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1464 wxString CLASS::CBNAME() const { \
1467 bool blocked = wxPyBeginBlockThreads(); \
1468 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1470 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1472 rval = Py2wxString(ro); \
1476 wxPyEndBlockThreads(blocked); \
1478 rval = PCLASS::CBNAME(); \
1481 wxString CLASS::base_##CBNAME() const { \
1482 return PCLASS::CBNAME(); \
1485 //---------------------------------------------------------------------------
1487 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1490 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1491 wxString CLASS::CBNAME() { \
1493 bool blocked = wxPyBeginBlockThreads(); \
1494 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1496 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1498 rval = Py2wxString(ro); \
1502 wxPyEndBlockThreads(blocked); \
1506 //---------------------------------------------------------------------------
1508 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1509 wxString CBNAME() const;
1511 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1512 wxString CLASS::CBNAME() const { \
1514 bool blocked = wxPyBeginBlockThreads(); \
1515 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1517 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1519 rval = Py2wxString(ro); \
1523 wxPyEndBlockThreads(blocked); \
1527 //---------------------------------------------------------------------------
1529 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1530 bool CBNAME(const wxHtmlTag& a)
1533 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1534 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1536 bool blocked = wxPyBeginBlockThreads(); \
1537 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1538 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
1539 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1542 wxPyEndBlockThreads(blocked); \
1546 //---------------------------------------------------------------------------
1548 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1549 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y); \
1550 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1552 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1553 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1555 bool blocked = wxPyBeginBlockThreads(); \
1556 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1557 PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \
1558 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1561 wxPyEndBlockThreads(blocked); \
1563 PCLASS::CBNAME(cell, x, y); \
1565 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1566 PCLASS::CBNAME(cell, x, y); \
1569 //---------------------------------------------------------------------------
1571 #define DEC_PYCALLBACK__COLOUR(CBNAME) \
1572 void CBNAME(const wxColour& c); \
1573 void base_##CBNAME(const wxColour& c)
1575 #define IMP_PYCALLBACK__COLOUR(CLASS, PCLASS, CBNAME) \
1576 void CLASS::CBNAME(const wxColour& c) { \
1578 bool blocked = wxPyBeginBlockThreads(); \
1579 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1580 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1581 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1584 wxPyEndBlockThreads(blocked); \
1586 PCLASS::CBNAME(c); \
1588 void CLASS::base_##CBNAME(const wxColour& c) { \
1589 PCLASS::CBNAME(c); \
1592 //---------------------------------------------------------------------------
1594 #define DEC_PYCALLBACK__CELLINTINTME(CBNAME) \
1595 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e); \
1596 void base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1598 #define IMP_PYCALLBACK__CELLINTINTME(CLASS, PCLASS, CBNAME) \
1599 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1601 bool blocked = wxPyBeginBlockThreads(); \
1602 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1603 PyObject* obj = wxPyConstructObject((void*)cell, wxT("wxHtmlCell"), 0); \
1604 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1605 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1609 wxPyEndBlockThreads(blocked); \
1611 PCLASS::CBNAME(cell, x, y, e); \
1613 void CLASS::base_##CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) {\
1614 PCLASS::CBNAME(cell, x, y, e); \
1619 //---------------------------------------------------------------------------
1621 #define DEC_PYCALLBACK___pure(CBNAME) \
1625 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1626 void CLASS::CBNAME() { \
1627 bool blocked = wxPyBeginBlockThreads(); \
1628 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1629 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1630 wxPyEndBlockThreads(blocked); \
1633 //---------------------------------------------------------------------------
1635 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1639 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1640 wxSize CLASS::CBNAME() { \
1641 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1643 bool blocked = wxPyBeginBlockThreads(); \
1644 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1647 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1649 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1651 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1652 PyObject* o1 = PySequence_GetItem(ro, 0); \
1653 PyObject* o2 = PySequence_GetItem(ro, 1); \
1654 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1655 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1657 PyErr_SetString(PyExc_TypeError, errmsg); \
1662 PyErr_SetString(PyExc_TypeError, errmsg); \
1667 wxPyEndBlockThreads(blocked); \
1671 //---------------------------------------------------------------------------
1673 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1674 bool CBNAME(wxWindow* a); \
1675 bool base_##CBNAME(wxWindow* a)
1678 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1679 bool CLASS::CBNAME(wxWindow* a) { \
1682 bool blocked = wxPyBeginBlockThreads(); \
1683 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1684 PyObject* obj = wxPyMake_wxObject(a,false); \
1685 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1688 wxPyEndBlockThreads(blocked); \
1690 rval = PCLASS::CBNAME(a); \
1693 bool CLASS::base_##CBNAME(wxWindow* a) { \
1694 return PCLASS::CBNAME(a); \
1697 //---------------------------------------------------------------------------
1699 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1700 bool CBNAME(wxWindow* a, wxDC& b); \
1701 bool base_##CBNAME(wxWindow* a, wxDC& b)
1704 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1705 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1708 bool blocked = wxPyBeginBlockThreads(); \
1709 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1710 PyObject* win = wxPyMake_wxObject(a,false); \
1711 PyObject* dc = wxPyMake_wxObject(&b,false); \
1712 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1716 wxPyEndBlockThreads(blocked); \
1718 rval = PCLASS::CBNAME(a, b); \
1721 bool CLASS::base_##CBNAME(wxWindow* a, wxDC& b) { \
1722 return PCLASS::CBNAME(a, b); \
1725 //---------------------------------------------------------------------------
1727 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1728 void CBNAME(wxWindowBase* a); \
1729 void base_##CBNAME(wxWindowBase* a)
1732 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1733 void CLASS::CBNAME(wxWindowBase* a) { \
1735 bool blocked = wxPyBeginBlockThreads(); \
1736 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1737 PyObject* obj = wxPyMake_wxObject(a,false); \
1738 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1741 wxPyEndBlockThreads(blocked); \
1743 PCLASS::CBNAME(a); \
1745 void CLASS::base_##CBNAME(wxWindowBase* a) { \
1746 PCLASS::CBNAME(a); \
1749 //---------------------------------------------------------------------------
1751 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1753 bool base_##CBNAME()
1756 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1757 bool CLASS::CBNAME() { \
1760 bool blocked = wxPyBeginBlockThreads(); \
1761 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1762 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1763 wxPyEndBlockThreads(blocked); \
1765 rval = PCLASS::CBNAME(); \
1768 bool CLASS::base_##CBNAME() { \
1769 return PCLASS::CBNAME(); \
1772 //---------------------------------------------------------------------------
1774 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1775 bool CBNAME() const; \
1776 bool base_##CBNAME() const
1779 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1780 bool CLASS::CBNAME() const { \
1783 bool blocked = wxPyBeginBlockThreads(); \
1784 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1785 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1786 wxPyEndBlockThreads(blocked); \
1788 rval = PCLASS::CBNAME(); \
1791 bool CLASS::base_##CBNAME() const { \
1792 return PCLASS::CBNAME(); \
1795 //---------------------------------------------------------------------------
1797 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1798 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def); \
1799 wxDragResult base_##CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1802 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1803 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1806 bool blocked = wxPyBeginBlockThreads(); \
1807 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1808 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1809 wxPyEndBlockThreads(blocked); \
1811 rval = PCLASS::CBNAME(a, b, c); \
1812 return (wxDragResult)rval; \
1814 wxDragResult CLASS::base_##CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1815 return PCLASS::CBNAME(a, b, c); \
1818 //---------------------------------------------------------------------------
1820 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1821 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1823 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1824 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1825 bool blocked = wxPyBeginBlockThreads(); \
1827 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1829 PyObject* obj = wxPyMake_wxObject(&a,false); \
1830 PyObject* s = wx2PyString(b); \
1831 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1834 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
1840 wxPyEndBlockThreads(blocked); \
1844 //---------------------------------------------------------------------------
1846 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1847 bool CBNAME(wxDragResult a); \
1848 bool base_##CBNAME(wxDragResult a)
1851 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1852 bool CLASS::CBNAME(wxDragResult a) { \
1855 bool blocked = wxPyBeginBlockThreads(); \
1856 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1857 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1858 wxPyEndBlockThreads(blocked); \
1860 rval = PCLASS::CBNAME(a); \
1863 bool CLASS::base_##CBNAME(wxDragResult a) { \
1864 return PCLASS::CBNAME(a); \
1867 //---------------------------------------------------------------------------
1869 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1870 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1873 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1874 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1875 bool blocked = wxPyBeginBlockThreads(); \
1877 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1878 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1879 wxPyEndBlockThreads(blocked); \
1880 return (wxDragResult)rval; \
1883 //---------------------------------------------------------------------------
1885 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1886 bool CBNAME(int a, int b, const wxString& c)
1888 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1889 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1891 bool blocked = wxPyBeginBlockThreads(); \
1892 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1893 PyObject* s = wx2PyString(c); \
1894 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1897 wxPyEndBlockThreads(blocked); \
1901 //---------------------------------------------------------------------------
1903 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1905 size_t base_##CBNAME()
1908 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1909 size_t CLASS::CBNAME() { \
1912 bool blocked = wxPyBeginBlockThreads(); \
1913 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1914 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1915 wxPyEndBlockThreads(blocked); \
1917 rval = PCLASS::CBNAME(); \
1920 size_t CLASS::base_##CBNAME() { \
1921 return PCLASS::CBNAME(); \
1924 //---------------------------------------------------------------------------
1926 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1927 size_t CBNAME() const; \
1928 size_t base_##CBNAME() const
1931 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1932 size_t CLASS::CBNAME() const { \
1935 bool blocked = wxPyBeginBlockThreads(); \
1936 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1937 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1938 wxPyEndBlockThreads(blocked); \
1940 rval = PCLASS::CBNAME(); \
1943 size_t CLASS::base_##CBNAME() const { \
1944 return PCLASS::CBNAME(); \
1947 //---------------------------------------------------------------------------
1949 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1950 wxDataFormat CBNAME(size_t a); \
1951 wxDataFormat base_##CBNAME(size_t a)
1954 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1955 wxDataFormat CLASS::CBNAME(size_t a) { \
1956 wxDataFormat rval=0; \
1958 bool blocked = wxPyBeginBlockThreads(); \
1959 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1961 wxDataFormat* ptr; \
1962 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1964 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1969 wxPyEndBlockThreads(blocked); \
1971 rval = PCLASS::CBNAME(a); \
1974 wxDataFormat CLASS::base_##CBNAME(size_t a) { \
1975 return PCLASS::CBNAME(a); \
1978 //---------------------------------------------------------------------------
1980 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1981 void CBNAME(const Type& a); \
1982 void base_##CBNAME(const Type& a)
1985 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1986 void CLASS::CBNAME(const Type& a) { \
1988 bool blocked = wxPyBeginBlockThreads(); \
1989 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1990 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1991 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1994 wxPyEndBlockThreads(blocked); \
1996 PCLASS::CBNAME(a); \
1998 void CLASS::base_##CBNAME(const Type& a) { \
1999 PCLASS::CBNAME(a); \
2003 //---------------------------------------------------------------------------
2005 #define DEC_PYCALLBACK__any(CBNAME, Type) \
2006 void CBNAME(Type& a); \
2007 void base_##CBNAME(Type& a)
2010 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
2011 void CLASS::CBNAME(Type& a) { \
2013 bool blocked = wxPyBeginBlockThreads(); \
2014 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2015 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2016 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2019 wxPyEndBlockThreads(blocked); \
2021 PCLASS::CBNAME(a); \
2023 void CLASS::base_##CBNAME(Type& a) { \
2024 PCLASS::CBNAME(a); \
2027 //---------------------------------------------------------------------------
2029 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
2030 bool CBNAME(Type& a); \
2031 bool base_##CBNAME(Type& a)
2034 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
2035 bool CLASS::CBNAME(Type& a) { \
2038 bool blocked = wxPyBeginBlockThreads(); \
2039 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2040 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2041 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2044 wxPyEndBlockThreads(blocked); \
2046 rv = PCLASS::CBNAME(a); \
2049 bool CLASS::base_##CBNAME(Type& a) { \
2050 return PCLASS::CBNAME(a); \
2053 //---------------------------------------------------------------------------
2055 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
2056 bool CBNAME(Type& a)
2059 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
2060 bool CLASS::CBNAME(Type& a) { \
2062 bool blocked = wxPyBeginBlockThreads(); \
2063 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2064 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
2065 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2068 wxPyEndBlockThreads(blocked); \
2072 //---------------------------------------------------------------------------
2074 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
2075 wxString CBNAME(long a, long b) const; \
2076 wxString base_##CBNAME(long a, long b) const
2078 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
2079 wxString CLASS::CBNAME(long a, long b) const { \
2082 bool blocked = wxPyBeginBlockThreads(); \
2083 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2085 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2087 rval = Py2wxString(ro); \
2091 wxPyEndBlockThreads(blocked); \
2093 rval = PCLASS::CBNAME(a,b); \
2096 wxString CLASS::base_##CBNAME(long a, long b) const { \
2097 return PCLASS::CBNAME(a,b); \
2100 //---------------------------------------------------------------------------
2102 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
2103 int CBNAME(long a) const; \
2104 int base_##CBNAME(long a) const
2107 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
2108 int CLASS::CBNAME(long a) const { \
2111 bool blocked = wxPyBeginBlockThreads(); \
2112 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2114 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2116 rval = PyInt_AsLong(ro); \
2120 wxPyEndBlockThreads(blocked); \
2122 rval = PCLASS::CBNAME(a); \
2125 int CLASS::base_##CBNAME(long a) const { \
2126 return PCLASS::CBNAME(a); \
2130 //---------------------------------------------------------------------------
2132 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2133 wxListItemAttr* CBNAME(long a) const; \
2134 wxListItemAttr* base_##CBNAME(long a) const
2137 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2138 wxListItemAttr *CLASS::CBNAME(long a) const { \
2139 wxListItemAttr *rval = NULL; \
2141 bool blocked = wxPyBeginBlockThreads(); \
2142 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2144 wxListItemAttr* ptr; \
2145 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2147 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2152 wxPyEndBlockThreads(blocked); \
2154 rval = PCLASS::CBNAME(a); \
2157 wxListItemAttr *CLASS::base_##CBNAME(long a) const { \
2158 return PCLASS::CBNAME(a); \
2161 //---------------------------------------------------------------------------
2163 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2164 bool CBNAME(wxMouseEvent& e); \
2165 bool base_##CBNAME(wxMouseEvent& e)
2167 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2168 bool CLASS::CBNAME(wxMouseEvent& e) { \
2171 bool blocked = wxPyBeginBlockThreads(); \
2172 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2174 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2175 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2177 rval = PyInt_AsLong(ro); \
2182 wxPyEndBlockThreads(blocked); \
2184 return PCLASS::CBNAME(e); \
2187 bool CLASS::base_##CBNAME(wxMouseEvent& e) { \
2188 return PCLASS::CBNAME(e); \
2192 //---------------------------------------------------------------------------
2194 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2195 wxWizardPage* CBNAME() const
2197 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2198 wxWizardPage* CLASS::CBNAME() const { \
2199 wxWizardPage* rv = NULL; \
2200 bool blocked = wxPyBeginBlockThreads(); \
2201 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2203 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2205 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2209 wxPyEndBlockThreads(blocked); \
2213 //---------------------------------------------------------------------------
2215 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2216 wxBitmap CBNAME() const
2218 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2219 wxBitmap CLASS::CBNAME() const { \
2221 bool blocked = wxPyBeginBlockThreads(); \
2222 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2225 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2227 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2232 wxPyEndBlockThreads(blocked); \
2236 //---------------------------------------------------------------------------
2238 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2241 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2242 wxObject* CLASS::CBNAME() { \
2243 wxObject* rv = NULL; \
2244 bool blocked = wxPyBeginBlockThreads(); \
2245 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2247 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2249 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2253 wxPyEndBlockThreads(blocked); \
2257 //---------------------------------------------------------------------------
2259 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2260 wxObject* CBNAME(const wxString& a)
2262 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2263 wxObject* CLASS::CBNAME(const wxString& a) { \
2264 wxObject* rv = NULL; \
2265 bool blocked = wxPyBeginBlockThreads(); \
2266 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2267 PyObject* so = wx2PyString(a); \
2269 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2271 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2276 wxPyEndBlockThreads(blocked); \
2280 //---------------------------------------------------------------------------
2282 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2283 bool CBNAME(wxXmlNode* a)
2286 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2287 bool CLASS::CBNAME(wxXmlNode* a) { \
2289 bool blocked = wxPyBeginBlockThreads(); \
2290 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2291 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2292 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2295 wxPyEndBlockThreads(blocked); \
2299 //---------------------------------------------------------------------------
2301 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2302 wxCoord CBNAME(size_t a) const
2305 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2306 wxCoord CLASS::CBNAME(size_t a) const { \
2309 bool blocked = wxPyBeginBlockThreads(); \
2310 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2311 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2313 wxPyEndBlockThreads(blocked); \
2317 //---------------------------------------------------------------------------
2319 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2320 void CBNAME(size_t a, size_t b) const; \
2321 void base_##CBNAME(size_t a, size_t b) const
2324 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2325 void CLASS::CBNAME(size_t a, size_t b) const { \
2327 bool blocked = wxPyBeginBlockThreads(); \
2328 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2329 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2330 wxPyEndBlockThreads(blocked); \
2332 PCLASS::CBNAME(a,b); \
2334 void CLASS::base_##CBNAME(size_t a, size_t b) const { \
2335 PCLASS::CBNAME(a,b); \
2338 //---------------------------------------------------------------------------
2340 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2341 wxCoord CBNAME() const; \
2342 wxCoord base_##CBNAME() const
2345 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2346 wxCoord CLASS::CBNAME() const { \
2349 bool blocked = wxPyBeginBlockThreads(); \
2350 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2351 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2352 wxPyEndBlockThreads(blocked); \
2354 rval = PCLASS::CBNAME(); \
2357 wxCoord CLASS::base_##CBNAME() const { \
2358 return PCLASS::CBNAME(); \
2361 //---------------------------------------------------------------------------
2363 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2364 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2367 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2368 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2370 bool blocked = wxPyBeginBlockThreads(); \
2371 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2372 PyObject* obj = wxPyMake_wxObject(&a,false); \
2373 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2374 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2377 wxPyEndBlockThreads(blocked); \
2380 //---------------------------------------------------------------------------
2382 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2383 void CBNAME(wxDC& a, const wxRect& b, size_t c) const; \
2384 void base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const
2387 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2388 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2390 bool blocked = wxPyBeginBlockThreads(); \
2391 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2392 PyObject* obj = wxPyMake_wxObject(&a,false); \
2393 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2394 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2397 wxPyEndBlockThreads(blocked); \
2399 PCLASS::CBNAME(a,b,c); \
2401 void CLASS::base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2402 PCLASS::CBNAME(a,b,c); \
2405 //---------------------------------------------------------------------------
2408 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2409 wxString CBNAME(size_t a) const; \
2410 wxString base_##CBNAME(size_t a) const
2412 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2413 wxString CLASS::CBNAME(size_t a) const { \
2416 bool blocked = wxPyBeginBlockThreads(); \
2417 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2419 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2421 rval = Py2wxString(ro); \
2425 wxPyEndBlockThreads(blocked); \
2427 rval = PCLASS::CBNAME(a); \
2430 wxString CLASS::base_##CBNAME(size_t a) const { \
2431 return PCLASS::CBNAME(a); \
2434 //---------------------------------------------------------------------------
2436 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2437 wxString CBNAME(size_t a) const
2439 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2440 wxString CLASS::CBNAME(size_t a) const { \
2443 bool blocked = wxPyBeginBlockThreads(); \
2444 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2446 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2448 rval = Py2wxString(ro); \
2452 wxPyEndBlockThreads(blocked); \
2456 //---------------------------------------------------------------------------
2458 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2459 wxVisualAttributes CBNAME() const; \
2460 wxVisualAttributes base_##CBNAME()
2463 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2464 wxVisualAttributes CLASS::CBNAME() const { \
2465 wxVisualAttributes rval; \
2467 bool blocked = wxPyBeginBlockThreads(); \
2468 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2470 wxVisualAttributes* ptr; \
2471 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2473 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2478 wxPyEndBlockThreads(blocked); \
2480 rval = PCLASS::CBNAME(); \
2483 wxVisualAttributes CLASS::base_##CBNAME() { \
2484 return PCLASS::CBNAME(); \
2487 //---------------------------------------------------------------------------