diff options
author | Silenio Quarti <silenio_quarti@ca.ibm.com> | 2013-04-03 10:57:13 -0400 |
---|---|---|
committer | Silenio Quarti <silenio_quarti@ca.ibm.com> | 2013-04-03 10:57:13 -0400 |
commit | d039075da3f3215b34e155a4c18404920facdf22 (patch) | |
tree | 3ab0be38d147d4e3242133daf998f063c28f9ada | |
parent | fb6bc4c89147f7b506bef4e864f80773bf8c749f (diff) | |
download | eclipse.platform.swt-d039075da3f3215b34e155a4c18404920facdf22.tar.gz eclipse.platform.swt-d039075da3f3215b34e155a4c18404920facdf22.tar.xz eclipse.platform.swt-d039075da3f3215b34e155a4c18404920facdf22.zip |
Bug 403474 - [GTK3] Problems setting background on latest
4 files changed, 41 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java index ec0938679c..7833301184 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java @@ -1727,6 +1727,14 @@ public void select (int index) { } } +void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) { + if (entryHandle == 0 || (style & SWT.READ_ONLY) != 0) { + super.setBackgroundColor (context, handle, rgba); + return; + } + setBackgroundColorGradient (OS.gtk_widget_get_style_context (entryHandle), handle, rgba); +} + void setBackgroundColor (GdkColor color) { super.setBackgroundColor (color); if (!OS.GTK3) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java index 658385aeb7..6cdacc9135 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java @@ -45,7 +45,7 @@ import org.eclipse.swt.internal.gtk.*; */ public abstract class Control extends Widget implements Drawable { long /*int*/ fixedHandle; - long /*int*/ redrawWindow, enableWindow; + long /*int*/ redrawWindow, enableWindow, provider; int drawCount; Composite parent; Cursor cursor; @@ -3954,6 +3954,25 @@ public void setBackground (Color color) { } } +void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) { + OS.gtk_widget_override_background_color (handle, OS.GTK_STATE_FLAG_NORMAL, rgba); +} + +void setBackgroundColorGradient (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) { + String css ="* {\n"; + if (rgba != null) { + String color = "rgba(" + (int)(rgba.red * 255) + "," + (int)(rgba.green * 255) + "," + (int)(rgba.blue * 255) + "," + (int)(rgba.alpha * 255) + ")"; + css += "background-image: -gtk-gradient (linear, 0 0, 0 1, color-stop(0, " + color + "), color-stop(1, " + color + "));\n"; + } + css += "}\n"; + if (provider == 0) { + provider = OS.gtk_css_provider_new (); + OS.gtk_style_context_add_provider (context, provider, OS.GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + OS.g_object_unref (provider); + } + OS.gtk_css_provider_load_from_data (provider, Converter.wcsToMbcs (null, css, true), -1, null); +} + void setBackgroundColor (long /*int*/ handle, GdkColor color) { if (OS.GTK3) { GdkRGBA rgba = null; @@ -3973,8 +3992,8 @@ void setBackgroundColor (long /*int*/ handle, GdkColor color) { rgba.green = (color.green & 0xFFFF) / (float)0xFFFF; rgba.blue = (color.blue & 0xFFFF) / (float)0xFFFF; } - OS.gtk_widget_override_background_color (handle, OS.GTK_STATE_FLAG_NORMAL, rgba); long /*int*/ context = OS.gtk_widget_get_style_context (handle); + setBackgroundColor (context, handle, rgba); OS.gtk_style_context_invalidate (context); return; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java index 519f96445d..22de9b2eec 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java @@ -885,6 +885,10 @@ void removeVerifyListener (VerifyListener listener) { eventTable.unhook (SWT.Verify, listener); } +void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) { + setBackgroundColorGradient (context, handle, rgba); +} + void setBackgroundColor (GdkColor color) { super.setBackgroundColor (color); if (!OS.GTK3) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java index 10c25e994f..4960e8ee77 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java @@ -2088,6 +2088,14 @@ void setBackgroundColor (GdkColor color) { } } +void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) { + if ((style & SWT.MULTI) != 0) { + super.setBackgroundColor (context, handle, rgba); + return; + } + setBackgroundColorGradient (context, handle, rgba); +} + void setCursor (long /*int*/ cursor) { long /*int*/ defaultCursor = 0; if (cursor == 0) defaultCursor = OS.gdk_cursor_new (OS.GDK_XTERM); |