6 #include "master_css.h"
12 typedef std::vector
<css_text
> vector
;
20 css_text(const char* txt
, const char* url
, const char* media_str
)
22 text
= txt
? txt
: "";
23 baseurl
= url
? url
: "";
24 media
= media_str
? media_str
: "";
27 css_text(const css_text
& val
)
30 baseurl
= val
.baseurl
;
39 virtual void begin_node(const litehtml::string
& descr
) = 0;
40 virtual void end_node() = 0;
41 virtual void begin_attrs_group(const litehtml::string
& descr
) = 0;
42 virtual void end_attrs_group() = 0;
43 virtual void add_attr(const litehtml::string
& name
, const litehtml::string
& value
) = 0;
49 class document
: public std::enable_shared_from_this
<document
>
52 typedef std::shared_ptr
<document
> ptr
;
53 typedef std::weak_ptr
<document
> weak_ptr
;
55 std::shared_ptr
<element
> m_root
;
56 std::shared_ptr
<render_item
> m_root_render
;
57 document_container
* m_container
;
59 css_text::vector m_css
;
60 litehtml::css m_styles
;
61 litehtml::web_color m_def_color
;
62 litehtml::css m_master_css
;
63 litehtml::css m_user_css
;
64 litehtml::size m_size
;
65 litehtml::size m_content_size
;
66 position::vector m_fixed_boxes
;
67 media_query_list::vector m_media_lists
;
68 element::ptr m_over_element
;
69 std::list
<std::shared_ptr
<render_item
>> m_tabular_elements
;
70 media_features m_media
;
74 document(document_container
* objContainer
);
77 document_container
* container() { return m_container
; }
78 uint_ptr
get_font(const char* name
, int size
, const char* weight
, const char* style
, const char* decoration
, font_metrics
* fm
);
79 int render(int max_width
, render_type rt
= render_all
);
80 void draw(uint_ptr hdc
, int x
, int y
, const position
* clip
);
81 web_color
get_def_color() { return m_def_color
; }
82 int to_pixels(const char* str
, int fontSize
, bool* is_percent
= nullptr) const;
83 void cvt_units(css_length
& val
, int fontSize
, int size
= 0) const;
84 int to_pixels(const css_length
& val
, int fontSize
, int size
= 0) const;
87 int content_width() const;
88 int content_height() const;
89 void add_stylesheet(const char* str
, const char* baseurl
, const char* media
);
90 bool on_mouse_over(int x
, int y
, int client_x
, int client_y
, position::vector
& redraw_boxes
);
91 bool on_lbutton_down(int x
, int y
, int client_x
, int client_y
, position::vector
& redraw_boxes
);
92 bool on_lbutton_up(int x
, int y
, int client_x
, int client_y
, position::vector
& redraw_boxes
);
93 bool on_mouse_leave(position::vector
& redraw_boxes
);
94 element::ptr
create_element(const char* tag_name
, const string_map
& attributes
);
96 void get_fixed_boxes(position::vector
& fixed_boxes
);
97 void add_fixed_box(const position
& pos
);
98 void add_media_list(const media_query_list::ptr
& list
);
101 bool match_lang(const string
& lang
);
102 void add_tabular(const std::shared_ptr
<render_item
>& el
);
103 element::const_ptr
get_over_element() const { return m_over_element
; }
105 void append_children_from_string(element
& parent
, const char* str
);
106 void dump(dumper
& cout
);
108 static litehtml::document::ptr
createFromString(const char* str
, litehtml::document_container
* objPainter
, const char* master_styles
= litehtml::master_css
, const char* user_styles
= "");
111 uint_ptr
add_font(const char* name
, int size
, const char* weight
, const char* style
, const char* decoration
, font_metrics
* fm
);
113 void create_node(void* gnode
, elements_list
& elements
, bool parseTextNode
);
114 bool update_media_lists(const media_features
& features
);
115 void fix_tables_layout();
116 void fix_table_children(const std::shared_ptr
<render_item
>& el_ptr
, style_display disp
, const char* disp_str
);
117 void fix_table_parent(const std::shared_ptr
<render_item
> & el_ptr
, style_display disp
, const char* disp_str
);
120 inline element::ptr
document::root()
124 inline void document::add_tabular(const std::shared_ptr
<render_item
>& el
)
126 m_tabular_elements
.push_back(el
);
128 inline bool document::match_lang(const string
& lang
)
130 return lang
== m_lang
|| lang
== m_culture
;
134 #endif // LH_DOCUMENT_H