File indexing completed on 2025-01-18 10:12:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGProgressBar
0013 #define ROOT_TGProgressBar
0014
0015
0016 #include "TGFrame.h"
0017
0018
0019 class TGProgressBar : public TGFrame {
0020
0021 public:
0022 enum EBarType { kStandard, kFancy };
0023 enum EFillType { kSolidFill, kBlockFill };
0024 enum { kProgressBarStandardWidth = 16, kProgressBarTextWidth = 24,
0025 kBlockSize = 8, kBlockSpace = 2 };
0026
0027 protected:
0028 Float_t fMin;
0029 Float_t fMax;
0030 Float_t fPos;
0031 Int_t fPosPix;
0032 Int_t fBarWidth;
0033 EFillType fFillType;
0034 EBarType fBarType;
0035 TString fFormat;
0036 Bool_t fShowPos;
0037 Bool_t fPercent;
0038 Bool_t fDrawBar;
0039 TGGC fBarColorGC;
0040 GContext_t fNormGC;
0041 FontStruct_t fFontStruct;
0042
0043 void DoRedraw() override = 0;
0044
0045 static const TGFont *fgDefaultFont;
0046 static TGGC *fgDefaultGC;
0047
0048 public:
0049 static FontStruct_t GetDefaultFontStruct();
0050 static const TGGC &GetDefaultGC();
0051
0052 TGProgressBar(const TGWindow *p, UInt_t w, UInt_t h,
0053 Pixel_t back = GetWhitePixel(),
0054 Pixel_t barcolor = GetDefaultSelectedBackground(),
0055 GContext_t norm = GetDefaultGC()(),
0056 FontStruct_t font = GetDefaultFontStruct(),
0057 UInt_t options = kDoubleBorder | kSunkenFrame);
0058 ~TGProgressBar() override { }
0059
0060 Float_t GetMin() const { return fMin; }
0061 Float_t GetMax() const { return fMax; }
0062 Float_t GetPosition() const { return fPos; }
0063 EFillType GetFillType() const { return fFillType; }
0064 EBarType GetBarType() const { return fBarType; }
0065 Bool_t GetShowPos() const { return fShowPos; }
0066 TString GetFormat() const { return fFormat; }
0067 const char* GetValueFormat() const { return fFormat.Data(); }
0068 Bool_t UsePercent() const { return fPercent; }
0069 Pixel_t GetBarColor() const { return fBarColorGC.GetForeground(); }
0070 GContext_t GetNormGC() const { return fNormGC; }
0071 FontStruct_t GetFontStruct() const { return fFontStruct; }
0072
0073 void SetPosition(Float_t pos);
0074 void SetRange(Float_t min, Float_t max);
0075 void Increment(Float_t inc);
0076 void SetBarType(EBarType type);
0077 void SetFillType(EFillType type);
0078 virtual void Percent(Bool_t on) { fPercent = on; fClient->NeedRedraw(this); }
0079 virtual void ShowPos(Bool_t on) { fShowPos = on; fClient->NeedRedraw(this); }
0080 virtual void Format(const char *format = "%.2f");
0081 void SetMin(Float_t min) { fMin = min; }
0082 void SetMax(Float_t max) { fMax = max; }
0083 virtual void SetBarColor(Pixel_t color);
0084 void SetBarColor(const char *color="blue");
0085 virtual void Reset();
0086 void SetForegroundColor(Pixel_t pixel) override;
0087
0088 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0089
0090 ClassDefOverride(TGProgressBar,0)
0091 };
0092
0093
0094 class TGHProgressBar : public TGProgressBar {
0095
0096 protected:
0097 void DoRedraw() override;
0098
0099 public:
0100 TGHProgressBar(const TGWindow *p = nullptr,
0101 UInt_t w = 4, UInt_t h = kProgressBarTextWidth,
0102 Pixel_t back = GetWhitePixel(),
0103 Pixel_t barcolor = GetDefaultSelectedBackground(),
0104 GContext_t norm = GetDefaultGC()(),
0105 FontStruct_t font = GetDefaultFontStruct(),
0106 UInt_t options = kDoubleBorder | kSunkenFrame);
0107 TGHProgressBar(const TGWindow *p, EBarType type, UInt_t w);
0108 ~TGHProgressBar() override { }
0109
0110 TGDimension GetDefaultSize() const override
0111 { return TGDimension(fWidth, fBarWidth); }
0112
0113 void ShowPosition(Bool_t set = kTRUE, Bool_t percent = kTRUE,
0114 const char *format = "%.2f");
0115
0116 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0117
0118 ClassDefOverride(TGHProgressBar,0)
0119 };
0120
0121
0122 class TGVProgressBar : public TGProgressBar {
0123
0124 protected:
0125 void DoRedraw() override;
0126
0127 public:
0128 TGVProgressBar(const TGWindow *p = nullptr,
0129 UInt_t w = kProgressBarTextWidth, UInt_t h = 4,
0130 Pixel_t back = GetWhitePixel(),
0131 Pixel_t barcolor = GetDefaultSelectedBackground(),
0132 GContext_t norm = GetDefaultGC()(),
0133 FontStruct_t font = GetDefaultFontStruct(),
0134 UInt_t options = kDoubleBorder | kSunkenFrame);
0135 TGVProgressBar(const TGWindow *p, EBarType type, UInt_t h);
0136 ~TGVProgressBar() override { }
0137
0138 TGDimension GetDefaultSize() const override
0139 { return TGDimension(fBarWidth, fHeight); }
0140 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0141 void ShowPos(Bool_t) override { }
0142 void Percent(Bool_t) override { }
0143
0144 ClassDefOverride(TGVProgressBar,0)
0145 };
0146
0147 #endif
0148