2018-08-26 18:40:34 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS text-mode setup
|
|
|
|
* FILE: base/setup/usetup/progress.c
|
|
|
|
* PURPOSE: Partition list functions
|
|
|
|
* PROGRAMMER:
|
|
|
|
*/
|
2002-12-06 21:39:04 +00:00
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
2006-08-31 09:13:03 +00:00
|
|
|
#include "usetup.h"
|
2005-06-20 22:49:45 +00:00
|
|
|
|
2010-06-07 21:38:49 +00:00
|
|
|
#define NDEBUG
|
2005-06-20 22:49:45 +00:00
|
|
|
#include <debug.h>
|
2002-12-06 21:39:04 +00:00
|
|
|
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
2018-08-26 18:40:34 +00:00
|
|
|
static
|
|
|
|
BOOLEAN NTAPI
|
|
|
|
UpdateProgressPercentage(
|
|
|
|
IN PPROGRESSBAR Bar,
|
2018-08-27 21:55:58 +00:00
|
|
|
IN BOOLEAN AlwaysUpdate,
|
2018-08-26 18:40:34 +00:00
|
|
|
OUT PSTR Buffer,
|
|
|
|
IN SIZE_T cchBufferSize)
|
|
|
|
{
|
|
|
|
// static PCSTR ProgressFormatText;
|
|
|
|
ULONG OldProgress = Bar->Progress;
|
|
|
|
|
2018-08-27 21:55:58 +00:00
|
|
|
/* Calculate the new percentage */
|
|
|
|
if (Bar->StepCount == 0)
|
|
|
|
Bar->Progress = 0;
|
|
|
|
else
|
|
|
|
Bar->Progress = ((100 * Bar->CurrentStep + (Bar->StepCount / 2)) / Bar->StepCount);
|
2018-08-26 18:40:34 +00:00
|
|
|
|
|
|
|
/* Build the progress string if it has changed */
|
|
|
|
if ( Bar->ProgressFormatText &&
|
2018-08-27 21:55:58 +00:00
|
|
|
(AlwaysUpdate || (Bar->Progress != OldProgress)) )
|
2018-08-26 18:40:34 +00:00
|
|
|
{
|
|
|
|
RtlStringCchPrintfA(Buffer, cchBufferSize,
|
|
|
|
Bar->ProgressFormatText, Bar->Progress);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-05-12 16:14:19 +00:00
|
|
|
static
|
|
|
|
VOID
|
|
|
|
DrawBorder(
|
2018-08-26 18:31:14 +00:00
|
|
|
IN PPROGRESSBAR Bar)
|
2002-12-06 21:39:04 +00:00
|
|
|
{
|
2014-05-12 16:14:19 +00:00
|
|
|
COORD coPos;
|
|
|
|
DWORD Written;
|
|
|
|
SHORT i;
|
|
|
|
|
|
|
|
/* draw upper left corner */
|
|
|
|
coPos.X = Bar->Left;
|
|
|
|
coPos.Y = Bar->Top + 1;
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
2022-10-07 22:46:00 +00:00
|
|
|
CharUpperLeftCorner, // '+',
|
2014-05-12 16:14:19 +00:00
|
|
|
1,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
/* draw upper edge */
|
|
|
|
coPos.X = Bar->Left + 1;
|
|
|
|
coPos.Y = Bar->Top + 1;
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
2022-10-07 22:46:00 +00:00
|
|
|
CharHorizontalLine, // '-',
|
2014-05-12 16:14:19 +00:00
|
|
|
Bar->Right - Bar->Left - 1,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
/* draw upper right corner */
|
|
|
|
coPos.X = Bar->Right;
|
|
|
|
coPos.Y = Bar->Top + 1;
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
2022-10-07 22:46:00 +00:00
|
|
|
CharUpperRightCorner, // '+',
|
2014-05-12 16:14:19 +00:00
|
|
|
1,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
/* draw left and right edge */
|
|
|
|
for (i = Bar->Top + 2; i < Bar->Bottom; i++)
|
2002-12-06 21:39:04 +00:00
|
|
|
{
|
2014-05-12 16:14:19 +00:00
|
|
|
coPos.X = Bar->Left;
|
|
|
|
coPos.Y = i;
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
2022-10-07 22:46:00 +00:00
|
|
|
CharVerticalLine, // '|',
|
2014-05-12 16:14:19 +00:00
|
|
|
1,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
coPos.X = Bar->Right;
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
2022-10-07 22:46:00 +00:00
|
|
|
CharVerticalLine, //'|',
|
2014-05-12 16:14:19 +00:00
|
|
|
1,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
2002-12-06 21:39:04 +00:00
|
|
|
}
|
|
|
|
|
2014-05-12 16:14:19 +00:00
|
|
|
/* draw lower left corner */
|
|
|
|
coPos.X = Bar->Left;
|
|
|
|
coPos.Y = Bar->Bottom;
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
2022-10-07 22:46:00 +00:00
|
|
|
CharLowerLeftCorner, // '+',
|
2014-05-12 16:14:19 +00:00
|
|
|
1,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
/* draw lower edge */
|
|
|
|
coPos.X = Bar->Left + 1;
|
|
|
|
coPos.Y = Bar->Bottom;
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
2022-10-07 22:46:00 +00:00
|
|
|
CharHorizontalLine, // '-',
|
2014-05-12 16:14:19 +00:00
|
|
|
Bar->Right - Bar->Left - 1,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
/* draw lower right corner */
|
|
|
|
coPos.X = Bar->Right;
|
|
|
|
coPos.Y = Bar->Bottom;
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
2022-10-07 22:46:00 +00:00
|
|
|
CharLowerRightCorner, // '+',
|
2014-05-12 16:14:19 +00:00
|
|
|
1,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
2002-12-06 21:39:04 +00:00
|
|
|
}
|
|
|
|
|
2014-05-12 16:14:19 +00:00
|
|
|
static
|
|
|
|
VOID
|
|
|
|
DrawThickBorder(
|
2018-08-26 18:31:14 +00:00
|
|
|
IN PPROGRESSBAR Bar)
|
2005-05-18 19:08:00 +00:00
|
|
|
{
|
2014-05-12 16:14:19 +00:00
|
|
|
COORD coPos;
|
|
|
|
DWORD Written;
|
|
|
|
SHORT i;
|
|
|
|
|
|
|
|
/* draw upper left corner */
|
|
|
|
coPos.X = Bar->Left;
|
|
|
|
coPos.Y = Bar->Top + 1;
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
2022-10-07 22:46:00 +00:00
|
|
|
CharDoubleUpperLeftCorner, // '+',
|
2014-05-12 16:14:19 +00:00
|
|
|
1,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
/* draw upper edge */
|
|
|
|
coPos.X = Bar->Left + 1;
|
|
|
|
coPos.Y = Bar->Top + 1;
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
2022-10-07 22:46:00 +00:00
|
|
|
CharDoubleHorizontalLine, // '-',
|
2014-05-12 16:14:19 +00:00
|
|
|
Bar->Right - Bar->Left - 1,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
/* draw upper right corner */
|
|
|
|
coPos.X = Bar->Right;
|
|
|
|
coPos.Y = Bar->Top + 1;
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
2022-10-07 22:46:00 +00:00
|
|
|
CharDoubleUpperRightCorner, // '+',
|
2014-05-12 16:14:19 +00:00
|
|
|
1,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
/* draw left and right edge */
|
|
|
|
for (i = Bar->Top + 2; i < Bar->Bottom; i++)
|
2005-05-18 19:08:00 +00:00
|
|
|
{
|
2014-05-12 16:14:19 +00:00
|
|
|
coPos.X = Bar->Left;
|
|
|
|
coPos.Y = i;
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
2022-10-07 22:46:00 +00:00
|
|
|
CharDoubleVerticalLine, // '|',
|
2014-05-12 16:14:19 +00:00
|
|
|
1,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
coPos.X = Bar->Right;
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
2022-10-07 22:46:00 +00:00
|
|
|
CharDoubleVerticalLine, //'|',
|
2014-05-12 16:14:19 +00:00
|
|
|
1,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
2005-05-18 19:08:00 +00:00
|
|
|
}
|
|
|
|
|
2014-05-12 16:14:19 +00:00
|
|
|
/* draw lower left corner */
|
|
|
|
coPos.X = Bar->Left;
|
|
|
|
coPos.Y = Bar->Bottom;
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
2022-10-07 22:46:00 +00:00
|
|
|
CharDoubleLowerLeftCorner, // '+',
|
2014-05-12 16:14:19 +00:00
|
|
|
1,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
/* draw lower edge */
|
|
|
|
coPos.X = Bar->Left + 1;
|
|
|
|
coPos.Y = Bar->Bottom;
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
2022-10-07 22:46:00 +00:00
|
|
|
CharDoubleHorizontalLine, // '-',
|
2014-05-12 16:14:19 +00:00
|
|
|
Bar->Right - Bar->Left - 1,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
/* draw lower right corner */
|
|
|
|
coPos.X = Bar->Right;
|
|
|
|
coPos.Y = Bar->Bottom;
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
2022-10-07 22:46:00 +00:00
|
|
|
CharDoubleLowerRightCorner, // '+',
|
2014-05-12 16:14:19 +00:00
|
|
|
1,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
2005-05-18 19:08:00 +00:00
|
|
|
}
|
2002-12-06 21:39:04 +00:00
|
|
|
|
2014-05-12 16:14:19 +00:00
|
|
|
static
|
|
|
|
VOID
|
|
|
|
DrawProgressBar(
|
2018-08-26 18:31:14 +00:00
|
|
|
IN PPROGRESSBAR Bar)
|
2002-12-06 21:39:04 +00:00
|
|
|
{
|
2014-05-12 16:14:19 +00:00
|
|
|
COORD coPos;
|
|
|
|
DWORD Written;
|
|
|
|
PROGRESSBAR BarBorder = *Bar;
|
2018-08-26 18:40:34 +00:00
|
|
|
CHAR TextBuffer[256];
|
2014-05-12 16:14:19 +00:00
|
|
|
|
2018-08-26 14:41:43 +00:00
|
|
|
/* Draw the progress bar "border" border */
|
2018-08-26 18:31:14 +00:00
|
|
|
if (Bar->DoubleEdge)
|
2018-08-26 14:41:43 +00:00
|
|
|
{
|
|
|
|
BarBorder.Top -= 5;
|
|
|
|
BarBorder.Bottom += 2;
|
|
|
|
BarBorder.Right += 5;
|
|
|
|
BarBorder.Left -= 5;
|
|
|
|
DrawThickBorder(&BarBorder);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw the progress bar border */
|
|
|
|
DrawBorder(Bar);
|
|
|
|
|
2018-08-26 18:31:14 +00:00
|
|
|
/* Display the description text */
|
|
|
|
if (Bar->DescriptionText)
|
|
|
|
CONSOLE_SetTextXY(Bar->TextTop, Bar->TextRight, Bar->DescriptionText);
|
2018-08-26 14:41:43 +00:00
|
|
|
|
2018-08-27 21:55:58 +00:00
|
|
|
/* Always update and display the progress */
|
2018-08-26 18:40:34 +00:00
|
|
|
if (Bar->UpdateProgressProc &&
|
2018-08-27 21:55:58 +00:00
|
|
|
Bar->UpdateProgressProc(Bar, TRUE, TextBuffer, ARRAYSIZE(TextBuffer)))
|
2018-08-26 18:40:34 +00:00
|
|
|
{
|
2021-06-29 16:50:15 +00:00
|
|
|
coPos.X = Bar->Left + (Bar->Width - (USHORT)strlen(TextBuffer) + 1) / 2;
|
2018-08-26 18:40:34 +00:00
|
|
|
coPos.Y = Bar->Top;
|
|
|
|
WriteConsoleOutputCharacterA(StdOutput,
|
|
|
|
TextBuffer,
|
|
|
|
strlen(TextBuffer),
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
}
|
2014-05-12 16:14:19 +00:00
|
|
|
|
2018-08-26 14:41:43 +00:00
|
|
|
/* Draw the empty bar */
|
2014-05-12 16:14:19 +00:00
|
|
|
coPos.X = Bar->Left + 1;
|
|
|
|
for (coPos.Y = Bar->Top + 2; coPos.Y <= Bar->Bottom - 1; coPos.Y++)
|
|
|
|
{
|
|
|
|
FillConsoleOutputAttribute(StdOutput,
|
2018-08-21 13:49:54 +00:00
|
|
|
Bar->ProgressColour,
|
2014-05-12 16:14:19 +00:00
|
|
|
Bar->Width - 2,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
|
|
|
' ',
|
|
|
|
Bar->Width - 2,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
}
|
2002-12-06 21:39:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-02-23 11:58:27 +00:00
|
|
|
PPROGRESSBAR
|
2018-08-21 13:49:54 +00:00
|
|
|
CreateProgressBarEx(
|
2018-08-26 18:31:14 +00:00
|
|
|
IN SHORT Left,
|
|
|
|
IN SHORT Top,
|
|
|
|
IN SHORT Right,
|
|
|
|
IN SHORT Bottom,
|
|
|
|
IN SHORT TextTop,
|
|
|
|
IN SHORT TextRight,
|
2014-05-12 16:14:19 +00:00
|
|
|
IN BOOLEAN DoubleEdge,
|
2018-08-26 18:31:14 +00:00
|
|
|
IN SHORT ProgressColour,
|
2018-08-27 21:55:58 +00:00
|
|
|
IN ULONG StepCount,
|
2018-08-26 18:40:34 +00:00
|
|
|
IN PCSTR DescriptionText OPTIONAL,
|
|
|
|
IN PCSTR ProgressFormatText OPTIONAL,
|
|
|
|
IN PUPDATE_PROGRESS UpdateProgressProc OPTIONAL)
|
2002-12-06 21:39:04 +00:00
|
|
|
{
|
2014-05-12 16:14:19 +00:00
|
|
|
PPROGRESSBAR Bar;
|
2002-12-06 21:39:04 +00:00
|
|
|
|
2014-05-12 16:14:19 +00:00
|
|
|
Bar = (PPROGRESSBAR)RtlAllocateHeap(ProcessHeap,
|
|
|
|
0,
|
|
|
|
sizeof(PROGRESSBAR));
|
|
|
|
if (Bar == NULL)
|
|
|
|
return NULL;
|
2002-12-06 21:39:04 +00:00
|
|
|
|
2014-05-12 16:14:19 +00:00
|
|
|
Bar->Left = Left;
|
|
|
|
Bar->Top = Top;
|
|
|
|
Bar->Right = Right;
|
|
|
|
Bar->Bottom = Bottom;
|
|
|
|
Bar->TextTop = TextTop;
|
|
|
|
Bar->TextRight = TextRight;
|
2002-12-06 21:39:04 +00:00
|
|
|
|
2014-05-12 16:14:19 +00:00
|
|
|
Bar->Width = Bar->Right - Bar->Left + 1;
|
2002-12-06 21:39:04 +00:00
|
|
|
|
2018-08-26 18:31:14 +00:00
|
|
|
Bar->DoubleEdge = DoubleEdge;
|
|
|
|
Bar->ProgressColour = ProgressColour;
|
|
|
|
Bar->DescriptionText = DescriptionText;
|
2018-08-26 18:40:34 +00:00
|
|
|
Bar->ProgressFormatText = ProgressFormatText;
|
2002-12-06 21:39:04 +00:00
|
|
|
|
2018-08-26 18:40:34 +00:00
|
|
|
Bar->UpdateProgressProc = UpdateProgressProc;
|
2018-08-26 18:31:14 +00:00
|
|
|
|
2018-08-27 21:55:58 +00:00
|
|
|
/* Reset the progress bar counts and initially draw it */
|
|
|
|
ProgressSetStepCount(Bar, StepCount);
|
2002-12-06 21:39:04 +00:00
|
|
|
|
2014-05-12 16:14:19 +00:00
|
|
|
return Bar;
|
2002-12-06 21:39:04 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 13:49:54 +00:00
|
|
|
PPROGRESSBAR
|
|
|
|
CreateProgressBar(
|
2018-08-26 18:31:14 +00:00
|
|
|
IN SHORT Left,
|
|
|
|
IN SHORT Top,
|
|
|
|
IN SHORT Right,
|
|
|
|
IN SHORT Bottom,
|
|
|
|
IN SHORT TextTop,
|
|
|
|
IN SHORT TextRight,
|
2018-08-21 13:49:54 +00:00
|
|
|
IN BOOLEAN DoubleEdge,
|
2018-08-26 18:31:14 +00:00
|
|
|
IN PCSTR DescriptionText OPTIONAL)
|
2018-08-21 13:49:54 +00:00
|
|
|
{
|
|
|
|
/* Call the Ex variant of the function */
|
|
|
|
return CreateProgressBarEx(Left, Top, Right, Bottom,
|
|
|
|
TextTop, TextRight,
|
|
|
|
DoubleEdge,
|
|
|
|
FOREGROUND_YELLOW | BACKGROUND_BLUE,
|
2018-08-27 21:55:58 +00:00
|
|
|
0,
|
2018-08-26 18:40:34 +00:00
|
|
|
DescriptionText,
|
|
|
|
"%-3lu%%",
|
|
|
|
UpdateProgressPercentage);
|
2018-08-21 13:49:54 +00:00
|
|
|
}
|
2002-12-06 21:39:04 +00:00
|
|
|
|
|
|
|
VOID
|
2014-05-12 16:14:19 +00:00
|
|
|
DestroyProgressBar(
|
2018-08-26 18:31:14 +00:00
|
|
|
IN OUT PPROGRESSBAR Bar)
|
2002-12-06 21:39:04 +00:00
|
|
|
{
|
2014-05-12 16:14:19 +00:00
|
|
|
RtlFreeHeap(ProcessHeap, 0, Bar);
|
2002-12-06 21:39:04 +00:00
|
|
|
}
|
|
|
|
|
2014-05-12 16:14:19 +00:00
|
|
|
|
2002-12-06 21:39:04 +00:00
|
|
|
VOID
|
2014-05-12 16:14:19 +00:00
|
|
|
ProgressSetStepCount(
|
2018-08-26 18:31:14 +00:00
|
|
|
IN PPROGRESSBAR Bar,
|
|
|
|
IN ULONG StepCount)
|
2002-12-06 21:39:04 +00:00
|
|
|
{
|
2014-05-12 16:14:19 +00:00
|
|
|
Bar->CurrentStep = 0;
|
|
|
|
Bar->StepCount = StepCount;
|
2002-12-06 21:39:04 +00:00
|
|
|
|
2018-08-27 21:55:58 +00:00
|
|
|
Bar->Progress = 0;
|
|
|
|
Bar->Pos = 0;
|
|
|
|
|
2014-05-12 16:14:19 +00:00
|
|
|
DrawProgressBar(Bar);
|
2002-12-06 21:39:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
2014-05-12 16:14:19 +00:00
|
|
|
ProgressNextStep(
|
2018-08-26 18:31:14 +00:00
|
|
|
IN PPROGRESSBAR Bar)
|
2002-12-06 21:39:04 +00:00
|
|
|
{
|
2014-05-12 16:14:19 +00:00
|
|
|
ProgressSetStep(Bar, Bar->CurrentStep + 1);
|
2004-02-23 11:58:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
2014-05-12 16:14:19 +00:00
|
|
|
ProgressSetStep(
|
2018-08-26 18:31:14 +00:00
|
|
|
IN PPROGRESSBAR Bar,
|
|
|
|
IN ULONG Step)
|
2004-02-23 11:58:27 +00:00
|
|
|
{
|
2014-05-12 16:14:19 +00:00
|
|
|
COORD coPos;
|
|
|
|
DWORD Written;
|
|
|
|
ULONG NewPos;
|
2018-08-26 18:40:34 +00:00
|
|
|
CHAR TextBuffer[256];
|
2004-02-23 11:58:27 +00:00
|
|
|
|
2014-05-12 16:14:19 +00:00
|
|
|
if (Step > Bar->StepCount)
|
|
|
|
return;
|
2004-02-23 11:58:27 +00:00
|
|
|
|
2014-05-12 16:14:19 +00:00
|
|
|
Bar->CurrentStep = Step;
|
2004-02-23 11:58:27 +00:00
|
|
|
|
2018-08-26 18:40:34 +00:00
|
|
|
/* Update the progress and redraw it if it has changed */
|
|
|
|
if (Bar->UpdateProgressProc &&
|
2018-08-27 21:55:58 +00:00
|
|
|
Bar->UpdateProgressProc(Bar, FALSE, TextBuffer, ARRAYSIZE(TextBuffer)))
|
2002-12-06 21:39:04 +00:00
|
|
|
{
|
2021-06-29 16:50:15 +00:00
|
|
|
coPos.X = Bar->Left + (Bar->Width - (USHORT)strlen(TextBuffer) + 1) / 2;
|
2014-05-12 16:14:19 +00:00
|
|
|
coPos.Y = Bar->Top;
|
|
|
|
WriteConsoleOutputCharacterA(StdOutput,
|
|
|
|
TextBuffer,
|
2018-08-26 18:40:34 +00:00
|
|
|
strlen(TextBuffer),
|
2014-05-12 16:14:19 +00:00
|
|
|
coPos,
|
|
|
|
&Written);
|
2002-12-06 21:39:04 +00:00
|
|
|
}
|
|
|
|
|
2018-08-26 18:31:14 +00:00
|
|
|
/* Calculate the bar position */
|
|
|
|
NewPos = (((Bar->Width - 2) * 2 * Bar->CurrentStep + (Bar->StepCount / 2)) / Bar->StepCount);
|
2002-12-06 21:39:04 +00:00
|
|
|
|
2018-08-26 18:31:14 +00:00
|
|
|
/* Redraw the bar if it has changed */
|
2014-05-12 16:14:19 +00:00
|
|
|
if (Bar->Pos != NewPos)
|
2002-12-06 21:39:04 +00:00
|
|
|
{
|
2014-05-12 16:14:19 +00:00
|
|
|
Bar->Pos = NewPos;
|
|
|
|
|
|
|
|
for (coPos.Y = Bar->Top + 2; coPos.Y <= Bar->Bottom - 1; coPos.Y++)
|
|
|
|
{
|
|
|
|
coPos.X = Bar->Left + 1;
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
2022-10-07 22:46:00 +00:00
|
|
|
CharBlock,
|
2014-05-12 16:14:19 +00:00
|
|
|
Bar->Pos / 2,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
2018-08-26 18:31:14 +00:00
|
|
|
coPos.X += Bar->Pos / 2;
|
2014-05-12 16:14:19 +00:00
|
|
|
|
|
|
|
if (NewPos & 1)
|
|
|
|
{
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
2022-10-07 22:46:00 +00:00
|
|
|
CharHalfBlock,
|
2014-05-12 16:14:19 +00:00
|
|
|
1,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
coPos.X++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (coPos.X <= Bar->Right - 1)
|
|
|
|
{
|
|
|
|
FillConsoleOutputCharacterA(StdOutput,
|
|
|
|
' ',
|
|
|
|
Bar->Right - coPos.X,
|
|
|
|
coPos,
|
|
|
|
&Written);
|
|
|
|
}
|
|
|
|
}
|
2002-12-06 21:39:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|