page scroller - autorepeat btn press

Susan Farley susan at codeweavers.com
Wed May 2 14:04:36 CDT 2001


Changelog:
* dlls/comctl32/pager.c

Implements autorepeat scrolling when button is held down.
Improvements to size and appearance of buttons.


Susan Farley <susan at codeweavers.com>
-------------- next part --------------
Index: dlls/comctl32/pager.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/pager.c,v
retrieving revision 1.26
diff -u -r1.26 pager.c
--- dlls/comctl32/pager.c	2001/03/05 20:00:16	1.26
+++ dlls/comctl32/pager.c	2001/05/02 19:54:24
@@ -34,7 +34,7 @@
     BOOL   bForward;   /* forward WM_MOUSEMOVE msgs to the contained wnd */
     INT    TLbtnState; /* state of top or left btn */
     INT    BRbtnState; /* state of bottom or right btn */
-
+    INT    direction;  /* direction of the scroll, (e.g. PGF_SCROLLUP) */
 } PAGER_INFO;
 
 #define PAGER_GetInfoPtr(hwnd) ((PAGER_INFO *)GetWindowLongA(hwnd, 0))
@@ -43,6 +43,10 @@
 #define MIN_ARROW_WIDTH  8
 #define MIN_ARROW_HEIGHT 5
 
+#define TIMERID1         1
+#define TIMERID2         2
+#define INITIAL_DELAY    500
+#define REPEAT_DELAY     50
 
 /* the horizontal arrows are: 
  *
@@ -161,13 +165,11 @@
 
     if (btnState == PGF_HOT) 
     {
-       rc.left++, rc.top++; rc.right++, rc.bottom++;
-       DrawEdge( hdc, &rc, EDGE_RAISED, BF_RECT);
+       DrawEdge( hdc, &rc, BDR_RAISEDINNER, BF_RECT);
        if (horz)
            PAGER_DrawHorzArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
        else
            PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
-       rc.left--, rc.top--; rc.right--, rc.bottom--;
     }
     else if (btnState == PGF_NORMAL) 
     {
@@ -179,13 +181,11 @@
     }
     else if (btnState == PGF_DEPRESSED) 
     {
-       rc.left++, rc.top++;
        DrawEdge( hdc, &rc, BDR_SUNKENOUTER, BF_RECT);
        if (horz)
            PAGER_DrawHorzArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
        else
            PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
-       rc.left--, rc.top--;
     }
     else if (btnState == PGF_GRAYED) 
     {
@@ -202,7 +202,6 @@
            rc.left++, rc.top++; rc.right++, rc.bottom++;
            PAGER_DrawVertArrow(hdc, rc, COLOR_3DSHADOW, topLeft);
        }
-       rc.left--, rc.top--; rc.right--, rc.bottom--;
     }
 
     SelectObject( hdc, hOldBrush );
@@ -469,6 +468,7 @@
 {
     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     INT scrollRange = PAGER_GetScrollRange(hwnd, infoPtr);
+    INT oldPos = infoPtr->nPos;
 
     if ((scrollRange <= 0) || (newPos < 0))
         infoPtr->nPos = 0;
@@ -479,9 +479,12 @@
 
     TRACE("[%04x] pos=%d\n", hwnd, infoPtr->nPos);
 
-    /* gray and restore btns, and if from WM_SETPOS, hide the gray btns */
-    PAGER_UpdateBtns(hwnd, infoPtr, scrollRange, !fromBtnPress);
-    PAGER_PositionChildWnd(hwnd, infoPtr);
+    if (infoPtr->nPos != oldPos)
+    {
+        /* 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;
 }
@@ -558,7 +561,7 @@
     {
         delta = wndRect.bottom - wndRect.top - infoPtr->nHeight;
         if (delta > infoPtr->nButtonSize)
-            infoPtr->nHeight += 4 * infoPtr->nButtonSize / 3;
+            infoPtr->nHeight += infoPtr->nButtonSize;
         else if (delta > 0)
             infoPtr->nHeight +=  infoPtr->nButtonSize / 3;
     }
@@ -585,7 +588,10 @@
         INT scrollRange = PAGER_GetScrollRange(hwnd, infoPtr);
 
         if (scrollRange <= 0)
+        {
+            infoPtr->nPos = -1;
             PAGER_SetPos(hwnd, 0, FALSE);
+        }
         else 
         {
             PAGER_UpdateBtns(hwnd, infoPtr, scrollRange, TRUE);
@@ -664,6 +670,7 @@
                      0,0,0,0,
                      SWP_SHOWWINDOW | SWP_NOSIZE);
 
+        infoPtr->nPos = -1;
         PAGER_SetPos(hwnd, 0, FALSE);
     }
 
@@ -708,11 +715,15 @@
 
         if (nmpgScroll.iScroll > 0)
         {
+            infoPtr->direction = dir;
+
             if (dir == PGF_SCROLLLEFT || dir == PGF_SCROLLUP)
                 PAGER_SetPos(hwnd, infoPtr->nPos - nmpgScroll.iScroll, TRUE);
             else
                 PAGER_SetPos(hwnd, infoPtr->nPos + nmpgScroll.iScroll, TRUE);
         }
+        else
+            infoPtr->direction = -1;
     }
 }
 
@@ -738,6 +749,7 @@
     infoPtr->bForward = FALSE;
     infoPtr->TLbtnState = PGF_INVISIBLE;
     infoPtr->BRbtnState = PGF_INVISIBLE;
+    infoPtr->direction = -1;
 
     if (dwStyle & PGS_AUTOSCROLL)
         FIXME("[%04x] Autoscroll style is not implemented yet.\n", hwnd);
@@ -968,6 +980,9 @@
 {
     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
 
+    KillTimer (hwnd, TIMERID1);
+    KillTimer (hwnd, TIMERID2);
+
     TRACE("[%04x] ReleaseCapture\n", hwnd);
     ReleaseCapture();
 
@@ -1005,11 +1020,13 @@
     {
         repaintBtns = infoPtr->TLbtnState != PGF_DEPRESSED;
         infoPtr->TLbtnState = PGF_DEPRESSED;
+        SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 
     }
     else if (hit == HTRIGHT || hit == HTBOTTOM)
     {
         repaintBtns = infoPtr->BRbtnState != PGF_DEPRESSED;
         infoPtr->BRbtnState = PGF_DEPRESSED;
+        SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 
     }
 
     if (repaintBtns)
@@ -1046,6 +1063,9 @@
     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     TRACE("[%04x]\n", hwnd);
 
+    KillTimer (hwnd, TIMERID1);
+    KillTimer (hwnd, TIMERID2);
+
     /* make PRESSED btns NORMAL but don't hide gray btns */
     PAGER_UpdateBtns(hwnd, infoPtr, -1, FALSE);
 
@@ -1188,6 +1208,22 @@
         case WM_PAINT:
             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_COMMAND:
             return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);



More information about the wine-patches mailing list