From: Vadim Zeitlin Date: Sat, 17 Nov 2007 14:24:18 +0000 (+0000) Subject: compare colours using their operator==() instead of comparing individual RGB componen... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/b685c0a6684e28fee1bade4e7b3677ef60f8f34c 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 --- diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index 167ad8e889..fb3f055d0e 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -736,16 +736,15 @@ wxGDIObjListBase::~wxGDIObjListBase() 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 (); - if ( - each_pen->GetWidth () == width && - each_pen->GetStyle () == style && - each_pen->GetColour ().Red () == colour.Red () && - each_pen->GetColour ().Green () == colour.Green () && - each_pen->GetColour ().Blue () == colour.Blue ()) - return each_pen; + wxPen * const pen = (wxPen *) node->GetData(); + if ( pen->GetWidth () == width && + pen->GetStyle () == style && + pen->GetColour() == colour ) + return pen; } 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) { - 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 (); - if ( - each_brush->GetStyle () == style && - each_brush->GetColour ().Red () == colour.Red () && - each_brush->GetColour ().Green () == colour.Green () && - each_brush->GetColour ().Blue () == colour.Blue ()) - return each_brush; + wxBrush * const brush = (wxBrush *) node->GetData (); + if ( brush->GetStyle () == style && brush->GetColour() == colour ) + return brush; } wxBrush* brush = NULL;