1 ////////////////////////////////////////////////////////////////////////////
2 // Name: wxPython_int.h (int == internal)
3 // Purpose: Helper functions/classes for the wxPython extension module
4 // This header should only be inclued directly by those source
5 // modules included in the wx._core module. All others should
6 // include wx/wxPython/wxPython.h instead.
10 // Created: 1-July-1997
12 // Copyright: (c) 1998 by Total Control Software
13 // Licence: wxWindows license
14 /////////////////////////////////////////////////////////////////////////////
16 #ifndef __wxp_helpers__
17 #define __wxp_helpers__
21 #include <wx/busyinfo.h>
23 #include <wx/choicebk.h>
24 #include <wx/clipbrd.h>
25 #include <wx/colordlg.h>
26 #include <wx/config.h>
27 #include <wx/cshelp.h>
28 #include <wx/dcmirror.h>
30 #include <wx/dirctrl.h>
31 #include <wx/dirdlg.h>
32 #include <wx/numdlg.h>
34 #include <wx/docview.h>
35 #include <wx/encconv.h>
36 #include <wx/fdrepdlg.h>
37 #include <wx/fileconf.h>
38 #include <wx/filesys.h>
39 #include <wx/fontdlg.h>
40 #include <wx/fs_inet.h>
41 #include <wx/fs_mem.h>
42 #include <wx/fs_zip.h>
43 #include <wx/gbsizer.h>
44 #include <wx/geometry.h>
45 #include <wx/htmllbox.h>
47 #include <wx/imaglist.h>
49 #include <wx/laywin.h>
50 #include <wx/listbook.h>
51 #include <wx/minifram.h>
52 #include <wx/notebook.h>
54 #include <wx/printdlg.h>
55 #include <wx/process.h>
56 #include <wx/progdlg.h>
57 #include <wx/sashwin.h>
58 #include <wx/spinbutt.h>
59 #include <wx/spinctrl.h>
60 #include <wx/splash.h>
61 #include <wx/splitter.h>
62 #include <wx/statline.h>
63 #include <wx/stream.h>
64 #include <wx/sysopt.h>
65 #include <wx/taskbar.h>
66 #include <wx/tglbtn.h>
67 #include <wx/tipwin.h>
68 #include <wx/toolbook.h>
69 #include <wx/tooltip.h>
70 #include <wx/treebook.h>
72 #include <wx/vscroll.h>
73 #include <wx/dateevt.h>
74 #include <wx/datectrl.h>
76 #include <wx/hyperlink.h>
77 #include <wx/pickerbase.h>
78 #include <wx/clrpicker.h>
79 #include <wx/filepicker.h>
80 #include <wx/fontpicker.h>
84 # pragma warning(disable:4800)
85 # pragma warning(disable:4190)
88 #ifdef __WXMAC__ // avoid a bug in Carbon headers
92 //---------------------------------------------------------------------------
94 #ifndef wxHAS_POWER_EVENTS
95 class wxPowerEvent
: public wxEvent
98 wxPowerEvent(wxEventType evtType
) : wxEvent(wxID_NONE
, evtType
) {}
100 bool IsVetoed() const { return false; }
101 virtual wxEvent
*Clone() const { return new wxPowerEvent(*this); }
105 //---------------------------------------------------------------------------
106 typedef unsigned char byte
;
107 typedef unsigned char* buffer
;
109 typedef wxPoint2DDouble wxPoint2D
;
110 typedef wxRect2DDouble wxRect2D
;
112 #ifndef SWIG_TYPE_TABLE
113 #define SWIG_TYPE_TABLE wxPython_type_table
117 #define wxDEFAULT_STATUSBAR_STYLE wxST_SIZEGRIP|wxFULL_REPAINT_ON_RESIZE
119 #define wxDEFAULT_STATUSBAR_STYLE wxST_SIZEGRIP
123 #ifndef wxPyUSE_EXPORTED_API
125 void __wxPyPreStart(PyObject
*);
126 void __wxPyCleanup();
127 PyObject
* __wxPySetDictionary(PyObject
*, PyObject
* args
);
129 void wxSetDefaultPyEncoding(const char* encoding
);
130 const char* wxGetDefaultPyEncoding();
133 void wxPyEventThunker(wxObject
*, wxEvent
& event
);
136 bool wxPyCheckSwigType(const wxChar
* className
);
137 PyObject
* wxPyConstructObject(void* ptr
,
138 const wxChar
* className
,
140 bool wxPyConvertSwigPtr(PyObject
* obj
, void **ptr
,
141 const wxChar
* className
);
142 PyObject
* wxPyMakeSwigPtr(void* ptr
, const wxChar
* classname
);
145 PyObject
* wx2PyString(const wxString
& src
);
146 wxString
Py2wxString(PyObject
* source
);
148 PyObject
* wxPyMake_wxObject(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
=true);
149 PyObject
* wxPyMake_wxSizer(wxSizer
* source
, bool setThisOwn
);
150 void wxPyPtrTypeMap_Add(const char* commonName
, const char* ptrName
);
152 PyObject
* wxPy_ConvertList(wxListBase
* list
);
153 long wxPyGetWinHandle(wxWindow
* win
);
155 void wxPy_ReinitStockObjects(int pass
);
157 bool wxPyInstance_Check(PyObject
* obj
);
158 bool wxPySwigInstance_Check(PyObject
* obj
);
161 #endif // wxPyUSE_EXPORTED_API
162 //---------------------------------------------------------------------------
164 // if we want to handle threads and Python threads are available...
165 #if defined(WXP_USE_THREAD) && defined(WITH_THREAD)
166 #define WXP_WITH_THREAD
167 #else // no Python threads...
168 #undef WXP_WITH_THREAD
172 // In Python 2.3 and later there are the PyGILState_* APIs that we can use for
173 // blocking threads when calling back into Python. Using them instead of my
174 // home-grown hacks greatly simplifies wxPyBeginBlockThreads and
175 // wxPyEndBlockThreads.
177 // Unfortunatly there is a bug somewhere when using these new APIs on Python
178 // 2.3. It manifests in Boa Constructor's debugger where it is unable to stop
179 // at breakpoints located in event handlers. I think that the cause may be
180 // something like the original PyThreadState for the main thread is not being
181 // restored for the callbacks, but I can't see where that could be
182 // happening... So we'll only activate this new change for Python 2.4+ :-(
184 #if PY_VERSION_HEX < 0x02040000
185 #define wxPyUSE_GIL_STATE 0
186 typedef bool wxPyBlock_t
;
188 #define wxPyUSE_GIL_STATE 1
189 typedef PyGILState_STATE wxPyBlock_t
;
193 // Python 2.5 changes the type of some API parameter and return types. Using
194 // this typedef for versions < 2.5 will help with the transition...
195 #if PY_VERSION_HEX < 0x02050000
196 typedef int Py_ssize_t
;
200 #ifndef wxPyUSE_EXPORTED_API
202 // For Python --> C++
203 PyThreadState
* wxPyBeginAllowThreads();
204 void wxPyEndAllowThreads(PyThreadState
* state
);
206 // For C++ --> Python
207 wxPyBlock_t
wxPyBeginBlockThreads();
208 void wxPyEndBlockThreads(wxPyBlock_t blocked
);
210 #endif // wxPyUSE_EXPORTED_API
213 // A macro that will help to execute simple statments wrapped in
214 // StartBlock/EndBlockThreads calls
215 #define wxPyBLOCK_THREADS(stmt) \
216 { wxPyBlock_t blocked = wxPyBeginBlockThreads(); stmt; wxPyEndBlockThreads(blocked); }
218 // Raise the NotImplementedError exception (blocking threads)
219 #define wxPyRaiseNotImplemented() \
220 wxPyBLOCK_THREADS(PyErr_SetNone(PyExc_NotImplementedError))
222 // Raise any exception with a string value (blocking threads)
223 #define wxPyErr_SetString(err, str) \
224 wxPyBLOCK_THREADS(PyErr_SetString(err, str))
227 //---------------------------------------------------------------------------
228 // These are helpers used by the typemaps
230 #ifndef wxPyUSE_EXPORTED_API
232 wxString
* wxString_in_helper(PyObject
* source
);
234 byte
* byte_LIST_helper(PyObject
* source
);
235 int* int_LIST_helper(PyObject
* source
);
236 long* long_LIST_helper(PyObject
* source
);
237 char** string_LIST_helper(PyObject
* source
);
238 wxPoint
* wxPoint_LIST_helper(PyObject
* source
, int* npoints
);
239 wxPoint2D
* wxPoint2D_LIST_helper(PyObject
* source
, size_t* npoints
);
240 wxBitmap
** wxBitmap_LIST_helper(PyObject
* source
);
241 wxString
* wxString_LIST_helper(PyObject
* source
);
242 wxAcceleratorEntry
* wxAcceleratorEntry_LIST_helper(PyObject
* source
);
243 wxPen
** wxPen_LIST_helper(PyObject
* source
);
245 bool wxSize_helper(PyObject
* source
, wxSize
** obj
);
246 bool wxPoint_helper(PyObject
* source
, wxPoint
** obj
);
247 bool wxRealPoint_helper(PyObject
* source
, wxRealPoint
** obj
);
248 bool wxRect_helper(PyObject
* source
, wxRect
** obj
);
249 bool wxColour_helper(PyObject
* source
, wxColour
** obj
);
250 bool wxPoint2D_helper(PyObject
* source
, wxPoint2D
** obj
);
251 bool wxRect2D_helper(PyObject
* source
, wxRect2D
** obj
);
254 bool wxPySimple_typecheck(PyObject
* source
, const wxChar
* classname
, int seqLen
);
255 bool wxColour_typecheck(PyObject
* source
);
258 // Other helpful stuff
259 bool wxPyCheckForApp();
260 bool wxPyTestDisplayAvailable();
262 bool wxPy2int_seq_helper(PyObject
* source
, int* i1
, int* i2
);
263 bool wxPy4int_seq_helper(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
265 PyObject
* wxArrayString2PyList_helper(const wxArrayString
& arr
);
266 PyObject
* wxArrayInt2PyList_helper(const wxArrayInt
& arr
);
267 PyObject
* wxArrayDouble2PyList_helper(const wxArrayDouble
& arr
);
269 #endif // wxPyUSE_EXPORTED_API
271 //---------------------------------------------------------------------------
273 #if PYTHON_API_VERSION < 1009
274 #define PySequence_Fast_GET_ITEM(o, i) \
275 (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
278 #define RETURN_NONE() { Py_INCREF(Py_None); return Py_None; }
279 #define DECLARE_DEF_STRING(name) static const wxString wxPy##name(wx##name)
280 #define DECLARE_DEF_STRING2(name,val) static const wxString wxPy##name(val)
282 //---------------------------------------------------------------------------
284 #ifndef wxPyUSE_EXPORTED_API
286 class wxPyCallback
: public wxObject
{
287 DECLARE_ABSTRACT_CLASS(wxPyCallback
)
289 wxPyCallback(PyObject
* func
);
290 wxPyCallback(const wxPyCallback
& other
);
293 void EventThunker(wxEvent
& event
);
298 #endif // wxPyUSE_EXPORTED_API
299 //---------------------------------------------------------------------------
300 //---------------------------------------------------------------------------
301 // These Event classes can be derived from in Python and passed through the
302 // event system without loosing anything. They do this by keeping a reference
303 // to themselves and some special case handling in wxPyCallback::EventThunker.
307 class wxPyEvtSelfRef
{
312 void SetSelf(PyObject
* self
, bool clone
=false);
313 PyObject
* GetSelf() const;
314 bool GetCloned() const { return m_cloned
; }
322 class wxPyEvent
: public wxEvent
, public wxPyEvtSelfRef
{
323 DECLARE_ABSTRACT_CLASS(wxPyEvent
)
325 wxPyEvent(int winid
=0, wxEventType commandType
= wxEVT_NULL
);
326 wxPyEvent(const wxPyEvent
& evt
);
329 virtual wxEvent
* Clone() const { return new wxPyEvent(*this); }
333 class wxPyCommandEvent
: public wxCommandEvent
, public wxPyEvtSelfRef
{
334 DECLARE_ABSTRACT_CLASS(wxPyCommandEvent
)
336 wxPyCommandEvent(wxEventType commandType
= wxEVT_NULL
, int id
=0);
337 wxPyCommandEvent(const wxPyCommandEvent
& evt
);
340 virtual wxEvent
* Clone() const { return new wxPyCommandEvent(*this); }
345 //----------------------------------------------------------------------
346 // Forward decalre a few things used in the exported API
347 class wxPyClientData
;
349 class wxPyOORClientData
;
350 class wxPyCBInputStream
;
352 void wxPyClientData_dtor(wxPyClientData
* self
);
353 void wxPyUserData_dtor(wxPyUserData
* self
);
354 void wxPyOORClientData_dtor(wxPyOORClientData
* self
);
355 wxPyCBInputStream
* wxPyCBInputStream_create(PyObject
*py
, bool block
);
356 wxPyCBInputStream
* wxPyCBInputStream_copy(wxPyCBInputStream
* other
);
358 //---------------------------------------------------------------------------
359 // Export a C API in a struct. Other modules will be able to load this from
360 // the wx.core module and will then have safe access to these functions, even if
361 // in another shared library.
363 class wxPyCallbackHelper
;
367 bool (*p_wxPyCheckSwigType
)(const wxChar
* className
);
368 PyObject
* (*p_wxPyConstructObject
)(void* ptr
, const wxChar
* className
, int setThisOwn
);
369 bool (*p_wxPyConvertSwigPtr
)(PyObject
* obj
, void **ptr
, const wxChar
* className
);
370 PyObject
* (*p_wxPyMakeSwigPtr
)(void* ptr
, const wxChar
* className
);
372 PyThreadState
* (*p_wxPyBeginAllowThreads
)();
373 void (*p_wxPyEndAllowThreads
)(PyThreadState
* state
);
374 wxPyBlock_t (*p_wxPyBeginBlockThreads
)();
375 void (*p_wxPyEndBlockThreads
)(wxPyBlock_t blocked
);
377 PyObject
* (*p_wxPy_ConvertList
)(wxListBase
* list
);
379 wxString
* (*p_wxString_in_helper
)(PyObject
* source
);
380 wxString (*p_Py2wxString
)(PyObject
* source
);
381 PyObject
* (*p_wx2PyString
)(const wxString
& src
);
383 byte
* (*p_byte_LIST_helper
)(PyObject
* source
);
384 int* (*p_int_LIST_helper
)(PyObject
* source
);
385 long* (*p_long_LIST_helper
)(PyObject
* source
);
386 char** (*p_string_LIST_helper
)(PyObject
* source
);
387 wxPoint
* (*p_wxPoint_LIST_helper
)(PyObject
* source
, int* npoints
);
388 wxBitmap
** (*p_wxBitmap_LIST_helper
)(PyObject
* source
);
389 wxString
* (*p_wxString_LIST_helper
)(PyObject
* source
);
390 wxAcceleratorEntry
* (*p_wxAcceleratorEntry_LIST_helper
)(PyObject
* source
);
392 bool (*p_wxSize_helper
)(PyObject
* source
, wxSize
** obj
);
393 bool (*p_wxPoint_helper
)(PyObject
* source
, wxPoint
** obj
);
394 bool (*p_wxRealPoint_helper
)(PyObject
* source
, wxRealPoint
** obj
);
395 bool (*p_wxRect_helper
)(PyObject
* source
, wxRect
** obj
);
396 bool (*p_wxColour_helper
)(PyObject
* source
, wxColour
** obj
);
397 bool (*p_wxPoint2D_helper
)(PyObject
* source
, wxPoint2D
** obj
);
400 bool (*p_wxPySimple_typecheck
)(PyObject
* source
, const wxChar
* classname
, int seqLen
);
401 bool (*p_wxColour_typecheck
)(PyObject
* source
);
403 void (*p_wxPyCBH_setCallbackInfo
)(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
404 bool (*p_wxPyCBH_findCallback
)(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
);
405 int (*p_wxPyCBH_callCallback
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
406 PyObject
* (*p_wxPyCBH_callCallbackObj
)(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
407 void (*p_wxPyCBH_delete
)(wxPyCallbackHelper
* cbh
);
409 PyObject
* (*p_wxPyMake_wxObject
)(wxObject
* source
, bool setThisOwn
, bool checkEvtHandler
);
410 PyObject
* (*p_wxPyMake_wxSizer
)(wxSizer
* source
, bool setThisOwn
);
411 void (*p_wxPyPtrTypeMap_Add
)(const char* commonName
, const char* ptrName
);
412 bool (*p_wxPy2int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
);
413 bool (*p_wxPy4int_seq_helper
)(PyObject
* source
, int* i1
, int* i2
, int* i3
, int* i4
);
414 PyObject
* (*p_wxArrayString2PyList_helper
)(const wxArrayString
& arr
);
415 PyObject
* (*p_wxArrayInt2PyList_helper
)(const wxArrayInt
& arr
);
417 void (*p_wxPyClientData_dtor
)(wxPyClientData
*);
418 void (*p_wxPyUserData_dtor
)(wxPyUserData
*);
419 void (*p_wxPyOORClientData_dtor
)(wxPyOORClientData
*);
421 wxPyCBInputStream
* (*p_wxPyCBInputStream_create
)(PyObject
*py
, bool block
);
422 wxPyCBInputStream
* (*p_wxPyCBInputStream_copy
)(wxPyCBInputStream
* other
);
424 bool (*p_wxPyInstance_Check
)(PyObject
* obj
);
425 bool (*p_wxPySwigInstance_Check
)(PyObject
* obj
);
427 bool (*p_wxPyCheckForApp
)();
429 // Add all new items at the end...
430 PyObject
* (*p_wxArrayDoublePyList_helper
)(const wxArrayDouble
& arr
);
431 wxPoint2D
* (*p_wxPoint2D_LIST_helper
)(PyObject
* source
, size_t* npoints
);
432 bool (*p_wxRect2D_helper
)(PyObject
* source
, wxRect2D
** obj
);
437 #ifdef wxPyUSE_EXPORTED_API
438 // Notice that this is static, not extern. This is by design, each module
439 // needs one, but doesn't have to use it.
440 static wxPyCoreAPI
* wxPyCoreAPIPtr
= NULL
;
441 inline wxPyCoreAPI
* wxPyGetCoreAPIPtr();
442 #endif // wxPyUSE_EXPORTED_API
444 //---------------------------------------------------------------------------
446 // A wxObject that holds a reference to a Python object
447 class wxPyUserData
: public wxObject
{
449 wxPyUserData(PyObject
* obj
) {
455 #ifdef wxPyUSE_EXPORTED_API
456 wxPyGetCoreAPIPtr()->p_wxPyUserData_dtor(this);
458 wxPyUserData_dtor(this);
465 // A wxClientData that holds a refernece to a Python object
466 class wxPyClientData
: public wxClientData
{
468 wxPyClientData(PyObject
* obj
, bool incref
=true) {
476 #ifdef wxPyUSE_EXPORTED_API
477 wxPyGetCoreAPIPtr()->p_wxPyClientData_dtor(this);
479 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
, bool incref
=true)
492 : wxPyClientData(obj
, incref
) {}
493 ~wxPyOORClientData() {
495 #ifdef wxPyUSE_EXPORTED_API
496 wxPyGetCoreAPIPtr()->p_wxPyOORClientData_dtor(this);
498 wxPyOORClientData_dtor(this);
504 //---------------------------------------------------------------------------
505 // A wxImageHandler that can be derived from in Python.
508 class wxPyImageHandler
: public wxImageHandler
{
512 // used for interning method names as PyStrings
513 static PyObject
* m_DoCanRead_Name
;
514 static PyObject
* m_GetImageCount_Name
;
515 static PyObject
* m_LoadFile_Name
;
516 static PyObject
* m_SaveFile_Name
;
518 // converstion helpers
519 PyObject
* py_InputStream(wxInputStream
* stream
);
520 PyObject
* py_Image(wxImage
* image
);
521 PyObject
* py_OutputStream(wxOutputStream
* stream
);
526 void _SetSelf(PyObject
*self
);
528 virtual bool LoadFile(wxImage
* image
, wxInputStream
& stream
,
529 bool verbose
=true, int index
=-1 );
530 virtual bool SaveFile(wxImage
* image
, wxOutputStream
& stream
,
532 virtual int GetImageCount(wxInputStream
& stream
);
533 virtual bool DoCanRead(wxInputStream
&stream
);
537 //---------------------------------------------------------------------------
538 // This class holds an instance of a Python Shadow Class object and assists
539 // with looking up and invoking Python callback methods from C++ virtual
540 // method redirections. For all classes which have virtuals which should be
541 // overridable in wxPython, a new subclass is created that contains a
542 // wxPyCallbackHelper.
545 class wxPyCallbackHelper
{
547 wxPyCallbackHelper(const wxPyCallbackHelper
& other
);
549 wxPyCallbackHelper() {
556 ~wxPyCallbackHelper() {
557 #ifdef wxPyUSE_EXPORTED_API
558 wxPyGetCoreAPIPtr()->p_wxPyCBH_delete(this);
560 wxPyCBH_delete(this);
564 void setSelf(PyObject
* self
, PyObject
* klass
, int incref
=true);
565 bool findCallback(const char* name
, bool setGuard
=true) const;
566 int callCallback(PyObject
* argTuple
) const;
567 PyObject
* callCallbackObj(PyObject
* argTuple
) const;
568 PyObject
* GetLastFound() const { return m_lastFound
; }
570 void setRecursionGuard(PyObject
* method
) const;
571 void clearRecursionGuard(PyObject
* method
) const;
576 PyObject
* m_lastFound
;
579 friend void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
583 void wxPyCBH_setCallbackInfo(wxPyCallbackHelper
& cbh
, PyObject
* self
, PyObject
* klass
, int incref
);
584 bool wxPyCBH_findCallback(const wxPyCallbackHelper
& cbh
, const char* name
, bool setGuard
=true);
585 int wxPyCBH_callCallback(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
586 PyObject
* wxPyCBH_callCallbackObj(const wxPyCallbackHelper
& cbh
, PyObject
* argTuple
);
587 void wxPyCBH_delete(wxPyCallbackHelper
* cbh
);
592 //---------------------------------------------------------------------------
594 // This is used in C++ classes that need to be able to make callback to
595 // "overloaded" python methods
598 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
599 wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
601 private: wxPyCallbackHelper m_myInst
604 //---------------------------------------------------------------------------
605 // The wxPythonApp class
608 wxPYAPP_ASSERT_SUPPRESS
= 1,
609 wxPYAPP_ASSERT_EXCEPTION
= 2,
610 wxPYAPP_ASSERT_DIALOG
= 4,
611 wxPYAPP_ASSERT_LOG
= 8
614 class wxPyApp
: public wxApp
616 DECLARE_ABSTRACT_CLASS(wxPyApp
)
624 int GetAssertMode() { return m_assertMode
; }
625 void SetAssertMode(int mode
) { m_assertMode
= mode
; }
627 virtual bool OnInitGui();
628 virtual int OnExit();
630 virtual void OnAssertFailure(const wxChar
*file
,
636 virtual void ExitMainLoop();
637 // virtual int FilterEvent(wxEvent& event); // This one too????
639 // For catching Apple Events
640 virtual void MacOpenFile(const wxString
&fileName
);
641 virtual void MacPrintFile(const wxString
&fileName
);
642 virtual void MacNewFile();
643 virtual void MacReopenApp();
645 static bool GetMacSupportPCMenuShortcuts();
646 static long GetMacAboutMenuItemId();
647 static long GetMacPreferencesMenuItemId();
648 static long GetMacExitMenuItemId();
649 static wxString
GetMacHelpMenuTitleName();
651 static void SetMacSupportPCMenuShortcuts(bool val
);
652 static void SetMacAboutMenuItemId(long val
);
653 static void SetMacPreferencesMenuItemId(long val
);
654 static void SetMacExitMenuItemId(long val
);
655 static void SetMacHelpMenuTitleName(const wxString
& val
);
658 void _BootstrapApp();
660 // implementation only
661 void SetStartupComplete(bool val
) { m_startupComplete
= val
; };
665 bool m_startupComplete
;
668 extern wxPyApp
*wxPythonApp
;
671 //----------------------------------------------------------------------
672 // These macros are used to implement the virtual methods that should
673 // redirect to a Python method if one exists. The names designate the
674 // return type, if any, as well as any parameter types.
675 //---------------------------------------------------------------------------
677 #define DEC_PYCALLBACK__(CBNAME) \
681 #define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
682 void CLASS::CBNAME() { \
684 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
685 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
686 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
687 wxPyEndBlockThreads(blocked); \
692 #define DEC_PYCALLBACK_VOID_(CBNAME) \
693 DEC_PYCALLBACK__(CBNAME)
695 #define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
696 IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME)
698 //---------------------------------------------------------------------------
700 #define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
701 bool CBNAME(int a, int b)
704 #define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
705 bool CLASS::CBNAME(int a, int b) { \
706 bool rval=false, found; \
707 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
708 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
709 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
710 wxPyEndBlockThreads(blocked); \
712 rval = PCLASS::CBNAME(a,b); \
716 //---------------------------------------------------------------------------
718 #define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
719 void CBNAME(int a, int b)
722 #define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
723 void CLASS::CBNAME(int a, int b) { \
725 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
726 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
727 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
728 wxPyEndBlockThreads(blocked); \
730 PCLASS::CBNAME(a,b); \
733 //---------------------------------------------------------------------------
735 #define DEC_PYCALLBACK_VOID_INT(CBNAME) \
739 #define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
740 void CLASS::CBNAME(int a) { \
742 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
743 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
744 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
745 wxPyEndBlockThreads(blocked); \
750 //---------------------------------------------------------------------------
752 #define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
753 void CBNAME(int a, int b, int c, int d)
756 #define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
757 void CLASS::CBNAME(int a, int b, int c, int d) { \
759 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
760 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
761 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
762 wxPyEndBlockThreads(blocked); \
764 PCLASS::CBNAME(a,b,c,d); \
767 //---------------------------------------------------------------------------
768 #define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
769 void CBNAME(int a, int b, int c, int d, int e)
772 #define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
773 void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
775 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
776 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
777 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
778 wxPyEndBlockThreads(blocked); \
780 PCLASS::CBNAME(a,b,c,d,e); \
783 //---------------------------------------------------------------------------
785 #define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
786 void CBNAME(int* a, int* b) const
789 #define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
790 void CLASS::CBNAME(int* a, int* b) const { \
791 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
793 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
794 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
796 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
798 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
799 PyObject* o1 = PySequence_GetItem(ro, 0); \
800 PyObject* o2 = PySequence_GetItem(ro, 1); \
801 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
802 *a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
805 PyErr_SetString(PyExc_TypeError, errmsg); \
810 PyErr_SetString(PyExc_TypeError, errmsg); \
815 wxPyEndBlockThreads(blocked); \
817 PCLASS::CBNAME(a,b); \
820 //---------------------------------------------------------------------------
822 #define DEC_PYCALLBACK_SIZE_const(CBNAME) \
823 wxSize CBNAME() const
826 #define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
827 wxSize CLASS::CBNAME() const { \
828 const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
829 bool found; wxSize rval(0,0); \
830 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
831 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
833 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
835 if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
836 PyObject* o1 = PySequence_GetItem(ro, 0); \
837 PyObject* o2 = PySequence_GetItem(ro, 1); \
838 if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
839 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
842 PyErr_SetString(PyExc_TypeError, errmsg); \
847 PyErr_SetString(PyExc_TypeError, errmsg); \
852 wxPyEndBlockThreads(blocked); \
854 return PCLASS::CBNAME(); \
859 //---------------------------------------------------------------------------
861 #define DEC_PYCALLBACK_BOOL_BOOL(CBNAME) \
865 #define IMP_PYCALLBACK_BOOL_BOOL(CLASS, PCLASS, CBNAME) \
866 bool CLASS::CBNAME(bool a) { \
867 bool rval=false, found; \
868 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
869 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
870 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
871 wxPyEndBlockThreads(blocked); \
873 rval = PCLASS::CBNAME(a); \
877 //---------------------------------------------------------------------------
879 #define DEC_PYCALLBACK_BOOL_INT(CBNAME) \
883 #define IMP_PYCALLBACK_BOOL_INT(CLASS, PCLASS, CBNAME) \
884 bool CLASS::CBNAME(int a) { \
885 bool rval=false, found; \
886 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
887 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
888 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a));\
889 wxPyEndBlockThreads(blocked); \
891 rval = PCLASS::CBNAME(a); \
895 //---------------------------------------------------------------------------
897 #define DEC_PYCALLBACK_BOOL_INT_pure(CBNAME) \
901 #define IMP_PYCALLBACK_BOOL_INT_pure(CLASS, PCLASS, CBNAME) \
902 bool CLASS::CBNAME(int a) { \
904 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
905 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
906 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
908 wxPyEndBlockThreads(blocked); \
913 //---------------------------------------------------------------------------
915 #define DEC_PYCALLBACK__DC(CBNAME) \
919 #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \
920 void CLASS::CBNAME(wxDC& a) { \
922 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
923 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
924 PyObject* obj = wxPyMake_wxObject(&a,false); \
925 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
928 wxPyEndBlockThreads(blocked); \
934 //---------------------------------------------------------------------------
936 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
937 void CBNAME(wxDC& a, bool b)
940 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
941 void CLASS::CBNAME(wxDC& a, bool b) { \
943 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
944 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
945 PyObject* obj = wxPyMake_wxObject(&a,false); \
946 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
949 wxPyEndBlockThreads(blocked); \
951 PCLASS::CBNAME(a, b); \
954 //---------------------------------------------------------------------------
956 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
957 void CBNAME(wxDC& a, bool b)
960 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
961 void CLASS::CBNAME(wxDC& a, bool b) { \
963 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
964 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
965 PyObject* obj = wxPyMake_wxObject(&a,false); \
966 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
969 wxPyEndBlockThreads(blocked); \
971 PCLASS::CBNAME(a, b); \
974 //---------------------------------------------------------------------------
976 #define DEC_PYCALLBACK__2DBL(CBNAME) \
977 void CBNAME(double a, double b)
980 #define IMP_PYCALLBACK__2DBL(CLASS, PCLASS, CBNAME) \
981 void CLASS::CBNAME(double a, double b) { \
983 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
984 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
985 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(dd)",a,b)); \
986 wxPyEndBlockThreads(blocked); \
988 PCLASS::CBNAME(a, b); \
991 //---------------------------------------------------------------------------
993 #define DEC_PYCALLBACK__2DBL2INT(CBNAME) \
994 void CBNAME(double a, double b, int c, int d)
997 #define IMP_PYCALLBACK__2DBL2INT(CLASS, PCLASS, CBNAME) \
998 void CLASS::CBNAME(double a, double b, int c, int d) { \
1000 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1001 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1002 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddii)", \
1004 wxPyEndBlockThreads(blocked); \
1006 PCLASS::CBNAME(a, b, c, d); \
1009 //---------------------------------------------------------------------------
1011 #define DEC_PYCALLBACK__DC4DBLBOOL(CBNAME) \
1012 void CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1015 #define IMP_PYCALLBACK__DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1016 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1018 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1019 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1020 PyObject* obj = wxPyMake_wxObject(&a,false); \
1021 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f)); \
1024 wxPyEndBlockThreads(blocked); \
1026 PCLASS::CBNAME(a, b, c, d, e, f); \
1029 //---------------------------------------------------------------------------
1031 #define DEC_PYCALLBACK_BOOL_DC4DBLBOOL(CBNAME) \
1032 bool CBNAME(wxDC& a, double b, double c, double d, double e, bool f)
1035 #define IMP_PYCALLBACK_BOOL_DC4DBLBOOL(CLASS, PCLASS, CBNAME) \
1036 bool CLASS::CBNAME(wxDC& a, double b, double c, double d, double e, bool f) { \
1038 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1040 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1041 PyObject* obj = wxPyMake_wxObject(&a,false); \
1042 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddddi)", obj, b, c, d, e, (int)f));\
1045 wxPyEndBlockThreads(blocked); \
1047 rval = PCLASS::CBNAME(a, b, c, d, e, f); \
1051 //---------------------------------------------------------------------------
1053 #define DEC_PYCALLBACK__BOOL2DBL2INT(CBNAME) \
1054 void CBNAME(bool a, double b, double c, int d, int e)
1057 #define IMP_PYCALLBACK__BOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1058 void CLASS::CBNAME(bool a, double b, double c, int d, int e) { \
1060 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1061 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1062 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddii)", \
1064 wxPyEndBlockThreads(blocked); \
1066 PCLASS::CBNAME(a, b, c, d, e); \
1069 //---------------------------------------------------------------------------
1071 #define DEC_PYCALLBACK__DC4DBL(CBNAME) \
1072 void CBNAME(wxDC& a, double b, double c, double d, double e)
1075 #define IMP_PYCALLBACK__DC4DBL(CLASS, PCLASS, CBNAME) \
1076 void CLASS::CBNAME(wxDC& a, double b, double c, double d, double e) { \
1078 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1079 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1080 PyObject* obj = wxPyMake_wxObject(&a,false); \
1081 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Odddd)", obj, b, c, d, e)); \
1084 wxPyEndBlockThreads(blocked); \
1086 PCLASS::CBNAME(a, b, c, d, e); \
1089 //---------------------------------------------------------------------------
1091 #define DEC_PYCALLBACK__DCBOOL(CBNAME) \
1092 void CBNAME(wxDC& a, bool b)
1095 #define IMP_PYCALLBACK__DCBOOL(CLASS, PCLASS, CBNAME) \
1096 void CLASS::CBNAME(wxDC& a, bool b) { \
1098 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1099 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1100 PyObject* obj = wxPyMake_wxObject(&a,false); \
1101 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)", obj, (int)b)); \
1104 wxPyEndBlockThreads(blocked); \
1106 PCLASS::CBNAME(a, b); \
1109 //---------------------------------------------------------------------------
1111 #define DEC_PYCALLBACK__WXCPBOOL2DBL2INT(CBNAME) \
1112 void CBNAME(wxControlPoint* a, bool b, double c, double d, int e, int f)
1115 #define IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PCLASS, CBNAME) \
1116 void CLASS::CBNAME(wxControlPoint* a, bool b, double c, double d, \
1119 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1120 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1121 PyObject* obj = wxPyMake_wxObject(a,false); \
1122 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oiddii)", obj, (int)b, c, d, e, f));\
1125 wxPyEndBlockThreads(blocked); \
1127 PCLASS::CBNAME(a, b, c, d, e, f); \
1130 //---------------------------------------------------------------------------
1132 #define DEC_PYCALLBACK__WXCP2DBL2INT(CBNAME) \
1133 void CBNAME(wxControlPoint* a, double b, double c, int d, int e)
1136 #define IMP_PYCALLBACK__WXCP2DBL2INT(CLASS, PCLASS, CBNAME) \
1137 void CLASS::CBNAME(wxControlPoint* a, double b, double c, int d, int e) { \
1139 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1140 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1141 PyObject* obj = wxPyMake_wxObject(a,false); \
1142 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oddii)", obj, b, c, d, e)); \
1145 wxPyEndBlockThreads(blocked); \
1147 PCLASS::CBNAME(a, b, c, d, e); \
1150 //---------------------------------------------------------------------------
1152 #define DEC_PYCALLBACK__2DBLINT(CBNAME) \
1153 void CBNAME(double a, double b, int c)
1156 #define IMP_PYCALLBACK__2DBLINT(CLASS, PCLASS, CBNAME) \
1157 void CLASS::CBNAME(double a, double b, int c) { \
1159 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1160 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1161 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ddi)", a,b,c)); \
1162 wxPyEndBlockThreads(blocked); \
1164 PCLASS::CBNAME(a, b, c); \
1167 //---------------------------------------------------------------------------
1169 #define DEC_PYCALLBACK__BOOL2DBLINT(CBNAME) \
1170 void CBNAME(bool a, double b, double c, int d)
1173 #define IMP_PYCALLBACK__BOOL2DBLINT(CLASS, PCLASS, CBNAME) \
1174 void CLASS::CBNAME(bool a, double b, double c, int d) { \
1176 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1177 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1178 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iddi)", (int)a,b,c,d));\
1179 wxPyEndBlockThreads(blocked); \
1181 PCLASS::CBNAME(a, b, c, d); \
1184 //---------------------------------------------------------------------------
1185 //---------------------------------------------------------------------------
1187 #define DEC_PYCALLBACK__STRING(CBNAME) \
1188 void CBNAME(const wxString& a)
1190 #define IMP_PYCALLBACK__STRING(CLASS, PCLASS, CBNAME) \
1191 void CLASS::CBNAME(const wxString& a) { \
1193 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1194 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1195 PyObject* s = wx2PyString(a); \
1196 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1199 wxPyEndBlockThreads(blocked); \
1201 PCLASS::CBNAME(a); \
1204 //---------------------------------------------------------------------------
1206 #define DEC_PYCALLBACK_BOOL_STRING(CBNAME) \
1207 bool CBNAME(const wxString& a)
1209 #define IMP_PYCALLBACK_BOOL_STRING(CLASS, PCLASS, CBNAME) \
1210 bool CLASS::CBNAME(const wxString& a) { \
1213 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1214 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1215 PyObject* s = wx2PyString(a); \
1216 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1219 wxPyEndBlockThreads(blocked); \
1221 rval = PCLASS::CBNAME(a); \
1225 //---------------------------------------------------------------------------
1227 #define DEC_PYCALLBACK_BOOL_STRING_pure(CBNAME) \
1228 bool CBNAME(const wxString& a)
1230 #define IMP_PYCALLBACK_BOOL_STRING_pure(CLASS, PCLASS, CBNAME) \
1231 bool CLASS::CBNAME(const wxString& a) { \
1233 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1234 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1235 PyObject* s = wx2PyString(a); \
1236 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", s)); \
1239 wxPyEndBlockThreads(blocked); \
1243 //---------------------------------------------------------------------------
1245 #define DEC_PYCALLBACK_STRING_STRING_pure(CBNAME) \
1246 wxString CBNAME(const wxString& a)
1248 #define IMP_PYCALLBACK_STRING_STRING_pure(CLASS, PCLASS, CBNAME) \
1249 wxString CLASS::CBNAME(const wxString& a) { \
1251 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1252 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1254 PyObject* s = wx2PyString(a); \
1255 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \
1258 rval = Py2wxString(ro); \
1262 wxPyEndBlockThreads(blocked); \
1266 //---------------------------------------------------------------------------
1268 #define DEC_PYCALLBACK_STRING_STRING(CBNAME) \
1269 wxString CBNAME(const wxString& a)
1271 #define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \
1272 wxString CLASS::CBNAME(const wxString& a) { \
1275 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1276 if ((found = 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); \
1288 rval = PCLASS::CBNAME(a); \
1292 //---------------------------------------------------------------------------
1294 #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \
1295 wxString CBNAME(const wxString& a,int b)
1297 #define IMP_PYCALLBACK_STRING_STRINGINT_pure(CLASS, PCLASS, CBNAME) \
1298 wxString CLASS::CBNAME(const wxString& a,int b) { \
1300 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1301 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1303 PyObject* s = wx2PyString(a); \
1304 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oi)",s,b)); \
1307 rval = Py2wxString(ro); \
1311 wxPyEndBlockThreads(blocked); \
1315 //---------------------------------------------------------------------------
1317 #define DEC_PYCALLBACK_BOOL_STRINGSTRING(CBNAME) \
1318 bool CBNAME(const wxString& a, const wxString& b)
1320 #define IMP_PYCALLBACK_BOOL_STRINGSTRING(CLASS, PCLASS, CBNAME) \
1321 bool CLASS::CBNAME(const wxString& a, const wxString& b) { \
1324 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1325 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1326 PyObject* s1 = wx2PyString(a); \
1327 PyObject* s2 = wx2PyString(b); \
1328 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",s1,s2)); \
1332 wxPyEndBlockThreads(blocked); \
1334 rval = PCLASS::CBNAME(a, b); \
1338 //---------------------------------------------------------------------------
1340 #define DEC_PYCALLBACK_STRING_(CBNAME) \
1343 #define IMP_PYCALLBACK_STRING_(CLASS, PCLASS, CBNAME) \
1344 wxString CLASS::CBNAME() { \
1347 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1348 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1350 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1352 rval = Py2wxString(ro); \
1356 wxPyEndBlockThreads(blocked); \
1358 rval = PCLASS::CBNAME(); \
1362 //---------------------------------------------------------------------------
1364 #define DEC_PYCALLBACK_STRING__const(CBNAME) \
1365 wxString CBNAME() const
1367 #define IMP_PYCALLBACK_STRING__const(CLASS, PCLASS, CBNAME) \
1368 wxString CLASS::CBNAME() const { \
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__pure(CBNAME) \
1391 #define IMP_PYCALLBACK_STRING__pure(CLASS, PCLASS, CBNAME) \
1392 wxString CLASS::CBNAME() { \
1394 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1395 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1397 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1399 rval = Py2wxString(ro); \
1403 wxPyEndBlockThreads(blocked); \
1407 //---------------------------------------------------------------------------
1409 #define DEC_PYCALLBACK_STRING__constpure(CBNAME) \
1410 wxString CBNAME() const;
1412 #define IMP_PYCALLBACK_STRING__constpure(CLASS, PCLASS, CBNAME) \
1413 wxString CLASS::CBNAME() const { \
1415 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1416 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1418 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1420 rval = Py2wxString(ro); \
1424 wxPyEndBlockThreads(blocked); \
1428 //---------------------------------------------------------------------------
1430 #define DEC_PYCALLBACK_BOOL_TAG_pure(CBNAME) \
1431 bool CBNAME(const wxHtmlTag& a)
1434 #define IMP_PYCALLBACK_BOOL_TAG_pure(CLASS, PCLASS, CBNAME) \
1435 bool CLASS::CBNAME(const wxHtmlTag& a) { \
1437 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1438 if (wxPyCBH_findCallback2(m_myInst, #CBNAME, false)) { \
1439 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxHtmlTag"), 0);\
1440 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1443 wxPyEndBlockThreads(blocked); \
1447 //---------------------------------------------------------------------------
1449 #define DEC_PYCALLBACK__CELLINTINT(CBNAME) \
1450 void CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y)
1452 #define IMP_PYCALLBACK__CELLINTINT(CLASS, PCLASS, CBNAME) \
1453 void CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y) { \
1455 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1456 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1457 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1458 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(Oii)",obj,x,y)); \
1461 wxPyEndBlockThreads(blocked); \
1463 PCLASS::CBNAME(cell, x, y); \
1466 //---------------------------------------------------------------------------
1468 #define DEC_PYCALLBACK__COLOUR(CBNAME) \
1469 void CBNAME(const wxColour& c);
1471 #define IMP_PYCALLBACK__COLOUR(CLASS, PCLASS, CBNAME) \
1472 void CLASS::CBNAME(const wxColour& c) { \
1474 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1475 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1476 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1477 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
1480 wxPyEndBlockThreads(blocked); \
1482 PCLASS::CBNAME(c); \
1485 //---------------------------------------------------------------------------
1486 #define DEC_PYCALLBACK__INTCOLOUR(CBNAME) \
1487 void CBNAME(int a, const wxColour& c);
1489 #define IMP_PYCALLBACK__INTCOLOUR(CLASS, PCLASS, CBNAME) \
1490 void CLASS::CBNAME(int a, const wxColour& c) { \
1492 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1493 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1494 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxColour"), 0); \
1495 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)",a, obj)); \
1498 wxPyEndBlockThreads(blocked); \
1500 PCLASS::CBNAME(a, c); \
1503 //---------------------------------------------------------------------------
1505 #define DEC_PYCALLBACK__INTFONT(CBNAME) \
1506 void CBNAME(int a, const wxFont& c);
1508 #define IMP_PYCALLBACK__INTFONT(CLASS, PCLASS, CBNAME) \
1509 void CLASS::CBNAME(int a, const wxFont& c) { \
1511 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1512 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1513 PyObject* obj = wxPyConstructObject((void*)&c, wxT("wxFont"), 0); \
1514 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)",a, obj)); \
1517 wxPyEndBlockThreads(blocked); \
1519 PCLASS::CBNAME(a, c); \
1522 //---------------------------------------------------------------------------
1524 #define DEC_PYCALLBACK__FONT(CBNAME) \
1525 void CBNAME(const wxFont& a);
1527 #define IMP_PYCALLBACK__FONT(CLASS, PCLASS, CBNAME) \
1528 void CLASS::CBNAME(const wxFont& a) { \
1530 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1531 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1532 PyObject* obj = wxPyConstructObject((void*)&a, wxT("wxFont"), 0); \
1533 wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj)); \
1536 wxPyEndBlockThreads(blocked); \
1538 PCLASS::CBNAME(a); \
1541 //---------------------------------------------------------------------------
1543 #define DEC_PYCALLBACK_BOOL_CELLINTINTME(CBNAME) \
1544 bool CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e)
1546 #define IMP_PYCALLBACK_BOOL_CELLINTINTME(CLASS, PCLASS, CBNAME) \
1547 bool CLASS::CBNAME(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& e) { \
1548 bool rval=false, found; \
1549 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1550 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1551 PyObject* obj = wxPyMake_wxObject(cell, 0); \
1552 PyObject* o2 = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
1553 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiiO)",obj,x,y,o2)); \
1557 wxPyEndBlockThreads(blocked); \
1559 rval = PCLASS::CBNAME(cell, x, y, e); \
1564 //---------------------------------------------------------------------------
1566 #define DEC_PYCALLBACK___pure(CBNAME) \
1570 #define IMP_PYCALLBACK___pure(CLASS, PCLASS, CBNAME) \
1571 void CLASS::CBNAME() { \
1572 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1573 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1574 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1575 wxPyEndBlockThreads(blocked); \
1578 //---------------------------------------------------------------------------
1580 #define DEC_PYCALLBACK_wxSize__pure(CBNAME) \
1584 #define IMP_PYCALLBACK_wxSize__pure(CLASS, PCLASS, CBNAME) \
1585 wxSize CLASS::CBNAME() { \
1586 const char* errmsg = #CBNAME " should return a 2-tuple of integers or a wxSize object."; \
1588 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1589 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1592 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
1594 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) \
1596 else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
1598 PyObject* o1 = PySequence_GetItem(ro, 0); \
1599 PyObject* o2 = PySequence_GetItem(ro, 1); \
1600 if (PyNumber_Check(o1) && PyNumber_Check(o2)) \
1601 rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2)); \
1603 PyErr_SetString(PyExc_TypeError, errmsg); \
1608 PyErr_SetString(PyExc_TypeError, errmsg); \
1613 wxPyEndBlockThreads(blocked); \
1617 //---------------------------------------------------------------------------
1619 #define DEC_PYCALLBACK_BOOL_WXWIN(CBNAME) \
1620 bool CBNAME(wxWindow* a)
1623 #define IMP_PYCALLBACK_BOOL_WXWIN(CLASS, PCLASS, CBNAME) \
1624 bool CLASS::CBNAME(wxWindow* a) { \
1627 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1628 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1629 PyObject* obj = wxPyMake_wxObject(a,false); \
1630 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1633 wxPyEndBlockThreads(blocked); \
1635 rval = PCLASS::CBNAME(a); \
1639 //---------------------------------------------------------------------------
1641 #define DEC_PYCALLBACK_BOOL_WXWINDC(CBNAME) \
1642 bool CBNAME(wxWindow* a, wxDC& b)
1645 #define IMP_PYCALLBACK_BOOL_WXWINDC(CLASS, PCLASS, CBNAME) \
1646 bool CLASS::CBNAME(wxWindow* a, wxDC& b) { \
1649 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1650 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1651 PyObject* win = wxPyMake_wxObject(a,false); \
1652 PyObject* dc = wxPyMake_wxObject(&b,false); \
1653 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", win, dc));\
1657 wxPyEndBlockThreads(blocked); \
1659 rval = PCLASS::CBNAME(a, b); \
1663 //---------------------------------------------------------------------------
1665 #define DEC_PYCALLBACK_VOID_WXWINBASE(CBNAME) \
1666 void CBNAME(wxWindowBase* a)
1669 #define IMP_PYCALLBACK_VOID_WXWINBASE(CLASS, PCLASS, CBNAME) \
1670 void CLASS::CBNAME(wxWindowBase* a) { \
1672 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1673 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1674 PyObject* obj = wxPyMake_wxObject(a,false); \
1675 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1678 wxPyEndBlockThreads(blocked); \
1680 PCLASS::CBNAME(a); \
1683 //---------------------------------------------------------------------------
1685 #define DEC_PYCALLBACK_BOOL_(CBNAME) \
1689 #define IMP_PYCALLBACK_BOOL_(CLASS, PCLASS, CBNAME) \
1690 bool CLASS::CBNAME() { \
1693 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1694 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1695 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1696 wxPyEndBlockThreads(blocked); \
1698 rval = PCLASS::CBNAME(); \
1702 //---------------------------------------------------------------------------
1704 #define DEC_PYCALLBACK_BOOL_const(CBNAME) \
1708 #define IMP_PYCALLBACK_BOOL_const(CLASS, PCLASS, CBNAME) \
1709 bool CLASS::CBNAME() const { \
1712 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1713 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1714 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1715 wxPyEndBlockThreads(blocked); \
1717 rval = PCLASS::CBNAME(); \
1721 //---------------------------------------------------------------------------
1723 #define DEC_PYCALLBACK_DR_2WXCDR(CBNAME) \
1724 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1727 #define IMP_PYCALLBACK_DR_2WXCDR(CLASS, PCLASS, CBNAME) \
1728 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1731 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1732 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1733 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1734 wxPyEndBlockThreads(blocked); \
1736 rval = PCLASS::CBNAME(a, b, c); \
1737 return (wxDragResult)rval; \
1740 //---------------------------------------------------------------------------
1742 #define DEC_PYCALLBACK_FSF_FSSTRING_pure(CBNAME) \
1743 wxFSFile* CBNAME(wxFileSystem& fs, const wxString& location)
1745 #define IMP_PYCALLBACK_FSF_FSSTRING_pure(CLASS, PCLASS, CBNAME) \
1746 wxFSFile* CLASS::CBNAME(wxFileSystem& a,const wxString& b) { \
1747 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1749 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1751 PyObject* obj = wxPyMake_wxObject(&a,false); \
1752 PyObject* s = wx2PyString(b); \
1753 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", \
1756 wxPyConvertSwigPtr(ro, (void **)&rval, wxT("wxFSFile")); \
1757 /* release ownership of the C++ wx.FSFile object. */ \
1758 PyObject_SetAttrString(ro, "thisown", Py_False); \
1764 wxPyEndBlockThreads(blocked); \
1768 //---------------------------------------------------------------------------
1770 #define DEC_PYCALLBACK_BOOL_DR(CBNAME) \
1771 bool CBNAME(wxDragResult a)
1774 #define IMP_PYCALLBACK_BOOL_DR(CLASS, PCLASS, CBNAME) \
1775 bool CLASS::CBNAME(wxDragResult a) { \
1778 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1779 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1780 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
1781 wxPyEndBlockThreads(blocked); \
1783 rval = PCLASS::CBNAME(a); \
1787 //---------------------------------------------------------------------------
1789 #define DEC_PYCALLBACK_DR_2WXCDR_pure(CBNAME) \
1790 wxDragResult CBNAME(wxCoord x, wxCoord y, wxDragResult def)
1793 #define IMP_PYCALLBACK_DR_2WXCDR_pure(CLASS, PCLASS, CBNAME) \
1794 wxDragResult CLASS::CBNAME(wxCoord a, wxCoord b, wxDragResult c) { \
1795 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1797 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) \
1798 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", a,b,c));\
1799 wxPyEndBlockThreads(blocked); \
1800 return (wxDragResult)rval; \
1803 //---------------------------------------------------------------------------
1805 #define DEC_PYCALLBACK_BOOL_INTINTSTR_pure(CBNAME) \
1806 bool CBNAME(int a, int b, const wxString& c)
1808 #define IMP_PYCALLBACK_BOOL_INTINTSTR_pure(CLASS, PCLASS, CBNAME) \
1809 bool CLASS::CBNAME(int a, int b, const wxString& c) { \
1811 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1812 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1813 PyObject* s = wx2PyString(c); \
1814 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",a,b,s));\
1817 wxPyEndBlockThreads(blocked); \
1821 //---------------------------------------------------------------------------
1823 #define DEC_PYCALLBACK_SIZET_(CBNAME) \
1827 #define IMP_PYCALLBACK_SIZET_(CLASS, PCLASS, CBNAME) \
1828 size_t CLASS::CBNAME() { \
1831 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1832 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1833 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1834 wxPyEndBlockThreads(blocked); \
1836 rval = PCLASS::CBNAME(); \
1840 //---------------------------------------------------------------------------
1842 #define DEC_PYCALLBACK_SIZET__const(CBNAME) \
1843 size_t CBNAME() const
1846 #define IMP_PYCALLBACK_SIZET__const(CLASS, PCLASS, CBNAME) \
1847 size_t CLASS::CBNAME() const { \
1850 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1851 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
1852 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
1853 wxPyEndBlockThreads(blocked); \
1855 rval = PCLASS::CBNAME(); \
1859 //---------------------------------------------------------------------------
1861 #define DEC_PYCALLBACK_DATAFMT_SIZET(CBNAME) \
1862 wxDataFormat CBNAME(size_t a)
1865 #define IMP_PYCALLBACK_DATAFMT_SIZET(CLASS, PCLASS, CBNAME) \
1866 wxDataFormat CLASS::CBNAME(size_t a) { \
1867 wxDataFormat rval=0; \
1869 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1870 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1872 wxDataFormat* ptr; \
1873 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
1875 if (wxPyCOnvertSwigPtr(ro, (void **)&ptr, wxT("wxDataFormat"))) \
1880 wxPyEndBlockThreads(blocked); \
1882 rval = PCLASS::CBNAME(a); \
1886 //---------------------------------------------------------------------------
1888 #define DEC_PYCALLBACK__constany(CBNAME, Type) \
1889 void CBNAME(const Type& a)
1892 #define IMP_PYCALLBACK__constany(CLASS, PCLASS, CBNAME, Type) \
1893 void CLASS::CBNAME(const Type& a) { \
1895 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1896 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1897 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1898 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1901 wxPyEndBlockThreads(blocked); \
1903 PCLASS::CBNAME(a); \
1907 //---------------------------------------------------------------------------
1909 #define DEC_PYCALLBACK__any(CBNAME, Type) \
1910 void CBNAME(Type& a)
1913 #define IMP_PYCALLBACK__any(CLASS, PCLASS, CBNAME, Type) \
1914 void CLASS::CBNAME(Type& a) { \
1916 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1917 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1918 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1919 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1922 wxPyEndBlockThreads(blocked); \
1924 PCLASS::CBNAME(a); \
1927 //---------------------------------------------------------------------------
1929 #define DEC_PYCALLBACK_bool_any(CBNAME, Type) \
1930 bool CBNAME(Type& a)
1933 #define IMP_PYCALLBACK_bool_any(CLASS, PCLASS, CBNAME, Type) \
1934 bool CLASS::CBNAME(Type& a) { \
1937 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1938 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1939 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1940 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1943 wxPyEndBlockThreads(blocked); \
1945 rv = PCLASS::CBNAME(a); \
1949 //---------------------------------------------------------------------------
1951 #define DEC_PYCALLBACK_bool_anypure(CBNAME, Type) \
1952 bool CBNAME(Type& a)
1955 #define IMP_PYCALLBACK_bool_anypure(CLASS, PCLASS, CBNAME, Type) \
1956 bool CLASS::CBNAME(Type& a) { \
1958 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1959 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
1960 PyObject* obj = wxPyConstructObject((void*)&a, wxT(#Type), 0); \
1961 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
1964 wxPyEndBlockThreads(blocked); \
1968 //---------------------------------------------------------------------------
1970 #define DEC_PYCALLBACK_STRING_LONGLONG(CBNAME) \
1971 wxString CBNAME(long a, long b) const
1973 #define IMP_PYCALLBACK_STRING_LONGLONG(CLASS, PCLASS, CBNAME) \
1974 wxString CLASS::CBNAME(long a, long b) const { \
1977 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
1978 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
1980 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
1982 rval = Py2wxString(ro); \
1986 wxPyEndBlockThreads(blocked); \
1988 rval = PCLASS::CBNAME(a,b); \
1992 //---------------------------------------------------------------------------
1994 #define DEC_PYCALLBACK_INT_LONG(CBNAME) \
1995 int CBNAME(long a) const
1998 #define IMP_PYCALLBACK_INT_LONG(CLASS, PCLASS, CBNAME) \
1999 int CLASS::CBNAME(long a) const { \
2002 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2003 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2005 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2007 rval = PyInt_AsLong(ro); \
2011 wxPyEndBlockThreads(blocked); \
2013 rval = PCLASS::CBNAME(a); \
2018 #define DEC_PYCALLBACK_INT_LONG_virtual(CBNAME) \
2019 int CBNAME(long a) const;
2022 #define IMP_PYCALLBACK_INT_LONG_virtual(CLASS, PCLASS, CBNAME) \
2023 int CLASS::CBNAME(long a) const { \
2024 int rval=-1; /* this rval is important for OnGetItemImage */ \
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); \
2040 //---------------------------------------------------------------------------
2042 #define DEC_PYCALLBACK_INT_INT(CBNAME) \
2046 #define IMP_PYCALLBACK_INT_INT(CLASS, PCLASS, CBNAME) \
2047 int CLASS::CBNAME(int a) { \
2050 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2051 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2053 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a)); \
2055 rval = PyInt_AsLong(ro); \
2059 wxPyEndBlockThreads(blocked); \
2061 rval = PCLASS::CBNAME(a); \
2065 //---------------------------------------------------------------------------
2067 #define DEC_PYCALLBACK_INT_LONGLONG(CBNAME) \
2068 int CBNAME(long a, long b) const
2071 #define IMP_PYCALLBACK_INT_LONGLONG(CLASS, PCLASS, CBNAME) \
2072 int CLASS::CBNAME(long a, long b) const { \
2075 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2076 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2078 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ll)",a,b)); \
2080 rval = PyInt_AsLong(ro); \
2084 wxPyEndBlockThreads(blocked); \
2086 rval = PCLASS::CBNAME(a, b); \
2091 #define DEC_PYCALLBACK_INT_LONGLONG_virtual(CBNAME) \
2092 int CBNAME(long a, long b) const;
2095 #define IMP_PYCALLBACK_INT_LONGLONG_virtual(CLASS, PCLASS, CBNAME) \
2096 int CLASS::CBNAME(long a, long b) const { \
2097 int rval=-1; /* this rval is important for OnGetItemImage */ \
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); \
2113 //---------------------------------------------------------------------------
2115 #define DEC_PYCALLBACK_LISTATTR_LONG(CBNAME) \
2116 wxListItemAttr* CBNAME(long a) const
2119 #define IMP_PYCALLBACK_LISTATTR_LONG(CLASS, PCLASS, CBNAME) \
2120 wxListItemAttr *CLASS::CBNAME(long a) const { \
2121 wxListItemAttr *rval = NULL; \
2123 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2124 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2126 wxListItemAttr* ptr; \
2127 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2129 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxListItemAttr")))\
2134 wxPyEndBlockThreads(blocked); \
2136 rval = PCLASS::CBNAME(a); \
2140 //---------------------------------------------------------------------------
2142 #define DEC_PYCALLBACK_BOOL_ME(CBNAME) \
2143 bool CBNAME(wxMouseEvent& e)
2145 #define IMP_PYCALLBACK_BOOL_ME(CLASS, PCLASS, CBNAME) \
2146 bool CLASS::CBNAME(wxMouseEvent& e) { \
2149 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2150 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2152 PyObject* obj = wxPyConstructObject((void*)&e, wxT("wxMouseEvent"), 0); \
2153 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)",obj)); \
2155 rval = PyInt_AsLong(ro); \
2160 wxPyEndBlockThreads(blocked); \
2162 return PCLASS::CBNAME(e); \
2166 //---------------------------------------------------------------------------
2168 #define DEC_PYCALLBACK_WIZPG__pure(CBNAME) \
2169 wxWizardPage* CBNAME() const
2171 #define IMP_PYCALLBACK_WIZPG__pure(CLASS, PCLASS, CBNAME) \
2172 wxWizardPage* CLASS::CBNAME() const { \
2173 wxWizardPage* rv = NULL; \
2174 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2175 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2177 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2179 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxWizardPage")); \
2183 wxPyEndBlockThreads(blocked); \
2187 //---------------------------------------------------------------------------
2189 #define DEC_PYCALLBACK_BITMAP__pure(CBNAME) \
2190 wxBitmap CBNAME() const
2192 #define IMP_PYCALLBACK_BITMAP__pure(CLASS, PCLASS, CBNAME) \
2193 wxBitmap CLASS::CBNAME() const { \
2195 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2196 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2199 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2201 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxBitmap"))) \
2206 wxPyEndBlockThreads(blocked); \
2210 //---------------------------------------------------------------------------
2212 #define DEC_PYCALLBACK_OBJECT__pure(CBNAME) \
2215 #define IMP_PYCALLBACK_OBJECT__pure(CLASS, PCLASS, CBNAME) \
2216 wxObject* CLASS::CBNAME() { \
2217 wxObject* rv = NULL; \
2218 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2219 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2221 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2223 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2227 wxPyEndBlockThreads(blocked); \
2231 //---------------------------------------------------------------------------
2233 #define DEC_PYCALLBACK_OBJECT_STRING_pure(CBNAME) \
2234 wxObject* CBNAME(const wxString& a)
2236 #define IMP_PYCALLBACK_OBJECT_STRING_pure(CLASS, PCLASS, CBNAME) \
2237 wxObject* CLASS::CBNAME(const wxString& a) { \
2238 wxObject* rv = NULL; \
2239 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2240 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2241 PyObject* so = wx2PyString(a); \
2243 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", so)); \
2245 wxPyConvertSwigPtr(ro, (void **)&rv, wxT("wxObject")); \
2250 wxPyEndBlockThreads(blocked); \
2254 //---------------------------------------------------------------------------
2256 #define DEC_PYCALLBACK_BOOL_NODE_pure(CBNAME) \
2257 bool CBNAME(wxXmlNode* a)
2260 #define IMP_PYCALLBACK_BOOL_NODE_pure(CLASS, PCLASS, CBNAME) \
2261 bool CLASS::CBNAME(wxXmlNode* a) { \
2263 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2264 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2265 PyObject* obj = wxPyConstructObject((void*)a, wxT("wxXmlNode"), 0); \
2266 rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \
2269 wxPyEndBlockThreads(blocked); \
2273 //---------------------------------------------------------------------------
2275 #define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \
2276 wxCoord CBNAME(size_t a) const
2279 #define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \
2280 wxCoord CLASS::CBNAME(size_t a) const { \
2283 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2284 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2285 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \
2287 wxPyEndBlockThreads(blocked); \
2291 //---------------------------------------------------------------------------
2293 #define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \
2294 void CBNAME(size_t a, size_t b) const
2297 #define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \
2298 void CLASS::CBNAME(size_t a, size_t b) const { \
2300 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2301 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2302 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
2303 wxPyEndBlockThreads(blocked); \
2305 PCLASS::CBNAME(a,b); \
2307 //---------------------------------------------------------------------------
2309 #define DEC_PYCALLBACK_COORD_const(CBNAME) \
2310 wxCoord CBNAME() const
2313 #define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \
2314 wxCoord CLASS::CBNAME() const { \
2317 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2318 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
2319 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
2320 wxPyEndBlockThreads(blocked); \
2322 rval = PCLASS::CBNAME(); \
2326 //---------------------------------------------------------------------------
2328 #define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \
2329 void CBNAME(wxDC& a, const wxRect& b, size_t c) const;
2331 #define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \
2332 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2334 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2335 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2336 PyObject* obj = wxPyMake_wxObject(&a,false); \
2337 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2338 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2339 Py_DECREF(obj); Py_DECREF(ro); \
2341 wxPyEndBlockThreads(blocked); \
2346 #define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \
2347 void CBNAME(wxDC& a, const wxRect& b, size_t c) const
2349 #define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \
2350 void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \
2352 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2353 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2354 PyObject* obj = wxPyMake_wxObject(&a,false); \
2355 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2356 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2357 Py_DECREF(obj); Py_DECREF(ro); \
2359 wxPyEndBlockThreads(blocked); \
2361 PCLASS::CBNAME(a,b,c); \
2365 //---------------------------------------------------------------------------
2366 // Same as the above set, but the wxRect is not const
2368 #define DEC_PYCALLBACK__DCRECTSIZET2_constpure(CBNAME) \
2369 void CBNAME(wxDC& a, wxRect& b, size_t c) const;
2371 #define IMP_PYCALLBACK__DCRECTSIZET2_constpure(CLASS, PCLASS, CBNAME) \
2372 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2374 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2375 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2376 PyObject* obj = wxPyMake_wxObject(&a,false); \
2377 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2378 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2379 Py_DECREF(obj); Py_DECREF(ro); \
2381 wxPyEndBlockThreads(blocked); \
2386 #define DEC_PYCALLBACK__DCRECTSIZET2_const(CBNAME) \
2387 void CBNAME(wxDC& a, wxRect& b, size_t c) const
2389 #define IMP_PYCALLBACK__DCRECTSIZET2_const(CLASS, PCLASS, CBNAME) \
2390 void CLASS::CBNAME(wxDC& a, wxRect& b, size_t c) const { \
2392 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2393 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2394 PyObject* obj = wxPyMake_wxObject(&a,false); \
2395 PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \
2396 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \
2397 Py_DECREF(obj); Py_DECREF(ro); \
2399 wxPyEndBlockThreads(blocked); \
2401 PCLASS::CBNAME(a,b,c); \
2404 //---------------------------------------------------------------------------
2406 #define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \
2407 wxString CBNAME(size_t a) const
2409 #define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \
2410 wxString CLASS::CBNAME(size_t a) const { \
2413 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2414 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2416 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \
2418 rval = Py2wxString(ro); \
2422 wxPyEndBlockThreads(blocked); \
2424 rval = PCLASS::CBNAME(a); \
2428 //---------------------------------------------------------------------------
2430 #define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \
2431 wxString CBNAME(size_t a) const
2433 #define IMP_PYCALLBACK_STRING_SIZET_pure(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); \
2450 //---------------------------------------------------------------------------
2452 #define DEC_PYCALLBACK_VIZATTR_(CBNAME) \
2453 wxVisualAttributes CBNAME() const
2456 #define IMP_PYCALLBACK_VIZATTR_(CLASS, PCLASS, CBNAME) \
2457 wxVisualAttributes CLASS::CBNAME() const { \
2458 wxVisualAttributes rval; \
2460 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2461 if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
2463 wxVisualAttributes* ptr; \
2464 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
2466 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxVisualAttributes"))) \
2471 wxPyEndBlockThreads(blocked); \
2473 rval = PCLASS::CBNAME(); \
2477 //---------------------------------------------------------------------------
2479 #define DEC_PYCALLBACK_FONT_INT(CBNAME) \
2480 wxFont CBNAME(int a)
2482 #define IMP_PYCALLBACK_FONT_INT(CLASS, PCLASS, CBNAME) \
2483 wxFont CLASS::CBNAME(int a) { \
2486 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2487 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2490 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2492 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxFont"))) \
2497 wxPyEndBlockThreads(blocked); \
2499 rv = PCLASS::CBNAME(a); \
2503 //---------------------------------------------------------------------------
2505 #define DEC_PYCALLBACK_COLOUR_INT(CBNAME) \
2506 wxColour CBNAME(int a)
2508 #define IMP_PYCALLBACK_COLOUR_INT(CLASS, PCLASS, CBNAME) \
2509 wxColour CLASS::CBNAME(int a) { \
2512 wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
2513 if (wxPyCBH_findCallback(m_myInst, #CBNAME)) { \
2516 ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)", a)); \
2518 if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxColour"))) \
2523 wxPyEndBlockThreads(blocked); \
2525 rv = PCLASS::CBNAME(a); \
2529 //---------------------------------------------------------------------------