Download
Documentation
Development
Examples
Donations
Contributions
Forum
Main Page
Related Pages
Modules
Classes
Sources
API
CSSLayout
CSSDocument
css_length.h
1
/*
2
** ClanLib SDK
3
** Copyright (c) 1997-2013 The ClanLib Team
4
**
5
** This software is provided 'as-is', without any express or implied
6
** warranty. In no event will the authors be held liable for any damages
7
** arising from the use of this software.
8
**
9
** Permission is granted to anyone to use this software for any purpose,
10
** including commercial applications, and to alter it and redistribute it
11
** freely, subject to the following restrictions:
12
**
13
** 1. The origin of this software must not be misrepresented; you must not
14
** claim that you wrote the original software. If you use this software
15
** in a product, an acknowledgment in the product documentation would be
16
** appreciated but is not required.
17
** 2. Altered source versions must be plainly marked as such, and must not be
18
** misrepresented as being the original software.
19
** 3. This notice may not be removed or altered from any source distribution.
20
**
21
** Note: Some of the libraries ClanLib may link to may have additional
22
** requirements or restrictions.
23
**
24
** File Author(s):
25
**
26
** Magnus Norddahl
27
*/
28
29
#pragma once
30
31
#include "../../Core/Text/string_help.h"
32
33
namespace
clan
34
{
37
38
class
CSSLength
39
{
40
public
:
41
enum
Type
42
{
43
type_mm
,
44
type_cm
,
45
type_in
,
46
type_pt
,
47
type_pc
,
48
type_px
,
49
type_em
,
50
type_ex
,
51
type_computed_px
52
};
53
54
CSSLength
()
55
:
type
(
type_px
),
value
(0.0f)
56
{
57
}
58
59
CSSLength
(
float
value
,
Type
type
)
60
: type(type), value(value)
61
{
62
}
63
64
std::string
to_string
()
const
65
{
66
if
(
value
== 0.0f)
67
return
"0"
;
68
std::string v =
StringHelp::float_to_text
(
value
);
69
switch
(
type
)
70
{
71
default
:
72
case
type_mm
:
73
return
v +
"mm"
;
74
case
type_cm
:
75
return
v +
"cm"
;
76
case
type_in
:
77
return
v +
"in"
;
78
case
type_pt
:
79
return
v +
"pt"
;
80
case
type_pc
:
81
return
v +
"pc"
;
82
case
type_px
:
83
return
v +
"px"
;
84
case
type_em
:
85
return
v +
"em"
;
86
case
type_ex
:
87
return
v +
"ex"
;
88
case
type_computed_px
:
89
return
v +
"computed-px"
;
90
}
91
}
92
93
Type
type
;
94
float
value
;
95
};
96
98
}
clan::CSSLength::type
Type type
Definition:
css_length.h:93
clan::CSSLength::type_in
Definition:
css_length.h:45
clan::CSSLength::type_mm
Definition:
css_length.h:43
clan::StringHelp::float_to_text
static std::string float_to_text(float value, int num_decimal_places=6)
Float to text.
clan::CSSLength::type_pc
Definition:
css_length.h:47
clan::CSSLength::to_string
std::string to_string() const
Definition:
css_length.h:64
clan::CSSLength::Type
Type
Definition:
css_length.h:41
clan::CSSLength::type_ex
Definition:
css_length.h:50
clan::CSSLength::type_computed_px
Definition:
css_length.h:51
clan::CSSLength::type_em
Definition:
css_length.h:49
clan::CSSLength::type_px
Definition:
css_length.h:48
clan::CSSLength::CSSLength
CSSLength()
Definition:
css_length.h:54
clan::CSSLength
Definition:
css_length.h:38
clan::CSSLength::value
float value
Definition:
css_length.h:94
clan::CSSLength::type_cm
Definition:
css_length.h:44
clan::CSSLength::type_pt
Definition:
css_length.h:46
clan::CSSLength::CSSLength
CSSLength(float value, Type type)
Definition:
css_length.h:59