Html code in Native WebView Environment
The code below will allow writing html code in Tizen Native WebView Environment.
/* Function to place child objects to table object */
static void my_table_pack(Evas_Object *table, Evas_Object *child, int x, int y,
int w, int h) {
evas_object_size_hint_align_set(child, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(child, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_table_pack(table, child, x, y, w, h);
evas_object_show(child);
}
…….
/* Create Base UI */
static void create_base_gui(appdata_s *ad) {
ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
{
/* Box Add */
Evas_Object *box = elm_box_add(ad->win);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND,
EVAS_HINT_EXPAND);
elm_win_resize_object_add(ad->win, box);
evas_object_show(box);
/* Table Add */
Evas_Object *table = elm_table_add(ad->win);
elm_table_homogeneous_set(table, EINA_TRUE);
elm_table_padding_set(table, 5 * elm_config_scale_get(),
10 * elm_config_scale_get());
evas_object_size_hint_weight_set(table, EVAS_HINT_EXPAND,
EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL);
/* Packing the box */
elm_box_pack_end(box, table);
evas_object_show(table);
{
/* Creating WebView */
Evas *evas = evas_object_evas_get(ad->win);
ad->web_view = ewk_view_add(evas);
/* Html file as string: a basic html form */
char html[99999] = "<!DOCTYPE html><html>"
"<body>\" Form Example(html) \""
"<form> First name:<br> <input type=\"text\" name=\"firstname\"> <br> Last name:<br> <input type=\"text\" name=\"lastname\"> </form>"
"<button onclick=\"JavaScript:alert(\'Well done!\')\">Click Me!</button>"
"</body></html>";
/* Loading html page as string in ewk_view */
ewk_view_html_string_load(ad->web_view , html, NULL, NULL);
evas_object_show(ad->web_view);
my_table_pack(table, ad->web_view, 0, 2, 3, 8);
}
}
evas_object_show(ad->win);
}