diff options
author | Anatoly Spektor <aspektor@redhat.com> | 2012-09-05 13:51:15 -0400 |
---|---|---|
committer | Anatoly Spektor <aspektor@redhat.com> | 2012-09-05 13:51:15 -0400 |
commit | 4363c9fb71dd4977832f4785d1aef323b0970580 (patch) | |
tree | 738e4454d334ed80e013c40898c73942fab03875 | |
parent | eda05e5e1bfd7a8e6860cccbab7bfcd105765ca8 (diff) | |
download | eclipse.platform.swt-gtk3_render_layout.tar.gz eclipse.platform.swt-gtk3_render_layout.tar.xz eclipse.platform.swt-gtk3_render_layout.zip |
Use gtk_render_layout instead of gtk_paint_layout for GTK+3 and highergtk3_render_layout
This patch implements GTK+ 3 API method gtk_render_layout() instead of
deprecated gtk_paint_layout() for GTK+ 3 and higher.
6 files changed, 97 insertions, 5 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 90c1ebac16..6ac157b50c 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 @@ -11056,7 +11056,15 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1layout) OS_NATIVE_ENTER(env, that, _1gtk_1paint_1layout_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_layout((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (const gchar *)lparg6, arg7, arg8, (PangoLayout *)arg9); +/* + gtk_paint_layout(arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (const gchar *)lparg6, arg7, arg8, (PangoLayout *)arg9); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_paint_layout) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, GdkWindow *, jint, jboolean, GdkRectangle *, GtkWidget *, const gchar *, jint, jint, PangoLayout *))fp)(arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (const gchar *)lparg6, arg7, arg8, (PangoLayout *)arg9); + } + } fail: if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0); if (arg4 && lparg4) setGdkRectangleFields(env, arg4, lparg4); @@ -12317,6 +12325,24 @@ fail: } #endif +#ifndef NO__1gtk_1render_1layout +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1render_1layout) + (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jdouble arg2, jdouble arg3, jintLong arg4) +{ + OS_NATIVE_ENTER(env, that, _1gtk_1render_1layout_FUNC); +/* + gtk_render_layout(arg0, (cairo_t *)arg1, (gdouble)arg2, (gdouble)arg3, (PangoLayout *)arg4); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_render_layout) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, cairo_t *, gdouble, gdouble, PangoLayout *))fp)(arg0, (cairo_t *)arg1, (gdouble)arg2, (gdouble)arg3, (PangoLayout *)arg4); + } + } + OS_NATIVE_EXIT(env, that, _1gtk_1render_1layout_FUNC); +} +#endif + #ifndef NO__1gtk_1scale_1set_1digits JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1scale_1set_1digits) (JNIEnv *env, jclass that, jintLong arg0, jint arg1) @@ -15780,6 +15806,26 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1widget_1get_1style) } #endif +#ifndef NO__1gtk_1widget_1get_1style_1context +JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1widget_1get_1style_1context) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jintLong rc = 0; + OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1style_1context_FUNC); +/* + rc = (jintLong)gtk_widget_get_style_context((GtkWidget *)arg0); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_widget_get_style_context) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GtkWidget *))fp)((GtkWidget *)arg0); + } + } + OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1style_1context_FUNC); + return rc; +} +#endif + #ifndef NO__1gtk_1widget_1get_1tooltip_1text JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1widget_1get_1tooltip_1text) (JNIEnv *env, jclass that, jintLong arg0) 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 09073e9c3e..029af838c3 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 @@ -226,9 +226,12 @@ #define gtk_widget_set_can_focus_LIB LIB_GTK #define gtk_widget_set_mapped_LIB LIB_GTK #define gtk_widget_set_sensitive_LIB LIB_GTK +#define gtk_widget_get_style_context_LIB LIB_GTK #define gtk_widget_set_receives_default_LIB LIB_GTK #define gtk_widget_set_visible_LIB LIB_GTK #define gtk_range_get_slider_range_LIB LIB_GTK +#define gtk_render_layout_LIB LIB_GTK +#define gtk_paint_layout_LIB LIB_GTK #define gdk_pango_context_set_colormap_LIB LIB_GDK #define gdk_x11_screen_get_window_manager_name_LIB LIB_GDK #define gdk_x11_screen_lookup_visual_LIB LIB_GDK 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 119f1c66aa..5025dd3b40 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 @@ -18,8 +18,8 @@ #ifdef NATIVE_STATS -int OS_nativeFunctionCount = 1335; -int OS_nativeFunctionCallCount[1335]; +int OS_nativeFunctionCount = 1337; +int OS_nativeFunctionCallCount[1337]; char * OS_nativeFunctionNames[] = { #ifndef JNI64 "Call__IIII", @@ -938,6 +938,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1rc_1style_1set_1color_1flags", "_1gtk_1rc_1style_1set_1fg", "_1gtk_1rc_1style_1set_1text", + "_1gtk_1render_1layout", "_1gtk_1scale_1set_1digits", "_1gtk_1scale_1set_1draw_1value", "_1gtk_1scrolled_1window_1add_1with_1viewport", @@ -1239,6 +1240,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1widget_1get_1sensitive", "_1gtk_1widget_1get_1size_1request", "_1gtk_1widget_1get_1style", + "_1gtk_1widget_1get_1style_1context", "_1gtk_1widget_1get_1tooltip_1text", "_1gtk_1widget_1get_1toplevel", "_1gtk_1widget_1get_1visible", 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 20250dbe2b..8641f80978 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 @@ -946,6 +946,7 @@ typedef enum { _1gtk_1rc_1style_1set_1color_1flags_FUNC, _1gtk_1rc_1style_1set_1fg_FUNC, _1gtk_1rc_1style_1set_1text_FUNC, + _1gtk_1render_1layout_FUNC, _1gtk_1scale_1set_1digits_FUNC, _1gtk_1scale_1set_1draw_1value_FUNC, _1gtk_1scrolled_1window_1add_1with_1viewport_FUNC, @@ -1247,6 +1248,7 @@ typedef enum { _1gtk_1widget_1get_1sensitive_FUNC, _1gtk_1widget_1get_1size_1request_FUNC, _1gtk_1widget_1get_1style_FUNC, + _1gtk_1widget_1get_1style_1context_FUNC, _1gtk_1widget_1get_1tooltip_1text_FUNC, _1gtk_1widget_1get_1toplevel_FUNC, _1gtk_1widget_1get_1visible_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 c2310b7878..f73837e40f 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 @@ -8377,6 +8377,35 @@ public static final void gtk_paint_box(int /*long*/ style, int /*long*/ window, } } /** + * @method flags=dynamic + * @param widget cast=(GtkWidget *) + */ +public static final native int /*long*/ _gtk_widget_get_style_context(int /*long*/ widget); +public static final int /*long*/ gtk_widget_get_style_context(int /*long*/ widget) { + lock.lock(); + try { + return _gtk_widget_get_style_context(widget); + } finally { + lock.unlock(); + } +} +/** + * @method flags=dynamic + * @param cr cast=(cairo_t *) + * @param x cast=(gdouble) + * @param y cast=(gdouble) + * @param layout cast=(PangoLayout *) + */ +public static final native void _gtk_render_layout(int /*long*/ context, int /*long*/ cr, double x , double y, int /*long*/ layout); +public static final void gtk_render_layout(int /*long*/ context, int /*long*/ cr, double x , double y, int /*long*/ layout) { + lock.lock(); + try { + _gtk_render_layout(context, cr, x, y, layout); + } finally { + lock.unlock(); + } +} +/** * @param style cast=(GtkStyle *) * @param window cast=(GdkWindow *) * @param widget cast=(GtkWidget *) @@ -8452,7 +8481,7 @@ public static final void gtk_paint_hline(int /*long*/ style, int /*long*/ window } } /** - * @param style cast=(GtkStyle *) + * @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/DrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/DrawData.java index 9785073ac0..2220cbdba0 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 @@ -134,7 +134,7 @@ void drawText(Theme theme, String text, int flags, GC gc, Rectangle bounds) { } int state_type = getStateType(DrawData.WIDGET_WHOLE); byte[] detail = Converter.wcsToMbcs(null, "label", true); - OS.gtk_paint_layout(gtkStyle, drawable, state_type, false, null, widget, detail, x, y, layout); + gtk_render_layout(gtkStyle, drawable, state_type, false, null, widget, detail, x, y, layout); OS.g_object_unref(layout); } @@ -188,4 +188,14 @@ 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_layout (int /*long*/ style, int /*long*/ window, int state_type, boolean use_text, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int /*long*/ layout) { + if (OS.GTK_VERSION >= OS.VERSION(3, 0, 0)) { + int /*long*/ cairo = OS.gdk_cairo_create (window); + int /*long*/ context = OS.gtk_widget_get_style_context (style); + OS.gtk_render_layout (context, cairo, x, y, layout); + } else { + OS.gtk_paint_layout(style, window, state_type, use_text, area, widget, detail, x , y, layout); + } +} + } |