X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1fded56b375bf7a4687af1cdb182899614c1b2a8..e41e579f40ec15c8c20aa3118b7367281ae4f95b:/wxPython/src/helpers.h diff --git a/wxPython/src/helpers.h b/wxPython/src/helpers.h index e731fb51df..55f28dbc7c 100644 --- a/wxPython/src/helpers.h +++ b/wxPython/src/helpers.h @@ -16,6 +16,10 @@ #include #include +//--------------------------------------------------------------------------- +#ifdef __WXMAC__ // avoid a bug in Carbon headers +#define scalb scalbn +#endif //--------------------------------------------------------------------------- typedef unsigned char byte; @@ -48,6 +52,9 @@ void wxPyPtrTypeMap_Add(const char* commonName, const char* ptrName); PyObject* wxPy_ConvertList(wxListBase* list, const char* className); long wxPyGetWinHandle(wxWindow* win); +void wxPy_ReinitStockObjects(); + + //---------------------------------------------------------------------- // if we want to handle threads and Python threads are available... @@ -181,6 +188,7 @@ public: void SetSelf(PyObject* self, bool clone=FALSE); PyObject* GetSelf() const; + bool GetCloned() const { return m_cloned; } protected: PyObject* m_self; @@ -191,7 +199,7 @@ protected: class wxPyEvent : public wxEvent, public wxPyEvtSelfRef { DECLARE_ABSTRACT_CLASS(wxPyEvent) public: - wxPyEvent(int id=0); + wxPyEvent(int winid=0, wxEventType commandType = wxEVT_NULL); wxPyEvent(const wxPyEvent& evt); ~wxPyEvent(); @@ -455,14 +463,12 @@ public: // virtual int FilterEvent(wxEvent& event); // This one too???? - static bool GetMacDefaultEncodingIsPC(); static bool GetMacSupportPCMenuShortcuts(); static long GetMacAboutMenuItemId(); static long GetMacPreferencesMenuItemId(); static long GetMacExitMenuItemId(); static wxString GetMacHelpMenuTitleName(); - static void SetMacDefaultEncodingIsPC(bool val); static void SetMacSupportPCMenuShortcuts(bool val); static void SetMacAboutMenuItemId(long val); static void SetMacPreferencesMenuItemId(long val); @@ -786,13 +792,13 @@ extern wxPyApp *wxPythonApp; #define IMP_PYCALLBACK__DC(CLASS, PCLASS, CBNAME) \ void CLASS::CBNAME(wxDC& a) { \ bool found; \ - wxPyBeginBlockThreads(); \ + wxPyBeginBlockThreads(); \ if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ PyObject* obj = wxPyMake_wxObject(&a); \ wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); \ Py_DECREF(obj); \ } \ - wxPyEndBlockThreads(); \ + wxPyEndBlockThreads(); \ if (! found) \ PCLASS::CBNAME(a); \ } \ @@ -2099,4 +2105,162 @@ extern wxPyApp *wxPythonApp; } \ //--------------------------------------------------------------------------- + +#define DEC_PYCALLBACK_COORD_SIZET_constpure(CBNAME) \ + wxCoord CBNAME(size_t a) const + + +#define IMP_PYCALLBACK_COORD_SIZET_constpure(CLASS, PCLASS, CBNAME) \ + wxCoord CLASS::CBNAME(size_t a) const { \ + wxCoord rval=0; \ + bool found; \ + wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a)); \ + } \ + wxPyEndBlockThreads(); \ + return rval; \ + } \ + +//--------------------------------------------------------------------------- + +#define DEC_PYCALLBACK_VOID_SIZETSIZET_const(CBNAME) \ + void CBNAME(size_t a, size_t b) const; \ + void base_##CBNAME(size_t a, size_t b) const + + +#define IMP_PYCALLBACK_VOID_SIZETSIZET_const(CLASS, PCLASS, CBNAME) \ + void CLASS::CBNAME(size_t a, size_t b) const { \ + bool found; \ + wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \ + wxPyEndBlockThreads(); \ + if (! found) \ + PCLASS::CBNAME(a,b); \ + } \ + void CLASS::base_##CBNAME(size_t a, size_t b) const { \ + PCLASS::CBNAME(a,b); \ + } + +//--------------------------------------------------------------------------- + +#define DEC_PYCALLBACK_COORD_const(CBNAME) \ + wxCoord CBNAME() const; \ + wxCoord base_##CBNAME() const + + +#define IMP_PYCALLBACK_COORD_const(CLASS, PCLASS, CBNAME) \ + wxCoord CLASS::CBNAME() const { \ + wxCoord rval=0; \ + bool found; \ + wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \ + rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \ + wxPyEndBlockThreads(); \ + if (! found) \ + rval = PCLASS::CBNAME(); \ + return rval; \ + } \ + wxCoord CLASS::base_##CBNAME() const { \ + return PCLASS::CBNAME(); \ + } + +//--------------------------------------------------------------------------- + +#define DEC_PYCALLBACK__DCRECTSIZET_constpure(CBNAME) \ + void CBNAME(wxDC& a, const wxRect& b, size_t c) const; + + +#define IMP_PYCALLBACK__DCRECTSIZET_constpure(CLASS, PCLASS, CBNAME) \ + void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \ + bool found; \ + wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* obj = wxPyMake_wxObject(&a); \ + PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \ + Py_DECREF(obj); \ + } \ + wxPyEndBlockThreads(); \ + } \ + +//--------------------------------------------------------------------------- + +#define DEC_PYCALLBACK__DCRECTSIZET_const(CBNAME) \ + void CBNAME(wxDC& a, const wxRect& b, size_t c) const; \ + void base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const + + +#define IMP_PYCALLBACK__DCRECTSIZET_const(CLASS, PCLASS, CBNAME) \ + void CLASS::CBNAME(wxDC& a, const wxRect& b, size_t c) const { \ + bool found; \ + wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* obj = wxPyMake_wxObject(&a); \ + PyObject* ro = wxPyConstructObject((void*)&b, wxT("wxRect"), 0); \ + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOi)", obj, ro, (int)c)); \ + Py_DECREF(obj); \ + } \ + wxPyEndBlockThreads(); \ + if (! found) \ + PCLASS::CBNAME(a,b,c); \ + } \ + void CLASS::base_##CBNAME(wxDC& a, const wxRect& b, size_t c) const { \ + PCLASS::CBNAME(a,b,c); \ + } + +//--------------------------------------------------------------------------- + + +#define DEC_PYCALLBACK_STRING_SIZET(CBNAME) \ + wxString CBNAME(size_t a) const; \ + wxString base_##CBNAME(size_t a) const + +#define IMP_PYCALLBACK_STRING_SIZET(CLASS, PCLASS, CBNAME) \ + wxString CLASS::CBNAME(size_t a) const { \ + wxString rval; \ + bool found; \ + wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* ro; \ + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \ + if (ro) { \ + rval = Py2wxString(ro); \ + Py_DECREF(ro); \ + } \ + } \ + wxPyEndBlockThreads(); \ + if (! found) \ + rval = PCLASS::CBNAME(a); \ + return rval; \ + } \ + wxString CLASS::base_##CBNAME(size_t a) const { \ + return PCLASS::CBNAME(a); \ + } + +//--------------------------------------------------------------------------- + +#define DEC_PYCALLBACK_STRING_SIZET_pure(CBNAME) \ + wxString CBNAME(size_t a) const + +#define IMP_PYCALLBACK_STRING_SIZET_pure(CLASS, PCLASS, CBNAME) \ + wxString CLASS::CBNAME(size_t a) const { \ + wxString rval; \ + bool found; \ + wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* ro; \ + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(l)",a)); \ + if (ro) { \ + rval = Py2wxString(ro); \ + Py_DECREF(ro); \ + } \ + } \ + wxPyEndBlockThreads(); \ + return rval; \ + } \ + +//--------------------------------------------------------------------------- + #endif