From 4be5fde7213acb46d20919fa9c0cb50eae479bfd Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Tue, 13 Feb 2024 21:49:53 +0100 Subject: [PATCH 1/3] Don't handle unset background colour as black in wxQt Unset background colour actually means to use the default one, which is still not the case for wxQt if the background had been previously changed, but at the very least it doesn't change it to black any longer. This commit is best viewed ignoring whitespace-only changes. --- src/qt/window.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/qt/window.cpp b/src/qt/window.cpp index 2a7d64c6d4..eed343f218 100644 --- a/src/qt/window.cpp +++ b/src/qt/window.cpp @@ -1294,8 +1294,11 @@ bool wxWindowQt::SetBackgroundColour(const wxColour& colour) if ( !wxWindowBase::SetBackgroundColour(colour) ) return false; - QWidget *widget = QtGetParentWidget(); - wxQtChangeRoleColour(widget->backgroundRole(), widget, colour); + if ( colour.IsOk() ) + { + QWidget *widget = QtGetParentWidget(); + wxQtChangeRoleColour(widget->backgroundRole(), widget, colour); + } return true; } From 253cfa3a315035c89518d13c02725c88d07d7139 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Tue, 13 Feb 2024 21:52:48 +0100 Subject: [PATCH 2/3] Use white background brush by default in wxQt too Just as this is done in the other ports. This commit is best viewed with Git --color-moved option. --- src/qt/dc.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/qt/dc.cpp b/src/qt/dc.cpp index 32e938d707..c1483c696e 100644 --- a/src/qt/dc.cpp +++ b/src/qt/dc.cpp @@ -222,14 +222,16 @@ void wxQtDCImpl::SetBackground(const wxBrush& brush) { m_backgroundBrush = brush; + // For consistency with the other ports: clearing the dc with + // invalid brush (Qt::NoBrush) should use white colour (which + // happens to be the default colour in Qt too) instead of no + // colour at all. + if (!m_backgroundBrush.IsOk()) + m_backgroundBrush = *wxWHITE_BRUSH; + if (m_qtPainter->isActive()) { - // For consistency with the other ports: clearing the dc with - // invalid brush (Qt::NoBrush) should use white colour (which - // happens to be the default colour in Qt too) instead of no - // colour at all. - m_qtPainter->setBackground( - brush.IsOk() ? brush.GetHandle() : Qt::white); + m_qtPainter->setBackground(m_backgroundBrush.GetHandle()); } } From 9b97d3a308d2e918f7eb4016bb5555e59f5e6bdf Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Tue, 13 Feb 2024 21:55:35 +0100 Subject: [PATCH 3/3] Fix generic wxSearchCtrl background colour in wxQt Set the background colour of the whole control to the text control background colour. --- src/generic/srchctlg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generic/srchctlg.cpp b/src/generic/srchctlg.cpp index 6b902b4485..a3b63dbfe9 100644 --- a/src/generic/srchctlg.cpp +++ b/src/generic/srchctlg.cpp @@ -306,8 +306,8 @@ bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id, wxEVT_SEARCH, m_searchBitmap); - SetBackgroundColour( m_text->GetBackgroundColour() ); m_text->SetBackgroundColour(wxColour()); + SetBackgroundColour( m_text->GetBackgroundColour() ); RecalcBitmaps();