From 3fdc19a025bdb1d1c9714427e7323556f1c5dd33 Mon Sep 17 00:00:00 2001 From: Anatoly Spektor Date: Thu, 4 Oct 2012 13:53:15 -0400 Subject: Use gtk_render_frame instead of gtk_paint_flat_box for GTK+ 3 and higher. --- .../Eclipse SWT PI/gtk/library/os.c | 28 +++++++++++++++++++++- .../Eclipse SWT PI/gtk/library/os_custom.h | 2 ++ .../Eclipse SWT PI/gtk/library/os_stats.c | 1 + .../Eclipse SWT PI/gtk/library/os_stats.h | 1 + .../gtk/org/eclipse/swt/internal/gtk/OS.java | 19 ++++++++++++++- .../eclipse/swt/internal/theme/ButtonDrawData.java | 4 ++-- .../eclipse/swt/internal/theme/ComboDrawData.java | 2 +- .../org/eclipse/swt/internal/theme/DrawData.java | 12 ++++++++++ .../gtk/org/eclipse/swt/widgets/Shell.java | 10 ++++---- .../gtk/org/eclipse/swt/widgets/Table.java | 2 +- .../gtk/org/eclipse/swt/widgets/Tree.java | 2 +- .../gtk/org/eclipse/swt/widgets/Widget.java | 12 ++++++++++ 12 files changed, 83 insertions(+), 12 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c index 697fca187a..cb1e5307cd 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c @@ -11390,7 +11390,15 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1flat_1box) OS_NATIVE_ENTER(env, that, _1gtk_1paint_1flat_1box_FUNC); if (arg4) if ((lparg4 = getGdkRectangleFields(env, arg4, &_arg4)) == NULL) goto fail; if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail; - gtk_paint_flat_box((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (const gchar *)lparg6, arg7, arg8, arg9, arg10); +/* + gtk_paint_flat_box(arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (const gchar *)lparg6, arg7, arg8, arg9, arg10); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_paint_flat_box) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, GdkWindow *, jint, jint, GdkRectangle *, GtkWidget *, const gchar *, jint, jint, jint, jint))fp)(arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (const gchar *)lparg6, arg7, arg8, arg9, arg10); + } + } fail: if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0); if (arg4 && lparg4) setGdkRectangleFields(env, arg4, lparg4); @@ -12767,6 +12775,24 @@ fail: } #endif +#ifndef NO__1gtk_1render_1frame +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1render_1frame) + (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jdouble arg2, jdouble arg3, jdouble arg4, jdouble arg5) +{ + OS_NATIVE_ENTER(env, that, _1gtk_1render_1frame_FUNC); +/* + gtk_render_frame(arg0, (cairo_t *)arg1, (gdouble)arg2, (gdouble)arg3, (gdouble)arg4, (gdouble)arg5); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_render_frame) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, cairo_t *, gdouble, gdouble, gdouble, gdouble))fp)(arg0, (cairo_t *)arg1, (gdouble)arg2, (gdouble)arg3, (gdouble)arg4, (gdouble)arg5); + } + } + OS_NATIVE_EXIT(env, that, _1gtk_1render_1frame_FUNC); +} +#endif + #ifndef NO__1gtk_1render_1handle JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1render_1handle) (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jdouble arg2, jdouble arg3, jdouble arg4, jdouble arg5) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h index 6ce95cd2f6..fb918382db 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h @@ -304,6 +304,7 @@ #define gtk_paint_handle_LIB LIB_GTK #define gtk_paint_hline_LIB LIB_GTK #define gtk_paint_vline_LIB LIB_GTK +#define gtk_paint_flat_box_LIB LIB_GTK #define gtk_page_setup_get_bottom_margin_LIB LIB_GTK #define gtk_page_setup_get_left_margin_LIB LIB_GTK #define gtk_page_setup_get_orientation_LIB LIB_GTK @@ -375,6 +376,7 @@ #define gtk_printer_is_default_LIB LIB_GTK #define gtk_render_handle_LIB LIB_GTK #define gtk_render_line_LIB LIB_GTK +#define gtk_render_frame_LIB LIB_GTK #define gtk_progress_bar_set_inverted_LIB LIB_GTK #define gtk_progress_bar_set_orientation_LIB LIB_GTK #define ubuntu_menu_proxy_get_LIB LIB_GTK diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c index 39ab44a43a..878e6d7812 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c @@ -951,6 +951,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1rc_1style_1set_1color_1flags", "_1gtk_1rc_1style_1set_1fg", "_1gtk_1rc_1style_1set_1text", + "_1gtk_1render_1frame", "_1gtk_1render_1handle", "_1gtk_1render_1line", "_1gtk_1scale_1new", diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h index 98ce7b032b..40d72c91fd 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h @@ -961,6 +961,7 @@ typedef enum { _1gtk_1rc_1style_1set_1color_1flags_FUNC, _1gtk_1rc_1style_1set_1fg_FUNC, _1gtk_1rc_1style_1set_1text_FUNC, + _1gtk_1render_1frame_FUNC, _1gtk_1render_1handle_FUNC, _1gtk_1render_1line_FUNC, _1gtk_1scale_1new_FUNC, 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 88c34944cc..0bd6d2c121 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 @@ -8537,7 +8537,24 @@ public static final void gtk_paint_handle(long /*int*/ style, long /*int*/ windo } } /** - * @param style cast=(GtkStyle *) + * @method flags=dynamic + * @param cr cast=(cairo_t *) + * @param x cast=(gdouble) + * @param y cast=(gdouble) + * @param width cast=(gdouble) + * @param height cast=(gdouble) + */ +public static final native void _gtk_render_frame(long /*int*/ context, long /*int*/ cr, double x , double y, double width, double height); +public static final void gtk_render_frame(long /*int*/ context, long /*int*/ cr, double x , double y, double width, double height) { + lock.lock(); + try { + _gtk_render_frame(context, cr, x, y, width, height); + } finally { + lock.unlock(); + } +} +/** + * @method flags=dynamic * @param window cast=(GdkWindow *) * @param widget cast=(GtkWidget *) * @param detail cast=(const gchar *) diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/ButtonDrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/ButtonDrawData.java index 6510a285e8..9176d5cbb8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/ButtonDrawData.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/ButtonDrawData.java @@ -60,7 +60,7 @@ void draw(Theme theme, GC gc, Rectangle bounds) { prelight_y = bounds.y + border_width; prelight_width = bounds.width - (2 * border_width); prelight_height = bounds.height - (2 * border_width); - OS.gtk_paint_flat_box(gtkStyle, drawable, OS.GTK_STATE_PRELIGHT, OS.GTK_SHADOW_ETCHED_OUT, null, radioButtonHandle, detail, prelight_x, prelight_y, prelight_width, prelight_height); + gtk_render_frame (gtkStyle, drawable, OS.GTK_STATE_PRELIGHT, OS.GTK_SHADOW_ETCHED_OUT, null, radioButtonHandle, detail, prelight_x, prelight_y, prelight_width, prelight_height); } int state_type = getStateType(DrawData.WIDGET_WHOLE); OS.gtk_paint_option(gtkStyle, drawable, state_type, shadow_type, null, radioButtonHandle, detail, x, y, indicator_size, indicator_size); @@ -107,7 +107,7 @@ void draw(Theme theme, GC gc, Rectangle bounds) { prelight_y = bounds.y + border_width; prelight_width = bounds.width - (2 * border_width); prelight_height = bounds.height - (2 * border_width); - OS.gtk_paint_flat_box(gtkStyle, drawable, OS.GTK_STATE_PRELIGHT, OS.GTK_SHADOW_ETCHED_OUT, null, checkButtonHandle, detail, prelight_x, prelight_y, prelight_width, prelight_height); + gtk_render_frame (gtkStyle, drawable, OS.GTK_STATE_PRELIGHT, OS.GTK_SHADOW_ETCHED_OUT, null, checkButtonHandle, detail, prelight_x, prelight_y, prelight_width, prelight_height); } int state_type = getStateType(DrawData.WIDGET_WHOLE); OS.gtk_paint_check(gtkStyle, drawable, state_type, shadow_type, null, checkButtonHandle, detail, x, y, indicator_size, indicator_size); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/ComboDrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/ComboDrawData.java index 7669e9fa79..dfe64201a5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/ComboDrawData.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/ComboDrawData.java @@ -77,7 +77,7 @@ void draw(Theme theme, GC gc, Rectangle bounds) { width -= 2 * xthickness; height -= 2 * ythickness; detail = Converter.wcsToMbcs(null, "entry_bg", true); - OS.gtk_paint_flat_box(gtkStyle, drawable, state_type, OS.GTK_SHADOW_NONE, null, entryHandle, detail, x, y, width - arrow_button_width, height); + gtk_render_frame (gtkStyle, drawable, state_type, OS.GTK_SHADOW_NONE, null, entryHandle, detail, x, y, width - arrow_button_width, height); if (clientArea != null) { clientArea.x = x; diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/DrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/DrawData.java index f51bdc1c13..f2539a349f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/DrawData.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/DrawData.java @@ -12,6 +12,7 @@ package org.eclipse.swt.internal.theme; import org.eclipse.swt.graphics.*; import org.eclipse.swt.internal.*; +import org.eclipse.swt.internal.cairo.Cairo; import org.eclipse.swt.internal.gtk.*; public class DrawData { @@ -188,4 +189,15 @@ Rectangle measureText(Theme theme, String text, int flags, GC gc, Rectangle boun return new Rectangle(0, 0, OS.PANGO_PIXELS(width[0]), OS.PANGO_PIXELS(height[0])); } +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, context, 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); + } +} + } 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 294d7a030c..fcfc9db3ee 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 @@ -1256,11 +1256,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; - 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]); + 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_frame (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/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java index 956f423d70..f078527b24 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 @@ -2630,7 +2630,7 @@ long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window, long /* 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); + gtk_render_frame (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; } 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 27717fb727..b873d6fc0e 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 @@ -2620,7 +2620,7 @@ long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window, long /* 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); + gtk_render_frame (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; } 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 ed56af4328..3a8ea6bf04 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 @@ -13,6 +13,7 @@ package org.eclipse.swt.widgets; import org.eclipse.swt.*; import org.eclipse.swt.internal.*; +import org.eclipse.swt.internal.cairo.Cairo; import org.eclipse.swt.internal.gtk.*; import org.eclipse.swt.events.*; @@ -2031,4 +2032,15 @@ 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, context, 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); + } +} + } -- cgit v1.2.3