Merge branch 'darkmode-custom-colour' of github.com:stevecor/wxWidgets

Preserve custom colours upon dark mode switch.

Also remove wxStaticText::MSWSetDarkOrLightMode() as it appears to be
unnecessary.

See #26596.
This commit is contained in:
Vadim Zeitlin
2026-06-16 00:29:38 +02:00
3 changed files with 11 additions and 22 deletions
-2
View File
@@ -57,8 +57,6 @@ protected:
WXWPARAM wParam,
WXLPARAM lParam) override;
virtual void MSWSetDarkOrLightMode(SetMode setmode) override;
virtual wxString WXGetVisibleLabel() const override;
virtual void WXSetVisibleLabel(const wxString& str) override;
+11 -10
View File
@@ -271,8 +271,9 @@ void wxNotebook::MSWSetDarkOrLightMode(SetMode setmode)
{
wxNotebookBase::MSWSetDarkOrLightMode(setmode);
// Background must always be set.
SetBackgroundColour(GetDefaultAttributes().colBg);
// Background must always be set, unless there is a custom colour.
if ( !m_hasBgCol )
m_backgroundColour = GetDefaultAttributes().colBg;
}
int wxNotebook::MSWGetToolTipMessage() const
@@ -1344,14 +1345,6 @@ void wxNotebook::MSWNotebookPaint()
void wxNotebook::OnPaint(wxPaintEvent& event)
{
// We can rely on the default implementation if we don't have a custom
// background colour (note that it is always set when using dark mode).
if ( !m_hasBgCol )
{
event.Skip();
return;
}
if ( wxMSWDarkMode::IsActive() )
{
// We can't use default painting in dark mode, it just doesn't work
@@ -1360,6 +1353,14 @@ void wxNotebook::OnPaint(wxPaintEvent& event)
return;
}
// We can rely on the default implementation if we don't have a custom
// background colour.
if ( !m_hasBgCol )
{
event.Skip();
return;
}
wxPaintDC dc(this);
RECT rc;
-10
View File
@@ -214,16 +214,6 @@ wxStaticText::MSWHandleMessage(WXLRESULT *result,
return false;
}
void wxStaticText::MSWSetDarkOrLightMode(SetMode setmode)
{
wxStaticTextBase::MSWSetDarkOrLightMode(setmode);
// When switching to light mode, the text color remains the same. We must
// explicitly update the color.
if ( setmode == SetMode::Change )
SetForegroundColour(GetDefaultAttributes().colFg);
}
void wxStaticText::SetLabel(const wxString& label)
{
// If the label doesn't really change, avoid flicker by not doing anything.