Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java27
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug537713_ComboSizing.java45
2 files changed, 50 insertions, 22 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 0c33a518f7..5e14cd076b 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
@@ -664,30 +664,13 @@ long /*int*/ findPopupHandle (long /*int*/ oldList) {
@Override
Point resizeCalculationsGTK3 (long /*int*/ widget, int width, int height) {
- Point sizes = new Point (width, height);
/*
- * Feature in GTK3.20+: size calculations take into account GtkCSSNode
- * elements which we cannot access. If the to-be-allocated size minus
- * these elements is < 0, allocate the preferred size instead. See bug 486068.
+ * Combo is a complex widget which has many widgets inside of it.
+ * Some of these widgets have large natural and/or minimum sizes. To prevent
+ * API breakage, just set the width and height from setBounds().
+ * See bug 537713.
*/
- if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0) && widget == handle) {
- GtkRequisition minimumSize = new GtkRequisition();
- GtkRequisition naturalSize = new GtkRequisition();
- // Use the handle only for READ_ONLY Combos, otherwise use the GtkEntry
- long /*int*/ preferredSizeHandle = ((style & SWT.READ_ONLY) == 0 && entryHandle != 0) ? entryHandle : handle;
- GTK.gtk_widget_get_preferred_size(preferredSizeHandle, minimumSize, naturalSize);
- /*
- * Use the smallest of the minimum/natural sizes to prevent oversized
- * widgets.
- */
- int smallestWidth = Math.min(minimumSize.width, naturalSize.width);
- int smallestHeight = Math.min(minimumSize.height, naturalSize.height);
- sizes.x = (width - (smallestWidth - width)) < 0 ? smallestWidth : width;
- sizes.y = (height - (smallestHeight - height)) < 0 ? smallestHeight : height;
- return sizes;
- } else {
- return super.resizeCalculationsGTK3(widget, width, height);
- }
+ return new Point (width, height);
}
long /*int*/ findButtonHandle() {
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug537713_ComboSizing.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug537713_ComboSizing.java
new file mode 100644
index 0000000000..dcf28eff3b
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug537713_ComboSizing.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug537713_ComboSizing {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ Rectangle clientArea = shell.getClientArea();
+ Combo combo1 = new Combo(shell, SWT.BORDER);
+ combo1.setItems("Alpha", "Bravo", "Charlie");
+ Point prefSize = combo1.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ combo1.setBounds(clientArea.x, clientArea.y, prefSize.x, prefSize.y);
+ Combo combo2 = new Combo(shell, SWT.BORDER);
+ combo2.setItems("Alpha", "Bravo", "Charlie");
+ combo2.setBounds(clientArea.x, clientArea.y + prefSize.y, (prefSize.x / 2) - 20, prefSize.y);
+ Combo combo3 = new Combo(shell, SWT.BORDER);
+ combo3.setItems("Alpha", "Bravo", "Charlie");
+ combo3.setBounds(clientArea.x, clientArea.y + prefSize.y * 2, (prefSize.x / 2) + 1, prefSize.y);
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+} \ No newline at end of file

Back to the top