Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiraj Modi2017-11-07 13:49:11 +0000
committerNiraj Modi2017-11-07 13:49:11 +0000
commit41b7b40e2bce65b5731c64c608596c9dd5c042d6 (patch)
treeb7ace2ceb5c73eff8d50adbc4ef5d148ddf66171
parenta2c26f8729b8ef37bbcb87f5744a17f205bcd178 (diff)
downloadeclipse.platform.swt-41b7b40e2bce65b5731c64c608596c9dd5c042d6.tar.gz
eclipse.platform.swt-41b7b40e2bce65b5731c64c608596c9dd5c042d6.tar.xz
eclipse.platform.swt-41b7b40e2bce65b5731c64c608596c9dd5c042d6.zip
Revert "Revert "Bug 518737 - [Win32] Background switches to light if tree widget is disabled""
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java42
3 files changed, 15 insertions, 43 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
index d1aff71670..c50b01d641 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
@@ -1749,6 +1749,14 @@ boolean hasCursor () {
return OS.GetCursorPos (pt) && OS.PtInRect (rect, pt);
}
+boolean hasCustomBackground() {
+ return background != -1;
+}
+
+boolean hasCustomForeground() {
+ return foreground != -1;
+}
+
boolean hasFocus () {
/*
* If a non-SWT child of the control has focus,
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 302172e371..525a467671 100644
--- 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
@@ -2944,14 +2944,6 @@ boolean hasChildren () {
return false;
}
-boolean hasCustomBackground() {
- return background != -1;
-}
-
-boolean hasCustomForeground() {
- return foreground != -1;
-}
-
boolean hitTestSelection (int index, int x, int y) {
int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (count == 0) return false;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
index dba3101232..6f3d4672f6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
@@ -1447,7 +1447,7 @@ LRESULT CDDS_POSTPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ l
LRESULT CDDS_PREPAINT (NMTVCUSTOMDRAW nmcd, long /*int*/ wParam, long /*int*/ lParam) {
if (explorerTheme) {
- if ((OS.IsWindowEnabled (handle) && hooks (SWT.EraseItem)) || findImageControl () != null) {
+ if ((OS.IsWindowEnabled (handle) && hooks (SWT.EraseItem)) || hasCustomBackground() || findImageControl () != null) {
RECT rect = new RECT ();
OS.SetRect (rect, nmcd.left, nmcd.top, nmcd.right, nmcd.bottom);
drawBackground (nmcd.hdc, rect);
@@ -2700,26 +2700,18 @@ void enableDrag (boolean enabled) {
void enableWidget (boolean enabled) {
super.enableWidget (enabled);
/*
- * Feature in Windows. When a tree is given a background color
- * using TVM_SETBKCOLOR and the tree is disabled, Windows draws
- * the tree using the background color rather than the disabled
- * colors. This is different from the table which draws grayed.
- * The fix is to set the default background color while the tree
- * is disabled and restore it when enabled.
- */
- Control control = findBackgroundControl ();
- /*
* Bug in Windows. On Vista only, Windows does not draw using
* the background color when the tree is disabled. The fix is
* to set the default color, even when the color has not been
* changed, causing Windows to draw correctly.
*/
+ Control control = findBackgroundControl ();
if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) {
if (control == null) control = this;
}
if (control != null) {
if (control.backgroundImage == null) {
- _setBackgroundPixel (enabled ? control.getBackgroundPixel () : -1);
+ _setBackgroundPixel (hasCustomBackground() ? control.getBackgroundPixel () : -1);
}
}
if (hwndParent != 0) OS.EnableWindow (hwndParent, enabled);
@@ -2729,7 +2721,7 @@ void enableWidget (boolean enabled) {
* TVS_FULLROWSELECT, the background color for the
* entire row is filled when an item is painted,
* drawing on top of the sort column color. The fix
- * is to clear TVS_FULLROWSELECT when a their is
+ * is to clear TVS_FULLROWSELECT when there is
* as sort column.
*/
updateFullSelection ();
@@ -3670,20 +3662,8 @@ public TreeColumn getSortColumn () {
}
int getSortColumnPixel () {
- int pixel = OS.IsWindowEnabled (handle) ? getBackgroundPixel () : OS.GetSysColor (OS.COLOR_3DFACE);
- int red = pixel & 0xFF;
- int green = (pixel & 0xFF00) >> 8;
- int blue = (pixel & 0xFF0000) >> 16;
- if (red > 240 && green > 240 && blue > 240) {
- red -= 8;
- green -= 8;
- blue -= 8;
- } else {
- red = Math.min (0xFF, (red / 10) + red);
- green = Math.min (0xFF, (green / 10) + green);
- blue = Math.min (0xFF, (blue / 10) + blue);
- }
- return (red & 0xFF) | ((green & 0xFF) << 8) | ((blue & 0xFF) << 16);
+ int pixel = OS.IsWindowEnabled (handle) || hasCustomBackground() ? getBackgroundPixel () : OS.GetSysColor (OS.COLOR_3DFACE);
+ return getSlightlyDifferentColor(pixel);
}
/**
@@ -4599,15 +4579,7 @@ void setBackgroundPixel (int pixel) {
setBackgroundImage (control.backgroundImage);
return;
}
- /*
- * Feature in Windows. When a tree is given a background color
- * using TVM_SETBKCOLOR and the tree is disabled, Windows draws
- * the tree using the background color rather than the disabled
- * colors. This is different from the table which draws grayed.
- * The fix is to set the default background color while the tree
- * is disabled and restore it when enabled.
- */
- if (OS.IsWindowEnabled (handle)) _setBackgroundPixel (pixel);
+ _setBackgroundPixel (pixel);
/*
* Feature in Windows. When the tree has the style

Back to the top