Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RAttrText.hxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
9#ifndef ROOT7_RAttrText
10#define ROOT7_RAttrText
11
12#include <ROOT/RAttrBase.hxx>
13#include <ROOT/RAttrValue.hxx>
14#include <ROOT/RAttrColor.hxx>
15
16namespace ROOT {
17namespace Experimental {
18
19/** \class RAttrText
20\ingroup GpadROOT7
21\brief A text attributes.
22\authors Axel Naumann <axel@cern.ch> Sergey Linev <s.linev@gsi.de>
23\date 2018-10-12
24\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
25*/
26
27class RAttrText : public RAttrBase {
28
29 RAttrColor fColor{this, "color"}; ///<! text color
30 RAttrValue<double> fSize{this, "size", 12.}; ///<! text size
31 RAttrValue<double> fAngle{this, "angle", 0.}; ///<! text angle
32 RAttrValue<int> fAlign{this, "align", 22}; ///<! text align
33 RAttrValue<std::string> fFontFamily{this, "font_familty"}; ///<! font family, corresponds to css font-familty attribute
34 RAttrValue<std::string> fFontStyle{this, "font_style"}; ///<! font style, corresponds to css font-style attribute
35 RAttrValue<std::string> fFontWeight{this, "font_weight"}; ///<! font weight, corresponds to css font-weight attribute
36
38
39 ///The text size
40 RAttrText &SetSize(double sz) { fSize = sz; return *this; }
41 double GetSize() const { return fSize; }
42
43 ///The text angle
44 RAttrText &SetAngle(double angle) { fAngle = angle; return *this; }
45 double GetAngle() const { return fAngle; }
46
47 ///The text alignment
48 RAttrText &SetAlign(int align) { fAlign = align; return *this; }
49 int GetAlign() const { return fAlign; }
50
51 ///Set text font by id as usually handled in the ROOT, set number between 1 and 15
52 RAttrText &SetFont(int font)
53 {
54 std::string family, style, weight;
55 switch(font) {
56 case 1: family = "Times New Roman"; style = "italic"; break;
57 case 2: family = "Times New Roman"; weight = "bold"; break;
58 case 3: family = "Times New Roman"; style = "italic"; weight = "bold"; break;
59 case 4: family = "Arial"; break;
60 case 5: family = "Arial"; style = "oblique"; break;
61 case 6: family = "Arial"; weight = "bold"; break;
62 case 7: family = "Arial"; style = "oblique"; weight = "bold"; break;
63 case 8: family = "Courier New"; break;
64 case 9: family = "Courier New"; style = "oblique"; break;
65 case 10: family = "Courier New"; weight = "bold"; break;
66 case 11: family = "Courier New"; style = "oblique"; weight = "bold"; break;
67 case 12: family = "Symbol"; break;
68 case 13: family = "Times New Roman"; break;
69 case 14: family = "Wingdings"; break;
70 case 15: family = "Symbol"; style = "italic"; break;
71 }
72
73 SetFontFamily(family);
75 SetFontStyle(weight);
76
77 return *this;
78 }
79
80 ///The text font-family attribute
81 RAttrText &SetFontFamily(const std::string &family)
82 {
83 if (family.empty())
85 else
86 fFontFamily = family;
87 return *this;
88 }
89 std::string GetFontFamily() const { return fFontFamily; }
90
91 ///The text font-style attribute
92 RAttrText &SetFontStyle(const std::string &style)
93 {
94 if (style.empty())
96 else
98 return *this;
99 }
100 std::string GetFontStyle() const { return fFontStyle; }
101
102 ///The text font-weight attribute
103 RAttrText &SetFontWeight(const std::string &weight)
104 {
105 if (weight.empty())
107 else
108 fFontWeight = weight;
109 return *this;
110 }
111 std::string GetFontWeight() const { return fFontWeight; }
112
113
114 ///The color of the text.
115 RAttrText &SetColor(const RColor &color) { fColor = color; return *this; }
116 RColor GetColor() const { return fColor.GetColor(); }
118
119};
120
121
122
123} // namespace Experimental
124} // namespace ROOT
125
126#endif
Base class for all attributes, used with RDrawable.
Definition RAttrBase.hxx:31
void Clear()
Clear all respective values from drawable. Only defaults can be used.
Access RColor from drawable attributes.
RColor GetColor() const
Extract RColor for given attribute.
R__ATTR_CLASS(RAttrText, "text")
std::string GetFontFamily() const
Definition RAttrText.hxx:89
RAttrText & SetAlign(int align)
The text alignment.
Definition RAttrText.hxx:48
RAttrText & SetAngle(double angle)
The text angle.
Definition RAttrText.hxx:44
RAttrValue< double > fSize
! text size
Definition RAttrText.hxx:30
RAttrValue< std::string > fFontFamily
! font family, corresponds to css font-familty attribute
Definition RAttrText.hxx:33
RAttrText & SetFontWeight(const std::string &weight)
The text font-weight attribute.
RAttrText & SetFontFamily(const std::string &family)
The text font-family attribute.
Definition RAttrText.hxx:81
RAttrText & SetColor(const RColor &color)
The color of the text.
std::string GetFontStyle() const
RAttrText & SetFontStyle(const std::string &style)
The text font-style attribute.
Definition RAttrText.hxx:92
RAttrText & SetSize(double sz)
The text size.
Definition RAttrText.hxx:40
RAttrColor fColor
! text color
Definition RAttrText.hxx:29
RAttrValue< double > fAngle
! text angle
Definition RAttrText.hxx:31
RAttrValue< std::string > fFontWeight
! font weight, corresponds to css font-weight attribute
Definition RAttrText.hxx:35
RAttrText & SetFont(int font)
Set text font by id as usually handled in the ROOT, set number between 1 and 15.
Definition RAttrText.hxx:52
std::string GetFontWeight() const
RAttrValue< int > fAlign
! text align
Definition RAttrText.hxx:32
RAttrValue< std::string > fFontStyle
! font style, corresponds to css font-style attribute
Definition RAttrText.hxx:34
Template class to access single value from drawable or other attributes.
The color class.
Definition RColor.hxx:35
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
TCanvas * style()
Definition style.C:1