#ifndef Progress_First #define Progress_First #ifdef __GNUG__ #pragma interface #endif #include "Object.h" class ProgressTimeoutHandler; class Timer; //---- Progress ---------------------------------------------------------------- class Progress : public Object { public: MetaDef(Progress); Progress(); void Start(const char *message, long mx, bool enable_abort= TRUE); // start progress indicator with message and max tick count mx virtual void SetMessage(const char *message); // change indicator message on-the-fly void SetMax(long mx); // set maximum tick bool Tick(long curr); // set absolut tick bool Inc(long inc); // increment tick; bool Stop(); // stop progress (normal end); returns same as WasAborted() void Abort(); // abort progress (abnormal end) void EnableAbort(bool stop); // allow/disallow aborting; (e.g. show a "stop" button) bool WasAborted(); protected: // subclass responsibility virtual void DoSetUp(); virtual bool DoSetVal(); virtual void DoAbort(bool skiptoend); virtual void DoEnableAbort(bool stop); virtual void DoSetMessage(const char *message); protected: friend ProgressTimeoutHandler; long curr, max; bool timeout, aborted; Timer *alarmhandler; static bool inProgress; }; extern Progress *gProgress; inline void Progress::SetMax(long mx) { max= mx; } inline bool Progress::Tick(long val) { curr= val; return timeout ? DoSetVal() : FALSE; } inline bool Progress::Inc(long inc) { curr+= inc; return timeout ? DoSetVal() : FALSE; } inline bool Progress::WasAborted() { return aborted; } #endif