scrollbar: sizegrip

Huw D M Davies h.davies1 at physics.ox.ac.uk
Thu Nov 20 11:14:10 CST 2003


        Aric Stewart <aric at codeweavers.com>
        Huw Davies <huw at codeweavers.com>
        Some support for SS_SIZEGRIP        
-- 
Huw Davies
huw at codeweavers.com
Index: controls/scroll.c
===================================================================
RCS file: /home/wine/wine/controls/scroll.c,v
retrieving revision 1.71
diff -u -r1.71 scroll.c
--- controls/scroll.c	4 Nov 2003 04:21:15 -0000	1.71
+++ controls/scroll.c	20 Nov 2003 17:09:46 -0000
@@ -40,6 +40,7 @@
     INT   maxVal;   /* Maximum scroll-bar value */
     INT   page;     /* Page size of scroll bar (Win32) */
     UINT  flags;    /* EnableScrollBar flags */
+    BOOL  bSizeBox;  /* We are actaully a sizebox and not a scrollbar */
 } SCROLLBAR_INFO, *LPSCROLLBAR_INFO;
 
 
@@ -202,6 +203,7 @@
             infoPtr->flags  = ESB_ENABLE_BOTH;
             if (nBar == SB_HORZ) wndPtr->pHScroll = infoPtr;
             else wndPtr->pVScroll = infoPtr;
+            infoPtr->bSizeBox = FALSE;
         }
         if (!hUpArrow) SCROLL_LoadBitmaps();
     }
@@ -877,6 +879,38 @@
     WIN_ReleaseWndPtr(wndPtr);
 }
 
+/***********************************************************************
+ *           SCROLL_DrawSizeGrip
+ *
+ *  Draw the size grip.
+ */
+static void SCROLL_DrawSizeGrip( HWND hwnd,  HDC hdc)
+{
+    RECT rc;
+    int x;
+
+    GetClientRect( hwnd, &rc );
+    FillRect( hdc, &rc, GetSysColorBrush(COLOR_SCROLLBAR) );
+
+    x = 13; 
+    while (x > 3)
+    {
+        SelectObject(hdc, SYSCOLOR_GetPen(COLOR_WINDOW));
+        MoveToEx(hdc, rc.right - x, rc.bottom, NULL);
+        LineTo(hdc, rc.right, rc.bottom - x);
+        x--;
+
+        SelectObject(hdc, SYSCOLOR_GetPen(COLOR_BTNSHADOW));
+        MoveToEx(hdc, rc.right - x , rc.bottom, NULL);
+        LineTo(hdc, rc.right, rc.bottom - x);
+        x--;
+        MoveToEx(hdc, rc.right - x , rc.bottom, NULL);
+        LineTo(hdc, rc.right, rc.bottom - x);
+    
+        x-=2;
+    }
+}
+
 
 /***********************************************************************
  *           SCROLL_RefreshScrollBar
@@ -958,6 +992,32 @@
     if ((SCROLL_trackHitTest == SCROLL_NOWHERE) && (msg != WM_LBUTTONDOWN))
 		  return;
 
+    if (infoPtr->bSizeBox)
+    {
+        switch(msg)
+        {
+            case WM_LBUTTONDOWN:  /* Initialise mouse tracking */
+                HideCaret(hwnd);  /* hide caret while holding down LBUTTON */
+                SetCapture( hwnd );
+                prevPt = pt;
+                SCROLL_trackHitTest  = hittest = SCROLL_THUMB;
+                break;
+            case WM_MOUSEMOVE:
+                GetClientRect(GetParent(GetParent(hwnd)),&rect);
+                prevPt = pt;
+                break;
+            case WM_LBUTTONUP:
+                ReleaseCapture();
+                SCROLL_trackHitTest  = hittest = SCROLL_NOWHERE;
+                if (hwnd==GetFocus()) ShowCaret(hwnd);
+                break;
+            case WM_SYSTIMER:
+                pt = prevPt;
+                break;
+        }
+        return;
+    }
+
     hdc = GetDCEx( hwnd, 0, DCX_CACHE | ((nBar == SB_CTL) ? 0 : DCX_WINDOW));
     vertical = SCROLL_GetScrollBarRect( hwnd, nBar, &rect,
                                         &arrowSize, &thumbSize, &thumbPos );
@@ -1229,13 +1289,32 @@
 
     TRACE("hwnd=%p lpCreate=%p\n", hwnd, lpCreate);
 
+    if ((lpCreate->style & (SBS_SIZEGRIP | SBS_SIZEBOX)) || 
+        (GetWindowLongW( hwnd, GWL_STYLE ) & (SBS_SIZEGRIP | SBS_SIZEBOX)))
+        info->bSizeBox = TRUE;
+    else
+        info->bSizeBox = FALSE; 
+
     if (lpCreate->style & WS_DISABLED)
     {
         info->flags = ESB_DISABLE_BOTH;
         TRACE("Created WS_DISABLED scrollbar\n");
     }
 
-    if (lpCreate->style & SBS_VERT)
+
+    if (lpCreate->style & SBS_SIZEBOXTOPLEFTALIGN)
+    {
+        MoveWindow( hwnd, lpCreate->x, lpCreate->y, GetSystemMetrics(SM_CXVSCROLL)+1,
+                    GetSystemMetrics(SM_CYHSCROLL)+1, FALSE );
+    }
+    else if(lpCreate->style & SBS_SIZEBOXBOTTOMRIGHTALIGN)
+    {
+        MoveWindow( hwnd, lpCreate->x+lpCreate->cx-GetSystemMetrics(SM_CXVSCROLL)-1, 
+                    lpCreate->y+lpCreate->cy-GetSystemMetrics(SM_CYHSCROLL)-1,
+                    GetSystemMetrics(SM_CXVSCROLL)+1,
+                    GetSystemMetrics(SM_CYHSCROLL)+1, FALSE );
+    }
+    else if (lpCreate->style & SBS_VERT)
     {
         if (lpCreate->style & SBS_LEFTALIGN)
             MoveWindow( hwnd, lpCreate->x, lpCreate->y,
@@ -1432,7 +1511,11 @@
         {
             PAINTSTRUCT ps;
             HDC hdc = wParam ? (HDC)wParam : BeginPaint(hwnd, &ps);
-            if (GetWindowLongW( hwnd, GWL_STYLE ) & SBS_SIZEBOX)
+            if (GetWindowLongW( hwnd, GWL_STYLE ) & SBS_SIZEGRIP)
+            {
+                SCROLL_DrawSizeGrip( hwnd, hdc);
+            }
+            else if (GetWindowLongW( hwnd, GWL_STYLE ) & SBS_SIZEBOX)
             {
                 RECT rc;
                 GetClientRect( hwnd, &rc );



More information about the wine-patches mailing list