Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
18namespace ROOT {
19namespace Experimental {
20
21class 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
32class RStyle {
33
34public:
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
62private:
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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
Base class for drawable entities: objects that can be painted on a RPad.
A set of defaults for graphics attributes, e.g.
Definition RStyle.hxx:32
std::list< Block_t > fBlocks
Definition RStyle.hxx:64
const RAttrMap::Value_t * Eval(const std::string &field, const RDrawable &drawable) const
Evaluate attribute value for provided RDrawable.
Definition RStyle.cxx:22
void Clear()
Parse string with CSS code inside.
Definition RStyle.cxx:63
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:72
RAttrMap & AddBlock(const std::string &selector)
Definition RStyle.hxx:50
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:274
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
RAttrMap map
container with attributes
Definition RStyle.hxx:38
Block_t(const Block_t &src)
Definition RStyle.hxx:42
Block_t(const std::string &_selector)
Definition RStyle.hxx:40
Block_t & operator=(const Block_t &)=delete
std::string selector
css selector
Definition RStyle.hxx:37