From eadee0572921008e4ada0434bb9dad560c7299f7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 29 Nov 2019 04:31:14 +0100 Subject: [PATCH] Don't change CSS for wxCheckNox with wxNO_BORDER in wxGTK 3 This makes the checkbox look ugly as it's clearly not supposed to be rendered without the border at all, so it's better to do nothing than mangle its CSS. It could be better to add some virtual GTKTurnOffBorder() method that could be overridden to do nothing in wxCheckBox and we should consider doing this if there are other classes for which wxNO_BORDER breaks their appearance, but for now, as long as it's the only case in which we need to do this, just turn wxNO_BORDER off when calling PostCreation(). --- src/gtk/checkbox.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/gtk/checkbox.cpp b/src/gtk/checkbox.cpp index d33908be4d..0579417ebc 100644 --- a/src/gtk/checkbox.cpp +++ b/src/gtk/checkbox.cpp @@ -156,8 +156,22 @@ bool wxCheckBox::Create(wxWindow *parent, m_parent->DoAddChild( this ); +#ifdef __WXGTK3__ + // CSS added if the window has wxNO_BORDER inside base class PostCreation() + // makes checkbox look broken in the default GTK 3 theme, so avoid doing + // this by temporarily turning this flag off. + if ( style & wxNO_BORDER ) + ToggleWindowStyle(wxNO_BORDER); +#endif + PostCreation(size); +#ifdef __WXGTK3__ + // Turn it back on if necessary. + if ( style & wxNO_BORDER ) + ToggleWindowStyle(wxNO_BORDER); +#endif + return true; }