"Fossies" - the Fresh Open Source Software Archive

Member "ansifilter-2.18/src/elementstyle.h" (30 Jan 2021, 4419 Bytes) of package /linux/privat/ansifilter-2.18.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "elementstyle.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 2.13_vs_2.14.

    1 /***************************************************************************
    2                           elementstyle.h  -  description
    3                              -------------------
    4 
    5     copyright            : (C) 2007-2011 by Andre Simon
    6     email                : a.simon@mailbox.org
    7  ***************************************************************************/
    8 
    9 /*
   10 This file is part of ANSIFilter.
   11 
   12 ANSIFilter is free software: you can redistribute it and/or modify
   13 it under the terms of the GNU General Public License as published by
   14 the Free Software Foundation, either version 3 of the License, or
   15 (at your option) any later version.
   16 
   17 ANSIFilter is distributed in the hope that it will be useful,
   18 but WITHOUT ANY WARRANTY; without even the implied warranty of
   19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   20 GNU General Public License for more details.
   21 
   22 You should have received a copy of the GNU General Public License
   23 along with ANSIFilter.  If not, see <http://www.gnu.org/licenses/>.
   24 */
   25 
   26 #ifndef ELEMENTSTYLE_H
   27 #define ELEMENTSTYLE_H
   28 
   29 #include "stylecolour.h"
   30 
   31 using namespace std;
   32 
   33 namespace ansifilter
   34 {
   35 
   36 /** \brief The class stores the basic text formatting properties.
   37 
   38 * @author Andre Simon
   39 */
   40 
   41 class ElementStyle
   42 {
   43 public:
   44 
   45     ElementStyle();
   46 
   47     ~ElementStyle();
   48 
   49     /** \return True if italic */
   50     bool isItalic() const;
   51 
   52     /** \return True if italic */
   53     bool isBlink() const;
   54 
   55     /** \return True if bold */
   56     bool isBold() const;
   57 
   58     /** \return True if underline */
   59     bool isUnderline() const;
   60 
   61     /** \return True if concealed */
   62     bool isConceal() const;
   63 
   64     /** \return True if background color should change */
   65     bool isBgColorSet() const;
   66 
   67     /** \return True if foreground color should change */
   68     bool isFgColorSet() const;
   69 
   70     /** \param b set blink flag */
   71     void setBlink(bool b)
   72     {
   73         blink = b;
   74     }
   75 
   76     /** \param b set italic flag */
   77     void setItalic(bool b)
   78     {
   79         italic = b;
   80     }
   81 
   82     /** \param b set conceal flag */
   83     void setConceal(bool b)
   84     {
   85         conceal = b;
   86     }
   87 
   88     /** \param b set bold flag */
   89     void setBold(bool b)
   90     {
   91         bold = b;
   92     }
   93 
   94     /** \param b set underline flag */
   95     void setUnderline(bool b)
   96     {
   97         underline = b;
   98     }
   99 
  100     /** \return True if reset flag was set */
  101     bool isReset() const
  102     {
  103         return reset;
  104     }
  105 
  106     /** \param b reset formatting parameters to defaults */
  107     void setReset(bool b);
  108 
  109     /** \return Foreground colour */
  110     const StyleColour getFgColour() const;
  111 
  112     /** \return Background colour */
  113     const StyleColour getBgColour() const;
  114 
  115     /** Set Foreground colour
  116         \param col colour of this element */
  117     void setFgColour(const StyleColour& col)
  118     {
  119         fgColour = col;
  120         fgColorSet=true;
  121     }
  122 
  123     /**   Set Background colour
  124           \param col colour of this element */
  125     void setBgColour(const StyleColour& col)
  126     {
  127         bgColour = col;
  128         bgColorSet=true;
  129     }
  130 
  131     /** Set Foreground colour
  132         \param col colour of this element */
  133     void setFgColour(const string& rgbVal)
  134     {
  135         fgColour.setRGB(rgbVal);
  136         fgColorSet=true;
  137     }
  138 
  139     /**   Set Background colour
  140           \param col colour of this element */
  141     void setBgColour(const string& rgbVal)
  142     {
  143         bgColour.setRGB(rgbVal);
  144         bgColorSet=true;
  145     }
  146 
  147 
  148     /** Set Foreground colour IF (RTF)
  149         \param col colour ID of this element */
  150     void setFgColourID(int id)
  151     {
  152         fgColID=id;
  153     }
  154 
  155     /**   Set Background colour ID (RTF)
  156           \param col colour ID of this element */
  157     void setBgColourID(int id)
  158     {
  159         bgColID=id;
  160     }
  161 
  162 
  163     /** Set Foreground colour IF (RTF)
  164         \param col colour ID of this element */
  165     int getFgColourID()
  166     {
  167         return fgColID;
  168     }
  169 
  170     /**   Set Background colour ID (RTF)
  171           \param col colour ID of this element */
  172     int getBgColourID()
  173     {
  174         return bgColID;
  175     }
  176 
  177     /** Swap background and foreground colors
  178         \param negative Set to true, to invert default colors, set to false, to invert them back to default*/
  179     void imageMode(bool negative=true);
  180 
  181 private:
  182     StyleColour fgColour;
  183     StyleColour bgColour;
  184     bool bold, italic, underline, blink;
  185     bool reset;
  186     bool isNegativeMode, conceal;
  187     bool bgColorSet, fgColorSet;
  188     int fgColID;
  189     int bgColID;
  190 };
  191 
  192 }
  193 
  194 #endif