Use wxBrush objects instead of pointers in wxGenericTreeCtrl

There is no need for double indirection, wxBrush object is already
pointer-like internally.

No real changes, just simplify/optimize the code a little.
This commit is contained in:
Vadim Zeitlin
2020-07-14 15:43:23 +02:00
parent cde033df8d
commit 1ec7ae9a6f
2 changed files with 7 additions and 13 deletions

View File

@@ -13,8 +13,9 @@
#if wxUSE_TREECTRL
#include "wx/scrolwin.h"
#include "wx/brush.h"
#include "wx/pen.h"
#include "wx/scrolwin.h"
// -----------------------------------------------------------------------------
// forward declaration
@@ -243,8 +244,8 @@ protected:
unsigned short m_indent;
int m_lineHeight;
wxPen m_dottedPen;
wxBrush *m_hilightBrush,
*m_hilightUnfocusedBrush;
wxBrush m_hilightBrush,
m_hilightUnfocusedBrush;
bool m_hasFocus;
bool m_dirty;
bool m_ownsImageListButtons;

View File

@@ -937,8 +937,6 @@ void wxGenericTreeCtrl::Init()
m_indent = 15;
m_spacing = 18;
m_hilightBrush = NULL;
m_hilightUnfocusedBrush = NULL;
m_imageListButtons = NULL;
m_ownsImageListButtons = false;
@@ -995,9 +993,6 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent,
wxGenericTreeCtrl::~wxGenericTreeCtrl()
{
delete m_hilightBrush;
delete m_hilightUnfocusedBrush;
DeleteAllItems();
delete m_renameTimer;
@@ -1020,10 +1015,8 @@ void wxGenericTreeCtrl::OnSysColourChanged(wxSysColourChangedEvent&)
if (!m_hasExplicitFont)
SetOwnFont(attr.font);
delete m_hilightBrush;
m_hilightBrush = new wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
delete m_hilightUnfocusedBrush;
m_hilightUnfocusedBrush = new wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
m_hilightBrush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
m_hilightUnfocusedBrush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
m_dottedPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT), 1, wxPENSTYLE_DOT);
@@ -2544,7 +2537,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
if ( item->IsSelected() )
{
dc.SetBrush(*(m_hasFocus ? m_hilightBrush : m_hilightUnfocusedBrush));
dc.SetBrush(m_hasFocus ? m_hilightBrush : m_hilightUnfocusedBrush);
drawItemBackground = true;
}
else