X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1b62f00d8e3ec5437ab780cb3d73d299cc61e20c..45eb5249574b0f1f50db5e6a7eb5bba43fd99cb9:/wxPython/src/misc2.i diff --git a/wxPython/src/misc2.i b/wxPython/src/misc2.i index e68acb89f9..ca975d61f8 100644 --- a/wxPython/src/misc2.i +++ b/wxPython/src/misc2.i @@ -22,7 +22,14 @@ #include #include #include + +#if wxUSE_JOYSTICK || defined(__WXMSW__) #include +#endif + +#if wxUSE_WAVE || defined(__WXMSW__) +#include +#endif %} //---------------------------------------------------------------------- @@ -112,12 +119,15 @@ bool wxColourDisplay(); int wxDisplayDepth(); int wxGetDisplayDepth(); -void wxDisplaySize(int* OUTPUT, int* OUTPUT); +void wxDisplaySize(int* OUTPUT, int* OUTPUT); wxSize wxGetDisplaySize(); -void wxDisplaySizeMM(int* OUTPUT, int* OUTPUT); +void wxDisplaySizeMM(int* OUTPUT, int* OUTPUT); wxSize wxGetDisplaySizeMM(); +void wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT); +wxRect wxGetClientDisplayRect(); + void wxSetCursor(wxCursor& cursor); //---------------------------------------------------------------------- @@ -129,6 +139,13 @@ wxWindow * wxFindWindowByName(const wxString& name, wxWindow *parent=NULL); void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR); wxWindow * wxGetActiveWindow(); +wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt); +wxWindow* wxFindWindowAtPoint(const wxPoint& pt); + +#ifdef __WXMSW__ +bool wxCheckForInterrupt(wxWindow *wnd); +void wxFlushEvents(); +#endif //--------------------------------------------------------------------------- // Resource System @@ -259,7 +276,7 @@ enum { //--------------------------------------------------------------------------- // wxToolTip -class wxToolTip { +class wxToolTip : public wxObject { public: wxToolTip(const wxString &tip); @@ -267,18 +284,10 @@ public: wxString GetTip(); // *** Not in the "public" interface void SetWindow(wxWindow *win); wxWindow *GetWindow(); -}; - -%inline %{ - void wxToolTip_Enable(bool flag) { - wxToolTip::Enable(flag); - } - - void wxToolTip_SetDelay(long milliseconds) { - wxToolTip::SetDelay(milliseconds); - } -%} + static void Enable(bool flag); + static void SetDelay(long milliseconds); +}; //---------------------------------------------------------------------- @@ -382,10 +391,31 @@ public: //---------------------------------------------------------------------- +bool wxSafeYield(wxWindow* win=NULL); void wxPostEvent(wxEvtHandler *dest, wxEvent& event); void wxWakeUpIdle(); -bool wxSafeYield(wxWindow* win=NULL); + +#ifdef __WXMSW__ +void wxWakeUpMainThread(); +#endif + +void wxMutexGuiEnter(); +void wxMutexGuiLeave(); + + +class wxMutexGuiLocker { +public: + wxMutexGuiLocker(); + ~wxMutexGuiLocker(); +}; + + +%inline %{ + bool wxThread_IsMain() { + return wxThread::IsMain(); + } +%} //---------------------------------------------------------------------- @@ -435,18 +465,24 @@ bool wxShowTip(wxWindow *parent, wxTipProvider *tipProvider, bool showAtStartup %{ #include -static wxPoint wxPyNullPoint; %} -%name (wxDragImage) class wxGenericDragImage +%name (wxDragImage) class wxGenericDragImage : public wxObject { public: wxGenericDragImage(const wxBitmap& image, - const wxCursor& cursor = wxNullCursor, - const wxPoint& hotspot = wxPyNullPoint); + const wxCursor& cursor = wxNullCursor); + %name(wxDragIcon)wxGenericDragImage(const wxIcon& image, + const wxCursor& cursor = wxNullCursor); + %name(wxDragString)wxGenericDragImage(const wxString& str, + const wxCursor& cursor = wxNullCursor); + %name(wxDragTreeItem)wxGenericDragImage(const wxTreeCtrl& treeCtrl, wxTreeItemId& id); + %name(wxDragListItem)wxGenericDragImage(const wxListCtrl& listCtrl, long id); + ~wxGenericDragImage(); + void SetBackingBitmap(wxBitmap* bitmap); bool BeginDrag(const wxPoint& hotspot, wxWindow* window, bool fullScreen = FALSE, wxRect* rect = NULL); @@ -464,49 +500,9 @@ public: }; -// Alternate Constructors -%new wxGenericDragImage* wxDragIcon(const wxIcon& image, - const wxCursor& cursor = wxNullCursor, - const wxPoint& hotspot = wxPyNullPoint); - -%new wxGenericDragImage* wxDragString(const wxString& str, - const wxCursor& cursor = wxNullCursor, - const wxPoint& hotspot = wxPyNullPoint); - -%new wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id); - -%new wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id); - - -%{ - -wxGenericDragImage* wxDragIcon(const wxIcon& image, - const wxCursor& cursor, - const wxPoint& hotspot) { - return new wxGenericDragImage(image, cursor, hotspot); -} - -wxGenericDragImage* wxDragString(const wxString& str, - const wxCursor& cursor, - const wxPoint& hotspot) { - return new wxGenericDragImage(str, cursor, hotspot); -} - -wxGenericDragImage* wxDragTreeItem(const wxTreeCtrl& treeCtrl, wxTreeItemId& id) { - return new wxGenericDragImage(treeCtrl, id); -} - -wxGenericDragImage* wxDragListItem(const wxListCtrl& listCtrl, long id) { - return new wxGenericDragImage(listCtrl, id); -} - -%} - - - //---------------------------------------------------------------------- -class wxPyTimer { +class wxPyTimer : public wxObject { public: wxPyTimer(PyObject* notify); ~wxPyTimer(); @@ -562,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; + } + } }; @@ -615,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); @@ -628,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; } } + +}; + //---------------------------------------------------------------------- @@ -663,6 +722,7 @@ public: }; IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate); + %} @@ -695,10 +755,71 @@ long wxExecute(const wxString& command, //---------------------------------------------------------------------- -#ifdef __WXMSW__ -class wxJoystick { +%{ +#if !wxUSE_JOYSTICK && !defined(__WXMSW__) +// A C++ stub class for wxJoystick for platforms that don't have it. +class wxJoystick : public wxObject { +public: + wxJoystick(int joystick = wxJOYSTICK1) { + bool doSave = wxPyRestoreThread(); + PyErr_SetString(PyExc_NotImplementedError, "wxJoystick is not available on this platform."); + wxPySaveThread(doSave); + } + wxPoint GetPosition() { return wxPoint(-1,-1); } + int GetZPosition() { return -1; } + int GetButtonState() { return -1; } + int GetPOVPosition() { return -1; } + int GetPOVCTSPosition() { return -1; } + int GetRudderPosition() { return -1; } + int GetUPosition() { return -1; } + int GetVPosition() { return -1; } + int GetMovementThreshold() { return -1; } + void SetMovementThreshold(int threshold) {} + + bool IsOk(void) { return FALSE; } + int GetNumberJoysticks() { return -1; } + int GetManufacturerId() { return -1; } + int GetProductId() { return -1; } + wxString GetProductName() { return ""; } + int GetXMin() { return -1; } + int GetYMin() { return -1; } + int GetZMin() { return -1; } + int GetXMax() { return -1; } + int GetYMax() { return -1; } + int GetZMax() { return -1; } + int GetNumberButtons() { return -1; } + int GetNumberAxes() { return -1; } + int GetMaxButtons() { return -1; } + int GetMaxAxes() { return -1; } + int GetPollingMin() { return -1; } + int GetPollingMax() { return -1; } + int GetRudderMin() { return -1; } + int GetRudderMax() { return -1; } + int GetUMin() { return -1; } + int GetUMax() { return -1; } + int GetVMin() { return -1; } + int GetVMax() { return -1; } + + bool HasRudder() { return FALSE; } + bool HasZ() { return FALSE; } + bool HasU() { return FALSE; } + bool HasV() { return FALSE; } + bool HasPOV() { return FALSE; } + bool HasPOV4Dir() { return FALSE; } + bool HasPOVCTS() { return FALSE; } + + bool SetCapture(wxWindow* win, int pollingFreq = 0) { return FALSE; } + bool ReleaseCapture() { return FALSE; } +}; +#endif +%} + + +class wxJoystick : public wxObject { public: wxJoystick(int joystick = wxJOYSTICK1); + ~wxJoystick(); + wxPoint GetPosition(); int GetZPosition(); int GetButtonState(); @@ -745,8 +866,62 @@ public: bool SetCapture(wxWindow* win, int pollingFreq = 0); bool ReleaseCapture(); }; + +//---------------------------------------------------------------------- + +%{ +#if !wxUSE_WAVE +// A C++ stub class for wxWave for platforms that don't have it. +class wxWave : public wxObject +{ +public: + wxWave(const wxString& fileName, bool isResource = FALSE) { + wxPyTState* state = wxPyBeginBlockThreads(); + PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform."); + wxPyEndBlockThreads(state); + } + wxWave(int size, const wxByte* data) { + wxPyTState* state = wxPyBeginBlockThreads(); + PyErr_SetString(PyExc_NotImplementedError, "wxWave is not available on this platform."); + wxPyEndBlockThreads(state); + } + + ~wxWave() {} + + bool IsOk() const { return FALSE; } + bool Play(bool async = TRUE, bool looped = FALSE) const { return FALSE; } +}; + #endif +%} +class wxWave : public wxObject +{ +public: + wxWave(const wxString& fileName, bool isResource = FALSE); + ~wxWave(); + + bool IsOk() const; + bool Play(bool async = TRUE, bool looped = FALSE) const; +}; + +%new wxWave* wxWaveData(const wxString& data); +%{ // Implementations of some alternate "constructors" + wxWave* wxWaveData(const wxString& data) { + return new wxWave(data.Len(), (wxByte*)data.c_str()); + } +%} + + +//---------------------------------------------------------------------- //---------------------------------------------------------------------- + + +%init %{ + wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator"); + wxPyPtrTypeMap_Add("wxDragImage", "wxGenericDragImage"); + wxPyPtrTypeMap_Add("wxProcess", "wxPyProcess"); +%} + //----------------------------------------------------------------------