Logo ROOT  
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 #include "TGFrame.h"
17 
18 
19 class TGProgressBar : public TGFrame {
20 
21 public:
25  kBlockSize = 8, kBlockSpace = 2 };
26 
27 protected:
28  Float_t fMin; ///< logical minimum value (default 0)
29  Float_t fMax; ///< logical maximum value (default 100)
30  Float_t fPos; ///< logical position [fMin,fMax]
31  Int_t fPosPix; ///< position of progress bar in pixel coordinates
32  Int_t fBarWidth; ///< progress bar width
33  EFillType fFillType; ///< *OPTION={GetMethod="GetFillType";SetMethod="SetFillType";Items=(kSolidFill=Solid",kBlockFill="Block")}*
34  EBarType fBarType; ///< *OPTION={GetMethod="GetBarType";SetMethod="SetBarType";Items=(kStandard="Standard",kFancy="Fancy")}*
35  TString fFormat; ///< format used to show position not in percent
36  Bool_t fShowPos; ///< show position value (default false)
37  Bool_t fPercent; ///< show position in percent (default true)
38  Bool_t fDrawBar; ///< if true draw only bar in DoRedraw()
39  TGGC fBarColorGC; ///< progress bar drawing context
40  GContext_t fNormGC; ///< text drawing graphics context
41  FontStruct_t fFontStruct; ///< font used to draw position text
42 
43  virtual void DoRedraw() = 0;
44 
45  static const TGFont *fgDefaultFont;
46  static TGGC *fgDefaultGC;
47 
48 public:
50  static const TGGC &GetDefaultGC();
51 
52  TGProgressBar(const TGWindow *p, UInt_t w, UInt_t h,
53  Pixel_t back = GetWhitePixel(),
55  GContext_t norm = GetDefaultGC()(),
57  UInt_t options = kDoubleBorder | kSunkenFrame);
58  virtual ~TGProgressBar() { }
59 
60  Float_t GetMin() const { return fMin; }
61  Float_t GetMax() const { return fMax; }
62  Float_t GetPosition() const { return fPos; }
63  EFillType GetFillType() const { return fFillType; }
64  EBarType GetBarType() const { return fBarType; }
65  Bool_t GetShowPos() const { return fShowPos; }
66  TString GetFormat() const { return fFormat; }
67  const char* GetValueFormat() const { return fFormat.Data(); }
68  Bool_t UsePercent() const { return fPercent; }
70  GContext_t GetNormGC() const { return fNormGC; }
72 
73  void SetPosition(Float_t pos); //*MENU* *GETTER=GetPosition
74  void SetRange(Float_t min, Float_t max); //*MENU*
75  void Increment(Float_t inc);
76  void SetBarType(EBarType type); //*SUBMENU*
77  void SetFillType(EFillType type); //*SUBMENU*
78  virtual void Percent(Bool_t on) { fPercent = on; fClient->NeedRedraw(this); } //*TOGGLE* *GETTER=UsePercent
79  virtual void ShowPos(Bool_t on) { fShowPos = on; fClient->NeedRedraw(this); } //*TOGGLE* *GETTER=GetShowPos
80  virtual void Format(const char *format = "%.2f"); //*MENU* *GETTER=GetValueFormat
81  void SetMin(Float_t min) { fMin = min; }
82  void SetMax(Float_t max) { fMax = max; }
83  virtual void SetBarColor(Pixel_t color);
84  void SetBarColor(const char *color="blue");
85  virtual void Reset(); //*MENU*
86  virtual void SetForegroundColor(Pixel_t pixel);
87 
88  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
89 
90  ClassDef(TGProgressBar,0) // Progress bar abstract base class
91 };
92 
93 
94 class TGHProgressBar : public TGProgressBar {
95 
96 protected:
97  virtual void DoRedraw();
98 
99 public:
100  TGHProgressBar(const TGWindow *p = 0,
102  Pixel_t back = GetWhitePixel(),
104  GContext_t norm = GetDefaultGC()(),
106  UInt_t options = kDoubleBorder | kSunkenFrame);
108  virtual ~TGHProgressBar() { }
109 
110  virtual TGDimension GetDefaultSize() const
111  { return TGDimension(fWidth, fBarWidth); }
112 
113  void ShowPosition(Bool_t set = kTRUE, Bool_t percent = kTRUE,
114  const char *format = "%.2f");
115 
116  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
117 
118  ClassDef(TGHProgressBar,0) // Horizontal progress bar widget
119 };
120 
121 
123 
124 protected:
125  virtual void DoRedraw();
126 
127 public:
128  TGVProgressBar(const TGWindow *p = 0,
130  Pixel_t back = GetWhitePixel(),
132  GContext_t norm = GetDefaultGC()(),
134  UInt_t options = kDoubleBorder | kSunkenFrame);
136  virtual ~TGVProgressBar() { }
137 
138  virtual TGDimension GetDefaultSize() const
139  { return TGDimension(fBarWidth, fHeight); }
140  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
141  void ShowPos(Bool_t) { }
142  void Percent(Bool_t) { }
143 
144  ClassDef(TGVProgressBar,0) // Vertical progress bar widget
145 };
146 
147 #endif
148 
TGHProgressBar::TGHProgressBar
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.
Definition: TGProgressBar.cxx:223
TGProgressBar::fFillType
EFillType fFillType
OPTION={GetMethod="GetFillType";SetMethod="SetFillType";Items=(kSolidFill=Solid",kBlockFill="Block")}
Definition: TGProgressBar.h:33
TGProgressBar::ShowPos
virtual void ShowPos(Bool_t on)
Definition: TGProgressBar.h:79
TGHProgressBar::GetDefaultSize
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGProgressBar.h:110
TGProgressBar::GetDefaultFontStruct
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
Definition: TGProgressBar.cxx:187
TGWindow
ROOT GUI Window base class.
Definition: TGWindow.h:23
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
TGProgressBar::Reset
virtual void Reset()
Reset progress bar (i.e. set pos to 0).
Definition: TGProgressBar.cxx:126
TGProgressBar::SetPosition
void SetPosition(Float_t pos)
Set progress position between [min,max].
Definition: TGProgressBar.cxx:92
TGGC::GetForeground
Pixel_t GetForeground() const
Definition: TGGC.h:73
TGDimension
Definition: TGDimension.h:18
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGProgressBar::fgDefaultFont
static const TGFont * fgDefaultFont
Definition: TGProgressBar.h:45
TGProgressBar::kProgressBarTextWidth
@ kProgressBarTextWidth
Definition: TGProgressBar.h:24
TString::Data
const char * Data() const
Definition: TString.h:369
TGProgressBar::GetMin
Float_t GetMin() const
Definition: TGProgressBar.h:60
Pixel_t
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
TGProgressBar::kSolidFill
@ kSolidFill
Definition: TGProgressBar.h:23
TGFrame::fWidth
UInt_t fWidth
frame width
Definition: TGFrame.h:87
FontStruct_t
Handle_t FontStruct_t
Pointer to font structure.
Definition: GuiTypes.h:39
TGVProgressBar::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a vertical progress bar as a C++ statement(s) on output stream out.
Definition: TGProgressBar.cxx:438
TGProgressBar::fPercent
Bool_t fPercent
show position in percent (default true)
Definition: TGProgressBar.h:37
Float_t
float Float_t
Definition: RtypesCore.h:57
TGProgressBar::fPos
Float_t fPos
logical position [fMin,fMax]
Definition: TGProgressBar.h:30
TGVProgressBar
Definition: TGProgressBar.h:122
TGVProgressBar::~TGVProgressBar
virtual ~TGVProgressBar()
Definition: TGProgressBar.h:136
TGProgressBar::SetRange
void SetRange(Float_t min, Float_t max)
Set min and max of progress bar.
Definition: TGProgressBar.cxx:66
TGProgressBar::GetFormat
TString GetFormat() const
Definition: TGProgressBar.h:66
TGProgressBar::kBlockFill
@ kBlockFill
Definition: TGProgressBar.h:23
TGProgressBar::EFillType
EFillType
Definition: TGProgressBar.h:23
TString
Basic string class.
Definition: TString.h:136
TGFrame
Definition: TGFrame.h:80
TGProgressBar::fBarType
EBarType fBarType
OPTION={GetMethod="GetBarType";SetMethod="SetBarType";Items=(kStandard="Standard",...
Definition: TGProgressBar.h:34
TGProgressBar::GetMax
Float_t GetMax() const
Definition: TGProgressBar.h:61
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
kDoubleBorder
@ kDoubleBorder
Definition: GuiTypes.h:385
TGProgressBar::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save progress bar parameters as a C++ statement(s) on output stream out.
Definition: TGProgressBar.cxx:396
bool
TGHProgressBar::~TGHProgressBar
virtual ~TGHProgressBar()
Definition: TGProgressBar.h:108
GContext_t
Handle_t GContext_t
Graphics context handle.
Definition: GuiTypes.h:38
TGProgressBar::fgDefaultGC
static TGGC * fgDefaultGC
Definition: TGProgressBar.h:46
TGProgressBar::UsePercent
Bool_t UsePercent() const
Definition: TGProgressBar.h:68
TGVProgressBar::GetDefaultSize
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGProgressBar.h:138
TGProgressBar::Format
virtual void Format(const char *format="%.2f")
Set format for displaying a value.
Definition: TGProgressBar.cxx:177
kSunkenFrame
@ kSunkenFrame
Definition: GuiTypes.h:383
TGHProgressBar
Definition: TGProgressBar.h:94
TGProgressBar::kStandard
@ kStandard
Definition: TGProgressBar.h:22
TGProgressBar::SetFillType
void SetFillType(EFillType type)
Set fill type.
Definition: TGProgressBar.cxx:136
TGProgressBar::Percent
virtual void Percent(Bool_t on)
Definition: TGProgressBar.h:78
TGProgressBar::fFormat
TString fFormat
format used to show position not in percent
Definition: TGProgressBar.h:35
TGProgressBar::GetBarType
EBarType GetBarType() const
Definition: TGProgressBar.h:64
h
#define h(i)
Definition: RSha256.hxx:106
TGGC
Encapsulate a graphics context used in the low level graphics.
Definition: TGGC.h:22
TGProgressBar::GetBarColor
Pixel_t GetBarColor() const
Definition: TGProgressBar.h:69
TGProgressBar::kFancy
@ kFancy
Definition: TGProgressBar.h:22
TGProgressBar::GetDefaultGC
static const TGGC & GetDefaultGC()
Return default graphics context in use.
Definition: TGProgressBar.cxx:197
TGProgressBar::fMax
Float_t fMax
logical maximum value (default 100)
Definition: TGProgressBar.h:29
TGFrame.h
TGProgressBar::GetFillType
EFillType GetFillType() const
Definition: TGProgressBar.h:63
TGProgressBar::~TGProgressBar
virtual ~TGProgressBar()
Definition: TGProgressBar.h:58
TGProgressBar::GetFontStruct
FontStruct_t GetFontStruct() const
Definition: TGProgressBar.h:71
TGProgressBar::SetMax
void SetMax(Float_t max)
Definition: TGProgressBar.h:82
TGVProgressBar::DoRedraw
virtual void DoRedraw()
Draw vertical progress bar.
Definition: TGProgressBar.cxx:359
TGProgressBar::fShowPos
Bool_t fShowPos
show position value (default false)
Definition: TGProgressBar.h:36
TGProgressBar::GetPosition
Float_t GetPosition() const
Definition: TGProgressBar.h:62
TGProgressBar::fFontStruct
FontStruct_t fFontStruct
font used to draw position text
Definition: TGProgressBar.h:41
TGVProgressBar::Percent
void Percent(Bool_t)
Definition: TGProgressBar.h:142
TGHProgressBar::DoRedraw
virtual void DoRedraw()
Draw horizontal progress bar.
Definition: TGProgressBar.cxx:265
unsigned int
TGVProgressBar::ShowPos
void ShowPos(Bool_t)
Definition: TGProgressBar.h:141
TGHProgressBar::ShowPosition
void ShowPosition(Bool_t set=kTRUE, Bool_t percent=kTRUE, const char *format="%.2f")
Show postion text, either in percent or formatted according format.
Definition: TGProgressBar.cxx:253
TGProgressBar::SetBarType
void SetBarType(EBarType type)
Set bar type.
Definition: TGProgressBar.cxx:146
TGProgressBar::fNormGC
GContext_t fNormGC
text drawing graphics context
Definition: TGProgressBar.h:40
TGClient::NeedRedraw
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:374
TGProgressBar::fPosPix
Int_t fPosPix
position of progress bar in pixel coordinates
Definition: TGProgressBar.h:31
TGProgressBar
The classes in this file implement progress bars.
Definition: TGProgressBar.h:19
TGHProgressBar::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a horizontal progress bar as a C++ statement(s) on output stream out.
Definition: TGProgressBar.cxx:464
TGObject::fClient
TGClient * fClient
Connection to display server.
Definition: TGObject.h:27
TGProgressBar::kProgressBarStandardWidth
@ kProgressBarStandardWidth
Definition: TGProgressBar.h:24
TGProgressBar::TGProgressBar
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)
Create progress bar.
Definition: TGProgressBar.cxx:42
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGProgressBar::fMin
Float_t fMin
logical minimum value (default 0)
Definition: TGProgressBar.h:28
TGProgressBar::fBarColorGC
TGGC fBarColorGC
progress bar drawing context
Definition: TGProgressBar.h:39
TGProgressBar::fDrawBar
Bool_t fDrawBar
if true draw only bar in DoRedraw()
Definition: TGProgressBar.h:38
TGFrame::GetWhitePixel
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:709
TGFrame::GetDefaultSelectedBackground
static Pixel_t GetDefaultSelectedBackground()
Get default selected frame background.
Definition: TGFrame.cxx:696
TGProgressBar::fBarWidth
Int_t fBarWidth
progress bar width
Definition: TGProgressBar.h:32
TGProgressBar::GetShowPos
Bool_t GetShowPos() const
Definition: TGProgressBar.h:65
TGFrame::fHeight
UInt_t fHeight
frame height
Definition: TGFrame.h:88
TGVProgressBar::TGVProgressBar
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)
Constructor.
Definition: TGProgressBar.cxx:328
TGProgressBar::kBlockSize
@ kBlockSize
Definition: TGProgressBar.h:25
type
int type
Definition: TGX11.cxx:121
TGFont
Encapsulate fonts used in the GUI system.
Definition: TGFont.h:140
TGProgressBar::DoRedraw
virtual void DoRedraw()=0
Redraw the frame.
TGProgressBar::SetForegroundColor
virtual void SetForegroundColor(Pixel_t pixel)
Change text color drawing.
Definition: TGProgressBar.cxx:207
TGProgressBar::Increment
void Increment(Float_t inc)
Increment progress position.
Definition: TGProgressBar.cxx:110
TGProgressBar::SetBarColor
virtual void SetBarColor(Pixel_t color)
Set progress bar color.
Definition: TGProgressBar.cxx:156
TGProgressBar::kBlockSpace
@ kBlockSpace
Definition: TGProgressBar.h:25
TGProgressBar::GetNormGC
GContext_t GetNormGC() const
Definition: TGProgressBar.h:70
TGProgressBar::GetValueFormat
const char * GetValueFormat() const
Definition: TGProgressBar.h:67
TGProgressBar::EBarType
EBarType
Definition: TGProgressBar.h:22
TGProgressBar::SetMin
void SetMin(Float_t min)
Definition: TGProgressBar.h:81
int