"Fossies" - the Fresh Open Source Software Archive

Member "ansifilter-2.18/src/stylecolour.h" (30 Jan 2021, 2976 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 "stylecolour.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                           stylecolour.h  -  description
    3                              -------------------
    4     begin                : Die Nov 5 2002
    5     copyright            : (C) 2002 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 STYLECOLOUR_H
   27 #define STYLECOLOUR_H
   28 
   29 #include "enums.h"
   30 
   31 #include <string>
   32 
   33 using namespace std;
   34 
   35 namespace ansifilter
   36 {
   37 
   38 /**\brief Stores colours and returns red, green and blue values in different formats
   39 * @author Andre Simon
   40  */
   41 
   42 struct RGBVal {
   43     int iRed,    ///< Red value
   44         iGreen,  ///< Green value
   45         iBlue;   ///< Blue value
   46 };
   47 
   48 class StyleColour
   49 {
   50 public:
   51     /** Constructor
   52         \param red Red value in hex notation
   53         \param green Blue value in hex notation
   54         \param blue Green value in hex notation
   55     */
   56     StyleColour(const string & red, const string & green, const string & blue);
   57 
   58     /** Constructor
   59         \param styleColourString String with rgb values
   60     */
   61     StyleColour(const string & styleColourString);
   62 
   63     StyleColour();
   64     ~StyleColour() {};
   65 
   66     /** Sets red, green and blue values
   67       \param styleColourString String containing colour attributes
   68     */
   69     void setRGB(const string & styleColourString);
   70 
   71     /** Sets red value
   72         \param red New red value */
   73     void setRed(const string & red);
   74 
   75     /** Sets green value
   76         \param green New green value */
   77     void setGreen(const string & green);
   78 
   79     /** Sets blue value
   80         \param blue New blue value */
   81     void setBlue(const string & blue);
   82 
   83     /**  @param type Output type
   84          @return Red value in color representation according to output type */
   85     const string getRed(OutputType type) const;
   86     
   87     /**  @param type Output type
   88          @return Green value in color representation according to output type */
   89     
   90     const string getGreen(OutputType type) const;
   91     /**  @param type Output type
   92          @return Blue value in color representation according to output type */
   93     const string getBlue(OutputType type) const;
   94 
   95 private:
   96     RGBVal rgb;
   97     string int2str(int, std::ios_base& (*f)(std::ios_base&) ) const;
   98     string float2str(double) const;
   99 };
  100 
  101 }
  102 
  103 #endif