KHTML
SVGPaint.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "config.h"
00024 #include "wtf/Platform.h"
00025 #if ENABLE(SVG)
00026 #include "SVGPaint.h"
00027
00028 namespace WebCore {
00029
00030 SVGPaint::SVGPaint()
00031 : SVGColor()
00032 , m_paintType(SVG_PAINTTYPE_UNKNOWN)
00033 {
00034 }
00035
00036 SVGPaint::SVGPaint(const String& uri)
00037 : SVGColor()
00038 , m_paintType(SVG_PAINTTYPE_URI_RGBCOLOR)
00039 {
00040 setUri(uri);
00041 }
00042
00043 SVGPaint::SVGPaint(SVGPaintType paintType)
00044 : SVGColor()
00045 , m_paintType(paintType)
00046 {
00047 }
00048
00049 SVGPaint::SVGPaint(SVGPaintType paintType, const String& uri, const String& rgbPaint, const String&)
00050 : SVGColor(rgbPaint)
00051 , m_paintType(paintType)
00052 {
00053 setUri(uri);
00054 }
00055
00056 SVGPaint::SVGPaint(const Color& c)
00057 : SVGColor(c)
00058 , m_paintType(SVG_PAINTTYPE_RGBCOLOR)
00059 {
00060 }
00061
00062 SVGPaint::SVGPaint(const String& uri, const Color& c)
00063 : SVGColor(c)
00064 , m_paintType(SVG_PAINTTYPE_URI_RGBCOLOR)
00065 {
00066 setUri(uri);
00067 }
00068
00069 SVGPaint::~SVGPaint()
00070 {
00071 }
00072
00073 SVGPaint* SVGPaint::defaultFill()
00074 {
00075 static SVGPaint* _defaultFill = new SVGPaint(Qt::black);
00076 return _defaultFill;
00077 }
00078
00079 SVGPaint* SVGPaint::defaultStroke()
00080 {
00081 static SVGPaint* _defaultStroke = new SVGPaint(SVG_PAINTTYPE_NONE);
00082 return _defaultStroke;
00083 }
00084
00085 String SVGPaint::uri() const
00086 {
00087 return m_uri;
00088 }
00089
00090 void SVGPaint::setUri(const String& uri)
00091 {
00092 m_uri = uri;
00093 }
00094
00095 void SVGPaint::setPaint(SVGPaintType paintType, const String& uri, const String& rgbPaint, const String&, ExceptionCode&)
00096 {
00097 m_paintType = paintType;
00098
00099 if (m_paintType == SVG_PAINTTYPE_URI)
00100 setUri(uri);
00101 else if (m_paintType == SVG_PAINTTYPE_RGBCOLOR)
00102 setRGBColor(rgbPaint);
00103 }
00104
00105 String SVGPaint::cssText() const
00106 {
00107 if (m_paintType == SVG_PAINTTYPE_NONE)
00108 return "none";
00109 else if (m_paintType == SVG_PAINTTYPE_CURRENTCOLOR)
00110 return "currentColor";
00111 else if (m_paintType == SVG_PAINTTYPE_URI)
00112 return m_uri;
00113
00114 return SVGColor::cssText();
00115 }
00116
00117 }
00118
00119
00120 #endif // ENABLE(SVG)
00121