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

@@ -95,6 +95,20 @@ protected:
virtual ~wxGridCellRenderer();
};
/**
Smart pointer wrapping wxGridCellRenderer.
wxGridCellRendererPtr takes ownership of wxGridCellRenderer passed to it on
construction and calls DecRef() on it automatically when it is destroyed.
It also provides transparent access to wxGridCellRenderer methods by allowing
to use objects of this class as if they were wxGridCellRenderer pointers.
@since 3.1.4
@category{grid}
*/
typedef wxObjectDataPtr<wxGridCellRenderer> wxGridCellRendererPtr;
/**
@class wxGridCellAutoWrapStringRenderer
@@ -591,6 +605,20 @@ protected:
virtual ~wxGridCellEditor();
};
/**
Smart pointer wrapping wxGridCellEditor.
wxGridCellEditorPtr takes ownership of wxGridCellEditor passed to it on
construction and calls DecRef() on it automatically when it is destroyed.
It also provides transparent access to wxGridCellEditor methods by allowing
to use objects of this class as if they were wxGridCellEditor pointers.
@since 3.1.4
@category{grid}
*/
typedef wxObjectDataPtr<wxGridCellEditor> wxGridCellEditorPtr;
/**
@class wxGridCellAutoWrapStringEditor
@@ -1058,9 +1086,22 @@ public:
/**
Returns the cell editor.
The caller is responsible for calling DecRef() on the returned pointer,
use GetEditorPtr() to do it automatically.
*/
wxGridCellEditor* GetEditor(const wxGrid* grid, int row, int col) const;
/**
Returns the cell editor.
This method is identical to GetEditor(), but returns a smart pointer,
which frees the caller from the need to call DecRef() manually.
@since 3.1.4
*/
wxGridCellEditorPtr GetEditorPtr(const wxGrid* grid, int row, int col) const;
/**
Returns the font.
*/
@@ -1091,9 +1132,22 @@ public:
/**
Returns the cell renderer.
The caller is responsible for calling DecRef() on the returned pointer,
use GetRendererPtr() to do it automatically.
*/
wxGridCellRenderer* GetRenderer(const wxGrid* grid, int row, int col) const;
/**
Returns the cell editor.
This method is identical to GetRenderer(), but returns a smart pointer,
which frees the caller from the need to call DecRef() manually.
@since 3.1.4
*/
wxGridCellRendererPtr GetRendererPtr(const wxGrid* grid, int row, int col) const;
/**
Returns the text colour.
*/