summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/gtk/org
diff options
context:
space:
mode:
authorSilenio Quarti <silenio_quarti@ca.ibm.com>2012-10-30 17:55:42 -0400
committerSilenio Quarti <silenio_quarti@ca.ibm.com>2012-10-30 17:55:42 -0400
commitccd2d5aea4fb2e484cfeea5d7ce086a6f7e68860 (patch)
tree150f22ca51340c4b93e96f23205564020a20c817 /bundles/org.eclipse.swt/Eclipse SWT/gtk/org
parent9e6ed5ddefaae266127428adb6c5fbedbb333dc4 (diff)
downloadeclipse.platform.swt-ccd2d5aea4fb2e484cfeea5d7ce086a6f7e68860.tar.gz
eclipse.platform.swt-ccd2d5aea4fb2e484cfeea5d7ce086a6f7e68860.tar.xz
eclipse.platform.swt-ccd2d5aea4fb2e484cfeea5d7ce086a6f7e68860.zip
Bug 389910 - Substitute GdkColor with GdkRGBA
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java55
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java107
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java127
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java44
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java31
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java32
25 files changed, 387 insertions, 178 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
index 00b684c23f..035a6e4705 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
@@ -659,7 +659,21 @@ protected void init () {
OS.gtk_widget_realize(shellHandle);
/* Initialize the system font slot */
- systemFont = getSystemFont ();
+ long /*int*/ defaultFont;
+ if (OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) {
+ long /*int*/ context = OS.gtk_widget_get_style_context (shellHandle);
+ defaultFont = OS.gtk_style_context_get_font (context, OS.GTK_STATE_FLAG_NORMAL);
+ } else {
+ long /*int*/ style = OS.gtk_widget_get_style (shellHandle);
+ defaultFont = OS.gtk_style_get_font_desc (style);
+ }
+ defaultFont = OS.pango_font_description_copy (defaultFont);
+ Point dpi = getDPI(), screenDPI = getScreenDPI();
+ if (dpi.y != screenDPI.y) {
+ int size = OS.pango_font_description_get_size(defaultFont);
+ OS.pango_font_description_set_size(defaultFont, size * dpi.y / screenDPI.y);
+ }
+ systemFont = Font.gtk_new (this, defaultFont);
}
/**
@@ -804,6 +818,10 @@ static synchronized void register (Device device) {
protected void release () {
if (shellHandle != 0) OS.gtk_widget_destroy(shellHandle);
shellHandle = 0;
+
+ /* Dispose the default font */
+ if (systemFont != null) systemFont.dispose ();
+ systemFont = null;
if (gdkColors != null) {
if (OS.GTK_VERSION < OS.VERSION(3, 0, 0)) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
index bad90829eb..4b9afb935e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
@@ -783,6 +783,27 @@ public void drawArc(int x, int y, int width, int height, int startAngle, int arc
*/
public void drawFocus(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ long /*int*/ cairo = data.cairo;
+ if (cairo != 0) {
+ checkGC(FOREGROUND);
+ if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) {
+ long /*int*/ context = OS.gtk_widget_get_style_context(data.device.shellHandle);
+ OS.gtk_render_focus(context, cairo, x, y, width, height);
+ } else {
+ int[] lineWidth = new int[1];
+ OS.gtk_widget_style_get(data.device.shellHandle, OS.focus_line_width, lineWidth, 0);
+ Cairo.cairo_save(cairo);
+ Cairo.cairo_set_line_width(cairo, lineWidth[0]);
+ double[] dashes = new double[]{1, 1};
+ double dash_offset = -lineWidth[0] / 2f;
+ while (dash_offset < 0) dash_offset += 2;
+ Cairo.cairo_set_dash(cairo, dashes, dashes.length, dash_offset);
+ Cairo.cairo_rectangle(cairo, x + lineWidth[0] / 2f, y + lineWidth[0] / 2f, width, height);
+ Cairo.cairo_stroke(cairo);
+ Cairo.cairo_restore(cairo);
+ }
+ return;
+ }
/*
* Feature in GTK. The function gtk_widget_get_default_style()
* can't be used here because gtk_paint_focus() uses GCs, which
@@ -790,23 +811,7 @@ public void drawFocus(int x, int y, int width, int height) {
* from a widget.
*/
long /*int*/ style = OS.gtk_widget_get_style(data.device.shellHandle);
- long /*int*/ cairo = data.cairo;
- if (cairo != 0) {
- checkGC(FOREGROUND);
- int[] lineWidth = new int[1];
- OS.gtk_widget_style_get(data.device.shellHandle, OS.focus_line_width, lineWidth, 0);
- Cairo.cairo_save(cairo);
- Cairo.cairo_set_line_width(cairo, lineWidth[0]);
- double[] dashes = new double[]{1, 1};
- double dash_offset = -lineWidth[0] / 2f;
- while (dash_offset < 0) dash_offset += 2;
- Cairo.cairo_set_dash(cairo, dashes, dashes.length, dash_offset);
- Cairo.cairo_rectangle(cairo, x + lineWidth[0] / 2f, y + lineWidth[0] / 2f, width, height);
- Cairo.cairo_stroke(cairo);
- Cairo.cairo_restore(cairo);
- return;
- }
- gtk_render_focus (style, data.drawable, OS.GTK_STATE_NORMAL, null, data.device.shellHandle, new byte[1], x, y, width, height);
+ OS.gtk_paint_focus(style, data.drawable, OS.GTK_STATE_NORMAL, null, data.device.shellHandle, new byte[1], x, y, width, height);
}
/**
@@ -4204,22 +4209,6 @@ public String toString () {
return "GC {" + handle + "}";
}
-void gtk_render_focus (long /*int*/ style, long /*int*/ window, int state_type, GdkRectangle area, long /*int*/ widget, byte[] detail, int x , int y, int width, int height) {
- if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) {
- long /*int*/ cairo = OS.gdk_cairo_create (window);
- long /*int*/ context = OS.gtk_widget_get_style_context (style);
- OS.gtk_style_context_save (context);
- OS.gtk_style_context_set_state (context, OS.gtk_widget_get_state_flags (widget));
- Cairo.cairo_save (cairo);
- OS.gtk_render_focus (context, cairo, x, y, width, height);
- Cairo.cairo_restore (cairo);
- OS.gtk_style_context_restore (context);
- Cairo.cairo_destroy (cairo);
- } else {
- OS.gtk_paint_focus (style, window, state_type, area, widget, detail, x, y, width, height);
- }
-}
-
long /*int*/ gdk_pixbuf_get_from_window(long /*int*/ dest, long /*int*/ src, int src_x, int src_y, int dest_x, int dest_y, int width, int height) {
if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) {
return OS.gdk_pixbuf_get_from_window (dest, src_x, src_y, width, height);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
index d894c84d21..14f3affcf6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
@@ -201,9 +201,9 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
indicatorHeight = indicatorSize [0] + 2 * indicatorSpacing [0];
trimWidth += indicatorHeight + indicatorSpacing [0];
} else {
- long /*int*/ style = OS.gtk_widget_get_style (handle);
- trimWidth += OS.gtk_style_get_xthickness (style) * 2;
- trimHeight += OS.gtk_style_get_ythickness (style) * 2;
+ Point thickness = getThickness (handle);
+ trimWidth += thickness.x * 2;
+ trimHeight += thickness.y * 2;
GtkBorder innerBorder = getBorder (OS.inner_border, handle, INNER_BORDER);
trimWidth += innerBorder.left + innerBorder.right;
trimHeight += innerBorder.top + innerBorder.bottom;
@@ -787,8 +787,8 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
void setFontDescription (long /*int*/ font) {
super.setFontDescription (font);
- if (labelHandle != 0) OS.gtk_widget_modify_font (labelHandle, font);
- if (imageHandle != 0) OS.gtk_widget_modify_font (imageHandle, font);
+ if (labelHandle != 0) setFontDescription (labelHandle, font);
+ if (imageHandle != 0) setFontDescription (imageHandle, font);
}
boolean setRadioSelection (boolean value) {
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 f0b30dff55..c478955dd3 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
@@ -356,9 +356,9 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
long /*int*/ layout = OS.gtk_entry_get_layout (entryHandle);
OS.pango_layout_get_size (layout, w, h);
int xborder = Display.INNER_BORDER, yborder = Display.INNER_BORDER;
- long /*int*/ style = OS.gtk_widget_get_style (entryHandle);
- xborder += OS.gtk_style_get_xthickness (style);
- yborder += OS.gtk_style_get_ythickness (style);
+ Point thickness = getThickness (entryHandle);
+ xborder += thickness.x;
+ yborder += thickness.y;
int [] property = new int [1];
OS.gtk_widget_style_get (entryHandle, OS.interior_focus, property, 0);
if (property [0] == 0) {
@@ -1736,9 +1736,11 @@ public void select (int index) {
void setBackgroundColor (GdkColor color) {
super.setBackgroundColor (color);
- if (entryHandle != 0) OS.gtk_widget_modify_base (entryHandle, 0, color);
- if (cellHandle != 0) OS.g_object_set (cellHandle, OS.background_gdk, color, 0);
- OS.g_object_set (textRenderer, OS.background_gdk, color, 0);
+ if (OS.GTK_VERSION < OS.VERSION (3, 0, 0)) {
+ if (entryHandle != 0) OS.gtk_widget_modify_base (entryHandle, 0, color);
+ if (cellHandle != 0) OS.g_object_set (cellHandle, OS.background_gdk, color, 0);
+ OS.g_object_set (textRenderer, OS.background_gdk, color, 0);
+ }
}
int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
@@ -1777,7 +1779,7 @@ void setMenuHandle (long /*int*/ widget) {
void setFontDescription (long /*int*/ font) {
super.setFontDescription (font);
- if (entryHandle != 0) OS.gtk_widget_modify_font (entryHandle, font);
+ if (entryHandle != 0) setFontDescription (entryHandle, font);
OS.g_object_set (textRenderer, OS.font_desc, font, 0);
if ((style & SWT.READ_ONLY) != 0) {
/*
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 71821f3889..dadd7d1d9a 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
@@ -226,11 +226,13 @@ void fixStyle (long /*int*/ handle) {
*/
if ((state & BACKGROUND) != 0) return;
if ((state & THEME_BACKGROUND) == 0) return;
- long /*int*/ childStyle = parent.childStyle ();
- if (childStyle != 0) {
- GdkColor color = new GdkColor();
- OS.gtk_style_get_bg (childStyle, 0, color);
- setBackgroundColor (color);
+ if (OS.GTK_VERSION < OS.VERSION (3, 0, 0)) {
+ long /*int*/ childStyle = parent.childStyle ();
+ if (childStyle != 0) {
+ GdkColor color = new GdkColor();
+ OS.gtk_style_get_bg (childStyle, 0, color);
+ setBackgroundColor (color);
+ }
}
}
@@ -2444,7 +2446,36 @@ public Image getBackgroundImage () {
return control.backgroundImage;
}
+GdkColor getContextBackground () {
+ long /*int*/ fontHandle = fontHandle ();
+ OS.gtk_widget_realize (fontHandle);
+ long /*int*/ context = OS.gtk_widget_get_style_context (fontHandle);
+ GdkRGBA rgba = new GdkRGBA ();
+ OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba);
+ GdkColor color = new GdkColor ();
+ color.red = (short)(rgba.red * 0xFFFF);
+ color.green = (short)(rgba.green * 0xFFFF);
+ color.blue = (short)(rgba.blue * 0xFFFF);
+ return color;
+}
+
+GdkColor getContextColor () {
+ long /*int*/ fontHandle = fontHandle ();
+ OS.gtk_widget_realize (fontHandle);
+ long /*int*/ context = OS.gtk_widget_get_style_context (fontHandle);
+ GdkRGBA rgba = new GdkRGBA ();
+ OS.gtk_style_context_get_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba);
+ GdkColor color = new GdkColor ();
+ color.red = (short)(rgba.red * 0xFFFF);
+ color.green = (short)(rgba.green * 0xFFFF);
+ color.blue = (short)(rgba.blue * 0xFFFF);
+ return color;
+}
+
GdkColor getBgColor () {
+ if (OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) {
+ return getContextBackground ();
+ }
long /*int*/ fontHandle = fontHandle ();
OS.gtk_widget_realize (fontHandle);
GdkColor color = new GdkColor ();
@@ -2453,6 +2484,9 @@ GdkColor getBgColor () {
}
GdkColor getBaseColor () {
+ if (OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) {
+ return getContextBackground ();
+ }
long /*int*/ fontHandle = fontHandle ();
OS.gtk_widget_realize (fontHandle);
GdkColor color = new GdkColor ();
@@ -2556,6 +2590,10 @@ public Font getFont () {
long /*int*/ getFontDescription () {
long /*int*/ fontHandle = fontHandle ();
OS.gtk_widget_realize (fontHandle);
+ if (OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) {
+ long /*int*/ context = OS.gtk_widget_get_style_context (fontHandle);
+ return OS.gtk_style_context_get_font(context, OS.GTK_STATE_FLAG_NORMAL);
+ }
return OS.gtk_style_get_font_desc (OS.gtk_widget_get_style (fontHandle));
}
@@ -2579,6 +2617,9 @@ GdkColor getForegroundColor () {
}
GdkColor getFgColor () {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) {
+ return getContextColor ();
+ }
long /*int*/ fontHandle = fontHandle ();
OS.gtk_widget_realize (fontHandle);
GdkColor color = new GdkColor ();
@@ -2591,6 +2632,9 @@ Point getIMCaretPos () {
}
GdkColor getTextColor () {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) {
+ return getContextColor ();
+ }
long /*int*/ fontHandle = fontHandle ();
OS.gtk_widget_realize (fontHandle);
GdkColor color = new GdkColor ();
@@ -2817,6 +2861,17 @@ public boolean getVisible () {
return (state & HIDDEN) == 0;
}
+Point getThickness (long /*int*/ widget) {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) {
+ GtkBorder padding = new GtkBorder();
+ long /*int*/ context = OS.gtk_widget_get_style_context (widget);
+ OS.gtk_style_context_get_padding (context, OS.GTK_STATE_FLAG_NORMAL, padding);
+ return new Point (padding.left, padding.top);
+ }
+ long /*int*/ style = OS.gtk_widget_get_style (widget);
+ return new Point (OS.gtk_style_get_xthickness (style), OS.gtk_style_get_ythickness (style));
+}
+
long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
return gtk_button_press_event (widget, event, true);
}
@@ -3804,12 +3859,16 @@ public void setBackground (Color color) {
gdkColor = color.handle;
}
boolean set = false;
- if (gdkColor == null) {
- long /*int*/ style = OS.gtk_widget_get_modifier_style (handle);
- set = (OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_NORMAL) & OS.GTK_RC_BG) != 0;
+ if (OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) {
+ set = !getBackground().equals(color);
} else {
- GdkColor oldColor = getBackgroundColor ();
- set = oldColor.pixel != gdkColor.pixel;
+ if (gdkColor == null) {
+ long /*int*/ style = OS.gtk_widget_get_modifier_style (handle);
+ set = (OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_NORMAL) & OS.GTK_RC_BG) != 0;
+ } else {
+ GdkColor oldColor = getBackgroundColor ();
+ set = oldColor.pixel != gdkColor.pixel;
+ }
}
if (set) {
if (color == null) {
@@ -3823,6 +3882,18 @@ public void setBackground (Color color) {
}
void setBackgroundColor (long /*int*/ handle, GdkColor color) {
+ if (OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) {
+ GdkRGBA rgba = null;
+ if (color != null) {
+ rgba = new GdkRGBA ();
+ rgba.alpha = 1;
+ rgba.red = (color.red & 0xFFFF) / (float)0xFFFF;
+ 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);
+ return;
+ }
int index = OS.GTK_STATE_NORMAL;
long /*int*/ style = OS.gtk_widget_get_modifier_style (handle);
long /*int*/ ptr = OS.gtk_rc_style_get_bg_pixmap_name (style, index);
@@ -4125,7 +4196,7 @@ public void setFont (Font font) {
}
void setFontDescription (long /*int*/ font) {
- OS.gtk_widget_modify_font (handle, font);
+ setFontDescription (handle, font);
}
/**
@@ -4154,12 +4225,16 @@ public void setForeground (Color color) {
gdkColor = color.handle;
}
boolean set = false;
- if (gdkColor == null) {
- long /*int*/ style = OS.gtk_widget_get_modifier_style (handle);
- set = (OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_NORMAL) & OS.GTK_RC_FG) != 0;
+ if (OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) {
+ set = !getForeground().equals(color);
} else {
- GdkColor oldColor = getForegroundColor ();
- set = oldColor.pixel != gdkColor.pixel;
+ if (gdkColor == null) {
+ long /*int*/ style = OS.gtk_widget_get_modifier_style (handle);
+ set = (OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_NORMAL) & OS.GTK_RC_FG) != 0;
+ } else {
+ GdkColor oldColor = getForegroundColor ();
+ set = oldColor.pixel != gdkColor.pixel;
+ }
}
if (set) {
if (color == null) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java
index d7c3328f49..5705c5c0ae 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java
@@ -1065,9 +1065,6 @@ void sendSelectionEvent () {
public void setBackground(Color color) {
super.setBackground(color);
- if (((style & SWT.CALENDAR) != 0) && color == null) {
- OS.gtk_widget_modify_base(handle, 0, null);
- }
bg = color;
if (text != null) text.setBackground(color);
if (popupCalendar != null) popupCalendar.setBackground(color);
@@ -1075,7 +1072,9 @@ public void setBackground(Color color) {
void setBackgroundColor (GdkColor color) {
if ((style & SWT.CALENDAR) != 0) {
- OS.gtk_widget_modify_base(handle, 0, color);
+ if (OS.GTK_VERSION < OS.VERSION (3, 0, 0)) {
+ OS.gtk_widget_modify_base(handle, 0, color);
+ }
} else {
super.setBackgroundColor (color);
}
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 b617c64042..075f300640 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
@@ -258,7 +258,6 @@ public class Display extends Device {
long /*int*/ [] flushData = new long /*int*/ [1];
/* System Resources */
- Font systemFont;
Image errorImage, infoImage, questionImage, warningImage;
Cursor [] cursors = new Cursor [SWT.CURSOR_HAND + 1];
Resource [] resources;
@@ -2205,7 +2204,87 @@ public Menu getSystemMenu () {
return null;
}
+GdkColor toGdkColor (GdkRGBA rgba) {
+ GdkColor gdkColor = new GdkColor();
+ gdkColor.red = (short)(rgba.red * 0xFFFF);
+ gdkColor.green = (short)(rgba.green * 0xFFFF);
+ gdkColor.blue = (short)(rgba.blue * 0xFFFF);
+ return gdkColor;
+}
+
+GdkColor toGdkColor (GdkRGBA rgba, float m1, float m2) {
+ RGB rgb = new RGB((int)(rgba.red * 0xFF), (int)(rgba.green * 0xFF), (int)(rgba.blue * 0xFF));
+ float[] hsb = rgb.getHSB();
+ hsb[1] = (float)Math.max(0f, Math.min(1f, hsb[1] * m1));
+ hsb[2] = (float)Math.max(0f, Math.min(1f, hsb[2] * m2));
+ rgb = new RGB(hsb[0], hsb[1], hsb[2]);
+ GdkColor gdkColor = new GdkColor();
+ gdkColor.red = (short)((rgb.red & 0xFF) | ((rgb.red & 0xFF) << 8));
+ gdkColor.green = (short)((rgb.green & 0xFF) | ((rgb.green & 0xFF) << 8));
+ gdkColor.blue = (short)((rgb.blue & 0xFF) | ((rgb.blue & 0xFF) << 8));
+ return gdkColor;
+}
+
void initializeSystemColors () {
+ if (OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) {
+ 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();
+ OS.gtk_style_context_get_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba);
+ COLOR_INFO_FOREGROUND = toGdkColor (rgba);
+ OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba);
+ COLOR_INFO_BACKGROUND = toGdkColor (rgba);
+ OS.gtk_widget_destroy (tooltipShellHandle);
+
+ context = OS.gtk_widget_get_style_context (shellHandle);
+
+ COLOR_WIDGET_DARK_SHADOW = toGdkColor (new GdkRGBA());
+ OS.gtk_style_context_get_border_color (context, OS.GTK_STATE_FLAG_INSENSITIVE, rgba);
+ COLOR_WIDGET_NORMAL_SHADOW = toGdkColor (rgba);
+ OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_INSENSITIVE, rgba);
+ COLOR_WIDGET_LIGHT_SHADOW = toGdkColor (rgba);
+ rgba.red = rgba.green = rgba.blue = 1;
+ COLOR_WIDGET_HIGHLIGHT_SHADOW = toGdkColor (rgba);
+
+ OS.gtk_style_context_get_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba);
+ COLOR_WIDGET_FOREGROUND = toGdkColor (rgba);
+ OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba);
+ COLOR_WIDGET_BACKGROUND = toGdkColor (rgba);
+
+ OS.gtk_style_context_save (context);
+ OS.gtk_style_context_add_class(context, OS.GTK_STYLE_CLASS_CELL);
+ OS.gtk_style_context_get_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba);
+ COLOR_LIST_FOREGROUND = toGdkColor (rgba);
+ OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba);
+ COLOR_LIST_BACKGROUND = toGdkColor (rgba);
+ OS.gtk_style_context_restore (context);
+ OS.gtk_style_context_get_color (context, OS.GTK_STATE_FLAG_SELECTED, rgba);
+ COLOR_LIST_SELECTION_TEXT = toGdkColor (rgba);
+ OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_SELECTED, rgba);
+ COLOR_LIST_SELECTION = toGdkColor (rgba);
+ OS.gtk_style_context_get_color (context, OS.GTK_STATE_FLAG_ACTIVE, rgba);
+ COLOR_LIST_SELECTION_TEXT_INACTIVE = toGdkColor (rgba);
+ OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_ACTIVE, rgba);
+ COLOR_LIST_SELECTION_INACTIVE = toGdkColor (rgba);
+
+ COLOR_TITLE_FOREGROUND = COLOR_LIST_SELECTION_TEXT;
+ COLOR_TITLE_BACKGROUND = COLOR_LIST_SELECTION;
+ OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_SELECTED, rgba);
+ COLOR_TITLE_BACKGROUND_GRADIENT = toGdkColor (rgba, 0.66f, 1);
+
+ OS.gtk_style_context_get_color (context, OS.GTK_STATE_FLAG_INSENSITIVE, rgba);
+ COLOR_TITLE_INACTIVE_FOREGROUND = toGdkColor (rgba);
+ OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_INSENSITIVE, rgba);
+ COLOR_TITLE_INACTIVE_BACKGROUND = toGdkColor (rgba);
+ COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT = toGdkColor (rgba, 1, 2f);
+ return;
+ }
+
GdkColor gdkColor;
/* Get Tooltip resources */
@@ -2288,35 +2367,6 @@ void initializeSystemColors () {
}
/**
- * Returns a reasonable font for applications to use.
- * On some platforms, this will match the "default font"
- * or "system font" if such can be found. This font
- * should not be free'd because it was allocated by the
- * system, not the application.
- * <p>
- * Typically, applications which want the default look
- * should simply not set the font on the widgets they
- * create. Widgets are always created with the correct
- * default font for the class of user-interface component
- * they represent.
- * </p>
- *
- * @return a font
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Font getSystemFont () {
- checkDevice ();
- if (systemFont != null) return systemFont;
- long /*int*/ style = OS.gtk_widget_get_style (shellHandle);
- long /*int*/ defaultFont = OS.pango_font_description_copy (OS.gtk_style_get_font_desc (style));
- return systemFont = Font.gtk_new (this, defaultFont);
-}
-
-/**
* Returns the single instance of the system taskBar or null
* when there is no system taskBar available for the platform.
*
@@ -3381,10 +3431,6 @@ void releaseDisplay () {
mouseHoverCallback.dispose ();
mouseHoverCallback = null;
- /* Dispose the default font */
- if (systemFont != null) systemFont.dispose ();
- systemFont = null;
-
/* Dispose the System Images */
if (errorImage != null) errorImage.dispose();
if (infoImage != null) infoImage.dispose();
@@ -4010,9 +4056,14 @@ void showIMWindow (Control control) {
if (preeditString [0] != 0 && OS.strlen (preeditString [0]) > 0) {
Control widget = control.findBackgroundControl ();
if (widget == null) widget = control;
- OS.gtk_widget_modify_bg (preeditWindow, OS.GTK_STATE_NORMAL, widget.getBackgroundColor ());
+ GdkColor color = widget.getBackgroundColor ();
+ if (OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) {
+ widget.setBackgroundColor (preeditWindow, color);
+ } else {
+ OS.gtk_widget_modify_bg (preeditWindow, OS.GTK_STATE_NORMAL, color);
+ }
widget.setForegroundColor (preeditLabel, control.getForegroundColor());
- OS.gtk_widget_modify_font (preeditLabel, control.getFontDescription ());
+ widget.setFontDescription (preeditLabel, control.getFontDescription ());
if (pangoAttrs [0] != 0) OS.gtk_label_set_attributes (preeditLabel, pangoAttrs[0]);
OS.gtk_label_set_text (preeditLabel, preeditString [0]);
Point point = control.toDisplay (control.getIMCaretPos ());
@@ -4217,10 +4268,6 @@ void saveResources () {
System.arraycopy (resources, 0, newResources, 0, resourceCount);
resources = newResources;
}
- if (systemFont != null) {
- resources [resourceCount++] = systemFont;
- systemFont = null;
- }
if (errorImage != null) resources [resourceCount++] = errorImage;
if (infoImage != null) resources [resourceCount++] = infoImage;
if (questionImage != null) resources [resourceCount++] = questionImage;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java
index 93673774d4..cf65c83111 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java
@@ -496,9 +496,9 @@ boolean setFocus () {
}
void setFontDescription (long /*int*/ font) {
- OS.gtk_widget_modify_font (handle, font);
- if (labelHandle != 0) OS.gtk_widget_modify_font (labelHandle, font);
- if (imageHandle != 0) OS.gtk_widget_modify_font (imageHandle, font);
+ setFontDescription (handle, font);
+ if (labelHandle != 0) setFontDescription (labelHandle, font);
+ if (imageHandle != 0) setFontDescription (imageHandle, font);
}
void setForegroundColor (GdkColor color) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
index 0a30a8d093..cbdea52cbd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
@@ -231,7 +231,7 @@ void setBackgroundColor (GdkColor color) {
void setFontDescription (long /*int*/ font) {
super.setFontDescription (font);
- OS.gtk_widget_modify_font (labelHandle, font);
+ setFontDescription (labelHandle, font);
}
void setForegroundColor (GdkColor color) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
index 5ecf918e10..aa8ed91938 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
@@ -189,8 +189,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
OS.g_object_get (labelHandle, OS.ypad, buffer, 0);
fontHeight += 2 * buffer [0];
if (frameHandle != 0) {
- long /*int*/ style = OS.gtk_widget_get_style (frameHandle);
- fontHeight += 2 * OS.gtk_style_get_ythickness (style);
+ fontHeight += 2 * getThickness (frameHandle).y;
fontHeight += 2 * OS.gtk_container_get_border_width (frameHandle);
}
size.y = Math.max (size.y, fontHeight);
@@ -281,7 +280,7 @@ public int getAlignment () {
public int getBorderWidth () {
checkWidget();
if (frameHandle != 0) {
- return OS.gtk_style_get_xthickness (OS.gtk_widget_get_style (frameHandle));
+ return getThickness (frameHandle).x;
}
return 0;
}
@@ -486,8 +485,8 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
void setFontDescription (long /*int*/ font) {
super.setFontDescription (font);
- if (labelHandle != 0) OS.gtk_widget_modify_font (labelHandle, font);
- if (imageHandle != 0) OS.gtk_widget_modify_font (imageHandle, font);
+ if (labelHandle != 0) setFontDescription (labelHandle, font);
+ if (imageHandle != 0) setFontDescription (imageHandle, font);
}
void setForegroundColor (GdkColor color) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
index 3b1821d9c1..3a1ded6d2f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
@@ -1225,7 +1225,9 @@ void selectFocusIndex (int index) {
void setBackgroundColor (GdkColor color) {
super.setBackgroundColor (color);
- OS.gtk_widget_modify_base (handle, 0, color);
+ if (OS.GTK_VERSION < OS.VERSION (3, 0, 0)) {
+ OS.gtk_widget_modify_base (handle, 0, color);
+ }
}
int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
index 8a570ee8db..967660d915 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
@@ -116,9 +116,9 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
trimWidth += vScrollBarWidth ();
if (scrolledHandle != 0) {
if (OS.gtk_scrolled_window_get_shadow_type (scrolledHandle) != OS.GTK_SHADOW_NONE) {
- long /*int*/ style = OS.gtk_widget_get_style (scrolledHandle);
- int xthickness = OS.gtk_style_get_xthickness (style);
- int ythickness = OS.gtk_style_get_ythickness (style);
+ Point thickness = getThickness (scrolledHandle);
+ int xthickness = thickness.x;
+ int ythickness = thickness.y;
trimX -= xthickness;
trimY -= ythickness;
trimWidth += xthickness * 2;
@@ -180,7 +180,7 @@ public int getBorderWidth () {
if (scrolledHandle != 0) {
border += OS.gtk_container_get_border_width (scrolledHandle);
if (OS.gtk_scrolled_window_get_shadow_type (scrolledHandle) != OS.GTK_SHADOW_NONE) {
- border += OS.gtk_style_get_xthickness (OS.gtk_widget_get_style (scrolledHandle));
+ border += getThickness (scrolledHandle).x;
}
}
return border;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
index 78f0178187..7c9817f0fa 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
@@ -713,9 +713,13 @@ void createHandle (int index) {
OS.gtk_window_set_title (shellHandle, new byte [1]);
if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0) {
OS.gtk_container_set_border_width (shellHandle, 1);
- GdkColor color = new GdkColor ();
- OS.gtk_style_get_black (OS.gtk_widget_get_style (shellHandle), color);
- OS.gtk_widget_modify_bg (shellHandle, OS.GTK_STATE_NORMAL, color);
+ if (OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) {
+ OS.gtk_widget_override_background_color (shellHandle, OS.GTK_STATE_FLAG_NORMAL, new GdkRGBA());
+ } else {
+ GdkColor color = new GdkColor ();
+ OS.gtk_style_get_black (OS.gtk_widget_get_style (shellHandle), color);
+ OS.gtk_widget_modify_bg (shellHandle, OS.GTK_STATE_NORMAL, color);
+ }
}
if (isCustomResize ()) {
OS.gtk_container_set_border_width (shellHandle, BORDER);
@@ -1244,6 +1248,30 @@ long /*int*/ gtk_enter_notify_event (long /*int*/ widget, long /*int*/ event) {
return 0;
}
+long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) {
+ if (widget == shellHandle) {
+ if (isCustomResize ()) {
+ int [] width = new int [1];
+ int [] height = new int [1];
+ long /*int*/ window = gtk_widget_get_window (widget);
+ gdk_window_get_size (window, width, height);
+ int border = OS.gtk_container_get_border_width (widget);
+ long /*int*/ context = OS.gtk_widget_get_style_context (shellHandle);
+ //TODO draw shell frame on GTK3
+ OS.gtk_style_context_save (context);
+ OS.gtk_render_frame (context, cairo, 0, 0, width [0], border);
+ OS.gtk_render_frame (context, cairo, 0, height [0] - border, width [0], border);
+ OS.gtk_render_frame (context, cairo, 0, border, border, height [0] - border - border);
+ OS.gtk_render_frame (context, cairo, width [0] - border, border, border, height [0] - border - border);
+ OS.gtk_render_frame (context, cairo, 0 + 10, 0 + 10, width [0] - 20, height [0] - 20);
+ OS.gtk_style_context_restore (context);
+ return 1;
+ }
+ return 0;
+ }
+ return super.gtk_draw (widget, cairo);
+}
+
long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ event) {
if (widget == shellHandle) {
if (isCustomResize ()) {
@@ -1262,11 +1290,11 @@ long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ event) {
byte [] detail = Converter.wcsToMbcs (null, "base", true); //$NON-NLS-1$
int border = OS.gtk_container_get_border_width (widget);
int state = display.activeShell == this ? OS.GTK_STATE_SELECTED : OS.GTK_STATE_PRELIGHT;
- gtk_render_frame (style, window, state, OS.GTK_SHADOW_NONE, area, widget, detail, 0, 0, width [0], border);
- gtk_render_frame (style, window, state, OS.GTK_SHADOW_NONE, area, widget, detail, 0, height [0] - border, width [0], border);
- gtk_render_frame (style, window, state, OS.GTK_SHADOW_NONE, area, widget, detail, 0, border, border, height [0] - border - border);
- gtk_render_frame (style, window, state, OS.GTK_SHADOW_NONE, area, widget, detail, width [0] - border, border, border, height [0] - border - border);
- gtk_render_box (style, window, state, OS.GTK_SHADOW_OUT, area, widget, detail, 0, 0, width [0], height [0]);
+ OS.gtk_paint_flat_box (style, window, state, OS.GTK_SHADOW_NONE, area, widget, detail, 0, 0, width [0], border);
+ OS.gtk_paint_flat_box (style, window, state, OS.GTK_SHADOW_NONE, area, widget, detail, 0, height [0] - border, width [0], border);
+ OS.gtk_paint_flat_box (style, window, state, OS.GTK_SHADOW_NONE, area, widget, detail, 0, border, border, height [0] - border - border);
+ OS.gtk_paint_flat_box (style, window, state, OS.GTK_SHADOW_NONE, area, widget, detail, width [0] - border, border, border, height [0] - border - border);
+ OS.gtk_paint_box (style, window, state, OS.GTK_SHADOW_OUT, area, widget, detail, 0, 0, width [0], height [0]);
return 1;
}
return 0;
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 088b217c06..9a0a61ef72 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
@@ -240,10 +240,10 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget ();
int xborder = 0, yborder = 0;
- long /*int*/ style = OS.gtk_widget_get_style (handle);
+ Point thickness = getThickness (handle);
if ((this.style & SWT.BORDER) != 0) {
- xborder += OS.gtk_style_get_xthickness (style);
- yborder += OS.gtk_style_get_ythickness (style);
+ xborder += thickness.x;
+ yborder += thickness.y;
}
int [] property = new int [1];
OS.gtk_widget_style_get (handle, OS.interior_focus, property, 0);
@@ -252,7 +252,7 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
xborder += property [0];
yborder += property [0];
}
- long /*int*/ fontDesc = OS.gtk_style_get_font_desc (style);
+ long /*int*/ fontDesc = getFontDescription ();
int fontSize = OS.pango_font_description_get_size (fontDesc);
int arrowSize = Math.max (OS.PANGO_PIXELS (fontSize), MIN_ARROW_WIDTH);
arrowSize = arrowSize - arrowSize % 2;
@@ -261,7 +261,7 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
trim.y -= yborder;
trim.width += 2 * xborder;
trim.height += 2 * yborder;
- trim.width += arrowSize + (2 * OS.gtk_style_get_xthickness (style));
+ trim.width += arrowSize + (2 * thickness.x);
GtkBorder innerBorder = Display.getEntryInnerBorder (handle);
trim.x -= innerBorder.left;
trim.y -= innerBorder.top;
@@ -374,9 +374,8 @@ GdkColor getBackgroundColor () {
public int getBorderWidth () {
checkWidget();
- long /*int*/ style = OS.gtk_widget_get_style (handle);
if ((this.style & SWT.BORDER) != 0) {
- return OS.gtk_style_get_xthickness (style);
+ return getThickness (handle).x;
}
return 0;
}
@@ -867,7 +866,9 @@ void removeVerifyListener (VerifyListener listener) {
void setBackgroundColor (GdkColor color) {
super.setBackgroundColor (color);
- OS.gtk_widget_modify_base (handle, 0, color);
+ if (OS.GTK_VERSION < OS.VERSION (3, 0, 0)) {
+ OS.gtk_widget_modify_base (handle, 0, color);
+ }
}
void setCursor (long /*int*/ cursor) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
index 7880b96fc4..3cf0aba18d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
@@ -284,8 +284,8 @@ public void setControl (Control control) {
}
void setFontDescription (long /*int*/ font) {
- OS.gtk_widget_modify_font (labelHandle, font);
- OS.gtk_widget_modify_font (imageHandle, font);
+ setFontDescription (labelHandle, font);
+ setFontDescription (imageHandle, font);
}
void setForegroundColor (GdkColor color) {
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 6837925800..fe67d523f9 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
@@ -2627,10 +2627,14 @@ long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window, long /*
if ((drawState & SWT.SELECTED) != 0) drawFlags |= OS.GTK_CELL_RENDERER_SELECTED;
if ((drawState & SWT.FOCUSED) != 0) drawFlags |= OS.GTK_CELL_RENDERER_FOCUSED;
if ((drawState & SWT.SELECTED) != 0) {
- long /*int*/ style = OS.gtk_widget_get_style (widget);
- //TODO - parity and sorted
- byte[] detail = Converter.wcsToMbcs (null, "cell_odd", true);
- gtk_render_frame (style, window, OS.GTK_STATE_SELECTED, OS.GTK_SHADOW_NONE, rect, widget, detail, rect.x, rect.y, rect.width, rect.height);
+ if (OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) {
+ //TODO draw selection on GTK3
+ } else {
+ long /*int*/ style = OS.gtk_widget_get_style (widget);
+ //TODO - parity and sorted
+ byte[] detail = Converter.wcsToMbcs (null, "cell_odd", true);
+ OS.gtk_paint_flat_box (style, window, OS.GTK_STATE_SELECTED, OS.GTK_SHADOW_NONE, rect, widget, detail, rect.x, rect.y, rect.width, rect.height);
+ }
} else {
if (wasSelected) drawForeground = gc.getForeground ().handle;
}
@@ -2932,7 +2936,9 @@ void selectFocusIndex (int index) {
void setBackgroundColor (GdkColor color) {
super.setBackgroundColor (color);
- OS.gtk_widget_modify_base (handle, 0, color);
+ if (OS.GTK_VERSION < OS.VERSION (3, 0, 0)) {
+ OS.gtk_widget_modify_base (handle, 0, color);
+ }
}
void setBackgroundPixmap (Image image) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
index be55f8a000..c0e65db0a0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
@@ -548,8 +548,8 @@ public void setAlignment (int alignment) {
}
void setFontDescription (long /*int*/ font) {
- OS.gtk_widget_modify_font (labelHandle, font);
- OS.gtk_widget_modify_font (imageHandle, font);
+ setFontDescription (labelHandle, font);
+ setFontDescription (imageHandle, font);
}
public void setImage (Image image) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
index 510138dfa3..20777f31e6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
@@ -1169,8 +1169,10 @@ public void setImage (int index, Image image) {
* are relying on the fact that it is done as part of modifying
* the style.
*/
- long /*int*/ style = OS.gtk_widget_get_modifier_style (parentHandle);
- parent.modifyStyle (parentHandle, style);
+ if (OS.GTK_VERSION < OS.VERSION (3, 0, 0)) {
+ long /*int*/ style = OS.gtk_widget_get_modifier_style (parentHandle);
+ parent.modifyStyle (parentHandle, style);
+ }
}
}
}
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 154acbb8e9..e68d24f1e3 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
@@ -570,9 +570,9 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
int xborder = 0, yborder = 0;
if ((style & SWT.SINGLE) != 0) {
if ((style & SWT.BORDER) != 0) {
- long /*int*/ style = OS.gtk_widget_get_style (handle);
- xborder += OS.gtk_style_get_xthickness (style);
- yborder += OS.gtk_style_get_ythickness (style);
+ Point thickness = getThickness (handle);
+ xborder += thickness.x;
+ yborder += thickness.y;
}
GtkBorder innerBorder = Display.getEntryInnerBorder (handle);
trim.x -= innerBorder.left;
@@ -771,9 +771,8 @@ GdkColor getBackgroundColor () {
public int getBorderWidth () {
checkWidget();
if ((style & SWT.MULTI) != 0) return super.getBorderWidth ();
- long /*int*/ style = OS.gtk_widget_get_style (handle);
if ((this.style & SWT.BORDER) != 0) {
- return OS.gtk_style_get_xthickness (style);
+ return getThickness (handle).x;
}
return 0;
}
@@ -1590,11 +1589,23 @@ void drawMessage (long /*int*/ cr) {
case SWT.CENTER: x = (width - rect.width) / 2; break;
case SWT.RIGHT: x = rtl ? innerBorder.left : width - rect.width; break;
}
- long /*int*/ style = OS.gtk_widget_get_style (handle);
GdkColor textColor = new GdkColor ();
- OS.gtk_style_get_text (style, OS.GTK_STATE_INSENSITIVE, textColor);
GdkColor baseColor = new GdkColor ();
- OS.gtk_style_get_base (style, OS.GTK_STATE_NORMAL, baseColor);
+ if (OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) {
+ long /*int*/ styleContext = OS.gtk_widget_get_style_context (handle);
+ GdkRGBA rgba = new GdkRGBA ();
+ OS.gtk_style_context_get_color (styleContext, OS.GTK_STATE_FLAG_INSENSITIVE, rgba);
+ textColor.red = (short)(rgba.red * 0xFFFF);
+ textColor.green = (short)(rgba.green * 0xFFFF);
+ textColor.blue = (short)(rgba.blue * 0xFFFF);
+ Point thickness = getThickness (handle);
+ x += thickness.x;
+ y += thickness.y;
+ } else {
+ long /*int*/ style = OS.gtk_widget_get_style (handle);
+ OS.gtk_style_get_text (style, OS.GTK_STATE_INSENSITIVE, textColor);
+ OS.gtk_style_get_base (style, OS.GTK_STATE_NORMAL, baseColor);
+ }
if (OS.USE_CAIRO) {
long /*int*/ cairo = cr != 0 ? cr : OS.gdk_cairo_create(window);
Cairo.cairo_set_source_rgba(cairo, (textColor.red & 0xFFFF) / (float)0xFFFF, (textColor.green & 0xFFFF) / (float)0xFFFF, (textColor.blue & 0xFFFF) / (float)0xFFFF, 1);
@@ -2059,7 +2070,9 @@ public void selectAll () {
void setBackgroundColor (GdkColor color) {
super.setBackgroundColor (color);
- OS.gtk_widget_modify_base (handle, 0, color);
+ if (OS.GTK_VERSION < OS.VERSION (3, 0, 0)) {
+ OS.gtk_widget_modify_base (handle, 0, color);
+ }
}
void setCursor (long /*int*/ cursor) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
index 9cb039a4ee..9f48cd9002 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
@@ -981,7 +981,7 @@ boolean setFocus () {
}
void setFontDescription (long /*int*/ font) {
- if (labelHandle != 0) OS.gtk_widget_modify_font (labelHandle, font);
+ if (labelHandle != 0) setFontDescription (labelHandle, font);
}
void setForegroundColor (GdkColor color) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
index 68d8478cea..0354d883a3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
@@ -266,7 +266,17 @@ void createHandle (int index) {
state |= HANDLE;
handle = OS.gtk_window_new (OS.GTK_WINDOW_POPUP);
Color background = display.getSystemColor (SWT.COLOR_INFO_BACKGROUND);
- OS.gtk_widget_modify_bg (handle, OS.GTK_STATE_NORMAL, background.handle);
+ if (OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) {
+ GdkColor color = background.handle;
+ GdkRGBA rgba = new GdkRGBA();
+ rgba.alpha = 1;
+ rgba.red = (color.red & 0xFFFF) / (float)0xFFFF;
+ 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);
+ } else {
+ OS.gtk_widget_modify_bg (handle, OS.GTK_STATE_NORMAL, background.handle);
+ }
OS.gtk_widget_set_app_paintable (handle, true);
OS.gtk_window_set_type_hint (handle, OS.GDK_WINDOW_TYPE_HINT_TOOLTIP);
} else {
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 03052bc921..a5ad2e6531 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
@@ -2617,10 +2617,14 @@ long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window, long /*
if ((drawState & SWT.SELECTED) != 0) drawFlags |= OS.GTK_CELL_RENDERER_SELECTED;
if ((drawState & SWT.FOCUSED) != 0) drawFlags |= OS.GTK_CELL_RENDERER_FOCUSED;
if ((drawState & SWT.SELECTED) != 0) {
- long /*int*/ style = OS.gtk_widget_get_style (widget);
- //TODO - parity and sorted
- byte[] detail = Converter.wcsToMbcs (null, "cell_odd", true);
- gtk_render_frame (style, window, OS.GTK_STATE_SELECTED, OS.GTK_SHADOW_NONE, rect, widget, detail, rect.x, rect.y, rect.width, rect.height);
+ if (OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) {
+ //TODO draw selection on GTK3
+ } else {
+ long /*int*/ style = OS.gtk_widget_get_style (widget);
+ //TODO - parity and sorted
+ byte[] detail = Converter.wcsToMbcs (null, "cell_odd", true);
+ OS.gtk_paint_flat_box (style, window, OS.GTK_STATE_SELECTED, OS.GTK_SHADOW_NONE, rect, widget, detail, rect.x, rect.y, rect.width, rect.height);
+ }
} else {
if (wasSelected) drawForeground = gc.getForeground ().handle;
}
@@ -2900,7 +2904,9 @@ public void selectAll () {
void setBackgroundColor (GdkColor color) {
super.setBackgroundColor (color);
- OS.gtk_widget_modify_base (handle, 0, color);
+ if (OS.GTK_VERSION < OS.VERSION (3, 0, 0)) {
+ OS.gtk_widget_modify_base (handle, 0, color);
+ }
}
void setBackgroundPixmap (Image image) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
index 70145a487b..e77d6f0fe2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
@@ -545,8 +545,8 @@ public void setAlignment (int alignment) {
}
void setFontDescription (long /*int*/ font) {
- OS.gtk_widget_modify_font (labelHandle, font);
- OS.gtk_widget_modify_font (imageHandle, font);
+ setFontDescription (labelHandle, font);
+ setFontDescription (imageHandle, font);
}
public void setImage (Image image) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
index 4c88cbfdb0..3f969dbee1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
@@ -1608,8 +1608,10 @@ public void setImage (int index, Image image) {
* are relying on the fact that it is done as part of modifying
* the style.
*/
- long /*int*/ style = OS.gtk_widget_get_modifier_style (parentHandle);
- parent.modifyStyle (parentHandle, style);
+ if (OS.GTK_VERSION < OS.VERSION (3, 0, 0)) {
+ long /*int*/ style = OS.gtk_widget_get_modifier_style (parentHandle);
+ parent.modifyStyle (parentHandle, style);
+ }
}
}
}
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 a6010807dd..6ac856254f 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
@@ -1636,11 +1636,32 @@ public void setData (String key, Object value) {
if (key.equals(SWT.SKIN_CLASS) || key.equals(SWT.SKIN_ID)) this.reskin(SWT.ALL);
}
+void setFontDescription (long /*int*/ widget, long /*int*/ font) {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) {
+ OS.gtk_widget_override_font (widget, font);
+ } else {
+ OS.gtk_widget_modify_font (widget, font);
+ }
+}
+
void setForegroundColor (long /*int*/ handle, GdkColor color) {
setForegroundColor (handle, color, true);
}
void setForegroundColor (long /*int*/ handle, GdkColor color, boolean setStateActive) {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) {
+ GdkRGBA rgba = null;
+ if (color != null) {
+ rgba = new GdkRGBA();
+ rgba.alpha = 1;
+ rgba.red = (color.red & 0xFFFF) / (float)0xFFFF;
+ rgba.green = (color.green & 0xFFFF) / (float)0xFFFF;
+ rgba.blue = (color.blue & 0xFFFF) / (float)0xFFFF;
+ }
+ OS.gtk_widget_override_color (handle, OS.GTK_STATE_FLAG_NORMAL, rgba);
+ return;
+ }
+
/*
* Feature in GTK. When the widget doesn't have focus, then
* gtk_default_draw_flat_box () changes the background color state_type
@@ -2134,17 +2155,6 @@ long /*int*/ gdk_window_get_device_position (long /*int*/ window, int[] x, int[]
}
}
-void gtk_render_frame (long /*int*/ style, long /*int*/ window, int state_type, int shadow_type, GdkRectangle area, long /*int*/ widget, byte[] detail, int x , int y, int width, int height) {
- if (OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) {
- long /*int*/ cairo = OS.gdk_cairo_create (window);
- long /*int*/ context = OS.gtk_widget_get_style_context (style);
- OS.gtk_render_frame (context, cairo, x, y, width, height);
- Cairo.cairo_destroy (cairo);
- } else {
- OS.gtk_paint_flat_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
- }
-}
-
void gtk_cell_renderer_get_preferred_size (long /*int*/ cell, long /*int*/ widget, int[] width, int[] height) {
if (OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) {
GtkRequisition minimum_size = new GtkRequisition ();