Add wxSystemAppearance::AreAppsDark() and IsSystemDark()
This allows to determine if dark mode is enabled (for the applications and/or the system UI itself, respectively) system-wide which is useful now that IsDark() returns false unless MSWEnableDarkMode() is called. Also document the incompatible change to IsDark().
This commit is contained in:
parent
ca5cd2f18d
commit
7ce2ba9b0c
6 changed files with 116 additions and 13 deletions
|
|
@ -1676,21 +1676,31 @@ void MyCanvas::DrawSystemColours(wxDC& dc)
|
|||
wxCoord x(FromDIP(10));
|
||||
wxRect r(textSize.GetWidth() + x, x, dc.FromDIP(100), lineHeight);
|
||||
|
||||
wxString title = "System colours";
|
||||
dc.DrawText("System colours", x, r.y);
|
||||
r.y += 2*lineHeight;
|
||||
|
||||
const wxSystemAppearance appearance = wxSystemSettings::GetAppearance();
|
||||
const wxString appearanceName = appearance.GetName();
|
||||
if ( !appearanceName.empty() )
|
||||
title += wxString::Format(" for \"%s\"", appearanceName);
|
||||
if ( appearance.IsDark() )
|
||||
title += " (using dark system theme)";
|
||||
dc.DrawText(title, x, r.y);
|
||||
r.y += 2*lineHeight;
|
||||
dc.DrawText(wxString::Format("Window background is %s",
|
||||
appearance.IsUsingDarkBackground() ? "dark"
|
||||
: "light"),
|
||||
x, r.y);
|
||||
r.y += 3*lineHeight;
|
||||
{
|
||||
dc.DrawText(wxString::Format("System appearance: %s", appearanceName),
|
||||
x, r.y);
|
||||
r.y += lineHeight;
|
||||
}
|
||||
|
||||
auto const showDarkOrLight = [&](const char* what, bool dark)
|
||||
{
|
||||
dc.DrawText(wxString::Format("%s: %s", what, dark ? "dark" : "light"),
|
||||
x, r.y);
|
||||
r.y += 1.5*lineHeight;
|
||||
};
|
||||
|
||||
showDarkOrLight("System", appearance.IsSystemDark());
|
||||
showDarkOrLight("App default", appearance.AreAppsDark());
|
||||
showDarkOrLight("Current app", appearance.IsDark());
|
||||
showDarkOrLight("Background", appearance.IsUsingDarkBackground());
|
||||
|
||||
r.y += lineHeight;
|
||||
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue