| Version: 3.2.8

Public Member Functions | Protected Member Functions | List of all members
wxDataViewRenderer Class Referenceabstract
Class List by Category » wxDataViewCtrl Related Classes

`#include <wx/dataview.h>`

Inheritance diagram for wxDataViewRenderer:
[legend]

## Detailed Description

This class is used by wxDataViewCtrl to render the individual cells.

One instance of a renderer class is owned by a wxDataViewColumn. There is a number of ready-to-use renderers provided:

- wxDataViewTextRenderer,
- wxDataViewIconTextRenderer,
- wxDataViewCheckIconTextRenderer,
- wxDataViewToggleRenderer,
- wxDataViewProgressRenderer,
- wxDataViewBitmapRenderer,
- wxDataViewDateRenderer,
- wxDataViewSpinRenderer.
- wxDataViewChoiceRenderer.

Additionally, the user can write their own renderers by deriving from wxDataViewCustomRenderer.

The wxDataViewCellMode and wxDataViewCellRenderState flags accepted by the constructors respectively controls what actions the cell data allows and how the renderer should display its contents in a cell.

##

Library: wxCore
Category: wxDataViewCtrl Related Classes

## Public Member Functions
| wxDataViewRenderer (const wxString &varianttype, wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT)
| Constructor. More...
void | EnableEllipsize (wxEllipsizeMode mode=wxELLIPSIZE_MIDDLE)
| Enable or disable replacing parts of the item text with ellipsis to make it fit the column width. More...
void | DisableEllipsize ()
| Disable replacing parts of the item text with ellipsis. More...
virtual wxString | GetAccessibleDescription () const =0
| This method returns a string describing the content of the renderer to the class implementing accessibility features in wxDataViewCtrl. More...
virtual int | GetAlignment () const
| Returns the alignment. More...
wxEllipsizeMode | GetEllipsizeMode () const
| Returns the ellipsize mode used by the renderer. More...
virtual wxDataViewCellMode | GetMode () const
| Returns the cell mode. More...
wxDataViewColumn * | GetOwner () const
| Returns pointer to the owning wxDataViewColumn. More...
virtual bool | GetValue (wxVariant &value) const =0
| This methods retrieves the value from the renderer in order to transfer the value back to the data model. More...
wxString | GetVariantType () const
| Returns a string with the type of the wxVariant supported by this renderer. More...
virtual bool | IsCompatibleVariantType (const wxString &variantType) const
| Check if the given variant type is compatible with the type expected by this renderer. More...
virtual void | SetAlignment (int align)
| Sets the alignment of the renderer's content. More...
void | SetOwner (wxDataViewColumn *owner)
| Sets the owning wxDataViewColumn. More...
virtual bool | SetValue (const wxVariant &value)=0
| Set the value of the renderer (and thus its cell) to value. More...
void | SetValueAdjuster (wxDataViewValueAdjuster *transformer)
| Set the transformer object to be used to customize values before they are rendered. More...
virtual bool | Validate (wxVariant &value)
| Before data is committed to the data model, it is passed to this method where it can be checked for validity. More...
virtual bool | HasEditorCtrl () const
virtual wxWindow * | CreateEditorCtrl (wxWindow *parent, wxRect labelRect, const wxVariant &value)
virtual bool | GetValueFromEditorCtrl (wxWindow *editor, wxVariant &value)
virtual bool | StartEditing (const wxDataViewItem &item, wxRect labelRect)
virtual void | CancelEditing ()
virtual bool | FinishEditing ()
wxWindow * | GetEditorCtrl ()
Public Member Functions inherited from wxObject
| wxObject ()
| Default ctor; initializes to NULL the internal reference data. More...
| wxObject (const wxObject &other)
| Copy ctor. More...
virtual | ~wxObject ()
| Destructor. More...
virtual wxClassInfo * | GetClassInfo () const
| This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar). More...
wxObjectRefData * | GetRefData () const
| Returns the wxObject::m_refData pointer, i.e. the data referenced by this object. More...
bool | IsKindOf (const wxClassInfo *info) const
| Determines whether this class is a subclass of (or the same class as) the given class. More...
bool | IsSameAs (const wxObject &obj) const
| Returns true if this object has the same data pointer as obj. More...
void | Ref (const wxObject &clone)
| Makes this object refer to the data in clone. More...
void | SetRefData (wxObjectRefData *data)
| Sets the wxObject::m_refData pointer. More...
void | UnRef ()
| Decrements the reference count in the associated data, and if it is zero, deletes the data. More...
void | UnShare ()
| This is the same of AllocExclusive() but this method is public. More...
void | operator delete (void *buf)
| The delete operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined. More...
void * | operator new (size_t size, const wxString &filename=NULL, int lineNum=0)
| The new operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined. More...

