1/*
2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006 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 SVGComponentTransferFunctionElement_h
22#define SVGComponentTransferFunctionElement_h
23
24#if ENABLE(SVG) && ENABLE(FILTERS)
25#include "FEComponentTransfer.h"
26#include "SVGAnimatedEnumeration.h"
27#include "SVGAnimatedNumber.h"
28#include "SVGAnimatedNumberList.h"
29
30namespace WebCore {
31
32template<>
33struct SVGPropertyTraits<ComponentTransferType> {
34    static unsigned highestEnumValue() { return FECOMPONENTTRANSFER_TYPE_GAMMA; }
35
36    static String toString(ComponentTransferType type)
37    {
38        switch (type) {
39        case FECOMPONENTTRANSFER_TYPE_UNKNOWN:
40            return emptyString();
41        case FECOMPONENTTRANSFER_TYPE_IDENTITY:
42            return "identity";
43        case FECOMPONENTTRANSFER_TYPE_TABLE:
44            return "table";
45        case FECOMPONENTTRANSFER_TYPE_DISCRETE:
46            return "discrete";
47        case FECOMPONENTTRANSFER_TYPE_LINEAR:
48            return "linear";
49        case FECOMPONENTTRANSFER_TYPE_GAMMA:
50            return "gamma";
51        }
52
53        ASSERT_NOT_REACHED();
54        return emptyString();
55    }
56
57    static ComponentTransferType fromString(const String& value)
58    {
59        if (value == "identity")
60            return FECOMPONENTTRANSFER_TYPE_IDENTITY;
61        if (value == "table")
62            return FECOMPONENTTRANSFER_TYPE_TABLE;
63        if (value == "discrete")
64            return FECOMPONENTTRANSFER_TYPE_DISCRETE;
65        if (value == "linear")
66            return FECOMPONENTTRANSFER_TYPE_LINEAR;
67        if (value == "gamma")
68            return FECOMPONENTTRANSFER_TYPE_GAMMA;
69        return FECOMPONENTTRANSFER_TYPE_UNKNOWN;
70    }
71};
72
73class SVGComponentTransferFunctionElement : public SVGElement {
74public:
75    ComponentTransferFunction transferFunction() const;
76
77protected:
78    SVGComponentTransferFunctionElement(const QualifiedName&, Document*);
79
80    bool isSupportedAttribute(const QualifiedName&);
81    virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
82    virtual void svgAttributeChanged(const QualifiedName&);
83
84private:
85    BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGComponentTransferFunctionElement)
86        DECLARE_ANIMATED_ENUMERATION(Type, type, ComponentTransferType)
87        DECLARE_ANIMATED_NUMBER_LIST(TableValues, tableValues)
88        DECLARE_ANIMATED_NUMBER(Slope, slope)
89        DECLARE_ANIMATED_NUMBER(Intercept, intercept)
90        DECLARE_ANIMATED_NUMBER(Amplitude, amplitude)
91        DECLARE_ANIMATED_NUMBER(Exponent, exponent)
92        DECLARE_ANIMATED_NUMBER(Offset, offset)
93    END_DECLARE_ANIMATED_PROPERTIES
94};
95
96} // namespace WebCore
97
98#endif // ENABLE(SVG) && ENABLE(FILTERS)
99#endif
100