Home | History | Annotate | Download | only in svg
      1 /*
      2  * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann (at) kde.org>
      3  * Copyright (C) 2004, 2005, 2006, 2008 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 SVGPathSegArc_h
     22 #define SVGPathSegArc_h
     23 
     24 #if ENABLE(SVG)
     25 #include "SVGPathSegWithContext.h"
     26 
     27 namespace WebCore {
     28 
     29 class SVGPathSegArc : public SVGPathSegWithContext {
     30 public:
     31     SVGPathSegArc(SVGPathElement* element, SVGPathSegRole role, float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
     32         : SVGPathSegWithContext(element, role)
     33         , m_x(x)
     34         , m_y(y)
     35         , m_r1(r1)
     36         , m_r2(r2)
     37         , m_angle(angle)
     38         , m_largeArcFlag(largeArcFlag)
     39         , m_sweepFlag(sweepFlag)
     40     {
     41     }
     42 
     43     float x() const { return m_x; }
     44     void setX(float x)
     45     {
     46         m_x = x;
     47         commitChange();
     48     }
     49 
     50     float y() const { return m_y; }
     51     void setY(float y)
     52     {
     53         m_y = y;
     54         commitChange();
     55     }
     56 
     57     float r1() const { return m_r1; }
     58     void setR1(float r1)
     59     {
     60         m_r1 = r1;
     61         commitChange();
     62     }
     63 
     64     float r2() const { return m_r2; }
     65     void setR2(float r2)
     66     {
     67         m_r2 = r2;
     68         commitChange();
     69     }
     70 
     71     float angle() const { return m_angle; }
     72     void setAngle(float angle)
     73     {
     74         m_angle = angle;
     75         commitChange();
     76     }
     77 
     78     bool largeArcFlag() const { return m_largeArcFlag; }
     79     void setLargeArcFlag(bool largeArcFlag)
     80     {
     81         m_largeArcFlag = largeArcFlag;
     82         commitChange();
     83     }
     84 
     85     bool sweepFlag() const { return m_sweepFlag; }
     86     void setSweepFlag(bool sweepFlag)
     87     {
     88         m_sweepFlag = sweepFlag;
     89         commitChange();
     90     }
     91 
     92 private:
     93     float m_x;
     94     float m_y;
     95     float m_r1;
     96     float m_r2;
     97     float m_angle;
     98 
     99     bool m_largeArcFlag : 1;
    100     bool m_sweepFlag : 1;
    101 };
    102 
    103 class SVGPathSegArcAbs : public SVGPathSegArc {
    104 public:
    105     static PassRefPtr<SVGPathSegArcAbs> create(SVGPathElement* element, SVGPathSegRole role, float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
    106     {
    107         return adoptRef(new SVGPathSegArcAbs(element, role, x, y, r1, r2, angle, largeArcFlag, sweepFlag));
    108     }
    109 
    110 private:
    111     SVGPathSegArcAbs(SVGPathElement* element, SVGPathSegRole role, float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
    112         : SVGPathSegArc(element, role, x, y, r1, r2, angle, largeArcFlag, sweepFlag)
    113     {
    114     }
    115 
    116     virtual unsigned short pathSegType() const { return PATHSEG_ARC_ABS; }
    117     virtual String pathSegTypeAsLetter() const { return "A"; }
    118 };
    119 
    120 class SVGPathSegArcRel : public SVGPathSegArc {
    121 public:
    122     static PassRefPtr<SVGPathSegArcRel> create(SVGPathElement* element, SVGPathSegRole role, float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
    123     {
    124         return adoptRef(new SVGPathSegArcRel(element, role, x, y, r1, r2, angle, largeArcFlag, sweepFlag));
    125     }
    126 
    127 private:
    128     SVGPathSegArcRel(SVGPathElement* element, SVGPathSegRole role, float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
    129         : SVGPathSegArc(element, role, x, y, r1, r2, angle, largeArcFlag, sweepFlag)
    130     {
    131     }
    132 
    133     virtual unsigned short pathSegType() const { return PATHSEG_ARC_REL; }
    134     virtual String pathSegTypeAsLetter() const { return "a"; }
    135 };
    136 
    137 } // namespace WebCore
    138 
    139 #endif // ENABLE(SVG)
    140 #endif
    141