fix invisible multi-line wxTextCtrl selection when custom foreground/background color is used with GTK3

closes #16176


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76308 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett
2014-04-10 15:57:28 +00:00
parent 79b8852011
commit f2e5faeb0a
2 changed files with 36 additions and 27 deletions

View File

@@ -1800,6 +1800,39 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style)
void wxTextCtrl::DoApplyWidgetStyle(GtkRcStyle *style)
{
#ifdef __WXGTK3__
// Preserve selection colors, otherwise the GTK_STATE_FLAG_NORMAL override
// will be used, and the selection is invisible
const GtkStateFlags selectedFocused =
GtkStateFlags(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED);
// remove any previous override
gtk_widget_override_color(m_text, GTK_STATE_FLAG_NORMAL, NULL);
gtk_widget_override_color(m_text, selectedFocused, NULL);
gtk_widget_override_background_color(m_text, GTK_STATE_FLAG_NORMAL, NULL);
gtk_widget_override_background_color(m_text, selectedFocused, NULL);
const bool fg_ok = m_foregroundColour.IsOk();
const bool bg_ok = m_backgroundColour.IsOk();
if (fg_ok || bg_ok)
{
GdkRGBA fg_orig, bg_orig;
GtkStyleContext* context = gtk_widget_get_style_context(m_text);
if (IsMultiLine())
{
gtk_style_context_save(context);
gtk_style_context_add_class(context, GTK_STYLE_CLASS_VIEW);
}
gtk_style_context_get_color(context, selectedFocused, &fg_orig);
gtk_style_context_get_background_color(context, selectedFocused, &bg_orig);
if (IsMultiLine())
gtk_style_context_restore(context);
if (fg_ok)
gtk_widget_override_color(m_text, selectedFocused, &fg_orig);
if (bg_ok)
gtk_widget_override_background_color(m_text, selectedFocused, &bg_orig);
}
#endif // __WXGTK3__
GTKApplyStyle(m_text, style);
}