KHtml

SVGLength.h
1 /*
2  Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <[email protected]>
3  2004, 2005, 2006 Rob Buis <[email protected]>
4 
5  This file is part of the KDE project
6 
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.
11 
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.
16 
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.
21 */
22 
23 #ifndef SVGLength_h
24 #define SVGLength_h
25 
26 #if ENABLE(SVG)
27 
28 //#include "PlatformString.h"
29 #include "Document.h"
30 
31 namespace WebCore
32 {
33 
34 class SVGStyledElement;
35 
36 enum SVGLengthType {
37  LengthTypeUnknown = 0,
38  LengthTypeNumber = 1,
39  LengthTypePercentage = 2,
40  LengthTypeEMS = 3,
41  LengthTypeEXS = 4,
42  LengthTypePX = 5,
43  LengthTypeCM = 6,
44  LengthTypeMM = 7,
45  LengthTypeIN = 8,
46  LengthTypePT = 9,
47  LengthTypePC = 10
48 };
49 
50 enum SVGLengthMode {
51  LengthModeWidth = 0,
52  LengthModeHeight,
53  LengthModeOther
54 };
55 
56 class SVGLength
57 {
58 public:
59  // Forward declare these enums in the w3c naming scheme, for IDL generation
60  enum {
61  SVG_LENGTHTYPE_UNKNOWN = LengthTypeUnknown,
62  SVG_LENGTHTYPE_NUMBER = LengthTypeNumber,
63  SVG_LENGTHTYPE_PERCENTAGE = LengthTypePercentage,
64  SVG_LENGTHTYPE_EMS = LengthTypeEMS,
65  SVG_LENGTHTYPE_EXS = LengthTypeEXS,
66  SVG_LENGTHTYPE_PX = LengthTypePX,
67  SVG_LENGTHTYPE_CM = LengthTypeCM,
68  SVG_LENGTHTYPE_MM = LengthTypeMM,
69  SVG_LENGTHTYPE_IN = LengthTypeIN,
70  SVG_LENGTHTYPE_PT = LengthTypePT,
71  SVG_LENGTHTYPE_PC = LengthTypePC
72  };
73 
74  SVGLength(const SVGStyledElement *context = nullptr, SVGLengthMode mode = LengthModeOther, const String &valueAsString = String());
75 
76  // 'SVGLength' functions
77  SVGLengthType unitType() const;
78 
79  float value() const;
80  void setValue(float);
81 
82  float valueInSpecifiedUnits() const;
83  void setValueInSpecifiedUnits(float);
84 
85  float valueAsPercentage() const;
86 
87  String valueAsString() const;
88  bool setValueAsString(const String &);
89 
90  void newValueSpecifiedUnits(unsigned short, float valueInSpecifiedUnits);
91  void convertToSpecifiedUnits(unsigned short);
92 
93  // Helper functions
94  static float PercentageOfViewport(float value, const SVGStyledElement *, SVGLengthMode);
95 
96  inline bool isRelative() const
97  {
98  SVGLengthType type = unitType();
99  return (type == LengthTypePercentage || type == LengthTypeEMS || type == LengthTypeEXS);
100  }
101 
102 private:
103  float m_valueInSpecifiedUnits;
104  unsigned int m_unit;
105 
106  const SVGStyledElement *m_context;
107 };
108 
109 } // namespace WebCore
110 
111 #endif // ENABLE(SVG)
112 #endif // SVGLength_h
113 
Type type(const QSqlDatabase &db)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.