summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogdan Gheorghe <gheorghe@ca.ibm.com>2012-08-01 17:52:51 -0400
committerBogdan Gheorghe <gheorghe@ca.ibm.com>2012-08-01 17:52:51 -0400
commitc8dd5b3da6b7a6916253d606e26594090c7a78b4 (patch)
tree173313d3a2ae9f80ef953cd6742b3eee5fed972b
parent091e36b96050b89d4e91c682d15c94c651865f88 (diff)
downloadeclipse.platform.swt-c8dd5b3da6b7a6916253d606e26594090c7a78b4.tar.gz
eclipse.platform.swt-c8dd5b3da6b7a6916253d606e26594090c7a78b4.tar.xz
eclipse.platform.swt-c8dd5b3da6b7a6916253d606e26594090c7a78b4.zip
Bug 245388 - [consistency] Combo.pack() does not consider item lengths
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java32
1 files changed, 31 insertions, 1 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 84c8c8fbf2..50a66e4581 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
@@ -341,7 +341,37 @@ void clearText () {
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
- return computeNativeSize (handle, wHint, hHint, changed);
+ if ((style & SWT.READ_ONLY) != 0) {
+ return computeNativeSize (handle, wHint, hHint, changed);
+ }
+ if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+ if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+ int[] w = new int [1], h = new int [1];
+ OS.gtk_widget_realize (entryHandle);
+ int /*long*/ layout = OS.gtk_entry_get_layout (entryHandle);
+ OS.pango_layout_get_size (layout, w, h);
+ 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);
+ int [] property = new int [1];
+ OS.gtk_widget_style_get (entryHandle, OS.interior_focus, property, 0);
+ if (property [0] == 0) {
+ OS.gtk_widget_style_get (entryHandle, OS.focus_line_width, property, 0);
+ xborder += property [0];
+ yborder += property [0];
+ }
+ int width = OS.PANGO_PIXELS (w [0]) + xborder * 2;
+ int height = OS.PANGO_PIXELS (h [0]) + yborder * 2;
+ GtkRequisition arrowRequesition = new GtkRequisition ();
+ OS.gtk_widget_size_request (buttonHandle, arrowRequesition);
+ GtkRequisition listRequesition = new GtkRequisition ();
+ int /*long*/ listParent = OS.gtk_bin_get_child(popupHandle);
+ OS.gtk_widget_size_request (listParent, listRequesition);
+ width = Math.max (listRequesition.width, width) + arrowRequesition.width;
+ width = wHint == SWT.DEFAULT ? width : wHint;
+ height = hHint == SWT.DEFAULT ? height : hHint;
+ return new Point (width, height);
}
/**