aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti2013-04-03 10:57:13 (EDT)
committerCarolyn MacLeod2013-04-09 10:57:03 (EDT)
commitad6dbcc0b9ca58111b3a98ef0cbd6add575c923e (patch)
treef5cde4a42b6d007011158d27bd0ef41d920381a7
parent5593c1df804233a5e3050dd9c6cdbe962b706e18 (diff)
downloadeclipse.platform.swt-ad6dbcc0b9ca58111b3a98ef0cbd6add575c923e.zip
eclipse.platform.swt-ad6dbcc0b9ca58111b3a98ef0cbd6add575c923e.tar.gz
eclipse.platform.swt-ad6dbcc0b9ca58111b3a98ef0cbd6add575c923e.tar.bz2
Bug 403474 - [GTK3] Problems setting background on latest
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java23
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java8
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 ec09386..7833301 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 658385a..6cdacc9 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 519f964..22de9b2 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 10c25e9..4960e8e 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);