Replace wxTreeItemAttr and wxListItemAttr with wxItemAttr

The two existing structs were completely identical, just replace them with a
single wxItemAttr.

Notice that wxDataViewItemAttr is not quite the same, although pretty similar,
so it remains separate for now. It would be nice to combine it with this one
too in the future, e.g. to make it simpler to make items bold in a wxListCtrl.
This commit is contained in:
Vadim Zeitlin
2016-04-16 17:44:19 +02:00
parent c592363e95
commit 246ae58c19
24 changed files with 232 additions and 221 deletions

View File

@@ -37,6 +37,7 @@
#include "wx/generic/treectlg.h"
#include "wx/imaglist.h"
#include "wx/itemattr.h"
#include "wx/renderer.h"
@@ -223,7 +224,7 @@ public:
{
wxFont font;
wxTreeItemAttr * const attr = GetAttributes();
wxItemAttr * const attr = GetAttributes();
if ( attr && attr->HasFont() )
font = attr->GetFont();
else if ( IsBold() )
@@ -282,19 +283,19 @@ public:
// attributes
// get them - may be NULL
wxTreeItemAttr *GetAttributes() const { return m_attr; }
wxItemAttr *GetAttributes() const { return m_attr; }
// get them ensuring that the pointer is not NULL
wxTreeItemAttr& Attr()
wxItemAttr& Attr()
{
if ( !m_attr )
{
m_attr = new wxTreeItemAttr;
m_attr = new wxItemAttr;
m_ownsAttr = true;
}
return *m_attr;
}
// set them
void SetAttributes(wxTreeItemAttr *attr)
void SetAttributes(wxItemAttr *attr)
{
if ( m_ownsAttr ) delete m_attr;
m_attr = attr;
@@ -303,7 +304,7 @@ public:
m_widthText = -1;
}
// set them and delete when done
void AssignAttributes(wxTreeItemAttr *attr)
void AssignAttributes(wxItemAttr *attr)
{
SetAttributes(attr);
m_ownsAttr = true;
@@ -335,7 +336,7 @@ private:
wxArrayGenericTreeItems m_children; // list of children
wxGenericTreeItem *m_parent; // parent of this item
wxTreeItemAttr *m_attr; // attributes???
wxItemAttr *m_attr; // attributes???
// tree ctrl images for the normal, selected, expanded and
// expanded+selected states
@@ -2554,7 +2555,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
else
{
wxColour colBg;
wxTreeItemAttr * const attr = item->GetAttributes();
wxItemAttr * const attr = item->GetAttributes();
if ( attr && attr->HasBackgroundColour() )
{
drawItemBackground =
@@ -2789,7 +2790,7 @@ wxGenericTreeCtrl::PaintLevel(wxGenericTreeItem *item,
}
else
{
wxTreeItemAttr *attr = item->GetAttributes();
wxItemAttr *attr = item->GetAttributes();
if (attr && attr->HasTextColour())
colText = attr->GetTextColour();
else