From b10c6ab3a83c9dc7a45d4a322c7b206df418fa65 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Mon, 14 Jan 2019 17:45:25 -0800 Subject: [PATCH] Fix background color from wxControl::GetDefaultAttributes() with GTK+3 The default background is not explicitly set on each widget, but is determined by a parent, usually the TLW. Fixes wxDC default background color for controls. See #18325 --- src/gtk/control.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gtk/control.cpp b/src/gtk/control.cpp index 772e2f8c8a..85e1e37af7 100644 --- a/src/gtk/control.cpp +++ b/src/gtk/control.cpp @@ -267,6 +267,18 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget, attr.font = wxFont(info); gdk_rgba_free(fc); gdk_rgba_free(bc); + + // Go up the parent chain for a background color + while (attr.colBg.Alpha() == 0 && (widget = gtk_widget_get_parent(widget))) + { + sc = gtk_widget_get_style_context(widget); + gtk_style_context_save(sc); + gtk_style_context_set_state(sc, stateFlag); + gtk_style_context_get(sc, stateFlag, "background-color", &bc, NULL); + gtk_style_context_restore(sc); + attr.colBg = wxColour(*bc); + gdk_rgba_free(bc); + } #else GtkStyle* style;