"Fossies" - the Fresh Open Source Software Archive

Member "highlight-3.57-x64/src/core/elementstyle.cpp" (12 May 2020, 2698 Bytes) of package /windows/www/highlight-3.57-x64.zip:


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.

    1 /***************************************************************************
    2                           elementstyle.cpp  -  description
    3                              -------------------
    4     begin                : Son Nov 10 2002
    5     copyright            : (C) 2002-2007 by Andre Simon
    6     email                : a.simon@mailbox.org
    7  ***************************************************************************/
    8 
    9 /*
   10 This file is part of Highlight.
   11 
   12 Highlight 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 Highlight 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 Highlight.  If not, see <http://www.gnu.org/licenses/>.
   24 */
   25 
   26 #include <sstream>
   27 #include "elementstyle.h"
   28 
   29 namespace highlight
   30 {
   31 
   32 ElementStyle::ElementStyle (const Colour &col, bool b, bool i, bool u )
   33     : colour ( col ) , bold ( b ), italic ( i ), underline ( u )
   34 {}
   35 
   36 ElementStyle:: ElementStyle ( const string & elementStyleString )
   37     : bold ( false ), italic ( false ), underline ( false )
   38 {
   39     set ( elementStyleString );
   40 }
   41 
   42 ElementStyle::ElementStyle()
   43     : bold ( false ), italic ( false ), underline ( false )
   44 {}
   45 
   46 void ElementStyle::set ( const string & elementStyleString )
   47 {
   48     istringstream valueStream ( elementStyleString );
   49     string r, g, b, attr;
   50 
   51     char c='\0';
   52     valueStream >> c;
   53 
   54     if ( c=='#' ) {
   55         string htmlNotation;
   56         valueStream >> htmlNotation;
   57         if ( htmlNotation.size() < 6 ) return;
   58         r = htmlNotation.substr ( 0, 2 );
   59         g = htmlNotation.substr ( 2, 2 );
   60         b = htmlNotation.substr ( 4, 2 );
   61     } else {
   62         valueStream.putback ( c );
   63         valueStream >> r;
   64         valueStream >> g;
   65         valueStream >> b;
   66     }
   67 
   68     colour.setRed ( r );
   69     colour.setGreen ( g );
   70     colour.setBlue ( b );
   71     while ( valueStream >> attr ) {
   72         if ( attr=="italic" ) {
   73             italic = true;
   74         } else if ( attr=="bold" ) {
   75             bold = true;
   76         } else if ( attr=="underline" ) {
   77             underline = true;
   78         }
   79     }
   80 }
   81 
   82 ElementStyle::~ElementStyle()
   83 {}
   84 
   85 bool ElementStyle::isItalic() const
   86 {
   87     return italic;
   88 }
   89 bool ElementStyle::isBold() const
   90 {
   91     return bold;
   92 }
   93 bool ElementStyle::isUnderline() const
   94 {
   95     return underline;
   96 }
   97 Colour ElementStyle::getColour() const
   98 {
   99     return colour;
  100 }
  101 
  102 }