summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java
diff options
context:
space:
mode:
authorFelipe Heidrich <fheidric>2006-05-02 21:29:10 +0000
committerFelipe Heidrich <fheidric>2006-05-02 21:29:10 +0000
commitaee214234b2413033c234516d23a9041155855a2 (patch)
tree8134e54688715cf241835c16eff949c06abbc62d /bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java
parent603b05a39f7173939b06bae6ef3e5ec76199299c (diff)
downloadeclipse.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/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java63
1 files changed, 48 insertions, 15 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;
}