ROOT  6.06/09
Reference Guide
TGProgressBar.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 10/10/2000
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGProgressBar
13 #define ROOT_TGProgressBar
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGProgressBar, TGHProgressBar and TGVProgressBar //
19 // //
20 // The classes in this file implement progress bars. Progress bars can //
21 // be used to show progress of tasks taking more then a few seconds. //
22 // TGProgressBar is an abstract base class, use either TGHProgressBar //
23 // or TGVProgressBar. TGHProgressBar can in addition show the position //
24 // as text in the bar. //
25 // //
26 //////////////////////////////////////////////////////////////////////////
27 
28 #ifndef ROOT_TGFrame
29 #include "TGFrame.h"
30 #endif
31 
32 
33 class TGProgressBar : public TGFrame {
34 
35 public:
39  kBlockSize = 8, kBlockSpace = 2 };
40 
41 protected:
42  Float_t fMin; // logical minimum value (default 0)
43  Float_t fMax; // logical maximum value (default 100)
44  Float_t fPos; // logical position [fMin,fMax]
45  Int_t fPosPix; // position of progress bar in pixel coordinates
46  Int_t fBarWidth; // progress bar width
47  EFillType fFillType; // *OPTION={GetMethod="GetFillType";SetMethod="SetFillType";Items=(kSolidFill=Solid",kBlockFill="Block")}*
48  EBarType fBarType; // *OPTION={GetMethod="GetBarType";SetMethod="SetBarType";Items=(kStandard="Standard",kFancy="Fancy")}*
49  TString fFormat; // format used to show position not in percent
50  Bool_t fShowPos; // show position value (default false)
51  Bool_t fPercent; // show position in percent (default true)
52  Bool_t fDrawBar; // if true draw only bar in DoRedraw()
53  TGGC fBarColorGC; // progress bar drawing context
54  GContext_t fNormGC; // text drawing graphics context
55  FontStruct_t fFontStruct; // font used to draw position text
56 
57  virtual void DoRedraw() = 0;
58 
59  static const TGFont *fgDefaultFont;
60  static TGGC *fgDefaultGC;
61 
62 public:
64  static const TGGC &GetDefaultGC();
65 
66  TGProgressBar(const TGWindow *p, UInt_t w, UInt_t h,
67  Pixel_t back = GetWhitePixel(),
71  UInt_t options = kDoubleBorder | kSunkenFrame);
72  virtual ~TGProgressBar() { }
73 
74  Float_t GetMin() const { return fMin; }
75  Float_t GetMax() const { return fMax; }
76  Float_t GetPosition() const { return fPos; }
77  EFillType GetFillType() const { return fFillType; }
78  EBarType GetBarType() const { return fBarType; }
79  Bool_t GetShowPos() const { return fShowPos; }
80  TString GetFormat() const { return fFormat; }
81  const char* GetValueFormat() const { return fFormat.Data(); }
82  Bool_t UsePercent() const { return fPercent; }
83  Pixel_t GetBarColor() const { return fBarColorGC.GetForeground(); }
84  GContext_t GetNormGC() const { return fNormGC; }
86 
87  void SetPosition(Float_t pos); //*MENU* *GETTER=GetPosition
88  void SetRange(Float_t min, Float_t max); //*MENU*
89  void Increment(Float_t inc);
90  void SetBarType(EBarType type); //*SUBMENU*
91  void SetFillType(EFillType type); //*SUBMENU*
92  virtual void Percent(Bool_t on) { fPercent = on; fClient->NeedRedraw(this); } //*TOGGLE* *GETTER=UsePercent
93  virtual void ShowPos(Bool_t on) { fShowPos = on; fClient->NeedRedraw(this); } //*TOGGLE* *GETTER=GetShowPos
94  virtual void Format(const char *format = "%.2f"); //*MENU* *GETTER=GetValueFormat
95  void SetMin(Float_t min) { fMin = min; }
96  void SetMax(Float_t max) { fMax = max; }
97  virtual void SetBarColor(Pixel_t color);
98  void SetBarColor(const char *color="blue");
99  virtual void Reset(); //*MENU*
100  virtual void SetForegroundColor(Pixel_t pixel);
101 
102  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
103 
104  ClassDef(TGProgressBar,0) // Progress bar abstract base class
105 };
106 
107 
109 
110 protected:
111  virtual void DoRedraw();
112 
113 public:
114  TGHProgressBar(const TGWindow *p = 0,
116  Pixel_t back = GetWhitePixel(),
120  UInt_t options = kDoubleBorder | kSunkenFrame);
122  virtual ~TGHProgressBar() { }
123 
124  virtual TGDimension GetDefaultSize() const
125  { return TGDimension(fWidth, fBarWidth); }
126 
127  void ShowPosition(Bool_t set = kTRUE, Bool_t percent = kTRUE,
128  const char *format = "%.2f");
129 
130  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
131 
132  ClassDef(TGHProgressBar,0) // Horizontal progress bar widget
133 };
134 
135 
137 
138 protected:
139  virtual void DoRedraw();
140 
141 public:
142  TGVProgressBar(const TGWindow *p = 0,
144  Pixel_t back = GetWhitePixel(),
148  UInt_t options = kDoubleBorder | kSunkenFrame);
150  virtual ~TGVProgressBar() { }
151 
152  virtual TGDimension GetDefaultSize() const
153  { return TGDimension(fBarWidth, fHeight); }
154  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
155  void ShowPos(Bool_t) { }
156  void Percent(Bool_t) { }
157 
158  ClassDef(TGVProgressBar,0) // Vertical progress bar widget
159 };
160 
161 #endif
162 
EBarType fBarType
Definition: TGProgressBar.h:48
EBarType GetBarType() const
Definition: TGProgressBar.h:78
virtual ~TGVProgressBar()
Float_t GetMin() const
Definition: TGProgressBar.h:74
Handle_t FontStruct_t
Definition: GuiTypes.h:40
static const TGGC & GetDefaultGC()
Return default graphics context in use.
EFillType GetFillType() const
Definition: TGProgressBar.h:77
TString fFormat
Definition: TGProgressBar.h:49
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
void Increment(Float_t inc)
Increment progress position.
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a vertical progress bar as a C++ statement(s) on output stream out.
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
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)
cconstructor
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
virtual ~TGHProgressBar()
static const TGFont * fgDefaultFont
Definition: TGProgressBar.h:59
virtual void DoRedraw()=0
Redraw the frame.
Handle_t GContext_t
Definition: GuiTypes.h:39
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
static std::string format(double x, double y, int digits, int width)
virtual void SetBarColor(Pixel_t color)
Set progress bar color.
const char * Data() const
Definition: TString.h:349
#define ClassDef(name, id)
Definition: Rtypes.h:254
ULong_t Pixel_t
Definition: GuiTypes.h:41
virtual void Percent(Bool_t on)
Definition: TGProgressBar.h:92
virtual void Format(const char *format="%.2f")
Set format for displaying a value.
const char * GetValueFormat() const
Definition: TGProgressBar.h:81
virtual void DoRedraw()
Draw horizontal progress bar.
Float_t GetMax() const
Definition: TGProgressBar.h:75
FontStruct_t GetFontStruct() const
Definition: TGProgressBar.h:85
char * out
Definition: TBase64.cxx:29
virtual void SetForegroundColor(Pixel_t pixel)
Change text color drawing.
Bool_t UsePercent() const
Definition: TGProgressBar.h:82
virtual void ShowPos(Bool_t on)
Definition: TGProgressBar.h:93
void SetBarType(EBarType type)
Set bar type.
void ShowPos(Bool_t)
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
GContext_t fNormGC
Definition: TGProgressBar.h:54
Pixel_t GetForeground() const
Definition: TGGC.h:86
void ShowPosition(Bool_t set=kTRUE, Bool_t percent=kTRUE, const char *format="%.2f")
Show postion text, either in percent or formatted according format.
virtual ~TGProgressBar()
Definition: TGProgressBar.h:72
UInt_t fWidth
Definition: TGFrame.h:150
Bool_t GetShowPos() const
Definition: TGProgressBar.h:79
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a horizontal progress bar as a C++ statement(s) on output stream out.
void SetRange(Float_t min, Float_t max)
Set min and max of progress bar.
void SetPosition(Float_t pos)
Set progress position between [min,max].
int type
Definition: TGX11.cxx:120
Definition: TGFont.h:155
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)
Horizontal progress bar constructor.
EFillType fFillType
Definition: TGProgressBar.h:47
UInt_t fHeight
Definition: TGFrame.h:151
GContext_t GetNormGC() const
Definition: TGProgressBar.h:84
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Definition: vector.h:440
virtual void Reset()
Reset progress bar (i.e. set pos to 0).
void SetMin(Float_t min)
Definition: TGProgressBar.h:95
Float_t GetPosition() const
Definition: TGProgressBar.h:76
TGClient * fClient
Definition: TGObject.h:41
static TGGC * fgDefaultGC
Definition: TGProgressBar.h:60
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save progress bar parameters as a C++ statement(s) on output stream out.
void Percent(Bool_t)
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:370
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 void DoRedraw()
Draw vertical progress bar.
TString GetFormat() const
Definition: TGProgressBar.h:80
void SetMax(Float_t max)
Definition: TGProgressBar.h:96
const Bool_t kTRUE
Definition: Rtypes.h:91
double norm(double *x, double *p)
Definition: unuranDistr.cxx:40
Definition: TGGC.h:35
void SetFillType(EFillType type)
Set fill type.
static Pixel_t GetDefaultSelectedBackground()
Get default selected frame background.
Definition: TGFrame.cxx:678
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
FontStruct_t fFontStruct
Definition: TGProgressBar.h:55
Pixel_t GetBarColor() const
Definition: TGProgressBar.h:83