diff options
author | Felipe Heidrich <fheidric> | 2006-05-02 21:29:10 +0000 |
---|---|---|
committer | Felipe Heidrich <fheidric> | 2006-05-02 21:29:10 +0000 |
commit | aee214234b2413033c234516d23a9041155855a2 (patch) | |
tree | 8134e54688715cf241835c16eff949c06abbc62d /bundles | |
parent | 603b05a39f7173939b06bae6ef3e5ec76199299c (diff) | |
download | eclipse.platform.swt-aee214234b2413033c234516d23a9041155855a2.tar.gz eclipse.platform.swt-aee214234b2413033c234516d23a9041155855a2.tar.xz eclipse.platform.swt-aee214234b2413033c234516d23a9041155855a2.zip |
Bug 139400 - ExpandItem header should set cursor to CURSOR_HAND in Windows
Diffstat (limited to 'bundles')
3 files changed, 58 insertions, 16 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java index bf7a58a738..abc71a3548 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java @@ -175,6 +175,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) { void createHandle () { super.createHandle (); state &= ~CANVAS; + state |= TRACK_MOUSE; } void createItem (ExpandItem item, int style, int index) { @@ -293,6 +294,17 @@ Control findThemeControl () { return isAppThemed () ? this : super.findThemeControl (); } +int getBandHeight () { + if (hFont == 0) return ExpandItem.CHEVRON_SIZE; + int hDC = OS.GetDC (handle); + int oldHFont = OS.SelectObject (hDC, hFont); + TEXTMETRIC lptm = OS.IsUnicode ? (TEXTMETRIC)new TEXTMETRICW() : new TEXTMETRICA(); + OS.GetTextMetrics (hDC, lptm); + OS.SelectObject (hDC, oldHFont); + OS.ReleaseDC (handle, hDC); + return Math.max (ExpandItem.CHEVRON_SIZE, lptm.tmHeight + 4); +} + /** * Returns the item at the given, zero-relative index in the * receiver. Throws an exception if the index is out of range. @@ -367,17 +379,6 @@ public int getSpacing () { return spacing; } -int getBandHeight () { - if (hFont == 0) return ExpandItem.CHEVRON_SIZE; - int hDC = OS.GetDC (handle); - int oldHFont = OS.SelectObject (hDC, hFont); - TEXTMETRIC lptm = OS.IsUnicode ? (TEXTMETRIC)new TEXTMETRICW() : new TEXTMETRICA(); - OS.GetTextMetrics (hDC, lptm); - OS.SelectObject (hDC, oldHFont); - OS.ReleaseDC (handle, hDC); - return Math.max (ExpandItem.CHEVRON_SIZE, lptm.tmHeight + 4); -} - /** * Searches the receiver's list starting at the first item * (index 0) until an item is found that is equal to the @@ -604,7 +605,7 @@ LRESULT WM_LBUTTONDOWN (int wParam, int lParam) { int y = (short) (lParam >> 16); for (int i = 0; i < itemCount; i++) { ExpandItem item = items[i]; - boolean hover = item.x <= x && x < (item.x + item.width) && item.y <= y && y < (item.y + getBandHeight()); + boolean hover = item.isHover (x, y); if (hover && focusItem != item) { focusItem.redraw (true); focusItem = item; @@ -622,7 +623,7 @@ LRESULT WM_LBUTTONUP (int wParam, int lParam) { if (focusItem == null) return result; int x = (short) (lParam & 0xFFFF); int y = (short) (lParam >> 16); - boolean hover = focusItem.x <= x && x < (focusItem.x + focusItem.width) && focusItem.y <= y && y < (focusItem.y + getBandHeight()); + boolean hover = focusItem.isHover (x, y); if (hover) { Event event = new Event (); event.item = focusItem; @@ -633,14 +634,28 @@ LRESULT WM_LBUTTONUP (int wParam, int lParam) { return result; } +LRESULT WM_MOUSELEAVE (int wParam, int lParam) { + LRESULT result = super.WM_MOUSELEAVE (wParam, lParam); + if (result != null) return result; + for (int i = 0; i < itemCount; i++) { + ExpandItem item = items [i]; + if (item.hover) { + item.hover = false; + item.redraw (false); + break; + } + } + return result; +} + LRESULT WM_MOUSEMOVE (int wParam, int lParam) { LRESULT result = super.WM_MOUSEMOVE (wParam, lParam); if (result == LRESULT.ZERO) return result; int x = (short) (lParam & 0xFFFF); int y = (short) (lParam >> 16); for (int i = 0; i < itemCount; i++) { - ExpandItem item = items[i]; - boolean hover = item.x <= x && x < (item.x + item.width) && item.y <= y && y < (item.y + getBandHeight()); + ExpandItem item = items [i]; + boolean hover = item.isHover (x, y); if (item.hover != hover) { item.hover = hover; item.redraw (false); @@ -691,6 +706,23 @@ LRESULT WM_PRINTCLIENT (int wParam, int lParam) { return result; } +LRESULT WM_SETCURSOR (int wParam, int lParam) { + LRESULT result = super.WM_SETCURSOR (wParam, lParam); + if (result != null) return result; + int hitTest = lParam & 0xFFFF; + if (hitTest == OS.HTCLIENT) { + for (int i = 0; i < itemCount; i++) { + ExpandItem item = items [i]; + if (item.hover) { + int hCursor = OS.LoadCursor (0, OS.IDC_HAND); + OS.SetCursor (hCursor); + return LRESULT.ONE; + } + } + } + return result; +} + LRESULT WM_SETFOCUS (int wParam, int lParam) { LRESULT result = super.WM_SETFOCUS (wParam, lParam); if (focusItem != null) focusItem.redraw (true); @@ -707,6 +739,7 @@ LRESULT WM_SIZE (int wParam, int lParam) { if (item.width != width) item.setBounds (0, 0, width, item.height, false, true); } setScrollbar (); + OS.InvalidateRect (handle, null, true); return result; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java index 9372e9d295..75fcf1d5d4 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java @@ -335,6 +335,11 @@ int getPreferredWidth (int hTheme, int hDC) { return width; } +boolean isHover (int x, int y) { + int bandHeight = parent.getBandHeight (); + return this.x < x && x < (this.x + width) && this.y < y && y < (this.y + bandHeight); +} + void redraw (boolean all) { int parentHandle = parent.handle; int headerHeight = parent.getBandHeight (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java index c692e78510..a946db1ae5 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java @@ -75,6 +75,9 @@ public abstract class Widget { static final int RELEASED = 1<<11; static final int DISPOSE_SENT = 1<<12; + /* Mouse track flag */ + static final int TRACK_MOUSE = 1<<13; + /* Default size for widgets */ static final int DEFAULT_WIDTH = 64; static final int DEFAULT_HEIGHT = 64; @@ -1897,10 +1900,11 @@ LRESULT wmMouseMove (int hwnd, int wParam, int lParam) { int pos = OS.GetMessagePos (); if (pos != display.lastMouse || display.captureChanged) { if (!OS.IsWinCE) { + boolean trackMouse = (state & TRACK_MOUSE) != 0; boolean mouseEnter = hooks (SWT.MouseEnter) || display.filters (SWT.MouseEnter); boolean mouseExit = hooks (SWT.MouseExit) || display.filters (SWT.MouseExit); boolean mouseHover = hooks (SWT.MouseHover) || display.filters (SWT.MouseHover); - if (mouseEnter || mouseExit || mouseHover) { + if (trackMouse || mouseEnter || mouseExit || mouseHover) { TRACKMOUSEEVENT lpEventTrack = new TRACKMOUSEEVENT (); lpEventTrack.cbSize = TRACKMOUSEEVENT.sizeof; lpEventTrack.dwFlags = OS.TME_QUERY; |