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
19class TGProgressBar : public TGFrame {
20
21public:
26
27protected:
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() override = 0;
44
45 static const TGFont *fgDefaultFont;
47
48public:
50 static const TGGC &GetDefaultGC();
51
53 Pixel_t back = GetWhitePixel(),
55 GContext_t norm = GetDefaultGC()(),
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 void SetForegroundColor(Pixel_t pixel) override;
87
88 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
89
90 ClassDefOverride(TGProgressBar,0) // Progress bar abstract base class
91};
92
93
95
96protected:
97 void DoRedraw() override;
98
99public:
100 TGHProgressBar(const TGWindow *p = nullptr,
102 Pixel_t back = GetWhitePixel(),
104 GContext_t norm = GetDefaultGC()(),
106 UInt_t options = kDoubleBorder | kSunkenFrame);
108 virtual ~TGHProgressBar() { }
109
111 { return TGDimension(fWidth, fBarWidth); }
112
114 const char *format = "%.2f");
115
116 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
117
118 ClassDefOverride(TGHProgressBar,0) // Horizontal progress bar widget
119};
120
121
123
124protected:
125 void DoRedraw() override;
126
127public:
128 TGVProgressBar(const TGWindow *p = nullptr,
130 Pixel_t back = GetWhitePixel(),
132 GContext_t norm = GetDefaultGC()(),
134 UInt_t options = kDoubleBorder | kSunkenFrame);
136 virtual ~TGVProgressBar() { }
137
139 { return TGDimension(fBarWidth, fHeight); }
140 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
141 void ShowPos(Bool_t) override { }
142 void Percent(Bool_t) override { }
143
144 ClassDefOverride(TGVProgressBar,0) // Vertical progress bar widget
145};
146
147#endif
148
Handle_t GContext_t
Graphics context handle.
Definition: GuiTypes.h:38
@ kSunkenFrame
Definition: GuiTypes.h:383
@ kDoubleBorder
Definition: GuiTypes.h:385
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
Handle_t FontStruct_t
Pointer to font structure.
Definition: GuiTypes.h:39
#define h(i)
Definition: RSha256.hxx:106
bool Bool_t
Definition: RtypesCore.h:63
float Float_t
Definition: RtypesCore.h:57
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void pixel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
Option_t Option_t TPoint TPoint percent
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:372
Encapsulate fonts used in the GUI system.
Definition: TGFont.h:140
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition: TGFrame.h:80
static Pixel_t GetDefaultSelectedBackground()
Get default selected frame background.
Definition: TGFrame.cxx:696
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:709
UInt_t fHeight
frame height
Definition: TGFrame.h:88
UInt_t fWidth
frame width
Definition: TGFrame.h:87
Encapsulate a graphics context used in the low level graphics.
Definition: TGGC.h:22
Pixel_t GetForeground() const
Definition: TGGC.h:73
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.
void DoRedraw() override
Draw horizontal progress bar.
TGHProgressBar(const TGWindow *p=nullptr, 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.
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a horizontal progress bar as a C++ statement(s) on output stream out.
TGClient * fClient
Connection to display server.
Definition: TGObject.h:25
The classes in this file implement progress bars.
Definition: TGProgressBar.h:19
static const TGFont * fgDefaultFont
Definition: TGProgressBar.h:45
Bool_t fPercent
show position in percent (default true)
Definition: TGProgressBar.h:37
void Increment(Float_t inc)
Increment progress position.
Float_t GetMin() const
Definition: TGProgressBar.h:60
TString fFormat
format used to show position not in percent
Definition: TGProgressBar.h:35
void SetForegroundColor(Pixel_t pixel) override
Change text color drawing.
Pixel_t GetBarColor() const
Definition: TGProgressBar.h:69
static TGGC * fgDefaultGC
Definition: TGProgressBar.h:46
EBarType fBarType
OPTION={GetMethod="GetBarType";SetMethod="SetBarType";Items=(kStandard="Standard",...
Definition: TGProgressBar.h:34
static const TGGC & GetDefaultGC()
Return default graphics context in use.
Float_t fPos
logical position [fMin,fMax]
Definition: TGProgressBar.h:30
Bool_t UsePercent() const
Definition: TGProgressBar.h:68
virtual void DoRedraw() override=0
Redraw the frame.
Float_t fMax
logical maximum value (default 100)
Definition: TGProgressBar.h:29
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.
GContext_t fNormGC
text drawing graphics context
Definition: TGProgressBar.h:40
Int_t fBarWidth
progress bar width
Definition: TGProgressBar.h:32
FontStruct_t fFontStruct
font used to draw position text
Definition: TGProgressBar.h:41
FontStruct_t GetFontStruct() const
Definition: TGProgressBar.h:71
void SetPosition(Float_t pos)
Set progress position between [min,max].
Bool_t fDrawBar
if true draw only bar in DoRedraw()
Definition: TGProgressBar.h:38
Bool_t GetShowPos() const
Definition: TGProgressBar.h:65
TString GetFormat() const
Definition: TGProgressBar.h:66
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
Float_t fMin
logical minimum value (default 0)
Definition: TGProgressBar.h:28
TGGC fBarColorGC
progress bar drawing context
Definition: TGProgressBar.h:39
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:81
virtual ~TGProgressBar()
Definition: TGProgressBar.h:58
Float_t GetPosition() const
Definition: TGProgressBar.h:62
virtual void SetBarColor(Pixel_t color)
Set progress bar color.
void SetMax(Float_t max)
Definition: TGProgressBar.h:82
void SetBarType(EBarType type)
Set bar type.
EBarType GetBarType() const
Definition: TGProgressBar.h:64
GContext_t GetNormGC() const
Definition: TGProgressBar.h:70
const char * GetValueFormat() const
Definition: TGProgressBar.h:67
virtual void Percent(Bool_t on)
Definition: TGProgressBar.h:78
Float_t GetMax() const
Definition: TGProgressBar.h:61
@ kProgressBarStandardWidth
Definition: TGProgressBar.h:24
void SetRange(Float_t min, Float_t max)
Set min and max of progress bar.
EFillType GetFillType() const
Definition: TGProgressBar.h:63
Int_t fPosPix
position of progress bar in pixel coordinates
Definition: TGProgressBar.h:31
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save progress bar parameters as a C++ statement(s) on output stream out.
EFillType fFillType
OPTION={GetMethod="GetFillType";SetMethod="SetFillType";Items=(kSolidFill=Solid",kBlockFill="Block")}
Definition: TGProgressBar.h:33
virtual void ShowPos(Bool_t on)
Definition: TGProgressBar.h:79
Bool_t fShowPos
show position value (default false)
Definition: TGProgressBar.h:36
virtual void Reset()
Reset progress bar (i.e. set pos to 0).
void DoRedraw() override
Draw vertical progress bar.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a vertical progress bar as a C++ statement(s) on output stream out.
void Percent(Bool_t) override
void ShowPos(Bool_t) override
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
virtual ~TGVProgressBar()
TGVProgressBar(const TGWindow *p=nullptr, 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.
ROOT GUI Window base class.
Definition: TGWindow.h:23
Basic string class.
Definition: TString.h:136
const char * Data() const
Definition: TString.h:369