From aa01abddd074c46fc4f152f21c08e746c7908696 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 11 Oct 2019 15:15:59 -0700 Subject: [PATCH] Only use the selection fg color on the columns drawn with the selection bg --- wx/lib/agw/customtreectrl.py | 24 ++++++++++++------------ wx/lib/agw/hypertreelist.py | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/wx/lib/agw/customtreectrl.py b/wx/lib/agw/customtreectrl.py index 4a2f4f68..83f970b1 100644 --- a/wx/lib/agw/customtreectrl.py +++ b/wx/lib/agw/customtreectrl.py @@ -4655,7 +4655,7 @@ class CustomTreeCtrl(wx.ScrolledWindow): if item not in siblings: # Item is unlinked from tree return None - + index = siblings.index(item) n = index + 1 return (n == len(siblings) and [None] or [siblings[n]])[0] @@ -7354,7 +7354,7 @@ class CustomTreeCtrl(wx.ScrolledWindow): top = self.GetRootItem() if self.HasAGWFlag(TR_HIDE_ROOT): top, cookie = self.GetFirstChild(top) - + lastEnabled = None while top: # Keep track of last enabled item encountered. @@ -7372,11 +7372,11 @@ class CustomTreeCtrl(wx.ScrolledWindow): top = self.GetRootItem() if self.HasAGWFlag(TR_HIDE_ROOT): top, cookie = self.GetFirstChild(top) - + # Scan for first enabled and displayed item. while top and self.IsItemEnabled(top) is False: top = self.GetNextShown(top) - + if top: self.DoSelectItem(top, unselect_others, extended_select, from_key=True) @@ -7411,7 +7411,7 @@ class CustomTreeCtrl(wx.ScrolledWindow): else: if visCount > 1 and targetItem != currentItem: # Move to top visible item in page. - break + break visCount = 0 # Move up to previous item, set as target if it is enabled. if prevItem.IsEnabled(): @@ -7420,7 +7420,7 @@ class CustomTreeCtrl(wx.ScrolledWindow): # Break loop if we moved up a page size and have a new target. if amount > pageSize and targetItem != currentItem: break - prevItem = self.GetPrevShown(prevItem) + prevItem = self.GetPrevShown(prevItem) # If we found a valid target, select it. if targetItem != currentItem: self.DoSelectItem(targetItem, unselect_others=True, @@ -7460,7 +7460,7 @@ class CustomTreeCtrl(wx.ScrolledWindow): else: if visCount > 1 and targetItem != currentItem: # Move to last visible item in page. - break + break visCount = 0 # Move down to next item, set as target if it is enabled. if nextItem.IsEnabled(): @@ -7508,13 +7508,13 @@ class CustomTreeCtrl(wx.ScrolledWindow): else: event.Skip() - + def GetPrevShown(self, item): """ Returns the previous displayed item in the tree. This is either the last displayed child of its previous sibling, or its parent item. - + :param `item`: an instance of :class:`GenericTreeItem`; :return: An instance of :class:`GenericTreeItem` or ``None`` if no previous item found (root). @@ -7534,7 +7534,7 @@ class CustomTreeCtrl(wx.ScrolledWindow): if prev == self.GetRootItem() and self.HasAGWFlag(TR_HIDE_ROOT): return None return prev - + def GetNextShown(self, item): """ @@ -7565,7 +7565,7 @@ class CustomTreeCtrl(wx.ScrolledWindow): # Return the next item. return next - + def GetNextActiveItem(self, item, down=True): """ Returns the next active item. Used Internally at present. @@ -8349,7 +8349,7 @@ class CustomTreeCtrl(wx.ScrolledWindow): wndx, wndy = wnd.GetPosition() if wndy != ya: wnd.Move(wndx, ya, flags=wx.SIZE_ALLOW_MINUS_ONE) - + y += height if not item.IsExpanded(): diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index ed376fbd..1adc6912 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -2894,10 +2894,7 @@ class TreeListMainWindow(CustomTreeCtrl): colText = wx.Colour(*dc.GetTextForeground()) if item.IsSelected(): - if (wx.Platform == "__WXMAC__" and self._hasFocus): - colTextHilight = wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHTTEXT) - else: - colTextHilight = wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHTTEXT) + colTextHilight = wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHTTEXT) else: attr = item.GetAttributes() @@ -3112,7 +3109,7 @@ class TreeListMainWindow(CustomTreeCtrl): else: if not item.IsSelected(): - + if self.HasAGWFlag(TR_FILL_WHOLE_COLUMN_BACKGROUND): itemrect = wx.Rect(text_x-2, item.GetY() + off_h, col_w-2*_MARGIN, total_h - off_h) else: @@ -3179,7 +3176,10 @@ class TreeListMainWindow(CustomTreeCtrl): _paintText(text, textrect, alignment) dc.SetTextForeground(foreground) else: - if wx.Platform == "__WXMAC__" and item.IsSelected() and self._hasFocus: + if ( wx.Platform == "__WXMAC__" and item.IsSelected() and + self._hasFocus and i == self.GetMainColumn()) : + # Use white on Macs, but only on the primary column if + # TR_FULL_ROW_HIGHLIGHT is NOT turned on. dc.SetTextForeground(wx.WHITE) _paintText(text, textrect, alignment)