Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:22:25

0001 /*************************************************************************
0002  * Copyright (C) 1995-2021, 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_RAttrFont
0010 #define ROOT7_RAttrFont
0011 
0012 #include <ROOT/RAttrAggregation.hxx>
0013 #include <ROOT/RAttrValue.hxx>
0014 
0015 namespace ROOT {
0016 namespace Experimental {
0017 
0018 /** \class RAttrFont
0019 \ingroup GpadROOT7
0020 \brief A font attributes, used together with text attributes
0021 \author Sergey Linev <s.linev@gsi.de>
0022 \date 2021-06-28
0023 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
0024 */
0025 
0026 class RAttrFont : public RAttrAggregation {
0027 
0028    R__ATTR_CLASS(RAttrFont, "font");
0029 
0030 public:
0031 
0032    RAttrValue<std::string> family{this, "family"};  ///<! font family, corresponds to css font-familty attribute
0033    RAttrValue<std::string> style{this, "style"};    ///<! font style, corresponds to css font-style attribute
0034    RAttrValue<std::string> weight{this, "weight"};  ///<! font weight, corresponds to css font-weight attribute
0035 
0036    enum EFont {
0037       kTimesItalic = 1,
0038       kTimesBold = 2,
0039       kTimesBoldItalic = 3,
0040       kArial = 4,
0041       kArialOblique = 5,
0042       kArialBold = 6,
0043       kArialBoldOblique = 7,
0044       kCourier = 8,
0045       kCourierOblique = 9,
0046       kCourierBold = 10,
0047       kCourierBoldOblique = 11,
0048       // kSymbol = 12, // not supported by web browsers
0049       kTimes = 13,
0050       // kWingdings = 14,
0051       // kSymbolItalic = 15, // not supported by web browsers
0052       kVerdana = 16,
0053       kVerdanaItalic = 17,
0054       kVerdanaBold = 18,
0055       kVerdanaBoldItalic = 19
0056    };
0057 
0058    ///Set text font by id as usually handled in the ROOT (without precision), number should be between 1 and 15
0059    RAttrFont &SetFont(EFont font)
0060    {
0061       switch(font) {
0062       case kTimesItalic: family = "Times New Roman"; style = "italic"; break;
0063       case kTimesBold: family = "Times New Roman"; weight = "bold"; break;
0064       case kTimesBoldItalic: family = "Times New Roman"; style = "italic"; weight = "bold"; break;
0065       case kArial: family = "Arial"; break;
0066       case kArialOblique: family = "Arial"; style = "oblique"; break;
0067       case kArialBold: family = "Arial"; weight = "bold"; break;
0068       case kArialBoldOblique: family = "Arial"; style = "oblique"; weight = "bold"; break;
0069       case kCourier: family = "Courier New"; break;
0070       case kCourierOblique: family = "Courier New"; style = "oblique"; break;
0071       case kCourierBold: family = "Courier New"; weight = "bold"; break;
0072       case kCourierBoldOblique: family = "Courier New"; style = "oblique"; weight = "bold"; break;
0073       // case kSymbol: family = "Symbol"; break;
0074       case kTimes: family = "Times New Roman"; break;
0075       // case kWingdings: family = "Wingdings"; break;
0076       // case kSymbolItalic: family = "Symbol"; style = "italic"; break;
0077       case kVerdana: family = "Verdana";  break;
0078       case kVerdanaItalic: family = "Verdana";  style = "italic";  break;
0079       case kVerdanaBold: family = "Verdana";  weight = "bold"; break;
0080       case kVerdanaBoldItalic: family = "Verdana";  weight = "bold"; style = "italic"; break;
0081       }
0082       return *this;
0083    }
0084 
0085    /// assign font id, setting all necessary properties
0086    RAttrFont &operator=(EFont id) { SetFont(id); return *this; }
0087 
0088    friend bool operator==(const RAttrFont &font, EFont id) { RAttrFont font2; font2.SetFont(id); return font == font2; }
0089 
0090    /// Returns full font name including weight and style
0091    std::string GetFullName() const
0092    {
0093       std::string name = family, s = style, w = weight;
0094       if (!w.empty()) {
0095          name += " ";
0096          name += w;
0097       }
0098       if (!s.empty()) {
0099          name += " ";
0100          name += s;
0101       }
0102       return name;
0103    }
0104 
0105 };
0106 
0107 } // namespace Experimental
0108 } // namespace ROOT
0109 
0110 #endif