X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cdf14688f51fa5a242df70f86c7af229fe64fd4f..45eb5249574b0f1f50db5e6a7eb5bba43fd99cb9:/wxPython/src/misc2.i diff --git a/wxPython/src/misc2.i b/wxPython/src/misc2.i index 192e87922d..ca975d61f8 100644 --- a/wxPython/src/misc2.i +++ b/wxPython/src/misc2.i @@ -558,12 +558,24 @@ public: static void SetTraceMask(wxTraceMask ulMask); static void AddTraceMask(const wxString& str); static void RemoveTraceMask(const wxString& str); + static void ClearTraceMasks(); + + static void SetTimestamp(const wxChar *ts); + static const wxChar *GetTimestamp(); bool GetVerbose() const { return m_bVerbose; } static wxTraceMask GetTraceMask(); static bool IsAllowedTraceMask(const char *mask); + // static void TimeStamp(wxString *str); + %addmethods { + wxString TimeStamp() { + wxString msg; + wxLog::TimeStamp(&msg); + return msg; + } + } }; @@ -611,6 +623,17 @@ public: }; +class wxLogChain : public wxLog +{ +public: + wxLogChain(wxLog *logger); + void SetLog(wxLog *logger); + void PassMessages(bool bDoPass); + bool IsPassingMessages(); + wxLog *GetOldLog(); +}; + + unsigned long wxSysErrorCode(); const char* wxSysErrorMsg(unsigned long nErrCode = 0); void wxLogFatalError(const char *szFormat); @@ -624,6 +647,46 @@ void wxLogStatus(const char *szFormat); void wxLogSysError(const char *szFormat); +%{ +// A Log class that can be derived from in wxPython +class wxPyLog : public wxLog { +public: + wxPyLog() : wxLog() {} + + virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t) { + bool found; + wxPyTState* state = wxPyBeginBlockThreads(); + if ((found = wxPyCBH_findCallback(m_myInst, "DoLog"))) + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(isi)", level, szString, t)); + wxPyEndBlockThreads(state); + if (! found) + wxLog::DoLog(level, szString, t); + } + + virtual void DoLogString(const wxChar *szString, time_t t) { + bool found; + wxPyTState* state = wxPyBeginBlockThreads(); + if ((found = wxPyCBH_findCallback(m_myInst, "DoLogString"))) + wxPyCBH_callCallback(m_myInst, Py_BuildValue("(si)", szString, t)); + wxPyEndBlockThreads(state); + if (! found) + wxLog::DoLogString(szString, t); + } + + PYPRIVATE; +}; +%} + +// Now tell SWIG about it +class wxPyLog : public wxLog { +public: + wxPyLog(); + void _setSelf(PyObject* self, PyObject* _class); + %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPyLog)" + %addmethods { void Destroy() { delete self; } } + +}; + //---------------------------------------------------------------------- @@ -659,6 +722,7 @@ public: }; IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate); + %} @@ -812,14 +876,14 @@ class wxWave : public wxObject { public: wxWave(const wxString& fileName, bool isResource = FALSE) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform."); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } wxWave(int size, const wxByte* data) { - bool doSave = wxPyRestoreThread(); + wxPyTState* state = wxPyBeginBlockThreads(); PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform."); - wxPySaveThread(doSave); + wxPyEndBlockThreads(state); } ~wxWave() {}