Logo ROOT   master
Reference Guide
RStyle.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_RStyle
10 #define ROOT7_RStyle
11 
12 #include <ROOT/RAttrMap.hxx>
13 
14 #include <string>
15 #include <list>
16 
17 namespace ROOT {
18 namespace Experimental {
19 
20 class RDrawable;
21 
22 /** \class RStyle
23 \ingroup GpadROOT7
24 \brief A set of defaults for graphics attributes, e.g. for histogram fill color, line width, frame offsets etc. Uses CSS syntax.
25 \author Axel Naumann <axel@cern.ch>
26 \author Sergey Linev <s.linev@gsi.de>
27 \date 2017-10-10
28 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
29 */
30 
31 class RStyle {
32 
33 public:
34 
35  struct Block_t {
36  std::string selector; ///< css selector
37  RAttrMap map; ///< container with attributes
38  Block_t() = default;
39  Block_t(const std::string &_selector) : selector(_selector) {}
40 
41  Block_t(const Block_t &src) : selector(src.selector), map(src.map) {} // not required
42  Block_t& operator=(const Block_t &) = delete;
43  };
44 
45  const RAttrMap::Value_t *Eval(const std::string &field, const RDrawable &drawable) const;
46 
47  const RAttrMap::Value_t *Eval(const std::string &field, const std::string &selector) const;
48 
49  RAttrMap &AddBlock(const std::string &selector)
50  {
51  fBlocks.emplace_back(selector);
52  return fBlocks.back().map;
53  }
54 
55  void Clear();
56 
57  bool ParseString(const std::string &css_code);
58 
59 private:
60 
61  std::list<Block_t> fBlocks; // use std::list to avoid calling of Block_t copy constructor
62 
63 };
64 
65 } // namespace Experimental
66 } // namespace ROOT
67 
68 #endif // ROOT7_RStyle
Base class for drawable entities: objects that can be painted on a RPad.
Definition: RDrawable.hxx:102
Returns the available number of logical cores.
Definition: StringConv.hxx:21
RAttrMap & AddBlock(const std::string &selector)
Definition: RStyle.hxx:49
const RAttrMap::Value_t * Eval(const std::string &field, const RDrawable &drawable) const
Evaluate attribute value for provided RDrawable.
Definition: RStyle.cxx:19
Block_t(const Block_t &src)
Definition: RStyle.hxx:41
Block_t & operator=(const Block_t &)=delete
RAttrMap map
container with attributes
Definition: RStyle.hxx:37
std::string selector
css selector
Definition: RStyle.hxx:36
Block_t(const std::string &_selector)
Definition: RStyle.hxx:39
void Clear()
Parse string with CSS code inside.
Definition: RStyle.cxx:52
A set of defaults for graphics attributes, e.g.
Definition: RStyle.hxx:31
bool ParseString(const std::string &css_code)
Parse string with CSS code inside All data will be append to existing style records.
Definition: RStyle.cxx:61
std::list< Block_t > fBlocks
Definition: RStyle.hxx:61