Logo ROOT  
Reference Guide
TGLabel.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 06/01/98
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_TGLabel
13 #define ROOT_TGLabel
14 
15 
16 #include "TGFrame.h"
17 #include "TGDimension.h"
18 #include "TGString.h"
19 
20 class TColor;
21 class TGTextLayout;
22 class TGFont;
23 
24 class TGLabel : public TGFrame {
25 
26 protected:
27  TGString *fText; ///< label text
28  UInt_t fTWidth; ///< text width
29  UInt_t fTHeight; ///< text height
30  Int_t fMLeft; ///< margin left
31  Int_t fMRight; ///< margin right
32  Int_t fMTop; ///< margin top
33  Int_t fMBottom; ///< margin bottom
34  Int_t fTMode; ///< text alignment
35  Int_t f3DStyle; ///< 3D style (0 - normal, kRaisedFrame - raised, kSunkenFrame - sunken)
36  Int_t fWrapLength; ///< wrap length
37  Int_t fTFlags; ///< text flags (see TGFont.h ETextLayoutFlags)
38  Bool_t fTextChanged; ///< has text changed
39  GContext_t fNormGC; ///< graphics context used for drawing label
40  TGFont *fFont; ///< font to draw label
41  TGTextLayout *fTLayout; ///< text layout
42  Bool_t fHasOwnFont; ///< kTRUE - font defined locally, kFALSE - globally
43  Bool_t fDisabled; ///< if kTRUE label looks disabled (shaded text)
44 
45  virtual void DoRedraw();
46  virtual void DrawText(GContext_t gc, Int_t x, Int_t y);
47 
48  static const TGFont *fgDefaultFont;
49  static const TGGC *fgDefaultGC;
50 
51 private:
52  TGLabel(const TGLabel&) = delete;
53  TGLabel& operator=(const TGLabel&) = delete;
54 
55 public:
57  static const TGGC &GetDefaultGC();
58 
59  TGLabel(const TGWindow *p, TGString *text,
60  GContext_t norm = GetDefaultGC()(),
62  UInt_t options = kChildFrame,
64  TGLabel(const TGWindow *p = nullptr, const char *text = nullptr,
65  GContext_t norm = GetDefaultGC()(),
67  UInt_t options = kChildFrame,
69 
70  virtual ~TGLabel();
71 
72  virtual TGDimension GetDefaultSize() const;
73 
74  const TGString *GetText() const { return fText; }
75  virtual const char *GetTitle() const { return fText->Data(); }
76  virtual void SetText(TGString *newText);
77  void SetText(const char *newText) { SetText(new TGString(newText)); }
78  virtual void ChangeText(const char *newText) { SetText(newText); } //*MENU*icon=bld_rename.png*
79  virtual void SetTitle(const char *label) { SetText(label); }
80  void SetText(Int_t number) { SetText(new TGString(number)); }
81  void SetTextJustify(Int_t tmode);
82  Int_t GetTextJustify() const { return fTMode; }
83  virtual void SetTextFont(TGFont *font, Bool_t global = kFALSE);
84  virtual void SetTextFont(FontStruct_t font, Bool_t global = kFALSE);
85  virtual void SetTextFont(const char *fontName, Bool_t global = kFALSE);
86  virtual void SetTextColor(Pixel_t color, Bool_t global = kFALSE);
87  virtual void SetTextColor(TColor *color, Bool_t global = kFALSE);
88  virtual void SetForegroundColor(Pixel_t fore) { SetTextColor(fore); }
89  virtual void Disable(Bool_t on = kTRUE)
90  { fDisabled = on; fClient->NeedRedraw(this); } //*TOGGLE* *GETTER=IsDisabled
91  virtual void Enable() { fDisabled = kFALSE; fClient->NeedRedraw(this); }
92  Bool_t IsDisabled() const { return fDisabled; }
93  Bool_t HasOwnFont() const;
94 
95  void SetWrapLength(Int_t wl) { fWrapLength = wl; Layout(); }
96  Int_t GetWrapLength() const { return fWrapLength; }
97 
99  Int_t Get3DStyle() const { return f3DStyle; }
100 
101  void SetMargins(Int_t left=0, Int_t right=0, Int_t top=0, Int_t bottom=0)
102  { fMLeft = left; fMRight = right; fMTop = top; fMBottom = bottom; }
103  Int_t GetLeftMargin() const { return fMLeft; }
104  Int_t GetRightMargin() const { return fMRight; }
105  Int_t GetTopMargin() const { return fMTop; }
106  Int_t GetBottomMargin() const { return fMBottom; }
107 
108  GContext_t GetNormGC() const { return fNormGC; }
110  TGFont *GetFont() const { return fFont; }
111 
112  virtual void Layout();
113  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
114 
115  ClassDef(TGLabel,0) // A label GUI element
116 };
117 
118 #endif
TGLabel::GetTopMargin
Int_t GetTopMargin() const
Definition: TGLabel.h:105
TGLabel::ChangeText
virtual void ChangeText(const char *newText)
Definition: TGLabel.h:78
TGWindow
ROOT GUI Window base class.
Definition: TGWindow.h:23
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
TGDimension
Definition: TGDimension.h:18
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGLabel::GetFont
TGFont * GetFont() const
Definition: TGLabel.h:110
TString::Data
const char * Data() const
Definition: TString.h:369
TGLabel::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a label widget as a C++ statement(s) on output stream out.
Definition: TGLabel.cxx:459
Pixel_t
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
TGLabel::Get3DStyle
Int_t Get3DStyle() const
Definition: TGLabel.h:99
TGLabel::fText
TGString * fText
label text
Definition: TGLabel.h:27
FontStruct_t
Handle_t FontStruct_t
Pointer to font structure.
Definition: GuiTypes.h:39
TGLabel::operator=
TGLabel & operator=(const TGLabel &)=delete
TGLabel
This class handles GUI labels.
Definition: TGLabel.h:24
TGLabel::SetWrapLength
void SetWrapLength(Int_t wl)
Definition: TGLabel.h:95
Int_t
int Int_t
Definition: RtypesCore.h:45
TGDimension.h
x
Double_t x[n]
Definition: legend1.C:17
TGLabel::GetDefaultFontStruct
static FontStruct_t GetDefaultFontStruct()
Static returning label default font struct.
Definition: TGLabel.cxx:525
TGLabel::SetTitle
virtual void SetTitle(const char *label)
Definition: TGLabel.h:79
TGFrame::GetDefaultFrameBackground
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:683
TGLabel::GetFontStruct
FontStruct_t GetFontStruct() const
Definition: TGLabel.h:109
TGLabel::GetRightMargin
Int_t GetRightMargin() const
Definition: TGLabel.h:104
TGFrame
Definition: TGFrame.h:80
TGLabel::fMBottom
Int_t fMBottom
margin bottom
Definition: TGLabel.h:33
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
text
TText * text
Definition: entrylist_figure1.C:10
TGLabel::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TGLabel.h:75
TGLabel::SetText
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:180
bool
TGLabel::fgDefaultFont
static const TGFont * fgDefaultFont
Definition: TGLabel.h:48
TGLabel::DoRedraw
virtual void DoRedraw()
Redraw label widget.
Definition: TGLabel.cxx:201
GContext_t
Handle_t GContext_t
Graphics context handle.
Definition: GuiTypes.h:38
TGLabel::fTLayout
TGTextLayout * fTLayout
text layout
Definition: TGLabel.h:41
style
TCanvas * style()
Definition: style.C:1
TGLabel::fMLeft
Int_t fMLeft
margin left
Definition: TGLabel.h:30
TGLabel::DrawText
virtual void DrawText(GContext_t gc, Int_t x, Int_t y)
Draw text at position (x, y).
Definition: TGLabel.cxx:192
TGLabel::TGLabel
TGLabel(const TGLabel &)=delete
TGLabel::SetText
void SetText(Int_t number)
Definition: TGLabel.h:80
TGLabel::GetTextJustify
Int_t GetTextJustify() const
Definition: TGLabel.h:82
TColor
The color creation and management class.
Definition: TColor.h:19
TGLabel::fNormGC
GContext_t fNormGC
graphics context used for drawing label
Definition: TGLabel.h:39
TGLabel::GetWrapLength
Int_t GetWrapLength() const
Definition: TGLabel.h:96
TGGC
Encapsulate a graphics context used in the low level graphics.
Definition: TGGC.h:22
TGLabel::~TGLabel
virtual ~TGLabel()
Delete label.
Definition: TGLabel.cxx:134
TGLabel::fHasOwnFont
Bool_t fHasOwnFont
kTRUE - font defined locally, kFALSE - globally
Definition: TGLabel.h:42
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
TGLabel::GetLeftMargin
Int_t GetLeftMargin() const
Definition: TGLabel.h:103
TGFrame.h
TGTextLayout
is used to keep track of string measurement information when using the text layout facilities.
Definition: TGFont.h:106
TGLabel::Disable
virtual void Disable(Bool_t on=kTRUE)
Definition: TGLabel.h:89
TGLabel::SetForegroundColor
virtual void SetForegroundColor(Pixel_t fore)
Definition: TGLabel.h:88
TGLabel::IsDisabled
Bool_t IsDisabled() const
Definition: TGLabel.h:92
TGLabel::fTWidth
UInt_t fTWidth
text width
Definition: TGLabel.h:28
y
Double_t y[n]
Definition: legend1.C:17
TGLabel::Enable
virtual void Enable()
Definition: TGLabel.h:91
TGString.h
TGLabel::SetText
void SetText(const char *newText)
Definition: TGLabel.h:77
unsigned int
TGLabel::SetTextFont
virtual void SetTextFont(TGFont *font, Bool_t global=kFALSE)
Changes text font specified by pointer to TGFont object.
Definition: TGLabel.cxx:324
TGLabel::GetBottomMargin
Int_t GetBottomMargin() const
Definition: TGLabel.h:106
TGLabel::fTMode
Int_t fTMode
text alignment
Definition: TGLabel.h:34
TGLabel::Set3DStyle
void Set3DStyle(Int_t style)
Definition: TGLabel.h:98
TGLabel::fTFlags
Int_t fTFlags
text flags (see TGFont.h ETextLayoutFlags)
Definition: TGLabel.h:37
TGClient::NeedRedraw
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:374
TGLabel::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Return default size.
Definition: TGLabel.cxx:168
TGLabel::SetTextColor
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition: TGLabel.cxx:362
TGLabel::GetText
const TGString * GetText() const
Definition: TGLabel.h:74
TGObject::fClient
TGClient * fClient
Connection to display server.
Definition: TGObject.h:27
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGLabel::GetDefaultGC
static const TGGC & GetDefaultGC()
Static returning label default graphics context.
Definition: TGLabel.cxx:536
TGLabel::fgDefaultGC
static const TGGC * fgDefaultGC
Definition: TGLabel.h:49
TGLabel::fTextChanged
Bool_t fTextChanged
has text changed
Definition: TGLabel.h:38
TGLabel::HasOwnFont
Bool_t HasOwnFont() const
Returns kTRUE if text attributes are unique.
Definition: TGLabel.cxx:451
TGFont::GetFontStruct
FontStruct_t GetFontStruct() const
Definition: TGFont.h:184
TGLabel::f3DStyle
Int_t f3DStyle
3D style (0 - normal, kRaisedFrame - raised, kSunkenFrame - sunken)
Definition: TGLabel.h:35
TGLabel::fMTop
Int_t fMTop
margin top
Definition: TGLabel.h:32
TGFont
Encapsulate fonts used in the GUI system.
Definition: TGFont.h:140
TGLabel::fFont
TGFont * fFont
font to draw label
Definition: TGLabel.h:40
TGLabel::SetMargins
void SetMargins(Int_t left=0, Int_t right=0, Int_t top=0, Int_t bottom=0)
Definition: TGLabel.h:101
TGLabel::fWrapLength
Int_t fWrapLength
wrap length
Definition: TGLabel.h:36
TGLabel::GetNormGC
GContext_t GetNormGC() const
Definition: TGLabel.h:108
TGString
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition: TGString.h:20
TGLabel::SetTextJustify
void SetTextJustify(Int_t tmode)
Set text justification.
Definition: TGLabel.cxx:396
TGLabel::fDisabled
Bool_t fDisabled
if kTRUE label looks disabled (shaded text)
Definition: TGLabel.h:43
TGLabel::Layout
virtual void Layout()
Layout label.
Definition: TGLabel.cxx:156
TGLabel::fTHeight
UInt_t fTHeight
text height
Definition: TGLabel.h:29
kChildFrame
@ kChildFrame
Definition: GuiTypes.h:379
int
TGLabel::fMRight
Int_t fMRight
margin right
Definition: TGLabel.h:31