#include </home/zeitlin/src/wx/github/interface/wx/grid.h>
This class can be used to alter the cells' appearance in the grid by changing their attributes from the defaults.
An object of this class may be returned by wxGridTableBase::GetAttr().
Public Types | |
enum | wxAttrKind { Any, Cell, Row, Col } |
Kind of the attribute to retrieve. More... | |
Public Member Functions | |
wxGridCellAttr (wxGridCellAttr *attrDefault=NULL) | |
Default constructor. | |
wxGridCellAttr (const wxColour &colText, const wxColour &colBack, const wxFont &font, int hAlign, int vAlign) | |
Constructor specifying some of the often used attributes. | |
wxGridCellAttr * | Clone () const |
Creates a new copy of this object. | |
void | DecRef () |
This class is reference counted: it is created with ref count of 1, so calling DecRef() once will delete it. | |
void | GetAlignment (int *hAlign, int *vAlign) const |
Get the alignment to use for the cell with the given attribute. | |
const wxColour & | GetBackgroundColour () const |
Returns the background colour. | |
wxGridCellEditor * | GetEditor (const wxGrid *grid, int row, int col) const |
Returns the cell editor. | |
const wxFont & | GetFont () const |
Returns the font. | |
void | GetNonDefaultAlignment (int *hAlign, int *vAlign) const |
Get the alignment defined by this attribute. | |
wxGridCellRenderer * | GetRenderer (const wxGrid *grid, int row, int col) const |
Returns the cell renderer. | |
const wxColour & | GetTextColour () const |
Returns the text colour. | |
bool | HasAlignment () const |
Returns true if this attribute has a valid alignment set. | |
bool | HasBackgroundColour () const |
Returns true if this attribute has a valid background colour set. | |
bool | HasEditor () const |
Returns true if this attribute has a valid cell editor set. | |
bool | HasFont () const |
Returns true if this attribute has a valid font set. | |
bool | HasRenderer () const |
Returns true if this attribute has a valid cell renderer set. | |
bool | HasTextColour () const |
Returns true if this attribute has a valid text colour set. | |
void | IncRef () |
This class is reference counted: it is created with ref count of 1, so calling DecRef() once will delete it. | |
bool | IsReadOnly () const |
Returns true if this cell is set as read-only. | |
void | SetAlignment (int hAlign, int vAlign) |
Sets the alignment. | |
void | SetBackgroundColour (const wxColour &colBack) |
Sets the background colour. | |
void | SetDefAttr (wxGridCellAttr *defAttr) |
void | SetEditor (wxGridCellEditor *editor) |
Sets the editor to be used with the cells with this attribute. | |
void | SetFont (const wxFont &font) |
Sets the font. | |
void | SetReadOnly (bool isReadOnly=true) |
Sets the cell as read-only. | |
void | SetRenderer (wxGridCellRenderer *renderer) |
Sets the renderer to be used for cells with this attribute. | |
void | SetTextColour (const wxColour &colText) |
Sets the text colour. |
Kind of the attribute to retrieve.
wxGridCellAttr::wxGridCellAttr | ( | wxGridCellAttr * | attrDefault = NULL | ) |
Default constructor.
wxGridCellAttr::wxGridCellAttr | ( | const wxColour & | colText, |
const wxColour & | colBack, | ||
const wxFont & | font, | ||
int | hAlign, | ||
int | vAlign | ||
) |
Constructor specifying some of the often used attributes.
wxGridCellAttr* wxGridCellAttr::Clone | ( | ) | const |
Creates a new copy of this object.
void wxGridCellAttr::DecRef | ( | ) |
void wxGridCellAttr::GetAlignment | ( | int * | hAlign, |
int * | vAlign | ||
) | const |
Get the alignment to use for the cell with the given attribute.
If this attribute doesn't specify any alignment, the default attribute alignment is used (which can be changed using wxGrid::SetDefaultCellAlignment() but is left and top by default).
Notice that hAlign and vAlign values are always overwritten by this function, use GetNonDefaultAlignment() if this is not desirable.
hAlign | Horizontal alignment is returned here if this argument is non-NULL. It is one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT. |
vAlign | Vertical alignment is returned here if this argument is non-NULL. It is one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM. |
const wxColour& wxGridCellAttr::GetBackgroundColour | ( | ) | const |
Returns the background colour.
wxGridCellEditor* wxGridCellAttr::GetEditor | ( | const wxGrid * | grid, |
int | row, | ||
int | col | ||
) | const |
Returns the cell editor.
const wxFont& wxGridCellAttr::GetFont | ( | ) | const |
Returns the font.
void wxGridCellAttr::GetNonDefaultAlignment | ( | int * | hAlign, |
int * | vAlign | ||
) | const |
Get the alignment defined by this attribute.
Unlike GetAlignment() this function only modifies hAlign and vAlign if this attribute does define a non-default alignment. This means that they must be initialized before calling this function and that their values will be preserved unchanged if they are different from wxALIGN_INVALID.
For example, the following fragment can be used to use the cell alignment if one is defined but right-align its contents by default (instead of left-aligning it by default) while still using the default vertical alignment:
int hAlign = wxALIGN_RIGHT, vAlign = wxALIGN_INVALID; attr.GetNonDefaultAlignment(&hAlign, &vAlign);
wxGridCellRenderer* wxGridCellAttr::GetRenderer | ( | const wxGrid * | grid, |
int | row, | ||
int | col | ||
) | const |
Returns the cell renderer.
const wxColour& wxGridCellAttr::GetTextColour | ( | ) | const |
Returns the text colour.
bool wxGridCellAttr::HasAlignment | ( | ) | const |
Returns true if this attribute has a valid alignment set.
bool wxGridCellAttr::HasBackgroundColour | ( | ) | const |
Returns true if this attribute has a valid background colour set.
bool wxGridCellAttr::HasEditor | ( | ) | const |
Returns true if this attribute has a valid cell editor set.
bool wxGridCellAttr::HasFont | ( | ) | const |
Returns true if this attribute has a valid font set.
bool wxGridCellAttr::HasRenderer | ( | ) | const |
Returns true if this attribute has a valid cell renderer set.
bool wxGridCellAttr::HasTextColour | ( | ) | const |
Returns true if this attribute has a valid text colour set.
void wxGridCellAttr::IncRef | ( | ) |
bool wxGridCellAttr::IsReadOnly | ( | ) | const |
Returns true if this cell is set as read-only.
void wxGridCellAttr::SetAlignment | ( | int | hAlign, |
int | vAlign | ||
) |
Sets the alignment.
hAlign can be one of wxALIGN_LEFT
, wxALIGN_CENTRE
or wxALIGN_RIGHT
and vAlign can be one of wxALIGN_TOP
, wxALIGN_CENTRE
or wxALIGN_BOTTOM
.
void wxGridCellAttr::SetBackgroundColour | ( | const wxColour & | colBack | ) |
Sets the background colour.
void wxGridCellAttr::SetDefAttr | ( | wxGridCellAttr * | defAttr | ) |
void wxGridCellAttr::SetEditor | ( | wxGridCellEditor * | editor | ) |
Sets the editor to be used with the cells with this attribute.
void wxGridCellAttr::SetFont | ( | const wxFont & | font | ) |
Sets the font.
void wxGridCellAttr::SetReadOnly | ( | bool | isReadOnly = true | ) |
Sets the cell as read-only.
void wxGridCellAttr::SetRenderer | ( | wxGridCellRenderer * | renderer | ) |
Sets the renderer to be used for cells with this attribute.
Takes ownership of the pointer.
void wxGridCellAttr::SetTextColour | ( | const wxColour & | colText | ) |
Sets the text colour.