• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2     Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
3                   2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 
5     This file is part of the KDE project
6 
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.
11 
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.
16 
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.
21 */
22 
23 #include "config.h"
24 #if ENABLE(SVG)
25 #include "SVGPaint.h"
26 
27 namespace WebCore {
28 
SVGPaint()29 SVGPaint::SVGPaint()
30     : m_paintType(SVG_PAINTTYPE_UNKNOWN)
31 {
32 }
33 
SVGPaint(const String & uri)34 SVGPaint::SVGPaint(const String& uri)
35     : m_paintType(SVG_PAINTTYPE_URI_RGBCOLOR)
36 {
37     setUri(uri);
38 }
39 
SVGPaint(SVGPaintType paintType)40 SVGPaint::SVGPaint(SVGPaintType paintType)
41     : m_paintType(paintType)
42 {
43 }
44 
SVGPaint(SVGPaintType paintType,const String & uri,const String & rgbPaint,const String &)45 SVGPaint::SVGPaint(SVGPaintType paintType, const String& uri, const String& rgbPaint, const String&)
46     : SVGColor(rgbPaint)
47     , m_paintType(paintType)
48 {
49     setUri(uri);
50 }
51 
SVGPaint(const Color & c)52 SVGPaint::SVGPaint(const Color& c)
53     : SVGColor(c)
54     , m_paintType(SVG_PAINTTYPE_RGBCOLOR)
55 {
56 }
57 
SVGPaint(const String & uri,const Color & c)58 SVGPaint::SVGPaint(const String& uri, const Color& c)
59     : SVGColor(c)
60     , m_paintType(SVG_PAINTTYPE_URI_RGBCOLOR)
61 {
62     setUri(uri);
63 }
64 
~SVGPaint()65 SVGPaint::~SVGPaint()
66 {
67 }
68 
defaultFill()69 SVGPaint* SVGPaint::defaultFill()
70 {
71     static SVGPaint* _defaultFill = new SVGPaint(Color::black);
72     return _defaultFill;
73 }
74 
defaultStroke()75 SVGPaint* SVGPaint::defaultStroke()
76 {
77     static SVGPaint* _defaultStroke = new SVGPaint(SVG_PAINTTYPE_NONE);
78     return _defaultStroke;
79 }
80 
uri() const81 String SVGPaint::uri() const
82 {
83     return m_uri;
84 }
85 
setUri(const String & uri)86 void SVGPaint::setUri(const String& uri)
87 {
88     m_uri = uri;
89 }
90 
setPaint(SVGPaintType paintType,const String & uri,const String & rgbPaint,const String &,ExceptionCode &)91 void SVGPaint::setPaint(SVGPaintType paintType, const String& uri, const String& rgbPaint, const String&, ExceptionCode&)
92 {
93     m_paintType = paintType;
94 
95     if (m_paintType == SVG_PAINTTYPE_URI)
96         setUri(uri);
97     else if (m_paintType == SVG_PAINTTYPE_RGBCOLOR)
98         setRGBColor(rgbPaint);
99 }
100 
cssText() const101 String SVGPaint::cssText() const
102 {
103     if (m_paintType == SVG_PAINTTYPE_NONE)
104         return "none";
105     else if (m_paintType == SVG_PAINTTYPE_CURRENTCOLOR)
106         return "currentColor";
107     else if (m_paintType == SVG_PAINTTYPE_URI)
108         return "url(" + m_uri + ")";
109 
110     return SVGColor::cssText();
111 }
112 
113 }
114 
115 // vim:ts=4:noet
116 #endif // ENABLE(SVG)
117 
118