Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Northover2006-12-06 18:59:14 -0500
committerSteve Northover2006-12-06 18:59:14 -0500
commite1929f1c3f43e3e6bd5928e5d3ab409bc77b273b (patch)
treeff2600f933c87b98cae65e33d0e74f4471a80c72
parent9cbde1ba14cfc58f94997d30baaef0def13b4b4b (diff)
downloadeclipse.platform.swt-e1929f1c3f43e3e6bd5928e5d3ab409bc77b273b.tar.gz
eclipse.platform.swt-e1929f1c3f43e3e6bd5928e5d3ab409bc77b273b.tar.xz
eclipse.platform.swt-e1929f1c3f43e3e6bd5928e5d3ab409bc77b273b.zip
165033 - Table vertical lines always showing
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java52
1 files changed, 33 insertions, 19 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
index 7bcbe2bacf..eb8729a9b7 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
@@ -71,7 +71,7 @@ public class Table extends Composite {
boolean ignoreCustomDraw, ignoreDrawForeground, ignoreDrawBackground, ignoreDrawSelection;
boolean customDraw, dragStarted, explorerTheme, firstColumnImage, fixScrollWidth, tipRequested, wasSelected, wasResized;
boolean ignoreActivate, ignoreSelect, ignoreShrink, ignoreResize, ignoreColumnMove, ignoreColumnResize;
- int headerToolTipHandle, itemHeight, lastIndexOf, lastWidth, sortDirection, resizeCount, selectionForeground;
+ int headerToolTipHandle, itemHeight, lastIndexOf, lastWidth, scrollWidth, selectionForeground, sortDirection, resizeCount;
static /*final*/ int HeaderProc;
static final int INSET = 4;
static final int GRID_WIDTH = 1;
@@ -941,20 +941,15 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
RECT rect = new RECT ();
OS.GetWindowRect (hwndHeader, rect);
- int height = rect.bottom - rect.top;
- int bits = 0;
- if (wHint != SWT.DEFAULT) {
- bits |= wHint & 0xFFFF;
+ int width = 0, height = rect.bottom - rect.top;
+ if (columnCount == 0) {
+ width = getScrollWidth ();
} else {
- int width = 0;
int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
for (int i=0; i<count; i++) {
width += OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, i, 0);
}
- bits |= width & 0xFFFF;
}
- int result = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, -1, bits | 0xFFFF0000);
- int width = result & 0xFFFF;
int empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
int oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
int itemHeight = (oneItem >> 16) - (empty >> 16);
@@ -1020,8 +1015,8 @@ void createHandle () {
if ((style & SWT.CHECK) != 0) {
int empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
int oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
- int width = (oneItem >> 16) - (empty >> 16), height = width;
- setCheckboxImageList (width, height, false);
+ int itemHeight = (oneItem >> 16) - (empty >> 16);
+ setCheckboxImageList (itemHeight, itemHeight, false);
OS.SendMessage (handle, OS. LVM_SETCALLBACKMASK, OS.LVIS_STATEIMAGEMASK, 0);
}
@@ -1214,7 +1209,7 @@ void createItem (TableColumn column, int index) {
OS.SendMessage (handle, OS.LVM_SETCOLUMN, 0, lvColumn);
if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
} else {
- OS.SendMessage (handle, OS.LVM_SETCOLUMNWIDTH, 0, 0);
+ setScrollWidth (0);
}
if ((parent.style & SWT.VIRTUAL) == 0) {
LVITEM lvItem = new LVITEM ();
@@ -2085,6 +2080,10 @@ public boolean getLinesVisible () {
return (bits & OS.LVS_EX_GRIDLINES) != 0;
}
+int getScrollWidth () {
+ return scrollWidth;
+}
+
/**
* Returns an array of <code>TableItem</code>s that are currently
* selected in the receiver. The order of the items is unspecified.
@@ -2982,9 +2981,8 @@ Event sendMeasureItemEvent (TableItem item, int row, int column, int hDC) {
OS.RestoreDC (hDC, nSavedDC);
if (!isDisposed () && !item.isDisposed ()) {
if (columnCount == 0) {
- int width = OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, 0, 0);
- if (event.x + event.width > width) {
- OS.SendMessage (handle, OS.LVM_SETCOLUMNWIDTH, 0, event.x + event.width);
+ if (event.x + event.width > getScrollWidth ()) {
+ setScrollWidth (event.x + event.width);
}
}
if (event.height > getItemHeight ()) setItemHeight (event.height);
@@ -3298,6 +3296,7 @@ void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
setDeferResize (true);
super.setBounds (x, y, width, height, flags, false);
setDeferResize (false);
+ if (columnCount == 0) setScrollWidth (scrollWidth);
}
/**
@@ -3903,6 +3902,15 @@ public void setRedraw (boolean redraw) {
}
}
+void setScrollWidth (int scrollWidth) {
+ forceResize ();
+ RECT rect = new RECT ();
+ OS.GetClientRect (handle, rect);
+ this.scrollWidth = Math.max (0, scrollWidth);
+ int newWidth = Math.max (this.scrollWidth, rect.right - rect.left);
+ OS.SendMessage (handle, OS.LVM_SETCOLUMNWIDTH, 0, newWidth);
+}
+
boolean setScrollWidth (TableItem item, boolean force) {
if (currentItem != null) {
if (currentItem != item) fixScrollWidth = true;
@@ -3996,13 +4004,12 @@ boolean setScrollWidth (TableItem item, boolean force) {
newWidth++;
}
newWidth += INSET * 2;
- int oldWidth = OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, 0, 0);
if (EXPLORER_THEME) {
if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) {
newWidth += EXPLORER_EXTRA;
}
}
- if (newWidth > oldWidth) {
+ if (newWidth > getScrollWidth ()) {
/*
* Feature in Windows. When LVM_SETCOLUMNWIDTH is sent,
* Windows draws right away instead of queuing a WM_PAINT.
@@ -4014,7 +4021,7 @@ boolean setScrollWidth (TableItem item, boolean force) {
*/
boolean redraw = drawCount == 0 && OS.IsWindowVisible (handle);
if (redraw) OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);
- OS.SendMessage (handle, OS.LVM_SETCOLUMNWIDTH, 0, newWidth);
+ setScrollWidth (newWidth);
if (redraw) {
OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
if (OS.IsWinCE) {
@@ -4277,7 +4284,7 @@ void setTableEmpty () {
}
items = new TableItem [4];
if (columnCount == 0) {
- OS.SendMessage (handle, OS.LVM_SETCOLUMNWIDTH, 0, 0);
+ setScrollWidth (0);
setScrollWidth (null, false);
}
}
@@ -4404,6 +4411,8 @@ public void showColumn (TableColumn column) {
* not redraw the newly exposed vertical grid lines. The fix
* is to save the old scroll position, call the window proc,
* get the new scroll position and redraw the new area.
+ *
+ * First, save the horizontal scroll position.
*/
int oldPos = 0;
int bits = OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
@@ -4414,6 +4423,8 @@ public void showColumn (TableColumn column) {
OS.GetScrollInfo (handle, OS.SB_HORZ, info);
oldPos = info.nPos;
}
+
+ /* Scroll the table */
RECT rect = new RECT ();
OS.GetClientRect (handle, rect);
if (itemRect.left < rect.left) {
@@ -4426,12 +4437,15 @@ public void showColumn (TableColumn column) {
OS.SendMessage (handle, OS.LVM_SCROLL, dx, 0);
}
}
+
/*
* Bug in Windows. When a table that is drawing grid lines
* is slowly scrolled horizontally to the left, the table does
* not redraw the newly exposed vertical grid lines. The fix
* is to save the old scroll position, call the window proc,
* get the new scroll position and redraw the new area.
+ *
+ * Now, redraw the area.
*/
if ((bits & OS.LVS_EX_GRIDLINES) != 0) {
SCROLLINFO info = new SCROLLINFO ();

Back to the top