1 /* 2 Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@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 #ifndef SVGPathElement_h 24 #define SVGPathElement_h 25 26 #if ENABLE(SVG) 27 #include "SVGAnimatedPathData.h" 28 #include "SVGExternalResourcesRequired.h" 29 #include "SVGLangSpace.h" 30 #include "SVGStyledTransformableElement.h" 31 #include "SVGTests.h" 32 33 namespace WebCore { 34 35 class SVGPathSeg; 36 class SVGPathSegArcAbs; 37 class SVGPathSegArcRel; 38 class SVGPathSegClosePath; 39 class SVGPathSegLinetoAbs; 40 class SVGPathSegLinetoRel; 41 class SVGPathSegMovetoAbs; 42 class SVGPathSegMovetoRel; 43 class SVGPathSegCurvetoCubicAbs; 44 class SVGPathSegCurvetoCubicRel; 45 class SVGPathSegLinetoVerticalAbs; 46 class SVGPathSegLinetoVerticalRel; 47 class SVGPathSegLinetoHorizontalAbs; 48 class SVGPathSegLinetoHorizontalRel; 49 class SVGPathSegCurvetoQuadraticAbs; 50 class SVGPathSegCurvetoQuadraticRel; 51 class SVGPathSegCurvetoCubicSmoothAbs; 52 class SVGPathSegCurvetoCubicSmoothRel; 53 class SVGPathSegCurvetoQuadraticSmoothAbs; 54 class SVGPathSegCurvetoQuadraticSmoothRel; 55 class SVGPathElement : public SVGStyledTransformableElement, 56 public SVGTests, 57 public SVGLangSpace, 58 public SVGExternalResourcesRequired, 59 public SVGAnimatedPathData { 60 public: 61 SVGPathElement(const QualifiedName&, Document*); 62 virtual ~SVGPathElement(); 63 isValid()64 virtual bool isValid() const { return SVGTests::isValid(); } 65 float getTotalLength(); 66 FloatPoint getPointAtLength(float distance); 67 unsigned long getPathSegAtLength(float distance); 68 69 static PassRefPtr<SVGPathSegClosePath> createSVGPathSegClosePath(); 70 static PassRefPtr<SVGPathSegMovetoAbs> createSVGPathSegMovetoAbs(float x, float y); 71 static PassRefPtr<SVGPathSegMovetoRel> createSVGPathSegMovetoRel(float x, float y); 72 static PassRefPtr<SVGPathSegLinetoAbs> createSVGPathSegLinetoAbs(float x, float y); 73 static PassRefPtr<SVGPathSegLinetoRel> createSVGPathSegLinetoRel(float x, float y); 74 static PassRefPtr<SVGPathSegCurvetoCubicAbs> createSVGPathSegCurvetoCubicAbs(float x, float y, float x1, float y1, float x2, float y2); 75 static PassRefPtr<SVGPathSegCurvetoCubicRel> createSVGPathSegCurvetoCubicRel(float x, float y, float x1, float y1, float x2, float y2); 76 static PassRefPtr<SVGPathSegCurvetoQuadraticAbs> createSVGPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1); 77 static PassRefPtr<SVGPathSegCurvetoQuadraticRel> createSVGPathSegCurvetoQuadraticRel(float x, float y, float x1, float y1); 78 static PassRefPtr<SVGPathSegArcAbs> createSVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag); 79 static PassRefPtr<SVGPathSegArcRel> createSVGPathSegArcRel(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag); 80 static PassRefPtr<SVGPathSegLinetoHorizontalAbs> createSVGPathSegLinetoHorizontalAbs(float x); 81 static PassRefPtr<SVGPathSegLinetoHorizontalRel> createSVGPathSegLinetoHorizontalRel(float x); 82 static PassRefPtr<SVGPathSegLinetoVerticalAbs> createSVGPathSegLinetoVerticalAbs(float y); 83 static PassRefPtr<SVGPathSegLinetoVerticalRel> createSVGPathSegLinetoVerticalRel(float y); 84 static PassRefPtr<SVGPathSegCurvetoCubicSmoothAbs> createSVGPathSegCurvetoCubicSmoothAbs(float x, float y, float x2, float y2); 85 static PassRefPtr<SVGPathSegCurvetoCubicSmoothRel> createSVGPathSegCurvetoCubicSmoothRel(float x, float y, float x2, float y2); 86 static PassRefPtr<SVGPathSegCurvetoQuadraticSmoothAbs> createSVGPathSegCurvetoQuadraticSmoothAbs(float x, float y); 87 static PassRefPtr<SVGPathSegCurvetoQuadraticSmoothRel> createSVGPathSegCurvetoQuadraticSmoothRel(float x, float y); 88 89 // Derived from: 'SVGAnimatedPathData' 90 virtual SVGPathSegList* pathSegList() const; 91 virtual SVGPathSegList* normalizedPathSegList() const; 92 virtual SVGPathSegList* animatedPathSegList() const; 93 virtual SVGPathSegList* animatedNormalizedPathSegList() const; 94 95 virtual void parseMappedAttribute(MappedAttribute*); 96 virtual void svgAttributeChanged(const QualifiedName&); 97 98 virtual Path toPathData() const; 99 supportsMarkers()100 virtual bool supportsMarkers() const { return true; } 101 102 protected: contextElement()103 virtual const SVGElement* contextElement() const { return this; } 104 105 private: 106 mutable RefPtr<SVGPathSegList> m_pathSegList; 107 108 ANIMATED_PROPERTY_DECLARATIONS(SVGPathElement, SVGNames::pathTagString, SVGNames::pathLengthAttrString, float, PathLength, pathLength) 109 }; 110 111 } // namespace WebCore 112 113 #endif // ENABLE(SVG) 114 #endif 115