Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork265
document_container
litehtml::document_container class draws the HTML elements and perform some actions depended of the platform. This is the only class you should implement in your application.
Below is the list of member function you have to implement.
virtual litehtml::uint_ptrcreate_font(constchar* faceName,int size,int weight, litehtml::font_style italic,unsignedint decoration, litehtml::font_metrics* fm);
This function called by litehtml to create the font. create_font returns uint_ptr that identify the created font.Parameters:
- faceName - the face name for the font.Note:faceName can contain some fonts as described in CSS specifications. You have to select the proper font.
- size - font size in pixels.
- weight - Defines from thin to thick characters. 400 is the same as normal, and 700 is the same as bold.
- decoration - one or more flags:
const unsigned int font_decoration_none=0x00;const unsigned int font_decoration_underline=0x01;const unsigned int font_decoration_linethrough=0x02;const unsigned int font_decoration_overline=0x04;
- fm - you have to fill this structure with the font metrics:
- height - the recommended vertical distance between baselines when setting consecutive lines of text with the font. This is greater than
ascent+descentby a quantity known as the line spacing or external leading. When space is at a premium, most fonts can be set with only a distance ofascent+descentbetween lines. - ascent - the distance that the font extends above the baseline. Note that this is not always exactly equal to the maximum of the extents of all the glyphs in the font, but rather is picked to express the font designer's intent as to how the font should align with elements above it.
- descent - the distance that the font extends below the baseline. This value is positive for typical fonts that include portions below the baseline. Note that this is not always exactly equal to the maximum of the extents of all the glyphs in the font, but rather is picked to express the font designer's intent as to how the font should align with elements below it.
- x_height - height of the 'x' char (used for internal calculations).
- height - the recommended vertical distance between baselines when setting consecutive lines of text with the font. This is greater than
virtualvoiddelete_font(uint_ptr hFont);
delete the font created increate_font function
virtualinttext_width(constchar* text, uint_ptr hFont);
Returns the text width.
virtualvoiddraw_text(uint_ptr hdc,constchar* text, uint_ptr hFont, litehtml::web_color color,const litehtml::position& pos);
This function draw the text string.
virtualintpt_to_px(int pt);
Convertpoints intopixels.
virtualintget_default_font_size();
Returns the default font size in pixels.
virtualconstchar*get_default_font_name();
Returns the default font face name.
virtualvoiddraw_list_marker(uint_ptr hdc,const litehtml::list_marker& marker);
Draws the list marker. Use the parametermarker to find the marker type and position.
virtualvoidload_image(constchar* src,constchar* baseurl);
You can preload image in this function. litehtml does not cache the images, so you have to create own images cache if you need it.
virtualvoidget_image_size(constchar* src,constchar* baseurl, litehtml::size& sz);
Fill thesz parameter with image width and height.
virtualvoiddraw_background(uint_ptr hdc,const litehtml::background_paint& bg);
Draw the background in this function. The parameterbg describes the element background (seebackground_paint description). Note the<img> html element are drawn as background.
virtualvoiddraw_borders(uint_ptr hdc,const css_borders& borders,const litehtml::position& draw_pos,bool root);
Draw the element borders here. The parameterroot istrue if you have to draw the borders for the root element (usually this is<html>).
virtualvoidset_caption(constchar* caption);
litehtml calls this function with<title> html tag text. You can use thecaption parameter to set the window caption text into the html page title.
virtualvoidset_base_url(constchar* base_url);
litehtml calls this function for the<base> html tag to set the base url. Save this string for future use in the functions that get thebaseurl parameter.
virtualvoidlink(litehtml::document* doc, litehtml::element::ptr el);
This function is used to process the<link> html tags. Note, litehtml processes the stylesheets references automatically and calls import_css function to load CSS file.
virtualvoidon_anchor_click(constchar* url, litehtml::element::ptr el);
litehtml calls this function on anchor element click. You can open new website or do something other here.
virtualvoidset_cursor(constchar* cursor);
Define this function to handle the CSS cursor property.
virtualvoidtransform_text(std::string& text, litehtml::text_transform tt);
Transform thetext parameter according thett value:
- text_transform_capitalize - make the first char upper case.
- text_transform_uppercase - make all chars upper case.
- text_transform_lowercase - make all chars lower case.
virtualvoidimport_css(std::string& text,const std::string& url, std::string& baseurl);
litehtml calls this function to load stylesheet. You have to download CSS file referred byurl andbaseurl parameters and copy content intotext parameter.
virtualvoidset_clip(const litehtml::position& pos,const litehtml::border_radiuses& bdr_radius);
Set the painting clip rectangle here.bdr_radius defines borders radius for rounded rectangles. Please note, litehtml can set some clip rects. You have to save the clip positions and apply clipping on draw something.
virtualvoiddel_clip();
Deletes the last clipping.
virtualvoidget_client_rect(litehtml::position& client);
Fill the parameterclient with the viewport position and size. Usually this is the size of the client rectangle of the window where you want to draw html.
virtual litehtml::element*create_element(constchar* tag_name);
Using this function you can process custom tags. Just make your own litehtml::element and return is from this function. Parametertag_name is the HTML tag (a, p, table etc.).
virtualvoidget_media_features(litehtml::media_features& media)
Fill themedia with the parameters of media where you render HTML. litehtml process stylesheets using the media features. Call document::media_changed function when any media feature is changed (for example user is changed the window size).