Use wxDataViewRenderer::PrepareForItem() in all ports

wxOSX and wxGTK previously used their own methods for handling the enabled
state and the attributes of the items being rendered, change them to reuse the
same methods as the generic implementation, i.e. SetEnabled() and SetAttr()
and remove the port-specific GtkSetAttr(), OSXApplyAttr() and so on.

This has the advantage of ensuring that the logic is the same for all
platforms (e.g. item enabled status wasn't handled in the same way in wxGTK as
in the other ports previously) and hopefully makes the code simpler by cutting
down on the number of virtual methods.

Notice that GtkSupportsAttrs() optimization was removed as it didn't seem to
be worth the bother (we basically saved a call to a virtual model method at a
price of a virtual renderer method call) and preserving it would have
complicated things needlessly.
This commit is contained in:
Vadim Zeitlin
2015-08-29 01:03:42 +02:00
parent a49567109a
commit 361c6357b4
9 changed files with 106 additions and 176 deletions

View File

@@ -49,12 +49,11 @@ public:
virtual void SetAlignment( int align );
virtual bool GtkSupportsAttrs() const { return true; }
virtual bool GtkSetAttr(const wxDataViewItemAttr& attr);
virtual GtkCellRendererText *GtkGetTextRenderer() const;
protected:
virtual void SetAttr(const wxDataViewItemAttr& attr) wxOVERRIDE;
// implementation of Set/GetValue()
bool SetTextValue(const wxString& str);
bool GetTextValue(wxString& str) const;
@@ -137,16 +136,6 @@ public:
m_renderParams = renderParams;
}
// we may or not support attributes, as we don't know it, return true to
// make it possible to use them
virtual bool GtkSupportsAttrs() const { return true; }
virtual bool GtkSetAttr(const wxDataViewItemAttr& attr)
{
SetAttr(attr);
return !attr.IsDefault();
}
virtual GtkCellRendererText *GtkGetTextRenderer() const;
private: