class Progress : public WithProgressLayout<TopWindow>
Progress is simple helper dialog that can be used to show a progress of long operation and to cancel it.
Progress()
Default constructor.
Progress(Ctrl *_owner)
Progress(const char *txt, int total = 0)
Progress(Ctrl *_owner, const char *txt, int total = 0)
Convenience constructor variants can set owner, text and total number of steps.
void SetOwner(Ctrl *_owner)
Sets the owner window of progress. _owner can be child of owner window too. Note that if owner is not specified, current active window is used as owner.
void Create()
Forces dialog to appear on the screen.
void Cancel()
Closes the dialog and sets it to canceled mode.
void Set(int pos, int total)
Sets the current progress position and total. This method can be called from non-main thread without restriction.
void SetPos(int pos)
Sets the current progress position. This method can be called from non-main thread without restriction.
void SetText(const char *s)
void SetText(const String& s)
Sets the text to be displayed in dialog. This method can be called from non-main thread without restriction.
void SetTotal(int total)
Sets the total number of progress steps.
void Step(int steps = 1)
Advances progress by steps. If total number of steps is zero, "running bar" is displayed. This method can be called from non-main thread without restriction.
int GetPos() const
Returns the current number of progress steps.
int GetTotal() const
Returns the total number of steps (as set by Set or SetTotal).
String GetText() const
Returns the text of Progress.
bool Canceled()
Shows a Cancel button if not shown yet. If this button is pressed, sets dialog to canceled mode. Returns true if dialog was canceled. This method can be called from non-main thread without restriction. Calling this method from the main thread also invokes processing GUI events, including paint event, so calling this as often as once per 1ms is desirable.
bool SetCanceled(int pos, int total)
Same as Set(pos, total), Canceled().
bool SetPosCanceled(int pos)
Same as SetPos(pos), Canceled().
bool StepCanceled(int steps = 1)
Same as Set(steps), Canceled().
void Reset()
Resets dialog to default settings.
void Granularity(int ms)
Sets how much often should dialog refresh. Default is 50ms.
void AlignText(int align)
Sets text alignment. Allowed values are ALIGN_LEFT, ALIGN_CENTER and ALIGN_RIGHT.
operator Gate2<int, int>()
Returns a callback to dialog's SetCanceled method.
void Delay(int ms)
Sets the delay before the dialog is shown for the first time (in order not to show it when operation proceeds fast). Default is 250ms.
|