summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti <silenio>2006-08-22 21:46:35 +0000
committerSilenio Quarti <silenio>2006-08-22 21:46:35 +0000
commit8b32017d20a06a4bdeb19f4c7d0a19c33c875c10 (patch)
treec865544124989644b188397039629e7fef0b5ffb
parent573d46046693aadcae9bdfaf5fccd6473e5d4d03 (diff)
downloadeclipse.platform.swt-8b32017d20a06a4bdeb19f4c7d0a19c33c875c10.tar.gz
eclipse.platform.swt-8b32017d20a06a4bdeb19f4c7d0a19c33c875c10.tar.xz
eclipse.platform.swt-8b32017d20a06a4bdeb19f4c7d0a19c33c875c10.zip
136472 (backport) - GC#drawText doesn't work with arabic text when advance is on
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.cairo.Cairo.properties10
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_structs.c76
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_structs.h12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/cairo_font_extents_t.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c224
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java72
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java134
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java70
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java9
18 files changed, 621 insertions, 86 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.cairo.Cairo.properties b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.cairo.Cairo.properties
index 5804506ac6..fbe53c49e3 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.cairo.Cairo.properties
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.cairo.Cairo.properties
@@ -550,6 +550,8 @@ Cairo_cairo_text_extents_0=cast=(cairo_t *)
Cairo_cairo_text_extents_1=
Cairo_cairo_text_extents_2=cast=cairo_text_extents_t *
+Cairo_cairo_text_extents_t_sizeof=
+
Cairo_cairo_text_path=
Cairo_cairo_text_path_0=cast=(cairo_t *)
Cairo_cairo_text_path_1=
@@ -624,3 +626,11 @@ cairo_path_t_status=
cairo_path_t_data=cast=cairo_path_data_t *
cairo_path_t_num_data=
+org_eclipse_swt_internal_cairo_cairo_1text_1extents_1t=
+cairo_text_extents_t_x_bearing=
+cairo_text_extents_t_y_bearing=
+cairo_text_extents_t_width=
+cairo_text_extents_t_height=
+cairo_text_extents_t_x_advance=
+cairo_text_extents_t_y_advance=
+
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties
index e3417ae4ed..371065bfdd 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties
@@ -1301,6 +1301,14 @@ OS__gdk_bitmap_create_from_data_1=cast=(const gchar *),flags=no_out critical
OS__gdk_bitmap_create_from_data_2=cast=(gint)
OS__gdk_bitmap_create_from_data_3=cast=(gint)
+OS__gdk_cairo_region=flags=dynamic
+OS__gdk_cairo_region_0=
+OS__gdk_cairo_region_1=
+
+OS__gdk_cairo_set_source_color=flags=dynamic
+OS__gdk_cairo_set_source_color_0=
+OS__gdk_cairo_set_source_color_1=
+
OS__gdk_color_white=
OS__gdk_color_white_0=cast=(GdkColormap *)
OS__gdk_color_white_1=cast=(GdkColor *),flags=no_in
@@ -4424,6 +4432,24 @@ OS__pango_attr_underline_new_0=
OS__pango_attr_weight_new=
OS__pango_attr_weight_new_0=
+OS__pango_cairo_create_layout=flags=dynamic
+OS__pango_cairo_create_layout_0=
+
+OS__pango_cairo_font_map_create_context=flags=dynamic
+OS__pango_cairo_font_map_create_context_0=
+
+OS__pango_cairo_font_map_get_default=flags=dynamic
+
+OS__pango_cairo_font_map_new=flags=dynamic
+
+OS__pango_cairo_layout_path=flags=dynamic
+OS__pango_cairo_layout_path_0=
+OS__pango_cairo_layout_path_1=
+
+OS__pango_cairo_show_layout=flags=dynamic
+OS__pango_cairo_show_layout_0=
+OS__pango_cairo_show_layout_1=
+
OS__pango_context_get_base_dir=
OS__pango_context_get_base_dir_0=cast=(PangoContext *)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c
index 69e7533fde..6bfb614e7a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo.c
@@ -1514,18 +1514,33 @@ JNIEXPORT jint JNICALL Cairo_NATIVE(cairo_1surface_1set_1user_1data)
#ifndef NO_cairo_1text_1extents
JNIEXPORT void JNICALL Cairo_NATIVE(cairo_1text_1extents)
- (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jobject arg2)
{
jbyte *lparg1=NULL;
+ cairo_text_extents_t _arg2, *lparg2=NULL;
Cairo_NATIVE_ENTER(env, that, cairo_1text_1extents_FUNC);
if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
- cairo_text_extents((cairo_t *)arg0, lparg1, (cairo_text_extents_t *)arg2);
+ if (arg2) if ((lparg2 = getcairo_text_extents_tFields(env, arg2, &_arg2)) == NULL) goto fail;
+ cairo_text_extents((cairo_t *)arg0, lparg1, (cairo_text_extents_t *)lparg2);
fail:
+ if (arg2 && lparg2) setcairo_text_extents_tFields(env, arg2, lparg2);
if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
Cairo_NATIVE_EXIT(env, that, cairo_1text_1extents_FUNC);
}
#endif
+#ifndef NO_cairo_1text_1extents_1t_1sizeof
+JNIEXPORT jint JNICALL Cairo_NATIVE(cairo_1text_1extents_1t_1sizeof)
+ (JNIEnv *env, jclass that)
+{
+ jint rc = 0;
+ Cairo_NATIVE_ENTER(env, that, cairo_1text_1extents_1t_1sizeof_FUNC);
+ rc = (jint)cairo_text_extents_t_sizeof();
+ Cairo_NATIVE_EXIT(env, that, cairo_1text_1extents_1t_1sizeof_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_cairo_1text_1path
JNIEXPORT void JNICALL Cairo_NATIVE(cairo_1text_1path)
(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c
index 9259eaa0e4..fbf5ba2683 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.c
@@ -24,8 +24,8 @@
#ifdef NATIVE_STATS
-int Cairo_nativeFunctionCount = 138;
-int Cairo_nativeFunctionCallCount[138];
+int Cairo_nativeFunctionCount = 139;
+int Cairo_nativeFunctionCallCount[139];
char * Cairo_nativeFunctionNames[] = {
"cairo_1append_1path",
"cairo_1arc",
@@ -154,6 +154,7 @@ char * Cairo_nativeFunctionNames[] = {
"cairo_1surface_1set_1device_1offset",
"cairo_1surface_1set_1user_1data",
"cairo_1text_1extents",
+ "cairo_1text_1extents_1t_1sizeof",
"cairo_1text_1path",
"cairo_1transform",
"cairo_1translate",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h
index 12eb248e9b..f9a920041b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_stats.h
@@ -158,6 +158,7 @@ typedef enum {
cairo_1surface_1set_1device_1offset_FUNC,
cairo_1surface_1set_1user_1data_FUNC,
cairo_1text_1extents_FUNC,
+ cairo_1text_1extents_1t_1sizeof_FUNC,
cairo_1text_1path_FUNC,
cairo_1transform_FUNC,
cairo_1translate_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_structs.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_structs.c
index 4eaa020d1c..4e9e9f6a07 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_structs.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_structs.c
@@ -35,33 +35,33 @@ void cachecairo_font_extents_tFields(JNIEnv *env, jobject lpObject)
{
if (cairo_font_extents_tFc.cached) return;
cairo_font_extents_tFc.clazz = (*env)->GetObjectClass(env, lpObject);
- cairo_font_extents_tFc.ascent = (*env)->GetFieldID(env, cairo_font_extents_tFc.clazz, "ascent", "F");
- cairo_font_extents_tFc.descent = (*env)->GetFieldID(env, cairo_font_extents_tFc.clazz, "descent", "F");
- cairo_font_extents_tFc.height = (*env)->GetFieldID(env, cairo_font_extents_tFc.clazz, "height", "F");
- cairo_font_extents_tFc.max_x_advance = (*env)->GetFieldID(env, cairo_font_extents_tFc.clazz, "max_x_advance", "F");
- cairo_font_extents_tFc.max_y_advance = (*env)->GetFieldID(env, cairo_font_extents_tFc.clazz, "max_y_advance", "F");
+ cairo_font_extents_tFc.ascent = (*env)->GetFieldID(env, cairo_font_extents_tFc.clazz, "ascent", "D");
+ cairo_font_extents_tFc.descent = (*env)->GetFieldID(env, cairo_font_extents_tFc.clazz, "descent", "D");
+ cairo_font_extents_tFc.height = (*env)->GetFieldID(env, cairo_font_extents_tFc.clazz, "height", "D");
+ cairo_font_extents_tFc.max_x_advance = (*env)->GetFieldID(env, cairo_font_extents_tFc.clazz, "max_x_advance", "D");
+ cairo_font_extents_tFc.max_y_advance = (*env)->GetFieldID(env, cairo_font_extents_tFc.clazz, "max_y_advance", "D");
cairo_font_extents_tFc.cached = 1;
}
cairo_font_extents_t *getcairo_font_extents_tFields(JNIEnv *env, jobject lpObject, cairo_font_extents_t *lpStruct)
{
if (!cairo_font_extents_tFc.cached) cachecairo_font_extents_tFields(env, lpObject);
- lpStruct->ascent = (*env)->GetFloatField(env, lpObject, cairo_font_extents_tFc.ascent);
- lpStruct->descent = (*env)->GetFloatField(env, lpObject, cairo_font_extents_tFc.descent);
- lpStruct->height = (*env)->GetFloatField(env, lpObject, cairo_font_extents_tFc.height);
- lpStruct->max_x_advance = (*env)->GetFloatField(env, lpObject, cairo_font_extents_tFc.max_x_advance);
- lpStruct->max_y_advance = (*env)->GetFloatField(env, lpObject, cairo_font_extents_tFc.max_y_advance);
+ lpStruct->ascent = (*env)->GetDoubleField(env, lpObject, cairo_font_extents_tFc.ascent);
+ lpStruct->descent = (*env)->GetDoubleField(env, lpObject, cairo_font_extents_tFc.descent);
+ lpStruct->height = (*env)->GetDoubleField(env, lpObject, cairo_font_extents_tFc.height);
+ lpStruct->max_x_advance = (*env)->GetDoubleField(env, lpObject, cairo_font_extents_tFc.max_x_advance);
+ lpStruct->max_y_advance = (*env)->GetDoubleField(env, lpObject, cairo_font_extents_tFc.max_y_advance);
return lpStruct;
}
void setcairo_font_extents_tFields(JNIEnv *env, jobject lpObject, cairo_font_extents_t *lpStruct)
{
if (!cairo_font_extents_tFc.cached) cachecairo_font_extents_tFields(env, lpObject);
- (*env)->SetFloatField(env, lpObject, cairo_font_extents_tFc.ascent, (jfloat)lpStruct->ascent);
- (*env)->SetFloatField(env, lpObject, cairo_font_extents_tFc.descent, (jfloat)lpStruct->descent);
- (*env)->SetFloatField(env, lpObject, cairo_font_extents_tFc.height, (jfloat)lpStruct->height);
- (*env)->SetFloatField(env, lpObject, cairo_font_extents_tFc.max_x_advance, (jfloat)lpStruct->max_x_advance);
- (*env)->SetFloatField(env, lpObject, cairo_font_extents_tFc.max_y_advance, (jfloat)lpStruct->max_y_advance);
+ (*env)->SetDoubleField(env, lpObject, cairo_font_extents_tFc.ascent, (jdouble)lpStruct->ascent);
+ (*env)->SetDoubleField(env, lpObject, cairo_font_extents_tFc.descent, (jdouble)lpStruct->descent);
+ (*env)->SetDoubleField(env, lpObject, cairo_font_extents_tFc.height, (jdouble)lpStruct->height);
+ (*env)->SetDoubleField(env, lpObject, cairo_font_extents_tFc.max_x_advance, (jdouble)lpStruct->max_x_advance);
+ (*env)->SetDoubleField(env, lpObject, cairo_font_extents_tFc.max_y_advance, (jdouble)lpStruct->max_y_advance);
}
#endif
@@ -136,3 +136,49 @@ void setcairo_path_tFields(JNIEnv *env, jobject lpObject, cairo_path_t *lpStruct
}
#endif
+#ifndef NO_cairo_text_extents_t
+typedef struct cairo_text_extents_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID x_bearing, y_bearing, width, height, x_advance, y_advance;
+} cairo_text_extents_t_FID_CACHE;
+
+cairo_text_extents_t_FID_CACHE cairo_text_extents_tFc;
+
+void cachecairo_text_extents_tFields(JNIEnv *env, jobject lpObject)
+{
+ if (cairo_text_extents_tFc.cached) return;
+ cairo_text_extents_tFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ cairo_text_extents_tFc.x_bearing = (*env)->GetFieldID(env, cairo_text_extents_tFc.clazz, "x_bearing", "D");
+ cairo_text_extents_tFc.y_bearing = (*env)->GetFieldID(env, cairo_text_extents_tFc.clazz, "y_bearing", "D");
+ cairo_text_extents_tFc.width = (*env)->GetFieldID(env, cairo_text_extents_tFc.clazz, "width", "D");
+ cairo_text_extents_tFc.height = (*env)->GetFieldID(env, cairo_text_extents_tFc.clazz, "height", "D");
+ cairo_text_extents_tFc.x_advance = (*env)->GetFieldID(env, cairo_text_extents_tFc.clazz, "x_advance", "D");
+ cairo_text_extents_tFc.y_advance = (*env)->GetFieldID(env, cairo_text_extents_tFc.clazz, "y_advance", "D");
+ cairo_text_extents_tFc.cached = 1;
+}
+
+cairo_text_extents_t *getcairo_text_extents_tFields(JNIEnv *env, jobject lpObject, cairo_text_extents_t *lpStruct)
+{
+ if (!cairo_text_extents_tFc.cached) cachecairo_text_extents_tFields(env, lpObject);
+ lpStruct->x_bearing = (*env)->GetDoubleField(env, lpObject, cairo_text_extents_tFc.x_bearing);
+ lpStruct->y_bearing = (*env)->GetDoubleField(env, lpObject, cairo_text_extents_tFc.y_bearing);
+ lpStruct->width = (*env)->GetDoubleField(env, lpObject, cairo_text_extents_tFc.width);
+ lpStruct->height = (*env)->GetDoubleField(env, lpObject, cairo_text_extents_tFc.height);
+ lpStruct->x_advance = (*env)->GetDoubleField(env, lpObject, cairo_text_extents_tFc.x_advance);
+ lpStruct->y_advance = (*env)->GetDoubleField(env, lpObject, cairo_text_extents_tFc.y_advance);
+ return lpStruct;
+}
+
+void setcairo_text_extents_tFields(JNIEnv *env, jobject lpObject, cairo_text_extents_t *lpStruct)
+{
+ if (!cairo_text_extents_tFc.cached) cachecairo_text_extents_tFields(env, lpObject);
+ (*env)->SetDoubleField(env, lpObject, cairo_text_extents_tFc.x_bearing, (jdouble)lpStruct->x_bearing);
+ (*env)->SetDoubleField(env, lpObject, cairo_text_extents_tFc.y_bearing, (jdouble)lpStruct->y_bearing);
+ (*env)->SetDoubleField(env, lpObject, cairo_text_extents_tFc.width, (jdouble)lpStruct->width);
+ (*env)->SetDoubleField(env, lpObject, cairo_text_extents_tFc.height, (jdouble)lpStruct->height);
+ (*env)->SetDoubleField(env, lpObject, cairo_text_extents_tFc.x_advance, (jdouble)lpStruct->x_advance);
+ (*env)->SetDoubleField(env, lpObject, cairo_text_extents_tFc.y_advance, (jdouble)lpStruct->y_advance);
+}
+#endif
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_structs.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_structs.h
index baa1fc49fc..10997168b8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_structs.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/library/cairo_structs.h
@@ -57,3 +57,15 @@ void setcairo_path_tFields(JNIEnv *env, jobject lpObject, cairo_path_t *lpStruct
#define cairo_path_t_sizeof() 0
#endif
+#ifndef NO_cairo_text_extents_t
+void cachecairo_text_extents_tFields(JNIEnv *env, jobject lpObject);
+cairo_text_extents_t *getcairo_text_extents_tFields(JNIEnv *env, jobject lpObject, cairo_text_extents_t *lpStruct);
+void setcairo_text_extents_tFields(JNIEnv *env, jobject lpObject, cairo_text_extents_t *lpStruct);
+#define cairo_text_extents_t_sizeof() sizeof(cairo_text_extents_t)
+#else
+#define cachecairo_text_extents_tFields(a,b)
+#define getcairo_text_extents_tFields(a,b,c) NULL
+#define setcairo_text_extents_tFields(a,b,c)
+#define cairo_text_extents_t_sizeof() 0
+#endif
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java
index 03ae87f4d6..7f1806a311 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/Cairo.java
@@ -89,6 +89,7 @@ public class Cairo {
public static final synchronized native int cairo_font_extents_t_sizeof ();
public static final synchronized native int cairo_path_data_t_sizeof ();
public static final synchronized native int cairo_path_t_sizeof ();
+public static final synchronized native int cairo_text_extents_t_sizeof ();
/** Natives */
public static final synchronized native int /*long*/ cairo_create (int /*long*/ target);
@@ -163,7 +164,7 @@ public static final synchronized native void cairo_show_glyphs (int /*long*/ cr,
public static final synchronized native int /*long*/ cairo_get_font_face (int /*long*/ cr);
public static final synchronized native void cairo_font_extents (int /*long*/ cr, cairo_font_extents_t extents);
public static final synchronized native void cairo_set_font_face (int /*long*/ cr, int /*long*/ font_face);
-public static final synchronized native void cairo_text_extents (int /*long*/ cr, byte[] utf8, int /*long*/ extents);
+public static final synchronized native void cairo_text_extents (int /*long*/ cr, byte[] utf8, cairo_text_extents_t extents);
public static final synchronized native void cairo_glyph_extents (int /*long*/ cr, int /*long*/ glyphs, int num_glyphs, int /*long*/ extents);
public static final synchronized native void cairo_text_path (int /*long*/ cr, byte[] utf8);
public static final synchronized native void cairo_glyph_path (int /*long*/ cr, int /*long*/ glyphs, int num_glyphs);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/cairo_font_extents_t.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/cairo_font_extents_t.java
index 326215a67a..3acd4a952e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/cairo_font_extents_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cairo/org/eclipse/swt/internal/cairo/cairo_font_extents_t.java
@@ -22,10 +22,10 @@ package org.eclipse.swt.internal.cairo;
public class cairo_font_extents_t {
- public float ascent;
- public float descent;
- public float height;
- public float max_x_advance;
- public float max_y_advance;
+ public double ascent;
+ public double descent;
+ public double height;
+ public double max_x_advance;
+ public double max_y_advance;
public static final int sizeof = Cairo.cairo_font_extents_t_sizeof();
}
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 5bded3796e..80f8aa3d71 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
@@ -3413,6 +3413,62 @@ fail:
}
#endif
+#ifndef NO__1gdk_1cairo_1region
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1cairo_1region)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ OS_NATIVE_ENTER(env, that, _1gdk_1cairo_1region_FUNC);
+/*
+ gdk_cairo_region(arg0, arg1);
+*/
+ {
+ static int initialized = 0;
+ static void *handle = NULL;
+ typedef void (*FPTR)(jint, jint);
+ static FPTR fptr;
+ if (!initialized) {
+ if (!handle) handle = dlopen(gdk_cairo_region_LIB, RTLD_LAZY);
+ if (handle) fptr = (FPTR)dlsym(handle, "gdk_cairo_region");
+ initialized = 1;
+ }
+ if (fptr) {
+ (*fptr)(arg0, arg1);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1gdk_1cairo_1region_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1cairo_1set_1source_1color
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1cairo_1set_1source_1color)
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ GdkColor _arg1, *lparg1=NULL;
+ OS_NATIVE_ENTER(env, that, _1gdk_1cairo_1set_1source_1color_FUNC);
+ if (arg1) if ((lparg1 = getGdkColorFields(env, arg1, &_arg1)) == NULL) goto fail;
+/*
+ gdk_cairo_set_source_color(arg0, lparg1);
+*/
+ {
+ static int initialized = 0;
+ static void *handle = NULL;
+ typedef void (*FPTR)(jint, GdkColor *);
+ static FPTR fptr;
+ if (!initialized) {
+ if (!handle) handle = dlopen(gdk_cairo_set_source_color_LIB, RTLD_LAZY);
+ if (handle) fptr = (FPTR)dlsym(handle, "gdk_cairo_set_source_color");
+ initialized = 1;
+ }
+ if (fptr) {
+ (*fptr)(arg0, lparg1);
+ }
+ }
+fail:
+ if (arg1 && lparg1) setGdkColorFields(env, arg1, lparg1);
+ OS_NATIVE_EXIT(env, that, _1gdk_1cairo_1set_1source_1color_FUNC);
+}
+#endif
+
#ifndef NO__1gdk_1color_1white
JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1color_1white)
(JNIEnv *env, jclass that, jint arg0, jobject arg1)
@@ -12687,6 +12743,174 @@ JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1attr_1weight_1new)
}
#endif
+#ifndef NO__1pango_1cairo_1create_1layout
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1cairo_1create_1layout)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, _1pango_1cairo_1create_1layout_FUNC);
+/*
+ rc = (jint)pango_cairo_create_layout(arg0);
+*/
+ {
+ static int initialized = 0;
+ static void *handle = NULL;
+ typedef jint (*FPTR)(jint);
+ static FPTR fptr;
+ rc = 0;
+ if (!initialized) {
+ if (!handle) handle = dlopen(pango_cairo_create_layout_LIB, RTLD_LAZY);
+ if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_create_layout");
+ initialized = 1;
+ }
+ if (fptr) {
+ rc = (jint)(*fptr)(arg0);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1pango_1cairo_1create_1layout_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1pango_1cairo_1font_1map_1create_1context
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1cairo_1font_1map_1create_1context)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, _1pango_1cairo_1font_1map_1create_1context_FUNC);
+/*
+ rc = (jint)pango_cairo_font_map_create_context(arg0);
+*/
+ {
+ static int initialized = 0;
+ static void *handle = NULL;
+ typedef jint (*FPTR)(jint);
+ static FPTR fptr;
+ rc = 0;
+ if (!initialized) {
+ if (!handle) handle = dlopen(pango_cairo_font_map_create_context_LIB, RTLD_LAZY);
+ if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_font_map_create_context");
+ initialized = 1;
+ }
+ if (fptr) {
+ rc = (jint)(*fptr)(arg0);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1pango_1cairo_1font_1map_1create_1context_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1pango_1cairo_1font_1map_1get_1default
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1cairo_1font_1map_1get_1default)
+ (JNIEnv *env, jclass that)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, _1pango_1cairo_1font_1map_1get_1default_FUNC);
+/*
+ rc = (jint)pango_cairo_font_map_get_default();
+*/
+ {
+ static int initialized = 0;
+ static void *handle = NULL;
+ typedef jint (*FPTR)();
+ static FPTR fptr;
+ rc = 0;
+ if (!initialized) {
+ if (!handle) handle = dlopen(pango_cairo_font_map_get_default_LIB, RTLD_LAZY);
+ if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_font_map_get_default");
+ initialized = 1;
+ }
+ if (fptr) {
+ rc = (jint)(*fptr)();
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1pango_1cairo_1font_1map_1get_1default_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1pango_1cairo_1font_1map_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1cairo_1font_1map_1new)
+ (JNIEnv *env, jclass that)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, _1pango_1cairo_1font_1map_1new_FUNC);
+/*
+ rc = (jint)pango_cairo_font_map_new();
+*/
+ {
+ static int initialized = 0;
+ static void *handle = NULL;
+ typedef jint (*FPTR)();
+ static FPTR fptr;
+ rc = 0;
+ if (!initialized) {
+ if (!handle) handle = dlopen(pango_cairo_font_map_new_LIB, RTLD_LAZY);
+ if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_font_map_new");
+ initialized = 1;
+ }
+ if (fptr) {
+ rc = (jint)(*fptr)();
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1pango_1cairo_1font_1map_1new_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1pango_1cairo_1layout_1path
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1cairo_1layout_1path)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ OS_NATIVE_ENTER(env, that, _1pango_1cairo_1layout_1path_FUNC);
+/*
+ pango_cairo_layout_path(arg0, arg1);
+*/
+ {
+ static int initialized = 0;
+ static void *handle = NULL;
+ typedef void (*FPTR)(jint, jint);
+ static FPTR fptr;
+ if (!initialized) {
+ if (!handle) handle = dlopen(pango_cairo_layout_path_LIB, RTLD_LAZY);
+ if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_layout_path");
+ initialized = 1;
+ }
+ if (fptr) {
+ (*fptr)(arg0, arg1);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1pango_1cairo_1layout_1path_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1cairo_1show_1layout
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1cairo_1show_1layout)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ OS_NATIVE_ENTER(env, that, _1pango_1cairo_1show_1layout_FUNC);
+/*
+ pango_cairo_show_layout(arg0, arg1);
+*/
+ {
+ static int initialized = 0;
+ static void *handle = NULL;
+ typedef void (*FPTR)(jint, jint);
+ static FPTR fptr;
+ if (!initialized) {
+ if (!handle) handle = dlopen(pango_cairo_show_layout_LIB, RTLD_LAZY);
+ if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_show_layout");
+ initialized = 1;
+ }
+ if (fptr) {
+ (*fptr)(arg0, arg1);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1pango_1cairo_1show_1layout_FUNC);
+}
+#endif
+
#ifndef NO__1pango_1context_1get_1base_1dir
JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1context_1get_1base_1dir)
(JNIEnv *env, jclass that, jint 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 0c0cc0d015..6f100522d5 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
@@ -72,6 +72,14 @@
#define gdk_x11_screen_lookup_visual_LIB "libgdk-x11-2.0.so.0"
#define atk_object_add_relationship_LIB "libatk-1.0.so.0"
#define pango_layout_set_auto_dir_LIB "libpango-1.0.so.0"
+#define pango_cairo_create_layout_LIB "libpangocairo-1.0.so.0"
+#define pango_cairo_layout_path_LIB "libpangocairo-1.0.so.0"
+#define pango_cairo_show_layout_LIB "libpangocairo-1.0.so.0"
+#define pango_cairo_font_map_create_context_LIB "libpangocairo-1.0.so.0"
+#define pango_cairo_font_map_new_LIB "libpangocairo-1.0.so.0"
+#define pango_cairo_font_map_get_default_LIB "libpangocairo-1.0.so.0"
+#define gdk_cairo_set_source_color_LIB "libgdk-x11-2.0.so.0"
+#define gdk_cairo_region_LIB "libgdk-x11-2.0.so.0"
/* Field accessors */
#define GTK_ACCEL_LABEL_SET_ACCEL_STRING(arg0, arg1) (arg0)->accel_string = arg1
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 86d770dc7a..6506d681cb 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 = 1107;
-int OS_nativeFunctionCallCount[1107];
+int OS_nativeFunctionCount = 1115;
+int OS_nativeFunctionCallCount[1115];
char * OS_nativeFunctionNames[] = {
"Call",
"GDK_1EVENT_1TYPE",
@@ -271,6 +271,8 @@ char * OS_nativeFunctionNames[] = {
"_1gdk_1atom_1name",
"_1gdk_1beep",
"_1gdk_1bitmap_1create_1from_1data",
+ "_1gdk_1cairo_1region",
+ "_1gdk_1cairo_1set_1source_1color",
"_1gdk_1color_1white",
"_1gdk_1colormap_1alloc_1color",
"_1gdk_1colormap_1free_1colors",
@@ -987,6 +989,12 @@ char * OS_nativeFunctionNames[] = {
"_1pango_1attr_1strikethrough_1new",
"_1pango_1attr_1underline_1new",
"_1pango_1attr_1weight_1new",
+ "_1pango_1cairo_1create_1layout",
+ "_1pango_1cairo_1font_1map_1create_1context",
+ "_1pango_1cairo_1font_1map_1get_1default",
+ "_1pango_1cairo_1font_1map_1new",
+ "_1pango_1cairo_1layout_1path",
+ "_1pango_1cairo_1show_1layout",
"_1pango_1context_1get_1base_1dir",
"_1pango_1context_1get_1language",
"_1pango_1context_1get_1metrics",
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 f80358f924..da77391dd4 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
@@ -275,6 +275,8 @@ typedef enum {
_1gdk_1atom_1name_FUNC,
_1gdk_1beep_FUNC,
_1gdk_1bitmap_1create_1from_1data_FUNC,
+ _1gdk_1cairo_1region_FUNC,
+ _1gdk_1cairo_1set_1source_1color_FUNC,
_1gdk_1color_1white_FUNC,
_1gdk_1colormap_1alloc_1color_FUNC,
_1gdk_1colormap_1free_1colors_FUNC,
@@ -991,6 +993,12 @@ typedef enum {
_1pango_1attr_1strikethrough_1new_FUNC,
_1pango_1attr_1underline_1new_FUNC,
_1pango_1attr_1weight_1new_FUNC,
+ _1pango_1cairo_1create_1layout_FUNC,
+ _1pango_1cairo_1font_1map_1create_1context_FUNC,
+ _1pango_1cairo_1font_1map_1get_1default_FUNC,
+ _1pango_1cairo_1font_1map_1new_FUNC,
+ _1pango_1cairo_1layout_1path_FUNC,
+ _1pango_1cairo_1show_1layout_FUNC,
_1pango_1context_1get_1base_1dir_FUNC,
_1pango_1context_1get_1language_FUNC,
_1pango_1context_1get_1metrics_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 c401dc1eae..d8e85d6166 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
@@ -2178,6 +2178,24 @@ public static final int /*long*/ gdk_bitmap_create_from_data(int /*long*/ window
lock.unlock();
}
}
+public static final native void _gdk_cairo_region(int /*long*/ cairo, int /*long*/ region);
+public static final void gdk_cairo_region(int /*long*/ cairo, int /*long*/ region) {
+ lock.lock();
+ try {
+ _gdk_cairo_region(cairo, region);
+ } finally {
+ lock.unlock();
+ }
+}
+public static final native void _gdk_cairo_set_source_color(int /*long*/ cairo, GdkColor color);
+public static final void gdk_cairo_set_source_color(int /*long*/ cairo, GdkColor color) {
+ lock.lock();
+ try {
+ _gdk_cairo_set_source_color(cairo, color);
+ } finally {
+ lock.unlock();
+ }
+}
public static final native boolean _gdk_color_white(int /*long*/ colormap, GdkColor color);
public static final boolean gdk_color_white(int /*long*/ colormap, GdkColor color) {
lock.lock();
@@ -8581,6 +8599,60 @@ public static final int /*long*/ pango_attr_weight_new(int weight) {
lock.unlock();
}
}
+public static final native int /*long*/ _pango_cairo_font_map_get_default();
+public static final int /*long*/ pango_cairo_font_map_get_default() {
+ lock.lock();
+ try {
+ return _pango_cairo_font_map_get_default();
+ } finally {
+ lock.unlock();
+ }
+}
+public static final native int /*long*/ _pango_cairo_font_map_new();
+public static final int /*long*/ pango_cairo_font_map_new() {
+ lock.lock();
+ try {
+ return _pango_cairo_font_map_new();
+ } finally {
+ lock.unlock();
+ }
+}
+public static final native int /*long*/ _pango_cairo_font_map_create_context(int /*long*/ fontmap);
+public static final int /*long*/ pango_cairo_font_map_create_context(int /*long*/ fontmap) {
+ lock.lock();
+ try {
+ return _pango_cairo_font_map_create_context(fontmap);
+ } finally {
+ lock.unlock();
+ }
+}
+public static final native int /*long*/ _pango_cairo_create_layout(int /*long*/ cairo);
+public static final int /*long*/ pango_cairo_create_layout(int /*long*/ cairo) {
+ lock.lock();
+ try {
+ return _pango_cairo_create_layout(cairo);
+ } finally {
+ lock.unlock();
+ }
+}
+public static final native void _pango_cairo_layout_path(int /*long*/ cairo, int /*long*/ layout);
+public static final void pango_cairo_layout_path(int /*long*/ cairo, int /*long*/ layout) {
+ lock.lock();
+ try {
+ _pango_cairo_layout_path(cairo, layout);
+ } finally {
+ lock.unlock();
+ }
+}
+public static final native void _pango_cairo_show_layout(int /*long*/ cairo, int /*long*/ layout);
+public static final void pango_cairo_show_layout(int /*long*/ cairo, int /*long*/ layout) {
+ lock.lock();
+ try {
+ _pango_cairo_show_layout(cairo, layout);
+ } finally {
+ lock.unlock();
+ }
+}
public static final native int _pango_context_get_base_dir(int /*long*/ context);
public static final int pango_context_get_base_dir(int /*long*/ context) {
lock.lock();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java
index 3e928df842..735dd5eebe 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java
@@ -185,13 +185,7 @@ public void addString(String string, float x, float y, Font font) {
if (font == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
move = false;
- GC.setCairoFont(handle, font);
- cairo_font_extents_t extents = new cairo_font_extents_t();
- Cairo.cairo_font_extents(handle, extents);
- double baseline = y + extents.ascent;
- Cairo.cairo_move_to(handle, x, baseline);
- byte[] buffer = Converter.wcsToMbcs(null, string, true);
- Cairo.cairo_text_path(handle, buffer);
+ GC.addCairoString(handle, string, x, y, font);
}
/**
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 41dbb7248b..cbe5b6d33d 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
@@ -137,6 +137,26 @@ public GC(Drawable drawable, int style) {
if (device.tracking) device.new_Object(this);
}
+static void addCairoString(int /*long*/ cairo, String string, float x, float y, Font font) {
+ byte[] buffer = Converter.wcsToMbcs(null, string, true);
+ if (OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+ int /*long*/ layout = OS.pango_cairo_create_layout(cairo);
+ if (layout == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ OS.pango_layout_set_text(layout, buffer, -1);
+ OS.pango_layout_set_font_description(layout, font.handle);
+ Cairo.cairo_move_to(cairo, x, y);
+ OS.pango_cairo_layout_path(cairo, layout);
+ OS.g_object_unref(layout);
+ } else {
+ GC.setCairoFont(cairo, font);
+ cairo_font_extents_t extents = new cairo_font_extents_t();
+ Cairo.cairo_font_extents(cairo, extents);
+ double baseline = y + extents.ascent;
+ Cairo.cairo_move_to(cairo, x, baseline);
+ Cairo.cairo_text_path(cairo, buffer);
+ }
+}
+
static int checkStyle (int style) {
if ((style & SWT.LEFT_TO_RIGHT) != 0) style &= ~SWT.RIGHT_TO_LEFT;
return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
@@ -258,6 +278,30 @@ public void copyArea(int srcX, int srcY, int width, int height, int destX, int d
}
}
+void createLayout() {
+ int /*long*/ context = OS.gdk_pango_context_get();
+ if (context == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ data.context = context;
+ int /*long*/ layout = OS.pango_layout_new(context);
+ if (layout == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ data.layout = layout;
+ OS.pango_context_set_language(context, OS.gtk_get_default_language());
+ OS.pango_context_set_base_dir(context, OS.PANGO_DIRECTION_LTR);
+ OS.gdk_pango_context_set_colormap(context, OS.gdk_colormap_get_system());
+ if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0)) {
+ OS.pango_layout_set_auto_dir(layout, false);
+ }
+ int /*long*/ font = data.font;
+ if (font != 0) OS.pango_layout_set_font_description(layout, font);
+}
+
+void disposeLayout() {
+ data.string = null;
+ if (data.context != 0) OS.g_object_unref(data.context);
+ if (data.layout != 0) OS.g_object_unref(data.layout);
+ data.layout = data.context = 0;
+}
+
/**
* Disposes of the operating system resources associated with
* the graphics context. Applications must dispose of all GCs
@@ -280,16 +324,13 @@ public void dispose() {
if (image.transparentPixel != -1) image.createMask();
}
- int /*long*/ context = data.context;
- if (context != 0) OS.g_object_unref(context);
- int /*long*/ layout = data.layout;
- if (layout != 0) OS.g_object_unref(layout);
+ disposeLayout();
/* Dispose the GC */
Device device = data.device;
drawable.internal_dispose_GC(handle, data);
- data.layout = data.context = data.drawable = data.clipRgn = 0;
+ data.drawable = data.clipRgn = 0;
drawable = null;
handle = 0;
data.image = null;
@@ -1239,15 +1280,17 @@ public void drawText (String string, int x, int y, int flags) {
if (string.length() == 0) return;
int /*long*/ cairo = data.cairo;
if (cairo != 0) {
- //TODO - honor flags
- cairo_font_extents_t extents = new cairo_font_extents_t();
- Cairo.cairo_font_extents(cairo, extents);
- double baseline = y + extents.ascent;
- Cairo.cairo_move_to(cairo, x, baseline);
- byte[] buffer = Converter.wcsToMbcs(null, string, true);
- Cairo.cairo_show_text(cairo, buffer);
- Cairo.cairo_new_path(cairo);
- return;
+ if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {
+ //TODO - honor flags
+ cairo_font_extents_t extents = new cairo_font_extents_t();
+ Cairo.cairo_font_extents(cairo, extents);
+ double baseline = y + extents.ascent;
+ Cairo.cairo_move_to(cairo, x, baseline);
+ byte[] buffer = Converter.wcsToMbcs(null, string, true);
+ Cairo.cairo_show_text(cairo, buffer);
+ Cairo.cairo_new_path(cairo);
+ return;
+ }
}
setString(string, flags);
GdkColor background = null;
@@ -1260,6 +1303,24 @@ public void drawText (String string, int x, int y, int flags) {
int /*long*/ colormap = OS.gdk_colormap_get_system();
OS.gdk_colormap_query_color(colormap, background.pixel, background);
}
+ if (cairo != 0) {
+ if ((flags & SWT.DRAW_TRANSPARENT) == 0) {
+ int[] width = new int[1], height = new int[1];
+ OS.pango_layout_get_size(data.layout, width, height);
+ Cairo.cairo_rectangle(cairo, x, y, OS.PANGO_PIXELS(width[0]), OS.PANGO_PIXELS(height[0]));
+ Cairo.cairo_save(cairo);
+ if (data.backgroundPattern != null) {
+ Cairo.cairo_set_source(cairo, data.backgroundPattern.handle);
+ } else {
+ Cairo.cairo_set_source_rgba(cairo, (background.red & 0xFFFF) / (float)0xFFFF, (background.green & 0xFFFF) / (float)0xFFFF, (background.blue & 0xFFFF) / (float)0xFFFF, data.alpha / (float)0xFF);
+ }
+ Cairo.cairo_fill(cairo);
+ Cairo.cairo_restore(cairo);
+ }
+ Cairo.cairo_move_to(cairo, x, y);
+ OS.pango_cairo_show_layout(cairo, data.layout);
+ return;
+ }
if (!data.xorMode) {
OS.gdk_draw_layout_with_colors(data.drawable, handle, x, y, data.layout, null, background);
} else {
@@ -2077,6 +2138,7 @@ public Font getFont() {
*/
public FontMetrics getFontMetrics() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.context == 0) createLayout();
int /*long*/ context = data.context;
int /*long*/ lang = OS.pango_context_get_language(context);
int /*long*/ metrics = OS.pango_context_get_metrics(context, data.font, lang);
@@ -2405,25 +2467,10 @@ public int hashCode() {
}
void init(Drawable drawable, GCData data, int /*long*/ gdkGC) {
- int /*long*/ context = OS.gdk_pango_context_get();
- if (context == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- OS.pango_context_set_language(context, OS.gtk_get_default_language());
- OS.pango_context_set_base_dir(context, OS.PANGO_DIRECTION_LTR);
- OS.gdk_pango_context_set_colormap(context, OS.gdk_colormap_get_system());
- data.context = context;
- int /*long*/ layout = OS.pango_layout_new(context);
- if (layout == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- data.layout = layout;
-
- if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0)) {
- OS.pango_layout_set_auto_dir(layout, false);
- }
GdkColor foreground = data.foreground;
if (foreground != null) OS.gdk_gc_set_foreground(gdkGC, foreground);
GdkColor background = data.background;
if (background != null) OS.gdk_gc_set_background(gdkGC, background);
- int /*long*/ font = data.font;
- if (font != 0) OS.pango_layout_set_font_description(layout, font);
Image image = data.image;
if (image != null) {
@@ -2498,7 +2545,9 @@ void initCairo() {
}
Cairo.cairo_set_dash(cairo, dashes, dashes.length, 0);
}
- setCairoFont(cairo, data.font);
+ if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {
+ setCairoFont(cairo, data.font);
+ }
setCairoClip(cairo, data.clipRgn);
}
@@ -2919,11 +2968,15 @@ public void setFont(Font font) {
if (font == null) font = data.device.systemFont;
if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
int /*long*/ fontHandle = data.font = font.handle;
- OS.pango_layout_set_font_description(data.layout, fontHandle);
+ if (data.layout != 0) {
+ OS.pango_layout_set_font_description(data.layout, fontHandle);
+ }
data.stringWidth = data.stringHeight = -1;
- int /*long*/ cairo = data.cairo;
- if (cairo != 0) {
- setCairoFont(cairo, fontHandle);
+ if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {
+ int /*long*/ cairo = data.cairo;
+ if (cairo != 0) {
+ setCairoFont(cairo, fontHandle);
+ }
}
}
@@ -3305,6 +3358,7 @@ public void setLineWidth(int lineWidth) {
}
void setString(String string, int flags) {
+ if (data.layout == 0) createLayout();
if (string == data.string && (flags & ~SWT.DRAW_TRANSPARENT) == (data.drawFlags & ~SWT.DRAW_TRANSPARENT)) {
return;
}
@@ -3565,6 +3619,18 @@ public Point textExtent(String string) {
public Point textExtent(String string, int flags) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int /*long*/ cairo = data.cairo;
+ if (cairo != 0) {
+ if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {
+ //TODO - honor flags
+ byte[] buffer = Converter.wcsToMbcs(null, string, true);
+ cairo_font_extents_t font_extents = new cairo_font_extents_t();
+ Cairo.cairo_font_extents(cairo, font_extents);
+ cairo_text_extents_t extents = new cairo_text_extents_t();
+ Cairo.cairo_text_extents(cairo, buffer, extents);
+ return new Point((int)extents.width, (int)font_extents.height);
+ }
+ }
setString(string, flags);
if (data.stringWidth != -1) return new Point(data.stringWidth, data.stringHeight);
int[] width = new int[1], height = new int[1];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java
index 5a1f225e7a..d6d325e730 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java
@@ -11,6 +11,7 @@
package org.eclipse.swt.graphics;
import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.cairo.*;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.*;
@@ -275,11 +276,7 @@ public void dispose() {
* </ul>
*/
public void draw(GC gc, int x, int y) {
- checkLayout ();
- computeRuns();
- if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- OS.gdk_draw_layout(gc.data.drawable, gc.handle, x, y, layout);
+ draw(gc, x, y, -1, -1, null, null);
}
/**
@@ -311,8 +308,15 @@ public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Colo
int length = text.length();
if (length == 0) return;
boolean hasSelection = selectionStart <= selectionEnd && selectionStart != -1 && selectionEnd != -1;
+ GCData data = gc.data;
+ int /*long*/ cairo = data.cairo;
if (!hasSelection) {
- OS.gdk_draw_layout(gc.data.drawable, gc.handle, x, y, layout);
+ if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+ Cairo.cairo_move_to(cairo, x, y);
+ OS.pango_cairo_show_layout(cairo, layout);
+ } else {
+ OS.gdk_draw_layout(data.drawable, gc.handle, x, y, layout);
+ }
} else {
selectionStart = Math.min(Math.max(0, selectionStart), length - 1);
selectionEnd = Math.min(Math.max(0, selectionEnd), length - 1);
@@ -323,30 +327,60 @@ public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Colo
if (selectionBackground == null) selectionBackground = device.getSystemColor(SWT.COLOR_LIST_SELECTION);
boolean fullSelection = selectionStart == 0 && selectionEnd == length - 1;
if (fullSelection) {
- OS.gdk_draw_layout_with_colors(gc.data.drawable, gc.handle, x, y, layout, selectionForeground.handle, selectionBackground.handle);
+ if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+ int /*long*/ ptr = OS.pango_layout_get_text(layout);
+ drawWithCairo(cairo, x, y, 0, OS.strlen(ptr), fullSelection, selectionBackground.handle, selectionForeground.handle);
+ } else {
+ OS.gdk_draw_layout_with_colors(data.drawable, gc.handle, x, y, layout, selectionForeground.handle, selectionBackground.handle);
+ }
} else {
int /*long*/ ptr = OS.pango_layout_get_text(layout);
- Region clipping = new Region();
- gc.getClipping(clipping);
int byteSelStart = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, selectionStart) - ptr);
int byteSelEnd = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, selectionEnd + 1) - ptr);
int strlen = OS.strlen(ptr);
byteSelStart = Math.min(byteSelStart, strlen);
byteSelEnd = Math.min(byteSelEnd, strlen);
- OS.gdk_draw_layout(gc.data.drawable, gc.handle, x, y, layout);
- int[] ranges = new int[]{byteSelStart, byteSelEnd};
- int /*long*/ rgn = OS.gdk_pango_layout_get_clip_region(layout, x, y, ranges, ranges.length / 2);
- if (rgn != 0) {
- OS.gdk_gc_set_clip_region(gc.handle, rgn);
- OS.gdk_region_destroy(rgn);
+ if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+ drawWithCairo(cairo, x, y, byteSelStart, byteSelEnd, fullSelection, selectionBackground.handle, selectionForeground.handle);
+ } else {
+ Region clipping = new Region();
+ gc.getClipping(clipping);
+ OS.gdk_draw_layout(data.drawable, gc.handle, x, y, layout);
+ int[] ranges = new int[]{byteSelStart, byteSelEnd};
+ int /*long*/ rgn = OS.gdk_pango_layout_get_clip_region(layout, x, y, ranges, ranges.length / 2);
+ if (rgn != 0) {
+ OS.gdk_gc_set_clip_region(gc.handle, rgn);
+ OS.gdk_region_destroy(rgn);
+ }
+ OS.gdk_draw_layout_with_colors(data.drawable, gc.handle, x, y, layout, selectionForeground.handle, selectionBackground.handle);
+ gc.setClipping(clipping);
+ clipping.dispose();
}
- OS.gdk_draw_layout_with_colors(gc.data.drawable, gc.handle, x, y, layout, selectionForeground.handle, selectionBackground.handle);
- gc.setClipping(clipping);
- clipping.dispose();
}
}
}
+void drawWithCairo(int /*long*/ cairo, int x, int y, int byteSelStart, int byteSelEnd, boolean fullSelection, GdkColor selectionBackground, GdkColor selectionForeground) {
+ Cairo.cairo_save(cairo);
+ if (!fullSelection) {
+ Cairo.cairo_move_to(cairo, x, y);
+ OS.pango_cairo_show_layout(cairo, layout);
+ }
+ int[] ranges = new int[]{byteSelStart, byteSelEnd};
+ int /*long*/ rgn = OS.gdk_pango_layout_get_clip_region(layout, x, y, ranges, ranges.length / 2);
+ if (rgn != 0) {
+ OS.gdk_cairo_region(cairo, rgn);
+ Cairo.cairo_clip(cairo);
+ OS.gdk_cairo_set_source_color(cairo, selectionBackground);
+ Cairo.cairo_paint(cairo);
+ OS.gdk_region_destroy(rgn);
+ }
+ OS.gdk_cairo_set_source_color(cairo, selectionForeground);
+ Cairo.cairo_move_to(cairo, x, y);
+ OS.pango_cairo_show_layout(cairo, layout);
+ Cairo.cairo_restore(cairo);
+}
+
void freeRuns() {
if (attrList == 0) return;
OS.pango_layout_set_attributes(layout, 0);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java
index 9828025211..df1f06429e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java
@@ -134,6 +134,15 @@ public GC(Drawable drawable, int style) {
init(drawable, data, xGC);
if (device.tracking) device.new_Object(this);
}
+static void addCairoString(int cairo, String string, float x, float y, Font font) {
+ byte[] buffer = Converter.wcsToMbcs(null, string, true);
+ GC.setCairoFont(cairo, font);
+ cairo_font_extents_t extents = new cairo_font_extents_t();
+ Cairo.cairo_font_extents(cairo, extents);
+ double baseline = y + extents.ascent;
+ Cairo.cairo_move_to(cairo, x, baseline);
+ Cairo.cairo_text_path(cairo, buffer);
+}
static int checkStyle (int style) {
if ((style & SWT.LEFT_TO_RIGHT) != 0) style &= ~SWT.RIGHT_TO_LEFT;
return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);