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 
28 class TColor;
29 class TGTextLayout;
30 class TGFont;
31 
32 class TGLabel : public TGFrame {
33 
34 protected:
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 
59 private:
60  TGLabel(const TGLabel&); // not implemented
61  TGLabel& operator=(const TGLabel&); // not implemented
62 
63 public:
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
TGLabel::GetTopMargin
Int_t GetTopMargin() const
Definition: TGLabel.h:113
TGLabel::ChangeText
virtual void ChangeText(const char *newText)
Definition: TGLabel.h:86
TGWindow
Definition: TGWindow.h:31
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TGDimension
Definition: TGDimension.h:27
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGLabel::GetFont
TGFont * GetFont() const
Definition: TGLabel.h:118
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:458
Pixel_t
ULong_t Pixel_t
Definition: GuiTypes.h:39
TGLabel::Get3DStyle
Int_t Get3DStyle() const
Definition: TGLabel.h:107
TGLabel::fText
TGString * fText
Definition: TGLabel.h:35
TGLabel::operator=
TGLabel & operator=(const TGLabel &)
FontStruct_t
Handle_t FontStruct_t
Definition: GuiTypes.h:38
TGLabel
Definition: TGLabel.h:32
TGLabel::SetWrapLength
void SetWrapLength(Int_t wl)
Definition: TGLabel.h:103
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:524
TGLabel::SetTitle
virtual void SetTitle(const char *label)
Definition: TGLabel.h:87
TGFrame::GetDefaultFrameBackground
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:668
TGLabel::GetFontStruct
FontStruct_t GetFontStruct() const
Definition: TGLabel.h:117
TGLabel::GetRightMargin
Int_t GetRightMargin() const
Definition: TGLabel.h:112
TGFrame
Definition: TGFrame.h:105
TGLabel::fMBottom
Int_t fMBottom
Definition: TGLabel.h:41
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:83
TGLabel::SetText
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:179
bool
TGLabel::fgDefaultFont
static const TGFont * fgDefaultFont
Definition: TGLabel.h:56
TGLabel::DoRedraw
virtual void DoRedraw()
Redraw label widget.
Definition: TGLabel.cxx:200
GContext_t
Handle_t GContext_t
Definition: GuiTypes.h:37
TGLabel::fTLayout
TGTextLayout * fTLayout
Definition: TGLabel.h:49
style
TCanvas * style()
Definition: style.C:1
TGLabel::fMLeft
Int_t fMLeft
Definition: TGLabel.h:38
TGLabel::DrawText
virtual void DrawText(GContext_t gc, Int_t x, Int_t y)
Draw text at position (x, y).
Definition: TGLabel.cxx:191
TGLabel::SetText
void SetText(Int_t number)
Definition: TGLabel.h:88
TGLabel::GetTextJustify
Int_t GetTextJustify() const
Definition: TGLabel.h:90
TColor
The color creation and management class.
Definition: TColor.h:19
TGLabel::fNormGC
GContext_t fNormGC
Definition: TGLabel.h:47
TGLabel::GetWrapLength
Int_t GetWrapLength() const
Definition: TGLabel.h:104
TGGC
Definition: TGGC.h:31
TGLabel::~TGLabel
virtual ~TGLabel()
Delete label.
Definition: TGLabel.cxx:133
TGLabel::fHasOwnFont
Bool_t fHasOwnFont
Definition: TGLabel.h:50
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TGLabel::GetLeftMargin
Int_t GetLeftMargin() const
Definition: TGLabel.h:111
TGFrame.h
TGTextLayout
Definition: TGFont.h:115
TGLabel::Disable
virtual void Disable(Bool_t on=kTRUE)
Definition: TGLabel.h:97
TGLabel::SetForegroundColor
virtual void SetForegroundColor(Pixel_t fore)
Definition: TGLabel.h:96
TGLabel::IsDisabled
Bool_t IsDisabled() const
Definition: TGLabel.h:100
TGLabel::fTWidth
UInt_t fTWidth
Definition: TGLabel.h:36
y
Double_t y[n]
Definition: legend1.C:17
TGLabel::Enable
virtual void Enable()
Definition: TGLabel.h:99
TGString.h
TGLabel::SetText
void SetText(const char *newText)
Definition: TGLabel.h:85
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:323
TGLabel::GetBottomMargin
Int_t GetBottomMargin() const
Definition: TGLabel.h:114
TGLabel::fTMode
Int_t fTMode
Definition: TGLabel.h:42
TGLabel::Set3DStyle
void Set3DStyle(Int_t style)
Definition: TGLabel.h:106
TGLabel::fTFlags
Int_t fTFlags
Definition: TGLabel.h:45
TGClient::NeedRedraw
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:373
TGLabel::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Return default size.
Definition: TGLabel.cxx:167
TGLabel::SetTextColor
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition: TGLabel.cxx:361
TGLabel::GetText
const TGString * GetText() const
Definition: TGLabel.h:82
TGObject::fClient
TGClient * fClient
Definition: TGObject.h:37
TGLabel::TGLabel
TGLabel(const TGLabel &)
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGLabel::GetDefaultGC
static const TGGC & GetDefaultGC()
Static returning label default graphics context.
Definition: TGLabel.cxx:535
TGLabel::fgDefaultGC
static const TGGC * fgDefaultGC
Definition: TGLabel.h:57
TGLabel::fTextChanged
Bool_t fTextChanged
Definition: TGLabel.h:46
TGLabel::HasOwnFont
Bool_t HasOwnFont() const
Returns kTRUE if text attributes are unique.
Definition: TGLabel.cxx:450
TGFont::GetFontStruct
FontStruct_t GetFontStruct() const
Definition: TGFont.h:193
TGLabel::f3DStyle
Int_t f3DStyle
Definition: TGLabel.h:43
TGLabel::fMTop
Int_t fMTop
Definition: TGLabel.h:40
TGFont
Definition: TGFont.h:149
TGLabel::fFont
TGFont * fFont
Definition: TGLabel.h:48
TGLabel::SetMargins
void SetMargins(Int_t left=0, Int_t right=0, Int_t top=0, Int_t bottom=0)
Definition: TGLabel.h:109
TGLabel::fWrapLength
Int_t fWrapLength
Definition: TGLabel.h:44
TGLabel::GetNormGC
GContext_t GetNormGC() const
Definition: TGLabel.h:116
TGString
Definition: TGString.h:30
TGLabel::SetTextJustify
void SetTextJustify(Int_t tmode)
Set text justification.
Definition: TGLabel.cxx:395
TGLabel::fDisabled
Bool_t fDisabled
Definition: TGLabel.h:51
TGLabel::Layout
virtual void Layout()
Layout label.
Definition: TGLabel.cxx:155
TGLabel::fTHeight
UInt_t fTHeight
Definition: TGLabel.h:37
kChildFrame
@ kChildFrame
Definition: GuiTypes.h:379
int
TGLabel::fMRight
Int_t fMRight
Definition: TGLabel.h:39