• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KHTML

SVGLineElement.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
00003                   2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
00004 
00005     This file is part of the KDE project
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Library General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Library General Public License for more details.
00016 
00017     You should have received a copy of the GNU Library General Public License
00018     along with this library; see the file COPYING.LIB.  If not, write to
00019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020     Boston, MA 02110-1301, USA.
00021 */
00022 
00023 #include "config.h"
00024 #include "wtf/Platform.h"
00025 
00026 #if ENABLE(SVG)
00027 #include "SVGLineElement.h"
00028 
00029 #include "FloatPoint.h"
00030 #include "RenderPath.h"
00031 #include "SVGLength.h"
00032 #include "SVGNames.h"
00033 
00034 namespace WebCore {
00035 
00036 SVGLineElement::SVGLineElement(const QualifiedName& tagName, Document* doc)
00037     : SVGStyledTransformableElement(tagName, doc)
00038     , SVGTests()
00039     , SVGLangSpace()
00040     , SVGExternalResourcesRequired()
00041     , m_x1(this, LengthModeWidth)
00042     , m_y1(this, LengthModeHeight)
00043     , m_x2(this, LengthModeWidth)
00044     , m_y2(this, LengthModeHeight)
00045 {
00046 }
00047 
00048 SVGLineElement::~SVGLineElement()
00049 {
00050 }
00051 
00052 ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, X1, x1, SVGNames::x1Attr, m_x1)
00053 ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, Y1, y1, SVGNames::y1Attr, m_y1)
00054 ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, X2, x2, SVGNames::x2Attr, m_x2)
00055 ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, Y2, y2, SVGNames::y2Attr, m_y2)
00056 
00057 void SVGLineElement::parseMappedAttribute(MappedAttribute* attr)
00058 {
00059     if (attr->name() == SVGNames::x1Attr)
00060         setX1BaseValue(SVGLength(this, LengthModeWidth, attr->value()));
00061     else if (attr->name() == SVGNames::y1Attr)
00062         setY1BaseValue(SVGLength(this, LengthModeHeight, attr->value()));
00063     else if (attr->name() == SVGNames::x2Attr)
00064         setX2BaseValue(SVGLength(this, LengthModeWidth, attr->value()));
00065     else if (attr->name() == SVGNames::y2Attr)
00066         setY2BaseValue(SVGLength(this, LengthModeHeight, attr->value()));
00067     else
00068     {
00069         if (SVGTests::parseMappedAttribute(attr))
00070             return;
00071         if (SVGLangSpace::parseMappedAttribute(attr))
00072             return;
00073         if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
00074             return;
00075         SVGStyledTransformableElement::parseMappedAttribute(attr);
00076     }
00077 }
00078 
00079 void SVGLineElement::svgAttributeChanged(const QualifiedName& attrName)
00080 {
00081     SVGStyledTransformableElement::svgAttributeChanged(attrName);
00082 
00083     if (!renderer())
00084         return;
00085 
00086     if (attrName == SVGNames::x1Attr || attrName == SVGNames::y1Attr ||
00087         attrName == SVGNames::x2Attr || attrName == SVGNames::y2Attr ||
00088         SVGTests::isKnownAttribute(attrName) ||
00089         SVGLangSpace::isKnownAttribute(attrName) ||
00090         SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
00091         SVGStyledTransformableElement::isKnownAttribute(attrName))
00092         renderer()->setNeedsLayout(true);
00093 }
00094 
00095 Path SVGLineElement::toPathData() const
00096 {
00097     return Path::createLine(FloatPoint(x1().value(), y1().value()),
00098                             FloatPoint(x2().value(), y2().value()));
00099 }
00100 
00101 bool SVGLineElement::hasRelativeValues() const
00102 {
00103     return (x1().isRelative() || y1().isRelative() ||
00104             x2().isRelative() || y2().isRelative());
00105 }
00106 
00107 }
00108 
00109 #endif // ENABLE(SVG)

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal