Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

document_container

Yuri Kobets edited this pageMay 22, 2023 ·9 revisions

litehtml::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.

create_font

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 thanascent+descent by 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+descent between 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).

delete_font

virtualvoiddelete_font(uint_ptr hFont);

delete the font created increate_font function

text_width

virtualinttext_width(constchar* text, uint_ptr hFont);

Returns the text width.

draw_text

virtualvoiddraw_text(uint_ptr hdc,constchar* text, uint_ptr hFont, litehtml::web_color color,const litehtml::position& pos);

This function draw the text string.

pt_to_px

virtualintpt_to_px(int pt);

Convertpoints intopixels.

get_default_font_size

virtualintget_default_font_size();

Returns the default font size in pixels.

get_default_font_name

virtualconstchar*get_default_font_name();

Returns the default font face name.

draw_list_marker

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.

load_image

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.

get_image_size

virtualvoidget_image_size(constchar* src,constchar* baseurl, litehtml::size& sz);

Fill thesz parameter with image width and height.

draw_background

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.

draw_borders

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>).

set_caption

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.

set_base_url

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.

link

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.

on_anchor_click

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.

set_cursor

virtualvoidset_cursor(constchar* cursor);

Define this function to handle the CSS cursor property.

transform_text

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.

import_css

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.

set_clip

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.

del_clip

virtualvoiddel_clip();

Deletes the last clipping.

get_client_rect

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.

create_element

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.).

get_media_features

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).


[8]ページ先頭

©2009-2025 Movatter.jp