Rubber-stamped by Brady Eidson.
[webbrowser.git] / WebCore / svg / SVGColor.h
blob406166bab9ba54d4e217706a840fffa43b659f17
1 /*
2 Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
3 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 #ifndef SVGColor_h
22 #define SVGColor_h
23 #if ENABLE(SVG)
25 #include "CSSValue.h"
26 #include "Color.h"
27 #include <wtf/PassRefPtr.h>
29 namespace WebCore {
31 class RGBColor;
33 class SVGColor : public CSSValue {
34 public:
35 static PassRefPtr<SVGColor> create(const String& color)
37 return adoptRef(new SVGColor(color));
39 static PassRefPtr<SVGColor> create(const Color& color)
41 return adoptRef(new SVGColor(color));
43 static PassRefPtr<SVGColor> createCurrentColor()
45 return adoptRef(new SVGColor(SVG_COLORTYPE_CURRENTCOLOR));
48 virtual ~SVGColor();
50 enum SVGColorType {
51 SVG_COLORTYPE_UNKNOWN = 0,
52 SVG_COLORTYPE_RGBCOLOR = 1,
53 SVG_COLORTYPE_RGBCOLOR_ICCCOLOR = 2,
54 SVG_COLORTYPE_CURRENTCOLOR = 3
57 // 'SVGColor' functions
58 unsigned short colorType() const;
60 PassRefPtr<RGBColor> rgbColor() const;
62 static Color colorFromRGBColorString(const String&);
64 void setRGBColor(const String& rgbColor) { ExceptionCode ignored = 0; setRGBColor(rgbColor, ignored); }
65 void setRGBColor(const String& rgbColor, ExceptionCode&);
66 void setRGBColorICCColor(const String& rgbColor, const String& iccColor, ExceptionCode&);
67 void setColor(unsigned short colorType, const String& rgbColor, const String& iccColor, ExceptionCode&);
69 virtual String cssText() const;
71 // Helpers
72 const Color& color() const;
74 protected:
75 SVGColor();
76 SVGColor(const String& color);
77 SVGColor(const Color&);
79 private:
80 SVGColor(SVGColorType);
82 static void create(int); // compile-time guard
84 virtual bool isSVGColor() const { return true; }
86 Color m_color;
87 unsigned short m_colorType;
90 } // namespace WebCore
92 #endif // ENABLE(SVG)
93 #endif // SVGColor_h
95 // vim:ts=4:noet