Also add wxGridCellEditorPtr and wxGridCellRendererPtr

This is similar to the previous commit and replaces manual calls to
DecRef() on the renderers/editors with the use of smart pointers for
them too.
This commit is contained in:
Vadim Zeitlin
2020-02-08 15:14:24 +01:00
parent 5f34b1749e
commit 2e64ba6d6e
3 changed files with 86 additions and 37 deletions

View File

@@ -206,6 +206,9 @@ public:
virtual wxGridCellRenderer *Clone() const = 0;
};
// Smart pointer to wxGridCellRenderer, calling DecRef() on it automatically.
typedef wxObjectDataPtr<wxGridCellRenderer> wxGridCellRendererPtr;
// ----------------------------------------------------------------------------
// wxGridCellEditor: This class is responsible for providing and manipulating
// the in-place edit controls for the grid. Instances of wxGridCellEditor
@@ -333,6 +336,9 @@ protected:
wxDECLARE_NO_COPY_CLASS(wxGridCellEditor);
};
// Smart pointer to wxGridCellEditor, calling DecRef() on it automatically.
typedef wxObjectDataPtr<wxGridCellEditor> wxGridCellEditorPtr;
// ----------------------------------------------------------------------------
// wxGridHeaderRenderer and company: like wxGridCellRenderer but for headers
// ----------------------------------------------------------------------------
@@ -573,8 +579,18 @@ public:
// whether the cell will draw the overflowed text to neighbour cells
// currently only left aligned cells can overflow
bool CanOverflow() const;
wxGridCellRenderer *GetRenderer(const wxGrid* grid, int row, int col) const;
wxGridCellRendererPtr GetRendererPtr(const wxGrid* grid, int row, int col) const
{
return wxGridCellRendererPtr(GetRenderer(grid, row, col));
}
wxGridCellEditor *GetEditor(const wxGrid* grid, int row, int col) const;
wxGridCellEditorPtr GetEditorPtr(const wxGrid* grid, int row, int col) const
{
return wxGridCellEditorPtr(GetEditor(grid, row, col));
}
bool IsReadOnly() const { return m_isReadOnly == wxGridCellAttr::ReadOnly; }