Move wxGenericHyperlinkCtrl GetLinkColour() to a private header

No changes yet, but this will allow reusing the same function from
wxHTML in the upcoming commit.
This commit is contained in:
Vadim Zeitlin 2023-06-01 15:54:15 +01:00
parent 08d4577495
commit 94e80dc21a
2 changed files with 35 additions and 18 deletions

View file

@ -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 <vadim@wxwidgets.org>
// 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_

View file

@ -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;
}