AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
SVGLength.hpp
1/*
2Copyright (C) 2025,2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGUI_SVGLENGTH_HPP
17#define AEONGUI_SVGLENGTH_HPP
18
19#include "DOMString.hpp"
20#include "aeongui/Platform.hpp"
21
22namespace AeonGUI
23{
24 namespace DOM
25 {
27 enum class SVGLengthType
28 {
29 UNKNOWN = 0,
30 NUMBER = 1,
31 PERCENTAGE = 2,
32 EMS = 3,
33 EXS = 4,
34 PX = 5,
35 CM = 6,
36 MM = 7,
37 IN = 8,
38 PT = 9,
39 PC = 10
40 };
41
47 class DLL SVGLength
48 {
49 public:
56 SVGLengthType unitType() const;
57
60 float value() const;
64 float value ( float value );
65
68 const DOMString& valueAsString() const;
72 const DOMString& valueAsString ( const DOMString& value );
73
76 float valueInSpecifiedUnits() const;
80 float valueInSpecifiedUnits ( float value );
81
84 void convertToSpecifiedUnits ( SVGLengthType unitType );
85
89 void newValueSpecifiedUnits ( SVGLengthType unitType, float valueInSpecifiedUnits );
90 private:
91 void UpdateValueAsString();
92 SVGLengthType mUnitType{SVGLengthType::UNKNOWN};
93 float mValue{};
94 float mValueInSpecifiedUnits{};
96 DOMString mValueAsString{};
98 };
99 }
100}
101#endif
Platform-specific DLL import/export macros and compiler helpers.
#define PRIVATE_TEMPLATE_MEMBERS_END
Restore warnings after PRIVATE_TEMPLATE_MEMBERS_START.
Definition Platform.hpp:49
#define PRIVATE_TEMPLATE_MEMBERS_START
Suppress MSVC C4251 warnings for private template data members.
Definition Platform.hpp:48
float valueInSpecifiedUnits() const
The value as a floating point value, in the units expressed by unitType.
Definition SVGLength.cpp:98
void convertToSpecifiedUnits(SVGLengthType unitType)
Preserve the same underlying stored value, but reset the stored unit identifier to the given unitType...
Definition SVGLength.cpp:109
const DOMString & valueAsString() const
The value as a string value, in the units expressed by unitType.
Definition SVGLength.cpp:76
SVGLength()
Default constructor.
SVGLengthType unitType() const
The type of the length. One of the SVGLengthType constants.
Definition SVGLength.cpp:60
void newValueSpecifiedUnits(SVGLengthType unitType, float valueInSpecifiedUnits)
Reset the value as a number with an associated unitType, thereby replacing the values for all of the ...
Definition SVGLength.cpp:182
float value() const
The value as a floating point value, in user units.
Definition SVGLength.cpp:65