diff options
Diffstat (limited to 'bundles/org.eclipse.swt')
36 files changed, 833 insertions, 227 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_custom.h index fd768bada4..87252e2584 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_custom.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_custom.h @@ -44,10 +44,3 @@ #define cairo_pop_group_to_source_LIB LIB_CAIRO #define cairo_region_num_rectangles_LIB LIB_CAIRO #define cairo_region_get_rectangle_LIB LIB_CAIRO - -#if (CAIRO_VERSION < CAIRO_VERSION_ENCODE(1,10,0)) -typedef struct { - int x, y; - int width, height; -} cairo_rectangle_int_t; -#endif 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 b3c423a855..f26899b651 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 @@ -657,6 +657,18 @@ JNIEXPORT jint JNICALL OS_NATIVE(GdkGeometry_1sizeof) } #endif +#ifndef NO_GdkRGBA_1sizeof +JNIEXPORT jint JNICALL OS_NATIVE(GdkRGBA_1sizeof) + (JNIEnv *env, jclass that) +{ + jint rc = 0; + OS_NATIVE_ENTER(env, that, GdkRGBA_1sizeof_FUNC); + rc = (jint)GdkRGBA_sizeof(); + OS_NATIVE_EXIT(env, that, GdkRGBA_1sizeof_FUNC); + return rc; +} +#endif + #ifndef NO_GdkRectangle_1sizeof JNIEXPORT jint JNICALL OS_NATIVE(GdkRectangle_1sizeof) (JNIEnv *env, jclass that) @@ -14465,6 +14477,136 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1status_1icon_1set_1visible) } #endif +#ifndef NO__1gtk_1style_1context_1add_1class +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1context_1add_1class) + (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1) +{ + jbyte *lparg1=NULL; + OS_NATIVE_ENTER(env, that, _1gtk_1style_1context_1add_1class_FUNC); + if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail; +/* + gtk_style_context_add_class(arg0, lparg1); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_style_context_add_class) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jbyte *))fp)(arg0, lparg1); + } + } +fail: + if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); + OS_NATIVE_EXIT(env, that, _1gtk_1style_1context_1add_1class_FUNC); +} +#endif + +#ifndef NO__1gtk_1style_1context_1get_1background_1color +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1context_1get_1background_1color) + (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jobject arg2) +{ + GdkRGBA _arg2, *lparg2=NULL; + OS_NATIVE_ENTER(env, that, _1gtk_1style_1context_1get_1background_1color_FUNC); + if (arg2) if ((lparg2 = getGdkRGBAFields(env, arg2, &_arg2)) == NULL) goto fail; +/* + gtk_style_context_get_background_color(arg0, arg1, lparg2); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_style_context_get_background_color) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jint, GdkRGBA *))fp)(arg0, arg1, lparg2); + } + } +fail: + if (arg2 && lparg2) setGdkRGBAFields(env, arg2, lparg2); + OS_NATIVE_EXIT(env, that, _1gtk_1style_1context_1get_1background_1color_FUNC); +} +#endif + +#ifndef NO__1gtk_1style_1context_1get_1border_1color +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1context_1get_1border_1color) + (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jobject arg2) +{ + GdkRGBA _arg2, *lparg2=NULL; + OS_NATIVE_ENTER(env, that, _1gtk_1style_1context_1get_1border_1color_FUNC); + if (arg2) if ((lparg2 = getGdkRGBAFields(env, arg2, &_arg2)) == NULL) goto fail; +/* + gtk_style_context_get_border_color(arg0, arg1, lparg2); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_style_context_get_border_color) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jint, GdkRGBA *))fp)(arg0, arg1, lparg2); + } + } +fail: + if (arg2 && lparg2) setGdkRGBAFields(env, arg2, lparg2); + OS_NATIVE_EXIT(env, that, _1gtk_1style_1context_1get_1border_1color_FUNC); +} +#endif + +#ifndef NO__1gtk_1style_1context_1get_1color +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1context_1get_1color) + (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jobject arg2) +{ + GdkRGBA _arg2, *lparg2=NULL; + OS_NATIVE_ENTER(env, that, _1gtk_1style_1context_1get_1color_FUNC); + if (arg2) if ((lparg2 = getGdkRGBAFields(env, arg2, &_arg2)) == NULL) goto fail; +/* + gtk_style_context_get_color(arg0, arg1, lparg2); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_style_context_get_color) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jint, GdkRGBA *))fp)(arg0, arg1, lparg2); + } + } +fail: + if (arg2 && lparg2) setGdkRGBAFields(env, arg2, lparg2); + OS_NATIVE_EXIT(env, that, _1gtk_1style_1context_1get_1color_FUNC); +} +#endif + +#ifndef NO__1gtk_1style_1context_1get_1font +JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1style_1context_1get_1font) + (JNIEnv *env, jclass that, jintLong arg0, jint arg1) +{ + jintLong rc = 0; + OS_NATIVE_ENTER(env, that, _1gtk_1style_1context_1get_1font_FUNC); +/* + rc = (jintLong)gtk_style_context_get_font(arg0, arg1); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_style_context_get_font) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong, jint))fp)(arg0, arg1); + } + } + OS_NATIVE_EXIT(env, that, _1gtk_1style_1context_1get_1font_FUNC); + return rc; +} +#endif + +#ifndef NO__1gtk_1style_1context_1get_1padding +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1context_1get_1padding) + (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jobject arg2) +{ + GtkBorder _arg2, *lparg2=NULL; + OS_NATIVE_ENTER(env, that, _1gtk_1style_1context_1get_1padding_FUNC); + if (arg2) if ((lparg2 = getGtkBorderFields(env, arg2, &_arg2)) == NULL) goto fail; +/* + gtk_style_context_get_padding(arg0, arg1, lparg2); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_style_context_get_padding) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jint, GtkBorder *))fp)(arg0, arg1, lparg2); + } + } +fail: + if (arg2 && lparg2) setGtkBorderFields(env, arg2, lparg2); + OS_NATIVE_EXIT(env, that, _1gtk_1style_1context_1get_1padding_FUNC); +} +#endif + #ifndef NO__1gtk_1style_1context_1restore JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1context_1restore) (JNIEnv *env, jclass that, jintLong arg0) @@ -14787,7 +14929,15 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1style_1render_1icon) jintLong rc = 0; OS_NATIVE_ENTER(env, that, _1gtk_1style_1render_1icon_FUNC); if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail; - rc = (jintLong)gtk_style_render_icon((GtkStyle *)arg0, (GtkIconSource *)arg1, arg2, arg3, arg4, (GtkWidget *)arg5, (const gchar *)lparg6); +/* + rc = (jintLong)gtk_style_render_icon(arg0, arg1, arg2, arg3, arg4, arg5, lparg6); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_style_render_icon) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong, jintLong, jint, jint, jint, jintLong, jbyte *))fp)(arg0, arg1, arg2, arg3, arg4, arg5, lparg6); + } + } fail: if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0); OS_NATIVE_EXIT(env, that, _1gtk_1style_1render_1icon_FUNC); @@ -17804,6 +17954,68 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1modify_1style) } #endif +#ifndef NO__1gtk_1widget_1override_1background_1color +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1override_1background_1color) + (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jobject arg2) +{ + GdkRGBA _arg2, *lparg2=NULL; + OS_NATIVE_ENTER(env, that, _1gtk_1widget_1override_1background_1color_FUNC); + if (arg2) if ((lparg2 = getGdkRGBAFields(env, arg2, &_arg2)) == NULL) goto fail; +/* + gtk_widget_override_background_color(arg0, arg1, lparg2); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_widget_override_background_color) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jint, GdkRGBA *))fp)(arg0, arg1, lparg2); + } + } +fail: + if (arg2 && lparg2) setGdkRGBAFields(env, arg2, lparg2); + OS_NATIVE_EXIT(env, that, _1gtk_1widget_1override_1background_1color_FUNC); +} +#endif + +#ifndef NO__1gtk_1widget_1override_1color +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1override_1color) + (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jobject arg2) +{ + GdkRGBA _arg2, *lparg2=NULL; + OS_NATIVE_ENTER(env, that, _1gtk_1widget_1override_1color_FUNC); + if (arg2) if ((lparg2 = getGdkRGBAFields(env, arg2, &_arg2)) == NULL) goto fail; +/* + gtk_widget_override_color(arg0, arg1, lparg2); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_widget_override_color) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jint, GdkRGBA *))fp)(arg0, arg1, lparg2); + } + } +fail: + if (arg2 && lparg2) setGdkRGBAFields(env, arg2, lparg2); + OS_NATIVE_EXIT(env, that, _1gtk_1widget_1override_1color_FUNC); +} +#endif + +#ifndef NO__1gtk_1widget_1override_1font +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1override_1font) + (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) +{ + OS_NATIVE_ENTER(env, that, _1gtk_1widget_1override_1font_FUNC); +/* + gtk_widget_override_font(arg0, arg1); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_widget_override_font) + if (fp) { + ((void (CALLING_CONVENTION*)(jintLong, jintLong))fp)(arg0, arg1); + } + } + OS_NATIVE_EXIT(env, that, _1gtk_1widget_1override_1font_FUNC); +} +#endif + #ifndef NO__1gtk_1widget_1queue_1resize JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1queue_1resize) (JNIEnv *env, jclass that, jintLong arg0) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h index 29c1f7da82..2df56e9d3c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h @@ -156,6 +156,23 @@ #define NO_GTK_1WIDGET_1REQUISITION_1WIDTH #define NO_GtkFixed +#else + +#define NO_GdkRGBA +#define NO__1gtk_1widget_1draw +#define NO__1gtk_1widget_1override_1color +#define NO__1gtk_1widget_1override_1background_1color +#define NO__1gtk_1widget_1override_1font +#define NO__1gtk_1style_1context_1get_1font +#define NO__1gtk_1style_1context_1get_1color +#define NO__1gtk_1style_1context_1get_1background_1color +#define NO__1gtk_1style_1context_1add_1class +#define NO__1gtk_1style_1context_1get_1border_1color +#define NO__1gtk_1style_1context_1get_1padding +#define NO__1gtk_1style_1context_1restore +#define NO__1gtk_1style_1context_1save +#define NO__1gtk_1style_1context_1set_1state + #endif #include "os_custom.h" 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 3adcde311a..3e982f8ca8 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 @@ -269,6 +269,7 @@ #define gtk_style_context_restore_LIB LIB_GTK #define gtk_style_context_save_LIB LIB_GTK #define gtk_style_context_set_state_LIB LIB_GTK +#define gtk_style_render_icon_LIB LIB_GTK #define gtk_hscale_new_LIB LIB_GTK #define gtk_vscale_new_LIB LIB_GTK #define gtk_selection_data_get_data_LIB LIB_GTK @@ -508,6 +509,15 @@ // GTK3 only #define gtk_widget_draw_LIB LIB_GTK +#define gtk_widget_override_color_LIB LIB_GTK +#define gtk_widget_override_background_color_LIB LIB_GTK +#define gtk_widget_override_font_LIB LIB_GTK +#define gtk_style_context_get_font_LIB LIB_GTK +#define gtk_style_context_get_color_LIB LIB_GTK +#define gtk_style_context_get_background_color_LIB LIB_GTK +#define gtk_style_context_add_class_LIB LIB_GTK +#define gtk_style_context_get_border_color_LIB LIB_GTK +#define gtk_style_context_get_padding_LIB LIB_GTK /* Field accessors */ #if GTK_CHECK_VERSION(3,0,0) 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 a61701050f..7e2f0d693a 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 @@ -80,6 +80,7 @@ char * OS_nativeFunctionNames[] = { "GdkEventWindowState_1sizeof", "GdkEvent_1sizeof", "GdkGeometry_1sizeof", + "GdkRGBA_1sizeof", "GdkRectangle_1sizeof", "GdkWindowAttr_1sizeof", "GtkAdjustment_1sizeof", @@ -1032,6 +1033,12 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1status_1icon_1set_1from_1pixbuf", "_1gtk_1status_1icon_1set_1tooltip", "_1gtk_1status_1icon_1set_1visible", + "_1gtk_1style_1context_1add_1class", + "_1gtk_1style_1context_1get_1background_1color", + "_1gtk_1style_1context_1get_1border_1color", + "_1gtk_1style_1context_1get_1color", + "_1gtk_1style_1context_1get_1font", + "_1gtk_1style_1context_1get_1padding", "_1gtk_1style_1context_1restore", "_1gtk_1style_1context_1save", "_1gtk_1style_1context_1set_1state", @@ -1317,6 +1324,9 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1widget_1modify_1bg", "_1gtk_1widget_1modify_1font", "_1gtk_1widget_1modify_1style", + "_1gtk_1widget_1override_1background_1color", + "_1gtk_1widget_1override_1color", + "_1gtk_1widget_1override_1font", "_1gtk_1widget_1queue_1resize", "_1gtk_1widget_1realize", "_1gtk_1widget_1remove_1accelerator", 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 58c65bc762..7ad8b58467 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 @@ -90,6 +90,7 @@ typedef enum { GdkEventWindowState_1sizeof_FUNC, GdkEvent_1sizeof_FUNC, GdkGeometry_1sizeof_FUNC, + GdkRGBA_1sizeof_FUNC, GdkRectangle_1sizeof_FUNC, GdkWindowAttr_1sizeof_FUNC, GtkAdjustment_1sizeof_FUNC, @@ -1042,6 +1043,12 @@ typedef enum { _1gtk_1status_1icon_1set_1from_1pixbuf_FUNC, _1gtk_1status_1icon_1set_1tooltip_FUNC, _1gtk_1status_1icon_1set_1visible_FUNC, + _1gtk_1style_1context_1add_1class_FUNC, + _1gtk_1style_1context_1get_1background_1color_FUNC, + _1gtk_1style_1context_1get_1border_1color_FUNC, + _1gtk_1style_1context_1get_1color_FUNC, + _1gtk_1style_1context_1get_1font_FUNC, + _1gtk_1style_1context_1get_1padding_FUNC, _1gtk_1style_1context_1restore_FUNC, _1gtk_1style_1context_1save_FUNC, _1gtk_1style_1context_1set_1state_FUNC, @@ -1327,6 +1334,9 @@ typedef enum { _1gtk_1widget_1modify_1bg_FUNC, _1gtk_1widget_1modify_1font_FUNC, _1gtk_1widget_1modify_1style_FUNC, + _1gtk_1widget_1override_1background_1color_FUNC, + _1gtk_1widget_1override_1color_FUNC, + _1gtk_1widget_1override_1font_FUNC, _1gtk_1widget_1queue_1resize_FUNC, _1gtk_1widget_1realize_FUNC, _1gtk_1widget_1remove_1accelerator_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_structs.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_structs.c index 1686d21ce4..a8813e21e9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_structs.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_structs.c @@ -1126,6 +1126,46 @@ void setGdkImageFields(JNIEnv *env, jobject lpObject, GdkImage *lpStruct) } #endif +#ifndef NO_GdkRGBA +typedef struct GdkRGBA_FID_CACHE { + int cached; + jclass clazz; + jfieldID red, green, blue, alpha; +} GdkRGBA_FID_CACHE; + +GdkRGBA_FID_CACHE GdkRGBAFc; + +void cacheGdkRGBAFields(JNIEnv *env, jobject lpObject) +{ + if (GdkRGBAFc.cached) return; + GdkRGBAFc.clazz = (*env)->GetObjectClass(env, lpObject); + GdkRGBAFc.red = (*env)->GetFieldID(env, GdkRGBAFc.clazz, "red", "D"); + GdkRGBAFc.green = (*env)->GetFieldID(env, GdkRGBAFc.clazz, "green", "D"); + GdkRGBAFc.blue = (*env)->GetFieldID(env, GdkRGBAFc.clazz, "blue", "D"); + GdkRGBAFc.alpha = (*env)->GetFieldID(env, GdkRGBAFc.clazz, "alpha", "D"); + GdkRGBAFc.cached = 1; +} + +GdkRGBA *getGdkRGBAFields(JNIEnv *env, jobject lpObject, GdkRGBA *lpStruct) +{ + if (!GdkRGBAFc.cached) cacheGdkRGBAFields(env, lpObject); + lpStruct->red = (*env)->GetDoubleField(env, lpObject, GdkRGBAFc.red); + lpStruct->green = (*env)->GetDoubleField(env, lpObject, GdkRGBAFc.green); + lpStruct->blue = (*env)->GetDoubleField(env, lpObject, GdkRGBAFc.blue); + lpStruct->alpha = (*env)->GetDoubleField(env, lpObject, GdkRGBAFc.alpha); + return lpStruct; +} + +void setGdkRGBAFields(JNIEnv *env, jobject lpObject, GdkRGBA *lpStruct) +{ + if (!GdkRGBAFc.cached) cacheGdkRGBAFields(env, lpObject); + (*env)->SetDoubleField(env, lpObject, GdkRGBAFc.red, (jdouble)lpStruct->red); + (*env)->SetDoubleField(env, lpObject, GdkRGBAFc.green, (jdouble)lpStruct->green); + (*env)->SetDoubleField(env, lpObject, GdkRGBAFc.blue, (jdouble)lpStruct->blue); + (*env)->SetDoubleField(env, lpObject, GdkRGBAFc.alpha, (jdouble)lpStruct->alpha); +} +#endif + #ifndef NO_GdkRectangle typedef struct GdkRectangle_FID_CACHE { int cached; diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_structs.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_structs.h index 2b22c726f8..cbea7c290f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_structs.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_structs.h @@ -267,6 +267,18 @@ void setGdkImageFields(JNIEnv *env, jobject lpObject, GdkImage *lpStruct); #define GdkImage_sizeof() 0 #endif +#ifndef NO_GdkRGBA +void cacheGdkRGBAFields(JNIEnv *env, jobject lpObject); +GdkRGBA *getGdkRGBAFields(JNIEnv *env, jobject lpObject, GdkRGBA *lpStruct); +void setGdkRGBAFields(JNIEnv *env, jobject lpObject, GdkRGBA *lpStruct); +#define GdkRGBA_sizeof() sizeof(GdkRGBA) +#else +#define cacheGdkRGBAFields(a,b) +#define getGdkRGBAFields(a,b,c) NULL +#define setGdkRGBAFields(a,b,c) +#define GdkRGBA_sizeof() 0 +#endif + #ifndef NO_GdkRectangle void cacheGdkRectangleFields(JNIEnv *env, jobject lpObject); GdkRectangle *getGdkRectangleFields(JNIEnv *env, jobject lpObject, GdkRectangle *lpStruct); diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkRGBA.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkRGBA.java new file mode 100644 index 0000000000..035de4eaf3 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GdkRGBA.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved. + * The contents of this file are made available under the terms + * of the GNU Lesser General Public License (LGPL) Version 2.1 that + * accompanies this distribution (lgpl-v21.txt). The LGPL is also + * available at http://www.gnu.org/licenses/lgpl.html. If the version + * of the LGPL at http://www.gnu.org is different to the version of + * the LGPL accompanying this distribution and there is any conflict + * between the two license versions, the terms of the LGPL accompanying + * this distribution shall govern. + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.internal.gtk; + + +public class GdkRGBA { + public double red; + public double green; + public double blue; + public double alpha; + public static final int sizeof = OS.GdkRGBA_sizeof(); +} 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 f1ff4f90b2..a80aecf297 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 @@ -378,6 +378,14 @@ public class OS extends C { public static final int GTK_STATE_NORMAL = 0x0; public static final int GTK_STATE_PRELIGHT = 0x2; public static final int GTK_STATE_SELECTED = 0x3; + public static final int GTK_STATE_FLAG_NORMAL = 0; + public static final int GTK_STATE_FLAG_ACTIVE = 1 << 0; + public static final int GTK_STATE_FLAG_PRELIGHT = 1 << 1; + public static final int GTK_STATE_FLAG_SELECTED = 1 << 2; + public static final int GTK_STATE_FLAG_INSENSITIVE = 1 << 3; + public static final int GTK_STATE_FLAG_INCONSISTENT = 1 << 4; + public static final int GTK_STATE_FLAG_FOCUSED = 1 << 5; + public static final int GTK_STATE_FLAG_BACKDROP = 1 << 6; public static final int GTK_TEXT_DIR_LTR = 1; public static final int GTK_TEXT_DIR_NONE = 0 ; public static final int GTK_TEXT_DIR_RTL = 2; @@ -551,6 +559,10 @@ public class OS extends C { public static final byte[] visibility_notify_event = ascii("visibility-notify-event"); public static final byte[] window_state_event = ascii("window-state-event"); + public static final byte[] GTK_STYLE_CLASS_TOOLTIP = ascii("tooltip"); + public static final byte[] GTK_STYLE_CLASS_VIEW = ascii("view"); + public static final byte[] GTK_STYLE_CLASS_CELL = ascii("cell"); + /** Properties */ public static final byte[] active = ascii("active"); public static final byte[] background_gdk = ascii("background-gdk"); @@ -632,6 +644,7 @@ public static final native int GPollFD_sizeof (); public static final native int GTypeInfo_sizeof (); public static final native int GTypeQuery_sizeof (); public static final native int GdkColor_sizeof(); +public static final native int GdkRGBA_sizeof(); public static final native int GdkDragContext_sizeof(); public static final native int GdkEvent_sizeof(); public static final native int GdkEventAny_sizeof(); @@ -10582,6 +10595,66 @@ public static final void gtk_style_get_base(long /*int*/ style, int index, GdkCo } } /** @method flags=dynamic */ +public static final native void _gtk_style_context_add_class(long /*int*/ context, byte[] class_name); +public static final void gtk_style_context_add_class(long /*int*/ context, byte[] class_name) { + lock.lock(); + try { + _gtk_style_context_add_class(context, class_name); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native void _gtk_style_context_get_background_color(long /*int*/ context, int state, GdkRGBA color); +public static final void gtk_style_context_get_background_color(long /*int*/ context, int state, GdkRGBA color) { + lock.lock(); + try { + _gtk_style_context_get_background_color(context, state, color); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native void _gtk_style_context_get_border_color(long /*int*/ context, int state, GdkRGBA color); +public static final void gtk_style_context_get_border_color(long /*int*/ context, int state, GdkRGBA color) { + lock.lock(); + try { + _gtk_style_context_get_border_color(context, state, color); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native void _gtk_style_context_get_color(long /*int*/ context, int state, GdkRGBA color); +public static final void gtk_style_context_get_color(long /*int*/ context, int state, GdkRGBA color) { + lock.lock(); + try { + _gtk_style_context_get_color(context, state, color); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native long /*int*/ _gtk_style_context_get_font(long /*int*/ context, int state); +public static final long /*int*/ gtk_style_context_get_font(long /*int*/ context, int state) { + lock.lock(); + try { + return _gtk_style_context_get_font(context, state); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ +public static final native void _gtk_style_context_get_padding(long /*int*/ context, int state, GtkBorder padding); +public static final void gtk_style_context_get_padding(long /*int*/ context, int state, GtkBorder padding) { + lock.lock(); + try { + _gtk_style_context_get_padding(context, state, padding); + } finally { + lock.unlock(); + } +} +/** @method flags=dynamic */ public static final native void _gtk_style_context_save(long /*int*/ self); public static final void gtk_style_context_save(long /*int*/ self) { lock.lock(); @@ -10849,10 +10922,7 @@ public static final int gtk_style_get_ythickness(long /*int*/ style) { } } /** - * @param style cast=(GtkStyle *) - * @param source cast=(GtkIconSource *) - * @param widget cast=(GtkWidget *) - * @param detail cast=(const gchar *) + * @method flags=dynamic */ public static final native long /*int*/ _gtk_style_render_icon(long /*int*/ style, long /*int*/ source, int direction, int state, int size, long /*int*/ widget, byte[] detail); public static final long /*int*/ gtk_style_render_icon(long /*int*/ style, long /*int*/ source, int direction, int state, int size, long /*int*/ widget, byte[] detail) { @@ -13444,6 +13514,42 @@ public static final void gtk_widget_modify_style(long /*int*/ widget, long /*int lock.unlock(); } } +/** + * @method flags=dynamic + */ +public static final native void _gtk_widget_override_color(long /*int*/ widget, int state, GdkRGBA color); +public static final void gtk_widget_override_color(long /*int*/ widget, int state, GdkRGBA color) { + lock.lock(); + try { + _gtk_widget_override_color(widget, state, color); + } finally { + lock.unlock(); + } +} +/** + * @method flags=dynamic + */ +public static final native void _gtk_widget_override_background_color(long /*int*/ widget, int state, GdkRGBA color); +public static final void gtk_widget_override_background_color(long /*int*/ widget, int state, GdkRGBA color) { + lock.lock(); + try { + _gtk_widget_override_background_color(widget, state, color); + } finally { + lock.unlock(); + } +} +/** + * @method flags=dynamic + */ +public static final native void _gtk_widget_override_font(long /*int*/ widget, long /*int*/ font); +public static final void gtk_widget_override_font(long /*int*/ widget, long /*int*/ font) { + lock.lock(); + try { + _gtk_widget_override_font(widget, font); + } finally { + lock.unlock(); + } +} /** @param widget cast=(GtkWidget *) */ public static final native void _gtk_widget_queue_resize(long /*int*/ widget); public static final void gtk_widget_queue_resize(long /*int*/ widget) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java index ed98be0c0e..f775588828 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java @@ -59,7 +59,6 @@ public final class Printer extends Device { * whether or not a GC was created for this printer */ boolean isGCCreated = false; - Font systemFont; static byte [] settingsData; static int start, end; @@ -386,38 +385,6 @@ static byte [] restoreBytes(String key, boolean nullTerminate) { return valueBuffer; } -/** - * 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_default_style(); - long /*int*/ defaultFont = OS.pango_font_description_copy (OS.gtk_style_get_font_desc (style)); - int size = OS.pango_font_description_get_size(defaultFont); - Point dpi = getDPI(), screenDPI = super.getDPI(); - OS.pango_font_description_set_size(defaultFont, size * dpi.y / screenDPI.y); - return systemFont = Font.gtk_new (this, defaultFont); -} - /** * Invokes platform specific functionality to allocate a new GC handle. * <p> @@ -506,10 +473,6 @@ public void internal_dispose_GC(long /*int*/ hDC, GCData data) { */ protected void release () { super.release(); - - /* Dispose the default font */ - if (systemFont != null) systemFont.dispose (); - systemFont = null; } /** 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 (); |