2 Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
3 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
5 This file is part of the KDE project
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
24 #include "wtf/Platform.h"
28 //#include "CSSParser.h"
29 #include "SVGException.h"
35 , m_colorType(SVG_COLORTYPE_UNKNOWN
)
39 SVGColor::SVGColor(const String
& rgbColor
)
41 , m_colorType(SVG_COLORTYPE_RGBCOLOR
)
43 setRGBColor(rgbColor
);
46 SVGColor::SVGColor(unsigned short colorType
)
48 , m_colorType(colorType
)
52 SVGColor::SVGColor(const Color
& c
)
55 , m_colorType(SVG_COLORTYPE_RGBCOLOR
)
64 unsigned short SVGColor::colorType() const
69 unsigned SVGColor::rgbColor() const
74 void SVGColor::setRGBColor(const String
& rgbColor
, ExceptionCode
& ec
)
76 Color color
= SVGColor::colorFromRGBColorString(rgbColor
);
80 ec
= SVGException::SVG_INVALID_VALUE_ERR
;
83 Color
SVGColor::colorFromRGBColorString(const String
& colorString
)
85 /*String s = colorString.stripWhiteSpace();
86 // hsl, hsla and rgba are not in the SVG spec.
87 // FIXME: rework css parser so it is more svg aware
88 if (s.startsWith("hsl") || s.startsWith("rgba"))
91 if (CSSParser::parseColor(color, s))
94 return QColor(colorString
.string());
97 void SVGColor::setRGBColorICCColor(const String
& /* rgbColor */, const String
& /* iccColor */, ExceptionCode
& ec
)
99 // TODO: implement me!
102 void SVGColor::setColor(unsigned short colorType
, const String
& /* rgbColor */ , const String
& /* iccColor */, ExceptionCode
& ec
)
104 // TODO: implement me!
105 m_colorType
= colorType
;
108 String
SVGColor::cssText() const
110 if (m_colorType
== SVG_COLORTYPE_RGBCOLOR
)
111 return m_color
.name();
116 const Color
& SVGColor::color() const
124 #endif // ENABLE(SVG)