Results 1 to 2 of 2

Thread: any solution to insert html into clanlib app?

  1. #1

    Default any solution to insert html into clanlib app?

    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;
    Last edited by kyelin; 12-26-2014 at 06:44 AM.

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    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:

    Code:
    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);
      }
    }

Similar Threads

  1. Replies: 4
    Last Post: 03-24-2014, 04:13 AM
  2. make html no ClanLib/core.h
    By bvanevery in forum Official ClanLib SDK Forums
    Replies: 10
    Last Post: 04-04-2013, 09:51 PM
  3. Default Active Solution in ClanLib 0.9
    By rombust in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 02-01-2009, 03:49 AM
  4. Parsing HTML -ClanLib right for the job?
    By Chambers in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 05-11-2007, 03:11 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •