Changeset 109 for trunk/src/comctl32/progress.c
- Timestamp:
- Jun 16, 1999, 5:29:27 PM (26 years ago)
- 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 $ */ 2 2 /* 3 3 * Progress control … … 18 18 /* Control configuration constants */ 19 19 20 #define LED_GAP 2 20 #define LED_GAP 2 21 #define BORDER_WIDTH 3 21 22 22 23 /* Work constants */ … … 38 39 { 39 40 PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd); 40 HBRUSH hbrBar, hbrBk;41 HBRUSH hbrBar,hbrBk,hbrLight,hbrShadow,hbrOld; 41 42 int rightBar, rightMost, ledWidth; 43 int lastBar; 42 44 RECT rect; 43 45 DWORD dwStyle; … … 46 48 // infoPtr->CurVal, infoPtr->MinVal, infoPtr->MaxVal); 47 49 50 if (infoPtr->MinVal == infoPtr->MaxVal) return; //Prevent division through 0 51 48 52 /* 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); 53 55 54 56 /* 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); 59 59 60 60 /* get client rectangle */ 61 61 GetClientRect (hwnd, &rect); 62 rect.right--; 63 rect.bottom--; 62 64 63 65 /* 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; 67 86 68 87 /* get the window style */ … … 72 91 if (dwStyle & PBS_VERTICAL) 73 92 { 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); 78 95 ledWidth = MulDiv ((rect.right - rect.left), 2, 3); 79 96 rightMost = rect.top; … … 81 98 else 82 99 { 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); 87 102 ledWidth = MulDiv ((rect.bottom - rect.top), 2, 3); 88 103 rightMost = rect.right; … … 93 108 { 94 109 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 101 151 { 102 152 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 } 119 213 } 120 214 } … … 122 216 123 217 /* delete bar brush */ 124 if (infoPtr->ColorBar != CLR_DEFAULT) 125 DeleteObject (hbrBar); 218 if (infoPtr->ColorBar != CLR_DEFAULT) DeleteObject (hbrBar); 126 219 127 220 /* delete background brush */ 128 if (infoPtr->ColorBk != CLR_DEFAULT) 129 DeleteObject (hbrBk); 221 if (infoPtr->ColorBk != CLR_DEFAULT) DeleteObject (hbrBk); 130 222 } 131 223 … … 217 309 { 218 310 PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd); 219 UINT temp;311 INT temp; 220 312 221 313 switch(message) … … 271 363 temp = infoPtr->CurVal; 272 364 if(wParam != 0){ 273 infoPtr->CurVal += (INT)wParam; //CB: negative values allowed, was UINT16365 infoPtr->CurVal += (INT)wParam; 274 366 PROGRESS_CoercePos (hwnd); 275 367 PROGRESS_Update (hwnd,temp); … … 306 398 UNKNOWN_PARAM(PBM_SETSTEP, wParam, lParam); 307 399 temp = infoPtr->Step; 308 infoPtr->Step = ( UINT16)wParam;400 infoPtr->Step = (INT)wParam; 309 401 return temp; 310 402
Note:
See TracChangeset
for help on using the changeset viewer.