From fd512ba2864a4ddf82ef70caf7a5b107d34906c8 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 5 Sep 2002 19:39:28 +0000 Subject: [PATCH] Various wxPython updates to go along with recent changes in CVS git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16993 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/contrib/xrc/xrc.cpp | 29 ++++++++++++++ wxPython/contrib/xrc/xrc.i | 3 ++ wxPython/contrib/xrc/xrc.py | 3 ++ wxPython/src/_defs.i | 4 ++ wxPython/src/gdi.i | 46 +++++++++++++++++++--- wxPython/src/grid.i | 14 ++++++- wxPython/src/helpers.cpp | 1 - wxPython/src/helpers.h | 27 +++++++++++++ wxPython/src/misc2.i | 74 ++++++++++++++++++++++++++++++++++-- wxPython/src/wx.i | 1 + 10 files changed, 191 insertions(+), 11 deletions(-) diff --git a/wxPython/contrib/xrc/xrc.cpp b/wxPython/contrib/xrc/xrc.cpp index f4753bcce1..e42e2572b8 100644 --- a/wxPython/contrib/xrc/xrc.cpp +++ b/wxPython/contrib/xrc/xrc.cpp @@ -1493,6 +1493,34 @@ static PyObject *_wrap_wxXmlResource_Set(PyObject *self, PyObject *args, PyObjec return _resultobj; } +#define wxXmlResource_GetFlags(_swigobj) (_swigobj->GetFlags()) +static PyObject *_wrap_wxXmlResource_GetFlags(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + int _result; + wxXmlResource * _arg0; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxXmlResource_GetFlags",_kwnames,&_argo0)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxXmlResource_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxXmlResource_GetFlags. Expected _wxXmlResource_p."); + return NULL; + } + } +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = (int )wxXmlResource_GetFlags(_arg0); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + #define new_wxXmlProperty(_swigarg0,_swigarg1,_swigarg2) (new wxXmlProperty(_swigarg0,_swigarg1,_swigarg2)) static PyObject *_wrap_new_wxXmlProperty(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; @@ -4962,6 +4990,7 @@ static PyMethodDef xrccMethods[] = { { "wxXmlProperty_GetValue", (PyCFunction) _wrap_wxXmlProperty_GetValue, METH_VARARGS | METH_KEYWORDS }, { "wxXmlProperty_GetName", (PyCFunction) _wrap_wxXmlProperty_GetName, METH_VARARGS | METH_KEYWORDS }, { "new_wxXmlProperty", (PyCFunction) _wrap_new_wxXmlProperty, METH_VARARGS | METH_KEYWORDS }, + { "wxXmlResource_GetFlags", (PyCFunction) _wrap_wxXmlResource_GetFlags, METH_VARARGS | METH_KEYWORDS }, { "wxXmlResource_Set", (PyCFunction) _wrap_wxXmlResource_Set, METH_VARARGS | METH_KEYWORDS }, { "wxXmlResource_Get", (PyCFunction) _wrap_wxXmlResource_Get, METH_VARARGS | METH_KEYWORDS }, { "wxXmlResource_CompareVersion", (PyCFunction) _wrap_wxXmlResource_CompareVersion, METH_VARARGS | METH_KEYWORDS }, diff --git a/wxPython/contrib/xrc/xrc.i b/wxPython/contrib/xrc/xrc.i index 04f3c39471..037e1eb214 100644 --- a/wxPython/contrib/xrc/xrc.i +++ b/wxPython/contrib/xrc/xrc.i @@ -196,6 +196,9 @@ public: // Sets global resources object and returns pointer to previous one (may be NULL). static wxXmlResource *Set(wxXmlResource *res); + // Returns flags, which may be a bitlist of wxXRC_USE_LOCALE and wxXRC_NO_SUBCLASSING. + int GetFlags(); + }; //---------------------------------------------------------------------- diff --git a/wxPython/contrib/xrc/xrc.py b/wxPython/contrib/xrc/xrc.py index 6290c6cb87..9a10422a35 100644 --- a/wxPython/contrib/xrc/xrc.py +++ b/wxPython/contrib/xrc/xrc.py @@ -132,6 +132,9 @@ class wxXmlResourcePtr(wxObjectPtr): def CompareVersion(self, *_args, **_kwargs): val = apply(xrcc.wxXmlResource_CompareVersion,(self,) + _args, _kwargs) return val + def GetFlags(self, *_args, **_kwargs): + val = apply(xrcc.wxXmlResource_GetFlags,(self,) + _args, _kwargs) + return val def __repr__(self): return "" % (self.this,) class wxXmlResource(wxXmlResourcePtr): diff --git a/wxPython/src/_defs.i b/wxPython/src/_defs.i index 2e02039ea5..553b379839 100644 --- a/wxPython/src/_defs.i +++ b/wxPython/src/_defs.i @@ -284,6 +284,10 @@ enum { wxTE_DONTWRAP, wxTE_LINEWRAP, wxTE_WORDWRAP, + wxTE_LEFT, + wxTE_RIGHT, + wxTE_CENTER, + wxTE_CENTRE, wxCB_SIMPLE, wxCB_DROPDOWN, diff --git a/wxPython/src/gdi.i b/wxPython/src/gdi.i index 5bf1c4ed41..b5cee56b36 100644 --- a/wxPython/src/gdi.i +++ b/wxPython/src/gdi.i @@ -689,6 +689,8 @@ public: // Draw a point for every set of coordinants in pyPoints, optionally // setting a new pen for each PyObject* _DrawPointList(PyObject* pyPoints, PyObject* pyPens) { + wxPyBeginBlockThreads(); + bool isFastSeq = PyList_Check(pyPoints) || PyTuple_Check(pyPoints); bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens); int numObjs = 0; @@ -697,6 +699,7 @@ public: PyObject* obj; int x1, y1; int i = 0; + PyObject* retval; if (!PySequence_Check(pyPoints)) { goto err0; @@ -739,6 +742,13 @@ public: Py_DECREF(obj); goto err0; } + if (PyErr_Occurred()) { + retval = NULL; + if (!isFastPens) + Py_DECREF(obj); + goto exit; + } + // Now draw the point self->DrawPoint(x1, y1); @@ -748,20 +758,29 @@ public: } Py_INCREF(Py_None); - return Py_None; + retval = Py_None; + goto exit; err1: PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens"); - return NULL; + retval = NULL; + goto exit; err0: PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x,y) sequences."); - return NULL; + retval = NULL; + goto exit; + + exit: + wxPyEndBlockThreads(); + return retval; } // Draw a line for every set of coordinants in pyLines, optionally // setting a new pen for each PyObject* _DrawLineList(PyObject* pyLines, PyObject* pyPens) { + wxPyBeginBlockThreads(); + bool isFastSeq = PyList_Check(pyLines) || PyTuple_Check(pyLines); bool isFastPens = PyList_Check(pyPens) || PyTuple_Check(pyPens); int numObjs = 0; @@ -770,6 +789,7 @@ public: PyObject* obj; int x1, y1, x2, y2; int i = 0; + PyObject* retval; if (!PySequence_Check(pyLines)) { goto err0; @@ -812,6 +832,12 @@ public: Py_DECREF(obj); goto err0; } + if (PyErr_Occurred()) { + retval = NULL; + if (!isFastPens) + Py_DECREF(obj); + goto exit; + } // Now draw the line self->DrawLine(x1, y1, x2, y2); @@ -821,14 +847,22 @@ public: } Py_INCREF(Py_None); - return Py_None; + retval = Py_None; + goto exit; err1: PyErr_SetString(PyExc_TypeError, "Expected a sequence of wxPens"); - return NULL; + retval = NULL; + goto exit; + err0: PyErr_SetString(PyExc_TypeError, "Expected a sequence of (x1,y1, x2,y2) sequences."); - return NULL; + retval = NULL; + goto exit; + + exit: + wxPyEndBlockThreads(); + return retval; } } diff --git a/wxPython/src/grid.i b/wxPython/src/grid.i index bb353e2e8d..bb79465929 100644 --- a/wxPython/src/grid.i +++ b/wxPython/src/grid.i @@ -1010,6 +1010,8 @@ public: void SetBackgroundColour(const wxColour& colBack); void SetFont(const wxFont& font); void SetAlignment(int hAlign, int vAlign); + void SetSize(int num_rows, int num_cols); + void SetOverflow( bool allow ); void SetReadOnly(bool isReadOnly = TRUE); void SetRenderer(wxGridCellRenderer *renderer); @@ -1028,6 +1030,8 @@ public: wxColour GetBackgroundColour() const; wxFont GetFont() const; void GetAlignment(int *OUTPUT, int *OUTPUT) const; + void GetSize(int *num_rows, int *num_cols) const; + bool GetOverflow() const; wxGridCellRenderer *GetRenderer(wxGrid* grid, int row, int col) const; wxGridCellEditor *GetEditor(wxGrid* grid, int row, int col) const; @@ -1525,11 +1529,12 @@ public: void EndBatch(); int GetBatchCount(); void ForceRefresh(); + void Refresh(bool eraseb=TRUE, wxRect* rect= NULL); // ------ edit control functions // - bool IsEditable() { return m_editable; } + bool IsEditable(); void EnableEditing( bool edit ); void EnableCellEditControl( bool enable = TRUE ); @@ -1640,6 +1645,7 @@ public: bool CanDragGridSize(); // this sets the specified attribute for all cells in this row/col + void SetAttr(int row, int col, wxGridCellAttr *attr); void SetRowAttr(int row, wxGridCellAttr *attr); void SetColAttr(int col, wxGridCellAttr *attr); @@ -1668,6 +1674,9 @@ public: wxFont GetCellFont( int row, int col ); void GetDefaultCellAlignment( int *horiz, int *vert ); void GetCellAlignment( int row, int col, int *horiz, int *vert ); + bool GetDefaultCellOverflow(); + bool GetCellOverflow( int row, int col ); + void GetCellSize( int row, int col, int *OUTPUT, int *OUTPUT ); void SetDefaultRowSize( int height, bool resizeExistingRows = FALSE ); void SetRowSize( int row, int height ); @@ -1705,6 +1714,9 @@ public: void SetCellFont( int row, int col, const wxFont& ); void SetDefaultCellAlignment( int horiz, int vert ); void SetCellAlignment( int row, int col, int horiz, int vert ); + void SetDefaultCellOverflow( bool allow ); + void SetCellOverflow( int row, int col, bool allow ); + void SetCellSize( int row, int col, int num_rows, int num_cols ); // takes ownership of the pointer void SetDefaultRenderer(wxGridCellRenderer *renderer); diff --git a/wxPython/src/helpers.cpp b/wxPython/src/helpers.cpp index 992ff622a6..e317a426be 100644 --- a/wxPython/src/helpers.cpp +++ b/wxPython/src/helpers.cpp @@ -217,7 +217,6 @@ void __wxPreStart() } - // Start the user application, user App's OnInit method is a parameter here PyObject* __wxStart(PyObject* /* self */, PyObject* args) { diff --git a/wxPython/src/helpers.h b/wxPython/src/helpers.h index 9cf9014612..1ca7acd7da 100644 --- a/wxPython/src/helpers.h +++ b/wxPython/src/helpers.h @@ -1068,6 +1068,33 @@ void wxPyCBH_delete(wxPyCallbackHelper* cbh); //--------------------------------------------------------------------------- +#define DEC_PYCALLBACK_STRING_STRING(CBNAME) \ + wxString CBNAME(const wxString& a); \ + wxString base_##CBNAME(const wxString& a); + +#define IMP_PYCALLBACK_STRING_STRING(CLASS, PCLASS, CBNAME) \ + wxString CLASS::CBNAME(const wxString& a) { \ + wxString rval; \ + bool found; \ + wxPyBeginBlockThreads(); \ + if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \ + PyObject* ro; \ + PyObject* s = wx2PyString(a); \ + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", s)); \ + Py_DECREF(s); \ + if (ro) { \ + rval = Py2wxString(ro); \ + Py_DECREF(ro); \ + } \ + } \ + if (! found) \ + rval = PCLASS::CBNAME(a); \ + wxPyEndBlockThreads(); \ + return rval; \ + } \ + +//--------------------------------------------------------------------------- + #define DEC_PYCALLBACK_STRING_STRINGINT_pure(CBNAME) \ wxString CBNAME(const wxString& a,int b); \ diff --git a/wxPython/src/misc2.i b/wxPython/src/misc2.i index 8fd676350a..db800a4455 100644 --- a/wxPython/src/misc2.i +++ b/wxPython/src/misc2.i @@ -32,6 +32,9 @@ #endif #include +#include +#include +//#include %} //---------------------------------------------------------------------- @@ -175,6 +178,8 @@ void wxFlushEvents(); wxWindow* wxGetTopLevelParent(wxWindow *win); +//bool wxSpawnBrowser(wxWindow *parent, wxString href); + //--------------------------------------------------------------------------- // Resource System @@ -443,7 +448,7 @@ public: virtual wxString GetTip() = 0; size_t GetCurrentTip(); - + virtual wxString PreprocessTip(const wxString& tip); }; @@ -455,12 +460,12 @@ public: : wxTipProvider(currentTip) {} DEC_PYCALLBACK_STRING__pure(GetTip); - + DEC_PYCALLBACK_STRING_STRING(PreprocessTip); PYPRIVATE; }; IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip); - +IMP_PYCALLBACK_STRING_STRING(wxPyTipProvider, wxTipProvider, PreprocessTip); %} @@ -614,6 +619,7 @@ public: static void AddTraceMask(const wxString& str); static void RemoveTraceMask(const wxString& str); static void ClearTraceMasks(); + static const wxArrayString &GetTraceMasks(); static void SetTimestamp(const wxString& ts); static const wxString& GetTimestamp(); @@ -1616,8 +1622,70 @@ public: }; //---------------------------------------------------------------------- + +class wxEffects: public wxObject +{ +public: + // Assume system colours + wxEffects(); + + wxColour GetHighlightColour() const; + wxColour GetLightShadow() const; + wxColour GetFaceColour() const; + wxColour GetMediumShadow() const; + wxColour GetDarkShadow() const; + + void SetHighlightColour(const wxColour& c); + void SetLightShadow(const wxColour& c); + void SetFaceColour(const wxColour& c); + void SetMediumShadow(const wxColour& c); + void SetDarkShadow(const wxColour& c); + + void Set(const wxColour& highlightColour, const wxColour& lightShadow, + const wxColour& faceColour, const wxColour& mediumShadow, + const wxColour& darkShadow); + + // Draw a sunken edge + void DrawSunkenEdge(wxDC& dc, const wxRect& rect, int borderSize = 1); + + // Tile a bitmap + bool TileBitmap(const wxRect& rect, wxDC& dc, wxBitmap& bitmap); + +}; + //---------------------------------------------------------------------- +class wxSingleInstanceChecker +{ +public: + // like Create() but no error checking (dangerous!) + wxSingleInstanceChecker(const wxString& name, + const wxString& path = wxPyEmptyString); + + // default ctor, use Create() after it + %name(wxPreSingleInstanceChecker) wxSingleInstanceChecker(); + + ~wxSingleInstanceChecker(); + + + // name must be given and be as unique as possible, it is used as the mutex + // name under Win32 and the lock file name under Unix - + // wxTheApp->GetAppName() may be a good value for this parameter + // + // path is optional and is ignored under Win32 and used as the directory to + // create the lock file in under Unix (default is wxGetHomeDir()) + // + // returns FALSE if initialization failed, it doesn't mean that another + // instance is running - use IsAnotherRunning() to check it + bool Create(const wxString& name, const wxString& path = wxPyEmptyString); + + // is another copy of this program already running? + bool IsAnotherRunning() const; +}; + +//---------------------------------------------------------------------- + + // %{ // #if wxUSE_UNICODE // #define ADD_STRING(dict, str) \ diff --git a/wxPython/src/wx.i b/wxPython/src/wx.i index 3925c11c67..476b7c1dde 100644 --- a/wxPython/src/wx.i +++ b/wxPython/src/wx.i @@ -93,6 +93,7 @@ public: int MainLoop(); bool Pending(); bool ProcessIdle(); + bool Yield(bool onlyIfNeeded = FALSE); void SetAppName(const wxString& name); #ifdef __WXMSW__ -- 2.45.2