Logo ROOT   6.14/05
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 
106  void Set3DStyle(Int_t style) { f3DStyle = style; fClient->NeedRedraw(this); }
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; }
117  FontStruct_t GetFontStruct() const { return fFont->GetFontStruct(); }
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
Handle_t FontStruct_t
Definition: GuiTypes.h:38
static FontStruct_t GetDefaultFontStruct()
Static returning label default font struct.
Definition: TGLabel.cxx:522
Int_t fTMode
Definition: TGLabel.h:42
virtual void DrawText(GContext_t gc, Int_t x, Int_t y)
Draw text at position (x, y).
Definition: TGLabel.cxx:189
void SetText(Int_t number)
Definition: TGLabel.h:88
Bool_t fTextChanged
Definition: TGLabel.h:46
static const TGFont * fgDefaultFont
Definition: TGLabel.h:56
Int_t f3DStyle
Definition: TGLabel.h:43
Int_t fWrapLength
Definition: TGLabel.h:44
Int_t fMBottom
Definition: TGLabel.h:41
const char Option_t
Definition: RtypesCore.h:62
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition: TGLabel.cxx:359
const TGString * GetText() const
Definition: TGLabel.h:82
TGFont * fFont
Definition: TGLabel.h:48
Int_t GetLeftMargin() const
Definition: TGLabel.h:111
Handle_t GContext_t
Definition: GuiTypes.h:37
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
GContext_t fNormGC
Definition: TGLabel.h:47
UInt_t fTHeight
Definition: TGLabel.h:37
virtual void SetTextFont(TGFont *font, Bool_t global=kFALSE)
Changes text font specified by pointer to TGFont object.
Definition: TGLabel.cxx:321
void SetWrapLength(Int_t wl)
Definition: TGLabel.h:103
void SetText(const char *newText)
Definition: TGLabel.h:85
Int_t GetBottomMargin() const
Definition: TGLabel.h:114
TGString * fText
Definition: TGLabel.h:35
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:320
ULong_t Pixel_t
Definition: GuiTypes.h:39
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:665
Int_t fMRight
Definition: TGLabel.h:39
TGTextLayout * fTLayout
Definition: TGLabel.h:49
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:177
Int_t fMTop
Definition: TGLabel.h:40
Bool_t fDisabled
Definition: TGLabel.h:51
static const TGGC & GetDefaultGC()
Static returning label default graphics context.
Definition: TGLabel.cxx:533
virtual void ChangeText(const char *newText)
Definition: TGLabel.h:86
Int_t GetWrapLength() const
Definition: TGLabel.h:104
Int_t fMLeft
Definition: TGLabel.h:38
TGLabel & operator=(const TGLabel &)
TGFont * GetFont() const
Definition: TGLabel.h:118
Int_t Get3DStyle() const
Definition: TGLabel.h:107
Bool_t fHasOwnFont
Definition: TGLabel.h:50
virtual void Disable(Bool_t on=kTRUE)
Definition: TGLabel.h:97
virtual void Layout()
Layout label.
Definition: TGLabel.cxx:153
Int_t GetTopMargin() const
Definition: TGLabel.h:113
unsigned int UInt_t
Definition: RtypesCore.h:42
Bool_t IsDisabled() const
Definition: TGLabel.h:100
UInt_t fTWidth
Definition: TGLabel.h:36
virtual const char * GetTitle() const
Returns title of object.
Definition: TGLabel.h:83
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:456
const Bool_t kFALSE
Definition: RtypesCore.h:88
TGLabel(const TGLabel &)
TText * text
virtual void Enable()
Definition: TGLabel.h:99
Definition: TGFont.h:149
TCanvas * style()
Definition: style.C:1
virtual void SetForegroundColor(Pixel_t fore)
Definition: TGLabel.h:96
FontStruct_t GetFontStruct() const
Definition: TGFont.h:193
Double_t y[n]
Definition: legend1.C:17
virtual void SetTitle(const char *label)
Definition: TGLabel.h:87
The color creation and management class.
Definition: TColor.h:19
void Set3DStyle(Int_t style)
Definition: TGLabel.h:106
Int_t GetRightMargin() const
Definition: TGLabel.h:112
GContext_t GetNormGC() const
Definition: TGLabel.h:116
void SetTextJustify(Int_t tmode)
Set text justification.
Definition: TGLabel.cxx:393
FontStruct_t GetFontStruct() const
Definition: TGLabel.h:117
TGClient * fClient
Definition: TGObject.h:37
virtual void DoRedraw()
Redraw label widget.
Definition: TGLabel.cxx:198
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:370
static const TGGC * fgDefaultGC
Definition: TGLabel.h:57
Bool_t HasOwnFont() const
Returns kTRUE if text attributes are unique.
Definition: TGLabel.cxx:448
void SetMargins(Int_t left=0, Int_t right=0, Int_t top=0, Int_t bottom=0)
Definition: TGLabel.h:109
virtual TGDimension GetDefaultSize() const
Return default size.
Definition: TGLabel.cxx:165
const Bool_t kTRUE
Definition: RtypesCore.h:87
Definition: TGGC.h:31
virtual ~TGLabel()
Delete label.
Definition: TGLabel.cxx:131
Int_t GetTextJustify() const
Definition: TGLabel.h:90
const char * Data() const
Definition: TString.h:364
Int_t fTFlags
Definition: TGLabel.h:45