00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TGProgressBar
00013 #define ROOT_TGProgressBar
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ROOT_TGFrame
00029 #include "TGFrame.h"
00030 #endif
00031
00032
00033 class TGProgressBar : public TGFrame {
00034
00035 public:
00036 enum EBarType { kStandard, kFancy };
00037 enum EFillType { kSolidFill, kBlockFill };
00038 enum { kProgressBarStandardWidth = 16, kProgressBarTextWidth = 24,
00039 kBlockSize = 8, kBlockSpace = 2 };
00040
00041 protected:
00042 Float_t fMin;
00043 Float_t fMax;
00044 Float_t fPos;
00045 Int_t fPosPix;
00046 Int_t fBarWidth;
00047 EFillType fFillType;
00048 EBarType fBarType;
00049 TString fFormat;
00050 Bool_t fShowPos;
00051 Bool_t fPercent;
00052 Bool_t fDrawBar;
00053 TGGC fBarColorGC;
00054 GContext_t fNormGC;
00055 FontStruct_t fFontStruct;
00056
00057 virtual void DoRedraw() = 0;
00058
00059 static const TGFont *fgDefaultFont;
00060 static TGGC *fgDefaultGC;
00061
00062 public:
00063 static FontStruct_t GetDefaultFontStruct();
00064 static const TGGC &GetDefaultGC();
00065
00066 TGProgressBar(const TGWindow *p, UInt_t w, UInt_t h,
00067 Pixel_t back = GetWhitePixel(),
00068 Pixel_t barcolor = GetDefaultSelectedBackground(),
00069 GContext_t norm = GetDefaultGC()(),
00070 FontStruct_t font = GetDefaultFontStruct(),
00071 UInt_t options = kDoubleBorder | kSunkenFrame);
00072 virtual ~TGProgressBar() { }
00073
00074 Float_t GetMin() const { return fMin; }
00075 Float_t GetMax() const { return fMax; }
00076 Float_t GetPosition() const { return fPos; }
00077 EFillType GetFillType() const { return fFillType; }
00078 EBarType GetBarType() const { return fBarType; }
00079 Bool_t GetShowPos() const { return fShowPos; }
00080 TString GetFormat() const { return fFormat; }
00081 const char* GetValueFormat() const { return fFormat.Data(); }
00082 Bool_t UsePercent() const { return fPercent; }
00083 Pixel_t GetBarColor() const { return fBarColorGC.GetForeground(); }
00084 GContext_t GetNormGC() const { return fNormGC; }
00085 FontStruct_t GetFontStruct() const { return fFontStruct; }
00086
00087 void SetPosition(Float_t pos);
00088 void SetRange(Float_t min, Float_t max);
00089 void Increment(Float_t inc);
00090 void SetBarType(EBarType type);
00091 void SetFillType(EFillType type);
00092 virtual void Percent(Bool_t on) { fPercent = on; fClient->NeedRedraw(this); }
00093 virtual void ShowPos(Bool_t on) { fShowPos = on; fClient->NeedRedraw(this); }
00094 virtual void Format(const char *format = "%.2f");
00095 void SetMin(Float_t min) { fMin = min; }
00096 void SetMax(Float_t max) { fMax = max; }
00097 virtual void SetBarColor(Pixel_t color);
00098 void SetBarColor(const char *color="blue");
00099 virtual void Reset();
00100 virtual void SetForegroundColor(Pixel_t pixel);
00101
00102 virtual void SavePrimitive(ostream &out, Option_t *option = "");
00103
00104 ClassDef(TGProgressBar,0)
00105 };
00106
00107
00108 class TGHProgressBar : public TGProgressBar {
00109
00110 protected:
00111 virtual void DoRedraw();
00112
00113 public:
00114 TGHProgressBar(const TGWindow *p = 0,
00115 UInt_t w = 4, UInt_t h = kProgressBarTextWidth,
00116 Pixel_t back = GetWhitePixel(),
00117 Pixel_t barcolor = GetDefaultSelectedBackground(),
00118 GContext_t norm = GetDefaultGC()(),
00119 FontStruct_t font = GetDefaultFontStruct(),
00120 UInt_t options = kDoubleBorder | kSunkenFrame);
00121 TGHProgressBar(const TGWindow *p, EBarType type, UInt_t w);
00122 virtual ~TGHProgressBar() { }
00123
00124 virtual TGDimension GetDefaultSize() const
00125 { return TGDimension(fWidth, fBarWidth); }
00126
00127 void ShowPosition(Bool_t set = kTRUE, Bool_t percent = kTRUE,
00128 const char *format = "%.2f");
00129
00130 virtual void SavePrimitive(ostream &out, Option_t *option = "");
00131
00132 ClassDef(TGHProgressBar,0)
00133 };
00134
00135
00136 class TGVProgressBar : public TGProgressBar {
00137
00138 protected:
00139 virtual void DoRedraw();
00140
00141 public:
00142 TGVProgressBar(const TGWindow *p = 0,
00143 UInt_t w = kProgressBarTextWidth, UInt_t h = 4,
00144 Pixel_t back = GetWhitePixel(),
00145 Pixel_t barcolor = GetDefaultSelectedBackground(),
00146 GContext_t norm = GetDefaultGC()(),
00147 FontStruct_t font = GetDefaultFontStruct(),
00148 UInt_t options = kDoubleBorder | kSunkenFrame);
00149 TGVProgressBar(const TGWindow *p, EBarType type, UInt_t h);
00150 virtual ~TGVProgressBar() { }
00151
00152 virtual TGDimension GetDefaultSize() const
00153 { return TGDimension(fBarWidth, fHeight); }
00154 virtual void SavePrimitive(ostream &out, Option_t *option = "");
00155 void ShowPos(Bool_t) { }
00156 void Percent(Bool_t) { }
00157
00158 ClassDef(TGVProgressBar,0)
00159 };
00160
00161 #endif
00162