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//////////////////////////////////////////////////////////////////////////
17// //
18// TGLabel //
19// //
20// This class handles GUI labels. //
21// //
22//////////////////////////////////////////////////////////////////////////
23
24#include "TGFrame.h"
25#include "TGDimension.h"
26#include "TGString.h"
27
28class TColor;
29class TGTextLayout;
30class TGFont;
31
32class TGLabel : public TGFrame {
33
34protected:
35 TGString *fText; // label text
36 UInt_t fTWidth; // text width
37 UInt_t fTHeight; // text height
38 Int_t fMLeft; // margin left
39 Int_t fMRight; // margin right
40 Int_t fMTop; // margin top
41 Int_t fMBottom; // margin bottom
42 Int_t fTMode; // text alignment
43 Int_t f3DStyle; // 3D style (0 - normal, kRaisedFrame - raised, kSunkenFrame - sunken)
44 Int_t fWrapLength; // wrap length
45 Int_t fTFlags; // text flags (see TGFont.h ETextLayoutFlags)
46 Bool_t fTextChanged; // has text changed
47 GContext_t fNormGC; // graphics context used for drawing label
48 TGFont *fFont; // font to draw label
49 TGTextLayout *fTLayout; // text layout
50 Bool_t fHasOwnFont; // kTRUE - font defined locally, kFALSE - globally
51 Bool_t fDisabled; // if kTRUE label looks disabled (shaded text)
52
53 virtual void DoRedraw();
54 virtual void DrawText(GContext_t gc, Int_t x, Int_t y);
55
56 static const TGFont *fgDefaultFont;
57 static const TGGC *fgDefaultGC;
58
59private:
60 TGLabel(const TGLabel&); // not implemented
61 TGLabel& operator=(const TGLabel&); // not implemented
62
63public:
65 static const TGGC &GetDefaultGC();
66
67 TGLabel(const TGWindow *p, TGString *text,
68 GContext_t norm = GetDefaultGC()(),
70 UInt_t options = kChildFrame,
72 TGLabel(const TGWindow *p = 0, const char *text = 0,
73 GContext_t norm = GetDefaultGC()(),
75 UInt_t options = kChildFrame,
77
78 virtual ~TGLabel();
79
80 virtual TGDimension GetDefaultSize() const;
81
82 const TGString *GetText() const { return fText; }
83 virtual const char *GetTitle() const { return fText->Data(); }
84 virtual void SetText(TGString *newText);
85 void SetText(const char *newText) { SetText(new TGString(newText)); }
86 virtual void ChangeText(const char *newText) { SetText(newText); } //*MENU*icon=bld_rename.png*
87 virtual void SetTitle(const char *label) { SetText(label); }
88 void SetText(Int_t number) { SetText(new TGString(number)); }
89 void SetTextJustify(Int_t tmode);
90 Int_t GetTextJustify() const { return fTMode; }
91 virtual void SetTextFont(TGFont *font, Bool_t global = kFALSE);
92 virtual void SetTextFont(FontStruct_t font, Bool_t global = kFALSE);
93 virtual void SetTextFont(const char *fontName, Bool_t global = kFALSE);
94 virtual void SetTextColor(Pixel_t color, Bool_t global = kFALSE);
95 virtual void SetTextColor(TColor *color, Bool_t global = kFALSE);
96 virtual void SetForegroundColor(Pixel_t fore) { SetTextColor(fore); }
97 virtual void Disable(Bool_t on = kTRUE)
98 { fDisabled = on; fClient->NeedRedraw(this); } //*TOGGLE* *GETTER=IsDisabled
99 virtual void Enable() { fDisabled = kFALSE; fClient->NeedRedraw(this); }
100 Bool_t IsDisabled() const { return fDisabled; }
101 Bool_t HasOwnFont() const;
102
103 void SetWrapLength(Int_t wl) { fWrapLength = wl; Layout(); }
104 Int_t GetWrapLength() const { return fWrapLength; }
105
107 Int_t Get3DStyle() const { return f3DStyle; }
108
109 void SetMargins(Int_t left=0, Int_t right=0, Int_t top=0, Int_t bottom=0)
110 { fMLeft = left; fMRight = right; fMTop = top; fMBottom = bottom; }
111 Int_t GetLeftMargin() const { return fMLeft; }
112 Int_t GetRightMargin() const { return fMRight; }
113 Int_t GetTopMargin() const { return fMTop; }
114 Int_t GetBottomMargin() const { return fMBottom; }
115
116 GContext_t GetNormGC() const { return fNormGC; }
118 TGFont *GetFont() const { return fFont; }
119
120 virtual void Layout();
121 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
122
123 ClassDef(TGLabel,0) // A label GUI element
124};
125
126#endif
@ kChildFrame
Definition: GuiTypes.h:379
Handle_t GContext_t
Definition: GuiTypes.h:37
Handle_t FontStruct_t
Definition: GuiTypes.h:38
ULong_t Pixel_t
Definition: GuiTypes.h:39
int Int_t
Definition: RtypesCore.h:43
const Bool_t kFALSE
Definition: RtypesCore.h:90
bool Bool_t
Definition: RtypesCore.h:61
const Bool_t kTRUE
Definition: RtypesCore.h:89
const char Option_t
Definition: RtypesCore.h:64
#define ClassDef(name, id)
Definition: Rtypes.h:322
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
Definition: TGFont.h:149
FontStruct_t GetFontStruct() const
Definition: TGFont.h:193
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:667
Definition: TGGC.h:31
Int_t fMLeft
Definition: TGLabel.h:38
virtual ~TGLabel()
Delete label.
Definition: TGLabel.cxx:132
void SetTextJustify(Int_t tmode)
Set text justification.
Definition: TGLabel.cxx:394
virtual const char * GetTitle() const
Returns title of object.
Definition: TGLabel.h:83
FontStruct_t GetFontStruct() const
Definition: TGLabel.h:117
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition: TGLabel.cxx:360
Int_t f3DStyle
Definition: TGLabel.h:43
void SetText(const char *newText)
Definition: TGLabel.h:85
Bool_t HasOwnFont() const
Returns kTRUE if text attributes are unique.
Definition: TGLabel.cxx:449
virtual void DrawText(GContext_t gc, Int_t x, Int_t y)
Draw text at position (x, y).
Definition: TGLabel.cxx:190
Bool_t fDisabled
Definition: TGLabel.h:51
TGFont * GetFont() const
Definition: TGLabel.h:118
static const TGGC * fgDefaultGC
Definition: TGLabel.h:57
GContext_t fNormGC
Definition: TGLabel.h:47
virtual void SetForegroundColor(Pixel_t fore)
Definition: TGLabel.h:96
Int_t GetTextJustify() const
Definition: TGLabel.h:90
virtual void Layout()
Layout label.
Definition: TGLabel.cxx:154
virtual void DoRedraw()
Redraw label widget.
Definition: TGLabel.cxx:199
Int_t GetTopMargin() const
Definition: TGLabel.h:113
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:178
static const TGGC & GetDefaultGC()
Static returning label default graphics context.
Definition: TGLabel.cxx:534
void SetText(Int_t number)
Definition: TGLabel.h:88
void Set3DStyle(Int_t style)
Definition: TGLabel.h:106
Bool_t fHasOwnFont
Definition: TGLabel.h:50
Bool_t IsDisabled() const
Definition: TGLabel.h:100
UInt_t fTWidth
Definition: TGLabel.h:36
Int_t fMRight
Definition: TGLabel.h:39
TGFont * fFont
Definition: TGLabel.h:48
Int_t GetBottomMargin() const
Definition: TGLabel.h:114
Int_t GetLeftMargin() const
Definition: TGLabel.h:111
GContext_t GetNormGC() const
Definition: TGLabel.h:116
UInt_t fTHeight
Definition: TGLabel.h:37
Int_t Get3DStyle() const
Definition: TGLabel.h:107
Int_t fWrapLength
Definition: TGLabel.h:44
TGLabel(const TGLabel &)
static FontStruct_t GetDefaultFontStruct()
Static returning label default font struct.
Definition: TGLabel.cxx:523
Int_t fMTop
Definition: TGLabel.h:40
virtual void ChangeText(const char *newText)
Definition: TGLabel.h:86
void SetMargins(Int_t left=0, Int_t right=0, Int_t top=0, Int_t bottom=0)
Definition: TGLabel.h:109
Int_t GetWrapLength() const
Definition: TGLabel.h:104
Int_t fTMode
Definition: TGLabel.h:42
Bool_t fTextChanged
Definition: TGLabel.h:46
static const TGFont * fgDefaultFont
Definition: TGLabel.h:56
TGLabel & operator=(const TGLabel &)
virtual TGDimension GetDefaultSize() const
Return default size.
Definition: TGLabel.cxx:166
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:457
virtual void Disable(Bool_t on=kTRUE)
Definition: TGLabel.h:97
Int_t fMBottom
Definition: TGLabel.h:41
virtual void SetTextFont(TGFont *font, Bool_t global=kFALSE)
Changes text font specified by pointer to TGFont object.
Definition: TGLabel.cxx:322
Int_t fTFlags
Definition: TGLabel.h:45
TGTextLayout * fTLayout
Definition: TGLabel.h:49
void SetWrapLength(Int_t wl)
Definition: TGLabel.h:103
const TGString * GetText() const
Definition: TGLabel.h:82
TGString * fText
Definition: TGLabel.h:35
Int_t GetRightMargin() const
Definition: TGLabel.h:112
virtual void Enable()
Definition: TGLabel.h:99
virtual void SetTitle(const char *label)
Definition: TGLabel.h:87
TGClient * fClient
Definition: TGObject.h:37
const char * Data() const
Definition: TString.h:364
TText * text
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
TCanvas * style()
Definition: style.C:1