Logo ROOT  
Reference Guide
RAttrMargins.hxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2019, 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_RAttrMargins
10#define ROOT7_RAttrMargins
11
12#include <ROOT/RAttrBase.hxx>
13#include <ROOT/RPadLength.hxx>
14
15namespace ROOT {
16namespace Experimental {
17
18/** \class RAttrMargins
19\ingroup GpadROOT7
20\author Sergey Linev <s.linev@gsi.de>
21\date 2020-02-20
22\brief A margins attributes. Only relative and pixel coordinates are allowed
23\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
24*/
25
26class RAttrMargins : public RAttrBase {
27
28 R__ATTR_CLASS(RAttrMargins, "margin_", AddString("left","").AddString("right","").AddString("top","").AddString("bottom",""));
29
30 RAttrMargins &SetLeft(const RPadLength &pos) { return SetMargin("left", pos); }
31 RPadLength GetLeft() const { return GetMargin("left"); }
32
33 RAttrMargins &SetRight(const RPadLength &pos) { return SetMargin("right", pos); }
34 RPadLength GetRight() const { return GetMargin("right"); }
35
36 RAttrMargins &SetTop(const RPadLength &pos) { return SetMargin("top", pos); }
37 RPadLength GetTop() const { return GetMargin("top"); }
38
39 RAttrMargins &SetBottom(const RPadLength &pos) { return SetMargin("bottom", pos); }
40 RPadLength GetBottom() const { return GetMargin("bottom"); }
41
42protected:
43
44 RAttrMargins &SetMargin(const std::string &name, const RPadLength &pos)
45 {
46 if (pos.Empty())
48 else
49 SetValue(name, pos.AsString());
50
51 return *this;
52 }
53
54 RPadLength GetMargin(const std::string &name) const
55 {
56 RPadLength res;
57
58 auto value = GetValue<std::string>(name);
59
60 if (!value.empty())
61 res.ParseString(value);
62
63 return res;
64 }
65
66};
67
68} // namespace Experimental
69} // namespace ROOT
70
71#endif
char name[80]
Definition: TGX11.cxx:109
Base class for all attributes, used with RDrawable.
Definition: RAttrBase.hxx:27
void ClearValue(const std::string &name)
Clear value if any with specified name.
Definition: RAttrBase.cxx:114
void SetValue(const std::string &name, bool value)
Set boolean value.
Definition: RAttrBase.cxx:133
A margins attributes. Only relative and pixel coordinates are allowed.
R__ATTR_CLASS(RAttrMargins, "margin_", AddString("left","").AddString("right","").AddString("top","").AddString("bottom",""))
RAttrMargins & SetTop(const RPadLength &pos)
RAttrMargins & SetRight(const RPadLength &pos)
RPadLength GetMargin(const std::string &name) const
RAttrMargins & SetLeft(const RPadLength &pos)
RAttrMargins & SetMargin(const std::string &name, const RPadLength &pos)
RAttrMargins & SetBottom(const RPadLength &pos)
std::string AsString() const
Converts RPadLength to string like "0.1 + 25px" User coordinates not (yet) supported.
Definition: RPadLength.cxx:19
bool ParseString(const std::string &val)
Parse string and fill RPadLength attributes String can be like "0.1 + 25px" User coordinates not (yet...
Definition: RPadLength.cxx:50
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21