Logo ROOT  
Reference Guide
TText.h
Go to the documentation of this file.
1 // @(#)root/graf:$Id$
2 // Author: Nicolas Brun 12/12/94
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_TText
13 #define ROOT_TText
14 
15 
16 #include "TAttText.h"
17 #include "TNamed.h"
18 #include "TAttBBox2D.h"
19 
20 class TPoint;
21 
22 class TText : public TNamed, public TAttText, public TAttBBox2D {
23 
24 protected:
25  Double_t fX{0}; ///< X position of text (left,center,etc..)
26  Double_t fY{0}; ///< Y position of text (left,center,etc..)
27  void *fWcsTitle{nullptr}; ///<!Used by TMathText
28 
29 public:
30  // TText status bits
31  enum {
32  kTextNDC = BIT(14) ///< The text position is in the NDC space
33  };
34 
35  TText() {} // NOLINT: not allowed to use = default because of TObject::kIsOnHeap detection, see ROOT-10300
36  TText(Double_t x, Double_t y, const char *text);
37  TText(Double_t x, Double_t y, const wchar_t *text);
38  TText(const TText &text);
39  virtual ~TText();
40 
41  TText &operator=(const TText &src);
42 
43  void Copy(TObject &text) const;
44  virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
45  virtual TText *DrawText(Double_t x, Double_t y, const char *text);
46  virtual TText *DrawText(Double_t x, Double_t y, const wchar_t *text);
47  virtual TText *DrawTextNDC(Double_t x, Double_t y, const char *text);
48  virtual TText *DrawTextNDC(Double_t x, Double_t y, const wchar_t *text);
49  virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
50 
51  virtual void GetControlBox(Int_t x, Int_t y, Double_t theta,
52  Int_t cBoxX[4], Int_t cBoxY[4]);
53  Double_t GetX() const { return fX; }
54  virtual void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle = kFALSE);
55  virtual void GetTextAscentDescent(UInt_t &a, UInt_t &d, const char *text) const;
56  virtual void GetTextAscentDescent(UInt_t &a, UInt_t &d, const wchar_t *text) const;
57  virtual void GetTextExtent(UInt_t &w, UInt_t &h, const char *text) const;
58  virtual void GetTextExtent(UInt_t &w, UInt_t &h, const wchar_t *text) const;
59  virtual void GetTextAdvance(UInt_t &a, const char *text, const Bool_t kern=kTRUE) const;
60  const void * GetWcsTitle(void) const;
61  Double_t GetY() const { return fY; }
62 
63  virtual void ls(Option_t *option="") const;
64  virtual void Paint(Option_t *option="");
65  virtual void PaintControlBox(Int_t x, Int_t y, Double_t theta);
66  virtual void PaintText(Double_t x, Double_t y, const char *text);
67  virtual void PaintText(Double_t x, Double_t y, const wchar_t *text);
68  virtual void PaintTextNDC(Double_t u, Double_t v, const char *text);
69  virtual void PaintTextNDC(Double_t u, Double_t v, const wchar_t *text);
70  virtual void Print(Option_t *option="") const;
71  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
72  virtual void SetMbTitle(const wchar_t *title=L"");
73  virtual void SetNDC(Bool_t isNDC=kTRUE);
74  virtual void SetText(Double_t x, Double_t y, const char *text) {fX=x; fY=y; SetTitle(text);} // *MENU* *ARGS={x=>fX,y=>fY,text=>fTitle}
75  virtual void SetText(Double_t x, Double_t y, const wchar_t *text) {fX=x; fY=y; SetMbTitle(text);}
76  virtual void SetX(Double_t x) { fX = x; } // *MENU*
77  virtual void SetY(Double_t y) { fY = y; } // *MENU*
78 
79  virtual Rectangle_t GetBBox();
80  virtual TPoint GetBBoxCenter();
81  virtual void SetBBoxCenter(const TPoint &p);
82  virtual void SetBBoxCenterX(const Int_t x);
83  virtual void SetBBoxCenterY(const Int_t y);
84  virtual void SetBBoxX1(const Int_t x); //Not Implemented
85  virtual void SetBBoxX2(const Int_t x); //Not Implemented
86  virtual void SetBBoxY1(const Int_t y); //Not Implemented
87  virtual void SetBBoxY2(const Int_t y); //Not Implemented
88 
89  ClassDef(TText,3) //Text
90 };
91 
92 #endif
TAttText
Definition: TAttText.h:18
TText::DrawText
virtual TText * DrawText(Double_t x, Double_t y, const char *text)
Draw this text with new coordinates.
Definition: TText.cxx:175
TText::SetBBoxCenterY
virtual void SetBBoxCenterY(const Int_t y)
Set Y coordinate of the point given by Alignment as 'center'.
Definition: TText.cxx:923
TAttBBox2D.h
TText::GetBoundingBox
virtual void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle=kFALSE)
Return text size in pixels.
Definition: TText.cxx:473
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TText::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TText.cxx:792
TText::ls
virtual void ls(Option_t *option="") const
List this text with its attributes.
Definition: TText.cxx:671
TText::Copy
void Copy(TObject &text) const
Copy this text to text.
Definition: TText.cxx:107
Rectangle_t
Definition: GuiTypes.h:360
TText::SetBBoxY1
virtual void SetBBoxY1(const Int_t y)
Set top of BoundingBox to a value (resize in y direction on top)
Definition: TText.cxx:949
TText::fX
Double_t fX
X position of text (left,center,etc..)
Definition: TText.h:25
TAttText.h
TText::Paint
virtual void Paint(Option_t *option="")
Paint this text with its current attributes.
Definition: TText.cxx:680
TText::SetX
virtual void SetX(Double_t x)
Definition: TText.h:76
TNamed.h
TText::GetBBoxCenter
virtual TPoint GetBBoxCenter()
Return the point given by Alignment as 'center'.
Definition: TText.cxx:895
TText::GetTextAscentDescent
virtual void GetTextAscentDescent(UInt_t &a, UInt_t &d, const char *text) const
Return text ascent and descent for string text.
Definition: TText.cxx:523
TText::~TText
virtual ~TText()
Text default destructor.
Definition: TText.cxx:82
Int_t
int Int_t
Definition: RtypesCore.h:45
x
Double_t x[n]
Definition: legend1.C:17
TText::GetTextAdvance
virtual void GetTextAdvance(UInt_t &a, const char *text, const Bool_t kern=kTRUE) const
Return text advance for string text if kern is true (default) kerning is taken into account.
Definition: TText.cxx:615
TText::PaintTextNDC
virtual void PaintTextNDC(Double_t u, Double_t v, const char *text)
Draw this text with new coordinates in NDC.
Definition: TText.cxx:762
TText::DistancetoPrimitive
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a string.
Definition: TText.cxx:144
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
v
@ v
Definition: rootcling_impl.cxx:3635
text
TText * text
Definition: entrylist_figure1.C:10
TText::GetControlBox
virtual void GetControlBox(Int_t x, Int_t y, Double_t theta, Int_t cBoxX[4], Int_t cBoxY[4])
Return the text control box.
Definition: TText.cxx:423
TText::SetBBoxX2
virtual void SetBBoxX2(const Int_t x)
Set right hand side of BoundingBox to a value (resize in x direction on right)
Definition: TText.cxx:941
TText::GetBBox
virtual Rectangle_t GetBBox()
Return the "bounding Box" of the Box.
Definition: TText.cxx:863
TText::SetText
virtual void SetText(Double_t x, Double_t y, const char *text)
Definition: TText.h:74
TAttBBox2D
Definition: TAttBBox2D.h:19
TGeant4Unit::L
static constexpr double L
Definition: TGeant4SystemOfUnits.h:123
TText::DrawTextNDC
virtual TText * DrawTextNDC(Double_t x, Double_t y, const char *text)
Draw this text with new coordinates in NDC.
Definition: TText.cxx:201
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TText::GetX
Double_t GetX() const
Definition: TText.h:53
TText::SetNDC
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
Definition: TText.cxx:813
TText::GetY
Double_t GetY() const
Definition: TText.h:61
h
#define h(i)
Definition: RSha256.hxx:124
TText::SetText
virtual void SetText(Double_t x, Double_t y, const wchar_t *text)
Definition: TText.h:75
TText::SetBBoxX1
virtual void SetBBoxX1(const Int_t x)
Set left hand side of BoundingBox to a value (resize in x direction on left)
Definition: TText.cxx:932
TText::PaintControlBox
virtual void PaintControlBox(Int_t x, Int_t y, Double_t theta)
Paint the text control box.
Definition: TText.cxx:691
TText::SetBBoxY2
virtual void SetBBoxY2(const Int_t y)
Set bottom of BoundingBox to a value (resize in y direction on bottom)
Definition: TText.cxx:958
a
auto * a
Definition: textangle.C:12
TNamed
Definition: TNamed.h:29
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
BIT
#define BIT(n)
Definition: Rtypes.h:85
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
y
Double_t y[n]
Definition: legend1.C:17
TText::fY
Double_t fY
Y position of text (left,center,etc..)
Definition: TText.h:26
TNamed::SetTitle
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
TText
Definition: TText.h:22
TPoint
Definition: TPoint.h:31
Double_t
double Double_t
Definition: RtypesCore.h:59
TText::GetTextExtent
virtual void GetTextExtent(UInt_t &w, UInt_t &h, const char *text) const
Return text extent for string text.
Definition: TText.cxx:587
TText::TText
TText()
Definition: TText.h:35
TText::operator=
TText & operator=(const TText &src)
Assignment operator.
Definition: TText.cxx:98
TText::PaintText
virtual void PaintText(Double_t x, Double_t y, const char *text)
Draw this text with new coordinates.
Definition: TText.cxx:744
TObject
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TText::SetBBoxCenterX
virtual void SetBBoxCenterX(const Int_t x)
Set X coordinate of the point given by Alignment as 'center'.
Definition: TText.cxx:915
d
#define d(i)
Definition: RSha256.hxx:120
TText::ExecuteEvent
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TText.cxx:224
TText::kTextNDC
@ kTextNDC
The text position is in the NDC space.
Definition: TText.h:32
TText::GetWcsTitle
const void * GetWcsTitle(void) const
Returns the text as UNICODE.
Definition: TText.cxx:130
TText::SetY
virtual void SetY(Double_t y)
Definition: TText.h:77
TText::SetBBoxCenter
virtual void SetBBoxCenter(const TPoint &p)
Set the point given by Alignment as 'center'.
Definition: TText.cxx:906
TText::fWcsTitle
void * fWcsTitle
!Used by TMathText
Definition: TText.h:27
TText::SetMbTitle
virtual void SetMbTitle(const wchar_t *title=L"")
Change (i.e. set) the title of the TNamed.
Definition: TText.cxx:822
TText::Print
virtual void Print(Option_t *option="") const
Dump this text with its attributes.
Definition: TText.cxx:780