2 /* INCLUDES *****************************************************************/
9 /* FUNCTIONS ****************************************************************/
13 DrawBorder(PPROGRESSBAR Bar
)
19 /* draw upper left corner */
21 coPos
.Y
= Bar
->Top
+ 1;
22 FillConsoleOutputCharacterA(StdOutput
,
29 coPos
.X
= Bar
->Left
+ 1;
30 coPos
.Y
= Bar
->Top
+ 1;
31 FillConsoleOutputCharacterA(StdOutput
,
33 Bar
->Right
- Bar
->Left
- 1,
37 /* draw upper right corner */
39 coPos
.Y
= Bar
->Top
+ 1;
40 FillConsoleOutputCharacterA(StdOutput
,
46 /* draw left and right edge */
47 for (i
= Bar
->Top
+ 2; i
< Bar
->Bottom
; i
++)
51 FillConsoleOutputCharacterA(StdOutput
,
58 FillConsoleOutputCharacterA(StdOutput
,
65 /* draw lower left corner */
67 coPos
.Y
= Bar
->Bottom
;
68 FillConsoleOutputCharacterA(StdOutput
,
75 coPos
.X
= Bar
->Left
+ 1;
76 coPos
.Y
= Bar
->Bottom
;
77 FillConsoleOutputCharacterA(StdOutput
,
79 Bar
->Right
- Bar
->Left
- 1,
83 /* draw lower right corner */
85 coPos
.Y
= Bar
->Bottom
;
86 FillConsoleOutputCharacterA(StdOutput
,
94 DrawThickBorder(PPROGRESSBAR Bar
)
100 /* draw upper left corner */
102 coPos
.Y
= Bar
->Top
+ 1;
103 FillConsoleOutputCharacterA(StdOutput
,
109 /* draw upper edge */
110 coPos
.X
= Bar
->Left
+ 1;
111 coPos
.Y
= Bar
->Top
+ 1;
112 FillConsoleOutputCharacterA(StdOutput
,
114 Bar
->Right
- Bar
->Left
- 1,
118 /* draw upper right corner */
119 coPos
.X
= Bar
->Right
;
120 coPos
.Y
= Bar
->Top
+ 1;
121 FillConsoleOutputCharacterA(StdOutput
,
127 /* draw left and right edge */
128 for (i
= Bar
->Top
+ 2; i
< Bar
->Bottom
; i
++)
132 FillConsoleOutputCharacterA(StdOutput
,
138 coPos
.X
= Bar
->Right
;
139 FillConsoleOutputCharacterA(StdOutput
,
146 /* draw lower left corner */
148 coPos
.Y
= Bar
->Bottom
;
149 FillConsoleOutputCharacterA(StdOutput
,
155 /* draw lower edge */
156 coPos
.X
= Bar
->Left
+ 1;
157 coPos
.Y
= Bar
->Bottom
;
158 FillConsoleOutputCharacterA(StdOutput
,
160 Bar
->Right
- Bar
->Left
- 1,
164 /* draw lower right corner */
165 coPos
.X
= Bar
->Right
;
166 coPos
.Y
= Bar
->Bottom
;
167 FillConsoleOutputCharacterA(StdOutput
,
175 DrawProgressBar(PPROGRESSBAR Bar
)
180 PROGRESSBAR BarBorder
= *Bar
;
182 /* Print percentage */
183 sprintf(TextBuffer
, "%-3lu%%", Bar
->Percent
);
185 coPos
.X
= Bar
->Left
+ (Bar
->Width
- 2) / 2;
187 WriteConsoleOutputCharacterA(StdOutput
,
193 /* Draw the progress bar border */
196 /* Write Text Associated with Bar */
197 CONSOLE_SetTextXY(Bar
->TextTop
, Bar
->TextRight
, Bar
->Text
);
199 /* Draw the progress bar "border" border */
203 BarBorder
.Bottom
+= 2;
204 BarBorder
.Right
+= 5;
206 DrawThickBorder(&BarBorder
);
210 coPos
.X
= Bar
->Left
+ 1;
211 for (coPos
.Y
= Bar
->Top
+ 2; coPos
.Y
<= Bar
->Bottom
- 1; coPos
.Y
++)
213 FillConsoleOutputAttribute(StdOutput
,
214 FOREGROUND_YELLOW
| BACKGROUND_BLUE
,
219 FillConsoleOutputCharacterA(StdOutput
,
231 CreateProgressBar(SHORT Left
,
237 IN BOOLEAN DoubleEdge
,
242 Bar
= (PPROGRESSBAR
)RtlAllocateHeap(ProcessHeap
,
244 sizeof(PROGRESSBAR
));
251 Bar
->Bottom
= Bottom
;
252 Bar
->TextTop
= TextTop
;
253 Bar
->TextRight
= TextRight
;
254 Bar
->Double
= DoubleEdge
;
257 Bar
->Width
= Bar
->Right
- Bar
->Left
+ 1;
263 Bar
->CurrentStep
= 0;
265 DrawProgressBar(Bar
);
272 DestroyProgressBar(PPROGRESSBAR Bar
)
274 RtlFreeHeap(ProcessHeap
,
280 ProgressSetStepCount(PPROGRESSBAR Bar
,
283 Bar
->CurrentStep
= 0;
284 Bar
->StepCount
= StepCount
;
286 DrawProgressBar(Bar
);
291 ProgressNextStep(PPROGRESSBAR Bar
)
293 ProgressSetStep(Bar
, Bar
->CurrentStep
+ 1);
298 ProgressSetStep (PPROGRESSBAR Bar
,
307 if (Step
> Bar
->StepCount
)
310 Bar
->CurrentStep
= Step
;
312 /* Calculate new percentage */
313 NewPercent
= (ULONG
)(((100.0 * (float)Bar
->CurrentStep
) / (float)Bar
->StepCount
) + 0.5);
315 /* Redraw precentage if changed */
316 if (Bar
->Percent
!= NewPercent
)
318 Bar
->Percent
= NewPercent
;
320 /* DO NOT REMOVE THOSE LINES
321 * This might be needed by sysreg
323 if (NewPercent
== 50)
325 DPRINT1("CHECKPOINT:HALF_COPIED\n");
328 sprintf(TextBuffer
, "%-3lu%%", Bar
->Percent
);
330 coPos
.X
= Bar
->Left
+ (Bar
->Width
- 2) / 2;
332 WriteConsoleOutputCharacterA(StdOutput
,
339 /* Calculate bar position */
340 NewPos
= (ULONG
)((((float)(Bar
->Width
- 2) * 2.0 * (float)Bar
->CurrentStep
) / (float)Bar
->StepCount
) + 0.5);
342 /* Redraw bar if changed */
343 if (Bar
->Pos
!= NewPos
)
347 for (coPos
.Y
= Bar
->Top
+ 2; coPos
.Y
<= Bar
->Bottom
- 1; coPos
.Y
++)
349 coPos
.X
= Bar
->Left
+ 1;
350 FillConsoleOutputCharacterA(StdOutput
,
355 coPos
.X
+= Bar
->Pos
/2;
359 FillConsoleOutputCharacterA(StdOutput
,
367 if (coPos
.X
<= Bar
->Right
- 1)
369 FillConsoleOutputCharacterA(StdOutput
,
371 Bar
->Right
- coPos
.X
,