Merge "[edje_externals/elm_datefield.c] Datefield widget external file is updated...
[framework/uifw/elementary.git] / src / lib / elm_list.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3 #include "els_scroller.h"
4
5 #define SWIPE_MOVES 12
6
7 typedef struct _Widget_Data Widget_Data;
8
9 struct _Widget_Data
10 {
11    Evas_Object *scr, *box, *self;
12    Eina_List *items, *selected, *to_delete;
13    Elm_List_Item *last_selected_item;
14    Elm_List_Mode mode;
15    Elm_List_Mode h_mode;
16    Evas_Coord minw[2], minh[2];
17    Eina_Bool scr_minw : 1;
18    Eina_Bool scr_minh : 1;
19    int walking;
20    int movements;
21    struct {
22         Evas_Coord x, y;
23    } history[SWIPE_MOVES];
24    Eina_Bool swipe : 1;
25    Eina_Bool fix_pending : 1;
26    Eina_Bool on_hold : 1;
27    Eina_Bool multi : 1;
28    Eina_Bool always_select : 1;
29    Eina_Bool longpressed : 1;
30    Eina_Bool wasselected : 1;
31 };
32
33 struct _Elm_List_Item
34 {
35    ELM_WIDGET_ITEM;
36    Widget_Data *wd;
37    Eina_List *node;
38    const char *label;
39    Evas_Object *icon, *end;
40    Evas_Smart_Cb func;
41    Ecore_Timer *long_timer;
42    Ecore_Timer *swipe_timer;
43    Eina_Bool deleted : 1;
44    Eina_Bool disabled : 1;
45    Eina_Bool even : 1;
46    Eina_Bool is_even : 1;
47    Eina_Bool is_separator : 1;
48    Eina_Bool fixed : 1;
49    Eina_Bool selected : 1;
50    Eina_Bool hilighted : 1;
51    Eina_Bool dummy_icon : 1;
52    Eina_Bool dummy_end : 1;
53 };
54
55 static const char *widtype = NULL;
56 static void _del_hook(Evas_Object *obj);
57 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
58 static void _theme_hook(Evas_Object *obj);
59 static void _sizing_eval(Evas_Object *obj);
60 static void _disable_hook(Evas_Object *obj);
61 static void _on_focus_hook(void *data, Evas_Object *obj);
62 static void _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source);
63 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
64 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
65 static void _fix_items(Evas_Object *obj);
66 static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
67 static void _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
68 static void _mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
69 static void _scroll_edge_left(void *data, Evas_Object *scr, void *event_info);
70 static void _scroll_edge_right(void *data, Evas_Object *scr, void *event_info);
71 static void _scroll_edge_top(void *data, Evas_Object *scr, void *event_info);
72 static void _scroll_edge_bottom(void *data, Evas_Object *scr, void *event_info);
73 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
74 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
75 static Eina_Bool _item_single_select_up(Widget_Data *wd);
76 static Eina_Bool _item_single_select_down(Widget_Data *wd);
77 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
78                              Evas_Callback_Type type, void *event_info);
79 static Eina_Bool _deselect_all_items(Widget_Data *wd);
80
81 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
82 static const char SIG_SELECTED[] = "selected";
83 static const char SIG_UNSELECTED[] = "unselected";
84 static const char SIG_LONGPRESSED[] = "longpressed";
85 static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
86 static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
87 static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
88 static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
89
90 static const Evas_Smart_Cb_Description _signals[] = {
91    {SIG_CLICKED_DOUBLE, ""},
92    {SIG_SELECTED, ""},
93    {SIG_UNSELECTED, ""},
94    {SIG_LONGPRESSED, ""},
95    {SIG_SCROLL_EDGE_TOP, ""},
96    {SIG_SCROLL_EDGE_BOTTOM, ""},
97    {SIG_SCROLL_EDGE_LEFT, ""},
98    {SIG_SCROLL_EDGE_RIGHT, ""},
99    {NULL, NULL}
100 };
101
102 #define ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ...)                      \
103    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, __VA_ARGS__);             \
104 if (it->deleted)                                                         \
105 {                                                                        \
106    ERR("ERROR: "#it" has been DELETED.\n");                              \
107    return __VA_ARGS__;                                                   \
108 }
109
110 static inline void
111 _elm_list_item_free(Elm_List_Item *it)
112 {
113    evas_object_event_callback_del_full
114       (VIEW(it), EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, it);
115    evas_object_event_callback_del_full
116       (VIEW(it), EVAS_CALLBACK_MOUSE_UP, _mouse_up, it);
117    evas_object_event_callback_del_full
118       (VIEW(it), EVAS_CALLBACK_MOUSE_MOVE, _mouse_move, it);
119
120    if (it->icon)
121      evas_object_event_callback_del_full
122         (it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
123          _changed_size_hints, WIDGET(it));
124
125    if (it->end)
126      evas_object_event_callback_del_full
127         (it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
128          _changed_size_hints, WIDGET(it));
129
130    eina_stringshare_del(it->label);
131
132    if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
133    if (it->long_timer) ecore_timer_del(it->long_timer);
134    if (it->icon) evas_object_del(it->icon);
135    if (it->end) evas_object_del(it->end);
136
137    elm_widget_item_del(it);
138 }
139
140 static Eina_Bool
141 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
142 {
143    if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
144    Evas_Event_Key_Down *ev = event_info;
145    Widget_Data *wd = elm_widget_data_get(obj);
146    if (!wd) return EINA_FALSE;
147    if (!wd->items) return EINA_FALSE;
148    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
149    if (elm_widget_disabled_get(obj)) return EINA_FALSE;
150
151    Elm_List_Item *it = NULL;
152    Evas_Coord x = 0;
153    Evas_Coord y = 0;
154    Evas_Coord step_x = 0;
155    Evas_Coord step_y = 0;
156    Evas_Coord v_w = 0;
157    Evas_Coord v_h = 0;
158    Evas_Coord page_x = 0;
159    Evas_Coord page_y = 0;
160
161    elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
162    elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
163    elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
164    elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
165
166    /* TODO: fix logic for horizontal mode */
167    if ((!strcmp(ev->keyname, "Left")) ||
168        (!strcmp(ev->keyname, "KP_Left")))
169      {
170         if ((wd->h_mode) &&
171             (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
172               (_item_multi_select_up(wd)))
173              || (_item_single_select_up(wd))))
174           {
175              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
176              return EINA_TRUE;
177           }
178         else
179           x -= step_x;
180      }
181    else if ((!strcmp(ev->keyname, "Right")) ||
182             (!strcmp(ev->keyname, "KP_Right")))
183      {
184         if ((wd->h_mode) &&
185             (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
186               (_item_multi_select_down(wd)))
187              || (_item_single_select_down(wd))))
188           {
189              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
190              return EINA_TRUE;
191           }
192         else
193           x += step_x;
194      }
195    else if ((!strcmp(ev->keyname, "Up"))  ||
196             (!strcmp(ev->keyname, "KP_Up")))
197      {
198         if ((!wd->h_mode) &&
199             (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
200               (_item_multi_select_up(wd)))
201              || (_item_single_select_up(wd))))
202           {
203              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
204              return EINA_TRUE;
205           }
206         else
207           y -= step_y;
208      }
209    else if ((!strcmp(ev->keyname, "Down")) ||
210             (!strcmp(ev->keyname, "KP_Down")))
211      {
212         if ((!wd->h_mode) &&
213             (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
214               (_item_multi_select_down(wd)))
215              || (_item_single_select_down(wd))))
216           {
217              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
218              return EINA_TRUE;
219           }
220         else
221           y += step_y;
222      }
223    else if ((!strcmp(ev->keyname, "Home")) ||
224             (!strcmp(ev->keyname, "KP_Home")))
225      {
226         it = eina_list_data_get(wd->items);
227         elm_list_item_bring_in(it);
228         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
229         return EINA_TRUE;
230      }
231    else if ((!strcmp(ev->keyname, "End")) ||
232             (!strcmp(ev->keyname, "KP_End")))
233      {
234         it = eina_list_data_get(eina_list_last(wd->items));
235         elm_list_item_bring_in(it);
236         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
237         return EINA_TRUE;
238      }
239    else if ((!strcmp(ev->keyname, "Prior")) ||
240             (!strcmp(ev->keyname, "KP_Prior")))
241      {
242         if (wd->h_mode)
243           {
244              if (page_x < 0)
245                x -= -(page_x * v_w) / 100;
246              else
247                x -= page_x;
248           }
249         else
250           {
251              if (page_y < 0)
252                y -= -(page_y * v_h) / 100;
253              else
254                y -= page_y;
255           }
256      }
257    else if ((!strcmp(ev->keyname, "Next")) ||
258             (!strcmp(ev->keyname, "KP_Next")))
259      {
260         if (wd->h_mode)
261           {
262              if (page_x < 0)
263                x += -(page_x * v_w) / 100;
264              else
265                x += page_x;
266           }
267         else
268           {
269              if (page_y < 0)
270                y += -(page_y * v_h) / 100;
271              else
272                y += page_y;
273           }
274      }
275    else if (!strcmp(ev->keyname, "Escape"))
276      {
277         if (!_deselect_all_items(wd)) return EINA_FALSE;
278         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
279         return EINA_TRUE;
280      }
281    else return EINA_FALSE;
282
283    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
284    elm_smart_scroller_child_pos_set(wd->scr, x, y);
285    return EINA_TRUE;
286 }
287
288 static void
289 _translate_hook(Evas_Object *obj)
290 {
291    evas_object_smart_callback_call(obj, "language,changed", NULL);
292 }
293
294 static Eina_Bool
295 _deselect_all_items(Widget_Data *wd)
296 {
297    if (!wd->selected) return EINA_FALSE;
298    while (wd->selected)
299      elm_list_item_selected_set(wd->selected->data, EINA_FALSE);
300
301    return EINA_TRUE;
302 }
303
304 static Eina_Bool
305 _item_multi_select_up(Widget_Data *wd)
306 {
307    if (!wd->selected) return EINA_FALSE;
308    if (!wd->multi) return EINA_FALSE;
309
310    Elm_List_Item *prev = elm_list_item_prev(wd->last_selected_item);
311    if (!prev) return EINA_TRUE;
312
313    if (elm_list_item_selected_get(prev))
314      {
315         elm_list_item_selected_set(wd->last_selected_item, EINA_FALSE);
316         wd->last_selected_item = prev;
317         elm_list_item_show(wd->last_selected_item);
318      }
319    else
320      {
321         elm_list_item_selected_set(prev, EINA_TRUE);
322         elm_list_item_show(prev);
323      }
324    return EINA_TRUE;
325 }
326
327 static Eina_Bool
328 _item_multi_select_down(Widget_Data *wd)
329 {
330    if (!wd->selected) return EINA_FALSE;
331    if (!wd->multi) return EINA_FALSE;
332
333    Elm_List_Item *next = elm_list_item_next(wd->last_selected_item);
334    if (!next) return EINA_TRUE;
335
336    if (elm_list_item_selected_get(next))
337      {
338         elm_list_item_selected_set(wd->last_selected_item, EINA_FALSE);
339         wd->last_selected_item = next;
340         elm_list_item_show(wd->last_selected_item);
341      }
342    else
343      {
344         elm_list_item_selected_set(next, EINA_TRUE);
345         elm_list_item_show(next);
346      }
347    return EINA_TRUE;
348 }
349
350 static Eina_Bool
351 _item_single_select_up(Widget_Data *wd)
352 {
353    Elm_List_Item *prev;
354
355    if (!wd->selected) prev = eina_list_data_get(eina_list_last(wd->items));
356    else prev = elm_list_item_prev(wd->last_selected_item);
357
358    if (!prev) return EINA_FALSE;
359
360    _deselect_all_items(wd);
361
362    elm_list_item_selected_set(prev, EINA_TRUE);
363    elm_list_item_show(prev);
364    return EINA_TRUE;
365 }
366
367 static Eina_Bool
368 _item_single_select_down(Widget_Data *wd)
369 {
370    Elm_List_Item *next;
371
372    if (!wd->selected) next = eina_list_data_get(wd->items);
373    else next = elm_list_item_next(wd->last_selected_item);
374
375    if (!next) return EINA_FALSE;
376
377    _deselect_all_items(wd);
378
379    elm_list_item_selected_set(next, EINA_TRUE);
380    elm_list_item_show(next);
381    return EINA_TRUE;
382 }
383
384 static void
385 _elm_list_process_deletions(Widget_Data *wd)
386 {
387    Elm_List_Item *it;
388
389    wd->walking++; // avoid nested deletion and also _sub_del() fix_items
390
391    EINA_LIST_FREE(wd->to_delete, it)
392      {
393         elm_widget_item_pre_notify_del(it);
394
395         wd->items = eina_list_remove_list(wd->items, it->node);
396         _elm_list_item_free(it);
397      }
398
399    wd->walking--;
400 }
401
402 static inline void
403 _elm_list_walk(Widget_Data *wd)
404 {
405    if (wd->walking < 0)
406      {
407         ERR("ERROR: walking was negative. fixed!\n");
408         wd->walking = 0;
409      }
410    wd->walking++;
411 }
412
413 static inline void
414 _elm_list_unwalk(Widget_Data *wd)
415 {
416    wd->walking--;
417    if (wd->walking < 0)
418      {
419         ERR("ERROR: walking became negative. fixed!\n");
420         wd->walking = 0;
421      }
422
423    if (wd->walking)
424      return;
425
426    if (wd->to_delete)
427      _elm_list_process_deletions(wd);
428
429    if (wd->fix_pending)
430      {
431         wd->fix_pending = EINA_FALSE;
432         _fix_items(wd->self);
433         _sizing_eval(wd->self);
434      }
435 }
436
437 static void
438 _del_pre_hook(Evas_Object *obj)
439 {
440    Widget_Data *wd = elm_widget_data_get(obj);
441    if (!wd) return;
442
443    evas_object_event_callback_del(wd->scr,
444                                   EVAS_CALLBACK_CHANGED_SIZE_HINTS,
445                                   _changed_size_hints);
446    evas_object_event_callback_del(wd->box,
447                                   EVAS_CALLBACK_CHANGED_SIZE_HINTS,
448                                   _changed_size_hints);
449 }
450
451 static void
452 _del_hook(Evas_Object *obj)
453 {
454    Widget_Data *wd = elm_widget_data_get(obj);
455    Elm_List_Item *it;
456    Eina_List *n;
457
458    if (!wd) return;
459    if (wd->walking)
460      ERR("ERROR: list deleted while walking.\n");
461
462    _elm_list_walk(wd);
463    EINA_LIST_FOREACH(wd->items, n, it) elm_widget_item_pre_notify_del(it);
464    _elm_list_unwalk(wd);
465    if (wd->to_delete)
466      ERR("ERROR: leaking nodes!\n");
467
468    EINA_LIST_FREE(wd->items, it) _elm_list_item_free(it);
469    eina_list_free(wd->selected);
470    free(wd);
471 }
472
473 static void
474 _show_region_hook(void *data, Evas_Object *obj)
475 {
476    Widget_Data *wd = elm_widget_data_get(data);
477    Evas_Coord x, y, w, h;
478    if (!wd) return;
479    elm_widget_show_region_get(obj, &x, &y, &w, &h);
480    elm_smart_scroller_child_region_set(wd->scr, x, y, w, h);
481 }
482
483 static void
484 _disable_hook(Evas_Object *obj)
485 {
486    Widget_Data *wd = elm_widget_data_get(obj);
487    if (!wd) return;
488    if (elm_widget_disabled_get(obj))
489      {
490         _signal_emit_hook(obj, "elm,state,disabled", "elm");
491         elm_widget_scroll_freeze_push(obj);
492         elm_widget_scroll_hold_push(obj);
493         /* FIXME: if we get to have a way to only un-hilight items
494          * in the future, keeping them selected... */
495         _deselect_all_items(wd);
496      }
497    else
498      {
499         _signal_emit_hook(obj, "elm,state,enabled", "elm");
500         elm_widget_scroll_freeze_pop(obj);
501         elm_widget_scroll_hold_pop(obj);
502      }
503 }
504
505 static void
506 _sizing_eval(Evas_Object *obj)
507 {
508
509    Widget_Data *wd = elm_widget_data_get(obj);
510    if (!wd) return;
511    Evas_Coord  vw, vh, minw, minh, maxw, maxh, w, h, vmw, vmh;
512    double xw, yw;
513
514    evas_object_size_hint_min_get(wd->box, &minw, &minh);
515    evas_object_size_hint_max_get(wd->box, &maxw, &maxh);
516    evas_object_size_hint_weight_get(wd->box, &xw, &yw);
517    if (!wd->scr) return;
518    elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
519    if (xw > 0.0)
520      {
521         if ((minw > 0) && (vw < minw)) vw = minw;
522         else if ((maxw > 0) && (vw > maxw)) vw = maxw;
523      }
524    else if (minw > 0) vw = minw;
525    if (yw > 0.0)
526      {
527         if ((minh > 0) && (vh < minh)) vh = minh;
528         else if ((maxh > 0) && (vh > maxh)) vh = maxh;
529      }
530    else if (minh > 0) vh = minh;
531    evas_object_resize(wd->box, vw, vh);
532    w = -1;
533    h = -1;
534    edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
535                              &vmw, &vmh);
536    if (wd->scr_minw) w = vmw + minw;
537    if (wd->scr_minh) h = vmh + minh;
538
539    evas_object_size_hint_max_get(obj, &maxw, &maxh);
540    if ((maxw > 0) && (w > maxw))
541      w = maxw;
542    if ((maxh > 0) && (h > maxh))
543      h = maxh;
544
545    evas_object_size_hint_min_set(obj, w, h);
546 }
547
548 static void
549 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
550 {
551    Widget_Data *wd = elm_widget_data_get(obj);
552    edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
553                            emission, source);
554 }
555
556 static void
557 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
558 {
559    Widget_Data *wd = elm_widget_data_get(obj);
560    edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
561                                    emission, source, func_cb, data);
562 }
563
564 static void
565 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
566 {
567    Widget_Data *wd = elm_widget_data_get(obj);
568    edje_object_signal_callback_del_full(
569       elm_smart_scroller_edje_object_get(wd->scr),
570       emission, source, func_cb, data);
571 }
572
573 static void
574 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
575 {
576    Widget_Data *wd = elm_widget_data_get(obj);
577    Elm_List_Item *it;
578    Eina_List *n;
579
580    if (!wd) return;
581    if (wd->scr)
582      elm_smart_scroller_mirrored_set(wd->scr, rtl);
583
584    EINA_LIST_FOREACH(wd->items, n, it)
585       edje_object_mirrored_set(VIEW(it), rtl);
586 }
587
588 static void
589 _theme_hook(Evas_Object *obj)
590 {
591    Widget_Data *wd = elm_widget_data_get(obj);
592    Elm_List_Item *it;
593    Eina_List *n;
594
595    if (!wd) return;
596    _elm_widget_mirrored_reload(obj);
597    _mirrored_set(obj, elm_widget_mirrored_get(obj));
598
599    if (wd->scr)
600      {
601         Evas_Object *edj;
602         const char *str;
603
604         elm_smart_scroller_object_theme_set(obj, wd->scr, "list", "base",
605                                             elm_widget_style_get(obj));
606         //        edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
607         edj = elm_smart_scroller_edje_object_get(wd->scr);
608         str = edje_object_data_get(edj, "focus_highlight");
609         if ((str) && (!strcmp(str, "on")))
610           elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
611         else
612           elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
613         elm_object_style_set(wd->scr, elm_widget_style_get(obj));
614      }
615    EINA_LIST_FOREACH(wd->items, n, it)
616      {
617         edje_object_scale_set(VIEW(it), elm_widget_scale_get(obj) * _elm_config->scale);
618         it->fixed = 0;
619      }
620    _fix_items(obj);
621    _sizing_eval(obj);
622 }
623
624 static void
625 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
626 {
627    Widget_Data *wd = elm_widget_data_get(obj);
628    if (!wd) return;
629    if (elm_widget_focus_get(obj))
630      {
631         edje_object_signal_emit(wd->self, "elm,action,focus", "elm");
632         evas_object_focus_set(wd->self, EINA_TRUE);
633
634         if ((wd->selected) && (!wd->last_selected_item))
635           wd->last_selected_item = eina_list_data_get(wd->selected);
636      }
637    else
638      {
639         edje_object_signal_emit(wd->self, "elm,action,unfocus", "elm");
640         evas_object_focus_set(wd->self, EINA_FALSE);
641      }
642 }
643
644 static void
645 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
646 {
647    Widget_Data *wd = elm_widget_data_get(data);
648    if (!wd) return;
649    _fix_items(data);
650    _sizing_eval(data);
651 }
652
653 static void
654 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
655 {
656    Widget_Data *wd = elm_widget_data_get(obj);
657    Evas_Object *sub = event_info;
658    const Eina_List *l;
659    Elm_List_Item *it;
660
661    if (!wd) return;
662    if (!sub) abort();
663    if ((sub == wd->box) || (sub == wd->scr)) return;
664
665    EINA_LIST_FOREACH(wd->items, l, it)
666      {
667         if ((sub == it->icon) || (sub == it->end))
668           {
669              if (it->icon == sub) it->icon = NULL;
670              if (it->end == sub) it->end = NULL;
671              evas_object_event_callback_del_full
672              (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints,
673               obj);
674              if (!wd->walking)
675                {
676                   _fix_items(obj);
677                   _sizing_eval(obj);
678                }
679              else
680                wd->fix_pending = EINA_TRUE;
681              break;
682           }
683      }
684 }
685
686 static void
687 _item_hilight(Elm_List_Item *it)
688 {
689    Evas_Object *obj = WIDGET(it);
690    Widget_Data *wd = elm_widget_data_get(obj);
691    const char *selectraise;
692
693    if (!wd) return;
694    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
695    if (it->hilighted) return;
696
697    evas_object_ref(obj);
698    _elm_list_walk(wd);
699
700    edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
701    selectraise = edje_object_data_get(VIEW(it), "selectraise");
702    if ((selectraise) && (!strcmp(selectraise, "on")))
703      evas_object_raise(VIEW(it));
704    it->hilighted = EINA_TRUE;
705
706    _elm_list_unwalk(wd);
707    evas_object_unref(obj);
708 }
709
710 static void
711 _item_select(Elm_List_Item *it)
712 {
713    Evas_Object *obj = WIDGET(it);
714    Widget_Data *wd = elm_widget_data_get(obj);
715
716    if (!wd) return;
717    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
718    if (it->selected)
719      {
720         if (wd->always_select) goto call;
721         return;
722      }
723    it->selected = EINA_TRUE;
724    wd->selected = eina_list_append(wd->selected, it);
725
726 call:
727    evas_object_ref(obj);
728    _elm_list_walk(wd);
729
730    if (it->func) it->func((void *)it->base.data, WIDGET(it), it);
731    evas_object_smart_callback_call(obj, SIG_SELECTED, it);
732    it->wd->last_selected_item = it;
733
734    _elm_list_unwalk(wd);
735    evas_object_unref(obj);
736 }
737
738 static void
739 _item_unselect(Elm_List_Item *it)
740 {
741    Evas_Object *obj = WIDGET(it);
742    Widget_Data *wd = elm_widget_data_get(obj);
743    const char *stacking, *selectraise;
744
745    if (!wd) return;
746    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
747    if (!it->hilighted) return;
748
749    evas_object_ref(obj);
750    _elm_list_walk(wd);
751
752    edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
753    stacking = edje_object_data_get(VIEW(it), "stacking");
754    selectraise = edje_object_data_get(VIEW(it), "selectraise");
755    if ((selectraise) && (!strcmp(selectraise, "on")))
756      {
757         if ((stacking) && (!strcmp(stacking, "below")))
758           evas_object_lower(VIEW(it));
759      }
760    it->hilighted = EINA_FALSE;
761    if (it->selected)
762      {
763         it->selected = EINA_FALSE;
764         wd->selected = eina_list_remove(wd->selected, it);
765         evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
766      }
767
768    _elm_list_unwalk(wd);
769    evas_object_unref(obj);
770 }
771
772 static Eina_Bool
773 _swipe_cancel(void *data)
774 {
775    Elm_List_Item *it = data;
776    Widget_Data *wd = elm_widget_data_get(WIDGET(it));
777
778    if (!wd) return ECORE_CALLBACK_CANCEL;
779    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
780    wd->swipe = EINA_FALSE;
781    wd->movements = 0;
782    return ECORE_CALLBACK_RENEW;
783 }
784
785 static void
786 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
787 {
788    Elm_List_Item *it = data;
789    Evas_Object *obj2 = WIDGET(it);
790    Widget_Data *wd = elm_widget_data_get(obj2);
791    Evas_Event_Mouse_Move *ev = event_info;
792
793    if (!wd) return;
794    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
795
796    evas_object_ref(obj2);
797    _elm_list_walk(wd);
798
799    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
800      {
801         if (!wd->on_hold)
802           {
803              wd->on_hold = EINA_TRUE;
804              if (it->long_timer)
805                {
806                   ecore_timer_del(it->long_timer);
807                   it->long_timer = NULL;
808                }
809              if (!wd->wasselected)
810                _item_unselect(it);
811           }
812         if (wd->movements == SWIPE_MOVES) wd->swipe = EINA_TRUE;
813         else
814           {
815              wd->history[wd->movements].x = ev->cur.canvas.x;
816              wd->history[wd->movements].y = ev->cur.canvas.y;
817              if (abs((wd->history[wd->movements].x - wd->history[0].x)) > 40)
818                wd->swipe = EINA_TRUE;
819              else
820                wd->movements++;
821           }
822      }
823
824    _elm_list_unwalk(wd);
825    evas_object_unref(obj2);
826 }
827
828 static void
829 _scroll_edge_left(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
830 {
831    Evas_Object *obj = data;
832    evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
833 }
834
835 static void
836 _scroll_edge_right(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
837 {
838    Evas_Object *obj = data;
839    evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
840 }
841
842 static void
843 _scroll_edge_top(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
844 {
845    Evas_Object *obj = data;
846    evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
847 }
848
849 static void
850 _scroll_edge_bottom(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
851 {
852    Evas_Object *obj = data;
853    evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
854 }
855
856 static Eina_Bool
857 _long_press(void *data)
858 {
859    Elm_List_Item *it = data;
860    Evas_Object *obj = WIDGET(it);
861    Widget_Data *wd = elm_widget_data_get(obj);
862
863    if (!wd) goto end;
864
865    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ECORE_CALLBACK_CANCEL);
866    it->long_timer = NULL;
867    if (it->disabled) goto end;
868
869    wd->longpressed = EINA_TRUE;
870    evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
871
872 end:
873    return ECORE_CALLBACK_CANCEL;
874 }
875
876 static void
877 _swipe(Elm_List_Item *it)
878 {
879    int i, sum = 0;
880    Widget_Data *wd = elm_widget_data_get(WIDGET(it));
881
882    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
883    if (!wd) return;
884    wd->swipe = EINA_FALSE;
885    for (i = 0; i < wd->movements; i++)
886      {
887         sum += wd->history[i].x;
888         if (abs(wd->history[0].y - wd->history[i].y) > 10) return;
889      }
890
891    sum /= wd->movements;
892    if (abs(sum - wd->history[0].x) <= 10) return;
893    evas_object_smart_callback_call(WIDGET(it), "swipe", it);
894 }
895
896 static void
897 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
898 {
899    Elm_List_Item *it = data;
900    Evas_Object *obj2 = WIDGET(it);
901    Widget_Data *wd = elm_widget_data_get(obj2);
902    Evas_Event_Mouse_Down *ev = event_info;
903
904    if (!wd) return;
905    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
906    if (ev->button != 1) return;
907    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
908    else wd->on_hold = EINA_FALSE;
909    if (wd->on_hold) return;
910    wd->wasselected = it->selected;
911
912    evas_object_ref(obj2);
913    _elm_list_walk(wd);
914
915    _item_hilight(it);
916    wd->longpressed = EINA_FALSE;
917    if (it->long_timer) ecore_timer_del(it->long_timer);
918    it->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, it);
919    if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
920    it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
921    /* Always call the callbacks last - the user may delete our context! */
922    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
923      evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
924    wd->swipe = EINA_FALSE;
925    wd->movements = 0;
926
927    _elm_list_unwalk(wd);
928    evas_object_unref(obj2);
929 }
930
931 static void
932 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
933 {
934    Elm_List_Item *it = data;
935    Evas_Object *obj2 = WIDGET(it);
936    Widget_Data *wd = elm_widget_data_get(obj2);
937    Evas_Event_Mouse_Up *ev = event_info;
938
939    if (!wd) return;
940    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
941    if (ev->button != 1) return;
942    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
943    else wd->on_hold = EINA_FALSE;
944    wd->longpressed = EINA_FALSE;
945    if (it->long_timer)
946      {
947         ecore_timer_del(it->long_timer);
948         it->long_timer = NULL;
949      }
950    if (it->swipe_timer)
951      {
952         ecore_timer_del(it->swipe_timer);
953         it->swipe_timer = NULL;
954      }
955    if (wd->on_hold)
956      {
957         if (wd->swipe) _swipe(data);
958         wd->on_hold = EINA_FALSE;
959         return;
960      }
961    if (wd->longpressed)
962      {
963         if (!wd->wasselected) _item_unselect(it);
964         wd->wasselected = 0;
965         return;
966      }
967
968    if (it->disabled)
969      return;
970    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
971
972    evas_object_ref(obj2);
973    _elm_list_walk(wd);
974
975    if (wd->multi)
976      {
977         if (!it->selected)
978           {
979              _item_hilight(it);
980              _item_select(it);
981           }
982         else _item_unselect(it);
983      }
984    else
985      {
986         if (!it->selected)
987           {
988              while (wd->selected)
989                _item_unselect(wd->selected->data);
990              _item_hilight(it);
991              _item_select(it);
992           }
993         else
994           {
995              const Eina_List *l, *l_next;
996              Elm_List_Item *it2;
997
998              EINA_LIST_FOREACH_SAFE(wd->selected, l, l_next, it2)
999                 if (it2 != it) _item_unselect(it2);
1000              _item_hilight(it);
1001              _item_select(it);
1002           }
1003      }
1004
1005    _elm_list_unwalk(wd);
1006    evas_object_unref(obj2);
1007 }
1008
1009 static Elm_List_Item *
1010 _item_new(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1011 {
1012    Widget_Data *wd = elm_widget_data_get(obj);
1013    Elm_List_Item *it;
1014
1015    if (!wd) return NULL;
1016    it = elm_widget_item_new(obj, Elm_List_Item);
1017    it->wd = wd;
1018    it->label = eina_stringshare_add(label);
1019    it->icon = icon;
1020    it->end = end;
1021    it->func = func;
1022    it->base.data = data;
1023    VIEW(it) = edje_object_add(evas_object_evas_get(obj));
1024    edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(obj));
1025    evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1026                                   _mouse_down, it);
1027    evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1028                                   _mouse_up, it);
1029    evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1030                                   _mouse_move, it);
1031    evas_object_size_hint_weight_set(VIEW(it), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1032    evas_object_size_hint_align_set(VIEW(it), EVAS_HINT_FILL, EVAS_HINT_FILL);
1033    if (it->icon)
1034      {
1035         elm_widget_sub_object_add(obj, it->icon);
1036         evas_object_event_callback_add(it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1037                                        _changed_size_hints, obj);
1038      }
1039    if (it->end)
1040      {
1041         elm_widget_sub_object_add(obj, it->end);
1042         evas_object_event_callback_add(it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1043                                        _changed_size_hints, obj);
1044      }
1045    return it;
1046 }
1047
1048 static void
1049 _elm_list_mode_set_internal(Widget_Data *wd)
1050 {
1051    if (!wd->scr)
1052      return;
1053
1054    if (wd->mode == ELM_LIST_LIMIT)
1055      {
1056         if (!wd->h_mode)
1057           {
1058              wd->scr_minw = EINA_TRUE;
1059              wd->scr_minh = EINA_FALSE;
1060           }
1061         else
1062           {
1063              wd->scr_minw = EINA_FALSE;
1064              wd->scr_minh = EINA_TRUE;
1065           }
1066      }
1067    else if (wd->mode == ELM_LIST_EXPAND)
1068      {
1069         wd->scr_minw = EINA_TRUE;
1070         wd->scr_minh = EINA_TRUE;
1071      }
1072    else
1073      {
1074         wd->scr_minw = EINA_FALSE;
1075         wd->scr_minh = EINA_FALSE;
1076      }
1077
1078    _sizing_eval(wd->self);
1079 }
1080
1081 static void
1082 _fix_items(Evas_Object *obj)
1083 {
1084    Widget_Data *wd = elm_widget_data_get(obj);
1085    if (!wd) return;
1086    const Eina_List *l;
1087    Elm_List_Item *it;
1088    Evas_Coord minw[2] = { 0, 0 }, minh[2] = { 0, 0 };
1089    Evas_Coord mw, mh;
1090    int i, redo = 0;
1091    const char *style = elm_widget_style_get(obj);
1092    const char *it_plain = wd->h_mode ? "h_item" : "item";
1093    const char *it_odd = wd->h_mode ? "h_item_odd" : "item_odd";
1094    const char *it_compress = wd->h_mode ? "h_item_compress" : "item_compress";
1095    const char *it_compress_odd = wd->h_mode ? "h_item_compress_odd" : "item_compress_odd";
1096
1097    if (wd->walking)
1098      {
1099         wd->fix_pending = EINA_TRUE;
1100         return;
1101      }
1102
1103    evas_object_ref(obj);
1104    _elm_list_walk(wd); // watch out "return" before unwalk!
1105
1106    EINA_LIST_FOREACH(wd->items, l, it)
1107      {
1108         if (it->deleted) continue;
1109         if (it->icon)
1110           {
1111              evas_object_size_hint_min_get(it->icon, &mw, &mh);
1112              if (mw > minw[0]) minw[0] = mw;
1113              if (mh > minh[0]) minh[0] = mh;
1114           }
1115         if (it->end)
1116           {
1117              evas_object_size_hint_min_get(it->end, &mw, &mh);
1118              if (mw > minw[1]) minw[1] = mw;
1119              if (mh > minh[1]) minh[1] = mh;
1120           }
1121      }
1122
1123    if ((minw[0] != wd->minw[0]) || (minw[1] != wd->minw[1]) ||
1124        (minw[0] != wd->minh[0]) || (minh[1] != wd->minh[1]))
1125      {
1126         wd->minw[0] = minw[0];
1127         wd->minw[1] = minw[1];
1128         wd->minh[0] = minh[0];
1129         wd->minh[1] = minh[1];
1130         redo = 1;
1131      }
1132    i = 0;
1133    EINA_LIST_FOREACH(wd->items, l, it)
1134      {
1135         if (it->deleted)
1136           continue;
1137
1138         it->even = i & 0x1;
1139         if ((it->even != it->is_even) || (!it->fixed) || (redo))
1140           {
1141              const char *stacking;
1142
1143              /* FIXME: separators' themes seem to be b0rked */
1144              if (it->is_separator)
1145                _elm_theme_object_set(obj, VIEW(it), "separator",
1146                                      wd->h_mode ? "horizontal" : "vertical",
1147                                      style);
1148              else if (wd->mode == ELM_LIST_COMPRESS)
1149                {
1150                   if (it->even)
1151                     _elm_theme_object_set(obj, VIEW(it), "list",
1152                                           it_compress, style);
1153                   else
1154                     _elm_theme_object_set(obj, VIEW(it), "list",
1155                                           it_compress_odd, style);
1156                }
1157              else
1158                {
1159                   if (it->even)
1160                     _elm_theme_object_set(obj, VIEW(it), "list", it_plain,
1161                                           style);
1162                   else
1163                     _elm_theme_object_set(obj, VIEW(it), "list", it_odd,
1164                                           style);
1165                }
1166              stacking = edje_object_data_get(VIEW(it), "stacking");
1167              if (stacking)
1168                {
1169                   if (!strcmp(stacking, "below"))
1170                     evas_object_lower(VIEW(it));
1171                   else if (!strcmp(stacking, "above"))
1172                     evas_object_raise(VIEW(it));
1173                }
1174              edje_object_part_text_set(VIEW(it), "elm.text", it->label);
1175
1176              if ((!it->icon) && (minh[0] > 0))
1177                {
1178                   it->icon = evas_object_rectangle_add(evas_object_evas_get(VIEW(it)));
1179                   evas_object_color_set(it->icon, 0, 0, 0, 0);
1180                   it->dummy_icon = EINA_TRUE;
1181                }
1182              if ((!it->end) && (minh[1] > 0))
1183                {
1184                   it->end = evas_object_rectangle_add(evas_object_evas_get(VIEW(it)));
1185                   evas_object_color_set(it->end, 0, 0, 0, 0);
1186                   it->dummy_end = EINA_TRUE;
1187                }
1188              if (it->icon)
1189                {
1190                   evas_object_size_hint_min_set(it->icon, minw[0], minh[0]);
1191                   evas_object_size_hint_max_set(it->icon, 99999, 99999);
1192                   edje_object_part_swallow(VIEW(it), "elm.swallow.icon", it->icon);
1193                }
1194              if (it->end)
1195                {
1196                   evas_object_size_hint_min_set(it->end, minw[1], minh[1]);
1197                   evas_object_size_hint_max_set(it->end, 99999, 99999);
1198                   edje_object_part_swallow(VIEW(it), "elm.swallow.end", it->end);
1199                }
1200              if (!it->fixed)
1201                {
1202                   // this may call up user and it may modify the list item
1203                   // but we're safe as we're flagged as walking.
1204                   // just don't process further
1205                   edje_object_message_signal_process(VIEW(it));
1206                   if (it->deleted)
1207                     continue;
1208                   mw = mh = -1;
1209                   elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1210                   edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh);
1211                   elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1212                   evas_object_size_hint_min_set(VIEW(it), mw, mh);
1213                   evas_object_show(VIEW(it));
1214                }
1215              if ((it->selected) || (it->hilighted))
1216                {
1217                   const char *selectraise;
1218
1219                   // this may call up user and it may modify the list item
1220                   // but we're safe as we're flagged as walking.
1221                   // just don't process further
1222                   edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
1223                   if (it->deleted)
1224                     continue;
1225
1226                   selectraise = edje_object_data_get(VIEW(it), "selectraise");
1227                   if ((selectraise) && (!strcmp(selectraise, "on")))
1228                     evas_object_raise(VIEW(it));
1229                }
1230              if (it->disabled)
1231                edje_object_signal_emit(VIEW(it), "elm,state,disabled",
1232                                        "elm");
1233
1234              it->fixed = EINA_TRUE;
1235              it->is_even = it->even;
1236           }
1237         i++;
1238      }
1239
1240    mw = 0; mh = 0;
1241    evas_object_size_hint_min_get(wd->box, &mw, &mh);
1242
1243    _elm_list_mode_set_internal(wd);
1244
1245    _elm_list_unwalk(wd);
1246    evas_object_unref(obj);
1247 }
1248
1249 static void
1250 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1251 {
1252    Widget_Data *wd = elm_widget_data_get(obj);
1253    if (!wd) return;
1254    if (wd->scr)
1255      elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
1256 }
1257
1258 static void
1259 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1260 {
1261    Widget_Data *wd = elm_widget_data_get(obj);
1262    if (!wd) return;
1263    if (wd->scr)
1264      elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1265 }
1266
1267 static void
1268 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1269 {
1270    Widget_Data *wd = elm_widget_data_get(obj);
1271    if (!wd) return;
1272    if (wd->scr)
1273      elm_smart_scroller_freeze_set(wd->scr, EINA_TRUE);
1274 }
1275
1276 static void
1277 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1278 {
1279    Widget_Data *wd = elm_widget_data_get(obj);
1280    if (!wd) return;
1281    if (wd->scr)
1282      elm_smart_scroller_freeze_set(wd->scr, EINA_FALSE);
1283 }
1284
1285 static void
1286 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1287 {
1288    _sizing_eval(data);
1289 }
1290
1291 EAPI Evas_Object *
1292 elm_list_add(Evas_Object *parent)
1293 {
1294    Evas_Object *obj;
1295    Evas *e;
1296    Widget_Data *wd;
1297    Evas_Coord minw, minh;
1298
1299    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1300
1301    ELM_SET_WIDTYPE(widtype, "list");
1302    elm_widget_type_set(obj, "list");
1303    elm_widget_sub_object_add(parent, obj);
1304    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1305    elm_widget_data_set(obj, wd);
1306    elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1307    elm_widget_del_hook_set(obj, _del_hook);
1308    elm_widget_theme_hook_set(obj, _theme_hook);
1309    elm_widget_disable_hook_set(obj, _disable_hook);
1310    elm_widget_can_focus_set(obj, EINA_TRUE);
1311    elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1312    elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1313    elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1314    elm_widget_event_hook_set(obj, _event_hook);
1315    elm_widget_translate_hook_set(obj, _translate_hook);
1316
1317    wd->self = obj;
1318    wd->scr = elm_smart_scroller_add(e);
1319    elm_smart_scroller_widget_set(wd->scr, obj);
1320    elm_widget_resize_object_set(obj, wd->scr);
1321    evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1322                                   _changed_size_hints, obj);
1323    edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &minw, &minh);
1324    evas_object_size_hint_min_set(obj, minw, minh);
1325    evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
1326
1327    elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
1328                                        _elm_config->thumbscroll_bounce_enable);
1329
1330    wd->box = elm_box_add(parent);
1331    elm_box_homogeneous_set(wd->box, 1);
1332    evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1333    evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1334    elm_widget_on_show_region_hook_set(wd->box, _show_region_hook, obj);
1335    elm_widget_sub_object_add(obj, wd->box);
1336    elm_smart_scroller_child_set(wd->scr, wd->box);
1337    evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1338                                   _changed_size_hints, obj);
1339
1340    evas_object_show(wd->box);
1341
1342    _theme_hook(obj);
1343
1344    wd->mode = ELM_LIST_SCROLL;
1345
1346    evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
1347    evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right, obj);
1348    evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
1349    evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom, obj);
1350
1351    evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
1352    evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1353    evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1354    evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1355    evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1356
1357    evas_object_smart_callbacks_descriptions_set(obj, _signals);
1358
1359    _mirrored_set(obj, elm_widget_mirrored_get(obj));
1360    _sizing_eval(obj);
1361    return obj;
1362 }
1363
1364 EAPI Elm_List_Item *
1365 elm_list_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1366 {
1367    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1368    Widget_Data *wd = elm_widget_data_get(obj);
1369    Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1370
1371    wd->items = eina_list_append(wd->items, it);
1372    it->node = eina_list_last(wd->items);
1373    elm_box_pack_end(wd->box, VIEW(it));
1374    return it;
1375 }
1376
1377 EAPI Elm_List_Item *
1378 elm_list_item_prepend(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1379 {
1380    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1381    Widget_Data *wd = elm_widget_data_get(obj);
1382    Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1383
1384    wd->items = eina_list_prepend(wd->items, it);
1385    it->node = wd->items;
1386    elm_box_pack_start(wd->box, VIEW(it));
1387    return it;
1388 }
1389
1390 EAPI Elm_List_Item *
1391 elm_list_item_insert_before(Evas_Object *obj, Elm_List_Item *before, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1392 {
1393    Widget_Data *wd;
1394    Elm_List_Item *it;
1395
1396    EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
1397    if (!before->node) return NULL;
1398    ELM_LIST_ITEM_CHECK_DELETED_RETURN(before, NULL);
1399
1400    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1401    wd = elm_widget_data_get(obj);
1402    if (!wd) return NULL;
1403    it = _item_new(obj, label, icon, end, func, data);
1404    wd->items = eina_list_prepend_relative_list(wd->items, it, before->node);
1405    it->node = before->node->prev;
1406    elm_box_pack_before(wd->box, VIEW(it), VIEW(before));
1407    return it;
1408 }
1409
1410 EAPI Elm_List_Item *
1411 elm_list_item_insert_after(Evas_Object *obj, Elm_List_Item *after, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data)
1412 {
1413    Widget_Data *wd;
1414    Elm_List_Item *it;
1415
1416    EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
1417    if (!after->node) return NULL;
1418    ELM_LIST_ITEM_CHECK_DELETED_RETURN(after, NULL);
1419
1420    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1421    wd = elm_widget_data_get(obj);
1422    if (!wd) return NULL;
1423    it = _item_new(obj, label, icon, end, func, data);
1424    wd->items = eina_list_append_relative_list(wd->items, it, after->node);
1425    it->node = after->node->next;
1426    elm_box_pack_after(wd->box, VIEW(it), VIEW(after));
1427    return it;
1428 }
1429
1430 EAPI Elm_List_Item *
1431 elm_list_item_sorted_insert(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data, Eina_Compare_Cb cmp_func)
1432 {
1433    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1434    Widget_Data *wd = elm_widget_data_get(obj);
1435    Elm_List_Item *it = _item_new(obj, label, icon, end, func, data);
1436    Eina_List *l;
1437
1438    wd->items = eina_list_sorted_insert(wd->items, cmp_func, it);
1439    l = eina_list_data_find_list(wd->items, it);
1440    l = eina_list_next(l);
1441    if (!l)
1442      {
1443         it->node = eina_list_last(wd->items);
1444         elm_box_pack_end(wd->box, VIEW(it));
1445      }
1446    else
1447      {
1448         Elm_List_Item *before = eina_list_data_get(l);
1449         it->node = before->node->prev;
1450         elm_box_pack_before(wd->box, VIEW(it), VIEW(before));
1451      }
1452    return it;
1453 }
1454
1455 EAPI void
1456 elm_list_clear(Evas_Object *obj)
1457 {
1458    ELM_CHECK_WIDTYPE(obj, widtype);
1459    Widget_Data *wd = elm_widget_data_get(obj);
1460    Elm_List_Item *it;
1461
1462    if (!wd) return;
1463    if (!wd->items) return;
1464
1465    eina_list_free(wd->selected);
1466    wd->selected = NULL;
1467
1468    if (wd->walking > 0)
1469      {
1470         Eina_List *n;
1471
1472         EINA_LIST_FOREACH(wd->items, n, it)
1473           {
1474              if (it->deleted) continue;
1475              it->deleted = EINA_TRUE;
1476              wd->to_delete = eina_list_append(wd->to_delete, it);
1477           }
1478         return;
1479      }
1480
1481    evas_object_ref(obj);
1482    _elm_list_walk(wd);
1483
1484    EINA_LIST_FREE(wd->items, it)
1485      {
1486         elm_widget_item_pre_notify_del(it);
1487         _elm_list_item_free(it);
1488      }
1489
1490    _elm_list_unwalk(wd);
1491
1492    _fix_items(obj);
1493    _sizing_eval(obj);
1494    evas_object_unref(obj);
1495 }
1496
1497 EAPI void
1498 elm_list_go(Evas_Object *obj)
1499 {
1500    ELM_CHECK_WIDTYPE(obj, widtype);
1501    Widget_Data *wd = elm_widget_data_get(obj);
1502    if (!wd) return;
1503    _fix_items(obj);
1504 }
1505
1506 EAPI void
1507 elm_list_multi_select_set(Evas_Object *obj, Eina_Bool multi)
1508 {
1509    ELM_CHECK_WIDTYPE(obj, widtype);
1510    Widget_Data *wd = elm_widget_data_get(obj);
1511    if (!wd) return;
1512    wd->multi = multi;
1513 }
1514
1515 EAPI Eina_Bool
1516 elm_list_multi_select_get(const Evas_Object *obj)
1517 {
1518    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1519    Widget_Data *wd = elm_widget_data_get(obj);
1520    if (!wd) return EINA_FALSE;
1521    return wd->multi;
1522 }
1523
1524 EAPI void
1525 elm_list_mode_set(Evas_Object *obj, Elm_List_Mode mode)
1526 {
1527    ELM_CHECK_WIDTYPE(obj, widtype);
1528
1529    Widget_Data *wd;
1530
1531    wd = elm_widget_data_get(obj);
1532    if (!wd)
1533      return;
1534    if (wd->mode == mode)
1535      return;
1536    wd->mode = mode;
1537
1538    _elm_list_mode_set_internal(wd);
1539 }
1540
1541 EAPI Elm_List_Mode
1542 elm_list_mode_get(const Evas_Object *obj)
1543 {
1544    ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
1545    Widget_Data *wd = elm_widget_data_get(obj);
1546    if (!wd) return ELM_LIST_LAST;
1547    return wd->mode;
1548 }
1549
1550 EAPI void
1551 elm_list_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
1552 {
1553    ELM_CHECK_WIDTYPE(obj, widtype);
1554
1555    Widget_Data *wd;
1556    Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1557
1558    wd = elm_widget_data_get(obj);
1559    if (!wd)
1560      return;
1561
1562    if (wd->h_mode == horizontal)
1563      return;
1564
1565    wd->h_mode = horizontal;
1566    elm_box_horizontal_set(wd->box, horizontal);
1567
1568    if (horizontal)
1569      {
1570         evas_object_size_hint_weight_set(wd->box, 0.0, EVAS_HINT_EXPAND);
1571         evas_object_size_hint_align_set(wd->box, 0.0, EVAS_HINT_FILL);
1572         elm_smart_scroller_bounce_allow_set(wd->scr, bounce, EINA_FALSE);
1573      }
1574    else
1575      {
1576         evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND, 0.0);
1577         evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, 0.0);
1578         elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE, bounce);
1579      }
1580
1581    _elm_list_mode_set_internal(wd);
1582 }
1583
1584 EAPI Eina_Bool
1585 elm_list_horizontal_get(const Evas_Object *obj)
1586 {
1587    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1588
1589    Widget_Data *wd;
1590
1591    wd = elm_widget_data_get(obj);
1592    if (!wd)
1593      return EINA_FALSE;
1594
1595    return wd->h_mode;
1596 }
1597
1598 EAPI void
1599 elm_list_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
1600 {
1601    ELM_CHECK_WIDTYPE(obj, widtype);
1602    Widget_Data *wd = elm_widget_data_get(obj);
1603    if (!wd) return;
1604    wd->always_select = always_select;
1605 }
1606
1607 EAPI Eina_Bool
1608 elm_list_always_select_mode_get(const Evas_Object *obj)
1609 {
1610    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1611    Widget_Data *wd = elm_widget_data_get(obj);
1612    if (!wd) return EINA_FALSE;
1613    return wd->always_select;
1614 }
1615
1616 EAPI const Eina_List *
1617 elm_list_items_get(const Evas_Object *obj)
1618 {
1619    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1620    Widget_Data *wd = elm_widget_data_get(obj);
1621    if (!wd) return NULL;
1622    return wd->items;
1623 }
1624
1625 EAPI Elm_List_Item *
1626 elm_list_selected_item_get(const Evas_Object *obj)
1627 {
1628    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1629    Widget_Data *wd = elm_widget_data_get(obj);
1630    if (!wd) return NULL;
1631    if (wd->selected) return wd->selected->data;
1632    return NULL;
1633 }
1634
1635 EAPI const Eina_List *
1636 elm_list_selected_items_get(const Evas_Object *obj)
1637 {
1638    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1639    Widget_Data *wd = elm_widget_data_get(obj);
1640    if (!wd) return NULL;
1641    return wd->selected;
1642 }
1643
1644 EAPI void
1645 elm_list_item_separator_set(Elm_List_Item *it, Eina_Bool setting)
1646 {
1647    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1648    it->is_separator = !!setting;
1649 }
1650
1651 EAPI Eina_Bool
1652 elm_list_item_separator_get(const Elm_List_Item *it)
1653 {
1654    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1655    return it->is_separator;
1656 }
1657
1658 EAPI void
1659 elm_list_item_selected_set(Elm_List_Item *it, Eina_Bool selected)
1660 {
1661    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1662    Evas_Object *obj = WIDGET(it);
1663    Widget_Data *wd = elm_widget_data_get(obj);
1664    if (!wd) return;
1665
1666    selected = !!selected;
1667    if (it->selected == selected) return;
1668
1669    evas_object_ref(obj);
1670    _elm_list_walk(wd);
1671
1672    if (selected)
1673      {
1674         if (!wd->multi)
1675           {
1676              while (wd->selected)
1677                _item_unselect(wd->selected->data);
1678           }
1679         _item_hilight(it);
1680         _item_select(it);
1681      }
1682    else
1683      _item_unselect(it);
1684
1685    _elm_list_unwalk(wd);
1686    evas_object_unref(obj);
1687 }
1688
1689 EAPI Eina_Bool
1690 elm_list_item_selected_get(const Elm_List_Item *it)
1691 {
1692    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
1693    return it->selected;
1694 }
1695
1696 EAPI void
1697 elm_list_item_show(Elm_List_Item *it)
1698 {
1699    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1700    Widget_Data *wd = elm_widget_data_get(WIDGET(it));
1701    Evas_Coord bx, by, bw, bh;
1702    Evas_Coord x, y, w, h;
1703
1704    evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1705    evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
1706    x -= bx;
1707    y -= by;
1708    if (wd->scr)
1709      elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
1710 }
1711
1712 EAPI void
1713 elm_list_item_bring_in(Elm_List_Item *it)
1714 {
1715    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1716    Widget_Data *wd = elm_widget_data_get(WIDGET(it));
1717    Evas_Coord bx, by, bw, bh;
1718    Evas_Coord x, y, w, h;
1719
1720    evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
1721    evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
1722    x -= bx;
1723    y -= by;
1724    if (wd->scr)
1725      elm_smart_scroller_region_bring_in(wd->scr, x, y, w, h);
1726 }
1727
1728 EAPI void
1729 elm_list_item_del(Elm_List_Item *it)
1730 {
1731    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1732    Evas_Object *obj = WIDGET(it);
1733    Widget_Data *wd = elm_widget_data_get(obj);
1734    if (!wd) return;
1735
1736    if (it->selected) _item_unselect(it);
1737
1738    if (wd->walking > 0)
1739      {
1740         if (it->deleted) return;
1741         it->deleted = EINA_TRUE;
1742         wd->to_delete = eina_list_append(wd->to_delete, it);
1743         return;
1744      }
1745
1746    wd->items = eina_list_remove_list(wd->items, it->node);
1747
1748    evas_object_ref(obj);
1749    _elm_list_walk(wd);
1750
1751    elm_widget_item_pre_notify_del(it);
1752    _elm_list_item_free(it);
1753
1754    _elm_list_unwalk(wd);
1755    evas_object_unref(obj);
1756 }
1757
1758 EAPI void
1759 elm_list_item_del_cb_set(Elm_List_Item *it, Evas_Smart_Cb func)
1760 {
1761    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1762    elm_widget_item_del_cb_set(it, func);
1763 }
1764
1765 EAPI void *
1766 elm_list_item_data_get(const Elm_List_Item *it)
1767 {
1768    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1769    return elm_widget_item_data_get(it);
1770 }
1771
1772 EAPI Evas_Object *
1773 elm_list_item_icon_get(const Elm_List_Item *it)
1774 {
1775    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1776    if (it->dummy_icon) return NULL;
1777    return it->icon;
1778 }
1779
1780 EAPI void
1781 elm_list_item_icon_set(Elm_List_Item *it, Evas_Object *icon)
1782 {
1783    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1784    if (it->icon == icon) return;
1785    if ((it->dummy_icon) && (!icon)) return;
1786    if (it->dummy_icon)
1787      {
1788         evas_object_del(it->icon);
1789         it->dummy_icon = EINA_FALSE;
1790      }
1791    if (!icon)
1792      {
1793         icon = evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
1794         evas_object_color_set(icon, 0, 0, 0, 0);
1795         it->dummy_icon = EINA_TRUE;
1796      }
1797    if (it->icon)
1798      {
1799         evas_object_del(it->icon);
1800         it->icon = NULL;
1801      }
1802    it->icon = icon;
1803    if (VIEW(it))
1804      edje_object_part_swallow(VIEW(it), "elm.swallow.icon", icon);
1805 }
1806
1807 EAPI Evas_Object *
1808 elm_list_item_end_get(const Elm_List_Item *it)
1809 {
1810    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1811    if (it->dummy_end) return NULL;
1812    return it->end;
1813 }
1814
1815 EAPI void
1816 elm_list_item_end_set(Elm_List_Item *it, Evas_Object *end)
1817 {
1818    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1819    if (it->end == end) return;
1820    if ((it->dummy_end) && (!end)) return;
1821    if (it->dummy_end)
1822      {
1823         evas_object_del(it->end);
1824         it->dummy_icon = EINA_FALSE;
1825      }
1826    if (!end)
1827      {
1828         end = evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
1829         evas_object_color_set(end, 0, 0, 0, 0);
1830         it->dummy_end = EINA_TRUE;
1831      }
1832    if (it->end)
1833      {
1834         evas_object_del(it->end);
1835         it->end = NULL;
1836      }
1837    it->end = end;
1838    if (VIEW(it))
1839      edje_object_part_swallow(VIEW(it), "elm.swallow.end", end);
1840 }
1841
1842 EAPI Evas_Object *
1843 elm_list_item_base_get(const Elm_List_Item *it)
1844 {
1845    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1846    return VIEW(it);
1847 }
1848
1849 EAPI const char *
1850 elm_list_item_label_get(const Elm_List_Item *it)
1851 {
1852    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1853    return it->label;
1854 }
1855
1856 EAPI void
1857 elm_list_item_label_set(Elm_List_Item *it, const char *text)
1858 {
1859    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
1860    if (!eina_stringshare_replace(&it->label, text)) return;
1861    if (VIEW(it))
1862      edje_object_part_text_set(VIEW(it), "elm.text", it->label);
1863 }
1864
1865 EAPI Elm_List_Item *
1866 elm_list_item_prev(const Elm_List_Item *it)
1867 {
1868    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1869    if (it->node->prev) return it->node->prev->data;
1870    else return NULL;
1871 }
1872
1873 EAPI Elm_List_Item *
1874 elm_list_item_next(const Elm_List_Item *it)
1875 {
1876    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, NULL);
1877    if (it->node->next) return it->node->next->data;
1878    else return NULL;
1879 }
1880
1881 EAPI void
1882 elm_list_item_tooltip_text_set(Elm_List_Item *item, const char *text)
1883 {
1884    ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1885    elm_widget_item_tooltip_text_set(item, text);
1886 }
1887
1888 EAPI void
1889 elm_list_item_tooltip_content_cb_set(Elm_List_Item *item, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb)
1890 {
1891    ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1892    elm_widget_item_tooltip_content_cb_set(item, func, data, del_cb);
1893 }
1894
1895 EAPI void
1896 elm_list_item_tooltip_unset(Elm_List_Item *item)
1897 {
1898    ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1899    elm_widget_item_tooltip_unset(item);
1900 }
1901
1902 EAPI Eina_Bool
1903 elm_list_item_tooltip_size_restrict_disable(Elm_List_Item *item, Eina_Bool disable)
1904 {
1905    ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE);
1906    return elm_widget_item_tooltip_size_restrict_disable(item, disable);
1907 }
1908
1909 EAPI Eina_Bool
1910 elm_list_item_tooltip_size_restrict_disabled_get(const Elm_List_Item *item)
1911 {
1912    ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE);
1913    return elm_widget_item_tooltip_size_restrict_disabled_get(item);
1914 }
1915
1916 EAPI void
1917 elm_list_item_tooltip_style_set(Elm_List_Item *item, const char *style)
1918 {
1919    ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1920    elm_widget_item_tooltip_style_set(item, style);
1921 }
1922
1923 EAPI const char *
1924 elm_list_item_tooltip_style_get(const Elm_List_Item *item)
1925 {
1926    ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1927    return elm_widget_item_tooltip_style_get(item);
1928 }
1929
1930 EAPI void
1931 elm_list_item_cursor_set(Elm_List_Item *item, const char *cursor)
1932 {
1933    ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1934    elm_widget_item_cursor_set(item, cursor);
1935 }
1936
1937 EAPI const char *
1938 elm_list_item_cursor_get(const Elm_List_Item *item)
1939 {
1940    ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1941    return elm_widget_item_cursor_get(item);
1942 }
1943
1944 EAPI void
1945 elm_list_item_cursor_unset(Elm_List_Item *item)
1946 {
1947    ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1948    elm_widget_item_cursor_unset(item);
1949 }
1950
1951 EAPI void
1952 elm_list_item_cursor_style_set(Elm_List_Item *item, const char *style)
1953 {
1954    ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1955    elm_widget_item_cursor_style_set(item, style);
1956 }
1957
1958 EAPI const char *
1959 elm_list_item_cursor_style_get(const Elm_List_Item *item)
1960 {
1961    ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, NULL);
1962    return elm_widget_item_cursor_style_get(item);
1963 }
1964
1965 EAPI void
1966 elm_list_item_cursor_engine_only_set(Elm_List_Item *item, Eina_Bool engine_only)
1967 {
1968    ELM_LIST_ITEM_CHECK_DELETED_RETURN(item);
1969    elm_widget_item_cursor_engine_only_set(item, engine_only);
1970 }
1971
1972 EAPI Eina_Bool
1973 elm_list_item_cursor_engine_only_get(const Elm_List_Item *item)
1974 {
1975    ELM_LIST_ITEM_CHECK_DELETED_RETURN(item, EINA_FALSE);
1976    return elm_widget_item_cursor_engine_only_get(item);
1977 }
1978
1979 EAPI void
1980 elm_list_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
1981 {
1982    ELM_CHECK_WIDTYPE(obj, widtype);
1983    Widget_Data *wd = elm_widget_data_get(obj);
1984    if (!wd) return;
1985    if (wd->scr)
1986      elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
1987 }
1988
1989 EAPI void
1990 elm_list_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
1991 {
1992    ELM_CHECK_WIDTYPE(obj, widtype);
1993    Widget_Data *wd = elm_widget_data_get(obj);
1994    if (!wd) return;
1995    elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
1996 }
1997
1998 EAPI void
1999 elm_list_scroller_policy_set(Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
2000 {
2001    ELM_CHECK_WIDTYPE(obj, widtype);
2002    Widget_Data *wd = elm_widget_data_get(obj);
2003    if (!wd) return;
2004    if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
2005        (policy_v >= ELM_SCROLLER_POLICY_LAST))
2006      if (wd->scr)
2007        elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
2008 }
2009
2010 EAPI void
2011 elm_list_scroller_policy_get(const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
2012 {
2013    ELM_CHECK_WIDTYPE(obj, widtype);
2014    Widget_Data *wd = elm_widget_data_get(obj);
2015    Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
2016    if ((!wd) || (!wd->scr)) return;
2017    elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
2018    if (policy_h) *policy_h = (Elm_Scroller_Policy) s_policy_h;
2019    if (policy_v) *policy_v = (Elm_Scroller_Policy) s_policy_v;
2020 }
2021
2022 EAPI void
2023 elm_list_item_disabled_set(Elm_List_Item *it, Eina_Bool disabled)
2024 {
2025    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it);
2026
2027    if (it->disabled == disabled)
2028      return;
2029
2030    it->disabled = !!disabled;
2031
2032    if (it->disabled)
2033      edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
2034    else
2035      edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
2036 }
2037
2038 EAPI Eina_Bool
2039 elm_list_item_disabled_get(const Elm_List_Item *it)
2040 {
2041    ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE);
2042
2043    return it->disabled;
2044 }