aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti2013-02-11 15:44:51 (EST)
committerCarolyn MacLeod2013-04-09 10:53:08 (EDT)
commit4861987588312630e051c90ed6bb3ca0ef56ad18 (patch)
tree7611a8973adec117f5ae04aedb929e4a203446c0
parent32611ad6724ef140a85b4fdc67366e293dd05a71 (diff)
downloadeclipse.platform.swt-4861987588312630e051c90ed6bb3ca0ef56ad18.zip
eclipse.platform.swt-4861987588312630e051c90ed6bb3ca0ef56ad18.tar.gz
eclipse.platform.swt-4861987588312630e051c90ed6bb3ca0ef56ad18.tar.bz2
Bug 181592 - [Widgets] Need a color constant for active and inactive hyperlink colors
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java4
3 files changed, 28 insertions, 17 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index f655ac4..135d5fe 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -522,6 +522,7 @@ public class OS extends C {
public static final byte[] key_press_event = ascii("key-press-event");
public static final byte[] key_release_event = ascii("key-release-event");
public static final byte[] leave_notify_event = ascii("leave-notify-event");
+ public static final byte[] link_color = ascii("link-color");
public static final byte[] map = ascii("map");
public static final byte[] map_event = ascii("map-event");
public static final byte[] mnemonic_activate = ascii("mnemonic-activate");
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 67f1015..2f77e37 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
@@ -270,7 +270,7 @@ public class Display extends Device {
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_INFO_BACKGROUND, COLOR_INFO_FOREGROUND, COLOR_LINK_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;
@@ -2100,6 +2100,7 @@ public Color getSystemColor (int id) {
checkDevice ();
GdkColor gdkColor = null;
switch (id) {
+ case SWT.COLOR_LINK_FOREGROUND: gdkColor = COLOR_LINK_FOREGROUND; break;
case SWT.COLOR_INFO_FOREGROUND: gdkColor = COLOR_INFO_FOREGROUND; break;
case SWT.COLOR_INFO_BACKGROUND: gdkColor = COLOR_INFO_BACKGROUND; break;
case SWT.COLOR_TITLE_FOREGROUND: gdkColor = COLOR_TITLE_FOREGROUND; break;
@@ -2281,12 +2282,30 @@ GdkColor toGdkColor (GdkRGBA rgba, double m) {
}
void initializeSystemColors () {
+ long /*int*/ tooltipShellHandle = OS.gtk_window_new (OS.GTK_WINDOW_POPUP);
+ if (tooltipShellHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ byte[] gtk_tooltip = Converter.wcsToMbcs (null, OS.GTK3 ? "gtk-tooltip" : "gtk-tooltips", true); //$NON-NLS-1$
+ OS.gtk_widget_set_name (tooltipShellHandle, gtk_tooltip);
+ OS.gtk_widget_realize (tooltipShellHandle);
+
+ /* Initialize link foreground */
+ long /*int*/ linkWidget = OS.gtk_label_new (new byte[1]);
+ if (linkWidget == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_container_add (tooltipShellHandle, linkWidget);
+ long /*int*/ [] linkColor = new long /*int*/ [1];
+ OS.gtk_widget_style_get (linkWidget, OS.link_color, linkColor, 0);
+ GdkColor gdkColor = new GdkColor();
+ if (linkColor [0] != 0) {
+ OS.memmove (gdkColor, linkColor[0], GdkColor.sizeof);
+ OS.gdk_color_free (linkColor [0]);
+ } else {
+ gdkColor.blue = (short)0xeeee;
+ }
+ long /*int*/ colormap = OS.gdk_colormap_get_system();
+ OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
+ COLOR_LINK_FOREGROUND = gdkColor;
+
if (OS.GTK3) {
- long /*int*/ tooltipShellHandle = OS.gtk_window_new (OS.GTK_WINDOW_POPUP);
- if (tooltipShellHandle == 0) error (SWT.ERROR_NO_HANDLES);
- byte[] gtk_tooltip = Converter.wcsToMbcs (null, "gtk-tooltip", true); //$NON-NLS-1$
- OS.gtk_widget_set_name (tooltipShellHandle, gtk_tooltip);
- OS.gtk_widget_realize (tooltipShellHandle);
long /*int*/ context = OS.gtk_widget_get_style_context (tooltipShellHandle);
OS.gtk_style_context_add_class (context, OS.GTK_STYLE_CLASS_TOOLTIP);
GdkRGBA rgba = new GdkRGBA();
@@ -2339,14 +2358,7 @@ void initializeSystemColors () {
return;
}
- GdkColor gdkColor;
-
/* Get Tooltip resources */
- long /*int*/ tooltipShellHandle = OS.gtk_window_new (OS.GTK_WINDOW_POPUP);
- if (tooltipShellHandle == 0) error (SWT.ERROR_NO_HANDLES);
- byte[] gtk_tooltips = Converter.wcsToMbcs (null, "gtk-tooltips", true); //$NON-NLS-1$
- OS.gtk_widget_set_name (tooltipShellHandle, gtk_tooltips);
- OS.gtk_widget_realize (tooltipShellHandle);
long /*int*/ tooltipStyle = OS.gtk_widget_get_style (tooltipShellHandle);
gdkColor = new GdkColor();
OS.gtk_style_get_fg (tooltipStyle, OS.GTK_STATE_NORMAL, gdkColor);
@@ -3513,7 +3525,7 @@ void releaseDisplay () {
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;
+ COLOR_INFO_BACKGROUND = COLOR_INFO_FOREGROUND = COLOR_LINK_FOREGROUND = null;
/* Dispose the event callback */
OS.gdk_event_handler_set (0, 0, 0);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
index 916a78f..8b4d89a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
@@ -48,7 +48,6 @@ public class Link extends Control {
int [] mnemonics;
int focusIndex;
- static final RGB LINK_FOREGROUND = new RGB (0, 51, 153);
static final RGB LINK_DISABLED_FOREGROUND = new RGB (172, 168, 153);
/**
@@ -148,7 +147,7 @@ void createHandle(int index) {
gtk_widget_set_has_window (handle, true);
gtk_widget_set_can_focus (handle, true);
layout = new TextLayout (display);
- linkColor = new Color (display, LINK_FOREGROUND);
+ linkColor = display.getSystemColor(SWT.COLOR_LINK_FOREGROUND);
disabledColor = new Color (display, LINK_DISABLED_FOREGROUND);
offsets = new Point [0];
ids = new String [0];
@@ -486,7 +485,6 @@ void releaseWidget () {
super.releaseWidget ();
if (layout != null) layout.dispose ();
layout = null;
- if (linkColor != null) linkColor.dispose ();
linkColor = null;
if (disabledColor != null) disabledColor.dispose ();
disabledColor = null;