157544 - List: preferred width incorrect after items are removed
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
index 98e6cdd..557403a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
@@ -35,6 +35,7 @@
*/
public class List extends Scrollable {
+ static final int INSET = 3;
static final int ListProc;
static final TCHAR ListClass = new TCHAR (0, "LISTBOX", true);
static {
@@ -187,6 +188,7 @@
if (wHint == SWT.DEFAULT) {
if ((style & SWT.H_SCROLL) != 0) {
width = OS.SendMessage (handle, OS.LB_GETHORIZONTALEXTENT, 0, 0);
+ width -= INSET;
} else {
int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
int newFont, oldFont = 0;
@@ -224,7 +226,7 @@
if (wHint != SWT.DEFAULT) width = wHint;
if (hHint != SWT.DEFAULT) height = hHint;
int border = getBorderWidth ();
- width += border * 2 + 3;
+ width += border * 2 + INSET;
height += border * 2;
if ((style & SWT.V_SCROLL) != 0) {
width += OS.GetSystemMetrics (OS.SM_CXVSCROLL);
@@ -1203,7 +1205,7 @@
if ((style & SWT.H_SCROLL) != 0) {
if (newFont != 0) OS.SelectObject (hDC, oldFont);
OS.ReleaseDC (handle, hDC);
- OS.SendMessage (handle, OS.LB_SETHORIZONTALEXTENT, newWidth + 3, 0);
+ OS.SendMessage (handle, OS.LB_SETHORIZONTALEXTENT, newWidth + INSET, 0);
}
if (redraw) {
OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0);
@@ -1245,7 +1247,7 @@
}
if (newFont != 0) OS.SelectObject (hDC, oldFont);
OS.ReleaseDC (handle, hDC);
- OS.SendMessage (handle, OS.LB_SETHORIZONTALEXTENT, newWidth + 3, 0);
+ OS.SendMessage (handle, OS.LB_SETHORIZONTALEXTENT, newWidth + INSET, 0);
}
void setScrollWidth (TCHAR buffer, boolean grow) {
@@ -1262,10 +1264,11 @@
}
void setScrollWidth (int newWidth, boolean grow) {
+ newWidth += INSET;
int width = OS.SendMessage (handle, OS.LB_GETHORIZONTALEXTENT, 0, 0);
if (grow) {
if (newWidth <= width) return;
- OS.SendMessage (handle, OS.LB_SETHORIZONTALEXTENT, newWidth + 3, 0);
+ OS.SendMessage (handle, OS.LB_SETHORIZONTALEXTENT, newWidth, 0);
} else {
if (newWidth < width) return;
setScrollWidth ();