don't discard iframe children.
[kdelibs.git] / khtml / svg / SVGLength.h
blob413411c18df8d6a7734c8df690b5a66e2f50adf4
1 /*
2 Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 2004, 2005, 2006 Rob Buis <buis@kde.org>
5 This file is part of the KDE project
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
23 #ifndef SVGLength_h
24 #define SVGLength_h
26 #if ENABLE(SVG)
28 //#include "PlatformString.h"
29 #include "Document.h"
31 namespace WebCore {
33 class SVGStyledElement;
35 enum SVGLengthType {
36 LengthTypeUnknown = 0,
37 LengthTypeNumber = 1,
38 LengthTypePercentage = 2,
39 LengthTypeEMS = 3,
40 LengthTypeEXS = 4,
41 LengthTypePX = 5,
42 LengthTypeCM = 6,
43 LengthTypeMM = 7,
44 LengthTypeIN = 8,
45 LengthTypePT = 9,
46 LengthTypePC = 10
49 enum SVGLengthMode {
50 LengthModeWidth = 0,
51 LengthModeHeight,
52 LengthModeOther
55 class SVGLength {
56 public:
57 // Forward declare these enums in the w3c naming scheme, for IDL generation
58 enum {
59 SVG_LENGTHTYPE_UNKNOWN = LengthTypeUnknown,
60 SVG_LENGTHTYPE_NUMBER = LengthTypeNumber,
61 SVG_LENGTHTYPE_PERCENTAGE = LengthTypePercentage,
62 SVG_LENGTHTYPE_EMS = LengthTypeEMS,
63 SVG_LENGTHTYPE_EXS = LengthTypeEXS,
64 SVG_LENGTHTYPE_PX = LengthTypePX,
65 SVG_LENGTHTYPE_CM = LengthTypeCM,
66 SVG_LENGTHTYPE_MM = LengthTypeMM,
67 SVG_LENGTHTYPE_IN = LengthTypeIN,
68 SVG_LENGTHTYPE_PT = LengthTypePT,
69 SVG_LENGTHTYPE_PC = LengthTypePC
72 SVGLength(const SVGStyledElement* context = 0, SVGLengthMode mode = LengthModeOther, const String& valueAsString = String());
74 // 'SVGLength' functions
75 SVGLengthType unitType() const;
77 float value() const;
78 void setValue(float);
80 float valueInSpecifiedUnits() const;
81 void setValueInSpecifiedUnits(float);
83 float valueAsPercentage() const;
85 String valueAsString() const;
86 bool setValueAsString(const String&);
88 void newValueSpecifiedUnits(unsigned short, float valueInSpecifiedUnits);
89 void convertToSpecifiedUnits(unsigned short);
91 // Helper functions
92 static float PercentageOfViewport(float value, const SVGStyledElement*, SVGLengthMode);
94 inline bool isRelative() const
96 SVGLengthType type = unitType();
97 return (type == LengthTypePercentage || type == LengthTypeEMS || type == LengthTypeEXS);
100 private:
101 float m_valueInSpecifiedUnits;
102 unsigned int m_unit;
104 const SVGStyledElement* m_context;
107 } // namespace WebCore
109 #endif // ENABLE(SVG)
110 #endif // SVGLength_h
112 // vim:ts=4:noet