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