Fix default colours used by wxHtmlWindow in dark mode

Don't hardcode white background in wxHtmlWindow, but use
wxSYS_COLOUR_WINDOW, as was already done in wxHtmlWinParser in case when
wxHtmlWindow was not used at all.

Also use wxSYS_COLOUR_WINDOWTEXT for the default foreground and
light/dark-mode dependent link colour instead of hardcoded blue. As a
side effect, this uses a more appropriate colour for the links in the
light mode as well.

Add a link to the lists test page in the HTML test sample to allow
testing the links appearance easily (links present in the other pages of
this sample use fixed colours specified in HTML itself).
This commit is contained in:
Vadim Zeitlin 2023-06-01 15:55:19 +01:00
parent 94e80dc21a
commit be4ec7b93d
3 changed files with 6 additions and 6 deletions

View file

@ -19,7 +19,7 @@
<ul><li>List in a table, this cell should not wrap</li></ul>
</td>
<td>
Second column, unimportant
Click <a href="test.htm">here</a> to go to the initial page.
</td>
<tr>
</table>

View file

@ -493,7 +493,7 @@ bool wxHtmlWindow::DoSetPage(const wxString& source)
// ...and run the parser on it:
wxClientDC dc(this);
dc.SetMapMode(wxMM_TEXT);
SetBackgroundColour(wxColour(0xFF, 0xFF, 0xFF));
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
SetBackgroundImage(wxNullBitmap);
double pixelScale = 1.0;

View file

@ -25,6 +25,7 @@
#include "wx/fontmap.h"
#include "wx/uri.h"
#include "wx/private/hyperlink.h"
//-----------------------------------------------------------------------------
// wxHtmlWinParser
@ -192,12 +193,11 @@ void wxHtmlWinParser::InitParser(const wxString& source)
m_UseLink = false;
m_Link = wxHtmlLinkInfo( wxEmptyString );
m_LinkColor.Set(0, 0, 0xFF);
m_ActualColor.Set(0, 0, 0);
const wxColour windowColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW) ;
m_LinkColor = wxPrivate::GetLinkColour();
m_ActualColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
m_ActualBackgroundColor = m_windowInterface
? m_windowInterface->GetHTMLBackgroundColour()
: windowColour;
: wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
m_ActualBackgroundMode = wxBRUSHSTYLE_TRANSPARENT;
m_Align = wxHTML_ALIGN_LEFT;
m_ScriptMode = wxHTML_SCRIPT_NORMAL;