2 /* INCLUDES *****************************************************************/
9 /* FUNCTIONS ****************************************************************/
21 /* draw upper left corner */
23 coPos
.Y
= Bar
->Top
+ 1;
24 FillConsoleOutputCharacterA(StdOutput
,
31 coPos
.X
= Bar
->Left
+ 1;
32 coPos
.Y
= Bar
->Top
+ 1;
33 FillConsoleOutputCharacterA(StdOutput
,
35 Bar
->Right
- Bar
->Left
- 1,
39 /* draw upper right corner */
41 coPos
.Y
= Bar
->Top
+ 1;
42 FillConsoleOutputCharacterA(StdOutput
,
48 /* draw left and right edge */
49 for (i
= Bar
->Top
+ 2; i
< Bar
->Bottom
; i
++)
53 FillConsoleOutputCharacterA(StdOutput
,
60 FillConsoleOutputCharacterA(StdOutput
,
67 /* draw lower left corner */
69 coPos
.Y
= Bar
->Bottom
;
70 FillConsoleOutputCharacterA(StdOutput
,
77 coPos
.X
= Bar
->Left
+ 1;
78 coPos
.Y
= Bar
->Bottom
;
79 FillConsoleOutputCharacterA(StdOutput
,
81 Bar
->Right
- Bar
->Left
- 1,
85 /* draw lower right corner */
87 coPos
.Y
= Bar
->Bottom
;
88 FillConsoleOutputCharacterA(StdOutput
,
105 /* draw upper left corner */
107 coPos
.Y
= Bar
->Top
+ 1;
108 FillConsoleOutputCharacterA(StdOutput
,
114 /* draw upper edge */
115 coPos
.X
= Bar
->Left
+ 1;
116 coPos
.Y
= Bar
->Top
+ 1;
117 FillConsoleOutputCharacterA(StdOutput
,
119 Bar
->Right
- Bar
->Left
- 1,
123 /* draw upper right corner */
124 coPos
.X
= Bar
->Right
;
125 coPos
.Y
= Bar
->Top
+ 1;
126 FillConsoleOutputCharacterA(StdOutput
,
132 /* draw left and right edge */
133 for (i
= Bar
->Top
+ 2; i
< Bar
->Bottom
; i
++)
137 FillConsoleOutputCharacterA(StdOutput
,
143 coPos
.X
= Bar
->Right
;
144 FillConsoleOutputCharacterA(StdOutput
,
151 /* draw lower left corner */
153 coPos
.Y
= Bar
->Bottom
;
154 FillConsoleOutputCharacterA(StdOutput
,
160 /* draw lower edge */
161 coPos
.X
= Bar
->Left
+ 1;
162 coPos
.Y
= Bar
->Bottom
;
163 FillConsoleOutputCharacterA(StdOutput
,
165 Bar
->Right
- Bar
->Left
- 1,
169 /* draw lower right corner */
170 coPos
.X
= Bar
->Right
;
171 coPos
.Y
= Bar
->Bottom
;
172 FillConsoleOutputCharacterA(StdOutput
,
188 PROGRESSBAR BarBorder
= *Bar
;
190 /* Print percentage */
191 sprintf(TextBuffer
, "%-3lu%%", Bar
->Percent
);
193 coPos
.X
= Bar
->Left
+ (Bar
->Width
- 2) / 2;
195 WriteConsoleOutputCharacterA(StdOutput
,
201 /* Draw the progress bar border */
204 /* Write Text Associated with Bar */
205 CONSOLE_SetTextXY(Bar
->TextTop
, Bar
->TextRight
, Bar
->Text
);
207 /* Draw the progress bar "border" border */
211 BarBorder
.Bottom
+= 2;
212 BarBorder
.Right
+= 5;
214 DrawThickBorder(&BarBorder
);
218 coPos
.X
= Bar
->Left
+ 1;
219 for (coPos
.Y
= Bar
->Top
+ 2; coPos
.Y
<= Bar
->Bottom
- 1; coPos
.Y
++)
221 FillConsoleOutputAttribute(StdOutput
,
222 FOREGROUND_YELLOW
| BACKGROUND_BLUE
,
227 FillConsoleOutputCharacterA(StdOutput
,
244 IN BOOLEAN DoubleEdge
,
249 Bar
= (PPROGRESSBAR
)RtlAllocateHeap(ProcessHeap
,
251 sizeof(PROGRESSBAR
));
258 Bar
->Bottom
= Bottom
;
259 Bar
->TextTop
= TextTop
;
260 Bar
->TextRight
= TextRight
;
261 Bar
->Double
= DoubleEdge
;
264 Bar
->Width
= Bar
->Right
- Bar
->Left
+ 1;
270 Bar
->CurrentStep
= 0;
272 DrawProgressBar(Bar
);
282 RtlFreeHeap(ProcessHeap
, 0, Bar
);
287 ProgressSetStepCount(
291 Bar
->CurrentStep
= 0;
292 Bar
->StepCount
= StepCount
;
294 DrawProgressBar(Bar
);
302 ProgressSetStep(Bar
, Bar
->CurrentStep
+ 1);
317 if (Step
> Bar
->StepCount
)
320 Bar
->CurrentStep
= Step
;
322 /* Calculate new percentage */
323 NewPercent
= (ULONG
)(((100.0 * (float)Bar
->CurrentStep
) / (float)Bar
->StepCount
) + 0.5);
325 /* Redraw percentage if changed */
326 if (Bar
->Percent
!= NewPercent
)
328 Bar
->Percent
= NewPercent
;
330 sprintf(TextBuffer
, "%-3lu%%", Bar
->Percent
);
332 coPos
.X
= Bar
->Left
+ (Bar
->Width
- 2) / 2;
334 WriteConsoleOutputCharacterA(StdOutput
,
341 /* Calculate bar position */
342 NewPos
= (ULONG
)((((float)(Bar
->Width
- 2) * 2.0 * (float)Bar
->CurrentStep
) / (float)Bar
->StepCount
) + 0.5);
344 /* Redraw bar if changed */
345 if (Bar
->Pos
!= NewPos
)
349 for (coPos
.Y
= Bar
->Top
+ 2; coPos
.Y
<= Bar
->Bottom
- 1; coPos
.Y
++)
351 coPos
.X
= Bar
->Left
+ 1;
352 FillConsoleOutputCharacterA(StdOutput
,
357 coPos
.X
+= Bar
->Pos
/2;
361 FillConsoleOutputCharacterA(StdOutput
,
369 if (coPos
.X
<= Bar
->Right
- 1)
371 FillConsoleOutputCharacterA(StdOutput
,
373 Bar
->Right
- coPos
.X
,