File indexing completed on 2024-04-28 11:37:28
0001 /* 0002 Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 0003 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 0004 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmial.com) 0005 (C) 2009 Maksim Orlovich (maksim@kde.org) 0006 0007 This file is part of the KDE project 0008 0009 This library is free software; you can redistribute it and/or 0010 modify it under the terms of the GNU Library General Public 0011 License as published by the Free Software Foundation; either 0012 version 2 of the License, or (at your option) any later version. 0013 0014 This library is distributed in the hope that it will be useful, 0015 but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0017 Library General Public License for more details. 0018 0019 You should have received a copy of the GNU Library General Public License 0020 along with this library; see the file COPYING.LIB. If not, write to 0021 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0022 Boston, MA 02110-1301, USA. 0023 */ 0024 0025 #ifndef _CSS_svg_valueimpl_h_ 0026 #define _CSS_svg_valueimpl_h_ 0027 0028 #include <QColor> 0029 #include "css/css_valueimpl.h" 0030 0031 namespace DOM 0032 { 0033 0034 class SVGCSSValueImpl : public CSSValueImpl 0035 { 0036 public: 0037 virtual bool isSVGColor() const 0038 { 0039 return false; 0040 } 0041 virtual bool isSVGPaint() const 0042 { 0043 return false; 0044 } 0045 0046 unsigned short cssValueType() const override 0047 { 0048 return DOM::CSSValue::CSS_SVG_VALUE; 0049 } 0050 }; 0051 0052 class SVGColorImpl : public SVGCSSValueImpl 0053 { 0054 public: 0055 SVGColorImpl(); 0056 SVGColorImpl(const DOMString &rgbColor); 0057 SVGColorImpl(const QColor &c); 0058 SVGColorImpl(unsigned short colorType); 0059 virtual ~SVGColorImpl(); 0060 0061 enum SVGColorType { 0062 SVG_COLORTYPE_UNKNOWN = 0, 0063 SVG_COLORTYPE_RGBCOLOR = 1, 0064 SVG_COLORTYPE_RGBCOLOR_ICCCOLOR = 2, 0065 SVG_COLORTYPE_CURRENTCOLOR = 3 0066 }; 0067 0068 // 'SVGColor' functions 0069 unsigned short colorType() const; 0070 0071 unsigned rgbColor() const; 0072 0073 static QColor colorFromRGBColorString(const DOMString &); 0074 void setRGBColor(const DOMString &rgbColor) 0075 { 0076 int ignored = 0; 0077 setRGBColor(rgbColor, ignored); 0078 } 0079 void setRGBColor(const DOMString &rgbColor, int &); 0080 void setRGBColorICCColor(const DOMString &rgbColor, const DOMString &iccColor, int &); 0081 void setColor(unsigned short colorType, const DOMString &rgbColor, const DOMString &iccColor, int &); 0082 0083 DOMString cssText() const override; 0084 0085 // Helpers 0086 const QColor &color() const; 0087 0088 bool isSVGColor() const override 0089 { 0090 return true; 0091 } 0092 0093 unsigned short cssValueType() const override 0094 { 0095 return DOM::CSSValue::CSS_SVG_VALUE; 0096 } 0097 private: 0098 QColor m_color; 0099 unsigned short m_colorType; 0100 }; 0101 0102 class SVGPaintImpl : public SVGColorImpl 0103 { 0104 public: 0105 enum SVGPaintType { 0106 SVG_PAINTTYPE_UNKNOWN = 0, 0107 SVG_PAINTTYPE_RGBCOLOR = 1, 0108 SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR = 2, 0109 SVG_PAINTTYPE_NONE = 101, 0110 SVG_PAINTTYPE_CURRENTCOLOR = 102, 0111 SVG_PAINTTYPE_URI_NONE = 103, 0112 SVG_PAINTTYPE_URI_CURRENTCOLOR = 104, 0113 SVG_PAINTTYPE_URI_RGBCOLOR = 105, 0114 SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR = 106, 0115 SVG_PAINTTYPE_URI = 107 0116 }; 0117 0118 SVGPaintImpl(); 0119 SVGPaintImpl(const DOMString &uri); 0120 SVGPaintImpl(SVGPaintType); 0121 SVGPaintImpl(SVGPaintType, const DOMString &uri, const DOMString &rgbPaint = DOMString(), const DOMString &iccPaint = DOMString()); 0122 SVGPaintImpl(const QColor &c); 0123 SVGPaintImpl(const DOMString &uri, const QColor &c); 0124 virtual ~SVGPaintImpl(); 0125 0126 // 'SVGPaint' functions 0127 SVGPaintType paintType() const 0128 { 0129 return m_paintType; 0130 } 0131 DOMString uri() const; 0132 0133 void setUri(const DOMString &); 0134 void setPaint(SVGPaintType, const DOMString &uri, const DOMString &rgbPaint, const DOMString &iccPaint, int &); 0135 0136 DOMString cssText() const override; 0137 0138 static SVGPaintImpl *defaultFill(); 0139 static SVGPaintImpl *defaultStroke(); 0140 0141 bool isSVGPaint() const override 0142 { 0143 return true; 0144 } 0145 private: 0146 SVGPaintType m_paintType; 0147 DOMString m_uri; 0148 }; 0149 0150 } // namespace DOM 0151 0152 #endif 0153