| Version: 3.2.5

Public Member Functions | List of all members
wxGridCellAttrProvider Class Reference

`#include <wx/grid.h>`

Inheritance diagram for wxGridCellAttrProvider:
[legend]

## 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. More...
virtual | ~wxGridCellAttrProvider ()
| Destructor releases any attributes held by this class. More...
virtual wxGridCellAttr * | GetAttr (int row, int col, wxGridCellAttr::wxAttrKind kind) const
| Get the attribute to use for the specified cell. More...
wxGridCellAttrPtr | GetAttrPtr (int row, int col, wxGridCellAttr::wxAttrKind kind) const
| Get the attribute to use for the specified cell. More...
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. The attribute can be NULL to reset a previously set value.
virtual void | SetAttr (wxGridCellAttr *attr, int row, int col)
| Set attribute for the specified cell. More...
virtual void | SetRowAttr (wxGridCellAttr *attr, int row)
| Set attribute for the specified row. More...
virtual void | SetColAttr (wxGridCellAttr *attr, int col)
| Set attribute for the specified column. More...
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.
virtual const wxGridColumnHeaderRenderer & | GetColumnHeaderRenderer (int col)
| Return the renderer used for drawing column headers. More...
virtual const wxGridRowHeaderRenderer & | GetRowHeaderRenderer (int row)
| Return the renderer used for drawing row headers. More...
virtual const wxGridCornerHeaderRenderer & | GetCornerRenderer ()
| Return the renderer used for drawing the corner window. More...
Public Member Functions inherited from wxClientDataContainer
| wxClientDataContainer ()
| Default constructor. More...
virtual | ~wxClientDataContainer ()
| Destructor. More...
void * | GetClientData () const
| Get the untyped client data. More...
wxClientData * | GetClientObject () const
| Get a pointer to the client data object. More...
void | SetClientData (void *data)
| Set the untyped client data. More...
void | SetClientObject (wxClientData *data)
| Set the client data object. More...

## Constructor & Destructor Documentation

## ◆ wxGridCellAttrProvider()

wxGridCellAttrProvider::wxGridCellAttrProvider | ( |  | ) |

Trivial default constructor.

## ◆ ~wxGridCellAttrProvider()

virtual wxGridCellAttrProvider::~wxGridCellAttrProvider | ( |  | ) |

virtual

Destructor releases any attributes held by this class.

## Member Function Documentation

## ◆ GetAttr()

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. GetAttrPtr() method can be used to do this automatically.

Parameters

  row | The row of the cell.
  col | The column of the cell.
  kind | The 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.

## ◆ GetAttrPtr()

wxGridCellAttrPtr wxGridCellAttrProvider::GetAttrPtr | ( | int | row,
|  | int | col,
|  | wxGridCellAttr::wxAttrKind | kind
| ) |  | const

Get the attribute to use for the specified cell.

This method is identical to GetAttr(), but returns a smart pointer, which frees the caller from the need to call DecRef() manually.

Since
  3.1.4

## ◆ GetColumnHeaderRenderer()

virtual const wxGridColumnHeaderRenderer& wxGridCellAttrProvider::GetColumnHeaderRenderer | ( | int | col | ) |

virtual

Return the renderer used for drawing column headers.

By default wxGridColumnHeaderRendererDefault is returned.

See also
  wxGrid::SetUseNativeColLabels(), wxGrid::UseNativeColHeader()

Since
  2.9.1

## ◆ GetCornerRenderer()

virtual const wxGridCornerHeaderRenderer& wxGridCellAttrProvider::GetCornerRenderer | ( |  | ) |

virtual

Return the renderer used for drawing the corner window.

By default wxGridCornerHeaderRendererDefault is returned.

Since
  2.9.1

## ◆ GetRowHeaderRenderer()

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

## ◆ SetAttr()

virtual void wxGridCellAttrProvider::SetAttr | ( | wxGridCellAttr * | attr,
|  | int | row,
|  | int | col
| ) |  |

virtual

Set attribute for the specified cell.

## ◆ SetColAttr()

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

virtual

Set attribute for the specified column.

## ◆ SetRowAttr()

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

virtual

Set attribute for the specified row.