1 #ifndef LH_CSS_LENGTH_H
2 #define LH_CSS_LENGTH_H
19 css_length(float val
, css_units units
= css_units_px
);
20 css_length
& operator=(float val
);
22 bool is_predefined() const;
25 static css_length
predef_value(int val
= 0);
26 void set_value(float val
, css_units units
);
28 css_units
units() const;
29 int calc_percent(int width
) const;
30 void fromString(const string
& str
, const string
& predefs
= "", int defValue
= 0);
31 static css_length
from_string(const string
& str
, const string
& predefs
= "", int defValue
= 0);
32 string
to_string() const;
35 using length_vector
= std::vector
<css_length
>;
39 inline css_length::css_length()
43 m_units
= css_units_none
;
44 m_is_predefined
= false;
47 inline css_length::css_length(float val
, css_units units
)
51 m_is_predefined
= false;
54 inline css_length
& css_length::operator=(float val
)
57 m_units
= css_units_px
;
58 m_is_predefined
= false;
62 inline bool css_length::is_predefined() const
64 return m_is_predefined
;
67 inline void css_length::predef(int val
)
70 m_is_predefined
= true;
73 inline int css_length::predef() const
82 inline void css_length::set_value(float val
, css_units units
)
85 m_is_predefined
= false;
89 inline float css_length::val() const
98 inline css_units
css_length::units() const
103 inline int css_length::calc_percent(int width
) const
107 if(units() == css_units_percentage
)
109 return (int) ((double) width
* (double) m_value
/ 100.0);
119 #endif // LH_CSS_LENGTH_H