diff options
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT')
4 files changed, 44 insertions, 16 deletions
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); |