compare colours using their operator==() instead of comparing individual RGB components as this is shorter and more correct for the colours with the same RGB but different alpha components (patch 1832844)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50022 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-11-17 14:24:18 +00:00
parent 9a2534df04
commit b685c0a668

View File

@@ -736,16 +736,15 @@ wxGDIObjListBase::~wxGDIObjListBase()
wxPen *wxPenList::FindOrCreatePen (const wxColour& colour, int width, int style) wxPen *wxPenList::FindOrCreatePen (const wxColour& colour, int width, int style)
{ {
for (wxList::compatibility_iterator node = list.GetFirst(); node; node = node->GetNext()) for ( wxList::compatibility_iterator node = list.GetFirst();
node;
node = node->GetNext() )
{ {
wxPen *each_pen = (wxPen *) node->GetData (); wxPen * const pen = (wxPen *) node->GetData();
if ( if ( pen->GetWidth () == width &&
each_pen->GetWidth () == width && pen->GetStyle () == style &&
each_pen->GetStyle () == style && pen->GetColour() == colour )
each_pen->GetColour ().Red () == colour.Red () && return pen;
each_pen->GetColour ().Green () == colour.Green () &&
each_pen->GetColour ().Blue () == colour.Blue ())
return each_pen;
} }
wxPen* pen = NULL; wxPen* pen = NULL;
@@ -761,15 +760,13 @@ wxPen *wxPenList::FindOrCreatePen (const wxColour& colour, int width, int style)
wxBrush *wxBrushList::FindOrCreateBrush (const wxColour& colour, int style) wxBrush *wxBrushList::FindOrCreateBrush (const wxColour& colour, int style)
{ {
for (wxList::compatibility_iterator node = list.GetFirst(); node; node = node->GetNext()) for ( wxList::compatibility_iterator node = list.GetFirst();
node;
node = node->GetNext() )
{ {
wxBrush *each_brush = (wxBrush *) node->GetData (); wxBrush * const brush = (wxBrush *) node->GetData ();
if ( if ( brush->GetStyle () == style && brush->GetColour() == colour )
each_brush->GetStyle () == style && return brush;
each_brush->GetColour ().Red () == colour.Red () &&
each_brush->GetColour ().Green () == colour.Green () &&
each_brush->GetColour ().Blue () == colour.Blue ())
return each_brush;
} }
wxBrush* brush = NULL; wxBrush* brush = NULL;