Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2019-06-19 11:51:09 -0400
committerEric Williams2019-06-20 09:55:17 -0400
commit4372e40e70e76e203ae9428df184a2e378c9ce90 (patch)
treeacd7201133bb1ff04a0f2031f533c5a5012f42a7
parent2d8c4271d38bd3d3777f952bb1cd8cf99b3d9853 (diff)
downloadeclipse.platform.swt-4372e40e70e76e203ae9428df184a2e378c9ce90.tar.gz
eclipse.platform.swt-4372e40e70e76e203ae9428df184a2e378c9ce90.tar.xz
eclipse.platform.swt-4372e40e70e76e203ae9428df184a2e378c9ce90.zip
Bug 548191: [GTK] Add color constant for disabled background and
foreground colors Define COLOR_WIDGET_DISABLED_FOREGROUND and COLOR_TEXT_DISABLED_BACKGROUND on GTK. Added an entry to ControlExample's ColorTab. Tested on GTK3.24 and Fedora 30. Change-Id: Id2c3686225c0aa557f4e243b2634b6e3785d4fce Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java18
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ColorTab.java2
2 files changed, 19 insertions, 1 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 3d878a5a5d..92248562e9 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
@@ -321,6 +321,7 @@ public class Display extends Device {
GdkRGBA COLOR_INFO_BACKGROUND_RGBA, COLOR_INFO_FOREGROUND_RGBA, COLOR_LINK_FOREGROUND_RGBA;
GdkRGBA COLOR_TITLE_FOREGROUND_RGBA, COLOR_TITLE_BACKGROUND_RGBA, COLOR_TITLE_BACKGROUND_GRADIENT_RGBA;
GdkRGBA COLOR_TITLE_INACTIVE_FOREGROUND_RGBA, COLOR_TITLE_INACTIVE_BACKGROUND_RGBA, COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT_RGBA;
+ GdkRGBA COLOR_WIDGET_DISABLED_FOREGROUND_RGBA, COLOR_TEXT_DISABLED_BACKGROUND_RGBA;
/* Initialize color list */
ArrayList<String> colorList;
@@ -2747,6 +2748,8 @@ public Color getSystemColor (int id) {
case SWT.COLOR_LIST_BACKGROUND: gdkRGBA = copyRGBA(COLOR_LIST_BACKGROUND_RGBA); break;
case SWT.COLOR_LIST_SELECTION: gdkRGBA = copyRGBA(COLOR_LIST_SELECTION_RGBA); break;
case SWT.COLOR_LIST_SELECTION_TEXT: gdkRGBA = copyRGBA(COLOR_LIST_SELECTION_TEXT_RGBA); break;
+ case SWT.COLOR_WIDGET_DISABLED_FOREGROUND: gdkRGBA = copyRGBA(COLOR_WIDGET_DISABLED_FOREGROUND_RGBA); break;
+ case SWT.COLOR_TEXT_DISABLED_BACKGROUND: gdkRGBA = copyRGBA(COLOR_TEXT_DISABLED_BACKGROUND_RGBA); break;
default:
return super.getSystemColor (id);
}
@@ -3036,6 +3039,7 @@ void initializeSystemColors () {
initializeSystemColorsTitle(shellContext);
initializeSystemColorsLink();
initializeSystemColorsTooltip();
+ initializeSystemColorsDisabled();
COLOR_TITLE_FOREGROUND_RGBA = COLOR_LIST_SELECTION_TEXT_RGBA;
COLOR_TITLE_BACKGROUND_RGBA = COLOR_LIST_SELECTION_RGBA;
@@ -3132,6 +3136,17 @@ void initializeSystemColorsTooltip() {
OS.g_object_unref(tooltip);
}
+void initializeSystemColorsDisabled() {
+ long entry = GTK.gtk_entry_new ();
+ OS.g_object_ref_sink(entry);
+ long context = GTK.gtk_widget_get_style_context (entry);
+
+ COLOR_WIDGET_DISABLED_FOREGROUND_RGBA = styleContextGetColor (context, GTK.GTK_STATE_FLAG_INSENSITIVE);
+ COLOR_TEXT_DISABLED_BACKGROUND_RGBA = styleContextEstimateBackgroundColor (context, GTK.GTK_STATE_FLAG_INSENSITIVE);
+
+ OS.g_object_unref(entry);
+}
+
GdkRGBA styleContextGetColor(long context, int flag) {
/*
* Feature in GTK: we need to handle calls to gtk_style_context_get_color()
@@ -4540,7 +4555,8 @@ void releaseDisplay () {
COLOR_LIST_SELECTION_INACTIVE_RGBA = COLOR_LIST_SELECTION_TEXT_INACTIVE_RGBA =
COLOR_WIDGET_FOREGROUND_RGBA = COLOR_TITLE_FOREGROUND_RGBA = COLOR_TITLE_BACKGROUND_RGBA = COLOR_TITLE_BACKGROUND_GRADIENT_RGBA =
COLOR_TITLE_INACTIVE_FOREGROUND_RGBA = COLOR_TITLE_INACTIVE_BACKGROUND_RGBA = COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT_RGBA =
- COLOR_INFO_BACKGROUND_RGBA = COLOR_INFO_FOREGROUND_RGBA = COLOR_LINK_FOREGROUND_RGBA = null;
+ COLOR_INFO_BACKGROUND_RGBA = COLOR_INFO_FOREGROUND_RGBA = COLOR_LINK_FOREGROUND_RGBA = COLOR_WIDGET_DISABLED_FOREGROUND_RGBA =
+ COLOR_TEXT_DISABLED_BACKGROUND_RGBA = null;
/* Dispose the event callback */
GDK.gdk_event_handler_set (0, 0, 0);
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ColorTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ColorTab.java
index 0fa1c6ad30..1eceed3a05 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ColorTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ColorTab.java
@@ -82,6 +82,8 @@ class ColorTab extends Tab {
hmap.put(SWT.COLOR_TITLE_INACTIVE_BACKGROUND, "COLOR_TITLE_INACTIVE_BACKGROUND");
hmap.put(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT, "COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT");
hmap.put(SWT.COLOR_LINK_FOREGROUND, "COLOR_LINK_FOREGROUND");
+ hmap.put(SWT.COLOR_WIDGET_DISABLED_FOREGROUND, "COLOR_WIDGET_DISABLED_FOREGROUND");
+ hmap.put(SWT.COLOR_TEXT_DISABLED_BACKGROUND, "COLOR_TEXT_DISABLED_BACKGROUND");
}
/**

Back to the top