#ifndef ROOT_TGProgressBar
#define ROOT_TGProgressBar
#ifndef ROOT_TGFrame
#include "TGFrame.h"
#endif
class TGProgressBar : public TGFrame {
public:
enum EBarType { kStandard, kFancy };
enum EFillType { kSolidFill, kBlockFill };
enum { kProgressBarStandardWidth = 16, kProgressBarTextWidth = 24,
kBlockSize = 8, kBlockSpace = 2 };
protected:
Float_t fMin;
Float_t fMax;
Float_t fPos;
Int_t fPosPix;
Int_t fBarWidth;
EFillType fFillType;
EBarType fBarType;
TString fFormat;
Bool_t fShowPos;
Bool_t fPercent;
Bool_t fDrawBar;
TGGC fBarColorGC;
GContext_t fNormGC;
FontStruct_t fFontStruct;
virtual void DoRedraw() = 0;
static const TGFont *fgDefaultFont;
static TGGC *fgDefaultGC;
public:
static FontStruct_t GetDefaultFontStruct();
static const TGGC &GetDefaultGC();
TGProgressBar(const TGWindow *p, UInt_t w, UInt_t h,
Pixel_t back = GetWhitePixel(),
Pixel_t barcolor = GetDefaultSelectedBackground(),
GContext_t norm = GetDefaultGC()(),
FontStruct_t font = GetDefaultFontStruct(),
UInt_t options = kDoubleBorder | kSunkenFrame);
virtual ~TGProgressBar() { }
Float_t GetMin() const { return fMin; }
Float_t GetMax() const { return fMax; }
Float_t GetPosition() const { return fPos; }
EFillType GetFillType() const { return fFillType; }
EBarType GetBarType() const { return fBarType; }
Bool_t GetShowPos() const { return fShowPos; }
TString GetFormat() const { return fFormat; }
const char* GetValueFormat() const { return fFormat.Data(); }
Bool_t UsePercent() const { return fPercent; }
Pixel_t GetBarColor() const { return fBarColorGC.GetForeground(); }
GContext_t GetNormGC() const { return fNormGC; }
FontStruct_t GetFontStruct() const { return fFontStruct; }
void SetPosition(Float_t pos);
void SetRange(Float_t min, Float_t max);
void Increment(Float_t inc);
void SetBarType(EBarType type);
void SetFillType(EFillType type);
virtual void Percent(Bool_t on) { fPercent = on; fClient->NeedRedraw(this); }
virtual void ShowPos(Bool_t on) { fShowPos = on; fClient->NeedRedraw(this); }
virtual void Format(const char *format = "%.2f");
void SetMin(Float_t min) { fMin = min; }
void SetMax(Float_t max) { fMax = max; }
virtual void SetBarColor(Pixel_t color);
void SetBarColor(const char *color="blue");
virtual void Reset();
virtual void SetForegroundColor(Pixel_t pixel);
virtual void SavePrimitive(ostream &out, Option_t *option = "");
ClassDef(TGProgressBar,0)
};
class TGHProgressBar : public TGProgressBar {
protected:
virtual void DoRedraw();
public:
TGHProgressBar(const TGWindow *p = 0,
UInt_t w = 4, UInt_t h = kProgressBarTextWidth,
Pixel_t back = GetWhitePixel(),
Pixel_t barcolor = GetDefaultSelectedBackground(),
GContext_t norm = GetDefaultGC()(),
FontStruct_t font = GetDefaultFontStruct(),
UInt_t options = kDoubleBorder | kSunkenFrame);
TGHProgressBar(const TGWindow *p, EBarType type, UInt_t w);
virtual ~TGHProgressBar() { }
virtual TGDimension GetDefaultSize() const
{ return TGDimension(fWidth, fBarWidth); }
void ShowPosition(Bool_t set = kTRUE, Bool_t percent = kTRUE,
const char *format = "%.2f");
virtual void SavePrimitive(ostream &out, Option_t *option = "");
ClassDef(TGHProgressBar,0)
};
class TGVProgressBar : public TGProgressBar {
protected:
virtual void DoRedraw();
public:
TGVProgressBar(const TGWindow *p = 0,
UInt_t w = kProgressBarTextWidth, UInt_t h = 4,
Pixel_t back = GetWhitePixel(),
Pixel_t barcolor = GetDefaultSelectedBackground(),
GContext_t norm = GetDefaultGC()(),
FontStruct_t font = GetDefaultFontStruct(),
UInt_t options = kDoubleBorder | kSunkenFrame);
TGVProgressBar(const TGWindow *p, EBarType type, UInt_t h);
virtual ~TGVProgressBar() { }
virtual TGDimension GetDefaultSize() const
{ return TGDimension(fBarWidth, fHeight); }
virtual void SavePrimitive(ostream &out, Option_t *option = "");
void ShowPos(Bool_t) { }
void Percent(Bool_t) { }
ClassDef(TGVProgressBar,0)
};
#endif