remove code related with elm_scroller_content
[framework/uifw/elementary.git] / src / lib / elm_scroller.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3 #include "els_scroller.h"
4
5 typedef struct _Widget_Data Widget_Data;
6
7 struct _Widget_Data
8 {
9    Evas_Object *scr;
10    Evas_Object *content;
11    const char *widget_name, *widget_base;
12    Eina_Bool min_w : 1;
13    Eina_Bool min_h : 1;
14    double pagerel_h, pagerel_v;
15    Evas_Coord pagesize_h, pagesize_v;
16 };
17
18 static const char *widtype = NULL;
19 static void _del_hook(Evas_Object *obj);
20 static void _theme_hook(Evas_Object *obj);
21 static void _show_region_hook(void *data, Evas_Object *obj);
22 static void _sizing_eval(Evas_Object *obj);
23 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
24 static void _on_focus_hook(void *data, Evas_Object *obj);
25 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
26                              Evas_Callback_Type type, void *event_info);
27
28
29 static const char SIG_SCROLL[] = "scroll";
30 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
31 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
32 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
33 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
34 static const char SIG_EDGE_LEFT[] = "edge,left";
35 static const char SIG_EDGE_RIGHT[] = "edge,right";
36 static const char SIG_EDGE_TOP[] = "edge,top";
37 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
38 static const Evas_Smart_Cb_Description _signals[] = {
39   {SIG_SCROLL, ""},
40   {SIG_SCROLL_ANIM_START, ""},
41   {SIG_SCROLL_ANIM_STOP, ""},
42   {SIG_SCROLL_DRAG_START, ""},
43   {SIG_SCROLL_DRAG_STOP, ""},
44   {SIG_EDGE_LEFT, ""},
45   {SIG_EDGE_RIGHT, ""},
46   {SIG_EDGE_TOP, ""},
47   {SIG_EDGE_BOTTOM, ""},
48   {NULL, NULL}
49 };
50
51 static Eina_Bool
52 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
53 {
54    if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
55    Evas_Event_Key_Down *ev = event_info;
56    Widget_Data *wd = elm_widget_data_get(obj);
57    if (!wd) return EINA_FALSE;
58    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
59    if (elm_widget_disabled_get(obj)) return EINA_FALSE;
60
61    Evas_Coord x = 0;
62    Evas_Coord y = 0;
63    Evas_Coord step_x = 0;
64    Evas_Coord step_y = 0;
65    Evas_Coord max_x = 0;
66    Evas_Coord max_y = 0;
67    Evas_Coord v_w = 0;
68    Evas_Coord v_h = 0;
69    Evas_Coord page_x = 0;
70    Evas_Coord page_y = 0;
71
72    elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
73    elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
74    elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
75    elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
76    elm_scroller_child_size_get(obj, &max_x, &max_y);
77
78    if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
79      {
80         x -= step_x;
81      }
82    else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
83      {
84         x += step_x;
85      }
86    else if ((!strcmp(ev->keyname, "Up"))  || (!strcmp(ev->keyname, "KP_Up")))
87      {
88         y -= step_y;
89      }
90    else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
91      {
92         y += step_y;
93      }
94    else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
95      {
96         y = 0;
97      }
98    else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
99      {
100         y = max_y - v_h;
101      }
102    else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
103      {
104         if (page_y < 0)
105           y -= -(page_y * v_h) / 100;
106         else
107           y -= page_y;
108      }
109    else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
110      {
111         if (page_y < 0)
112           y += -(page_y * v_h) / 100;
113         else
114           y += page_y;
115      }
116    else return EINA_FALSE;
117
118    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
119    elm_smart_scroller_child_pos_set(wd->scr, x, y);
120    return EINA_TRUE;
121 }
122
123 static void
124 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
125 {
126    Widget_Data *wd = elm_widget_data_get(obj);
127    if (!wd) return;
128    if (elm_widget_focus_get(obj))
129      {
130         edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,focus", "elm");
131         evas_object_focus_set(wd->scr, EINA_TRUE);
132      }
133    else
134      {
135         edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,unfocus", "elm");
136         evas_object_focus_set(wd->scr, EINA_FALSE);
137      }
138 }
139
140 static void
141 _del_hook(Evas_Object *obj)
142 {
143    Widget_Data *wd = elm_widget_data_get(obj);
144    if (!wd) return;
145    free(wd);
146 }
147
148 static void
149 _mirrored_set(Evas_Object *obj, Eina_Bool mirrored)
150 {
151    Widget_Data *wd = elm_widget_data_get(obj);
152    if (!wd) return;
153    if (wd->scr)
154      elm_smart_scroller_mirrored_set(wd->scr, mirrored);
155 }
156
157 static void
158 _theme_hook(Evas_Object *obj)
159 {
160    Widget_Data *wd = elm_widget_data_get(obj);
161    if (!wd) return;
162    _elm_widget_mirrored_reload(obj);
163    if (wd->scr)
164      {
165         Evas_Object *edj;
166         const char *str;
167
168         _mirrored_set(obj, elm_widget_mirrored_get(obj));
169         elm_smart_scroller_object_theme_set(obj, wd->scr,
170                                             wd->widget_name, wd->widget_base,
171                                             elm_widget_style_get(obj));
172         //        edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
173         edj = elm_smart_scroller_edje_object_get(wd->scr);
174         str = edje_object_data_get(edj, "focus_highlight");
175         if ((str) && (!strcmp(str, "on")))
176           elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
177         else
178           elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
179      }
180    _sizing_eval(obj);
181 }
182
183 static Eina_Bool
184 _elm_scroller_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
185 {
186    Widget_Data *wd = elm_widget_data_get(obj);
187    Evas_Object *cur;
188
189    if ((!wd) || (!wd->content))
190      return EINA_FALSE;
191
192    cur = wd->content;
193
194    /* Try Focus cycle in subitem */
195    if (elm_widget_focus_get(obj))
196      {
197         if ((elm_widget_can_focus_get(cur)) || (elm_widget_child_can_focus_get(cur)))
198           return elm_widget_focus_next_get(cur, dir, next);
199      }
200
201    /* Return */
202    *next = (Evas_Object *)obj;
203    return !elm_widget_focus_get(obj);
204 }
205
206 static void
207 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
208 {
209    Widget_Data *wd = elm_widget_data_get(obj);
210    if (!wd) return;
211    edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
212                            emission, source);
213 }
214
215 static void
216 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
217 {
218    Widget_Data *wd = elm_widget_data_get(obj);
219    if (!wd) return;
220    edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
221                                    emission, source, func_cb, data);
222 }
223
224 static void
225 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
226 {
227    Widget_Data *wd = elm_widget_data_get(obj);
228    edje_object_signal_callback_del_full(
229       elm_smart_scroller_edje_object_get(wd->scr), emission, source,
230       func_cb, data);
231 }
232
233 static void
234 _show_region_hook(void *data, Evas_Object *obj)
235 {
236    Widget_Data *wd = elm_widget_data_get(data);
237    Evas_Coord x, y, w, h;
238    if (!wd) return;
239    elm_widget_show_region_get(obj, &x, &y, &w, &h);
240    if (wd->scr)
241      elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
242 }
243
244 static void
245 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
246 {
247    Widget_Data *wd = elm_widget_data_get(obj);
248    if (wd->scr)
249      elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
250 }
251
252 static void
253 _sizing_eval(Evas_Object *obj)
254 {
255    Widget_Data *wd = elm_widget_data_get(obj);
256    Evas_Coord  vw = 0, vh = 0, minw = 0, minh = 0, maxw = 0, maxh = 0, w, h, vmw, vmh;
257    double xw = 0.0, yw = 0.0;
258
259    if (!wd) return;
260    if (wd->content)
261      {
262         evas_object_size_hint_min_get(wd->content, &minw, &minh);
263         evas_object_size_hint_max_get(wd->content, &maxw, &maxh);
264         evas_object_size_hint_weight_get(wd->content, &xw, &yw);
265      }
266    if (wd->scr)
267      {
268         elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
269         if (xw > 0.0)
270           {
271              if ((minw > 0) && (vw < minw)) vw = minw;
272              else if ((maxw > 0) && (vw > maxw)) vw = maxw;
273           }
274         else if (minw > 0) vw = minw;
275         if (yw > 0.0)
276           {
277              if ((minh > 0) && (vh < minh)) vh = minh;
278              else if ((maxh > 0) && (vh > maxh)) vh = maxh;
279           }
280         else if (minh > 0) vh = minh;
281         if (wd->content) evas_object_resize(wd->content, vw, vh);
282         w = -1;
283         h = -1;
284         edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
285         if (wd->min_w) w = vmw + minw;
286         if (wd->min_h) h = vmh + minh;
287         evas_object_size_hint_max_get(obj, &maxw, &maxh);
288         if ((maxw > 0) && (w > maxw)) w = maxw;
289         if ((maxh > 0) && (h > maxh)) h = maxh;
290         evas_object_size_hint_min_set(obj, w, h);
291      }
292 }
293
294 static void
295 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
296 {
297    _sizing_eval(data);
298 }
299
300 static void
301 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
302 {
303    Widget_Data *wd = elm_widget_data_get(obj);
304    Evas_Object *sub = event_info;
305
306    if (!wd) return;
307    if (sub == wd->content)
308      {
309         elm_widget_on_show_region_hook_set(wd->content, NULL, NULL);
310         evas_object_event_callback_del_full (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
311                                              _changed_size_hints, obj);
312         wd->content = NULL;
313         _sizing_eval(obj);
314      }
315    else if (sub == wd->scr)
316      wd->scr = NULL;
317 }
318
319 static void
320 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
321 {
322    Widget_Data *wd = elm_widget_data_get(obj);
323
324    if (!wd) return;
325    if (wd->scr)
326      elm_smart_scroller_hold_set(wd->scr, 1);
327 }
328
329 static void
330 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
331 {
332    Widget_Data *wd = elm_widget_data_get(obj);
333
334    if (!wd) return;
335    if (wd->scr)
336      elm_smart_scroller_hold_set(wd->scr, 0);
337 }
338
339 static void
340 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
341 {
342    Widget_Data *wd = elm_widget_data_get(obj);
343
344    if (!wd) return;
345    if (wd->scr)
346      elm_smart_scroller_freeze_set(wd->scr, 1);
347 }
348
349 static void
350 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
351 {
352    Widget_Data *wd = elm_widget_data_get(obj);
353
354    if (!wd) return;
355    if (wd->scr)
356      elm_smart_scroller_freeze_set(wd->scr, 0);
357 }
358
359 static void
360 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
361 {
362    _sizing_eval(data);
363 }
364
365 static void
366 _edge_left(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
367 {
368    evas_object_smart_callback_call(data, SIG_EDGE_LEFT, NULL);
369 }
370
371 static void
372 _edge_right(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
373 {
374    evas_object_smart_callback_call(data, SIG_EDGE_RIGHT, NULL);
375 }
376
377 static void
378 _edge_top(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
379 {
380    evas_object_smart_callback_call(data, SIG_EDGE_TOP, NULL);
381 }
382
383 static void
384 _edge_bottom(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
385 {
386    evas_object_smart_callback_call(data, SIG_EDGE_BOTTOM, NULL);
387 }
388
389 static void
390 _scroll(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
391 {
392    evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
393 }
394
395 static void
396 _scroll_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
397 {
398    evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
399 }
400
401 static void
402 _scroll_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
403 {
404    evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
405 }
406
407 static void
408 _scroll_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
409 {
410    evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
411 }
412
413 static void
414 _scroll_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
415 {
416    evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
417 }
418
419 Evas_Object *
420 _elm_scroller_edje_object_get(Evas_Object *obj)
421 {
422    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
423    Widget_Data *wd = elm_widget_data_get(obj);
424    if (!wd) return NULL;
425    return elm_smart_scroller_edje_object_get(wd->scr);
426 }
427
428 static void
429 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
430 {
431    ELM_CHECK_WIDTYPE(obj, widtype);
432    Widget_Data *wd;
433    if (part && strcmp(part, "default")) return;
434    wd = elm_widget_data_get(obj);
435    if (!wd) return;
436    if (wd->content == content) return;
437    if (wd->content) evas_object_del(wd->content);
438    wd->content = content;
439    if (content)
440      {
441         elm_widget_on_show_region_hook_set(content, _show_region_hook, obj);
442         elm_widget_sub_object_add(obj, content);
443         if (wd->scr)
444           elm_smart_scroller_child_set(wd->scr, content);
445         evas_object_event_callback_add(content,
446                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
447                                        _changed_size_hints, obj);
448      }
449    _sizing_eval(obj);
450 }
451
452 static Evas_Object *
453 _content_get_hook(const Evas_Object *obj, const char *part)
454 {
455    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
456    Widget_Data *wd;
457    if (part && strcmp(part, "default")) return NULL;
458    wd = elm_widget_data_get(obj);
459    if (!wd) return NULL;
460    return wd->content;
461 }
462
463 static Evas_Object *
464 _content_unset_hook(Evas_Object *obj, const char *part)
465 {
466    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
467    Widget_Data *wd;
468    Evas_Object *content;
469    if (part && strcmp(part, "default")) return NULL;
470    wd = elm_widget_data_get(obj);
471    if (!wd) return NULL;
472    if (!wd->content) return NULL;
473    content = wd->content;
474    elm_widget_sub_object_del(obj, wd->content);
475    evas_object_event_callback_del_full(wd->content,
476                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
477                                        _changed_size_hints, obj);
478    edje_object_part_unswallow(elm_smart_scroller_edje_object_get(wd->scr),
479                               wd->content);
480    wd->content = NULL;
481    return content;
482 }
483
484 EAPI Evas_Object *
485 elm_scroller_add(Evas_Object *parent)
486 {
487    Evas_Object *obj;
488    Evas *e;
489    Widget_Data *wd;
490    Evas_Coord minw, minh;
491
492    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
493
494    ELM_SET_WIDTYPE(widtype, "scroller");
495    elm_widget_type_set(obj, "scroller");
496    elm_widget_sub_object_add(parent, obj);
497    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
498    elm_widget_data_set(obj, wd);
499    elm_widget_del_hook_set(obj, _del_hook);
500    elm_widget_theme_hook_set(obj, _theme_hook);
501    elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
502    elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
503    elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
504    elm_widget_focus_next_hook_set(obj, _elm_scroller_focus_next_hook);
505    elm_widget_can_focus_set(obj, EINA_TRUE);
506    elm_widget_event_hook_set(obj, _event_hook);
507    elm_widget_focus_region_hook_set(obj, _focus_region_hook);
508    elm_widget_content_set_hook_set(obj, _content_set_hook);
509    elm_widget_content_get_hook_set(obj, _content_get_hook);
510    elm_widget_content_unset_hook_set(obj, _content_unset_hook);
511
512    wd->widget_name = eina_stringshare_add("scroller");
513    wd->widget_base = eina_stringshare_add("base");
514
515    wd->scr = elm_smart_scroller_add(e);
516    elm_smart_scroller_widget_set(wd->scr, obj);
517    _theme_hook(obj);
518    elm_widget_resize_object_set(obj, wd->scr);
519    evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
520                                   _changed_size_hints, obj);
521
522    edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &minw, &minh);
523    evas_object_size_hint_min_set(obj, minw, minh);
524    evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
525
526    evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
527    evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
528    evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
529    evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
530    evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
531
532    evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
533    evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
534    evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
535    evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom, obj);
536    evas_object_smart_callback_add(wd->scr, "scroll", _scroll, obj);
537    evas_object_smart_callback_add(wd->scr, "animate,start", _scroll_anim_start, obj);
538    evas_object_smart_callback_add(wd->scr, "animate,stop", _scroll_anim_stop, obj);
539    evas_object_smart_callback_add(wd->scr, "drag,start", _scroll_drag_start, obj);
540    evas_object_smart_callback_add(wd->scr, "drag,stop", _scroll_drag_stop, obj);
541
542    _sizing_eval(obj);
543
544    // TODO: convert Elementary to subclassing of Evas_Smart_Class
545    // TODO: and save some bytes, making descriptions per-class and not instance!
546    evas_object_smart_callbacks_descriptions_set(obj, _signals);
547    _mirrored_set(obj, elm_widget_mirrored_get(obj));
548    return obj;
549 }
550
551 EAPI void
552 elm_scroller_custom_widget_base_theme_set(Evas_Object *obj, const char *widget, const char *base)
553 {
554    ELM_CHECK_WIDTYPE(obj, widtype);
555    Widget_Data *wd = elm_widget_data_get(obj);
556    if (!wd) return;
557    EINA_SAFETY_ON_NULL_RETURN(widget);
558    EINA_SAFETY_ON_NULL_RETURN(base);
559    if (eina_stringshare_replace(&wd->widget_name, widget) |
560        eina_stringshare_replace(&wd->widget_base, base))
561      _theme_hook(obj);
562 }
563
564 EAPI void
565 elm_scroller_content_min_limit(Evas_Object *obj, Eina_Bool w, Eina_Bool h)
566 {
567    ELM_CHECK_WIDTYPE(obj, widtype);
568    Widget_Data *wd = elm_widget_data_get(obj);
569    if (!wd) return;
570    wd->min_w = w;
571    wd->min_h = h;
572    _sizing_eval(obj);
573 }
574
575 EAPI void
576 elm_scroller_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
577 {
578    ELM_CHECK_WIDTYPE(obj, widtype);
579    Widget_Data *wd = elm_widget_data_get(obj);
580    if ((!wd) || (!wd->scr)) return;
581    elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
582 }
583
584 EAPI void
585 elm_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
586 {
587    ELM_CHECK_WIDTYPE(obj, widtype);
588    Widget_Data *wd = elm_widget_data_get(obj);
589    if ((!wd) || (!wd->scr)) return;
590    if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
591        (policy_v >= ELM_SCROLLER_POLICY_LAST))
592      return;
593    elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
594 }
595
596 EAPI void
597 elm_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
598 {
599    ELM_CHECK_WIDTYPE(obj, widtype);
600    Widget_Data *wd = elm_widget_data_get(obj);
601    if ((!wd) || (!wd->scr)) return;
602    elm_smart_scroller_policy_get(wd->scr,
603                                  (Elm_Smart_Scroller_Policy *) policy_h,
604                                  (Elm_Smart_Scroller_Policy *) policy_v);
605 }
606
607 EAPI void
608 elm_scroller_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
609 {
610    ELM_CHECK_WIDTYPE(obj, widtype);
611    Widget_Data *wd = elm_widget_data_get(obj);
612    if ((!wd) || (!wd->scr)) return;
613    if ((x) || (y)) elm_smart_scroller_child_pos_get(wd->scr, x, y);
614    if ((w) || (h)) elm_smart_scroller_child_viewport_size_get(wd->scr, w, h);
615 }
616
617 EAPI void
618 elm_scroller_child_size_get(const Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
619 {
620    ELM_CHECK_WIDTYPE(obj, widtype);
621    Widget_Data *wd = elm_widget_data_get(obj);
622    if (!wd) return;
623    evas_object_geometry_get(wd->content, NULL, NULL, w, h);
624 }
625
626 EAPI void
627 elm_scroller_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
628 {
629    ELM_CHECK_WIDTYPE(obj, widtype);
630    Widget_Data *wd = elm_widget_data_get(obj);
631    if ((!wd) || (!wd->scr)) return;
632    elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
633 }
634
635 EAPI void
636 elm_scroller_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
637 {
638    ELM_CHECK_WIDTYPE(obj, widtype);
639    Widget_Data *wd = elm_widget_data_get(obj);
640    if (!wd) return;
641    elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
642 }
643
644 EAPI void
645 elm_scroller_page_relative_set(Evas_Object *obj, double h_pagerel, double v_pagerel)
646 {
647    ELM_CHECK_WIDTYPE(obj, widtype);
648    Widget_Data *wd = elm_widget_data_get(obj);
649    if (!wd) return;
650    wd->pagerel_h = h_pagerel;
651    wd->pagerel_v = v_pagerel;
652    if (wd->scr)
653      elm_smart_scroller_paging_set(wd->scr, wd->pagerel_h, wd->pagerel_v,
654                                    wd->pagesize_h, wd->pagesize_v);
655 }
656
657 EAPI void
658 elm_scroller_page_size_set(Evas_Object *obj, Evas_Coord h_pagesize, Evas_Coord v_pagesize)
659 {
660    ELM_CHECK_WIDTYPE(obj, widtype);
661    Widget_Data *wd = elm_widget_data_get(obj);
662    if (!wd) return;
663    wd->pagesize_h = h_pagesize;
664    wd->pagesize_v = v_pagesize;
665    if (wd->scr)
666      elm_smart_scroller_paging_set(wd->scr, wd->pagerel_h, wd->pagerel_v,
667                                    wd->pagesize_h, wd->pagesize_v);
668 }
669
670 EAPI void
671 elm_scroller_current_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
672 {
673    ELM_CHECK_WIDTYPE(obj, widtype);
674    Widget_Data *wd = elm_widget_data_get(obj);
675    if (!wd) return;
676    if (wd->scr)
677      elm_smart_scroller_current_page_get(wd->scr, h_pagenumber, v_pagenumber);
678 }
679
680 EAPI void
681 elm_scroller_last_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
682 {
683    ELM_CHECK_WIDTYPE(obj, widtype);
684    Widget_Data *wd = elm_widget_data_get(obj);
685    if (!wd) return;
686    if (wd->scr)
687      elm_smart_scroller_last_page_get(wd->scr, h_pagenumber, v_pagenumber);
688 }
689
690 EAPI void
691 elm_scroller_page_show(Evas_Object *obj, int h_pagenumber, int v_pagenumber)
692 {
693    ELM_CHECK_WIDTYPE(obj, widtype);
694    Widget_Data *wd = elm_widget_data_get(obj);
695    if (!wd) return;
696    if (wd->scr)
697      elm_smart_scroller_page_show(wd->scr, h_pagenumber, v_pagenumber);
698 }
699
700 EAPI void
701 elm_scroller_page_bring_in(Evas_Object *obj, int h_pagenumber, int v_pagenumber)
702 {
703    ELM_CHECK_WIDTYPE(obj, widtype);
704    Widget_Data *wd = elm_widget_data_get(obj);
705    if (!wd) return;
706    if (wd->scr)
707      elm_smart_scroller_page_bring_in(wd->scr, h_pagenumber, v_pagenumber);
708 }
709
710 EAPI void
711 elm_scroller_region_bring_in(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
712 {
713    ELM_CHECK_WIDTYPE(obj, widtype);
714    Widget_Data *wd = elm_widget_data_get(obj);
715    if ((!wd) || (!wd->scr)) return;
716    elm_smart_scroller_region_bring_in(wd->scr, x, y, w, h);
717 }
718
719 EAPI void
720 elm_scroller_propagate_events_set(Evas_Object *obj, Eina_Bool propagation)
721 {
722    ELM_CHECK_WIDTYPE(obj, widtype);
723    Widget_Data *wd = elm_widget_data_get(obj);
724    if (!wd) return;
725
726    evas_object_propagate_events_set(wd->scr, propagation);
727 }
728
729 EAPI Eina_Bool
730 elm_scroller_propagate_events_get(const Evas_Object *obj)
731 {
732    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
733    Widget_Data *wd = elm_widget_data_get(obj);
734    if (!wd) return EINA_FALSE;
735
736    return evas_object_propagate_events_get(wd->scr);
737 }
738
739 EAPI void
740 elm_scroller_gravity_set(Evas_Object *obj, double x, double y)
741 {
742    ELM_CHECK_WIDTYPE(obj, widtype);
743    Widget_Data *wd = elm_widget_data_get(obj);
744    if (!wd) return;
745
746    elm_smart_scroller_gravity_set(wd->scr, x, y);
747 }
748
749 EAPI void
750 elm_scroller_gravity_get(const Evas_Object *obj, double *x, double *y)
751 {
752    ELM_CHECK_WIDTYPE(obj, widtype);
753    Widget_Data *wd = elm_widget_data_get(obj);
754    if (!wd) return;
755
756    elm_smart_scroller_gravity_get(wd->scr, x, y);
757 }