Commit 07f86907 authored by Frank Richter's avatar Frank Richter Committed by Alexandre Julliard

Add hottracking support for the header control.

parent 50cd0e02
...@@ -416,7 +416,7 @@ HEADER_RefreshItem (HWND hwnd, HDC hdc, INT iItem) ...@@ -416,7 +416,7 @@ HEADER_RefreshItem (HWND hwnd, HDC hdc, INT iItem)
hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT); hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT);
hOldFont = SelectObject (hdc, hFont); hOldFont = SelectObject (hdc, hFont);
HEADER_DrawItem (hwnd, hdc, iItem, FALSE); HEADER_DrawItem (hwnd, hdc, iItem, infoPtr->iHotItem == iItem);
SelectObject (hdc, hOldFont); SelectObject (hdc, hOldFont);
} }
...@@ -1580,6 +1580,22 @@ HEADER_NotifyFormat (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1580,6 +1580,22 @@ HEADER_NotifyFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
static LRESULT static LRESULT
HEADER_MouseLeave (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
/* Reset hot-tracked item when mouse leaves control. */
INT oldHotItem = infoPtr->iHotItem;
HDC hdc = GetDC (hwnd);
infoPtr->iHotItem = -1;
if (oldHotItem != -1) HEADER_RefreshItem (hwnd, hdc, oldHotItem);
ReleaseDC (hwnd, hdc);
return 0;
}
static LRESULT
HEADER_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam) HEADER_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
{ {
HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd); HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
...@@ -1588,28 +1604,35 @@ HEADER_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1588,28 +1604,35 @@ HEADER_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
UINT flags; UINT flags;
INT nItem, nWidth; INT nItem, nWidth;
HDC hdc; HDC hdc;
/* With theming, hottracking is always enabled */
BOOL hotTrackEnabled =
((dwStyle & HDS_BUTTONS) && (dwStyle & HDS_HOTTRACK))
|| (GetWindowTheme (hwnd) != NULL);
INT oldHotItem = infoPtr->iHotItem;
pt.x = (INT)(SHORT)LOWORD(lParam); pt.x = (INT)(SHORT)LOWORD(lParam);
pt.y = (INT)(SHORT)HIWORD(lParam); pt.y = (INT)(SHORT)HIWORD(lParam);
HEADER_InternalHitTest (hwnd, &pt, &flags, &nItem); HEADER_InternalHitTest (hwnd, &pt, &flags, &nItem);
if ((dwStyle & HDS_BUTTONS) && (dwStyle & HDS_HOTTRACK)) { if (hotTrackEnabled) {
if (flags & (HHT_ONHEADER | HHT_ONDIVIDER | HHT_ONDIVOPEN)) if (flags & (HHT_ONHEADER | HHT_ONDIVIDER | HHT_ONDIVOPEN))
infoPtr->iHotItem = nItem; infoPtr->iHotItem = nItem;
else else
infoPtr->iHotItem = -1; infoPtr->iHotItem = -1;
InvalidateRect(hwnd, NULL, FALSE);
} }
if (infoPtr->bCaptured) { if (infoPtr->bCaptured) {
if (infoPtr->bPressed) { if (infoPtr->bPressed) {
BOOL oldState = infoPtr->items[infoPtr->iMoveItem].bDown;
if ((nItem == infoPtr->iMoveItem) && (flags == HHT_ONHEADER)) if ((nItem == infoPtr->iMoveItem) && (flags == HHT_ONHEADER))
infoPtr->items[infoPtr->iMoveItem].bDown = TRUE; infoPtr->items[infoPtr->iMoveItem].bDown = TRUE;
else else
infoPtr->items[infoPtr->iMoveItem].bDown = FALSE; infoPtr->items[infoPtr->iMoveItem].bDown = FALSE;
if (oldState != infoPtr->items[infoPtr->iMoveItem].bDown) {
hdc = GetDC (hwnd); hdc = GetDC (hwnd);
HEADER_RefreshItem (hwnd, hdc, infoPtr->iMoveItem); HEADER_RefreshItem (hwnd, hdc, infoPtr->iMoveItem);
ReleaseDC (hwnd, hdc); ReleaseDC (hwnd, hdc);
}
TRACE("Moving pressed item %d!\n", infoPtr->iMoveItem); TRACE("Moving pressed item %d!\n", infoPtr->iMoveItem);
} }
...@@ -1642,8 +1665,18 @@ HEADER_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1642,8 +1665,18 @@ HEADER_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
} }
} }
if ((dwStyle & HDS_BUTTONS) && (dwStyle & HDS_HOTTRACK)) { if (hotTrackEnabled) {
FIXME("hot track support!\n"); TRACKMOUSEEVENT tme;
if (oldHotItem != infoPtr->iHotItem) {
hdc = GetDC (hwnd);
if (oldHotItem != -1) HEADER_RefreshItem (hwnd, hdc, oldHotItem);
if (infoPtr->iHotItem != -1) HEADER_RefreshItem (hwnd, hdc, infoPtr->iHotItem);
ReleaseDC (hwnd, hdc);
}
tme.cbSize = sizeof( tme );
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = hwnd;
TrackMouseEvent( &tme );
} }
return 0; return 0;
...@@ -1853,6 +1886,9 @@ HEADER_WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -1853,6 +1886,9 @@ HEADER_WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_LBUTTONUP: case WM_LBUTTONUP:
return HEADER_LButtonUp (hwnd, wParam, lParam); return HEADER_LButtonUp (hwnd, wParam, lParam);
case WM_MOUSELEAVE:
return HEADER_MouseLeave (hwnd, wParam, lParam);
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
return HEADER_MouseMove (hwnd, wParam, lParam); return HEADER_MouseMove (hwnd, wParam, lParam);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment