Home | History | Annotate | Download | only in svg
      1 /*
      2     Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann (at) kde.org>
      3                   2004, 2005, 2006 Rob Buis <buis (at) kde.org>
      4 
      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.
      9 
     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.
     14 
     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.
     19 */
     20 
     21 #ifndef SVGMarkerElement_h
     22 #define SVGMarkerElement_h
     23 
     24 #if ENABLE(SVG)
     25 #include "RenderObject.h"
     26 #include "SVGAngle.h"
     27 #include "SVGExternalResourcesRequired.h"
     28 #include "SVGFitToViewBox.h"
     29 #include "SVGLangSpace.h"
     30 #include "SVGResourceMarker.h"
     31 #include "SVGStyledElement.h"
     32 
     33 namespace WebCore {
     34 
     35     class Document;
     36 
     37     extern char SVGOrientTypeAttrIdentifier[];
     38     extern char SVGOrientAngleAttrIdentifier[];
     39 
     40     class SVGMarkerElement : public SVGStyledElement,
     41                              public SVGLangSpace,
     42                              public SVGExternalResourcesRequired,
     43                              public SVGFitToViewBox {
     44     public:
     45         enum SVGMarkerUnitsType {
     46             SVG_MARKERUNITS_UNKNOWN           = 0,
     47             SVG_MARKERUNITS_USERSPACEONUSE    = 1,
     48             SVG_MARKERUNITS_STROKEWIDTH       = 2
     49         };
     50 
     51         enum SVGMarkerOrientType {
     52             SVG_MARKER_ORIENT_UNKNOWN    = 0,
     53             SVG_MARKER_ORIENT_AUTO       = 1,
     54             SVG_MARKER_ORIENT_ANGLE      = 2
     55         };
     56 
     57         SVGMarkerElement(const QualifiedName&, Document*);
     58         virtual ~SVGMarkerElement();
     59 
     60         AffineTransform viewBoxToViewTransform(float viewWidth, float viewHeight) const;
     61 
     62         void setOrientToAuto();
     63         void setOrientToAngle(const SVGAngle&);
     64 
     65         virtual void parseMappedAttribute(MappedAttribute*);
     66         virtual void svgAttributeChanged(const QualifiedName&);
     67         virtual void synchronizeProperty(const QualifiedName&);
     68         virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
     69 
     70         virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
     71         virtual SVGResource* canvasResource(const RenderObject*);
     72 
     73     private:
     74         DECLARE_ANIMATED_PROPERTY(SVGMarkerElement, SVGNames::refXAttr, SVGLength, RefX, refX)
     75         DECLARE_ANIMATED_PROPERTY(SVGMarkerElement, SVGNames::refYAttr, SVGLength, RefY, refY)
     76         DECLARE_ANIMATED_PROPERTY(SVGMarkerElement, SVGNames::markerWidthAttr, SVGLength, MarkerWidth, markerWidth)
     77         DECLARE_ANIMATED_PROPERTY(SVGMarkerElement, SVGNames::markerHeightAttr, SVGLength, MarkerHeight, markerHeight)
     78         DECLARE_ANIMATED_PROPERTY(SVGMarkerElement, SVGNames::markerUnitsAttr, int, MarkerUnits, markerUnits)
     79         DECLARE_ANIMATED_PROPERTY_MULTIPLE_WRAPPERS(SVGMarkerElement, SVGNames::orientAttr, SVGOrientTypeAttrIdentifier, int, OrientType, orientType)
     80         DECLARE_ANIMATED_PROPERTY_MULTIPLE_WRAPPERS(SVGMarkerElement, SVGNames::orientAttr, SVGOrientAngleAttrIdentifier, SVGAngle, OrientAngle, orientAngle)
     81 
     82         // SVGExternalResourcesRequired
     83         DECLARE_ANIMATED_PROPERTY(SVGMarkerElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired)
     84 
     85         // SVGFitToViewBox
     86         DECLARE_ANIMATED_PROPERTY(SVGMarkerElement, SVGNames::viewBoxAttr, FloatRect, ViewBox, viewBox)
     87         DECLARE_ANIMATED_PROPERTY(SVGMarkerElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio)
     88 
     89         RefPtr<SVGResourceMarker> m_marker;
     90     };
     91 
     92 } // namespace WebCore
     93 
     94 #endif // ENABLE(SVG)
     95 #endif
     96