WebCore/svg/SVGPathSeg.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2     Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
       
     3                   2004, 2005, 2006, 2008 Rob Buis <buis@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 SVGPathSeg_h
       
    22 #define SVGPathSeg_h
       
    23 
       
    24 #if ENABLE(SVG)
       
    25 #include "PlatformString.h"
       
    26 #include "SVGNames.h"
       
    27 
       
    28 #include <wtf/RefCounted.h>
       
    29 
       
    30 namespace WebCore {
       
    31     class SVGPathElement;
       
    32     class SVGStyledElement;
       
    33 
       
    34     class SVGPathSeg : public RefCounted<SVGPathSeg> {
       
    35     public:
       
    36         virtual ~SVGPathSeg() { }
       
    37 
       
    38         enum SVGPathSegType {
       
    39             PATHSEG_UNKNOWN                         = 0,
       
    40             PATHSEG_CLOSEPATH                       = 1,
       
    41             PATHSEG_MOVETO_ABS                      = 2,
       
    42             PATHSEG_MOVETO_REL                      = 3,
       
    43             PATHSEG_LINETO_ABS                      = 4,
       
    44             PATHSEG_LINETO_REL                      = 5,
       
    45             PATHSEG_CURVETO_CUBIC_ABS               = 6,
       
    46             PATHSEG_CURVETO_CUBIC_REL               = 7,
       
    47             PATHSEG_CURVETO_QUADRATIC_ABS           = 8,
       
    48             PATHSEG_CURVETO_QUADRATIC_REL           = 9,
       
    49             PATHSEG_ARC_ABS                         = 10,
       
    50             PATHSEG_ARC_REL                         = 11,
       
    51             PATHSEG_LINETO_HORIZONTAL_ABS           = 12,
       
    52             PATHSEG_LINETO_HORIZONTAL_REL           = 13,
       
    53             PATHSEG_LINETO_VERTICAL_ABS             = 14,
       
    54             PATHSEG_LINETO_VERTICAL_REL             = 15,
       
    55             PATHSEG_CURVETO_CUBIC_SMOOTH_ABS        = 16,
       
    56             PATHSEG_CURVETO_CUBIC_SMOOTH_REL        = 17,
       
    57             PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS    = 18,
       
    58             PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL    = 19
       
    59         };
       
    60 
       
    61         virtual unsigned short pathSegType() const { return PATHSEG_UNKNOWN; }
       
    62         virtual String pathSegTypeAsLetter() const { return ""; }
       
    63         virtual String toString() const { return ""; }
       
    64 
       
    65         const QualifiedName& associatedAttributeName() const { return SVGNames::dAttr; }
       
    66         
       
    67     protected:
       
    68         SVGPathSeg() { }
       
    69     };
       
    70 
       
    71     class SVGPathSegSingleCoord : public SVGPathSeg { 
       
    72     public:
       
    73         SVGPathSegSingleCoord(float x, float y)
       
    74         : SVGPathSeg() , m_x(x) , m_y(y) {}
       
    75 
       
    76         void setX(float x) { m_x = x; }
       
    77         float x() const { return m_x; }
       
    78 
       
    79         void setY(float y) { m_y = y; }
       
    80         float y() const { return m_y; }
       
    81 
       
    82         virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg %.6lg", m_x, m_y); }
       
    83 
       
    84     private:
       
    85         float m_x;
       
    86         float m_y;
       
    87     };
       
    88 
       
    89 
       
    90 } // namespace WebCore
       
    91 
       
    92 #endif // ENABLE(SVG)
       
    93 #endif