fix invisible wxTextCtrl selection when custom foreground/background color is used with GTK3
closes #16176 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76307 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
0eca2b6a9a
commit
79b8852011
@ -4310,13 +4310,37 @@ void wxWindowGTK::GTKApplyStyle(GtkWidget* widget, GtkRcStyle* WXUNUSED_IN_GTK3(
|
||||
if (m_font.IsOk())
|
||||
pfd = m_font.GetNativeFontInfo()->description;
|
||||
gtk_widget_override_font(widget, pfd);
|
||||
gtk_widget_override_color(widget, GTK_STATE_FLAG_NORMAL, m_foregroundColour);
|
||||
gtk_widget_override_background_color(widget, GTK_STATE_FLAG_NORMAL, m_backgroundColour);
|
||||
|
||||
const GdkRGBA* fg = m_foregroundColour;
|
||||
const GdkRGBA* bg = m_backgroundColour;
|
||||
GtkStyleContext* context = gtk_widget_get_style_context(widget);
|
||||
// Preserve selection colors for GtkEntry, otherwise the
|
||||
// GTK_STATE_FLAG_NORMAL override will be used, and the selection is invisible
|
||||
if (GTK_IS_ENTRY(widget))
|
||||
{
|
||||
const GtkStateFlags selectedFocused =
|
||||
GtkStateFlags(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED);
|
||||
// remove any previous override
|
||||
gtk_widget_override_color(widget, selectedFocused, NULL);
|
||||
gtk_widget_override_background_color(widget, selectedFocused, NULL);
|
||||
GdkRGBA c;
|
||||
if (fg)
|
||||
{
|
||||
gtk_style_context_get_color(context, selectedFocused, &c);
|
||||
gtk_widget_override_color(widget, selectedFocused, &c);
|
||||
}
|
||||
if (bg)
|
||||
{
|
||||
gtk_style_context_get_background_color(context, selectedFocused, &c);
|
||||
gtk_widget_override_background_color(widget, selectedFocused, &c);
|
||||
}
|
||||
}
|
||||
gtk_widget_override_color(widget, GTK_STATE_FLAG_NORMAL, fg);
|
||||
gtk_widget_override_background_color(widget, GTK_STATE_FLAG_NORMAL, bg);
|
||||
|
||||
// setting background color has no effect with some themes when the widget style
|
||||
// has a "background-image" property, so we need to override that as well
|
||||
|
||||
GtkStyleContext* context = gtk_widget_get_style_context(widget);
|
||||
if (m_styleProvider)
|
||||
gtk_style_context_remove_provider(context, m_styleProvider);
|
||||
cairo_pattern_t* pattern = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user