X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/80b6bf7c7c3cbd1f6e57de3f759cb85e9f01b56b..3af4da323ab401ad41e2eca2c6afbc2c3d632da6:/wxPython/src/grid.i diff --git a/wxPython/src/grid.i b/wxPython/src/grid.i index e45dd130b1..6c78cc4bb7 100644 --- a/wxPython/src/grid.i +++ b/wxPython/src/grid.i @@ -35,8 +35,6 @@ %pythoncode { __docfilter__ = wx.__DocFilter(globals()) } -%include _grid_rename.i - MAKE_CONST_WXSTRING_NOSWIG(EmptyString); MAKE_CONST_WXSTRING_NOSWIG(PanelNameStr); MAKE_CONST_WXSTRING_NOSWIG(DefaultDateTimeFormat); @@ -491,11 +489,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 +504,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 +537,7 @@ public: }; + // The C++ version of wxPyGridCellRenderer %{ class wxPyGridCellRenderer : public wxGridCellRenderer @@ -703,16 +718,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 +728,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 +995,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 +1105,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); @@ -1112,7 +1125,7 @@ class wxGridTableBase : public wxObject { public: // wxGridTableBase(); This is an ABC - //~wxGridTableBase(); + ~wxGridTableBase(); %extend { void _setOORInfo(PyObject* _self) { @@ -1519,8 +1532,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() { @@ -1591,7 +1629,12 @@ public: long style = wxWANTS_CHARS, const wxString& name = wxPyPanelNameStr ); - + // Override the global renamer to leave these as they are, for backwards + // compatibility + %rename(wxGridSelectCells) wxGridSelectCells; + %rename(wxGridSelectRows) wxGridSelectRows; + %rename(wxGridSelectColumns) wxGridSelectColumns; + enum wxGridSelectionModes { wxGridSelectCells, wxGridSelectRows, @@ -1619,9 +1662,12 @@ public: wxGridTableBase * GetTable() const; + + %disownarg(wxGridTableBase *); bool SetTable( wxGridTableBase *table, bool takeOwnership=false, WXGRIDSELECTIONMODES selmode = wxGrid::wxGridSelectCells ); + %cleardisown(wxGridTableBase *); void ClearGrid(); bool InsertRows( int pos = 0, int numRows = 1, bool updateLabels=true ); @@ -1700,7 +1746,7 @@ public: } int YToRow( int y ); - int XToCol( int x ); + int XToCol( int x, bool clipToMinMax = false ); int YToEdgeOfRow( int y ); int XToEdgeOfCol( int x ); @@ -1758,6 +1804,12 @@ public: wxString GetRowLabelValue( int row ); wxString GetColLabelValue( int col ); wxColour GetGridLineColour(); + + virtual wxPen GetDefaultGridLinePen(); + virtual wxPen GetRowGridLinePen(int row); + virtual wxPen GetColGridLinePen(int col); + + wxColour GetCellHighlightColour(); int GetCellHighlightPenWidth(); int GetCellHighlightROPenWidth(); @@ -1783,6 +1835,9 @@ public: void EnableDragColSize( bool enable = true ); void DisableDragColSize(); bool CanDragColSize(); + void EnableDragColMove( bool enable = true ); + void DisableDragColMove() { EnableDragColMove( false ); } + bool CanDragColMove() { return m_canDragColMove; } void EnableDragGridSize(bool enable = true); void DisableDragGridSize(); bool CanDragGridSize(); @@ -1848,6 +1903,10 @@ public: void SetColSize( int col, int width ); + int GetColAt( int colPos ) const; + void SetColPos( int colID, int newPos ); + int GetColPos( int colID ) const; + // automatically size the column or row to fit to its contents, if // setAsMin is True, this optimal width will also be set as minimal width // for this column @@ -2021,7 +2080,7 @@ public: bool MetaDown(); bool ShiftDown(); bool AltDown(); - + bool CmdDown(); }; @@ -2038,7 +2097,7 @@ public: bool MetaDown(); bool ShiftDown(); bool AltDown(); - + bool CmdDown(); }; @@ -2063,6 +2122,7 @@ public: bool MetaDown(); bool ShiftDown(); bool AltDown(); + bool CmdDown(); };