diff --git a/src/generic/hyperlinkg.cpp b/src/generic/hyperlinkg.cpp index 191be40579..f583b108e7 100644 --- a/src/generic/hyperlinkg.cpp +++ b/src/generic/hyperlinkg.cpp @@ -34,6 +34,7 @@ #include "wx/menu.h" #include "wx/log.h" #include "wx/dataobj.h" + #include "wx/settings.h" #endif #include "wx/clipbrd.h" @@ -105,8 +106,13 @@ namespace wxColour GetLinkColour() { + // There is a standard link colour appropriate for the default "light" mode, // see https://html.spec.whatwg.org/multipage/rendering.html#phrasing-content-3 - return wxColour(0x00, 0x00, 0xee); + // it doesn't stand out enough in dark mode, so choose "light sky blue" + // colour for the links in dark mode instead (this is a rather arbitrary + // choice, but there doesn't seem to be any standard one). + return wxSystemSettings::SelectLightDark(wxColour(0x00, 0x00, 0xee), + wxColour(0x87, 0xce, 0xfa)); } } // anonymous namespace diff --git a/src/msw/hyperlink.cpp b/src/msw/hyperlink.cpp index 47de3ff9f6..4649b1c97e 100644 --- a/src/msw/hyperlink.cpp +++ b/src/msw/hyperlink.cpp @@ -108,6 +108,14 @@ bool wxHyperlinkCtrl::Create(wxWindow *parent, return false; } + if ( wxSystemSettings::GetAppearance().IsDark() ) + { + // Override the colour used by default by the native control with the + // colour appropriate for the dark mode, as the default one doesn't + // have enough contrast in it. + SetNormalColour(GetClassDefaultAttributes().colFg); + } + ConnectMenuHandlers(); return true; @@ -243,7 +251,7 @@ wxHyperlinkCtrl::GetClassDefaultAttributes(wxWindowVariant variant) { auto attrs = wxGenericHyperlinkCtrl::GetClassDefaultAttributes(variant); - if ( HasNativeHyperlinkCtrl() ) + if ( HasNativeHyperlinkCtrl() && !wxSystemSettings::GetAppearance().IsDark() ) attrs.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_HOTLIGHT); return attrs;