Merge pull request #2018 from pauldmccarthy/mnt/wx-lib-agw-aui-mac-theme

MNT: Remove legacy macOS logic, and use wx.SystemSettings to select default colours
This commit is contained in:
Scott Talbert
2023-07-19 12:22:02 -04:00
committed by GitHub
3 changed files with 5 additions and 51 deletions

View File

@@ -26,15 +26,6 @@ import wx
from .aui_constants import *
if wx.Platform == "__WXMAC__":
try:
import Carbon.Appearance
except ImportError:
CARBON = False
else:
CARBON = True
def BlendColour(fg, bg, alpha):
"""
Blends the two colour component `fg` and `bg` into one colour component, adding
@@ -183,18 +174,7 @@ def GetBaseColour():
mimicking as closely as possible the platform UI colours.
"""
if wx.Platform == "__WXMAC__":
k = Carbon.Appearance.kThemeBrushToolbarBackground if CARBON else 52
if hasattr(wx, 'MacThemeColour'):
base_colour = wx.MacThemeColour(k)
else:
brush = wx.Brush(wx.BLACK)
brush.MacSetTheme(k)
base_colour = brush.GetColour()
else:
base_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE)
base_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE)
# the base_colour is too pale to use as our base colour,
# so darken it a bit
@@ -666,7 +646,3 @@ def CopyAttributes(newArt, oldArt):
setattr(newArt, attr, getattr(oldArt, attr))
return newArt

View File

@@ -208,7 +208,7 @@ class AuiDefaultDockArt(object):
self._active_caption_gradient_colour = LightContrastColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT))
self._active_caption_text_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHTTEXT)
self._inactive_caption_text_colour = wx.BLACK
self._inactive_caption_text_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT)
def SetDefaultColours(self, base_colour=None):

View File

@@ -30,13 +30,6 @@ __date__ = "31 March 2009"
import wx
if wx.Platform == '__WXMAC__':
try:
import Carbon.Appearance
except ImportError:
CARBON = False
else:
CARBON = True
from .aui_utilities import BitmapFromBits, StepColour, IndentPressedBitmap, ChopText
from .aui_utilities import GetBaseColour, DrawMACCloseButton, LightColour, TakeScreenShot
@@ -158,22 +151,9 @@ class AuiDefaultTabArt(object):
self._active_windowlist_bmp = BitmapFromBits(nb_list_bits, 16, 16, active_colour)
self._disabled_windowlist_bmp = BitmapFromBits(nb_list_bits, 16, 16, disabled_colour)
if wx.Platform == "__WXMAC__":
k = Carbon.Appearance.kThemeBrushFocusHighlight if CARBON else 19
# Get proper highlight colour for focus rectangle from the
# current Mac theme. kThemeBrushFocusHighlight is
# available on Mac OS 8.5 and higher
if hasattr(wx, 'MacThemeColour'):
c = wx.MacThemeColour(k)
else:
brush = wx.Brush(active_colour)
brush.MacSetTheme(k)
c = brush.GetColour()
self._focusPen = wx.Pen(c, 2, wx.PENSTYLE_SOLID)
else:
self._focusPen = wx.Pen(active_colour, 1, wx.PENSTYLE_USER_DASH)
self._focusPen.SetDashes([1, 1])
self._focusPen.SetCap(wx.CAP_BUTT)
self._focusPen = wx.Pen(active_colour, 1, wx.PENSTYLE_USER_DASH)
self._focusPen.SetDashes([1, 1])
self._focusPen.SetCap(wx.CAP_BUTT)
def SetBaseColour(self, base_colour):
@@ -2767,5 +2747,3 @@ class ChromeTabArt(AuiDefaultTabArt):
dc.DestroyClippingRegion()
return out_tab_rect, out_button_rect, x_extent