diff options
author | Bogdan Gheorghe <gheorghe> | 2009-01-20 22:08:22 +0000 |
---|---|---|
committer | Bogdan Gheorghe <gheorghe> | 2009-01-20 22:08:22 +0000 |
commit | 90874dd0f318ad72c86947cdc4c25287bab952a0 (patch) | |
tree | dc7029d49f9a6834fb75971994447391812320a2 | |
parent | ef97fe54dc22960e591264f9a40821c6e605bd48 (diff) | |
download | eclipse.platform.swt-90874dd0f318ad72c86947cdc4c25287bab952a0.tar.gz eclipse.platform.swt-90874dd0f318ad72c86947cdc4c25287bab952a0.tar.xz eclipse.platform.swt-90874dd0f318ad72c86947cdc4c25287bab952a0.zip |
261219 text inner border can be wrong on gtk 2.10
8 files changed, 94 insertions, 18 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c index 997be85b81..e27fdf1356 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 @@ -6313,6 +6313,16 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1bin_1get_1child) } #endif +#ifndef NO__1gtk_1border_1free +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1border_1free) + (JNIEnv *env, jclass that, jintLong arg0) +{ + OS_NATIVE_ENTER(env, that, _1gtk_1border_1free_FUNC); + gtk_border_free((GtkBorder *)arg0); + OS_NATIVE_EXIT(env, that, _1gtk_1border_1free_FUNC); +} +#endif + #ifndef NO__1gtk_1box_1set_1child_1packing JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1box_1set_1child_1packing) (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jboolean arg2, jboolean arg3, jint arg4, jint arg5) @@ -7344,6 +7354,18 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1editable_1set_1position) } #endif +#ifndef NO__1gtk_1entry_1get_1inner_1border +JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1entry_1get_1inner_1border) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jintLong rc = 0; + OS_NATIVE_ENTER(env, that, _1gtk_1entry_1get_1inner_1border_FUNC); + rc = (jintLong)gtk_entry_get_inner_border((GtkEntry *)arg0); + OS_NATIVE_EXIT(env, that, _1gtk_1entry_1get_1inner_1border_FUNC); + return rc; +} +#endif + #ifndef NO__1gtk_1entry_1get_1invisible_1char JNIEXPORT jchar JNICALL OS_NATIVE(_1gtk_1entry_1get_1invisible_1char) (JNIEnv *env, jclass that, jintLong 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 c3f3c0e9bb..bd72c1e6e9 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 = 1278; -int OS_nativeFunctionCallCount[1278]; +int OS_nativeFunctionCount = 1280; +int OS_nativeFunctionCallCount[1280]; char * OS_nativeFunctionNames[] = { #ifndef JNI64 "Call__IIII", @@ -535,6 +535,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1arrow_1new", "_1gtk_1arrow_1set", "_1gtk_1bin_1get_1child", + "_1gtk_1border_1free", "_1gtk_1box_1set_1child_1packing", "_1gtk_1box_1set_1spacing", "_1gtk_1button_1clicked", @@ -612,6 +613,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1editable_1select_1region", "_1gtk_1editable_1set_1editable", "_1gtk_1editable_1set_1position", + "_1gtk_1entry_1get_1inner_1border", "_1gtk_1entry_1get_1invisible_1char", "_1gtk_1entry_1get_1layout", "_1gtk_1entry_1get_1layout_1offsets", 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 547d5d61b1..c52a9cee90 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 @@ -543,6 +543,7 @@ typedef enum { _1gtk_1arrow_1new_FUNC, _1gtk_1arrow_1set_FUNC, _1gtk_1bin_1get_1child_FUNC, + _1gtk_1border_1free_FUNC, _1gtk_1box_1set_1child_1packing_FUNC, _1gtk_1box_1set_1spacing_FUNC, _1gtk_1button_1clicked_FUNC, @@ -620,6 +621,7 @@ typedef enum { _1gtk_1editable_1select_1region_FUNC, _1gtk_1editable_1set_1editable_FUNC, _1gtk_1editable_1set_1position_FUNC, + _1gtk_1entry_1get_1inner_1border_FUNC, _1gtk_1entry_1get_1invisible_1char_FUNC, _1gtk_1entry_1get_1layout_FUNC, _1gtk_1entry_1get_1layout_1offsets_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 1e582d1f59..75b9af97f9 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 @@ -492,6 +492,7 @@ public class OS extends C { public static final byte[] gtk_cursor_blink_time = ascii("gtk-cursor-blink-time"); public static final byte[] gtk_double_click_time = ascii("gtk-double-click-time"); public static final byte[] gtk_entry_select_on_focus = ascii("gtk-entry-select-on-focus"); + public static final byte[] inner_border = ascii("inner-border"); public static final byte[] horizontal_separator = ascii("horizontal-separator"); public static final byte[] inconsistent = ascii("inconsistent"); public static final byte[] interior_focus = ascii("interior-focus"); @@ -5179,6 +5180,16 @@ public static final int /*long*/ gtk_bin_get_child(int /*long*/ bin) { lock.unlock(); } } +/** @param border cast=(GtkBorder *) */ +public static final native void _gtk_border_free(int /*long*/ border); +public static final void gtk_border_free(int /*long*/ border) { + lock.lock(); + try { + _gtk_border_free(border); + } finally { + lock.unlock(); + } +} /** @param box cast=(GtkBox *) */ public static final native void _gtk_box_set_spacing(int /*long*/ box, int spacing); public static final void gtk_box_set_spacing(int /*long*/ box, int spacing) { @@ -6082,6 +6093,17 @@ public static final void gtk_editable_set_position(int /*long*/ editable, int po lock.unlock(); } } +/** @method flags=dynamic */ +/** @param entry cast=(GtkEntry *) */ +public static final native int /*long*/ _gtk_entry_get_inner_border (int /*long*/ entry); +public static final int /*long*/ gtk_entry_get_inner_border (int /*long*/ entry) { + lock.lock(); + try { + return _gtk_entry_get_inner_border(entry); + } finally { + lock.unlock(); + } +} /** @param entry cast=(GtkEntry *) */ public static final native char _gtk_entry_get_invisible_char(int /*long*/ entry); public static final char gtk_entry_get_invisible_char(int /*long*/ entry) { 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 944cf19c73..dbb7f314d6 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 @@ -63,8 +63,6 @@ public class Combo extends Composite { String [] items = new String [0]; boolean ignoreSelect, lockText; - static final int INNER_BORDER = 2; - /** * the operating system limit for the number of characters * that the text field in an instance of this class can hold @@ -372,7 +370,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) { OS.gtk_widget_realize (entryHandle); int /*long*/ layout = OS.gtk_entry_get_layout (entryHandle); OS.pango_layout_get_size (layout, w, h); - int xborder = INNER_BORDER, yborder = INNER_BORDER; + int xborder = Display.INNER_BORDER, yborder = Display.INNER_BORDER; int /*long*/ style = OS.gtk_widget_get_style (entryHandle); xborder += OS.gtk_style_get_xthickness (style); yborder += OS.gtk_style_get_ythickness (style); 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 7389390673..ee223a8951 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 @@ -272,6 +272,9 @@ public class Display extends Device { /* Click count*/ int clickCount = 1; + /* Entry inner border */ + static final int INNER_BORDER = 2; + /* Timestamp of the Last Received Events */ int lastEventTime, lastUserEventTime; @@ -1436,6 +1439,29 @@ public Control getCursorControl () { return null; } +static GtkBorder getEntryInnerBorder (int /*long*/ handle) { + GtkBorder gtkBorder = new GtkBorder(); + if (OS.GTK_VERSION >= OS.VERSION (2, 10, 0)) { + int /*long*/ border = OS.gtk_entry_get_inner_border (handle); + if (border != 0) { + OS.memmove (gtkBorder, border, GtkBorder.sizeof); + return gtkBorder; + } + int [] /*long*/ borderPtr = new int /*long*/ [1]; + OS.gtk_widget_style_get (handle, OS.inner_border, borderPtr,0); + if (borderPtr[0] != 0) { + OS.memmove (gtkBorder, borderPtr[0], GtkBorder.sizeof); + OS.gtk_border_free(borderPtr[0]); + return gtkBorder; + } + } + gtkBorder.left = INNER_BORDER; + gtkBorder.top = INNER_BORDER; + gtkBorder.right = INNER_BORDER; + gtkBorder.bottom = INNER_BORDER; + return gtkBorder; +} + boolean filterEvent (Event event) { if (filterTable != null) filterTable.sendEvent (event); return false; 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 c6c86b79c6..7180778e24 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 @@ -42,7 +42,6 @@ import org.eclipse.swt.events.*; * @since 3.1 */ public class Spinner extends Composite { - static final int INNER_BORDER = 2; static final int MIN_ARROW_WIDTH = 6; int lastEventTime = 0; int /*long*/ gdkEventKey = 0; @@ -244,8 +243,6 @@ public Rectangle computeTrim (int x, int y, int width, int height) { xborder += OS.gtk_style_get_xthickness (style); yborder += OS.gtk_style_get_ythickness (style); } - xborder += INNER_BORDER; - yborder += INNER_BORDER; int [] property = new int [1]; OS.gtk_widget_style_get (handle, OS.interior_focus, property, 0); if (property [0] == 0) { @@ -263,6 +260,11 @@ public Rectangle computeTrim (int x, int y, int width, int height) { trim.width += 2 * xborder; trim.height += 2 * yborder; trim.width += arrowSize + (2 * OS.gtk_style_get_xthickness (style)); + GtkBorder innerBorder = Display.getEntryInnerBorder (handle); + trim.x -= innerBorder.left; + trim.y -= innerBorder.top; + trim.width += innerBorder.left + innerBorder.right; + trim.height += innerBorder.top + innerBorder.bottom; return new Rectangle (trim.x, trim.y, trim.width, trim.height); } 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 1b62ee9a66..5cf9c27b0c 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 @@ -53,7 +53,6 @@ public class Text extends Scrollable { boolean doubleClick; String message = ""; - static final int INNER_BORDER = 2; static final int ITER_SIZEOF = OS.GtkTextIter_sizeof(); static final int SPACE_FOR_CURSOR = 1; @@ -379,8 +378,11 @@ public Rectangle computeTrim (int x, int y, int width, int height) { xborder += OS.gtk_style_get_xthickness (style); yborder += OS.gtk_style_get_ythickness (style); } - xborder += INNER_BORDER; - yborder += INNER_BORDER; + GtkBorder innerBorder = Display.getEntryInnerBorder (handle); + trim.x -= innerBorder.left; + trim.y -= innerBorder.top; + trim.width += innerBorder.left + innerBorder.right; + trim.height += innerBorder.top + innerBorder.bottom; } else { int borderWidth = OS.gtk_container_get_border_width (handle); xborder += borderWidth; @@ -1271,9 +1273,9 @@ int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ event) { int /*long*/ window = paintWindow (); int [] w = new int [1], h = new int [1]; OS.gdk_drawable_get_size (window, w, h); - int border = INNER_BORDER; - int height = h [0] - border - border; - int width = w [0] - border - border; + GtkBorder innerBorder = Display.getEntryInnerBorder (handle); + int width = w [0] - innerBorder.left - innerBorder.right; + int height = h [0] - innerBorder.top - innerBorder.bottom; int /*long*/ context = OS.gtk_widget_get_pango_context (handle); int /*long*/ lang = OS.pango_context_get_language (context); int /*long*/ metrics = OS.pango_context_get_metrics (context, getFontDescription (), lang); @@ -1296,14 +1298,14 @@ int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ event) { } else if (y + rect.height > height) { y = height - rect.height; } - y += border; - int x = border; + y += innerBorder.top; + int x = innerBorder.left; boolean rtl = (style & SWT.RIGHT_TO_LEFT) != 0; int alignment = style & (SWT.LEFT | SWT.CENTER | SWT.RIGHT); switch (alignment) { - case SWT.LEFT: x = rtl ? width - rect.width: border; break; + case SWT.LEFT: x = rtl ? width - rect.width: innerBorder.left; break; case SWT.CENTER: x = (width - rect.width) / 2; break; - case SWT.RIGHT: x = rtl ? border : width - rect.width; break; + case SWT.RIGHT: x = rtl ? innerBorder.left : width - rect.width; break; } int /*long*/ gc = OS.gdk_gc_new (window); int /*long*/ style = OS.gtk_widget_get_style (handle); |