ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #ifndef ROOT_TGFrame
25 #include "TGFrame.h"
26 #endif
27 #ifndef ROOT_TGDimension
28 #include "TGDimension.h"
29 #endif
30 #ifndef ROOT_TGString
31 #include "TGString.h"
32 #endif
33 
34 class TColor;
35 class TGTextLayout;
36 class TGFont;
37 
38 class TGLabel : public TGFrame {
39 
40 protected:
41  TGString *fText; // label text
42  UInt_t fTWidth; // text width
43  UInt_t fTHeight; // text height
44  Int_t fMLeft; // margin left
45  Int_t fMRight; // margin right
46  Int_t fMTop; // margin top
47  Int_t fMBottom; // margin bottom
48  Int_t fTMode; // text alignment
49  Int_t f3DStyle; // 3D style (0 - normal, kRaisedFrame - raised, kSunkenFrame - sunken)
50  Int_t fWrapLength; // wrap length
51  Int_t fTFlags; // text flags (see TGFont.h ETextLayoutFlags)
52  Bool_t fTextChanged; // has text changed
53  GContext_t fNormGC; // graphics context used for drawing label
54  TGFont *fFont; // font to draw label
55  TGTextLayout *fTLayout; // text layout
56  Bool_t fHasOwnFont; // kTRUE - font defined locally, kFALSE - globally
57  Bool_t fDisabled; // if kTRUE label looks disabled (shaded text)
58 
59  virtual void DoRedraw();
60  virtual void DrawText(GContext_t gc, Int_t x, Int_t y);
61 
62  static const TGFont *fgDefaultFont;
63  static const TGGC *fgDefaultGC;
64 
65 private:
66  TGLabel(const TGLabel&); // not implemented
67  TGLabel& operator=(const TGLabel&); // not implemented
68 
69 public:
71  static const TGGC &GetDefaultGC();
72 
73  TGLabel(const TGWindow *p, TGString *text,
76  UInt_t options = kChildFrame,
78  TGLabel(const TGWindow *p = 0, const char *text = 0,
81  UInt_t options = kChildFrame,
83 
84  virtual ~TGLabel();
85 
86  virtual TGDimension GetDefaultSize() const;
87 
88  const TGString *GetText() const { return fText; }
89  virtual const char *GetTitle() const { return fText->Data(); }
90  virtual void SetText(TGString *newText);
91  void SetText(const char *newText) { SetText(new TGString(newText)); }
92  virtual void ChangeText(const char *newText) { SetText(newText); } //*MENU*icon=bld_rename.png*
93  virtual void SetTitle(const char *label) { SetText(label); }
94  void SetText(Int_t number) { SetText(new TGString(number)); }
95  void SetTextJustify(Int_t tmode);
96  Int_t GetTextJustify() const { return fTMode; }
97  virtual void SetTextFont(TGFont *font, Bool_t global = kFALSE);
98  virtual void SetTextFont(FontStruct_t font, Bool_t global = kFALSE);
99  virtual void SetTextFont(const char *fontName, Bool_t global = kFALSE);
100  virtual void SetTextColor(Pixel_t color, Bool_t global = kFALSE);
101  virtual void SetTextColor(TColor *color, Bool_t global = kFALSE);
102  virtual void SetForegroundColor(Pixel_t fore) { SetTextColor(fore); }
103  virtual void Disable(Bool_t on = kTRUE)
104  { fDisabled = on; fClient->NeedRedraw(this); } //*TOGGLE* *GETTER=IsDisabled
105  virtual void Enable() { fDisabled = kFALSE; fClient->NeedRedraw(this); }
106  Bool_t IsDisabled() const { return fDisabled; }
107  Bool_t HasOwnFont() const;
108 
109  void SetWrapLength(Int_t wl) { fWrapLength = wl; Layout(); }
110  Int_t GetWrapLength() const { return fWrapLength; }
111 
113  Int_t Get3DStyle() const { return f3DStyle; }
114 
115  void SetMargins(Int_t left=0, Int_t right=0, Int_t top=0, Int_t bottom=0)
116  { fMLeft = left; fMRight = right; fMTop = top; fMBottom = bottom; }
117  Int_t GetLeftMargin() const { return fMLeft; }
118  Int_t GetRightMargin() const { return fMRight; }
119  Int_t GetTopMargin() const { return fMTop; }
120  Int_t GetBottomMargin() const { return fMBottom; }
121 
122  GContext_t GetNormGC() const { return fNormGC; }
124  TGFont *GetFont() const { return fFont; }
125 
126  virtual void Layout();
127  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
128 
129  ClassDef(TGLabel,0) // A label GUI element
130 };
131 
132 #endif
Handle_t FontStruct_t
Definition: GuiTypes.h:40
static FontStruct_t GetDefaultFontStruct()
Static returning label default font struct.
Definition: TGLabel.cxx:522
Bool_t HasOwnFont() const
Returns kTRUE if text attributes are unique.
Definition: TGLabel.cxx:448
Int_t fTMode
Definition: TGLabel.h:48
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:94
Bool_t fTextChanged
Definition: TGLabel.h:52
Int_t GetLeftMargin() const
Definition: TGLabel.h:117
static const TGFont * fgDefaultFont
Definition: TGLabel.h:62
Int_t f3DStyle
Definition: TGLabel.h:49
Int_t fWrapLength
Definition: TGLabel.h:50
Int_t fMBottom
Definition: TGLabel.h:47
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
TGFont * fFont
Definition: TGLabel.h:54
Int_t Get3DStyle() const
Definition: TGLabel.h:113
TGFont * GetFont() const
Definition: TGLabel.h:124
Handle_t GContext_t
Definition: GuiTypes.h:39
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
GContext_t fNormGC
Definition: TGLabel.h:53
UInt_t fTHeight
Definition: TGLabel.h:43
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:109
void SetText(const char *newText)
Definition: TGLabel.h:91
const char * Data() const
Definition: TString.h:349
TGString * fText
Definition: TGLabel.h:41
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
ULong_t Pixel_t
Definition: GuiTypes.h:41
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:665
Int_t fMRight
Definition: TGLabel.h:45
TGTextLayout * fTLayout
Definition: TGLabel.h:55
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:177
Int_t fMTop
Definition: TGLabel.h:46
GContext_t GetNormGC() const
Definition: TGLabel.h:122
Bool_t fDisabled
Definition: TGLabel.h:57
static const TGGC & GetDefaultGC()
Static returning label default graphics context.
Definition: TGLabel.cxx:533
char * out
Definition: TBase64.cxx:29
virtual void ChangeText(const char *newText)
Definition: TGLabel.h:92
Int_t fMLeft
Definition: TGLabel.h:44
TGLabel & operator=(const TGLabel &)
Bool_t fHasOwnFont
Definition: TGLabel.h:56
virtual void Disable(Bool_t on=kTRUE)
Definition: TGLabel.h:103
Int_t GetRightMargin() const
Definition: TGLabel.h:118
virtual TGDimension GetDefaultSize() const
Return default size.
Definition: TGLabel.cxx:165
virtual void Layout()
Layout label.
Definition: TGLabel.cxx:153
unsigned int UInt_t
Definition: RtypesCore.h:42
UInt_t fTWidth
Definition: TGLabel.h:42
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
virtual const char * GetTitle() const
Returns title of object.
Definition: TGLabel.h:89
TGLabel(const TGLabel &)
virtual void Enable()
Definition: TGLabel.h:105
Definition: TGFont.h:155
Int_t GetWrapLength() const
Definition: TGLabel.h:110
TCanvas * style()
Definition: style.C:1
virtual void SetForegroundColor(Pixel_t fore)
Definition: TGLabel.h:102
Double_t y[n]
Definition: legend1.C:17
virtual void SetTitle(const char *label)
Definition: TGLabel.h:93
The color creation and management class.
Definition: TColor.h:47
void Set3DStyle(Int_t style)
Definition: TGLabel.h:112
Int_t GetBottomMargin() const
Definition: TGLabel.h:120
void SetTextJustify(Int_t tmode)
Set text justification.
Definition: TGLabel.cxx:393
FontStruct_t GetFontStruct() const
Definition: TGFont.h:199
TGClient * fClient
Definition: TGObject.h:41
virtual void DoRedraw()
Redraw label widget.
Definition: TGLabel.cxx:198
Int_t GetTopMargin() const
Definition: TGLabel.h:119
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:370
const TGString * GetText() const
Definition: TGLabel.h:88
static const TGGC * fgDefaultGC
Definition: TGLabel.h:63
FontStruct_t GetFontStruct() const
Definition: TGLabel.h:123
void SetMargins(Int_t left=0, Int_t right=0, Int_t top=0, Int_t bottom=0)
Definition: TGLabel.h:115
Bool_t IsDisabled() const
Definition: TGLabel.h:106
const Bool_t kTRUE
Definition: Rtypes.h:91
double norm(double *x, double *p)
Definition: unuranDistr.cxx:40
Definition: TGGC.h:35
Int_t GetTextJustify() const
Definition: TGLabel.h:96
virtual ~TGLabel()
Delete label.
Definition: TGLabel.cxx:131
Int_t fTFlags
Definition: TGLabel.h:51