From 16a50d33ca2972073e159310fb9c52b652b751d4 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 14 Jan 2014 02:34:51 +0000 Subject: [PATCH] The rest of PR 36. Loop optimizations in ListRowHighlighter.RefreshRows. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@75611 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wx/lib/mixins/listctrl.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/wx/lib/mixins/listctrl.py b/wx/lib/mixins/listctrl.py index b6e24de3..d48c4c0c 100644 --- a/wx/lib/mixins/listctrl.py +++ b/wx/lib/mixins/listctrl.py @@ -842,27 +842,28 @@ class ListRowHighlighter: def RefreshRows(self): """Re-color all the rows""" + if self._color is None: + if wx.Platform in ('__WXGTK__', '__WXMSW__'): + color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DLIGHT) + else: + color = wx.Colour(237, 243, 254) + else: + color = self._color + local_defaultb = self._defaultb + local_mode = self._mode for row in xrange(self.GetItemCount()): - if self._defaultb is None: - self._defaultb = self.GetItemBackgroundColour(row) - - if self._mode & HIGHLIGHT_EVEN: + if local_mode & HIGHLIGHT_EVEN: dohlight = not row % 2 else: dohlight = row % 2 if dohlight: - if self._color is None: - if wx.Platform in ['__WXGTK__', '__WXMSW__']: - color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DLIGHT) - else: - color = wx.Colour(237, 243, 254) - else: - color = self._color - else: - color = self._defaultb - - self.SetItemBackgroundColour(row, color) + self.SetItemBackgroundColour(row, color) + elif local_defaultb: + self.SetItemBackgroundColour(row, local_defaultb) + else: # This part of the loop should only happen once if self._defaultb is None. + local_defaultb = self._defaultb = self.GetItemBackgroundColour(row) + self.SetItemBackgroundColour(row, local_defaultb) def SetHighlightColor(self, color): """Set the color used to highlight the rows. Call :meth:`RefreshRows` after