X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/80b6bf7c7c3cbd1f6e57de3f759cb85e9f01b56b..a2234452a7af149ed9e93aae537eb7a4a6ad356f:/wxPython/src/grid.i diff --git a/wxPython/src/grid.i b/wxPython/src/grid.i index e45dd130b1..ec563fc7f2 100644 --- a/wxPython/src/grid.i +++ b/wxPython/src/grid.i @@ -491,11 +491,14 @@ enum { //--------------------------------------------------------------------------- -// wxGridCellRenderer is an ABC, and several derived classes are available. -// Classes implemented in Python should be derived from wxPyGridCellRenderer. +// TODO: Use these to have SWIG automatically handle the IncRef/DecRef calls: +// +// %ref wxGridCellWorker "$this->IncRef();"; +// %unref wxGridCellWorker "$this->DecRef();"; +// -class wxGridCellRenderer +class wxGridCellWorker { public: %extend { @@ -503,12 +506,25 @@ public: if (!self->GetClientObject()) self->SetClientObject(new wxPyOORClientData(_self)); } + + // A dummy dtor to shut up SWIG. (The real one is protected and can + // only be called by DecRef) + ~wxGridCellWorker() { + } } void SetParameters(const wxString& params); void IncRef(); void DecRef(); +}; + + +// wxGridCellRenderer is an ABC, and several derived classes are available. +// Classes implemented in Python should be derived from wxPyGridCellRenderer. + +class wxGridCellRenderer : public wxGridCellWorker +{ virtual void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, @@ -523,6 +539,7 @@ public: }; + // The C++ version of wxPyGridCellRenderer %{ class wxPyGridCellRenderer : public wxGridCellRenderer @@ -703,16 +720,9 @@ public: // wxGridCellEditor is an ABC, and several derived classes are available. // Classes implemented in Python should be derived from wxPyGridCellEditor. -class wxGridCellEditor +class wxGridCellEditor : public wxGridCellWorker { public: - %extend { - void _setOORInfo(PyObject* _self) { - if (!self->GetClientObject()) - self->SetClientObject(new wxPyOORClientData(_self)); - } - } - bool IsCreated(); wxControl* GetControl(); void SetControl(wxControl* control); @@ -720,10 +730,6 @@ public: wxGridCellAttr* GetCellAttr(); void SetCellAttr(wxGridCellAttr* attr); - void SetParameters(const wxString& params); - void IncRef(); - void DecRef(); - virtual void Create(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler); @@ -991,11 +997,20 @@ public: %pythonAppend wxGridCellAttr "self._setOORInfo(self)" wxGridCellAttr(wxGridCellAttr *attrDefault = NULL); + + %extend { + // A dummy dtor to shut up SWIG. (The real one is protected and can + // only be called by DecRef) + ~wxGridCellAttr() { + } + } wxGridCellAttr *Clone() const; void MergeWith(wxGridCellAttr *mergefrom); + void IncRef(); void DecRef(); + void SetTextColour(const wxColour& colText); void SetBackgroundColour(const wxColour& colBack); void SetFont(const wxFont& font); @@ -1092,7 +1107,7 @@ public: void _setCallbackInfo(PyObject* self, PyObject* _class); wxGridCellAttr *GetAttr(int row, int col, - wxGridCellAttr::wxAttrKind kind); + wxGridCellAttr::wxAttrKind kind); void SetAttr(wxGridCellAttr *attr, int row, int col); void SetRowAttr(wxGridCellAttr *attr, int row); void SetColAttr(wxGridCellAttr *attr, int col); @@ -1519,8 +1534,33 @@ public: void SetCol( int n ); void Set( int row, int col ); - bool operator==( const wxGridCellCoords& other ) const; - bool operator!=( const wxGridCellCoords& other ) const; + %extend { + KeepGIL(__eq__); + DocStr(__eq__, "Test for equality of GridCellCoords objects.", ""); + bool __eq__(PyObject* other) { + wxGridCellCoords temp, *obj = &temp; + if ( other == Py_None ) return false; + if ( ! wxGridCellCoords_helper(other, &obj) ) { + PyErr_Clear(); + return false; + } + return self->operator==(*obj); + } + + + KeepGIL(__ne__); + DocStr(__ne__, "Test for inequality of GridCellCoords objects.", ""); + bool __ne__(PyObject* other) { + wxGridCellCoords temp, *obj = &temp; + if ( other == Py_None ) return true; + if ( ! wxGridCellCoords_helper(other, &obj)) { + PyErr_Clear(); + return true; + } + return self->operator!=(*obj); + } + } + %extend { PyObject* Get() {