summaryrefslogtreecommitdiff
path: root/web/web_dom.h
blob: 45afd15c67fbf45366fc4060ecc2744cf55ce442 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef WEB_DOM_H
#define WEB_DOM_H

#include <stdbool.h>

struct dom_elem {
	char *type, *ns, *name, *content;
	int n_attrs, size_attrs;
	char **attr_names, **attr_vals;
	int n_children, size_children;
	struct dom_elem **children;
};

struct dom_elem *dom_elem_init(char *ns, char *name, int size_attrs);
struct dom_elem *dom_text_init(char *content);
void dom_elem_free(struct dom_elem *e);
void dom_elem_add_attr(struct dom_elem *e, char *name, char *val);
void dom_elem_add_attrd(struct dom_elem *e, char *name, double val);
void dom_elem_add_child(struct dom_elem *e, struct dom_elem *child);

void dom_append_elemv(char *sel, int elemc, struct dom_elem **elemv);

char *dom_get_content(char *sel);
void dom_set_content(char *sel, char *str);
void dom_set_value(char *sel, char *str);

bool dom_has_class(char *sel, char *class);
void dom_add_class(char *sel, char *class);
void dom_remove_class(char *sel, char *class);
void dom_toggle_class(char *sel, char *class);
void dom_set_uniq_class(char *sel, char *class, char *sel_set);

void dom_set_style_property_int(char *prop, int val);

void dom_scroll_to_bottom(char *sel);
void dom_scroll_to_center_child(char *sel, char *sel_child);

void dom_enable_exit_dialogue(bool enable);

#endif