3 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
5 #include <Elementary.h>
9 * @defgroup WebView WebView
14 typedef struct _Widget_Data Widget_Data;
18 #ifdef BOUNCING_SUPPORT
19 Evas_Object *container;
24 static const char *widtype = NULL;
25 static void _del_hook(Evas_Object *obj);
26 static void _sizing_eval(Evas_Object *obj);
27 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
28 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
31 _del_pre_hook(Evas_Object *obj)
33 Widget_Data *wd = elm_widget_data_get(obj);
35 /*evas_object_event_callback_del_full
36 (wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
37 evas_object_box_remove_all(wd->box, 0);
42 _del_hook(Evas_Object *obj)
44 Widget_Data *wd = elm_widget_data_get(obj);
46 //_els_webview_del(wd->webkit);
51 _sizing_eval(Evas_Object *obj)
53 Widget_Data *wd = elm_widget_data_get(obj);
55 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
56 printf("sizing eval : %d, %d\n", w, h);
57 #ifdef BOUNCING_SUPPORT
58 evas_object_resize(wd->container, w, h);
60 evas_object_resize(wd->webkit, w, h);
64 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
70 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
76 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
82 _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
84 Widget_Data *wd = data;
86 //_els_box_layout(o, priv, wd->horizontal, wd->homogeneous);
90 * Add a new box to the parent
92 * @param parent The parent object
93 * @return The new object or NULL if it cannot be created
99 elm_webview_add(Evas_Object *parent, Eina_Bool tiled)
105 wd = ELM_NEW(Widget_Data);
106 e = evas_object_evas_get(parent);
107 obj = elm_widget_add(e);
108 ELM_SET_WIDTYPE(widtype, "webview");
109 elm_widget_type_set(obj, "webview");
110 elm_widget_sub_object_add(parent, obj);
111 elm_widget_data_set(obj, wd);
112 elm_widget_del_hook_set(obj, _del_hook);
114 wd->webkit = _elm_smart_webview_add(e, tiled);
115 #ifdef BOUNCING_SUPPORT
116 wd->container = elm_smart_webview_container_add(e);
117 _elm_smart_webview_container_child_set(wd->container, wd->webkit);
119 _elm_smart_webview_widget_set(wd->webkit, obj);
120 evas_object_event_callback_add(wd->webkit, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
121 _changed_size_hints, obj);
123 #ifdef BOUNCING_SUPPORT
124 elm_widget_resize_object_set(obj, wd->container);
125 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
127 elm_widget_resize_object_set(obj, wd->webkit);
129 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
134 elm_webview_webkit_get(Evas_Object *obj)
136 Widget_Data *wd = elm_widget_data_get(obj);
142 elm_webview_events_feed_set(Evas_Object *obj, Eina_Bool feed)
144 Widget_Data *wd = elm_widget_data_get(obj);
146 _elm_smart_webview_events_feed_set(wd->webkit, feed);
150 elm_webview_events_feed_get(Evas_Object *obj)
152 Widget_Data *wd = elm_widget_data_get(obj);
153 if (!wd) return EINA_FALSE;
154 return _elm_smart_webview_events_feed_get(wd->webkit);
158 elm_webview_auto_fitting_set(Evas_Object *obj, Eina_Bool enable)
160 Widget_Data *wd = elm_widget_data_get(obj);
162 _elm_smart_webview_auto_fitting_set(wd->webkit, enable);
166 elm_webview_auto_fitting_get(Evas_Object *obj)
168 Widget_Data *wd = elm_widget_data_get(obj);
169 if (!wd) return EINA_FALSE;
170 return _elm_smart_webview_auto_fitting_get(wd->webkit);
174 elm_webview_minimap_get(Evas_Object *obj)
176 Widget_Data *wd = elm_widget_data_get(obj);
177 if (!wd) return EINA_FALSE;
178 return _elm_smart_webview_minimap_get(wd->webkit);
182 elm_webview_uri_set(Evas_Object *obj, const char *uri)
184 Widget_Data *wd = elm_widget_data_get(obj);
186 _elm_smart_webview_uri_set(wd->webkit, uri);
190 * Set bouncing behavior(Not supported yet)
192 * When scrolling, the WebView may "bounce" when reaching an edge of contents
193 * This is a visual way to indicate the end has been reached. This is enabled
194 * by default for both axes. This will set if it is enabled for that axis with
195 * the boolean parameers for each axis.
197 * @param obj The WebView object
198 * @param h_bounce Will the WebView bounce horizontally or not
199 * @param v_bounce Will the WebView bounce vertically or not
204 elm_webview_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
206 Widget_Data *wd = elm_widget_data_get(obj);
208 _elm_smart_webview_bounce_allow_set(wd->webkit, h_bounce, v_bounce);
212 * Add callback to treat mime type
214 * When user click link, the WebView may have different action by mime type.
215 * This is a way to choose proper action each mime type.
217 * @param obj The WebView object
218 * @param mime mime type string
219 * @param mime_callback callback when user choose link which involved @mime
224 elm_webview_mime_callback_set(Evas_Object *obj, const char *mime, Elm_WebView_Mime_Cb func)
226 Widget_Data *wd = elm_widget_data_get(obj);
228 _elm_smart_webview_mime_callback_set(wd->webkit, mime, func);
232 * Set default layout width
234 * If you want to load webpage with specific layout width, you can set it using this API.
235 * If you do not set it, the default layout width will be 1024.
237 * @param obj Webview object
238 * @param width width size that you want to set
244 elm_webview_default_layout_width_set(Evas_Object *obj, int width)
246 Widget_Data *wd = elm_widget_data_get(obj);
248 _elm_smart_webview_default_layout_width_set(wd->webkit, width);