Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
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.
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.
static const TGFont * fgDefaultFont
Bool_t fPercent
show position in percent (default true)
void Increment(Float_t inc)
Increment progress position.
Float_t GetMin() const
TString fFormat
format used to show position not in percent
void SetForegroundColor(Pixel_t pixel) override
Change text color drawing.
Pixel_t GetBarColor() const
static TGGC * fgDefaultGC
EBarType fBarType
OPTION={GetMethod="GetBarType";SetMethod="SetBarType";Items=(kStandard="Standard",...
static const TGGC & GetDefaultGC()
Return default graphics context in use.
Float_t fPos
logical position [fMin,fMax]
Bool_t UsePercent() const
virtual void DoRedraw() override=0
Redraw the frame.
Float_t fMax
logical maximum value (default 100)
GContext_t fNormGC
text drawing graphics context
Int_t fBarWidth
progress bar width
FontStruct_t fFontStruct
font used to draw position text
FontStruct_t GetFontStruct() const
void SetPosition(Float_t pos)
Set progress position between [min,max].
Bool_t fDrawBar
if true draw only bar in DoRedraw()
Bool_t GetShowPos() const
TString GetFormat() const
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
Float_t fMin
logical minimum value (default 0)
TGGC fBarColorGC
progress bar drawing context
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)
virtual ~TGProgressBar()
Float_t GetPosition() const
virtual void SetBarColor(Pixel_t color)
Set progress bar color.
void SetMax(Float_t max)
void SetBarType(EBarType type)
Set bar type.
EBarType GetBarType() const
GContext_t GetNormGC() const
const char * GetValueFormat() const
virtual void Percent(Bool_t on)
Float_t GetMax() const
void SetRange(Float_t min, Float_t max)
Set min and max of progress bar.
EFillType GetFillType() const
Int_t fPosPix
position of progress bar in pixel coordinates
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")}
virtual void ShowPos(Bool_t on)
Bool_t fShowPos
show position value (default false)
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()
ROOT GUI Window base class.
Definition TGWindow.h:23
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:380