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 #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(wd->scr, "elm,action,focus", "elm");
131         evas_object_focus_set(wd->scr, EINA_TRUE);
132      }
133    else
134      {
135         edje_object_signal_emit(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_can_focus_get(cur)) || (elm_widget_child_can_focus_get(cur)))
196      return elm_widget_focus_next_get(cur, dir, next);
197
198    /* Return */
199    *next = (Evas_Object *)obj;
200    return !elm_widget_focus_get(obj);
201 }
202
203 static void
204 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
205 {
206    Widget_Data *wd = elm_widget_data_get(obj);
207    if (!wd) return;
208    edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
209                            emission, source);
210 }
211
212 static void
213 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
214 {
215    Widget_Data *wd = elm_widget_data_get(obj);
216    if (!wd) return;
217    edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
218                                    emission, source, func_cb, data);
219 }
220
221 static void
222 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
223 {
224    Widget_Data *wd = elm_widget_data_get(obj);
225    edje_object_signal_callback_del_full(
226       elm_smart_scroller_edje_object_get(wd->scr), emission, source,
227       func_cb, data);
228 }
229
230 static void
231 _show_region_hook(void *data, Evas_Object *obj)
232 {
233    Widget_Data *wd = elm_widget_data_get(data);
234    Evas_Coord x, y, w, h;
235    if (!wd) return;
236    elm_widget_show_region_get(obj, &x, &y, &w, &h);
237    if (wd->scr)
238      elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
239 }
240
241 static void
242 _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
243 {
244    Widget_Data *wd = elm_widget_data_get(obj);
245    if (wd->scr)
246      elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
247 }
248
249 static void
250 _sizing_eval(Evas_Object *obj)
251 {
252    Widget_Data *wd = elm_widget_data_get(obj);
253    Evas_Coord  vw, vh, minw = 0, minh = 0, maxw = 0, maxh = 0, w, h, vmw, vmh;
254    double xw = 0.0, yw = 0.0;
255
256    if (!wd) return;
257    if (wd->content)
258      {
259         evas_object_size_hint_min_get(wd->content, &minw, &minh);
260         evas_object_size_hint_max_get(wd->content, &maxw, &maxh);
261         evas_object_size_hint_weight_get(wd->content, &xw, &yw);
262      }
263    if (wd->scr)
264      {
265         elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
266         if (xw > 0.0)
267           {
268              if ((minw > 0) && (vw < minw)) vw = minw;
269              else if ((maxw > 0) && (vw > maxw)) vw = maxw;
270           }
271         else if (minw > 0) vw = minw;
272         if (yw > 0.0)
273           {
274              if ((minh > 0) && (vh < minh)) vh = minh;
275              else if ((maxh > 0) && (vh > maxh)) vh = maxh;
276           }
277         else if (minh > 0) vh = minh;
278         if (wd->content) evas_object_resize(wd->content, vw, vh);
279         w = -1;
280         h = -1;
281         edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
282         if (wd->min_w) w = vmw + minw;
283         if (wd->min_h) h = vmh + minh;
284         evas_object_size_hint_max_get(obj, &maxw, &maxh);
285         if ((maxw > 0) && (w > maxw)) w = maxw;
286         if ((maxh > 0) && (h > maxh)) h = maxh;
287         evas_object_size_hint_min_set(obj, w, h);
288      }
289 }
290
291 static void
292 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
293 {
294    _sizing_eval(data);
295 }
296
297 static void
298 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
299 {
300    Widget_Data *wd = elm_widget_data_get(obj);
301    Evas_Object *sub = event_info;
302
303    if (!wd) return;
304    if (sub == wd->content)
305      {
306         elm_widget_on_show_region_hook_set(wd->content, NULL, NULL);
307         evas_object_event_callback_del_full (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
308                                              _changed_size_hints, obj);
309         wd->content = NULL;
310         _sizing_eval(obj);
311      }
312    else if (sub == wd->scr)
313      wd->scr = NULL;
314 }
315
316 static void
317 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
318 {
319    Widget_Data *wd = elm_widget_data_get(obj);
320
321    if (!wd) return;
322    if (wd->scr)
323      elm_smart_scroller_hold_set(wd->scr, 1);
324 }
325
326 static void
327 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
328 {
329    Widget_Data *wd = elm_widget_data_get(obj);
330
331    if (!wd) return;
332    if (wd->scr)
333      elm_smart_scroller_hold_set(wd->scr, 0);
334 }
335
336 static void
337 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
338 {
339    Widget_Data *wd = elm_widget_data_get(obj);
340
341    if (!wd) return;
342    if (wd->scr)
343      elm_smart_scroller_freeze_set(wd->scr, 1);
344 }
345
346 static void
347 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
348 {
349    Widget_Data *wd = elm_widget_data_get(obj);
350
351    if (!wd) return;
352    if (wd->scr)
353      elm_smart_scroller_freeze_set(wd->scr, 0);
354 }
355
356 static void
357 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
358 {
359    _sizing_eval(data);
360 }
361
362 static void
363 _edge_left(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
364 {
365    evas_object_smart_callback_call(data, SIG_EDGE_LEFT, NULL);
366 }
367
368 static void
369 _edge_right(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
370 {
371    evas_object_smart_callback_call(data, SIG_EDGE_RIGHT, NULL);
372 }
373
374 static void
375 _edge_top(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
376 {
377    evas_object_smart_callback_call(data, SIG_EDGE_TOP, NULL);
378 }
379
380 static void
381 _edge_bottom(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
382 {
383    evas_object_smart_callback_call(data, SIG_EDGE_BOTTOM, NULL);
384 }
385
386 static void
387 _scroll(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
388 {
389    evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
390 }
391
392 static void
393 _scroll_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
394 {
395    evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
396 }
397
398 static void
399 _scroll_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
400 {
401    evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
402 }
403
404 static void
405 _scroll_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
406 {
407    evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
408 }
409
410 static void
411 _scroll_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
412 {
413    evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
414 }
415
416 Evas_Object *
417 _elm_scroller_edje_object_get(Evas_Object *obj)
418 {
419    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
420    Widget_Data *wd = elm_widget_data_get(obj);
421    if (!wd) return NULL;
422    return elm_smart_scroller_edje_object_get(wd->scr);
423 }
424
425 static void
426 _content_set_hook(Evas_Object *obj, const char *part __UNUSED__, Evas_Object *content)
427 {
428    ELM_CHECK_WIDTYPE(obj, widtype);
429    Widget_Data *wd = elm_widget_data_get(obj);
430    if (!wd) return;
431    if (wd->content == content) return;
432    if (wd->content) evas_object_del(wd->content);
433    wd->content = content;
434    if (content)
435      {
436         elm_widget_on_show_region_hook_set(content, _show_region_hook, obj);
437         elm_widget_sub_object_add(obj, content);
438         if (wd->scr)
439           elm_smart_scroller_child_set(wd->scr, content);
440         evas_object_event_callback_add(content,
441                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
442                                        _changed_size_hints, obj);
443      }
444    _sizing_eval(obj);
445 }
446
447 static Evas_Object *
448 _content_get_hook(const Evas_Object *obj, const char *part __UNUSED__)
449 {
450    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
451    Widget_Data *wd = elm_widget_data_get(obj);
452    if (!wd) return NULL;
453    return wd->content;
454 }
455
456 static Evas_Object *
457 _content_unset_hook(Evas_Object *obj, const char *part __UNUSED__)
458 {
459    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
460    Widget_Data *wd = elm_widget_data_get(obj);
461    Evas_Object *content;
462    if (!wd) return NULL;
463    if (!wd->content) return NULL;
464    content = wd->content;
465    elm_widget_sub_object_del(obj, wd->content);
466    evas_object_event_callback_del_full(wd->content,
467                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
468                                        _changed_size_hints, obj);
469    edje_object_part_unswallow(elm_smart_scroller_edje_object_get(wd->scr),
470                               wd->content);
471    wd->content = NULL;
472    return content;
473 }
474
475 EAPI Evas_Object *
476 elm_scroller_add(Evas_Object *parent)
477 {
478    Evas_Object *obj;
479    Evas *e;
480    Widget_Data *wd;
481    Evas_Coord minw, minh;
482
483    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
484
485    ELM_SET_WIDTYPE(widtype, "scroller");
486    elm_widget_type_set(obj, "scroller");
487    elm_widget_sub_object_add(parent, obj);
488    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
489    elm_widget_data_set(obj, wd);
490    elm_widget_del_hook_set(obj, _del_hook);
491    elm_widget_theme_hook_set(obj, _theme_hook);
492    elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
493    elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
494    elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
495    elm_widget_focus_next_hook_set(obj, _elm_scroller_focus_next_hook);
496    elm_widget_can_focus_set(obj, EINA_TRUE);
497    elm_widget_event_hook_set(obj, _event_hook);
498    elm_widget_focus_region_hook_set(obj, _focus_region_hook);
499    elm_widget_content_set_hook_set(obj, _content_set_hook);
500    elm_widget_content_get_hook_set(obj, _content_get_hook);
501    elm_widget_content_unset_hook_set(obj, _content_unset_hook);
502
503    wd->widget_name = eina_stringshare_add("scroller");
504    wd->widget_base = eina_stringshare_add("base");
505
506    wd->scr = elm_smart_scroller_add(e);
507    elm_smart_scroller_widget_set(wd->scr, obj);
508    _theme_hook(obj);
509    elm_widget_resize_object_set(obj, wd->scr);
510    evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
511                                   _changed_size_hints, obj);
512
513    edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &minw, &minh);
514    evas_object_size_hint_min_set(obj, minw, minh);
515    evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
516
517    evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
518    evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
519    evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
520    evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
521    evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
522
523    evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
524    evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
525    evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
526    evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom, obj);
527    evas_object_smart_callback_add(wd->scr, "scroll", _scroll, obj);
528    evas_object_smart_callback_add(wd->scr, "animate,start", _scroll_anim_start, obj);
529    evas_object_smart_callback_add(wd->scr, "animate,stop", _scroll_anim_stop, obj);
530    evas_object_smart_callback_add(wd->scr, "drag,start", _scroll_drag_start, obj);
531    evas_object_smart_callback_add(wd->scr, "drag,stop", _scroll_drag_stop, obj);
532
533    _sizing_eval(obj);
534
535    // TODO: convert Elementary to subclassing of Evas_Smart_Class
536    // TODO: and save some bytes, making descriptions per-class and not instance!
537    evas_object_smart_callbacks_descriptions_set(obj, _signals);
538    _mirrored_set(obj, elm_widget_mirrored_get(obj));
539    return obj;
540 }
541
542 EAPI void
543 elm_scroller_content_set(Evas_Object *obj, Evas_Object *content)
544 {
545    _content_set_hook(obj, NULL, content);
546 }
547
548 EAPI Evas_Object *
549 elm_scroller_content_get(const Evas_Object *obj)
550 {
551    return _content_get_hook(obj, NULL);
552 }
553
554 EAPI Evas_Object *
555 elm_scroller_content_unset(Evas_Object *obj)
556 {
557    return _content_unset_hook(obj, NULL);
558 }
559
560 EAPI void
561 elm_scroller_custom_widget_base_theme_set(Evas_Object *obj, const char *widget, const char *base)
562 {
563    ELM_CHECK_WIDTYPE(obj, widtype);
564    Widget_Data *wd = elm_widget_data_get(obj);
565    if (!wd) return;
566    EINA_SAFETY_ON_NULL_RETURN(widget);
567    EINA_SAFETY_ON_NULL_RETURN(base);
568    if (eina_stringshare_replace(&wd->widget_name, widget) |
569        eina_stringshare_replace(&wd->widget_base, base))
570      _theme_hook(obj);
571 }
572
573 EAPI void
574 elm_scroller_content_min_limit(Evas_Object *obj, Eina_Bool w, Eina_Bool h)
575 {
576    ELM_CHECK_WIDTYPE(obj, widtype);
577    Widget_Data *wd = elm_widget_data_get(obj);
578    if (!wd) return;
579    wd->min_w = w;
580    wd->min_h = h;
581    _sizing_eval(obj);
582 }
583
584 EAPI void
585 elm_scroller_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
586 {
587    ELM_CHECK_WIDTYPE(obj, widtype);
588    Widget_Data *wd = elm_widget_data_get(obj);
589    if ((!wd) || (!wd->scr)) return;
590    elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
591 }
592
593 EAPI void
594 elm_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
595 {
596    ELM_CHECK_WIDTYPE(obj, widtype);
597    Widget_Data *wd = elm_widget_data_get(obj);
598    const Elm_Scroller_Policy map[3] =
599      {
600         ELM_SMART_SCROLLER_POLICY_AUTO,
601         ELM_SMART_SCROLLER_POLICY_ON,
602         ELM_SMART_SCROLLER_POLICY_OFF
603      };
604    if ((!wd) || (!wd->scr)) return;
605    if ((policy_h >= 3) || (policy_v >= 3)) return;
606    elm_smart_scroller_policy_set(wd->scr, map[policy_h], map[policy_v]);
607 }
608
609 EAPI void
610 elm_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
611 {
612    ELM_CHECK_WIDTYPE(obj, widtype);
613    Widget_Data *wd = elm_widget_data_get(obj);
614    if ((!wd) || (!wd->scr)) return;
615    elm_smart_scroller_policy_get(wd->scr,
616                                  (Elm_Smart_Scroller_Policy *) policy_h,
617                                  (Elm_Smart_Scroller_Policy *) policy_v);
618 }
619
620 EAPI void
621 elm_scroller_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
622 {
623    ELM_CHECK_WIDTYPE(obj, widtype);
624    Widget_Data *wd = elm_widget_data_get(obj);
625    if ((!wd) || (!wd->scr)) return;
626    if ((x) || (y)) elm_smart_scroller_child_pos_get(wd->scr, x, y);
627    if ((w) || (h)) elm_smart_scroller_child_viewport_size_get(wd->scr, w, h);
628 }
629
630 EAPI void
631 elm_scroller_child_size_get(const Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
632 {
633    ELM_CHECK_WIDTYPE(obj, widtype);
634    Widget_Data *wd = elm_widget_data_get(obj);
635    if (!wd) return;
636    evas_object_geometry_get(wd->content, NULL, NULL, w, h);
637 }
638
639 EAPI void
640 elm_scroller_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
641 {
642    ELM_CHECK_WIDTYPE(obj, widtype);
643    Widget_Data *wd = elm_widget_data_get(obj);
644    if ((!wd) || (!wd->scr)) return;
645    elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
646 }
647
648 EAPI void
649 elm_scroller_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
650 {
651    ELM_CHECK_WIDTYPE(obj, widtype);
652    Widget_Data *wd = elm_widget_data_get(obj);
653    if (!wd) return;
654    elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
655 }
656
657 EAPI void
658 elm_scroller_page_relative_set(Evas_Object *obj, double h_pagerel, double v_pagerel)
659 {
660    ELM_CHECK_WIDTYPE(obj, widtype);
661    Widget_Data *wd = elm_widget_data_get(obj);
662    if (!wd) return;
663    wd->pagerel_h = h_pagerel;
664    wd->pagerel_v = v_pagerel;
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_page_size_set(Evas_Object *obj, Evas_Coord h_pagesize, Evas_Coord v_pagesize)
672 {
673    ELM_CHECK_WIDTYPE(obj, widtype);
674    Widget_Data *wd = elm_widget_data_get(obj);
675    if (!wd) return;
676    wd->pagesize_h = h_pagesize;
677    wd->pagesize_v = v_pagesize;
678    if (wd->scr)
679      elm_smart_scroller_paging_set(wd->scr, wd->pagerel_h, wd->pagerel_v,
680                                    wd->pagesize_h, wd->pagesize_v);
681 }
682
683 EAPI void
684 elm_scroller_current_page_get(Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
685 {
686    ELM_CHECK_WIDTYPE(obj, widtype);
687    Widget_Data *wd = elm_widget_data_get(obj);
688    if (!wd) return;
689    if (wd->scr)
690      elm_smart_scroller_current_page_get(wd->scr, h_pagenumber, v_pagenumber);
691 }
692
693 EAPI void
694 elm_scroller_last_page_get(Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
695 {
696    ELM_CHECK_WIDTYPE(obj, widtype);
697    Widget_Data *wd = elm_widget_data_get(obj);
698    if (!wd) return;
699    if (wd->scr)
700      elm_smart_scroller_last_page_get(wd->scr, h_pagenumber, v_pagenumber);
701 }
702
703 EAPI void
704 elm_scroller_page_show(Evas_Object *obj, int h_pagenumber, int v_pagenumber)
705 {
706    ELM_CHECK_WIDTYPE(obj, widtype);
707    Widget_Data *wd = elm_widget_data_get(obj);
708    if (!wd) return;
709    if (wd->scr)
710      elm_smart_scroller_page_show(wd->scr, h_pagenumber, v_pagenumber);
711 }
712
713 EAPI void
714 elm_scroller_page_bring_in(Evas_Object *obj, int h_pagenumber, int v_pagenumber)
715 {
716    ELM_CHECK_WIDTYPE(obj, widtype);
717    Widget_Data *wd = elm_widget_data_get(obj);
718    if (!wd) return;
719    if (wd->scr)
720      elm_smart_scroller_page_bring_in(wd->scr, h_pagenumber, v_pagenumber);
721 }
722
723 EAPI void
724 elm_scroller_region_bring_in(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
725 {
726    ELM_CHECK_WIDTYPE(obj, widtype);
727    Widget_Data *wd = elm_widget_data_get(obj);
728    if ((!wd) || (!wd->scr)) return;
729    elm_smart_scroller_region_bring_in(wd->scr, x, y, w, h);
730 }
731
732 EAPI void
733 elm_scroller_propagate_events_set(Evas_Object *obj, Eina_Bool propagation)
734 {
735    ELM_CHECK_WIDTYPE(obj, widtype);
736    Widget_Data *wd = elm_widget_data_get(obj);
737    if (!wd) return;
738
739    elm_smart_scroller_propagate_events_set(wd->scr, propagation);
740 }
741
742 EAPI Eina_Bool
743 elm_scroller_propagate_events_get(const Evas_Object *obj)
744 {
745    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
746    Widget_Data *wd = elm_widget_data_get(obj);
747    if (!wd) return EINA_FALSE;
748
749    return elm_smart_scroller_propagate_events_get(wd->scr);
750 }
751
752 EAPI void
753 elm_scroller_gravity_set(Evas_Object *obj, double x, double y)
754 {
755    ELM_CHECK_WIDTYPE(obj, widtype);
756    Widget_Data *wd = elm_widget_data_get(obj);
757    if (!wd) return;
758
759    elm_smart_scroller_gravity_set(wd->scr, x, y);
760 }
761
762 EAPI void
763 elm_scroller_gravity_get(const Evas_Object *obj, double *x, double *y)
764 {
765    ELM_CHECK_WIDTYPE(obj, widtype);
766    Widget_Data *wd = elm_widget_data_get(obj);
767    if (!wd) return;
768
769    elm_smart_scroller_gravity_get(wd->scr, x, y);
770 }
771
772 EAPI void
773 elm_scroller_page_move_set(Evas_Object *obj, Eina_Bool set)
774 {
775    return ;
776 }