Commit ce7f12c4 authored by Susan Farley's avatar Susan Farley Committed by Alexandre Julliard

Implement autorepeat scrolling when button is held down.

Improvements to size and appearance of buttons.
parent 382d2175
...@@ -34,7 +34,7 @@ typedef struct ...@@ -34,7 +34,7 @@ typedef struct
BOOL bForward; /* forward WM_MOUSEMOVE msgs to the contained wnd */ BOOL bForward; /* forward WM_MOUSEMOVE msgs to the contained wnd */
INT TLbtnState; /* state of top or left btn */ INT TLbtnState; /* state of top or left btn */
INT BRbtnState; /* state of bottom or right btn */ INT BRbtnState; /* state of bottom or right btn */
INT direction; /* direction of the scroll, (e.g. PGF_SCROLLUP) */
} PAGER_INFO; } PAGER_INFO;
#define PAGER_GetInfoPtr(hwnd) ((PAGER_INFO *)GetWindowLongA(hwnd, 0)) #define PAGER_GetInfoPtr(hwnd) ((PAGER_INFO *)GetWindowLongA(hwnd, 0))
...@@ -43,6 +43,10 @@ typedef struct ...@@ -43,6 +43,10 @@ typedef struct
#define MIN_ARROW_WIDTH 8 #define MIN_ARROW_WIDTH 8
#define MIN_ARROW_HEIGHT 5 #define MIN_ARROW_HEIGHT 5
#define TIMERID1 1
#define TIMERID2 2
#define INITIAL_DELAY 500
#define REPEAT_DELAY 50
/* the horizontal arrows are: /* the horizontal arrows are:
* *
...@@ -161,13 +165,11 @@ PAGER_DrawButton(HDC hdc, COLORREF clrBk, RECT arrowRect, ...@@ -161,13 +165,11 @@ PAGER_DrawButton(HDC hdc, COLORREF clrBk, RECT arrowRect,
if (btnState == PGF_HOT) if (btnState == PGF_HOT)
{ {
rc.left++, rc.top++; rc.right++, rc.bottom++; DrawEdge( hdc, &rc, BDR_RAISEDINNER, BF_RECT);
DrawEdge( hdc, &rc, EDGE_RAISED, BF_RECT);
if (horz) if (horz)
PAGER_DrawHorzArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft); PAGER_DrawHorzArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
else else
PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft); PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
rc.left--, rc.top--; rc.right--, rc.bottom--;
} }
else if (btnState == PGF_NORMAL) else if (btnState == PGF_NORMAL)
{ {
...@@ -179,13 +181,11 @@ PAGER_DrawButton(HDC hdc, COLORREF clrBk, RECT arrowRect, ...@@ -179,13 +181,11 @@ PAGER_DrawButton(HDC hdc, COLORREF clrBk, RECT arrowRect,
} }
else if (btnState == PGF_DEPRESSED) else if (btnState == PGF_DEPRESSED)
{ {
rc.left++, rc.top++;
DrawEdge( hdc, &rc, BDR_SUNKENOUTER, BF_RECT); DrawEdge( hdc, &rc, BDR_SUNKENOUTER, BF_RECT);
if (horz) if (horz)
PAGER_DrawHorzArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft); PAGER_DrawHorzArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
else else
PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft); PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
rc.left--, rc.top--;
} }
else if (btnState == PGF_GRAYED) else if (btnState == PGF_GRAYED)
{ {
...@@ -202,7 +202,6 @@ PAGER_DrawButton(HDC hdc, COLORREF clrBk, RECT arrowRect, ...@@ -202,7 +202,6 @@ PAGER_DrawButton(HDC hdc, COLORREF clrBk, RECT arrowRect,
rc.left++, rc.top++; rc.right++, rc.bottom++; rc.left++, rc.top++; rc.right++, rc.bottom++;
PAGER_DrawVertArrow(hdc, rc, COLOR_3DSHADOW, topLeft); PAGER_DrawVertArrow(hdc, rc, COLOR_3DSHADOW, topLeft);
} }
rc.left--, rc.top--; rc.right--, rc.bottom--;
} }
SelectObject( hdc, hOldBrush ); SelectObject( hdc, hOldBrush );
...@@ -469,6 +468,7 @@ PAGER_SetPos(HWND hwnd, INT newPos, BOOL fromBtnPress) ...@@ -469,6 +468,7 @@ PAGER_SetPos(HWND hwnd, INT newPos, BOOL fromBtnPress)
{ {
PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
INT scrollRange = PAGER_GetScrollRange(hwnd, infoPtr); INT scrollRange = PAGER_GetScrollRange(hwnd, infoPtr);
INT oldPos = infoPtr->nPos;
if ((scrollRange <= 0) || (newPos < 0)) if ((scrollRange <= 0) || (newPos < 0))
infoPtr->nPos = 0; infoPtr->nPos = 0;
...@@ -479,9 +479,12 @@ PAGER_SetPos(HWND hwnd, INT newPos, BOOL fromBtnPress) ...@@ -479,9 +479,12 @@ PAGER_SetPos(HWND hwnd, INT newPos, BOOL fromBtnPress)
TRACE("[%04x] pos=%d\n", hwnd, infoPtr->nPos); TRACE("[%04x] pos=%d\n", hwnd, infoPtr->nPos);
/* gray and restore btns, and if from WM_SETPOS, hide the gray btns */ if (infoPtr->nPos != oldPos)
PAGER_UpdateBtns(hwnd, infoPtr, scrollRange, !fromBtnPress); {
PAGER_PositionChildWnd(hwnd, infoPtr); /* gray and restore btns, and if from WM_SETPOS, hide the gray btns */
PAGER_UpdateBtns(hwnd, infoPtr, scrollRange, !fromBtnPress);
PAGER_PositionChildWnd(hwnd, infoPtr);
}
return 0; return 0;
} }
...@@ -558,7 +561,7 @@ PAGER_SetFixedHeight(HWND hwnd, PAGER_INFO* infoPtr) ...@@ -558,7 +561,7 @@ PAGER_SetFixedHeight(HWND hwnd, PAGER_INFO* infoPtr)
{ {
delta = wndRect.bottom - wndRect.top - infoPtr->nHeight; delta = wndRect.bottom - wndRect.top - infoPtr->nHeight;
if (delta > infoPtr->nButtonSize) if (delta > infoPtr->nButtonSize)
infoPtr->nHeight += 4 * infoPtr->nButtonSize / 3; infoPtr->nHeight += infoPtr->nButtonSize;
else if (delta > 0) else if (delta > 0)
infoPtr->nHeight += infoPtr->nButtonSize / 3; infoPtr->nHeight += infoPtr->nButtonSize / 3;
} }
...@@ -585,7 +588,10 @@ PAGER_RecalcSize(HWND hwnd) ...@@ -585,7 +588,10 @@ PAGER_RecalcSize(HWND hwnd)
INT scrollRange = PAGER_GetScrollRange(hwnd, infoPtr); INT scrollRange = PAGER_GetScrollRange(hwnd, infoPtr);
if (scrollRange <= 0) if (scrollRange <= 0)
{
infoPtr->nPos = -1;
PAGER_SetPos(hwnd, 0, FALSE); PAGER_SetPos(hwnd, 0, FALSE);
}
else else
{ {
PAGER_UpdateBtns(hwnd, infoPtr, scrollRange, TRUE); PAGER_UpdateBtns(hwnd, infoPtr, scrollRange, TRUE);
...@@ -664,6 +670,7 @@ PAGER_SetChild (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -664,6 +670,7 @@ PAGER_SetChild (HWND hwnd, WPARAM wParam, LPARAM lParam)
0,0,0,0, 0,0,0,0,
SWP_SHOWWINDOW | SWP_NOSIZE); SWP_SHOWWINDOW | SWP_NOSIZE);
infoPtr->nPos = -1;
PAGER_SetPos(hwnd, 0, FALSE); PAGER_SetPos(hwnd, 0, FALSE);
} }
...@@ -708,11 +715,15 @@ PAGER_Scroll(HWND hwnd, INT dir) ...@@ -708,11 +715,15 @@ PAGER_Scroll(HWND hwnd, INT dir)
if (nmpgScroll.iScroll > 0) if (nmpgScroll.iScroll > 0)
{ {
infoPtr->direction = dir;
if (dir == PGF_SCROLLLEFT || dir == PGF_SCROLLUP) if (dir == PGF_SCROLLLEFT || dir == PGF_SCROLLUP)
PAGER_SetPos(hwnd, infoPtr->nPos - nmpgScroll.iScroll, TRUE); PAGER_SetPos(hwnd, infoPtr->nPos - nmpgScroll.iScroll, TRUE);
else else
PAGER_SetPos(hwnd, infoPtr->nPos + nmpgScroll.iScroll, TRUE); PAGER_SetPos(hwnd, infoPtr->nPos + nmpgScroll.iScroll, TRUE);
} }
else
infoPtr->direction = -1;
} }
} }
...@@ -738,6 +749,7 @@ PAGER_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -738,6 +749,7 @@ PAGER_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
infoPtr->bForward = FALSE; infoPtr->bForward = FALSE;
infoPtr->TLbtnState = PGF_INVISIBLE; infoPtr->TLbtnState = PGF_INVISIBLE;
infoPtr->BRbtnState = PGF_INVISIBLE; infoPtr->BRbtnState = PGF_INVISIBLE;
infoPtr->direction = -1;
if (dwStyle & PGS_AUTOSCROLL) if (dwStyle & PGS_AUTOSCROLL)
FIXME("[%04x] Autoscroll style is not implemented yet.\n", hwnd); FIXME("[%04x] Autoscroll style is not implemented yet.\n", hwnd);
...@@ -968,6 +980,9 @@ PAGER_MouseLeave (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -968,6 +980,9 @@ PAGER_MouseLeave (HWND hwnd, WPARAM wParam, LPARAM lParam)
{ {
PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
KillTimer (hwnd, TIMERID1);
KillTimer (hwnd, TIMERID2);
TRACE("[%04x] ReleaseCapture\n", hwnd); TRACE("[%04x] ReleaseCapture\n", hwnd);
ReleaseCapture(); ReleaseCapture();
...@@ -1005,11 +1020,13 @@ PAGER_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1005,11 +1020,13 @@ PAGER_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
{ {
repaintBtns = infoPtr->TLbtnState != PGF_DEPRESSED; repaintBtns = infoPtr->TLbtnState != PGF_DEPRESSED;
infoPtr->TLbtnState = PGF_DEPRESSED; infoPtr->TLbtnState = PGF_DEPRESSED;
SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0);
} }
else if (hit == HTRIGHT || hit == HTBOTTOM) else if (hit == HTRIGHT || hit == HTBOTTOM)
{ {
repaintBtns = infoPtr->BRbtnState != PGF_DEPRESSED; repaintBtns = infoPtr->BRbtnState != PGF_DEPRESSED;
infoPtr->BRbtnState = PGF_DEPRESSED; infoPtr->BRbtnState = PGF_DEPRESSED;
SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0);
} }
if (repaintBtns) if (repaintBtns)
...@@ -1046,6 +1063,9 @@ PAGER_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1046,6 +1063,9 @@ PAGER_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
TRACE("[%04x]\n", hwnd); TRACE("[%04x]\n", hwnd);
KillTimer (hwnd, TIMERID1);
KillTimer (hwnd, TIMERID2);
/* make PRESSED btns NORMAL but don't hide gray btns */ /* make PRESSED btns NORMAL but don't hide gray btns */
PAGER_UpdateBtns(hwnd, infoPtr, -1, FALSE); PAGER_UpdateBtns(hwnd, infoPtr, -1, FALSE);
...@@ -1188,6 +1208,22 @@ PAGER_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ...@@ -1188,6 +1208,22 @@ PAGER_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_PAINT: case WM_PAINT:
return PAGER_Paint (hwnd, wParam); return PAGER_Paint (hwnd, wParam);
*/ */
case WM_TIMER:
/* if initial timer, kill it and start the repeat timer */
if (wParam == TIMERID1)
{
KillTimer(hwnd, TIMERID1);
SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0);
}
KillTimer(hwnd, TIMERID2);
if (infoPtr->direction > 0)
{
PAGER_Scroll(hwnd, infoPtr->direction);
SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0);
}
break;
case WM_NOTIFY: case WM_NOTIFY:
case WM_COMMAND: case WM_COMMAND:
return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam); return SendMessageA (GetParent (hwnd), uMsg, 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