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 SVGPathSegCurvetoCubic_h
     22 #define SVGPathSegCurvetoCubic_h
     23 
     24 #if ENABLE(SVG)
     25 #include "SVGPathSegWithContext.h"
     26 
     27 namespace WebCore {
     28 
     29 class SVGPathSegCurvetoCubic : public SVGPathSegWithContext {
     30 public:
     31     SVGPathSegCurvetoCubic(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x1, float y1, float x2, float y2)
     32         : SVGPathSegWithContext(element, role)
     33         , m_x(x)
     34         , m_y(y)
     35         , m_x1(x1)
     36         , m_y1(y1)
     37         , m_x2(x2)
     38         , m_y2(y2)
     39     {
     40     }
     41 
     42     float x() const { return m_x; }
     43     void setX(float x)
     44     {
     45         m_x = x;
     46         commitChange();
     47     }
     48 
     49     float y() const { return m_y; }
     50     void setY(float y)
     51     {
     52         m_y = y;
     53         commitChange();
     54     }
     55 
     56     float x1() const { return m_x1; }
     57     void setX1(float x1)
     58     {
     59         m_x1 = x1;
     60         commitChange();
     61     }
     62 
     63     float y1() const { return m_y1; }
     64     void setY1(float y1)
     65     {
     66         m_y1 = y1;
     67         commitChange();
     68     }
     69 
     70     float x2() const { return m_x2; }
     71     void setX2(float x2)
     72     {
     73         m_x2 = x2;
     74         commitChange();
     75     }
     76 
     77     float y2() const { return m_y2; }
     78     void setY2(float y2)
     79     {
     80         m_y2 = y2;
     81         commitChange();
     82     }
     83 
     84 private:
     85     float m_x;
     86     float m_y;
     87     float m_x1;
     88     float m_y1;
     89     float m_x2;
     90     float m_y2;
     91 };
     92 
     93 class SVGPathSegCurvetoCubicAbs : public SVGPathSegCurvetoCubic {
     94 public:
     95     static PassRefPtr<SVGPathSegCurvetoCubicAbs> create(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x1, float y1, float x2, float y2)
     96     {
     97         return adoptRef(new SVGPathSegCurvetoCubicAbs(element, role, x, y, x1, y1, x2, y2));
     98     }
     99 
    100 private:
    101     SVGPathSegCurvetoCubicAbs(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x1, float y1, float x2, float y2)
    102         : SVGPathSegCurvetoCubic(element, role, x, y, x1, y1, x2, y2)
    103     {
    104     }
    105 
    106     virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_ABS; }
    107     virtual String pathSegTypeAsLetter() const { return "C"; }
    108 };
    109 
    110 class SVGPathSegCurvetoCubicRel : public SVGPathSegCurvetoCubic {
    111 public:
    112     static PassRefPtr<SVGPathSegCurvetoCubicRel> create(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x1, float y1, float x2, float y2)
    113     {
    114         return adoptRef(new SVGPathSegCurvetoCubicRel(element, role, x, y, x1, y1, x2, y2));
    115     }
    116 
    117 private:
    118     SVGPathSegCurvetoCubicRel(SVGPathElement* element, SVGPathSegRole role, float x, float y, float x1, float y1, float x2, float y2)
    119         : SVGPathSegCurvetoCubic(element, role, x, y, x1, y1, x2, y2)
    120     {
    121     }
    122 
    123     virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_REL; }
    124     virtual String pathSegTypeAsLetter() const { return "c"; }
    125 };
    126 
    127 } // namespace WebCore
    128 
    129 #endif // ENABLE(SVG)
    130 #endif
    131