Finished implementing ProgressStatusBar class

This commit is contained in:
Joseph Lenox 2018-05-05 12:48:24 -05:00 committed by Joseph Lenox
parent 1ffd57d37a
commit 1e8655bf24
2 changed files with 22 additions and 6 deletions

View File

@ -52,6 +52,18 @@ void ProgressStatusBar::OnSize(wxSizeEvent &e) {
e.Skip();
}
void ProgressStatusBar::SetProgress(size_t val) {
if (!this->prog->IsShown()) {
this->ShowProgress(true);
}
if (val == this->prog->GetRange()) {
this->prog->SetValue(0);
this->ShowProgress(false);
} else {
this->prog->SetValue(val);
}
}
void ProgressStatusBar::OnTimer(wxTimerEvent& e) {
if (this->prog->IsShown())
this->timer->Stop();

View File

@ -32,21 +32,25 @@ public:
cb == nullptr ? this->cancelbutton->Hide() : this->cancelbutton->Show();
}
/// Accessor function for the current value of the progress bar
size_t GetProgress() {return this->prog->GetValue();}
/// Accessor function for busy state
bool IsBusy() {return this->busy;}
/// Show the progress bar.
void ShowProgress(bool show = true) { this->prog->Show(show); this->prog->Pulse(); }
/// Accessor function for the current value of the progress bar
inline size_t GetProgress() {return this->prog->GetValue();}
/// Accessor set function for the current value of the progress bar
void SetProgress(size_t val);
void SetRange(int range) { if (range != this->prog->GetRange() ) this->prog->SetRange(range);}
/// Start the timer.
void Run(int rate = 100) { if (this->timer->IsRunning()) this->timer->Start(rate);};
void StartBusy(int rate = 100) { this->busy = true; this->ShowProgress(true); if (!this->timer->IsRunning()) this->timer->Start(rate); }
void StopBusy() { this->timer->Stop(); this->ShowProgress(false); this->prog->SetValue(0); this->busy = false;}
/// Accessor function for busy state
bool IsBusy() {return this->busy;}
private:
void OnSize(wxSizeEvent& e);