Merge branch 'mac-tweaks'

This commit is contained in:
Robin Dunn
2019-10-17 14:09:05 -07:00
5 changed files with 28 additions and 21 deletions

View File

@@ -147,6 +147,9 @@ class SysColorPanel(SysPanelBase):
nextx += self._maxw + 8
dc.DrawRectangle(nextx, nexty, self._box[0], self._box[1])
nextx += self._box[0] + 12
dc.DrawText('{}'.format(syscolor.Get()), nextx, nexty)
nextx = 10
nexty += 20

View File

@@ -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():

View File

@@ -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)

View File

@@ -172,7 +172,11 @@ class GenButton(wx.Control):
self.SetLabel(label)
self.InheritAttributes()
self.SetInitialSize(size)
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))
face = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)
if 'wxMac' in wx.PlatformInfo and face.alpha == 0:
face = wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DLIGHT)
assert face.alpha != 0, "a different default system colour is needed!"
self.SetBackgroundColour(face)
self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)

View File

@@ -149,8 +149,8 @@ class CustomColourData(object):
class ColourSelect(wx.lib.buttons.GenBitmapButton):
"""
A subclass of :class:`wx.BitmapButton` that, when clicked, will
display a colour selection dialog.
A subclass of :class:`wx.lib.buttons.GenBitmapButton` that,
when clicked, will display a colour selection dialog.
"""
def __init__(self, parent, id=wx.ID_ANY, label="", colour=wx.BLACK,