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