Changeset 538 for trunk/src


Ignore:
Timestamp:
Aug 17, 1999, 11:13:57 PM (26 years ago)
Author:
cbratschi
Message:

trackbar finished

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/trackbar.c

    r496 r538  
    1 /* $Id: trackbar.c,v 1.12 1999-08-14 16:13:15 cbratschi Exp $ */
     1/* $Id: trackbar.c,v 1.13 1999-08-17 21:13:57 cbratschi Exp $ */
    22/*
    33 * Trackbar control
     
    1212 *
    1313 *   - more notifications. (CB: should be complete)
    14  *   - TRACKBAR_UpdateThumb, TRACKBAR_UpdateThumbPosition:
    15  *     use a memory dc to avoid flickering by short movements
     14 *   - Status: ready to use
    1615 */
    1716
     
    2221
    2322
    24 #define TRACKBAR_GetInfoPtr(wndPtr) ((TRACKBAR_INFO *)GetWindowLongA (hwnd,0))
     23#define TRACKBAR_GetInfoPtr(hwnd) ((TRACKBAR_INFO*)GetWindowLongA(hwnd,0))
    2524
    2625
     
    730729//update thumb position
    731730
    732 static VOID TRACKBAR_UpdateThumbPosition(HWND hwnd,INT lastPos)
     731static VOID TRACKBAR_UpdateThumbPosition(HWND hwnd,INT lastPos,BOOL mustRedraw)
    733732{
    734733   HDC hdc;
    735734   TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(hwnd);
    736735   DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    737    RECT lastRect,newRect;
    738    HRGN hrgn,hrgnLast,hrgnNew;
     736   RECT lastRect,newRect,windowRect;
     737   HDC hdcCompatible;
     738   HBITMAP bitmap,oldbmp;
    739739
    740740   //last
     
    755755   newRect = infoPtr->rcFullThumb;
    756756
     757   //same rect?
     758   if (!mustRedraw && EqualRect(&lastRect,&newRect)) return;
    757759
    758760   //3D frame adjustation
     
    762764   newRect.bottom++;
    763765
     766   //BitBlt from memory -> no flickering
     767   GetClientRect(hwnd,&windowRect);
    764768   hdc = GetDC(hwnd);
    765    hrgnLast = CreateRectRgnIndirect(&lastRect);
    766    hrgnNew = CreateRectRgnIndirect(&newRect);
    767    hrgn = CreateRectRgn(0,0,0,0);
    768    CombineRgn(hrgn,hrgnLast,hrgnNew,RGN_OR);
    769    SelectClipRgn(hdc,hrgn);
    770    TRACKBAR_Draw(hwnd,hdc);
    771    SelectClipRgn(hdc,0);
    772    DeleteObject(hrgnLast);
    773    DeleteObject(hrgnNew);
    774    DeleteObject(hrgn);
     769   hdcCompatible = CreateCompatibleDC(hdc);
     770   bitmap = CreateCompatibleBitmap(hdc,windowRect.right,windowRect.bottom);
     771   oldbmp = SelectObject(hdcCompatible,bitmap);
     772   TRACKBAR_Draw(hwnd,hdcCompatible);
     773   if (dwStyle & TBS_VERT)
     774   {
     775     if (lastRect.top > newRect.top && lastRect.top < newRect.bottom)
     776       BitBlt(hdc,newRect.left,newRect.top,newRect.right-newRect.left,lastRect.bottom-newRect.top,hdcCompatible,newRect.left,newRect.top,SRCCOPY);
     777     else if (lastRect.bottom < newRect.bottom && lastRect.bottom > newRect.top)
     778       BitBlt(hdc,lastRect.left,lastRect.top,lastRect.right-lastRect.left,newRect.bottom-lastRect.top,hdcCompatible,lastRect.left,lastRect.top,SRCCOPY);
     779     else
     780     {
     781       BitBlt(hdc,lastRect.left,lastRect.top,lastRect.right-lastRect.left,lastRect.bottom-lastRect.top,hdcCompatible,lastRect.left,lastRect.top,SRCCOPY);
     782       BitBlt(hdc,newRect.left,newRect.top,newRect.right-newRect.left,newRect.bottom-newRect.top,hdcCompatible,newRect.left,newRect.top,SRCCOPY);
     783     }
     784   } else
     785   {
     786     if (lastRect.right > newRect.left && lastRect.right < newRect.right)
     787       BitBlt(hdc,lastRect.left,lastRect.top,newRect.right-lastRect.left,lastRect.bottom-lastRect.top,hdcCompatible,lastRect.left,lastRect.top,SRCCOPY);
     788     else if (lastRect.left < newRect.right && lastRect.left > newRect.left)
     789       BitBlt(hdc,newRect.left,newRect.top,lastRect.right-newRect.left,newRect.bottom-newRect.top,hdcCompatible,newRect.left,newRect.top,SRCCOPY);
     790     else
     791     {
     792       BitBlt(hdc,lastRect.left,lastRect.top,lastRect.right-lastRect.left,lastRect.bottom-lastRect.top,hdcCompatible,lastRect.left,lastRect.top,SRCCOPY);
     793       BitBlt(hdc,newRect.left,newRect.top,newRect.right-newRect.left,newRect.bottom-newRect.top,hdcCompatible,newRect.left,newRect.top,SRCCOPY);
     794     }
     795   }
     796   SelectObject(hdcCompatible,oldbmp);
     797   DeleteObject(bitmap);
     798   DeleteDC(hdcCompatible);
    775799   ReleaseDC(hwnd,hdc);
    776800}
     
    11431167    infoPtr->flags |= TB_THUMBPOSCHANGED;
    11441168
    1145     if (wParam) TRACKBAR_UpdateThumbPosition(hwnd,lastPos);
     1169    if (wParam) TRACKBAR_UpdateThumbPosition(hwnd,lastPos,FALSE);
    11461170
    11471171    return 0;
     
    16951719    {
    16961720      infoPtr->flags |= TB_THUMBPOSCHANGED;
    1697       TRACKBAR_UpdateThumbPosition(hwnd,prevPos);
     1721      TRACKBAR_UpdateThumbPosition(hwnd,prevPos,TRUE);
    16981722    }
    16991723
     
    17811805    {
    17821806      infoPtr->flags |= TB_THUMBPOSCHANGED;
    1783       TRACKBAR_UpdateThumbPosition(hwnd,prevPos);
     1807      TRACKBAR_UpdateThumbPosition(hwnd,prevPos,FALSE);
    17841808    }
    17851809
     
    17961820      int lastPos = infoPtr->nPos;
    17971821      infoPtr->nPos = infoPtr->dragPos;
    1798       if (lastPos != infoPtr->nPos) TRACKBAR_UpdateThumbPosition(hwnd,lastPos);
     1822      if (lastPos != infoPtr->nPos) TRACKBAR_UpdateThumbPosition(hwnd,lastPos,TRUE);
    17991823    }
    18001824
     
    19191943    infoPtr->flags |= TB_DRAGPOSVALID;
    19201944
    1921     TRACKBAR_UpdateThumbPosition(hwnd,infoPtr->nPos); //infoPtr->nPos now set
     1945    TRACKBAR_UpdateThumbPosition(hwnd,infoPtr->nPos,FALSE); //infoPtr->nPos now set
    19221946
    19231947    TRACKBAR_SendNotify(hwnd,TB_THUMBTRACK | (infoPtr->nPos >> 16));
     
    20032027    {
    20042028      infoPtr->flags |= TB_THUMBPOSCHANGED;
    2005       TRACKBAR_UpdateThumbPosition(hwnd,pos);
     2029      TRACKBAR_UpdateThumbPosition(hwnd,pos,FALSE);
    20062030    }
    20072031
Note: See TracChangeset for help on using the changeset viewer.