Ignore:
Timestamp:
Jun 16, 1999, 5:29:27 PM (26 years ago)
Author:
cbratschi
Message:

comctl32: progress.c finished (performance updates), trackbar running
GetSysColor returns wrong 3D colors

File:
1 edited

Legend:

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

    r106 r109  
    1 /* $Id: progress.c,v 1.3 1999-06-12 20:44:06 cbratschi Exp $ */
     1/* $Id: progress.c,v 1.4 1999-06-16 15:29:26 cbratschi Exp $ */
    22/*
    33 * Progress control
     
    1818/* Control configuration constants */
    1919
    20 #define LED_GAP    2
     20#define LED_GAP      2
     21#define BORDER_WIDTH 3
    2122
    2223/* Work constants */
     
    3839{
    3940  PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
    40   HBRUSH hbrBar, hbrBk;
     41  HBRUSH hbrBar,hbrBk,hbrLight,hbrShadow,hbrOld;
    4142  int rightBar, rightMost, ledWidth;
     43  int lastBar;
    4244  RECT rect;
    4345  DWORD dwStyle;
     
    4648//             infoPtr->CurVal, infoPtr->MinVal, infoPtr->MaxVal);
    4749
     50  if (infoPtr->MinVal == infoPtr->MaxVal) return; //Prevent division through 0
     51
    4852  /* get the required bar brush */
    49   if (infoPtr->ColorBar == CLR_DEFAULT)
    50     hbrBar = GetSysColorBrush(COLOR_HIGHLIGHT);
    51   else
    52     hbrBar = CreateSolidBrush (infoPtr->ColorBar);
     53  if (infoPtr->ColorBar == CLR_DEFAULT) hbrBar = GetSysColorBrush(COLOR_HIGHLIGHT);
     54  else hbrBar = CreateSolidBrush (infoPtr->ColorBar);
    5355
    5456  /* get the required background brush */
    55   if (infoPtr->ColorBk == CLR_DEFAULT)
    56     hbrBk = GetSysColorBrush (COLOR_3DFACE);
    57   else
    58     hbrBk = CreateSolidBrush (infoPtr->ColorBk);
     57  if (infoPtr->ColorBk == CLR_DEFAULT) hbrBk = GetSysColorBrush (COLOR_3DFACE);
     58  else hbrBk = CreateSolidBrush (infoPtr->ColorBk);
    5959
    6060  /* get client rectangle */
    6161  GetClientRect (hwnd, &rect);
     62  rect.right--;
     63  rect.bottom--;
    6264
    6365  /* draw the background */
    64   FillRect(hdc, &rect, hbrBk);
    65 
    66   rect.left++; rect.right--; rect.top++; rect.bottom--;
     66  if (!inUpdate)
     67  {
     68    FillRect(hdc, &rect, hbrBk);
     69    //Border
     70    hbrLight = GetSysColorBrush(COLOR_3DLIGHT);
     71    hbrShadow = GetSysColorBrush(COLOR_3DSHADOW);
     72    MoveToEx(hdc,rect.left,rect.bottom,NULL);
     73    hbrOld = SelectObject(hdc,hbrShadow);
     74    LineTo(hdc,rect.left,rect.top);
     75    LineTo(hdc,rect.right,rect.top);
     76    SelectObject(hdc,hbrLight);
     77    LineTo(hdc,rect.right,rect.bottom);
     78    LineTo(hdc,rect.left,rect.bottom);
     79    SelectObject(hdc,hbrOld);
     80  }
     81
     82  rect.left += BORDER_WIDTH;
     83  rect.right -= BORDER_WIDTH;
     84  rect.top += BORDER_WIDTH;
     85  rect.bottom -= BORDER_WIDTH;
    6786
    6887  /* get the window style */
     
    7291  if (dwStyle & PBS_VERTICAL)
    7392  {
    74     rightBar = rect.bottom -
    75       MulDiv(infoPtr->CurVal-infoPtr->MinVal,
    76                rect.bottom - rect.top,
    77                infoPtr->MaxVal-infoPtr->MinVal);
     93    rightBar = rect.bottom-MulDiv(infoPtr->CurVal-infoPtr->MinVal,rect.bottom-rect.top,infoPtr->MaxVal-infoPtr->MinVal);
     94    if (inUpdate) lastBar = rect.bottom-MulDiv(lastVal-infoPtr->MinVal,rect.bottom-rect.top,infoPtr->MaxVal-infoPtr->MinVal);
    7895    ledWidth = MulDiv ((rect.right - rect.left), 2, 3);
    7996    rightMost = rect.top;
     
    8198  else
    8299  {
    83     rightBar = rect.left +
    84       MulDiv(infoPtr->CurVal-infoPtr->MinVal,
    85                rect.right - rect.left,
    86                infoPtr->MaxVal-infoPtr->MinVal);
     100    rightBar = rect.left+MulDiv(infoPtr->CurVal-infoPtr->MinVal,rect.right-rect.left,infoPtr->MaxVal-infoPtr->MinVal);
     101    if (inUpdate) lastBar = rect.left+MulDiv(lastVal-infoPtr->MinVal,rect.right-rect.left,infoPtr->MaxVal-infoPtr->MinVal);
    87102    ledWidth = MulDiv ((rect.bottom - rect.top), 2, 3);
    88103    rightMost = rect.right;
     
    93108  {
    94109    if (dwStyle & PBS_VERTICAL)
    95       rect.top = rightBar;
    96     else
    97       rect.right = rightBar;
    98     FillRect(hdc, &rect, hbrBar);
    99   }
    100   else
     110    {
     111      if (inUpdate)
     112      {
     113        if (infoPtr->CurVal > lastVal)
     114        {
     115          rect.top = rightBar;
     116          rect.bottom = lastBar;
     117          FillRect(hdc,&rect,hbrBar);
     118        } else if (infoPtr->CurVal < lastVal)
     119        {
     120          rect.top = lastBar;
     121          rect.bottom = rightBar;
     122          FillRect(hdc,&rect,hbrBk);
     123        }
     124      } else
     125      {
     126        rect.top = rightBar;
     127        FillRect(hdc,&rect,hbrBar);
     128      }
     129    } else //Horizontal
     130    {
     131      if (inUpdate)
     132      {
     133        if (infoPtr->CurVal > lastVal)
     134        {
     135          rect.left = lastBar;
     136          rect.right = rightBar;
     137          FillRect(hdc,&rect,hbrBar);
     138        } else if (infoPtr->CurVal < lastVal)
     139        {
     140          rect.left = rightBar;
     141          rect.right = lastBar;
     142          FillRect(hdc,&rect,hbrBk);
     143        }
     144      } else
     145      {
     146        rect.right = rightBar;
     147        FillRect(hdc,&rect,hbrBar);
     148      }
     149    }
     150  } else
    101151  {
    102152    if (dwStyle & PBS_VERTICAL)
    103   {
    104       while(rect.bottom > rightBar) {
    105         rect.top = rect.bottom-ledWidth;
    106         if (rect.top < rightMost)
    107           rect.top = rightMost;
    108         FillRect(hdc, &rect, hbrBar);
    109         rect.bottom = rect.top-LED_GAP;
    110       }
    111     }
    112     else {
    113       while(rect.left < rightBar) {
    114         rect.right = rect.left+ledWidth;
    115         if (rect.right > rightMost)
    116           rect.right = rightMost;
    117         FillRect(hdc, &rect, hbrBar);
    118         rect.left  = rect.right+LED_GAP;
     153    {
     154      if (inUpdate)
     155      {
     156        if (infoPtr->CurVal > lastVal)
     157        {
     158          rect.bottom -= ((int)(rect.bottom-lastBar)/(ledWidth+LED_GAP))*(ledWidth+LED_GAP);
     159          while(rect.bottom > rightBar)
     160          {
     161            rect.top = rect.bottom-ledWidth;
     162            if (rect.top < rightMost) rect.top = rightMost;
     163            FillRect(hdc,&rect,hbrBar);
     164            rect.bottom = rect.top-LED_GAP;
     165          }
     166        } else if (infoPtr->CurVal < lastVal)
     167        {
     168          rect.top = rect.bottom-((int)(rect.bottom-lastBar)/(ledWidth+LED_GAP))*(ledWidth+LED_GAP)-ledWidth;
     169          if (rect.top < rightMost) rect.top = rightMost;
     170          rect.bottom -= ((int)(rect.bottom-rightBar)/(ledWidth+LED_GAP))*(ledWidth+LED_GAP);
     171          FillRect(hdc,&rect,hbrBk);
     172        }
     173      } else
     174      {
     175        while(rect.bottom > rightBar)
     176        {
     177          rect.top = rect.bottom-ledWidth;
     178          if (rect.top < rightMost) rect.top = rightMost;
     179          FillRect(hdc,&rect,hbrBar);
     180          rect.bottom = rect.top-LED_GAP;
     181        }
     182      }
     183    } else //Horizontal
     184    {
     185      if (inUpdate)
     186      {
     187        if (infoPtr->CurVal > lastVal)
     188        {
     189          rect.left += ((int)(lastBar-rect.left)/(ledWidth+LED_GAP))*(ledWidth+LED_GAP);
     190          while(rect.left < rightBar)
     191          {
     192            rect.right = rect.left+ledWidth;
     193            if (rect.right > rightMost) rect.right = rightMost;
     194            FillRect(hdc,&rect,hbrBar);
     195            rect.left  = rect.right+LED_GAP;
     196          }
     197        } else if (infoPtr->CurVal < lastVal)
     198        {
     199          rect.right = rect.left+((int)(lastBar-rect.left)/(ledWidth+LED_GAP))*(ledWidth+LED_GAP)+ledWidth;
     200          if (rect.right > rightMost) rect.right = rightMost;
     201          rect.left += ((int)(rightBar-rect.left)/(ledWidth+LED_GAP))*(ledWidth+LED_GAP);
     202          FillRect(hdc,&rect,hbrBk);
     203        }
     204      } else
     205      {
     206        while(rect.left < rightBar)
     207        {
     208          rect.right = rect.left+ledWidth;
     209          if (rect.right > rightMost) rect.right = rightMost;
     210          FillRect(hdc,&rect,hbrBar);
     211          rect.left  = rect.right+LED_GAP;
     212        }
    119213      }
    120214  }
     
    122216
    123217  /* delete bar brush */
    124   if (infoPtr->ColorBar != CLR_DEFAULT)
    125       DeleteObject (hbrBar);
     218  if (infoPtr->ColorBar != CLR_DEFAULT) DeleteObject (hbrBar);
    126219
    127220  /* delete background brush */
    128   if (infoPtr->ColorBk != CLR_DEFAULT)
    129       DeleteObject (hbrBk);
     221  if (infoPtr->ColorBk != CLR_DEFAULT) DeleteObject (hbrBk);
    130222}
    131223
     
    217309{
    218310    PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
    219   UINT temp;
     311  INT temp;
    220312
    221313  switch(message)
     
    271363      temp = infoPtr->CurVal;
    272364      if(wParam != 0){
    273         infoPtr->CurVal += (INT)wParam; //CB: negative values allowed, was UINT16
     365        infoPtr->CurVal += (INT)wParam;
    274366        PROGRESS_CoercePos (hwnd);
    275367        PROGRESS_Update (hwnd,temp);
     
    306398        UNKNOWN_PARAM(PBM_SETSTEP, wParam, lParam);
    307399      temp = infoPtr->Step;
    308       infoPtr->Step = (UINT16)wParam;
     400      infoPtr->Step = (INT)wParam;
    309401      return temp;
    310402
Note: See TracChangeset for help on using the changeset viewer.