## Protected Member Functions
wxDataViewCtrl * | GetView () const
Protected Member Functions inherited from wxObject
void | AllocExclusive ()
| Ensure that this object's data is not shared with any other object. More...
virtual wxObjectRefData * | CreateRefData () const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it. More...
virtual wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data. More...

## Additional Inherited Members
Protected Attributes inherited from wxObject
wxObjectRefData * | m_refData
| Pointer to an object which is the object's reference-counted data. More...

## Constructor & Destructor Documentation

## ◆ wxDataViewRenderer()

wxDataViewRenderer::wxDataViewRenderer | ( | const wxString & | varianttype,
|  | wxDataViewCellMode | mode = `wxDATAVIEW_CELL_INERT`,
|  | int | align = `wxDVR_DEFAULT_ALIGNMENT`
| ) |  |

Constructor.

The varianttype parameter is the main type of wxVariant objects supported by this renderer, i.e. those that can be passed to its SetValue(), e.g. "string" for wxDataViewTextRenderer. The value of this parameter is returned by GetVariantType().

When deriving a custom renderer, either an existing variant type or a new custom one can be used, see wxVariant documentation for more details.

## Member Function Documentation

## ◆ CancelEditing()

virtual void wxDataViewRenderer::CancelEditing | ( |  | ) |
| virtual

## ◆ CreateEditorCtrl()

virtual wxWindow* wxDataViewRenderer::CreateEditorCtrl | ( | wxWindow * | parent,
|  | wxRect | labelRect,
|  | const wxVariant & | value
| ) |  |
| virtual

Reimplemented in wxDataViewCustomRenderer.

## ◆ DisableEllipsize()

void wxDataViewRenderer::DisableEllipsize | ( |  | ) |

Disable replacing parts of the item text with ellipsis.

If ellipsizing is disabled, the string will be truncated if it doesn't fit.

This is the same as

EnableEllipsize(wxELLIPSIZE_NONE)
wxDataViewRenderer::EnableEllipsize
void EnableEllipsize(wxEllipsizeMode mode=wxELLIPSIZE_MIDDLE)
Enable or disable replacing parts of the item text with ellipsis to make it fit the column width.
wxELLIPSIZE_NONE
@ wxELLIPSIZE_NONE
Don't ellipsize the text at all.
Definition: gdicmn.h:152

.

Since
  2.9.1

## ◆ EnableEllipsize()

void wxDataViewRenderer::EnableEllipsize | ( | wxEllipsizeMode | mode = `wxELLIPSIZE_MIDDLE` | ) |

Enable or disable replacing parts of the item text with ellipsis to make it fit the column width.

This method only makes sense for the renderers working with text, such as wxDataViewTextRenderer or wxDataViewIconTextRenderer.

By default wxELLIPSIZE_MIDDLE is used.

Parameters

  mode | Ellipsization mode, use wxELLIPSIZE_NONE to disable.

Since
  2.9.1

## ◆ FinishEditing()

virtual bool wxDataViewRenderer::FinishEditing | ( |  | ) |
| virtual

## ◆ GetAccessibleDescription()

virtual wxString wxDataViewRenderer::GetAccessibleDescription | ( |  | ) | const
| pure virtual

This method returns a string describing the content of the renderer to the class implementing accessibility features in wxDataViewCtrl.

Note
  The method is implemented if `wxUSE_ACCESSIBILITY` setup symbol is set to 1.

Since
  3.1.1

## ◆ GetAlignment()

virtual int wxDataViewRenderer::GetAlignment | ( |  | ) | const
| virtual

Returns the alignment.

See SetAlignment()

## ◆ GetEditorCtrl()

wxWindow* wxDataViewRenderer::GetEditorCtrl | ( |  | ) |

## ◆ GetEllipsizeMode()

wxEllipsizeMode wxDataViewRenderer::GetEllipsizeMode | ( |  | ) | const

