Add support for custom attributes to wxGTK wxDataViewCustomRenderer.
Call SetAttr() to store them in wxDataViewCustomRenderer before rendering it and also honour the attributes in RenderText() (by reusing the same code we already use for wxDataViewTextRenderer). The attributes now work correctly in dataview sample under wxGTK as well. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62596 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -166,6 +166,8 @@ public:
|
||||
bool GetBold() const { return m_bold; }
|
||||
bool GetItalic() const { return m_italic; }
|
||||
|
||||
bool IsDefault() const { return !(HasColour() || HasFont()); }
|
||||
|
||||
private:
|
||||
wxColour m_colour;
|
||||
bool m_bold;
|
||||
|
@@ -58,6 +58,14 @@ public:
|
||||
// for details
|
||||
virtual bool GtkSupportsAttrs() const { return false; }
|
||||
|
||||
// if GtkSupportsAttrs() returns true, this function will be called to
|
||||
// effectively set the attribute to use for rendering the next item
|
||||
//
|
||||
// it should return true if the attribute had any non-default properties
|
||||
virtual bool GtkSetAttr(const wxDataViewItemAttr& WXUNUSED(attr))
|
||||
{ return false; }
|
||||
|
||||
|
||||
// these functions are only called if GtkSupportsAttrs() returns true and
|
||||
// are used to remember whether the renderer currently uses the default
|
||||
// attributes or if we changed (and not reset them)
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#define _WX_GTK_DVRENDERERS_H_
|
||||
|
||||
typedef struct _GdkRectangle GdkRectangle;
|
||||
typedef struct _GtkCellRendererText GtkCellRendererText;
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewTextRenderer
|
||||
@@ -44,6 +45,7 @@ public:
|
||||
virtual void SetAlignment( int align );
|
||||
|
||||
virtual bool GtkSupportsAttrs() const { return true; }
|
||||
virtual bool GtkSetAttr(const wxDataViewItemAttr& attr);
|
||||
|
||||
protected:
|
||||
// implementation of Set/GetValue()
|
||||
@@ -128,13 +130,23 @@ public:
|
||||
m_renderParams.flags = flags;
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
protected:
|
||||
bool Init(wxDataViewCellMode mode, int align);
|
||||
|
||||
private:
|
||||
wxDC *m_dc;
|
||||
|
||||
GtkCellRenderer *m_text_renderer;
|
||||
GtkCellRendererText *m_text_renderer;
|
||||
|
||||
// parameters of the original render() call stored so that we could pass
|
||||
// them forward to m_text_renderer if our RenderText() is called
|
||||
|
Reference in New Issue
Block a user