Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
20class TColor;
21class TGTextLayout;
22class TGFont;
23
24class TGLabel : public TGFrame {
25
26protected:
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 void DoRedraw() override;
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
51private:
52 TGLabel(const TGLabel&) = delete;
53 TGLabel& operator=(const TGLabel&) = delete;
54
55public:
57 static const TGGC &GetDefaultGC();
58
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 ~TGLabel() override;
71
72 TGDimension GetDefaultSize() const override;
73
74 const TGString *GetText() const { return fText; }
75 const char *GetTitle() const override { 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 void SetForegroundColor(Pixel_t fore) override { 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 void Layout() override;
113 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
114
115 ClassDefOverride(TGLabel,0) // A label GUI element
116};
117
118#endif
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
@ kChildFrame
Definition GuiTypes.h:379
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
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 on
Option_t Option_t SetTextFont
Option_t Option_t TPoint TPoint DrawText
Option_t Option_t style
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
Option_t Option_t TPoint TPoint const char text
The color creation and management class.
Definition TColor.h:21
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
void SetTextJustify(Int_t tmode)
Set text justification.
Definition TGLabel.cxx:396
FontStruct_t GetFontStruct() const
Definition TGLabel.h:109
void Layout() override
Layout label.
Definition TGLabel.cxx:156
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
Bool_t fDisabled
if kTRUE label looks disabled (shaded text)
Definition TGLabel.h:43
TGFont * GetFont() const
Definition TGLabel.h:110
~TGLabel() override
Delete label.
Definition TGLabel.cxx:134
static const TGGC * fgDefaultGC
Definition TGLabel.h:49
GContext_t fNormGC
graphics context used for drawing label
Definition TGLabel.h:39
Int_t GetTextJustify() const
Definition TGLabel.h:82
void DoRedraw() override
Redraw label widget.
Definition TGLabel.cxx:201
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a label widget as a C++ statement(s) on output stream out.
Definition TGLabel.cxx:459
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
void SetForegroundColor(Pixel_t fore) override
Definition TGLabel.h:88
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
const char * GetTitle() const override
Returns title of object.
Definition TGLabel.h:75
Int_t fMTop
margin top
Definition TGLabel.h:32
virtual void ChangeText(const char *newText)
Definition TGLabel.h:78
TGDimension GetDefaultSize() const override
Return default size.
Definition TGLabel.cxx:168
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 void Disable(Bool_t on=kTRUE)
Definition TGLabel.h:89
Int_t fMBottom
margin bottom
Definition TGLabel.h:33
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:25
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:376
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17