Returns the ellipsize mode used by the renderer.

If the return value is wxELLIPSIZE_NONE, the text is simply truncated if it doesn't fit.

See also
  EnableEllipsize()

## ◆ GetMode()

virtual wxDataViewCellMode wxDataViewRenderer::GetMode | ( |  | ) | const
| virtual

Returns the cell mode.

## ◆ GetOwner()

wxDataViewColumn* wxDataViewRenderer::GetOwner | ( |  | ) | const

Returns pointer to the owning wxDataViewColumn.

## ◆ GetValue()

virtual bool wxDataViewRenderer::GetValue | ( | wxVariant & | value | ) | const
| pure virtual

This methods retrieves the value from the renderer in order to transfer the value back to the data model.

Returns false on failure.

## ◆ GetValueFromEditorCtrl()

virtual bool wxDataViewRenderer::GetValueFromEditorCtrl | ( | wxWindow * | editor,
|  | wxVariant & | value
| ) |  |
| virtual

Reimplemented in wxDataViewCustomRenderer.

## ◆ GetVariantType()

wxString wxDataViewRenderer::GetVariantType | ( |  | ) | const

Returns a string with the type of the wxVariant supported by this renderer.

Note that a renderer may support more than one variant type, in which case it needs to override IsCompatibleVariantType() to return true for all types it supports. But by default only the type returned by this function is supported.

## ◆ GetView()

wxDataViewCtrl* wxDataViewRenderer::GetView | ( |  | ) | const
| protected

## ◆ HasEditorCtrl()

virtual bool wxDataViewRenderer::HasEditorCtrl | ( |  | ) | const
| virtual

Reimplemented in wxDataViewCustomRenderer.

## ◆ IsCompatibleVariantType()

virtual bool wxDataViewRenderer::IsCompatibleVariantType | ( | const wxString & | variantType | ) | const
| virtual

Check if the given variant type is compatible with the type expected by this renderer.

The base class implementation just compares variantType with the value returned by GetVariantType(), but this function can be overridden to accept other types that can be converted to the type needed by the renderer.

Since
  3.1.7

## ◆ SetAlignment()

virtual void wxDataViewRenderer::SetAlignment | ( | int | align | ) |
| virtual

Sets the alignment of the renderer's content.

The default value of `wxDVR_DEFAULT_ALIGNMENT` indicates that the content should have the same alignment as the column header.

The method is not implemented under macOS and the renderer always aligns its contents as the column header on that platform. The other platforms support both vertical and horizontal alignment.

## ◆ SetOwner()

void wxDataViewRenderer::SetOwner | ( | wxDataViewColumn * | owner | ) |

Sets the owning wxDataViewColumn.

This is usually called from within wxDataViewColumn.

## ◆ SetValue()

virtual bool wxDataViewRenderer::SetValue | ( | const wxVariant & | value | ) |
| pure virtual

Set the value of the renderer (and thus its cell) to value.

The internal code will then render this cell with this data.

Parameters

  value | A valid, i.e. non-null, value to be shown.

## ◆ SetValueAdjuster()

void wxDataViewRenderer::SetValueAdjuster | ( | wxDataViewValueAdjuster * | transformer | ) |

Set the transformer object to be used to customize values before they are rendered.

Can be used to change the value if it is shown on a highlighted row (i.e. in selection) which typically has dark background. It is useful in combination with wxDataViewTextRenderer with markup and can be used e.g. to remove background color attributes inside selection, as a lightweight alternative to implementing an entire wxDataViewCustomRenderer specialization.

transformer can be NULL to reset any transformer currently being used.

Takes ownership of transformer.

See also
  wxDataViewValueAdjuster

Since
  3.1.1

## ◆ StartEditing()

virtual bool wxDataViewRenderer::StartEditing | ( | const wxDataViewItem & | item,
|  | wxRect | labelRect
| ) |  |
| virtual

## ◆ Validate()

virtual bool wxDataViewRenderer::Validate | ( | wxVariant & | value | ) |
| virtual

Before data is committed to the data model, it is passed to this method where it can be checked for validity.

This can also be used for checking a valid range or limiting the user input in a certain aspect (e.g. max number of characters or only alphanumeric input, ASCII only etc.). Return false if the value is not valid.

Please note that due to implementation limitations, this validation is done after the editing control already is destroyed and the editing process finished.