summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/gtk
diff options
context:
space:
mode:
authorMarkus Keller <markus_keller@ch.ibm.com>2012-10-18 14:59:35 +0200
committerMarkus Keller <markus_keller@ch.ibm.com>2012-10-18 14:59:35 +0200
commitde2297113fcb0174b02c429f9d73e7ee7a1eccda (patch)
tree55182b48a03843465fbfb35e93d45769c7cd7475 /bundles/org.eclipse.swt/Eclipse SWT/gtk
parent5673881707cbfd963bc0ed943607494119f5edb9 (diff)
downloadeclipse.platform.swt-de2297113fcb0174b02c429f9d73e7ee7a1eccda.tar.gz
eclipse.platform.swt-de2297113fcb0174b02c429f9d73e7ee7a1eccda.tar.xz
eclipse.platform.swt-de2297113fcb0174b02c429f9d73e7ee7a1eccda.zip
Bug 361373: StyledCellLabelProvider on Ubuntu: Wrong text color for selected, unfocused table and tree items
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java8
4 files changed, 38 insertions, 12 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index 68e93c77c0..3a6bd74ca2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -268,6 +268,7 @@ public class Display extends Device {
GdkColor COLOR_WIDGET_DARK_SHADOW, COLOR_WIDGET_NORMAL_SHADOW, COLOR_WIDGET_LIGHT_SHADOW;
GdkColor COLOR_WIDGET_HIGHLIGHT_SHADOW, COLOR_WIDGET_BACKGROUND, COLOR_WIDGET_FOREGROUND, COLOR_WIDGET_BORDER;
GdkColor COLOR_LIST_FOREGROUND, COLOR_LIST_BACKGROUND, COLOR_LIST_SELECTION, COLOR_LIST_SELECTION_TEXT;
+ GdkColor COLOR_LIST_SELECTION_INACTIVE, COLOR_LIST_SELECTION_TEXT_INACTIVE;
GdkColor COLOR_INFO_BACKGROUND, COLOR_INFO_FOREGROUND;
GdkColor COLOR_TITLE_FOREGROUND, COLOR_TITLE_BACKGROUND, COLOR_TITLE_BACKGROUND_GRADIENT;
GdkColor COLOR_TITLE_INACTIVE_FOREGROUND, COLOR_TITLE_INACTIVE_BACKGROUND, COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT;
@@ -2244,6 +2245,12 @@ void initializeSystemColors () {
OS.gtk_style_get_base (style, OS.GTK_STATE_SELECTED, gdkColor);
COLOR_LIST_SELECTION = gdkColor;
gdkColor = new GdkColor();
+ OS.gtk_style_get_text (style, OS.GTK_STATE_ACTIVE, gdkColor);
+ COLOR_LIST_SELECTION_TEXT_INACTIVE = gdkColor;
+ gdkColor = new GdkColor();
+ OS.gtk_style_get_base (style, OS.GTK_STATE_ACTIVE, gdkColor);
+ COLOR_LIST_SELECTION_INACTIVE = gdkColor;
+ gdkColor = new GdkColor();
OS.gtk_style_get_bg (style, OS.GTK_STATE_SELECTED, gdkColor);
COLOR_TITLE_BACKGROUND = gdkColor;
gdkColor = new GdkColor();
@@ -3378,6 +3385,7 @@ void releaseDisplay () {
COLOR_WIDGET_DARK_SHADOW = COLOR_WIDGET_NORMAL_SHADOW = COLOR_WIDGET_LIGHT_SHADOW =
COLOR_WIDGET_HIGHLIGHT_SHADOW = COLOR_WIDGET_BACKGROUND = COLOR_WIDGET_BORDER =
COLOR_LIST_FOREGROUND = COLOR_LIST_BACKGROUND = COLOR_LIST_SELECTION = COLOR_LIST_SELECTION_TEXT =
+ COLOR_LIST_SELECTION_INACTIVE = COLOR_LIST_SELECTION_TEXT_INACTIVE =
COLOR_WIDGET_FOREGROUND = COLOR_TITLE_FOREGROUND = COLOR_TITLE_BACKGROUND = COLOR_TITLE_BACKGROUND_GRADIENT =
COLOR_TITLE_INACTIVE_FOREGROUND = COLOR_TITLE_INACTIVE_BACKGROUND = COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT =
COLOR_INFO_BACKGROUND = COLOR_INFO_FOREGROUND = null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
index 0a8886e064..577bc27e46 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
@@ -2678,8 +2678,21 @@ long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window, long /*
contentWidth [0] += imageWidth;
GC gc = new GC (this);
if ((drawState & SWT.SELECTED) != 0) {
- gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION));
- gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT));
+ Color background, foreground;
+ if (gtk_widget_has_focus (handle)) {
+ background = display.getSystemColor (SWT.COLOR_LIST_SELECTION);
+ foreground = display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT);
+ } else {
+ /*
+ * Feature in GTK. When the widget doesn't have focus, then
+ * gtk_paint_flat_box () changes the background color state_type
+ * to GTK_STATE_ACTIVE. The fix is to use the same values in the GC.
+ */
+ background = Color.gtk_new (display, display.COLOR_LIST_SELECTION_INACTIVE);
+ foreground = Color.gtk_new (display, display.COLOR_LIST_SELECTION_TEXT_INACTIVE);
+ }
+ gc.setBackground (background);
+ gc.setForeground (foreground);
} else {
gc.setBackground (item.getBackground (columnIndex));
Color foreground = drawForeground != null ? Color.gtk_new (display, drawForeground) : item.getForeground (columnIndex);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
index 7f3ab5d1ad..34ebec35c2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
@@ -2679,8 +2679,21 @@ long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window, long /*
contentWidth [0] += imageWidth;
GC gc = new GC (this);
if ((drawState & SWT.SELECTED) != 0) {
- gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION));
- gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT));
+ Color background, foreground;
+ if (gtk_widget_has_focus (handle)) {
+ background = display.getSystemColor (SWT.COLOR_LIST_SELECTION);
+ foreground = display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT);
+ } else {
+ /*
+ * Feature in GTK. When the widget doesn't have focus, then
+ * gtk_paint_flat_box () changes the background color state_type
+ * to GTK_STATE_ACTIVE. The fix is to use the same values in the GC.
+ */
+ background = Color.gtk_new (display, display.COLOR_LIST_SELECTION_INACTIVE);
+ foreground = Color.gtk_new (display, display.COLOR_LIST_SELECTION_TEXT_INACTIVE);
+ }
+ gc.setBackground (background);
+ gc.setForeground (foreground);
} else {
gc.setBackground (item.getBackground (columnIndex));
Color foreground = drawForeground != null ? Color.gtk_new (display, drawForeground) : item.getForeground (columnIndex);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
index 5cbb6dc3af..510e85de66 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
@@ -1558,20 +1558,15 @@ public void setData (String key, Object value) {
void setForegroundColor (long /*int*/ handle, GdkColor color) {
long /*int*/ style = OS.gtk_widget_get_modifier_style (handle);
OS.gtk_rc_style_set_fg (style, OS.GTK_STATE_NORMAL, color);
- OS.gtk_rc_style_set_fg (style, OS.GTK_STATE_ACTIVE, color);
OS.gtk_rc_style_set_fg (style, OS.GTK_STATE_PRELIGHT, color);
int flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_NORMAL);
flags = (color == null) ? flags & ~OS.GTK_RC_FG: flags | OS.GTK_RC_FG;
OS.gtk_rc_style_set_color_flags (style, OS.GTK_STATE_NORMAL, flags);
- flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_ACTIVE);
- flags = (color == null) ? flags & ~OS.GTK_RC_FG: flags | OS.GTK_RC_FG;
- OS.gtk_rc_style_set_color_flags (style, OS.GTK_STATE_ACTIVE, flags);
flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_PRELIGHT);
flags = (color == null) ? flags & ~OS.GTK_RC_FG: flags | OS.GTK_RC_FG;
OS.gtk_rc_style_set_color_flags (style, OS.GTK_STATE_PRELIGHT, flags);
OS.gtk_rc_style_set_text (style, OS.GTK_STATE_NORMAL, color);
- OS.gtk_rc_style_set_text (style, OS.GTK_STATE_ACTIVE, color);
OS.gtk_rc_style_set_text (style, OS.GTK_STATE_PRELIGHT, color);
flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_NORMAL);
flags = (color == null) ? flags & ~OS.GTK_RC_TEXT: flags | OS.GTK_RC_TEXT;
@@ -1579,9 +1574,6 @@ void setForegroundColor (long /*int*/ handle, GdkColor color) {
flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_PRELIGHT);
flags = (color == null) ? flags & ~OS.GTK_RC_TEXT: flags | OS.GTK_RC_TEXT;
OS.gtk_rc_style_set_color_flags (style, OS.GTK_STATE_PRELIGHT, flags);
- flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_ACTIVE);
- flags = (color == null) ? flags & ~OS.GTK_RC_TEXT: flags | OS.GTK_RC_TEXT;
- OS.gtk_rc_style_set_color_flags (style, OS.GTK_STATE_ACTIVE, flags);
modifyStyle (handle, style);
}