diff --git a/include/wx/private/hyperlink.h b/include/wx/private/hyperlink.h new file mode 100644 index 0000000000..5060f68a37 --- /dev/null +++ b/include/wx/private/hyperlink.h @@ -0,0 +1,31 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/private/link.h +// Purpose: Private functions related to hyperlinks. +// Author: Vadim Zeitlin +// Created: 2023-06-01 +// Copyright: (c) 2023 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_PRIVATE_HYPERLINK_H_ +#define _WX_PRIVATE_HYPERLINK_H_ + +#include "wx/settings.h" + +namespace wxPrivate +{ + +inline 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 + // 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)); +} + +} // namespace wxPrivate + +#endif // _WX_PRIVATE_HYPERLINK_H_ diff --git a/src/generic/hyperlinkg.cpp b/src/generic/hyperlinkg.cpp index f583b108e7..61826097e4 100644 --- a/src/generic/hyperlinkg.cpp +++ b/src/generic/hyperlinkg.cpp @@ -40,6 +40,8 @@ #include "wx/clipbrd.h" #include "wx/renderer.h" +#include "wx/private/hyperlink.h" + // ============================================================================ // implementation // ============================================================================ @@ -101,22 +103,6 @@ bool wxGenericHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id, return true; } -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 - // 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 - void wxGenericHyperlinkCtrl::Init() { m_rollover = false; @@ -124,7 +110,7 @@ void wxGenericHyperlinkCtrl::Init() m_visited = false; // colours - m_normalColour = GetLinkColour(); + m_normalColour = wxPrivate::GetLinkColour(); m_hoverColour = *wxRED; m_visitedColour = wxColour("#551a8b"); } @@ -153,7 +139,7 @@ wxVisualAttributes wxGenericHyperlinkCtrl::GetClassDefaultAttributes(wxWindowVariant variant) { auto attrs = wxHyperlinkCtrlBase::GetClassDefaultAttributes(variant); - attrs.colFg = GetLinkColour(); + attrs.colFg = wxPrivate::GetLinkColour(); return attrs; }