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