Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:48

0001 /*************************************************************************
0002  * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers.               *
0003  * All rights reserved.                                                  *
0004  *                                                                       *
0005  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0006  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0007  *************************************************************************/
0008 
0009 #ifndef ROOT7_RStyle
0010 #define ROOT7_RStyle
0011 
0012 #include <ROOT/RAttrMap.hxx>
0013 
0014 #include <string>
0015 #include <list>
0016 #include <memory>
0017 
0018 namespace ROOT {
0019 namespace Experimental {
0020 
0021 class RDrawable;
0022 
0023 /** \class RStyle
0024 \ingroup GpadROOT7
0025 \brief A set of defaults for graphics attributes, e.g. for histogram fill color, line width, frame offsets etc. Uses CSS syntax.
0026 \author Axel Naumann <axel@cern.ch>
0027 \author Sergey Linev <s.linev@gsi.de>
0028 \date 2017-10-10
0029 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
0030 */
0031 
0032 class RStyle {
0033 
0034 public:
0035 
0036    struct Block_t {
0037       std::string selector;       ///<  css selector
0038       RAttrMap map;               ///<  container with attributes
0039       Block_t() = default;
0040       Block_t(const std::string &_selector) : selector(_selector) {}
0041 
0042       Block_t(const Block_t &src) : selector(src.selector), map(src.map) {} // not required
0043       Block_t& operator=(const Block_t &) = delete;
0044    };
0045 
0046    const RAttrMap::Value_t *Eval(const std::string &field, const RDrawable &drawable) const;
0047 
0048    const RAttrMap::Value_t *Eval(const std::string &field, const std::string &selector) const;
0049 
0050    RAttrMap &AddBlock(const std::string &selector)
0051    {
0052       fBlocks.emplace_back(selector);
0053       return fBlocks.back().map;
0054    }
0055 
0056    void Clear();
0057 
0058    static std::shared_ptr<RStyle> Parse(const std::string &css_code);
0059 
0060    bool ParseString(const std::string &css_code);
0061 
0062 private:
0063 
0064    std::list<Block_t> fBlocks;  // use std::list to avoid calling of Block_t copy constructor
0065 
0066 };
0067 
0068 } // namespace Experimental
0069 } // namespace ROOT
0070 
0071 #endif // ROOT7_RStyle