1 ////////////////////////////////////////////////////////////////////////////
2 // Name: wxPython_int.h (int == internal)
3 // Purpose: Helper functions/classes for the wxPython extension module
4 // This header should only be inclued directly by those source
5 // modules included in the wx._core module. All others should
6 // include wx/wxPython/wxPython.h instead.
10 // Created: 1-July-1997
12 // Copyright: (c) 1998 by Total Control Software
13 // Licence: wxWindows license
14 /////////////////////////////////////////////////////////////////////////////
16 #ifndef __wxp_helpers__
17 #define __wxp_helpers__
21 #include <wx/busyinfo.h>
23 #include <wx/choicebk.h>
24 #include <wx/clipbrd.h>
25 #include <wx/colordlg.h>
26 #include <wx/config.h>
27 #include <wx/cshelp.h>
28 #include <wx/dcmirror.h>
30 #include <wx/dirctrl.h>
31 #include <wx/dirdlg.h>
32 #include <wx/numdlg.h>
34 #include <wx/docview.h>
35 #include <wx/encconv.h>
36 #include <wx/fdrepdlg.h>
37 #include <wx/fileconf.h>
38 #include <wx/filesys.h>
39 #include <wx/fontdlg.h>
40 #include <wx/fs_inet.h>
41 #include <wx/fs_mem.h>
42 #include <wx/fs_zip.h>
43 #include <wx/gbsizer.h>
44 #include <wx/geometry.h>
45 #include <wx/htmllbox.h>
47 #include <wx/imaglist.h>
49 #include <wx/laywin.h>
50 #include <wx/listbook.h>
51 #include <wx/minifram.h>
52 #include <wx/notebook.h>
54 #include <wx/printdlg.h>
55 #include <wx/process.h>
56 #include <wx/progdlg.h>
57 #include <wx/sashwin.h>
58 #include <wx/spinbutt.h>
59 #include <wx/spinctrl.h>
60 #include <wx/splash.h>
61 #include <wx/splitter.h>
62 #include <wx/statline.h>
63 #include <wx/stream.h>
64 #include <wx/sysopt.h>
65 #include <wx/taskbar.h>
66 #include <wx/tglbtn.h>
67 #include <wx/tipwin.h>
68 #include <wx/toolbook.h>
69 #include <wx/tooltip.h>
70 #include <wx/treebook.h>
72 #include <wx/vscroll.h>
73 #include <wx/dateevt.h>
74 #include <wx/datectrl.h>
76 #include <wx/hyperlink.h>
77 #include <wx/pickerbase.h>
78 #include <wx/clrpicker.h>
79 #include <wx/filepicker.h>
80 #include <wx/fontpicker.h>
81 #include <wx/collpane.h>
85 # pragma warning(disable:4800)
86 # pragma warning(disable:4190)
89 #ifdef __WXMAC__ // avoid a bug in Carbon headers
93 //---------------------------------------------------------------------------
95 #ifndef wxHAS_POWER_EVENTS
96 class wxPowerEvent
: public wxEvent
99 wxPowerEvent(wxEventType evtType
) : wxEvent(wxID_NONE
, evtType
) {}
101 bool IsVetoed() const { return false; }
102 virtual wxEvent
*Clone() const { return new wxPowerEvent(*this); }
106 //---------------------------------------------------------------------------
107 typedef unsigned char byte
;
108 typedef unsigned char* buffer
;
110 typedef wxPoint2DDouble wxPoint2D
;
111 typedef wxRect2DDouble wxRect2D
;
113 #ifndef SWIG_TYPE_TABLE
114 #define SWIG_TYPE_TABLE wxPython_type_table
118 #define wxDEFAULT_STATUSBAR_STYLE wxST_SIZEGRIP|wxFULL_REPAINT_ON_RESIZE
120 #define wxDEFAULT_STATUSBAR_STYLE wxST_SIZEGRIP
124 #ifndef wxPyUSE_EXPORTED_API
126 void __wxPyPreStart(PyObject
*);
127 void __wxPyCleanup();
128 PyObject
* __wxPySetDictionary(PyObject
*, PyObject
* args
);
130 void wxSetDefaultPyEncoding(const char* encoding
);
131 const char* wxGetDefaultPyEncoding();
134 void wxPyEventThunker(wxObject
*, wxEvent
& event
);
137 bool wxPyCheckSwigType(const wxChar
* className
);
138 PyObject
* wxPyConstructObject(void* ptr
,
139 const wxChar
* className
,
141 bool wxPyConvertSwigPtr(PyObject
* obj
, void **ptr
,
142 const wxChar
* className
);
143 PyObject
* wxPyMakeSwigPtr(void* ptr
, const wxChar
* classname
);
146 PyObject
* wx2PyString(const wxString
& src
);
147 wxString
Py2wxString(PyObject
* source
);
149 PyObject
* wxPyMake_wxObject(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
=true);
150 PyObject
* wxPyMake_wxSizer(wxSizer
* source
, bool setThisOwn
);
151 void wxPyPtrTypeMap_Add(const char* commonName
, const char* ptrName
);
153 PyObject
* wxPy_ConvertList(wxListBase
* list
);
154 long wxPyGetWinHandle(wxWindow
* win
);
156 void wxPy_ReinitStockObjects(int pass
);
158 bool wxPyInstance_Check(PyObject
* obj
);
159 bool wxPySwigInstance_Check(PyObject
* obj
);
162 #endif // wxPyUSE_EXPORTED_API
163 //---------------------------------------------------------------------------
165 // if we want to handle threads and Python threads are available...
166 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
167 #define WXP_WITH_THREAD
168 #else // no Python threads...
169 #undef WXP_WITH_THREAD
173 // In Python 2.3 and later there are the PyGILState_* APIs that we can use for
174 // blocking threads when calling back into Python. Using them instead of my
175 // home-grown hacks greatly simplifies wxPyBeginBlockThreads and
176 // wxPyEndBlockThreads.
178 // Unfortunatly there is a bug somewhere when using these new APIs on Python
179 // 2.3. It manifests in Boa Constructor's debugger where it is unable to stop
180 // at breakpoints located in event handlers. I think that the cause may be
181 // something like the original PyThreadState for the main thread is not being
182 // restored for the callbacks, but I can't see where that could be
183 // happening... So we'll only activate this new change for Python 2.4+ :-(
185 #if PY_VERSION_HEX < 0x02040000
186 #define wxPyUSE_GIL_STATE 0
187 typedef bool wxPyBlock_t
;
189 #define wxPyUSE_GIL_STATE 1
190 typedef PyGILState_STATE wxPyBlock_t
;
194 // Python 2.5 changes the type of some API parameter and return types. Using
195 // this typedef for versions < 2.5 will help with the transition...
196 #if PY_VERSION_HEX < 0x02050000
197 typedef int Py_ssize_t
;
201 #ifndef wxPyUSE_EXPORTED_API
203 // For Python --> C++
204 PyThreadState
* wxPyBeginAllowThreads();
205 void wxPyEndAllowThreads(PyThreadState
* state
);
207 // For C++ --> Python
208 wxPyBlock_t
wxPyBeginBlockThreads();
209 void wxPyEndBlockThreads(wxPyBlock_t blocked
);
211 #endif // wxPyUSE_EXPORTED_API
214 // A macro that will help to execute simple statments wrapped in
215 // StartBlock/EndBlockThreads calls
216 #define wxPyBLOCK_THREADS(stmt) \
217 { wxPyBlock_t blocked = wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads(blocked); }
219 // Raise the NotImplementedError exception (blocking threads)
220 #define wxPyRaiseNotImplemented() \
221 wxPyBLOCK_THREADS(PyErr_SetNone(PyExc_NotImplementedError))
223 // Raise any exception with a string value (blocking threads)
224 #define wxPyErr_SetString(err, str) \
225 wxPyBLOCK_THREADS(PyErr_SetString(err, str))
228 //---------------------------------------------------------------------------
229 // These are helpers used by the typemaps
231 #ifndef wxPyUSE_EXPORTED_API
233 wxString
* wxString_in_helper(PyObject
* source
);
235 byte
* byte_LIST_helper(PyObject
* source
);
236 int* int_LIST_helper(PyObject
* source
);
237 long* long_LIST_helper(PyObject
* source
);
238 char** string_LIST_helper(PyObject
* source
);
239 wxPoint
* wxPoint_LIST_helper(PyObject
* source
, int* npoints
);
240 wxPoint2D
* wxPoint2D_LIST_helper(PyObject
* source
, size_t* npoints
);
241 wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
242 wxString
* wxString_LIST_helper(PyObject
* source
);
243 wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
244 wxPen
** wxPen_LIST_helper(PyObject
* source
);
246 bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
247 bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
248 bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
249 bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
250 bool wxColour_helper(PyObject
* source
, wxColour
** obj
);
251 bool wxPoint2D_helper(PyObject
* source
, wxPoint2D
** obj
);
252 bool wxRect2D_helper(PyObject
* source
, wxRect2D
** obj
);
255 bool wxPySimple_typecheck(PyObject
* source
, const wxChar
* classname
, int seqLen
);
256 bool wxColour_typecheck(PyObject
* source
);
259 // Other helpful stuff
260 bool wxPyCheckForApp();
261 bool wxPyTestDisplayAvailable();
263 bool wxPy2int_seq_helper(PyObject
* source
, int* i1
, int* i2
);
264 bool wxPy4int_seq_helper(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
266 PyObject
* wxArrayString2PyList_helper(const wxArrayString
& arr
);
267 PyObject
* wxArrayInt2PyList_helper(const wxArrayInt
& arr
);
268 PyObject
* wxArrayDouble2PyList_helper(const wxArrayDouble
& arr
);
270 #endif // wxPyUSE_EXPORTED_API
272 //---------------------------------------------------------------------------
274 #if PYTHON_API_VERSION < 1009
275 #define PySequence_Fast_GET_ITEM(o, i) \
276 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
279 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
280 #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name)
281 #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val)
283 //---------------------------------------------------------------------------
285 #ifndef wxPyUSE_EXPORTED_API
287 class wxPyCallback
: public wxObject
{
288 DECLARE_ABSTRACT_CLASS(wxPyCallback
)
290 wxPyCallback(PyObject
* func
);
291 wxPyCallback(const wxPyCallback
& other
);
294 void EventThunker(wxEvent
& event
);
299 #endif // wxPyUSE_EXPORTED_API
300 //---------------------------------------------------------------------------
301 //---------------------------------------------------------------------------
302 // These Event classes can be derived from in Python and passed through the
303 // event system without loosing anything. They do this by keeping a reference
304 // to themselves and some special case handling in wxPyCallback::EventThunker.
308 class wxPyEvtSelfRef
{
313 void SetSelf(PyObject
* self
, bool clone
=false);
314 PyObject
* GetSelf() const;
315 bool GetCloned() const { return m_cloned
; }
323 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
324 DECLARE_ABSTRACT_CLASS(wxPyEvent
)
326 wxPyEvent(int winid
=0, wxEventType commandType
= wxEVT_NULL
);
327 wxPyEvent(const wxPyEvent
& evt
);
330 virtual wxEvent
* Clone() const { return new wxPyEvent(*this); }
334 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
335 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent
)
337 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
338 wxPyCommandEvent(const wxPyCommandEvent
& evt
);
341 virtual wxEvent
* Clone() const { return new wxPyCommandEvent(*this); }
346 //----------------------------------------------------------------------
347 // Forward decalre a few things used in the exported API
348 class wxPyClientData
;
350 class wxPyOORClientData
;
351 class wxPyCBInputStream
;
353 void wxPyClientData_dtor(wxPyClientData
* self
);
354 void wxPyUserData_dtor(wxPyUserData
* self
);
355 void wxPyOORClientData_dtor(wxPyOORClientData
* self
);
356 wxPyCBInputStream
* wxPyCBInputStream_create(PyObject
*py
, bool block
);
357 wxPyCBInputStream
* wxPyCBInputStream_copy(wxPyCBInputStream
* other
);
359 //---------------------------------------------------------------------------
360 // Export a C API in a struct. Other modules will be able to load this from
361 // the wx.core module and will then have safe access to these functions, even if
362 // in another shared library.
364 class wxPyCallbackHelper
;
368 bool (*p_wxPyCheckSwigType
)(const wxChar
* className
);
369 PyObject
* (*p_wxPyConstructObject
)(void* ptr
, const wxChar
* className
, int setThisOwn
);
370 bool (*p_wxPyConvertSwigPtr
)(PyObject
* obj
, void **ptr
, const wxChar
* className
);
371 PyObject
* (*p_wxPyMakeSwigPtr
)(void* ptr
, const wxChar
* className
);
373 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
374 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
375 wxPyBlock_t (*p_wxPyBeginBlockThreads
)();
376 void (*p_wxPyEndBlockThreads
)(wxPyBlock_t blocked
);
378 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
);
380 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
381 wxString (*p_Py2wxString
)(PyObject
* source
);
382 PyObject
* (*p_wx2PyString
)(const wxString
& src
);
384 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
385 int* (*p_int_LIST_helper
)(PyObject
* source
);
386 long* (*p_long_LIST_helper
)(PyObject
* source
);
387 char** (*p_string_LIST_helper
)(PyObject
* source
);
388 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
389 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
390 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
391 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
393 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
394 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
395 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
396 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
397 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
398 bool (*p_wxPoint2D_helper
)(PyObject
* source
, wxPoint2D
** obj
);
401 bool (*p_wxPySimple_typecheck
)(PyObject
* source
, const wxChar
* classname
, int seqLen
);
402 bool (*p_wxColour_typecheck
)(PyObject
* source
);
404 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
405 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
);
406 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
407 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
408 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
410 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
);
411 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
, bool setThisOwn
);
412 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
413 bool (*p_wxPy2int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
);
414 bool (*p_wxPy4int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
415 PyObject
* (*p_wxArrayString2PyList_helper
)(const wxArrayString
& arr
);
416 PyObject
* (*p_wxArrayInt2PyList_helper
)(const wxArrayInt
& arr
);
418 void (*p_wxPyClientData_dtor
)(wxPyClientData
*);
419 void (*p_wxPyUserData_dtor
)(wxPyUserData
*);
420 void (*p_wxPyOORClientData_dtor
)(wxPyOORClientData
*);
422 wxPyCBInputStream
* (*p_wxPyCBInputStream_create
)(PyObject
*py
, bool block
);
423 wxPyCBInputStream
* (*p_wxPyCBInputStream_copy
)(wxPyCBInputStream
* other
);
425 bool (*p_wxPyInstance_Check
)(PyObject
* obj
);
426 bool (*p_wxPySwigInstance_Check
)(PyObject
* obj
);
428 bool (*p_wxPyCheckForApp
)();
430 // Add all new items at the end...
431 PyObject
* (*p_wxArrayDoublePyList_helper
)(const wxArrayDouble
& arr
);
432 wxPoint2D
* (*p_wxPoint2D_LIST_helper
)(PyObject
* source
, size_t* npoints
);
433 bool (*p_wxRect2D_helper
)(PyObject
* source
, wxRect2D
** obj
);
438 #ifdef wxPyUSE_EXPORTED_API
439 // Notice that this is static, not extern. This is by design, each module
440 // needs one, but doesn't have to use it.
441 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
;
442 inline wxPyCoreAPI
* wxPyGetCoreAPIPtr();
443 #endif // wxPyUSE_EXPORTED_API
445 //---------------------------------------------------------------------------
447 // A wxObject that holds a reference to a Python object
448 class wxPyUserData
: public wxObject
{
450 wxPyUserData(PyObject
* obj
) {
456 #ifdef wxPyUSE_EXPORTED_API
457 wxPyGetCoreAPIPtr()->p_wxPyUserData_dtor(this);
459 wxPyUserData_dtor(this);
466 // A wxClientData that holds a refernece to a Python object
467 class wxPyClientData
: public wxClientData
{
469 wxPyClientData(PyObject
* obj
, bool incref
=true) {
477 #ifdef wxPyUSE_EXPORTED_API
478 wxPyGetCoreAPIPtr()->p_wxPyClientData_dtor(this);
480 wxPyClientData_dtor(this);
488 // Just like wxPyClientData, except when this object is destroyed it does some
489 // OOR magic on the Python Object.
490 class wxPyOORClientData
: public wxPyClientData
{
492 wxPyOORClientData(PyObject
* obj
, bool incref
=true)
493 : wxPyClientData(obj
, incref
) {}
494 ~wxPyOORClientData() {
496 #ifdef wxPyUSE_EXPORTED_API
497 wxPyGetCoreAPIPtr()->p_wxPyOORClientData_dtor(this);
499 wxPyOORClientData_dtor(this);
505 //---------------------------------------------------------------------------
506 // A wxImageHandler that can be derived from in Python.
509 class wxPyImageHandler
: public wxImageHandler
{
513 // used for interning method names as PyStrings
514 static PyObject
* m_DoCanRead_Name
;
515 static PyObject
* m_GetImageCount_Name
;
516 static PyObject
* m_LoadFile_Name
;
517 static PyObject
* m_SaveFile_Name
;
519 // converstion helpers
520 PyObject
* py_InputStream(wxInputStream
* stream
);
521 PyObject
* py_Image(wxImage
* image
);
522 PyObject
* py_OutputStream(wxOutputStream
* stream
);
527 void _SetSelf(PyObject
*self
);
529 virtual bool LoadFile(wxImage
* image
, wxInputStream
& stream
,
530 bool verbose
=true, int index
=-1 );
531 virtual bool SaveFile(wxImage
* image
, wxOutputStream
& stream
,
533 virtual int GetImageCount(wxInputStream
& stream
);
534 virtual bool DoCanRead(wxInputStream
&stream
);
538 //---------------------------------------------------------------------------
539 // This class holds an instance of a Python Shadow Class object and assists
540 // with looking up and invoking Python callback methods from C++ virtual
541 // method redirections. For all classes which have virtuals which should be
542 // overridable in wxPython, a new subclass is created that contains a
543 // wxPyCallbackHelper.
546 class wxPyCallbackHelper
{
548 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
550 wxPyCallbackHelper() {
557 ~wxPyCallbackHelper() {
558 #ifdef wxPyUSE_EXPORTED_API
559 wxPyGetCoreAPIPtr()->p_wxPyCBH_delete(this);
561 wxPyCBH_delete(this);
565 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=true);
566 bool findCallback(const char* name
, bool setGuard
=true) const;
567 int callCallback(PyObject
* argTuple
) const;
568 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
569 PyObject
* GetLastFound() const { return m_lastFound
; }
571 void setRecursionGuard(PyObject
* method
) const;
572 void clearRecursionGuard(PyObject
* method
) const;
577 PyObject
* m_lastFound
;
580 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
584 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
585 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
=true);
586 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
587 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
588 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
593 //---------------------------------------------------------------------------
595 // This is used in C++ classes that need to be able to make callback to
596 // "overloaded" python methods
599 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
600 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
602 private: wxPyCallbackHelper m_myInst
605 //---------------------------------------------------------------------------
606 // The wxPythonApp class
609 wxPYAPP_ASSERT_SUPPRESS
= 1,
610 wxPYAPP_ASSERT_EXCEPTION
= 2,
611 wxPYAPP_ASSERT_DIALOG
= 4,
612 wxPYAPP_ASSERT_LOG
= 8
615 class wxPyApp
: public wxApp
617 DECLARE_ABSTRACT_CLASS(wxPyApp
)
625 int GetAssertMode() { return m_assertMode
; }
626 void SetAssertMode(int mode
) { m_assertMode
= mode
; }
628 virtual bool OnInitGui();
629 virtual int OnExit();
631 virtual void OnAssertFailure(const wxChar
*file
,
637 virtual void ExitMainLoop();
638 // virtual int FilterEvent(wxEvent& event); // This one too????
640 // For catching Apple Events
641 virtual void MacOpenFile(const wxString
&fileName
);
642 virtual void MacPrintFile(const wxString
&fileName
);
643 virtual void MacNewFile();
644 virtual void MacReopenApp();
646 static bool GetMacSupportPCMenuShortcuts();
647 static long GetMacAboutMenuItemId();
648 static long GetMacPreferencesMenuItemId();
649 static long GetMacExitMenuItemId();
650 static wxString
GetMacHelpMenuTitleName();
652 static void SetMacSupportPCMenuShortcuts(bool val
);
653 static void SetMacAboutMenuItemId(long val
);
654 static void SetMacPreferencesMenuItemId(long val
);
655 static void SetMacExitMenuItemId(long val
);
656 static void SetMacHelpMenuTitleName(const wxString
& val
);
659 void _BootstrapApp();
661 // implementation only
662 void SetStartupComplete(bool val
) { m_startupComplete
= val
; };
666 bool m_startupComplete
;
669 extern wxPyApp
*wxPythonApp
;
672 //----------------------------------------------------------------------
673 // These macros are used to implement the virtual methods that should
674 // redirect to a Python method if one exists. The names designate the
675 // return type, if any, as well as any parameter types.
676 //---------------------------------------------------------------------------
678 #define DEC_PYCALLBACK__(CBNAME) \
682 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
683 void CLASS::CBNAME() { \
685 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
686 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
687 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
688 wxPyEndBlockThreads(blocked); \
693 #define DEC_PYCALLBACK_VOID_(CBNAME) \
694 DEC_PYCALLBACK__(CBNAME)
696 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
697 IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME)
699 //---------------------------------------------------------------------------
701 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
702 bool CBNAME(int a, int b)
705 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
706 bool CLASS::CBNAME(int a, int b) { \
707 bool rval=false, found; \
708 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
709 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
710 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
711 wxPyEndBlockThreads(blocked); \
713 rval = PCLASS::CBNAME(a,b); \
717 //---------------------------------------------------------------------------
719 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
720 void CBNAME(int a, int b)
723 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
724 void CLASS::CBNAME(int a, int b) { \
726 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
727 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
728 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
729 wxPyEndBlockThreads(blocked); \
731 PCLASS::CBNAME(a,b); \
734 //---------------------------------------------------------------------------
736 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
740 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
741 void CLASS::CBNAME(int a) { \
743 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
744 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
745 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
746 wxPyEndBlockThreads(blocked); \
751 //---------------------------------------------------------------------------
753 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
754 void CBNAME(int a, int b, int c, int d)
757 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
758 void CLASS::CBNAME(int a, int b, int c, int d) { \
760 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
761 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
762 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
763 wxPyEndBlockThreads(blocked); \
765 PCLASS::CBNAME(a,b,c,d); \
768 //---------------------------------------------------------------------------
769 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
770 void CBNAME(int a, int b, int c, int d, int e)
773 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
774 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
776 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
777 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
778 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
779 wxPyEndBlockThreads(blocked); \
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
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 wxPyBlock_t 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); \
821 //---------------------------------------------------------------------------
823 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
824 wxSize CBNAME() const
827 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
828 wxSize CLASS::CBNAME() const { \
829 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
830 bool found; wxSize rval(0,0); \
831 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
832 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
834 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
836 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
837 PyObject* o1 = PySequence_GetItem(ro, 0); \
838 PyObject* o2 = PySequence_GetItem(ro, 1); \
839 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
840 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
843 PyErr_SetString(PyExc_TypeError, errmsg); \
848 PyErr_SetString(PyExc_TypeError, errmsg); \
853 wxPyEndBlockThreads(blocked); \
855 return PCLASS::CBNAME(); \
860 //---------------------------------------------------------------------------
862 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
866 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
867 bool CLASS::CBNAME(bool a) { \
868 bool rval=false, found; \
869 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
870 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
871 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
872 wxPyEndBlockThreads(blocked); \
874 rval = PCLASS::CBNAME(a); \
878 //---------------------------------------------------------------------------
880 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
884 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
885 bool CLASS::CBNAME(int a) { \
886 bool rval=false, found; \
887 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
888 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
889 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
890 wxPyEndBlockThreads(blocked); \
892 rval = PCLASS::CBNAME(a); \
896 //---------------------------------------------------------------------------
898 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
902 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
903 bool CLASS::CBNAME(int a) { \
905 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
906 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
907 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
909 wxPyEndBlockThreads(blocked); \
914 //---------------------------------------------------------------------------
916 #define DEC_PYCALLBACK_INT_WIN(CBNAME) \
917 int CBNAME(wxWindow* a)
920 #define IMP_PYCALLBACK_INT_WIN(CLASS, PCLASS, CBNAME) \
921 int CLASS::CBNAME(wxWindow* a) { \
924 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
925 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
926 PyObject* obj = wxPyMake_wxObject(a, false); \
927 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)",obj)); \
930 wxPyEndBlockThreads(blocked); \
932 rval = PCLASS::CBNAME(a); \
937 //---------------------------------------------------------------------------
939 #define DEC_PYCALLBACK__DC(CBNAME) \
943 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
944 void CLASS::CBNAME(wxDC& a) { \
946 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
947 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
948 PyObject* obj = wxPyMake_wxObject(&a,false); \
949 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
952 wxPyEndBlockThreads(blocked); \
958 //---------------------------------------------------------------------------
960 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
961 void CBNAME(wxDC& a, bool b)
964 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
965 void CLASS::CBNAME(wxDC& a, bool b) { \
967 wxPyBlock_t 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); \
978 //---------------------------------------------------------------------------
980 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
981 void CBNAME(wxDC& a, bool b)
984 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
985 void CLASS::CBNAME(wxDC& a, bool b) { \
987 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
988 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
989 PyObject* obj = wxPyMake_wxObject(&a,false); \
990 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
993 wxPyEndBlockThreads(blocked); \
995 PCLASS::CBNAME(a, b); \
998 //---------------------------------------------------------------------------
1000 #define DEC_PYCALLBACK__2DBL(CBNAME) \
1001 void CBNAME(double a, double b)
1004 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
1005 void CLASS::CBNAME(double a, double b) { \
1007 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1008 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1009 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
1010 wxPyEndBlockThreads(blocked); \
1012 PCLASS::CBNAME(a, b); \
1015 //---------------------------------------------------------------------------
1017 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
1018 void CBNAME(double a, double b, int c, int d)
1021 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
1022 void CLASS::CBNAME(double a, double b, int c, int d) { \
1024 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1025 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1026 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
1028 wxPyEndBlockThreads(blocked); \
1030 PCLASS::CBNAME(a, b, c, d); \
1033 //---------------------------------------------------------------------------
1035 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
1036 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1039 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1040 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1042 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1043 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1044 PyObject* obj = wxPyMake_wxObject(&a,false); \
1045 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
1048 wxPyEndBlockThreads(blocked); \
1050 PCLASS::CBNAME(a, b, c, d, e, f); \
1053 //---------------------------------------------------------------------------
1055 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
1056 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1059 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1060 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1062 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1064 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1065 PyObject* obj = wxPyMake_wxObject(&a,false); \
1066 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1069 wxPyEndBlockThreads(blocked); \
1071 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1075 //---------------------------------------------------------------------------
1077 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1078 void CBNAME(bool a, double b, double c, int d, int e)
1081 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1082 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1084 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1085 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1086 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1088 wxPyEndBlockThreads(blocked); \
1090 PCLASS::CBNAME(a, b, c, d, e); \
1093 //---------------------------------------------------------------------------
1095 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1096 void CBNAME(wxDC& a, double b, double c, double d, double e)
1099 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1100 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1102 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1103 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1104 PyObject* obj = wxPyMake_wxObject(&a,false); \
1105 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1108 wxPyEndBlockThreads(blocked); \
1110 PCLASS::CBNAME(a, b, c, d, e); \
1113 //---------------------------------------------------------------------------
1115 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1116 void CBNAME(wxDC& a, bool b)
1119 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1120 void CLASS::CBNAME(wxDC& a, bool b) { \
1122 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1123 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1124 PyObject* obj = wxPyMake_wxObject(&a,false); \
1125 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1128 wxPyEndBlockThreads(blocked); \
1130 PCLASS::CBNAME(a, b); \
1133 //---------------------------------------------------------------------------
1135 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1136 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1139 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1140 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1143 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1144 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1145 PyObject* obj = wxPyMake_wxObject(a,false); \
1146 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1149 wxPyEndBlockThreads(blocked); \
1151 PCLASS::CBNAME(a, b, c, d, e, f); \
1154 //---------------------------------------------------------------------------
1156 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1157 void CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1160 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1161 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1163 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1164 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1165 PyObject* obj = wxPyMake_wxObject(a,false); \
1166 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1169 wxPyEndBlockThreads(blocked); \
1171 PCLASS::CBNAME(a, b, c, d, e); \
1174 //---------------------------------------------------------------------------
1176 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1177 void CBNAME(double a, double b, int c)
1180 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1181 void CLASS::CBNAME(double a, double b, int c) { \
1183 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1184 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1185 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1186 wxPyEndBlockThreads(blocked); \
1188 PCLASS::CBNAME(a, b, c); \
1191 //---------------------------------------------------------------------------
1193 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1194 void CBNAME(bool a, double b, double c, int d)
1197 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1198 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1200 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1201 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1202 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1203 wxPyEndBlockThreads(blocked); \
1205 PCLASS::CBNAME(a, b, c, d); \
1208 //---------------------------------------------------------------------------
1209 //---------------------------------------------------------------------------
1211 #define DEC_PYCALLBACK__STRING(CBNAME) \
1212 void CBNAME(const wxString& a)
1214 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1215 void CLASS::CBNAME(const wxString& a) { \
1217 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1218 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1219 PyObject* s = wx2PyString(a); \
1220 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1223 wxPyEndBlockThreads(blocked); \
1225 PCLASS::CBNAME(a); \
1228 //---------------------------------------------------------------------------
1230 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1231 bool CBNAME(const wxString& a)
1233 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1234 bool CLASS::CBNAME(const wxString& a) { \
1237 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1238 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1239 PyObject* s = wx2PyString(a); \
1240 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1243 wxPyEndBlockThreads(blocked); \
1245 rval = PCLASS::CBNAME(a); \
1249 //---------------------------------------------------------------------------
1251 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1252 bool CBNAME(const wxString& a)
1254 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1255 bool CLASS::CBNAME(const wxString& a) { \
1257 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1258 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1259 PyObject* s = wx2PyString(a); \
1260 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1263 wxPyEndBlockThreads(blocked); \
1267 //---------------------------------------------------------------------------
1269 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1270 wxString CBNAME(const wxString& a)
1272 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1273 wxString CLASS::CBNAME(const wxString& a) { \
1275 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1276 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1278 PyObject* s = wx2PyString(a); \
1279 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1282 rval = Py2wxString(ro); \
1286 wxPyEndBlockThreads(blocked); \
1290 //---------------------------------------------------------------------------
1292 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1293 wxString CBNAME(const wxString& a)
1295 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1296 wxString CLASS::CBNAME(const wxString& a) { \
1299 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1300 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1302 PyObject* s = wx2PyString(a); \
1303 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1306 rval = Py2wxString(ro); \
1310 wxPyEndBlockThreads(blocked); \
1312 rval = PCLASS::CBNAME(a); \
1316 //---------------------------------------------------------------------------
1318 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1319 wxString CBNAME(const wxString& a,int b)
1321 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1322 wxString CLASS::CBNAME(const wxString& a,int b) { \
1324 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1325 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1327 PyObject* s = wx2PyString(a); \
1328 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1331 rval = Py2wxString(ro); \
1335 wxPyEndBlockThreads(blocked); \
1339 //---------------------------------------------------------------------------
1341 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1342 bool CBNAME(const wxString& a, const wxString& b)
1344 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1345 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1348 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1349 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1350 PyObject* s1 = wx2PyString(a); \
1351 PyObject* s2 = wx2PyString(b); \
1352 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1356 wxPyEndBlockThreads(blocked); \
1358 rval = PCLASS::CBNAME(a, b); \
1362 //---------------------------------------------------------------------------
1364 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1367 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1368 wxString CLASS::CBNAME() { \
1371 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1372 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1374 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1376 rval = Py2wxString(ro); \
1380 wxPyEndBlockThreads(blocked); \
1382 rval = PCLASS::CBNAME(); \
1386 //---------------------------------------------------------------------------
1388 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1389 wxString CBNAME() const
1391 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1392 wxString CLASS::CBNAME() const { \
1395 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1396 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1398 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1400 rval = Py2wxString(ro); \
1404 wxPyEndBlockThreads(blocked); \
1406 rval = PCLASS::CBNAME(); \
1410 //---------------------------------------------------------------------------
1412 #define DEC_PYCALLBACK_STRING__pure(CBNAME) \
1415 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1416 wxString CLASS::CBNAME() { \
1418 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1419 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1421 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1423 rval = Py2wxString(ro); \
1427 wxPyEndBlockThreads(blocked); \
1431 //---------------------------------------------------------------------------
1433 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1434 wxString CBNAME() const;
1436 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1437 wxString CLASS::CBNAME() const { \
1439 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1440 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1442 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1444 rval = Py2wxString(ro); \
1448 wxPyEndBlockThreads(blocked); \
1452 //---------------------------------------------------------------------------
1454 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1455 bool CBNAME(const wxHtmlTag& a)
1458 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1459 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1461 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1462 if (wxPyCBH_findCallback2(m_myInst, #CBNAME, false)) { \
1463 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
1464 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1467 wxPyEndBlockThreads(blocked); \
1471 //---------------------------------------------------------------------------
1473 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1474 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1476 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1477 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1479 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1480 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1481 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1482 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1485 wxPyEndBlockThreads(blocked); \
1487 PCLASS::CBNAME(cell, x, y); \
1490 //---------------------------------------------------------------------------
1492 #define DEC_PYCALLBACK__COLOUR(CBNAME) \
1493 void CBNAME(const wxColour& c);
1495 #define IMP_PYCALLBACK__COLOUR(CLASS, PCLASS, CBNAME) \
1496 void CLASS::CBNAME(const wxColour& c) { \
1498 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1499 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1500 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1501 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1504 wxPyEndBlockThreads(blocked); \
1506 PCLASS::CBNAME(c); \
1509 //---------------------------------------------------------------------------
1510 #define DEC_PYCALLBACK__INTCOLOUR(CBNAME) \
1511 void CBNAME(int a, const wxColour& c);
1513 #define IMP_PYCALLBACK__INTCOLOUR(CLASS, PCLASS, CBNAME) \
1514 void CLASS::CBNAME(int a, const wxColour& c) { \
1516 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1517 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1518 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1519 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)",a, obj)); \
1522 wxPyEndBlockThreads(blocked); \
1524 PCLASS::CBNAME(a, c); \
1527 //---------------------------------------------------------------------------
1529 #define DEC_PYCALLBACK__INTFONT(CBNAME) \
1530 void CBNAME(int a, const wxFont& c);
1532 #define IMP_PYCALLBACK__INTFONT(CLASS, PCLASS, CBNAME) \
1533 void CLASS::CBNAME(int a, const wxFont& c) { \
1535 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1536 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1537 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxFont"), 0); \
1538 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)",a, obj)); \
1541 wxPyEndBlockThreads(blocked); \
1543 PCLASS::CBNAME(a, c); \
1546 //---------------------------------------------------------------------------
1548 #define DEC_PYCALLBACK__FONT(CBNAME) \
1549 void CBNAME(const wxFont& a);
1551 #define IMP_PYCALLBACK__FONT(CLASS, PCLASS, CBNAME) \
1552 void CLASS::CBNAME(const wxFont& a) { \
1554 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1555 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1556 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxFont"), 0); \
1557 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj)); \
1560 wxPyEndBlockThreads(blocked); \
1562 PCLASS::CBNAME(a); \
1565 //---------------------------------------------------------------------------
1567 #define DEC_PYCALLBACK_BOOL_CELLINTINTME(CBNAME) \
1568 bool CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1570 #define IMP_PYCALLBACK_BOOL_CELLINTINTME(CLASS, PCLASS, CBNAME) \
1571 bool CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1572 bool rval=false, found; \
1573 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1574 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1575 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1576 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1577 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1581 wxPyEndBlockThreads(blocked); \
1583 rval = PCLASS::CBNAME(cell, x, y, e); \
1588 //---------------------------------------------------------------------------
1590 #define DEC_PYCALLBACK___pure(CBNAME) \
1594 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1595 void CLASS::CBNAME() { \
1596 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1597 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1598 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1599 wxPyEndBlockThreads(blocked); \
1602 //---------------------------------------------------------------------------
1604 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1608 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1609 wxSize CLASS::CBNAME() { \
1610 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1612 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1613 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1616 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1618 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1620 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1622 PyObject* o1 = PySequence_GetItem(ro, 0); \
1623 PyObject* o2 = PySequence_GetItem(ro, 1); \
1624 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1625 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1627 PyErr_SetString(PyExc_TypeError, errmsg); \
1632 PyErr_SetString(PyExc_TypeError, errmsg); \
1637 wxPyEndBlockThreads(blocked); \
1641 //---------------------------------------------------------------------------
1643 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1644 bool CBNAME(wxWindow* a)
1647 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1648 bool CLASS::CBNAME(wxWindow* a) { \
1651 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1652 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1653 PyObject* obj = wxPyMake_wxObject(a,false); \
1654 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1657 wxPyEndBlockThreads(blocked); \
1659 rval = PCLASS::CBNAME(a); \
1663 //---------------------------------------------------------------------------
1665 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1666 bool CBNAME(wxWindow* a, wxDC& b)
1669 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1670 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1673 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1674 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1675 PyObject* win = wxPyMake_wxObject(a,false); \
1676 PyObject* dc = wxPyMake_wxObject(&b,false); \
1677 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1681 wxPyEndBlockThreads(blocked); \
1683 rval = PCLASS::CBNAME(a, b); \
1687 //---------------------------------------------------------------------------
1689 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1690 void CBNAME(wxWindowBase* a)
1693 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1694 void CLASS::CBNAME(wxWindowBase* a) { \
1696 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1697 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1698 PyObject* obj = wxPyMake_wxObject(a,false); \
1699 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1702 wxPyEndBlockThreads(blocked); \
1704 PCLASS::CBNAME(a); \
1707 //---------------------------------------------------------------------------
1709 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1713 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1714 bool CLASS::CBNAME() { \
1717 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1718 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1719 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1720 wxPyEndBlockThreads(blocked); \
1722 rval = PCLASS::CBNAME(); \
1726 //---------------------------------------------------------------------------
1728 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1732 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1733 bool CLASS::CBNAME() const { \
1736 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1737 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1738 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1739 wxPyEndBlockThreads(blocked); \
1741 rval = PCLASS::CBNAME(); \
1745 //---------------------------------------------------------------------------
1747 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1748 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1751 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1752 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1755 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1756 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1757 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1758 wxPyEndBlockThreads(blocked); \
1760 rval = PCLASS::CBNAME(a, b, c); \
1761 return (wxDragResult)rval; \
1764 //---------------------------------------------------------------------------
1766 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1767 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1769 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1770 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1771 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1773 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1775 PyObject* obj = wxPyMake_wxObject(&a,false); \
1776 PyObject* s = wx2PyString(b); \
1777 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1780 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
1781 /* release ownership of the C++ wx.FSFile object. */ \
1782 PyObject_SetAttrString(ro, "thisown", Py_False); \
1788 wxPyEndBlockThreads(blocked); \
1792 //---------------------------------------------------------------------------
1794 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1795 bool CBNAME(wxDragResult a)
1798 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1799 bool CLASS::CBNAME(wxDragResult a) { \
1802 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1803 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1804 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1805 wxPyEndBlockThreads(blocked); \
1807 rval = PCLASS::CBNAME(a); \
1811 //---------------------------------------------------------------------------
1813 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1814 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1817 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1818 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1819 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1821 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1822 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1823 wxPyEndBlockThreads(blocked); \
1824 return (wxDragResult)rval; \
1827 //---------------------------------------------------------------------------
1829 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1830 bool CBNAME(int a, int b, const wxString& c)
1832 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1833 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1835 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1836 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1837 PyObject* s = wx2PyString(c); \
1838 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1841 wxPyEndBlockThreads(blocked); \
1845 //---------------------------------------------------------------------------
1847 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1851 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1852 size_t CLASS::CBNAME() { \
1855 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1856 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1857 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1858 wxPyEndBlockThreads(blocked); \
1860 rval = PCLASS::CBNAME(); \
1864 //---------------------------------------------------------------------------
1866 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1867 size_t CBNAME() const
1870 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1871 size_t CLASS::CBNAME() const { \
1874 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1875 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1876 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1877 wxPyEndBlockThreads(blocked); \
1879 rval = PCLASS::CBNAME(); \
1883 //---------------------------------------------------------------------------
1885 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1886 wxDataFormat CBNAME(size_t a)
1889 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1890 wxDataFormat CLASS::CBNAME(size_t a) { \
1891 wxDataFormat rval=0; \
1893 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1894 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1896 wxDataFormat* ptr; \
1897 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1899 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1904 wxPyEndBlockThreads(blocked); \
1906 rval = PCLASS::CBNAME(a); \
1910 //---------------------------------------------------------------------------
1912 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1913 void CBNAME(const Type& a)
1916 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1917 void CLASS::CBNAME(const Type& a) { \
1919 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1920 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1921 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1922 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1925 wxPyEndBlockThreads(blocked); \
1927 PCLASS::CBNAME(a); \
1931 //---------------------------------------------------------------------------
1933 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1934 void CBNAME(Type& a)
1937 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1938 void CLASS::CBNAME(Type& a) { \
1940 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1941 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1942 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1943 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1946 wxPyEndBlockThreads(blocked); \
1948 PCLASS::CBNAME(a); \
1951 //---------------------------------------------------------------------------
1953 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1954 bool CBNAME(Type& a)
1957 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1958 bool CLASS::CBNAME(Type& a) { \
1961 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1962 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1963 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1964 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1967 wxPyEndBlockThreads(blocked); \
1969 rv = PCLASS::CBNAME(a); \
1973 //---------------------------------------------------------------------------
1975 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
1976 bool CBNAME(Type& a)
1979 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
1980 bool CLASS::CBNAME(Type& a) { \
1982 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1983 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1984 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1985 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1988 wxPyEndBlockThreads(blocked); \
1992 //---------------------------------------------------------------------------
1994 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1995 wxString CBNAME(long a, long b) const
1997 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1998 wxString CLASS::CBNAME(long a, long b) const { \
2001 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2002 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2004 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2006 rval = Py2wxString(ro); \
2010 wxPyEndBlockThreads(blocked); \
2012 rval = PCLASS::CBNAME(a,b); \
2016 //---------------------------------------------------------------------------
2018 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
2019 int CBNAME(long a) const
2022 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
2023 int CLASS::CBNAME(long a) const { \
2026 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2027 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2029 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2031 rval = PyInt_AsLong(ro); \
2035 wxPyEndBlockThreads(blocked); \
2037 rval = PCLASS::CBNAME(a); \
2042 #define DEC_PYCALLBACK_INT_LONG_virtual(CBNAME) \
2043 int CBNAME(long a) const;
2046 #define IMP_PYCALLBACK_INT_LONG_virtual(CLASS, PCLASS, CBNAME) \
2047 int CLASS::CBNAME(long a) const { \
2048 int rval=-1; /* this rval is important for OnGetItemImage */ \
2050 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2051 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2053 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2055 rval = PyInt_AsLong(ro); \
2059 wxPyEndBlockThreads(blocked); \
2064 //---------------------------------------------------------------------------
2066 #define DEC_PYCALLBACK_INT_INT(CBNAME) \
2070 #define IMP_PYCALLBACK_INT_INT(CLASS, PCLASS, CBNAME) \
2071 int CLASS::CBNAME(int a) { \
2074 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2075 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2077 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a)); \
2079 rval = PyInt_AsLong(ro); \
2083 wxPyEndBlockThreads(blocked); \
2085 rval = PCLASS::CBNAME(a); \
2089 //---------------------------------------------------------------------------
2091 #define DEC_PYCALLBACK_INT_LONGLONG(CBNAME) \
2092 int CBNAME(long a, long b) const
2095 #define IMP_PYCALLBACK_INT_LONGLONG(CLASS, PCLASS, CBNAME) \
2096 int CLASS::CBNAME(long a, long b) const { \
2099 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2100 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2102 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2104 rval = PyInt_AsLong(ro); \
2108 wxPyEndBlockThreads(blocked); \
2110 rval = PCLASS::CBNAME(a, b); \
2115 #define DEC_PYCALLBACK_INT_LONGLONG_virtual(CBNAME) \
2116 int CBNAME(long a, long b) const;
2119 #define IMP_PYCALLBACK_INT_LONGLONG_virtual(CLASS, PCLASS, CBNAME) \
2120 int CLASS::CBNAME(long a, long b) const { \
2121 int rval=-1; /* this rval is important for OnGetItemImage */ \
2123 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2124 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2126 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2128 rval = PyInt_AsLong(ro); \
2132 wxPyEndBlockThreads(blocked); \
2137 //---------------------------------------------------------------------------
2139 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2140 wxListItemAttr* CBNAME(long a) const
2143 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2144 wxListItemAttr *CLASS::CBNAME(long a) const { \
2145 wxListItemAttr *rval = NULL; \
2147 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2148 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2150 wxListItemAttr* ptr; \
2151 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2153 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2158 wxPyEndBlockThreads(blocked); \
2160 rval = PCLASS::CBNAME(a); \
2164 //---------------------------------------------------------------------------
2166 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2167 bool CBNAME(wxMouseEvent& e)
2169 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2170 bool CLASS::CBNAME(wxMouseEvent& e) { \
2173 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2174 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2176 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2177 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2179 rval = PyInt_AsLong(ro); \
2184 wxPyEndBlockThreads(blocked); \
2186 return PCLASS::CBNAME(e); \
2190 //---------------------------------------------------------------------------
2192 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2193 wxWizardPage* CBNAME() const
2195 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2196 wxWizardPage* CLASS::CBNAME() const { \
2197 wxWizardPage* rv = NULL; \
2198 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2199 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2201 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2203 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2207 wxPyEndBlockThreads(blocked); \
2211 //---------------------------------------------------------------------------
2213 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2214 wxBitmap CBNAME() const
2216 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2217 wxBitmap CLASS::CBNAME() const { \
2219 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2220 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2223 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2225 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2230 wxPyEndBlockThreads(blocked); \
2234 //---------------------------------------------------------------------------
2236 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2239 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2240 wxObject* CLASS::CBNAME() { \
2241 wxObject* rv = NULL; \
2242 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2243 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2245 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2247 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2251 wxPyEndBlockThreads(blocked); \
2255 //---------------------------------------------------------------------------
2257 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2258 wxObject* CBNAME(const wxString& a)
2260 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2261 wxObject* CLASS::CBNAME(const wxString& a) { \
2262 wxObject* rv = NULL; \
2263 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2264 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2265 PyObject* so = wx2PyString(a); \
2267 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2269 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2274 wxPyEndBlockThreads(blocked); \
2278 //---------------------------------------------------------------------------
2280 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2281 bool CBNAME(wxXmlNode* a)
2284 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2285 bool CLASS::CBNAME(wxXmlNode* a) { \
2287 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2288 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2289 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2290 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2293 wxPyEndBlockThreads(blocked); \
2297 //---------------------------------------------------------------------------
2299 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2300 wxCoord CBNAME(size_t a) const
2303 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2304 wxCoord CLASS::CBNAME(size_t a) const { \
2307 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2308 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2309 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2311 wxPyEndBlockThreads(blocked); \
2315 //---------------------------------------------------------------------------
2317 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2318 void CBNAME(size_t a, size_t b) const
2321 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2322 void CLASS::CBNAME(size_t a, size_t b) const { \
2324 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2325 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2326 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2327 wxPyEndBlockThreads(blocked); \
2329 PCLASS::CBNAME(a,b); \
2331 //---------------------------------------------------------------------------
2333 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2334 wxCoord CBNAME() const
2337 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2338 wxCoord CLASS::CBNAME() const { \
2341 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2342 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2343 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2344 wxPyEndBlockThreads(blocked); \
2346 rval = PCLASS::CBNAME(); \
2350 //---------------------------------------------------------------------------
2352 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2353 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2355 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2356 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2358 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2359 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2360 PyObject* obj = wxPyMake_wxObject(&a,false); \
2361 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2362 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2363 Py_DECREF(obj); Py_DECREF(ro); \
2365 wxPyEndBlockThreads(blocked); \
2370 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2371 void CBNAME(wxDC& a, const wxRect& b, size_t c) const
2373 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2374 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2376 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2377 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2378 PyObject* obj = wxPyMake_wxObject(&a,false); \
2379 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2380 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2381 Py_DECREF(obj); Py_DECREF(ro); \
2383 wxPyEndBlockThreads(blocked); \
2385 PCLASS::CBNAME(a,b,c); \
2389 //---------------------------------------------------------------------------
2390 // Same as the above set, but the wxRect is not const
2392 #define DEC_PYCALLBACK__DCRECTSIZET2_constpure(CBNAME) \
2393 void CBNAME(wxDC& a, wxRect& b, size_t c) const;
2395 #define IMP_PYCALLBACK__DCRECTSIZET2_constpure(CLASS, PCLASS, CBNAME) \
2396 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2398 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2399 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2400 PyObject* obj = wxPyMake_wxObject(&a,false); \
2401 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2402 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2403 Py_DECREF(obj); Py_DECREF(ro); \
2405 wxPyEndBlockThreads(blocked); \
2410 #define DEC_PYCALLBACK__DCRECTSIZET2_const(CBNAME) \
2411 void CBNAME(wxDC& a, wxRect& b, size_t c) const
2413 #define IMP_PYCALLBACK__DCRECTSIZET2_const(CLASS, PCLASS, CBNAME) \
2414 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2416 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2417 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2418 PyObject* obj = wxPyMake_wxObject(&a,false); \
2419 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2420 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2421 Py_DECREF(obj); Py_DECREF(ro); \
2423 wxPyEndBlockThreads(blocked); \
2425 PCLASS::CBNAME(a,b,c); \
2428 //---------------------------------------------------------------------------
2430 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2431 wxString CBNAME(size_t a) const
2433 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2434 wxString CLASS::CBNAME(size_t a) const { \
2437 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2438 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2440 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2442 rval = Py2wxString(ro); \
2446 wxPyEndBlockThreads(blocked); \
2448 rval = PCLASS::CBNAME(a); \
2452 //---------------------------------------------------------------------------
2454 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2455 wxString CBNAME(size_t a) const
2457 #define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \
2458 wxString CLASS::CBNAME(size_t a) const { \
2461 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2462 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2464 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2466 rval = Py2wxString(ro); \
2470 wxPyEndBlockThreads(blocked); \
2474 //---------------------------------------------------------------------------
2476 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2477 wxVisualAttributes CBNAME() const
2480 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2481 wxVisualAttributes CLASS::CBNAME() const { \
2482 wxVisualAttributes rval; \
2484 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2485 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2487 wxVisualAttributes* ptr; \
2488 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2490 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2495 wxPyEndBlockThreads(blocked); \
2497 rval = PCLASS::CBNAME(); \
2501 //---------------------------------------------------------------------------
2503 #define DEC_PYCALLBACK_FONT_INT(CBNAME) \
2504 wxFont CBNAME(int a)
2506 #define IMP_PYCALLBACK_FONT_INT(CLASS, PCLASS, CBNAME) \
2507 wxFont CLASS::CBNAME(int a) { \
2510 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2511 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2514 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2516 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxFont"))) \
2521 wxPyEndBlockThreads(blocked); \
2523 rv = PCLASS::CBNAME(a); \
2527 //---------------------------------------------------------------------------
2529 #define DEC_PYCALLBACK_COLOUR_INT(CBNAME) \
2530 wxColour CBNAME(int a)
2532 #define IMP_PYCALLBACK_COLOUR_INT(CLASS, PCLASS, CBNAME) \
2533 wxColour CLASS::CBNAME(int a) { \
2536 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2537 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2540 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2542 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxColour"))) \
2547 wxPyEndBlockThreads(blocked); \
2549 rv = PCLASS::CBNAME(a); \
2553 //---------------------------------------------------------------------------