PDA

View Full Version : any solution to insert html into clanlib app?



kyelin
12-25-2014, 02:50 PM
How to inert htmlview (or richedit) into clanlib?
for the htmlweb, clanlib's test have an example "WebBrowser", but just do the simple display.
Need i have to Improve as this?

Sorry for truble again;:o

Judas
12-26-2014, 06:49 AM
There is currently not any way to display HTML directly with ClanLib.

Rich text functionality can to some extent be done using either SpanLayout (clanDisplay) or SpanLayoutView (clanUI). Each of them allows you to create inline elements with more complex formatting. To simulate div (p, h1-h7, ul, li, etc) blocks you'd have to add some margin between the span layouts.

For example with clanUI:



class RichText : public clan::View
{
public:
RichText()
{
box_style.set_layout_block();

TextStyle h1_style;
h1_style.set_font_family("Verdana", 14.0f, 18.0f);
h1_style.set_weight_bold();

TextStyle p_style;
p_style.set_font_family("Tahoma", 11.0f, 14.0f);

TextStyle p_bold_style;
p_bold_style.set_font_family("Tahoma", 11.0f, 14.0f);
p_bold_style.set_weight_bold();

auto h1 = std::make_shared<SpanLayoutView>();
h1.box_style.set_margin(0.0f, 15.0f, 0.0f, 10.0f);
h1.add_text("Rich text example", h1_style);
add_subview(h1);

auto p1 = std::make_shared<SpanLayoutView>();
p1.box_style.set_margin(0.0f, 5.0f);
p1.add_text("This is a long tale about a rich text example blah blah blah", p_style);
add_subview(p1);

auto p2 = std::make_shared<SpanLayoutView>();
p2.box_style.set_margin(0.0f, 5.0f);
p2.add_text("A second paragraph where we type ", p_style);
p2.add_text("even more", p_bold_style);
p2.add_text("stuff!", p_style);
add_subview(p2);
}
}