Version: 3.0.2
wxGridCellAttrProvider Class Reference

#include <wx/grid.h>

+ Inheritance diagram for wxGridCellAttrProvider:

Detailed Description

Class providing attributes to be used for the grid cells.

This class both defines an interface which grid cell attributes providers should implement – and which can be implemented differently in derived classes – and a default implementation of this interface which is often good enough to be used without modification, especially with not very large grids for which the efficiency of attributes storage hardly matters (see the discussion below).

An object of this class can be associated with a wxGrid using wxGridTableBase::SetAttrProvider() but it's not necessary to call it if you intend to use the default provider as it is used by wxGridTableBase by default anyhow.

Notice that while attributes provided by this class can be set for individual cells using SetAttr() or the entire rows or columns using SetRowAttr() and SetColAttr() they are always retrieved using GetAttr() function.

The default implementation of this class stores the attributes passed to its SetAttr(), SetRowAttr() and SetColAttr() in a straightforward way. A derived class may use its knowledge about how the attributes are used in your program to implement it much more efficiently: for example, using a special background colour for all even-numbered rows can be implemented by simply returning the same attribute from GetAttr() if the row number is even instead of having to store N/2 row attributes where N is the total number of rows in the grid.

Notice that objects of this class can't be copied.

Public Member Functions

 wxGridCellAttrProvider ()
 Trivial default constructor.
 
virtual ~wxGridCellAttrProvider ()
 Destructor releases any attributes held by this class.
 
virtual wxGridCellAttrGetAttr (int row, int col, wxGridCellAttr::wxAttrKind kind) const
 Get the attribute to use for the specified cell.
 
virtual void SetAttr (wxGridCellAttr *attr, int row, int col)
 Setting attributes.
 
virtual void SetRowAttr (wxGridCellAttr *attr, int row)
 Set attribute for the specified row.
 
virtual void SetColAttr (wxGridCellAttr *attr, int col)
 Set attribute for the specified column.
 
virtual const
wxGridColumnHeaderRenderer
GetColumnHeaderRenderer (int col)
 Getting header renderers.
 
virtual const
wxGridRowHeaderRenderer
GetRowHeaderRenderer (int row)
 Return the renderer used for drawing row headers.
 
virtual const
wxGridCornerHeaderRenderer
GetCornerRenderer ()
 Return the renderer used for drawing the corner window.
 
- Public Member Functions inherited from wxClientDataContainer
 wxClientDataContainer ()
 Default constructor.
 
virtual ~wxClientDataContainer ()
 Destructor.
 
void * GetClientData () const
 Get the untyped client data.
 
wxClientDataGetClientObject () const
 Get a pointer to the client data object.
 
void SetClientData (void *data)
 Set the untyped client data.
 
void SetClientObject (wxClientData *data)
 Set the client data object.
 

Constructor & Destructor Documentation

wxGridCellAttrProvider::wxGridCellAttrProvider ( )

Trivial default constructor.

virtual wxGridCellAttrProvider::~wxGridCellAttrProvider ( )
virtual

Destructor releases any attributes held by this class.

Member Function Documentation

virtual wxGridCellAttr* wxGridCellAttrProvider::GetAttr ( int  row,
int  col,
wxGridCellAttr::wxAttrKind  kind 
) const
virtual

Get the attribute to use for the specified cell.

If wxGridCellAttr::Any is used as kind value, this function combines the attributes set for this cell using SetAttr() and those for its row or column (set with SetRowAttr() or SetColAttr() respectively), with the cell attribute having the highest precedence.

Notice that the caller must call DecRef() on the returned pointer if it is non-NULL.

Parameters
rowThe row of the cell.
colThe column of the cell.
kindThe kind of the attribute to return.
Returns
The attribute to use which should be DecRef()'d by caller or NULL if no attributes are defined for this cell.
virtual const wxGridColumnHeaderRenderer& wxGridCellAttrProvider::GetColumnHeaderRenderer ( int  col)
virtual

Getting header renderers.

These functions return the renderers for the given row or column header label and the corner window. Unlike cell attributes, these objects are not reference counted and are never NULL so they are returned by reference and not pointer and DecRef() shouldn't (and can't) be called for them.

All these functions were added in wxWidgets 2.9.1. Return the renderer used for drawing column headers.

By default wxGridColumnHeaderRendererDefault is returned.

See Also
wxGrid::SetUseNativeColLabels(), wxGrid::UseNativeColHeader()
Since
2.9.1
virtual const wxGridCornerHeaderRenderer& wxGridCellAttrProvider::GetCornerRenderer ( )
virtual

Return the renderer used for drawing the corner window.

By default wxGridCornerHeaderRendererDefault is returned.

Since
2.9.1
virtual const wxGridRowHeaderRenderer& wxGridCellAttrProvider::GetRowHeaderRenderer ( int  row)
virtual

Return the renderer used for drawing row headers.

By default wxGridRowHeaderRendererDefault is returned.

Since
2.9.1
virtual void wxGridCellAttrProvider::SetAttr ( wxGridCellAttr attr,
int  row,
int  col 
)
virtual

Setting attributes.

All these functions take ownership of the attribute passed to them, i.e. will call DecRef() on it themselves later and so it should not be destroyed by the caller. And the attribute can be NULL to reset a previously set value.Set attribute for the specified cell.

virtual void wxGridCellAttrProvider::SetColAttr ( wxGridCellAttr attr,
int  col 
)
virtual

Set attribute for the specified column.

virtual void wxGridCellAttrProvider::SetRowAttr ( wxGridCellAttr attr,
int  row 
)
virtual

Set attribute for the specified row.