Logo ROOT   6.16/01
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#include "TGFrame.h"
29
30
31class TGProgressBar : public TGFrame {
32
33public:
38
39protected:
40 Float_t fMin; // logical minimum value (default 0)
41 Float_t fMax; // logical maximum value (default 100)
42 Float_t fPos; // logical position [fMin,fMax]
43 Int_t fPosPix; // position of progress bar in pixel coordinates
44 Int_t fBarWidth; // progress bar width
45 EFillType fFillType; // *OPTION={GetMethod="GetFillType";SetMethod="SetFillType";Items=(kSolidFill=Solid",kBlockFill="Block")}*
46 EBarType fBarType; // *OPTION={GetMethod="GetBarType";SetMethod="SetBarType";Items=(kStandard="Standard",kFancy="Fancy")}*
47 TString fFormat; // format used to show position not in percent
48 Bool_t fShowPos; // show position value (default false)
49 Bool_t fPercent; // show position in percent (default true)
50 Bool_t fDrawBar; // if true draw only bar in DoRedraw()
51 TGGC fBarColorGC; // progress bar drawing context
52 GContext_t fNormGC; // text drawing graphics context
53 FontStruct_t fFontStruct; // font used to draw position text
54
55 virtual void DoRedraw() = 0;
56
57 static const TGFont *fgDefaultFont;
59
60public:
62 static const TGGC &GetDefaultGC();
63
65 Pixel_t back = GetWhitePixel(),
67 GContext_t norm = GetDefaultGC()(),
70 virtual ~TGProgressBar() { }
71
72 Float_t GetMin() const { return fMin; }
73 Float_t GetMax() const { return fMax; }
74 Float_t GetPosition() const { return fPos; }
75 EFillType GetFillType() const { return fFillType; }
76 EBarType GetBarType() const { return fBarType; }
77 Bool_t GetShowPos() const { return fShowPos; }
78 TString GetFormat() const { return fFormat; }
79 const char* GetValueFormat() const { return fFormat.Data(); }
80 Bool_t UsePercent() const { return fPercent; }
82 GContext_t GetNormGC() const { return fNormGC; }
84
85 void SetPosition(Float_t pos); //*MENU* *GETTER=GetPosition
86 void SetRange(Float_t min, Float_t max); //*MENU*
87 void Increment(Float_t inc);
88 void SetBarType(EBarType type); //*SUBMENU*
89 void SetFillType(EFillType type); //*SUBMENU*
90 virtual void Percent(Bool_t on) { fPercent = on; fClient->NeedRedraw(this); } //*TOGGLE* *GETTER=UsePercent
91 virtual void ShowPos(Bool_t on) { fShowPos = on; fClient->NeedRedraw(this); } //*TOGGLE* *GETTER=GetShowPos
92 virtual void Format(const char *format = "%.2f"); //*MENU* *GETTER=GetValueFormat
93 void SetMin(Float_t min) { fMin = min; }
94 void SetMax(Float_t max) { fMax = max; }
95 virtual void SetBarColor(Pixel_t color);
96 void SetBarColor(const char *color="blue");
97 virtual void Reset(); //*MENU*
98 virtual void SetForegroundColor(Pixel_t pixel);
99
100 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
101
102 ClassDef(TGProgressBar,0) // Progress bar abstract base class
103};
104
105
107
108protected:
109 virtual void DoRedraw();
110
111public:
112 TGHProgressBar(const TGWindow *p = 0,
114 Pixel_t back = GetWhitePixel(),
116 GContext_t norm = GetDefaultGC()(),
118 UInt_t options = kDoubleBorder | kSunkenFrame);
120 virtual ~TGHProgressBar() { }
121
123 { return TGDimension(fWidth, fBarWidth); }
124
125 void ShowPosition(Bool_t set = kTRUE, Bool_t percent = kTRUE,
126 const char *format = "%.2f");
127
128 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
129
130 ClassDef(TGHProgressBar,0) // Horizontal progress bar widget
131};
132
133
135
136protected:
137 virtual void DoRedraw();
138
139public:
140 TGVProgressBar(const TGWindow *p = 0,
142 Pixel_t back = GetWhitePixel(),
144 GContext_t norm = GetDefaultGC()(),
146 UInt_t options = kDoubleBorder | kSunkenFrame);
148 virtual ~TGVProgressBar() { }
149
151 { return TGDimension(fBarWidth, fHeight); }
152 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
153 void ShowPos(Bool_t) { }
154 void Percent(Bool_t) { }
155
156 ClassDef(TGVProgressBar,0) // Vertical progress bar widget
157};
158
159#endif
160
Handle_t GContext_t
Definition: GuiTypes.h:37
Handle_t FontStruct_t
Definition: GuiTypes.h:38
ULong_t Pixel_t
Definition: GuiTypes.h:39
#define h(i)
Definition: RSha256.hxx:106
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
bool Bool_t
Definition: RtypesCore.h:59
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:324
@ kSunkenFrame
Definition: TGFrame.h:61
@ kDoubleBorder
Definition: TGFrame.h:63
int type
Definition: TGX11.cxx:120
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:372
Definition: TGFont.h:149
static Pixel_t GetDefaultSelectedBackground()
Get default selected frame background.
Definition: TGFrame.cxx:678
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
UInt_t fHeight
Definition: TGFrame.h:135
UInt_t fWidth
Definition: TGFrame.h:134
Definition: TGGC.h:31
Pixel_t GetForeground() const
Definition: TGGC.h:82
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.
virtual void DoRedraw()
Draw horizontal progress bar.
virtual ~TGHProgressBar()
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 TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a horizontal progress bar as a C++ statement(s) on output stream out.
TGClient * fClient
Definition: TGObject.h:37
static const TGFont * fgDefaultFont
Definition: TGProgressBar.h:57
void Increment(Float_t inc)
Increment progress position.
Float_t GetMin() const
Definition: TGProgressBar.h:72
TString fFormat
Definition: TGProgressBar.h:47
Pixel_t GetBarColor() const
Definition: TGProgressBar.h:81
static TGGC * fgDefaultGC
Definition: TGProgressBar.h:58
virtual void DoRedraw()=0
Redraw the frame.
EBarType fBarType
Definition: TGProgressBar.h:46
static const TGGC & GetDefaultGC()
Return default graphics context in use.
Bool_t UsePercent() const
Definition: TGProgressBar.h:80
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.
virtual void SetForegroundColor(Pixel_t pixel)
Change text color drawing.
GContext_t fNormGC
Definition: TGProgressBar.h:52
FontStruct_t fFontStruct
Definition: TGProgressBar.h:53
FontStruct_t GetFontStruct() const
Definition: TGProgressBar.h:83
void SetPosition(Float_t pos)
Set progress position between [min,max].
Bool_t GetShowPos() const
Definition: TGProgressBar.h:77
TString GetFormat() const
Definition: TGProgressBar.h:78
@ kProgressBarStandardWidth
Definition: TGProgressBar.h:36
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
virtual void Format(const char *format="%.2f")
Set format for displaying a value.
void SetFillType(EFillType type)
Set fill type.
void SetMin(Float_t min)
Definition: TGProgressBar.h:93
virtual ~TGProgressBar()
Definition: TGProgressBar.h:70
Float_t GetPosition() const
Definition: TGProgressBar.h:74
virtual void SetBarColor(Pixel_t color)
Set progress bar color.
void SetMax(Float_t max)
Definition: TGProgressBar.h:94
void SetBarType(EBarType type)
Set bar type.
EBarType GetBarType() const
Definition: TGProgressBar.h:76
GContext_t GetNormGC() const
Definition: TGProgressBar.h:82
const char * GetValueFormat() const
Definition: TGProgressBar.h:79
virtual void Percent(Bool_t on)
Definition: TGProgressBar.h:90
Float_t GetMax() const
Definition: TGProgressBar.h:73
void SetRange(Float_t min, Float_t max)
Set min and max of progress bar.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save progress bar parameters as a C++ statement(s) on output stream out.
EFillType GetFillType() const
Definition: TGProgressBar.h:75
EFillType fFillType
Definition: TGProgressBar.h:45
virtual void ShowPos(Bool_t on)
Definition: TGProgressBar.h:91
virtual void Reset()
Reset progress bar (i.e. set pos to 0).
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
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
virtual void DoRedraw()
Draw vertical progress bar.
virtual ~TGVProgressBar()
void ShowPos(Bool_t)
void Percent(Bool_t)
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a vertical progress bar as a C++ statement(s) on output stream out.
Basic string class.
Definition: TString.h:131
const char * Data() const
Definition: TString.h:364