summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Northover <steve>2006-09-25 23:22:47 +0000
committerSteve Northover <steve>2006-09-25 23:22:47 +0000
commit8cc8a0e9aa8134388228fcd492f8285d1e169f4c (patch)
treea0c1937f505bb9482cd504e73a1cb1f5e12d55b6
parent8a0ae11ea42676ebdb11fa2397d5be01b71cadb7 (diff)
downloadeclipse.platform.swt-8cc8a0e9aa8134388228fcd492f8285d1e169f4c.tar.gz
eclipse.platform.swt-8cc8a0e9aa8134388228fcd492f8285d1e169f4c.tar.xz
eclipse.platform.swt-8cc8a0e9aa8134388228fcd492f8285d1e169f4c.zip
157544 - List: preferred width incorrect after items are removed
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java11
1 files changed, 7 insertions, 4 deletions
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 98e6cddb18..557403a203 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 @@ import org.eclipse.swt.events.*;
*/
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 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
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 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
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 @@ public void setItems (String [] items) {
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 @@ void setScrollWidth () {
}
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 (TCHAR buffer, boolean grow) {
}
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 ();