summaryrefslogtreecommitdiffstats
path: root/bundles
diff options
context:
space:
mode:
authorSilenio Quarti <silenio>2007-05-23 18:10:02 +0000
committerSilenio Quarti <silenio>2007-05-23 18:10:02 +0000
commitaa2b979f45c5e2480914ab00ce560d0a67ce4efb (patch)
tree46538b6aa366e76837495a792f9cdbe74a4054ff /bundles
parent06d90d9a57442d7814f25b224526651743c00e35 (diff)
downloadeclipse.platform.swt-aa2b979f45c5e2480914ab00ce560d0a67ce4efb.tar.gz
eclipse.platform.swt-aa2b979f45c5e2480914ab00ce560d0a67ce4efb.tar.xz
eclipse.platform.swt-aa2b979f45c5e2480914ab00ce560d0a67ce4efb.zip
188265 - Trees flicker when focus changes
Diffstat (limited to 'bundles')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java106
1 files changed, 74 insertions, 32 deletions
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 12182df2d0..cb78c9e1fb 100755
--- 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
@@ -3615,7 +3615,47 @@ boolean isItemSelected (NMTVCUSTOMDRAW nmcd) {
}
return selected;
}
-
+
+void redrawSelection () {
+ if ((style & SWT.SINGLE) != 0) {
+ int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ if (hItem != 0) {
+ RECT rect = new RECT ();
+ rect.left = hItem;
+ OS.SendMessage (handle, OS.TVM_GETITEMRECT, 0, rect);
+ OS.InvalidateRect (handle, rect, true);
+ }
+ } else {
+ int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
+ if (hItem != 0) {
+ TVITEM tvItem = null;
+ if (OS.IsWinCE) {
+ tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_STATE;
+ }
+ RECT rect = new RECT ();
+ int index = 0, count = OS.SendMessage (handle, OS.TVM_GETVISIBLECOUNT, 0, 0);
+ while (index < count && hItem != 0) {
+ int state = 0;
+ if (OS.IsWinCE) {
+ tvItem.hItem = hItem;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ state = tvItem.state;
+ } else {
+ state = OS.SendMessage (handle, OS.TVM_GETITEMSTATE, hItem, OS.TVIS_SELECTED);
+ }
+ if ((state & OS.TVIS_SELECTED) != 0) {
+ rect.left = hItem;
+ OS.SendMessage (handle, OS.TVM_GETITEMRECT, 0, rect);
+ OS.InvalidateRect (handle, rect, true);
+ }
+ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, hItem);
+ index++;
+ }
+ }
+ }
+}
+
void register () {
super.register ();
if (hwndParent != 0) display.addControl (hwndParent, this);
@@ -5619,26 +5659,27 @@ LRESULT WM_KILLFOCUS (int wParam, int lParam) {
* with alpha is expanded or collapsed, the area where
* the image is drawn is not erased before it is drawn.
* This means that the image gets darker each time.
- * The fix is to redraw the tree.
- */
- if (!OS.IsWinCE && OS.COMCTL32_MAJOR >= 6) {
- if (imageList != null) {
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- if ((bits & OS.TVS_FULLROWSELECT) == 0) {
- OS.InvalidateRect (handle, null, true);
- }
- }
- }
- if ((style & SWT.SINGLE) != 0) return result;
- /*
+ * The fix is to redraw the selection.
+ *
* Feature in Windows. When multiple item have
* the TVIS_SELECTED state, Windows redraws only
* the focused item in the color used to show the
* selection when the tree loses or gains focus.
- * The fix is to force Windows to redraw all the
- * visible items when focus is gained or lost.
+ * The fix is to force Windows to redraw the
+ * selection when focus is gained or lost.
*/
- OS.InvalidateRect (handle, null, false);
+ boolean redraw = (style & SWT.MULTI) != 0;
+ if (!redraw) {
+ if (!OS.IsWinCE && OS.COMCTL32_MAJOR >= 6) {
+ if (imageList != null) {
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.TVS_FULLROWSELECT) == 0) {
+ redraw = true;
+ }
+ }
+ }
+ }
+ if (redraw) redrawSelection ();
return result;
}
@@ -6269,32 +6310,33 @@ LRESULT WM_PRINTCLIENT (int wParam, int lParam) {
}
LRESULT WM_SETFOCUS (int wParam, int lParam) {
- LRESULT result = super.WM_SETFOCUS (wParam, lParam);
+ LRESULT result = super.WM_SETFOCUS (wParam, lParam);
/*
* Bug in Windows. When a tree item that has an image
* with alpha is expanded or collapsed, the area where
* the image is drawn is not erased before it is drawn.
* This means that the image gets darker each time.
- * The fix is to redraw the tree.
- */
- if (!OS.IsWinCE && OS.COMCTL32_MAJOR >= 6) {
- if (imageList != null) {
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- if ((bits & OS.TVS_FULLROWSELECT) == 0) {
- OS.InvalidateRect (handle, null, true);
- }
- }
- }
- if ((style & SWT.SINGLE) != 0) return result;
- /*
+ * The fix is to redraw the selection.
+ *
* Feature in Windows. When multiple item have
* the TVIS_SELECTED state, Windows redraws only
* the focused item in the color used to show the
* selection when the tree loses or gains focus.
- * The fix is to force Windows to redraw all the
- * visible items when focus is gained or lost.
+ * The fix is to force Windows to redraw the
+ * selection when focus is gained or lost.
*/
- OS.InvalidateRect (handle, null, false);
+ boolean redraw = (style & SWT.MULTI) != 0;
+ if (!redraw) {
+ if (!OS.IsWinCE && OS.COMCTL32_MAJOR >= 6) {
+ if (imageList != null) {
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.TVS_FULLROWSELECT) == 0) {
+ redraw = true;
+ }
+ }
+ }
+ }
+ if (redraw) redrawSelection ();
return result;
}