Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Heidrich2006-08-09 16:44:36 +0000
committerFelipe Heidrich2006-08-09 16:44:36 +0000
commit5ec22a2707996c01e2c6d6e26ce64ed068159bb2 (patch)
tree47398558e1ffeb9493381c4ad12a8e1845762815
parent8211e54b5531e6f130bb66c8fa416a5c37413842 (diff)
downloadeclipse.platform.swt-5ec22a2707996c01e2c6d6e26ce64ed068159bb2.tar.gz
eclipse.platform.swt-5ec22a2707996c01e2c6d6e26ce64ed068159bb2.tar.xz
eclipse.platform.swt-5ec22a2707996c01e2c6d6e26ce64ed068159bb2.zip
backport of Bug 144765
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java29
6 files changed, 84 insertions, 2 deletions
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 583db33d15..e3417ae4ed 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
@@ -2645,6 +2645,9 @@ OS__gtk_init_check=
OS__gtk_init_check_0=cast=(int *)
OS__gtk_init_check_1=cast=(char ***)
+OS__gtk_label_get_layout=
+OS__gtk_label_get_layout_0=cast=(GtkLabel *)
+
OS__gtk_label_get_mnemonic_keyval=
OS__gtk_label_get_mnemonic_keyval_0=cast=GtkLabel *
@@ -4530,6 +4533,9 @@ OS__pango_layout_get_alignment_0=cast=PangoLayout*
OS__pango_layout_get_attributes=
OS__pango_layout_get_attributes_0=cast=PangoLayout *
+OS__pango_layout_get_context=
+OS__pango_layout_get_context_0=cast=(PangoLayout *)
+
OS__pango_layout_get_indent=
OS__pango_layout_get_indent_0=cast=(PangoLayout*)
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 16914e5587..5bded3796e 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
@@ -7806,6 +7806,18 @@ fail:
}
#endif
+#ifndef NO__1gtk_1label_1get_1layout
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1label_1get_1layout)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, _1gtk_1label_1get_1layout_FUNC);
+ rc = (jint)gtk_label_get_layout((GtkLabel *)arg0);
+ OS_NATIVE_EXIT(env, that, _1gtk_1label_1get_1layout_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1gtk_1label_1get_1mnemonic_1keyval
JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1label_1get_1mnemonic_1keyval)
(JNIEnv *env, jclass that, jint arg0)
@@ -13089,6 +13101,18 @@ JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1get_1attributes)
}
#endif
+#ifndef NO__1pango_1layout_1get_1context
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1get_1context)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, _1pango_1layout_1get_1context_FUNC);
+ rc = (jint)pango_layout_get_context((PangoLayout *)arg0);
+ OS_NATIVE_EXIT(env, that, _1pango_1layout_1get_1context_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1pango_1layout_1get_1indent
JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1get_1indent)
(JNIEnv *env, jclass that, jint arg0)
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 e45a05b355..86d770dc7a 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 = 1105;
-int OS_nativeFunctionCallCount[1105];
+int OS_nativeFunctionCount = 1107;
+int OS_nativeFunctionCallCount[1107];
char * OS_nativeFunctionNames[] = {
"Call",
"GDK_1EVENT_1TYPE",
@@ -590,6 +590,7 @@ char * OS_nativeFunctionNames[] = {
"_1gtk_1image_1set_1from_1pixbuf",
"_1gtk_1image_1set_1from_1pixmap",
"_1gtk_1init_1check",
+ "_1gtk_1label_1get_1layout",
"_1gtk_1label_1get_1mnemonic_1keyval",
"_1gtk_1label_1new",
"_1gtk_1label_1new_1with_1mnemonic",
@@ -1018,6 +1019,7 @@ char * OS_nativeFunctionNames[] = {
"_1pango_1layout_1context_1changed",
"_1pango_1layout_1get_1alignment",
"_1pango_1layout_1get_1attributes",
+ "_1pango_1layout_1get_1context",
"_1pango_1layout_1get_1indent",
"_1pango_1layout_1get_1iter",
"_1pango_1layout_1get_1justify",
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 fc58a57799..f80358f924 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
@@ -594,6 +594,7 @@ typedef enum {
_1gtk_1image_1set_1from_1pixbuf_FUNC,
_1gtk_1image_1set_1from_1pixmap_FUNC,
_1gtk_1init_1check_FUNC,
+ _1gtk_1label_1get_1layout_FUNC,
_1gtk_1label_1get_1mnemonic_1keyval_FUNC,
_1gtk_1label_1new_FUNC,
_1gtk_1label_1new_1with_1mnemonic_FUNC,
@@ -1022,6 +1023,7 @@ typedef enum {
_1pango_1layout_1context_1changed_FUNC,
_1pango_1layout_1get_1alignment_FUNC,
_1pango_1layout_1get_1attributes_FUNC,
+ _1pango_1layout_1get_1context_FUNC,
_1pango_1layout_1get_1indent_FUNC,
_1pango_1layout_1get_1iter_FUNC,
_1pango_1layout_1get_1justify_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 f0ed70dff1..c401dc1eae 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
@@ -452,6 +452,7 @@ public class OS extends Platform {
public static final byte[] pixbuf = ascii("pixbuf");
public static final byte[] text = ascii("text");
public static final byte[] xalign = ascii("xalign");
+ public static final byte[] ypad = ascii("ypad");
public static final int GTK_VERSION = VERSION(gtk_major_version(), gtk_minor_version(), gtk_micro_version());
@@ -4950,6 +4951,15 @@ public static final boolean gtk_init_check(int /*long*/[] argc, int /*long*/[] a
lock.unlock();
}
}
+public static final native int /*long*/ _gtk_label_get_layout(int /*long*/ label);
+public static final int /*long*/ gtk_label_get_layout(int /*long*/ label) {
+ lock.lock();
+ try {
+ return _gtk_label_get_layout(label);
+ } finally {
+ lock.unlock();
+ }
+}
public static final native int _gtk_label_get_mnemonic_keyval(int /*long*/ label);
public static final int gtk_label_get_mnemonic_keyval(int /*long*/ label) {
lock.lock();
@@ -8850,6 +8860,15 @@ public static final int pango_layout_get_alignment(int /*long*/ layout) {
lock.unlock();
}
}
+public static final native int /*long*/ _pango_layout_get_context(int /*long*/ layout);
+public static final int /*long*/ pango_layout_get_context(int /*long*/ layout) {
+ lock.lock();
+ try {
+ return _pango_layout_get_context(layout);
+ } finally {
+ lock.unlock();
+ }
+}
public static final native int /*long*/ _pango_layout_get_attributes(int /*long*/ layout);
public static final int /*long*/ pango_layout_get_attributes(int /*long*/ layout) {
lock.lock();
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 625efef1eb..8d277bdd25 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
@@ -135,6 +135,35 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
if (fixWrap) {
OS.gtk_widget_set_size_request (labelHandle, labelWidth [0], labelHeight [0]);
}
+ /*
+ * Feature in GTK. Instead of using the font height to determine
+ * the preferred height of the widget, GTK uses the text metrics.
+ * The fix is to ensure that the preferred height is at least as
+ * tall as the font height.
+ *
+ * NOTE: This work around does not fix the case when there are
+ * muliple lines of text.
+ */
+ if (hHint == SWT.DEFAULT && labelHandle != 0) {
+ int /*long*/ layout = OS.gtk_label_get_layout (labelHandle);
+ int /*long*/ context = OS.pango_layout_get_context (layout);
+ int /*long*/ lang = OS.pango_context_get_language (context);
+ int /*long*/ font = getFontDescription ();
+ int /*long*/ metrics = OS.pango_context_get_metrics (context, font, lang);
+ int ascent = OS.PANGO_PIXELS (OS.pango_font_metrics_get_ascent (metrics));
+ int descent = OS.PANGO_PIXELS (OS.pango_font_metrics_get_descent (metrics));
+ OS.pango_font_metrics_unref (metrics);
+ int fontHeight = ascent + descent;
+ int [] buffer = new int [1];
+ OS.g_object_get (labelHandle, OS.ypad, buffer, 0);
+ fontHeight += 2 * buffer [0];
+ if (frameHandle != 0) {
+ int /*long*/ style = OS.gtk_widget_get_style (frameHandle);
+ fontHeight += 2 * OS.gtk_style_get_ythickness (style);
+ fontHeight += 2 * OS.gtk_container_get_border_width (frameHandle);
+ }
+ size.y = Math.max (size.y, fontHeight);
+ }
return size;
}

Back to the top