Fix wxDataViewIconTextRenderer background on GTK

Background attribute needs to be set on the icon renderer as well.
See #19301
This commit is contained in:
Paul Cornett
2022-03-28 21:28:10 -07:00
parent 9bb3945778
commit ffdaec88ee
2 changed files with 22 additions and 0 deletions

View File

@@ -216,6 +216,7 @@ protected:
class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewTextRenderer
{
typedef wxDataViewTextRenderer BaseType;
public:
static wxString GetDefaultType() { return wxS("wxDataViewIconText"); }
@@ -230,6 +231,7 @@ public:
virtual void GtkPackIntoColumn(GtkTreeViewColumn *column) wxOVERRIDE;
protected:
virtual void SetAttr(const wxDataViewItemAttr& attr) wxOVERRIDE;
virtual wxVariant GtkGetValueFromString(const wxString& str) const wxOVERRIDE;
private:

View File

@@ -3136,6 +3136,26 @@ bool wxDataViewIconTextRenderer::GetValue(wxVariant& value) const
return true;
}
void wxDataViewIconTextRenderer::SetAttr(const wxDataViewItemAttr& attr)
{
BaseType::SetAttr(attr);
if (attr.HasBackgroundColour())
{
#ifdef __WXGTK3__
const GdkRGBA* rbga = attr.GetBackgroundColour();
g_object_set(G_OBJECT(m_rendererIcon), "cell-background-rgba", rbga, NULL);
#else
const GdkColor* color = attr.GetBackgroundColour().GetColor();
g_object_set(G_OBJECT(m_rendererIcon), "cell-background-gdk", color, NULL);
#endif
}
else
{
g_object_set(G_OBJECT(m_rendererIcon), "cell-background-set", false, NULL);
}
}
wxVariant
wxDataViewIconTextRenderer::GtkGetValueFromString(const wxString& str) const
{