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