X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/82edfbe7d99a970b00ca37e5017ce74c3c9a37e0..86ac84b8ce086e6bbda58f422d41f84268606e35:/include/wx/generic/grid.h diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index 0e8c1b9ff3..8f66617f86 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -110,16 +110,10 @@ class wxGridDirectionOperations; // class is not documented and is not public at all // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_ADV wxGridCellWorker : public wxClientDataContainer +class WXDLLIMPEXP_ADV wxGridCellWorker : public wxClientDataContainer, public wxRefCounter { public: - wxGridCellWorker() { m_nRef = 1; } - - // this class is ref counted: it is created with ref count of 1, so - // calling DecRef() once will delete it. Calling IncRef() allows to lock - // it until the matching DecRef() is called - void IncRef() { m_nRef++; } - void DecRef() { if ( --m_nRef == 0 ) delete this; } + wxGridCellWorker() { } // interpret renderer parameters: arbitrary string whose interpretatin is // left to the derived classes @@ -131,8 +125,6 @@ protected: virtual ~wxGridCellWorker(); private: - size_t m_nRef; - // suppress the stupid gcc warning about the class having private dtor and // no friends friend class wxGridCellWorkerDummyFriend; @@ -297,7 +289,7 @@ protected: // class may be returned by wxGridTable::GetAttr(). // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_ADV wxGridCellAttr : public wxClientDataContainer +class WXDLLIMPEXP_ADV wxGridCellAttr : public wxClientDataContainer, public wxRefCounter { public: enum wxAttrKind @@ -336,12 +328,6 @@ public: wxGridCellAttr *Clone() const; void MergeWith(wxGridCellAttr *mergefrom); - // this class is ref counted: it is created with ref count of 1, so - // calling DecRef() once will delete it. Calling IncRef() allows to lock - // it until the matching DecRef() is called - void IncRef() { m_nRef++; } - void DecRef() { if ( --m_nRef == 0 ) delete this; } - // setters void SetTextColour(const wxColour& colText) { m_colText = colText; } void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; } @@ -419,9 +405,6 @@ private: void Init(wxGridCellAttr *attrDefault = NULL); - // the ref count - when it goes to 0, we die - size_t m_nRef; - wxColour m_colText, m_colBack; wxFont m_font; @@ -725,14 +708,13 @@ class WXDLLIMPEXP_ADV wxGridStringTable : public wxGridTableBase public: wxGridStringTable(); wxGridStringTable( int numRows, int numCols ); - virtual ~wxGridStringTable(); // these are pure virtual in wxGridTableBase // - int GetNumberRows(); - int GetNumberCols(); - wxString GetValue( int row, int col ); - void SetValue( int row, int col, const wxString& s ); + virtual int GetNumberRows() { return m_data.size(); } + virtual int GetNumberCols() { return m_numCols; } + virtual wxString GetValue( int row, int col ); + virtual void SetValue( int row, int col, const wxString& s ); // overridden functions from wxGridTableBase // @@ -752,6 +734,12 @@ public: private: wxGridStringArray m_data; + // notice that while we don't need to store the number of our rows as it's + // always equal to the size of m_data array, we do need to store the number + // of our columns as we can't retrieve it from m_data when the number of + // rows is 0 (see #10818) + int m_numCols; + // These only get used if you set your own labels, otherwise the // GetRow/ColLabelValue functions return wxGridTableBase defaults // @@ -1956,10 +1944,10 @@ protected: // it was processed (but not vetoed) and 0 if it wasn't processed int SendEvent(const wxEventType evtType, int row, int col, - wxMouseEvent& e); + const wxMouseEvent& e); int SendEvent(const wxEventType evtType, const wxGridCellCoords& coords, - wxMouseEvent& e) + const wxMouseEvent& e) { return SendEvent(evtType, coords.GetRow(), coords.GetCol(), e); } int SendEvent(const wxEventType evtType, int row, int col, @@ -1971,6 +1959,11 @@ protected: int SendEvent(const wxEventType evtType, const wxString& s = wxString()) { return SendEvent(evtType, m_currentCellCoords, s); } + // send wxEVT_GRID_{ROW,COL}_SIZE + void SendGridSizeEvent(wxEventType type, + int row, int col, + const wxMouseEvent& mouseEv); + void OnPaint( wxPaintEvent& ); void OnSize( wxSizeEvent& ); void OnKeyDown( wxKeyEvent& ); @@ -2084,14 +2077,14 @@ private: void DoUpdateResizeColWidth(int w); void DoStartMoveCol(int col); - void DoEndDragResizeRow(); - void DoEndDragResizeCol(wxMouseEvent *event = NULL); + void DoEndDragResizeRow(const wxMouseEvent& event); + void DoEndDragResizeCol(const wxMouseEvent& event); void DoEndMoveCol(int pos); // common implementations of methods defined for both rows and columns void DeselectLine(int line, const wxGridOperations& oper); - void DoEndDragResizeLine(const wxGridOperations& oper); + bool DoEndDragResizeLine(const wxGridOperations& oper); int PosToLinePos(int pos, bool clipToMinMax, const wxGridOperations& oper) const; int PosToLine(int pos, bool clipToMinMax,