ReactOS  0.4.14-dev-55-g2da92ac
progress.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _PROGRESSBAR
 

Typedefs

typedef IN BOOLEAN AlwaysUpdate
 
typedef IN BOOLEAN OUT PSTR Buffer = Buffer
 
typedef IN BOOLEAN OUT PSTR IN SIZE_T cchBufferSize
 
typedef struct _PROGRESSBAR PROGRESSBAR
 
typedef struct _PROGRESSBARPPROGRESSBAR
 

Functions

typedef BOOLEAN (NTAPI *PUPDATE_PROGRESS)(IN struct _PROGRESSBAR *Bar
 
PPROGRESSBAR CreateProgressBarEx (IN SHORT Left, IN SHORT Top, IN SHORT Right, IN SHORT Bottom, IN SHORT TextTop, IN SHORT TextRight, IN BOOLEAN DoubleEdge, IN SHORT ProgressColour, IN ULONG StepCount, IN PCSTR DescriptionText OPTIONAL, IN PCSTR ProgressFormatText OPTIONAL, IN PUPDATE_PROGRESS UpdateProgressProc OPTIONAL)
 
PPROGRESSBAR CreateProgressBar (IN SHORT Left, IN SHORT Top, IN SHORT Right, IN SHORT Bottom, IN SHORT TextTop, IN SHORT TextRight, IN BOOLEAN DoubleEdge, IN PCSTR DescriptionText OPTIONAL)
 
VOID DestroyProgressBar (IN OUT PPROGRESSBAR Bar)
 
VOID ProgressSetStepCount (IN PPROGRESSBAR Bar, IN ULONG StepCount)
 
VOID ProgressNextStep (IN PPROGRESSBAR Bar)
 
VOID ProgressSetStep (IN PPROGRESSBAR Bar, IN ULONG Step)
 

Typedef Documentation

◆ AlwaysUpdate

Definition at line 34 of file progress.h.

◆ Buffer

Definition at line 34 of file progress.h.

◆ cchBufferSize

Definition at line 34 of file progress.h.

◆ PPROGRESSBAR

◆ PROGRESSBAR

Function Documentation

◆ BOOLEAN()

typedef BOOLEAN ( NTAPI PUPDATE_PROGRESS)

◆ CreateProgressBar()

PPROGRESSBAR CreateProgressBar ( IN SHORT  Left,
IN SHORT  Top,
IN SHORT  Right,
IN SHORT  Bottom,
IN SHORT  TextTop,
IN SHORT  TextRight,
IN BOOLEAN  DoubleEdge,
IN PCSTR DescriptionText  OPTIONAL 
)

Definition at line 317 of file progress.c.

326 {
327  /* Call the Ex variant of the function */
328  return CreateProgressBarEx(Left, Top, Right, Bottom,
329  TextTop, TextRight,
330  DoubleEdge,
332  0,
333  DescriptionText,
334  "%-3lu%%",
336 }
PPROGRESSBAR CreateProgressBarEx(IN SHORT Left, IN SHORT Top, IN SHORT Right, IN SHORT Bottom, IN SHORT TextTop, IN SHORT TextRight, IN BOOLEAN DoubleEdge, IN SHORT ProgressColour, IN ULONG StepCount, IN PCSTR DescriptionText OPTIONAL, IN PCSTR ProgressFormatText OPTIONAL, IN PUPDATE_PROGRESS UpdateProgressProc OPTIONAL)
Definition: progress.c:272
static BOOLEAN NTAPI UpdateProgressPercentage(IN PPROGRESSBAR Bar, IN BOOLEAN AlwaysUpdate, OUT PSTR Buffer, IN SIZE_T cchBufferSize)
Definition: progress.c:20
#define FOREGROUND_YELLOW
Definition: consup.h:30
#define BACKGROUND_BLUE
Definition: wincon.h:43
static LPHIST_ENTRY Bottom
Definition: history.c:54
static LPHIST_ENTRY Top
Definition: history.c:53

Referenced by ChkdskPartition(), FileCopyPage(), and FormatPartition().

◆ CreateProgressBarEx()

PPROGRESSBAR CreateProgressBarEx ( IN SHORT  Left,
IN SHORT  Top,
IN SHORT  Right,
IN SHORT  Bottom,
IN SHORT  TextTop,
IN SHORT  TextRight,
IN BOOLEAN  DoubleEdge,
IN SHORT  ProgressColour,
IN ULONG  StepCount,
IN PCSTR DescriptionText  OPTIONAL,
IN PCSTR ProgressFormatText  OPTIONAL,
IN PUPDATE_PROGRESS UpdateProgressProc  OPTIONAL 
)

Definition at line 272 of file progress.c.

285 {
286  PPROGRESSBAR Bar;
287 
289  0,
290  sizeof(PROGRESSBAR));
291  if (Bar == NULL)
292  return NULL;
293 
294  Bar->Left = Left;
295  Bar->Top = Top;
296  Bar->Right = Right;
297  Bar->Bottom = Bottom;
298  Bar->TextTop = TextTop;
299  Bar->TextRight = TextRight;
300 
301  Bar->Width = Bar->Right - Bar->Left + 1;
302 
303  Bar->DoubleEdge = DoubleEdge;
304  Bar->ProgressColour = ProgressColour;
305  Bar->DescriptionText = DescriptionText;
306  Bar->ProgressFormatText = ProgressFormatText;
307 
308  Bar->UpdateProgressProc = UpdateProgressProc;
309 
310  /* Reset the progress bar counts and initially draw it */
311  ProgressSetStepCount(Bar, StepCount);
312 
313  return Bar;
314 }
BOOLEAN DoubleEdge
Definition: progress.h:60
SHORT TextRight
Definition: progress.h:46
SHORT Left
Definition: progress.h:41
PUPDATE_PROGRESS UpdateProgressProc
Definition: progress.h:55
VOID ProgressSetStepCount(IN PPROGRESSBAR Bar, IN ULONG StepCount)
Definition: progress.c:347
SHORT ProgressColour
Definition: progress.h:61
SHORT Bottom
Definition: progress.h:44
SHORT Right
Definition: progress.h:43
smooth NULL
Definition: ftsmooth.c:416
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
SHORT TextTop
Definition: progress.h:45
SHORT Width
Definition: progress.h:48
PCSTR DescriptionText
Definition: progress.h:62
HANDLE ProcessHeap
Definition: servman.c:15
static LPHIST_ENTRY Bottom
Definition: history.c:54
struct _PROGRESSBAR * PPROGRESSBAR
SHORT Top
Definition: progress.h:42
static LPHIST_ENTRY Top
Definition: history.c:53
PCSTR ProgressFormatText
Definition: progress.h:63

Referenced by CreateProgressBar(), and ProgressCountdown().

◆ DestroyProgressBar()

VOID DestroyProgressBar ( IN OUT PPROGRESSBAR  Bar)

Definition at line 339 of file progress.c.

341 {
342  RtlFreeHeap(ProcessHeap, 0, Bar);
343 }
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
HANDLE ProcessHeap
Definition: servman.c:15

Referenced by ChkdskPartition(), FileCopyPage(), FormatPartition(), and ProgressCountdown().

◆ ProgressNextStep()

VOID ProgressNextStep ( IN PPROGRESSBAR  Bar)

Definition at line 361 of file progress.c.

363 {
364  ProgressSetStep(Bar, Bar->CurrentStep + 1);
365 }
VOID ProgressSetStep(IN PPROGRESSBAR Bar, IN ULONG Step)
Definition: progress.c:368

Referenced by FileCopyCallback().

◆ ProgressSetStep()

VOID ProgressSetStep ( IN PPROGRESSBAR  Bar,
IN ULONG  Step 
)

Definition at line 368 of file progress.c.

371 {
372  COORD coPos;
373  DWORD Written;
374  ULONG NewPos;
375  CHAR TextBuffer[256];
376 
377  if (Step > Bar->StepCount)
378  return;
379 
380  Bar->CurrentStep = Step;
381 
382  /* Update the progress and redraw it if it has changed */
383  if (Bar->UpdateProgressProc &&
384  Bar->UpdateProgressProc(Bar, FALSE, TextBuffer, ARRAYSIZE(TextBuffer)))
385  {
386  coPos.X = Bar->Left + (Bar->Width - strlen(TextBuffer) + 1) / 2;
387  coPos.Y = Bar->Top;
389  TextBuffer,
391  coPos,
392  &Written);
393  }
394 
395  /* Calculate the bar position */
396  NewPos = (((Bar->Width - 2) * 2 * Bar->CurrentStep + (Bar->StepCount / 2)) / Bar->StepCount);
397 
398  /* Redraw the bar if it has changed */
399  if (Bar->Pos != NewPos)
400  {
401  Bar->Pos = NewPos;
402 
403  for (coPos.Y = Bar->Top + 2; coPos.Y <= Bar->Bottom - 1; coPos.Y++)
404  {
405  coPos.X = Bar->Left + 1;
407  0xDB,
408  Bar->Pos / 2,
409  coPos,
410  &Written);
411  coPos.X += Bar->Pos / 2;
412 
413  if (NewPos & 1)
414  {
416  0xDD,
417  1,
418  coPos,
419  &Written);
420  coPos.X++;
421  }
422 
423  if (coPos.X <= Bar->Right - 1)
424  {
426  ' ',
427  Bar->Right - coPos.X,
428  coPos,
429  &Written);
430  }
431  }
432  }
433 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
BOOL WINAPI FillConsoleOutputCharacterA(IN HANDLE hConsoleOutput, IN CHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:509
HANDLE StdOutput
Definition: consup.c:37
BOOL WINAPI WriteConsoleOutputCharacterA(HANDLE hConsoleOutput, IN LPCSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:356
ULONG X
Definition: bl.h:1340
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: bl.h:1338
char TextBuffer[BUFFERLEN]
Definition: combotst.c:45
unsigned int ULONG
Definition: retypes.h:1
ULONG Y
Definition: bl.h:1341

Referenced by FormatCallback(), ProgressCountdown(), ProgressNextStep(), and SetupUpdateMemoryInfo().

◆ ProgressSetStepCount()

VOID ProgressSetStepCount ( IN PPROGRESSBAR  Bar,
IN ULONG  StepCount 
)

Definition at line 347 of file progress.c.

350 {
351  Bar->CurrentStep = 0;
352  Bar->StepCount = StepCount;
353 
354  Bar->Progress = 0;
355  Bar->Pos = 0;
356 
357  DrawProgressBar(Bar);
358 }
static VOID DrawProgressBar(IN PPROGRESSBAR Bar)
Definition: progress.c:214

Referenced by ChkdskPartition(), CreateProgressBarEx(), FileCopyCallback(), FormatPartition(), ProgressCountdown(), and SetupUpdateMemoryInfo().