3 #include "render_item.h"
5 litehtml::el_text::el_text(const char* text
, const document::ptr
& doc
) : element(doc
)
11 m_use_transformed
= false;
13 css_w().set_display(display_inline_text
);
16 void litehtml::el_text::get_content_size( size
& sz
, int max_width
)
21 void litehtml::el_text::get_text( string
& text
)
26 void litehtml::el_text::compute_styles(bool recursive
)
28 element::ptr el_parent
= parent();
31 css_w().set_line_height(el_parent
->css().get_line_height());
32 css_w().set_font(el_parent
->css().get_font());
33 css_w().set_font_metrics(el_parent
->css().get_font_metrics());
34 css_w().set_white_space(el_parent
->css().get_white_space());
35 css_w().set_text_transform(el_parent
->css().get_text_transform());
37 css_w().set_display(display_inline_text
);
38 css_w().set_float(float_none
);
40 if(m_css
.get_text_transform() != text_transform_none
)
42 m_transformed_text
= m_text
;
43 m_use_transformed
= true;
44 get_document()->container()->transform_text(m_transformed_text
, m_css
.get_text_transform());
47 m_use_transformed
= false;
50 element::ptr p
= parent();
51 while(p
&& p
->css().get_display() == display_inline
)
53 if(p
->css().get_position() == element_position_relative
)
55 css_w().set_offsets(p
->css().get_offsets());
56 css_w().set_position(element_position_relative
);
63 css_w().set_position(element_position_static
);
68 m_transformed_text
= " ";
69 m_use_transformed
= true;
74 m_transformed_text
= " ";
75 m_use_transformed
= true;
77 if(m_text
== "\n" || m_text
== "\r")
79 m_transformed_text
= "";
80 m_use_transformed
= true;
88 font
= el_parent
->css().get_font();
89 fm
= el_parent
->css().get_font_metrics();
91 if(is_break() || !font
)
97 m_size
.height
= fm
.height
;
98 m_size
.width
= get_document()->container()->text_width(m_use_transformed
? m_transformed_text
.c_str() : m_text
.c_str(), font
);
100 m_draw_spaces
= fm
.draw_spaces
;
103 void litehtml::el_text::draw(uint_ptr hdc
, int x
, int y
, const position
*clip
, const std::shared_ptr
<render_item
> &ri
)
105 if(is_white_space() && !m_draw_spaces
)
110 position pos
= ri
->pos();
114 if(pos
.does_intersect(clip
))
116 element::ptr el_parent
= parent();
119 document::ptr doc
= get_document();
121 uint_ptr font
= el_parent
->css().get_font();
124 web_color color
= el_parent
->css().get_color();
125 doc
->container()->draw_text(hdc
, m_use_transformed
? m_transformed_text
.c_str() : m_text
.c_str(), font
,
132 litehtml::string
litehtml::el_text::dump_get_name()
134 return "text: \"" + get_escaped_string(m_text
) + "\"";
137 std::vector
<std::tuple
<litehtml::string
, litehtml::string
>> litehtml::el_text::dump_get_attrs()
139 return std::vector
<std::tuple
<string
, string
>>();