wxWidgets: wxDataViewValueAdjuster Class Reference

| Version: 3.1.7

Loading...
Searching...
No Matches
Public Member Functions | List of all members
wxDataViewValueAdjuster Class Reference
Class List by Category » wxDataViewCtrl Related Classes

`#include </cygdrive/c/Users/Hamis/Cygwin-packaging/wxWidgets3.1/wxWidgets3.1-3.1.7-1.x86_64/src/wxWidgets-3.1.7/interface/wx/dataview.h>`

## Detailed Description

This class can be used with wxDataViewRenderer::SetValueAdjuster() to customize rendering of model values with standard renderers.

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.

// Markup renderer that removes bgcolor attributes when in selection
class DataViewMarkupRenderer : public wxDataViewTextRenderer
{
public:
DataViewMarkupRenderer()
{
EnableMarkup();
SetValueAdjuster(new Adjuster());
}
private:
class Adjuster : public wxDataViewValueAdjuster
{
public:
wxVariant MakeHighlighted(const wxVariant& value) const override
{
wxString s = value.GetString();
size_t pos = s.find(" bgcolor=\"");
if (pos != wxString::npos)
{
size_t pos2 = s.find('"', pos + 10);
s.erase(pos, pos2 - pos + 1);
return s;
}
return value;
}
};
};
wxDataViewRenderer::SetValueAdjuster
void SetValueAdjuster(wxDataViewValueAdjuster *transformer)
Set the transformer object to be used to customize values before they are rendered.
wxDataViewTextRenderer
wxDataViewTextRenderer is used for rendering text.
Definition dataview.h:2181
wxDataViewTextRenderer::EnableMarkup
void EnableMarkup(bool enable=true)
Enable interpretation of markup in the item data.
wxDataViewValueAdjuster
This class can be used with wxDataViewRenderer::SetValueAdjuster() to customize rendering of model va...
Definition dataview.h:4116
wxString
String class for passing textual data to or receiving it from wxWidgets.
Definition string.h:315
wxString::erase
wxString & erase(size_type pos=0, size_type n=npos)
An 'invalid' value for string index.
wxString::find
size_t find(const wxString &str, size_t nStart=0) const
An 'invalid' value for string index.
wxString::npos
static const size_t npos
An 'invalid' value for string index.
Definition string.h:1783
wxVariant
The wxVariant class represents a container for any type.
Definition variant.h:163
wxVariant::GetString
wxString GetString() const
Gets the string value.

Since
  3.1.1

##

Library: wxCore
Category: wxDataViewCtrl Related Classes

## Public Member Functions
virtual wxVariant | MakeHighlighted (const wxVariant &value) const
| Change value for rendering when highlighted.

## Member Function Documentation

## ◆ MakeHighlighted()

virtual wxVariant wxDataViewValueAdjuster::MakeHighlighted | ( | const wxVariant & | value | ) | const
| virtual

Change value for rendering when highlighted.

Override to customize the value when it is shown in a highlighted (selected) row, typically on a dark background.

Default implementation returns value unmodified.

The value passed to this method is always non-null and it must return a non-null value too.