Elementary genlist: Removed unnecesssary code.
[framework/uifw/elementary.git] / src / lib / elm_genlist.c
1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
3 #include "elm_priv.h"
4
5 #define SWIPE_MOVES         12
6 #define MAX_ITEMS_PER_BLOCK 32
7
8 /**
9  * @defgroup Genlist Genlist
10  *
11  * The aim was to have more expansive list than the simple list in
12  * Elementary that could have more flexible items and allow many more entries
13  * while still being fast and low on memory usage. At the same time it was
14  * also made to be able to do tree structures. But the price to pay is more
15  * complex when it comes to usage. If all you want is a simple list with
16  * icons and a single label, use the normal List object.
17  *
18  * Genlist has a fairly large API, mostly because it's relatively complex,
19  * trying to be both expansive, powerful and efficient. First we will begin
20  * an overview on the theory behind genlist.
21  *
22  * Evas tracks every object you create. Every time it processes an event
23  * (mouse move, down, up etc.) it needs to walk through objects and find out
24  * what event that affects. Even worse every time it renders display updates,
25  * in order to just calculate what to re-draw, it needs to walk through many
26  * many many objects. Thus, the more objects you keep active, the more
27  * overhead Evas has in just doing its work. It is advisable to keep your
28  * active objects to the minimum working set you need. Also remember that
29  * object creation and deletion carries an overhead, so there is a
30  * middle-ground, which is not easily determined. But don't keep massive lists
31  * of objects you can't see or use. Genlist does this with list objects. It
32  * creates and destroys them dynamically as you scroll around. It groups them
33  * into blocks so it can determine the visibility etc. of a whole block at
34  * once as opposed to having to walk the whole list. This 2-level list allows
35  * for very large numbers of items to be in the list (tests have used up to
36  * 2,000,000 items). Also genlist employs a queue for adding items. As items
37  * may be different sizes, every item added needs to be calculated as to its
38  * size and thus this presents a lot of overhead on populating the list, this
39  * genlist employs a queue. Any item added is queued and spooled off over
40  * time, actually appearing some time later, so if your list has many members
41  * you may find it takes a while for them to all appear, with your process
42  * consuming a lot of CPU while it is busy spooling.
43  *
44  * Genlist also implements a tree structure, but it does so with callbacks to
45  * the application, with the application filling in tree structures when
46  * requested (allowing for efficient building of a very deep tree that could
47  * even be used for file-management). See the above smart signal callbacks for
48  * details.
49  *
50  * An item in the genlist world can have 0 or more text labels (they can be
51  * regular text or textblock - that's up to the style to determine), 0 or
52  * more icons (which are simply objects swallowed into the genlist item) and
53  * 0 or more boolean states that can be used for check, radio or other
54  * indicators by the edje theme style. An item may be one of several styles
55  * (Elementary provides 4 by default - "default", "double_label", "group_index"
56  * and "icon_top_text_bottom", but this can be extended by system or
57  * application custom themes/overlays/extensions).
58  *
59  * In order to implement the ability to add and delete items on the fly,
60  * Genlist implements a class/callback system where the application provides
61  * a structure with information about that type of item (genlist may contain
62  * multiple different items with different classes, states and styles).
63  * Genlist will call the functions in this struct (methods) when an item is
64  * "realized" (that is created dynamically while scrolling). All objects will
65  * simply be deleted  when no longer needed with evas_object_del(). The
66  * Elm_Genlist_Item_Class structure contains the following members:
67  *
68  * item_style - This is a constant string and simply defines the name of the
69  * item style. It must be specified and the default should be "default".
70  *
71  * func.label_get - This function is called when an actual item object is
72  * created. The data parameter is the data parameter passed to
73  * elm_genlist_item_append() and related item creation functions. The obj
74  * parameter is the genlist object and the part parameter is the string name
75  * of the text part in the edje design that is listed as one of the possible
76  * labels that can be set. This function must return a strudup()'ed string as
77  * the caller will free() it when done.
78  *
79  * func.icon_get - This function is called when an actual item object is
80  * created. The data parameter is the data parameter passed to
81  * elm_genlist_item_append() and related item creation functions. The obj
82  * parameter is the genlist object and the part parameter is the string name
83  * of the icon part in the edje design that is listed as one of the possible
84  * icons that can be set. This must return NULL for no object or a valid
85  * object. The object will be deleted by genlist on shutdown or when the item
86  * is unrealized.
87  *
88  * func.state_get - This function is called when an actual item object is
89  * created. The data parameter is the data parameter passed to
90  * elm_genlist_item_append() and related item creation functions. The obj
91  * parameter is the genlist object and the part parameter is the string name
92  * of the state part in the edje design that is listed as one of the possible
93  * states that can be set. Return 0 for false or 1 for true. Genlist will
94  * emit a signal to the edje object with "elm,state,XXX,active" "elm" when
95  * true (the default is false), where XXX is the name of the part.
96  *
97  * func.del - This is called when elm_genlist_item_del() is called on an
98  * item, elm_genlist_clear() is called on the genlist, or
99  * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
100  * intended for use when actual genlist items are deleted, so any backing
101  * data attached to the item (e.g. its data parameter on creation) can be
102  * deleted.
103  *
104  * Items can be added by several calls. All of them return a Elm_Genlist_Item
105  * handle that is an internal member inside the genlist. They all take a data
106  * parameter that is meant to be used for a handle to the applications
107  * internal data (eg the struct with the original item data). The parent
108  * parameter is the parent genlist item this belongs to if it is a tree or
109  * an indexed group, and NULL if there is no parent. The flags can be a bitmask
110  * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
111  * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
112  * is displayed as an item that is able to expand and have child items.
113  * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
114  * displayed at the top until the next group comes. The func parameter is a
115  * convenience callback that is called when the item is selected and the data
116  * parameter will be the func_data parameter, obj be the genlist object and
117  * event_info will be the genlist item.
118  *
119  * elm_genlist_item_append() appends an item to the end of the list, or if
120  * there is a parent, to the end of all the child items of the parent.
121  * elm_genlist_item_prepend() is the same but prepends to the beginning of
122  * the list or children list. elm_genlist_item_insert_before() inserts at
123  * item before another item and elm_genlist_item_insert_after() inserts after
124  * the indicated item.
125  *
126  * The application can clear the list with elm_genlist_clear() which deletes
127  * all the items in the list and elm_genlist_item_del() will delete a specific
128  * item. elm_genlist_item_subitems_clear() will clear all items that are
129  * children of the indicated parent item.
130  *
131  * If the application wants multiple items to be able to be selected,
132  * elm_genlist_multi_select_set() can enable this. If the list is
133  * single-selection only (the default), then elm_genlist_selected_item_get()
134  * will return the selected item, if any, or NULL I none is selected. If the
135  * list is multi-select then elm_genlist_selected_items_get() will return a
136  * list (that is only valid as long as no items are modified (added, deleted,
137  * selected or unselected)).
138  *
139  * To help inspect list items you can jump to the item at the top of the list
140  * with elm_genlist_first_item_get() which will return the item pointer, and
141  * similarly elm_genlist_last_item_get() gets the item at the end of the list.
142  * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
143  * and previous items respectively relative to the indicated item. Using
144  * these calls you can walk the entire item list/tree. Note that as a tree
145  * the items are flattened in the list, so elm_genlist_item_parent_get() will
146  * let you know which item is the parent (and thus know how to skip them if
147  * wanted).
148  *
149  * There are also convenience functions. elm_genlist_item_genlist_get() will
150  * return the genlist object the item belongs to. elm_genlist_item_show()
151  * will make the scroller scroll to show that specific item so its visible.
152  * elm_genlist_item_data_get() returns the data pointer set by the item
153  * creation functions.
154  *
155  * If an item changes (state of boolean changes, label or icons change),
156  * then use elm_genlist_item_update() to have genlist update the item with
157  * the new state. Genlist will re-realize the item thus call the functions
158  * in the _Elm_Genlist_Item_Class for that item.
159  *
160  * To programmatically (un)select an item use elm_genlist_item_selected_set().
161  * To get its selected state use elm_genlist_item_selected_get(). Similarly
162  * to expand/contract an item and get its expanded state, use
163  * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
164  * again to make an item disabled (unable to be selected and appear
165  * differently) use elm_genlist_item_disabled_set() to set this and
166  * elm_genlist_item_disabled_get() to get the disabled state.
167  *
168  * In general to indicate how the genlist should expand items horizontally to
169  * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
170  * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
171  * mode means that if items are too wide to fit, the scroller will scroll
172  * horizontally. Otherwise items are expanded to fill the width of the
173  * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
174  * to the viewport width and limited to that size. This can be combined with
175  * a different style that uses edjes' ellipsis feature (cutting text off like
176  * this: "tex...").
177  *
178  * Items will only call their selection func and callback when first becoming
179  * selected. Any further clicks will do nothing, unless you enable always
180  * select with elm_genlist_always_select_mode_set(). This means even if
181  * selected, every click will make the selected callbacks be called.
182  * elm_genlist_no_select_mode_set() will turn off the ability to select
183  * items entirely and they will neither appear selected nor call selected
184  * callback functions.
185  *
186  * Remember that you can create new styles and add your own theme augmentation
187  * per application with elm_theme_extension_add(). If you absolutely must
188  * have a specific style that overrides any theme the user or system sets up
189  * you can use elm_theme_overlay_add() to add such a file.
190  *
191  * Signals that you can add callbacks for are:
192  *
193  * "clicked,double" - This is called when a user has double-clicked an item. The
194  *                    event_info parameter is the genlist item that was double-c
195  *                    licked.
196  * "selected" - This is called when a user has made an item selected. The
197  *              event_info parameter is the genlist item that was selected.
198  * "unselected" - This is called when a user has made an item unselected. The
199  *                 event_info parameter is the genlist item that was unselected.
200  * "expanded" - This is called when elm_genlist_item_expanded_set() is called
201  *              and the item is now meant to be expanded. The event_info
202  *              parameter is the genlist item that was indicated to expand. It
203  *              is the job of this callback to then fill in the child items.
204  * "contracted" - This is called when elm_genlist_item_expanded_set() is called
205  *                and the item is now meant to be contracted. The event_info
206  *                parameter is the genlist item that was indicated to contract.
207  *                It is the job of this callback to then delete the child items.
208  * "expand,request" - This is called when a user has indicated they want to
209  *                    expand a tree branch item. The callback should decide if
210  *                    the item can expand (has any children) and then call
211  *                    elm_genlist_item_expanded_set() appropriately to set the
212  *                    state. The event_info parameter is the genlist item that
213  *                    was indicated to expand.
214  * "contract,request" - This is called when a user has indicated they want to
215  *                      contract a tree branch item. The callback should decide
216  *                      if the item can contract (has any children) and then
217  *                      call elm_genlist_item_expanded_set() appropriately to
218  *                      set the state. The event_info parameter is the genlist
219  *                      item that was indicated to contract.
220  * "realized" - This is called when the item in the list is created as a real
221  *              evas object. event_info parameter is the genlist item that was
222  *              created. The object may be deleted at any time, so it is up to
223  *              the caller to not use the object pointer from
224  *              elm_genlist_item_object_get() in a way  where it may point to
225  *              freed objects.
226  * "unrealized" - This is called just before an item is unrealized. After this
227  *                call icon objects provided will be deleted and the item object
228  *                itself delete or be put into a floating cache.
229  * "drag,start,up" - This is called when the item in the list has been dragged
230  *                   (not scrolled) up.
231  * "drag,start,down" - This is called when the item in the list has been dragged
232  *                     (not scrolled) down.
233  * "drag,start,left" - This is called when the item in the list has been dragged
234  *                     (not scrolled) left.
235  * "drag,start,right" - This is called when the item in the list has been
236  *                      dragged (not scrolled) right.
237  * "drag,stop" - This is called when the item in the list has stopped being
238  *               dragged.
239  * "drag" - This is called when the item in the list is being dragged.
240  * "longpressed" - This is called when the item is pressed for a certain amount
241  *                 of time. By default it's 1 second.
242  * "scroll,edge,top" - This is called when the genlist is scrolled until the
243  *                     top edge.
244  * "scroll,edge,bottom" - This is called when the genlist is scrolled until the
245  *                         bottom edge.
246  * "scroll,edge,left" - This is called when the genlist is scrolled until the
247  *                      left edge.
248  * "scroll,edge,right" - This is called when the genlist is scrolled until the
249  *                       right edge.
250  * "multi,swipe,left" - This is called when the genlist is multi-touch swiped
251  *                       left.
252  * "multi,swipe,right" - This is called when the genlist is multi-touch swiped
253  *                       right.
254  * "multi,swipe,up" - This is called when the genlist is multi-touch swiped up.
255  * "multi,swipe,down" - This is called when the genlist is multi-touch swiped
256  *                      down.
257  * "multi,pinch,out" - This is called when the genlist is multi-touch pinched
258  *                     out.
259  * "multi,pinch,in" - This is called when the genlist is multi-touch pinched in.
260  */
261
262 typedef struct _Widget_Data Widget_Data;
263 typedef struct _Item_Block  Item_Block;
264 typedef struct _Pan         Pan;
265 typedef struct _Item_Cache  Item_Cache;
266
267 struct _Widget_Data
268 {
269    Evas_Object      *obj, *scr, *pan_smart;
270    Eina_Inlist      *items, *blocks;
271    Eina_List        *group_items;
272    Pan              *pan;
273    Evas_Coord        pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
274    Ecore_Job        *calc_job, *update_job;
275    Ecore_Idler      *queue_idler, *must_recalc_idler;
276    Eina_List        *queue, *selected;
277    Elm_Genlist_Item *show_item, *last_selected_item, *anchor_item, *mode_item;
278    Eina_Inlist      *item_cache;
279    Evas_Coord        anchor_y;
280    Elm_List_Mode     mode;
281    Ecore_Timer      *multi_timer, *scr_hold_timer;
282    const char       *mode_type;
283    Evas_Coord        prev_x, prev_y, prev_mx, prev_my;
284    Evas_Coord        cur_x, cur_y, cur_mx, cur_my;
285    Eina_Bool         mouse_down : 1;
286    Eina_Bool         multi_down : 1;
287    Eina_Bool         multi_timeout : 1;
288    Eina_Bool         multitouched : 1;
289    Eina_Bool         on_hold : 1;
290    Eina_Bool         multi : 1;
291    Eina_Bool         always_select : 1;
292    Eina_Bool         longpressed : 1;
293    Eina_Bool         wasselected : 1;
294    Eina_Bool         no_select : 1;
295    Eina_Bool         bring_in : 1;
296    Eina_Bool         compress : 1;
297    Eina_Bool         height_for_width : 1;
298    Eina_Bool         homogeneous : 1;
299    Eina_Bool         clear_me : 1;
300    Eina_Bool         swipe : 1;
301    struct
302    {
303       Evas_Coord x, y;
304    } history[SWIPE_MOVES];
305    int               multi_device;
306    int               item_cache_count;
307    int               item_cache_max;
308    int               movements;
309    int               walking;
310    int               item_width;
311    int               item_height;
312    int               group_item_width;
313    int               group_item_height;
314    int               max_items_per_block;
315    double            longpress_timeout;
316 };
317
318 struct _Item_Block
319 {
320    EINA_INLIST;
321    int          count;
322    int          num;
323    Widget_Data *wd;
324    Eina_List   *items;
325    Evas_Coord   x, y, w, h, minw, minh;
326    Eina_Bool    want_unrealize : 1;
327    Eina_Bool    realized : 1;
328    Eina_Bool    changed : 1;
329    Eina_Bool    updateme : 1;
330    Eina_Bool    showme : 1;
331    Eina_Bool    must_recalc : 1;
332 };
333
334 struct _Elm_Genlist_Item
335 {
336    Elm_Widget_Item               base;
337    EINA_INLIST;
338    Widget_Data                  *wd;
339    Item_Block                   *block;
340    Eina_List                    *items;
341    Evas_Coord                    x, y, w, h, minw, minh;
342    const Elm_Genlist_Item_Class *itc;
343    Elm_Genlist_Item             *parent;
344    Elm_Genlist_Item             *group_item;
345    Elm_Genlist_Item_Flags        flags;
346    struct
347    {
348       Evas_Smart_Cb func;
349       const void   *data;
350    } func;
351
352    Evas_Object                  *spacer;
353    Eina_List                    *labels, *icons, *states, *icon_objs;
354    Eina_List                    *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
355    Ecore_Timer                  *long_timer;
356    Ecore_Timer                  *swipe_timer;
357    Evas_Coord                    dx, dy;
358    Evas_Coord                    scrl_x, scrl_y;
359
360    Elm_Genlist_Item             *rel;
361    Evas_Object                  *mode_view;
362
363    struct
364    {
365       const void                 *data;
366       Elm_Tooltip_Item_Content_Cb content_cb;
367       Evas_Smart_Cb               del_cb;
368       const char                 *style;
369    } tooltip;
370
371    const char                   *mouse_cursor;
372
373    int                           relcount;
374    int                           walking;
375    int                           expanded_depth;
376    int                           order_num_in;
377
378    Eina_Bool                     before : 1;
379
380    Eina_Bool                     want_unrealize : 1;
381    Eina_Bool                     want_realize : 1;
382    Eina_Bool                     realized : 1;
383    Eina_Bool                     selected : 1;
384    Eina_Bool                     highlighted : 1;
385    Eina_Bool                     expanded : 1;
386    Eina_Bool                     disabled : 1;
387    Eina_Bool                     display_only : 1;
388    Eina_Bool                     mincalcd : 1;
389    Eina_Bool                     queued : 1;
390    Eina_Bool                     showme : 1;
391    Eina_Bool                     delete_me : 1;
392    Eina_Bool                     down : 1;
393    Eina_Bool                     dragging : 1;
394    Eina_Bool                     updateme : 1;
395    Eina_Bool                     nocache : 1;
396 };
397
398 struct _Item_Cache
399 {
400    EINA_INLIST;
401
402    Evas_Object *base_view, *spacer;
403
404    const char  *item_style; // it->itc->item_style
405    Eina_Bool    tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
406    Eina_Bool    compress : 1; // it->wd->compress
407    Eina_Bool    odd : 1; // in & 0x1
408
409    Eina_Bool    selected : 1; // it->selected
410    Eina_Bool    disabled : 1; // it->disabled
411    Eina_Bool    expanded : 1; // it->expanded
412 };
413
414 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
415   ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
416
417 struct _Pan
418 {
419    Evas_Object_Smart_Clipped_Data __clipped_data;
420    Widget_Data                   *wd;
421    Ecore_Job                     *resize_job;
422 };
423
424 static const char *widtype = NULL;
425 static void      _item_cache_zero(Widget_Data *wd);
426 static void      _del_hook(Evas_Object *obj);
427 static void      _mirrored_set(Evas_Object *obj,
428                                Eina_Bool    rtl);
429 static void      _theme_hook(Evas_Object *obj);
430 static void      _show_region_hook(void        *data,
431                                    Evas_Object *obj);
432 static void      _sizing_eval(Evas_Object *obj);
433 static void      _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc);
434 static void      _item_block_unrealize(Item_Block *itb);
435 static void      _calc_job(void *data);
436 static void      _on_focus_hook(void        *data,
437                                 Evas_Object *obj);
438 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
439 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
440 static Eina_Bool _item_single_select_up(Widget_Data *wd);
441 static Eina_Bool _item_single_select_down(Widget_Data *wd);
442 static Eina_Bool _event_hook(Evas_Object       *obj,
443                              Evas_Object       *src,
444                              Evas_Callback_Type type,
445                              void              *event_info);
446 static void      _signal_emit_hook(Evas_Object *obj,
447                                    const char *emission,
448                                    const char *source);
449 static Eina_Bool _deselect_all_items(Widget_Data *wd);
450 static void      _pan_calculate(Evas_Object *obj);
451 static void      _item_position(Elm_Genlist_Item *it, Evas_Object *obj);
452 static void      _mode_item_realize(Elm_Genlist_Item *it);
453 static void      _mode_item_unrealize(Elm_Genlist_Item *it);
454 static void      _item_mode_set(Elm_Genlist_Item *it);
455 static void      _item_mode_unset(Widget_Data *wd);
456
457 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
458
459 static Eina_Bool
460 _event_hook(Evas_Object       *obj,
461             Evas_Object       *src __UNUSED__,
462             Evas_Callback_Type type,
463             void              *event_info)
464 {
465    if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
466    Evas_Event_Key_Down *ev = event_info;
467    Widget_Data *wd = elm_widget_data_get(obj);
468    if (!wd) return EINA_FALSE;
469    if (!wd->items) return EINA_FALSE;
470    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
471    if (elm_widget_disabled_get(obj)) return EINA_FALSE;
472
473    Elm_Genlist_Item *it = NULL;
474    Evas_Coord x = 0;
475    Evas_Coord y = 0;
476    Evas_Coord step_x = 0;
477    Evas_Coord step_y = 0;
478    Evas_Coord v_w = 0;
479    Evas_Coord v_h = 0;
480    Evas_Coord page_x = 0;
481    Evas_Coord page_y = 0;
482
483    elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
484    elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
485    elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
486    elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
487
488    if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
489      {
490         x -= step_x;
491      }
492    else if ((!strcmp(ev->keyname, "Right")) ||
493             (!strcmp(ev->keyname, "KP_Right")))
494      {
495         x += step_x;
496      }
497    else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
498      {
499         if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
500              (_item_multi_select_up(wd)))
501             || (_item_single_select_up(wd)))
502           {
503              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
504              return EINA_TRUE;
505           }
506         else
507           y -= step_y;
508      }
509    else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
510      {
511         if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
512              (_item_multi_select_down(wd)))
513             || (_item_single_select_down(wd)))
514           {
515              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
516              return EINA_TRUE;
517           }
518         else
519           y += step_y;
520      }
521    else if ((!strcmp(ev->keyname, "Home")) ||
522             (!strcmp(ev->keyname, "KP_Home")))
523      {
524         it = elm_genlist_first_item_get(obj);
525         elm_genlist_item_bring_in(it);
526         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
527         return EINA_TRUE;
528      }
529    else if ((!strcmp(ev->keyname, "End")) ||
530             (!strcmp(ev->keyname, "KP_End")))
531      {
532         it = elm_genlist_last_item_get(obj);
533         elm_genlist_item_bring_in(it);
534         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
535         return EINA_TRUE;
536      }
537    else if ((!strcmp(ev->keyname, "Prior")) ||
538             (!strcmp(ev->keyname, "KP_Prior")))
539      {
540         if (page_y < 0)
541           y -= -(page_y * v_h) / 100;
542         else
543           y -= page_y;
544      }
545    else if ((!strcmp(ev->keyname, "Next")) ||
546             (!strcmp(ev->keyname, "KP_Next")))
547      {
548         if (page_y < 0)
549           y += -(page_y * v_h) / 100;
550         else
551           y += page_y;
552      }
553    else if(((!strcmp(ev->keyname, "Return")) ||
554             (!strcmp(ev->keyname, "KP_Enter")) ||
555             (!strcmp(ev->keyname, "space")))
556            && (!wd->multi) && (wd->selected))
557      {
558         Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
559         elm_genlist_item_expanded_set(it,
560                                       !elm_genlist_item_expanded_get(it));
561      }
562    else if (!strcmp(ev->keyname, "Escape"))
563      {
564         if (!_deselect_all_items(wd)) return EINA_FALSE;
565         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
566         return EINA_TRUE;
567      }
568    else return EINA_FALSE;
569
570    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
571    elm_smart_scroller_child_pos_set(wd->scr, x, y);
572    return EINA_TRUE;
573 }
574
575 static Eina_Bool
576 _deselect_all_items(Widget_Data *wd)
577 {
578    if (!wd->selected) return EINA_FALSE;
579    while(wd->selected)
580      elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
581
582    return EINA_TRUE;
583 }
584
585 static Eina_Bool
586 _item_multi_select_up(Widget_Data *wd)
587 {
588    if (!wd->selected) return EINA_FALSE;
589    if (!wd->multi) return EINA_FALSE;
590
591    Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
592    if (!prev) return EINA_TRUE;
593
594    if (elm_genlist_item_selected_get(prev))
595      {
596         elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
597         wd->last_selected_item = prev;
598         elm_genlist_item_show(wd->last_selected_item);
599      }
600    else
601      {
602         elm_genlist_item_selected_set(prev, EINA_TRUE);
603         elm_genlist_item_show(prev);
604      }
605    return EINA_TRUE;
606 }
607
608 static Eina_Bool
609 _item_multi_select_down(Widget_Data *wd)
610 {
611    if (!wd->selected) return EINA_FALSE;
612    if (!wd->multi) return EINA_FALSE;
613
614    Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
615    if (!next) return EINA_TRUE;
616
617    if (elm_genlist_item_selected_get(next))
618      {
619         elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
620         wd->last_selected_item = next;
621         elm_genlist_item_show(wd->last_selected_item);
622      }
623    else
624      {
625         elm_genlist_item_selected_set(next, EINA_TRUE);
626         elm_genlist_item_show(next);
627      }
628    return EINA_TRUE;
629 }
630
631 static Eina_Bool
632 _item_single_select_up(Widget_Data *wd)
633 {
634    Elm_Genlist_Item *prev;
635    if (!wd->selected)
636      {
637         prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
638         while ((prev) && (prev->delete_me))
639           prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
640      }
641    else prev = elm_genlist_item_prev_get(wd->last_selected_item);
642
643    if (!prev) return EINA_FALSE;
644
645    _deselect_all_items(wd);
646
647    elm_genlist_item_selected_set(prev, EINA_TRUE);
648    elm_genlist_item_show(prev);
649    return EINA_TRUE;
650 }
651
652 static Eina_Bool
653 _item_single_select_down(Widget_Data *wd)
654 {
655    Elm_Genlist_Item *next;
656    if (!wd->selected)
657      {
658         next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
659         while ((next) && (next->delete_me))
660           next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
661      }
662    else next = elm_genlist_item_next_get(wd->last_selected_item);
663
664    if (!next) return EINA_FALSE;
665
666    _deselect_all_items(wd);
667
668    elm_genlist_item_selected_set(next, EINA_TRUE);
669    elm_genlist_item_show(next);
670    return EINA_TRUE;
671 }
672
673 static void
674 _on_focus_hook(void        *data __UNUSED__,
675                Evas_Object *obj)
676 {
677    Widget_Data *wd = elm_widget_data_get(obj);
678    if (!wd) return;
679    if (elm_widget_focus_get(obj))
680      {
681         edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
682         evas_object_focus_set(wd->obj, EINA_TRUE);
683         if ((wd->selected) && (!wd->last_selected_item))
684           wd->last_selected_item = eina_list_data_get(wd->selected);
685      }
686    else
687      {
688         edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
689         evas_object_focus_set(wd->obj, EINA_FALSE);
690      }
691 }
692
693 static void
694 _del_hook(Evas_Object *obj)
695 {
696    Widget_Data *wd = elm_widget_data_get(obj);
697    if (!wd) return;
698    _item_cache_zero(wd);
699    if (wd->calc_job) ecore_job_del(wd->calc_job);
700    if (wd->update_job) ecore_job_del(wd->update_job);
701    if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
702    if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
703    if (wd->mode_type) eina_stringshare_del(wd->mode_type);
704    if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
705    free(wd);
706 }
707
708 static void
709 _del_pre_hook(Evas_Object *obj)
710 {
711    Widget_Data *wd = elm_widget_data_get(obj);
712    if (!wd) return;
713    evas_object_del(wd->pan_smart);
714    wd->pan_smart = NULL;
715    elm_genlist_clear(obj);
716 }
717
718 static void
719 _mirrored_set(Evas_Object *obj,
720               Eina_Bool    rtl)
721 {
722    Widget_Data *wd = elm_widget_data_get(obj);
723    if (!wd) return;
724    _item_cache_zero(wd);
725    elm_smart_scroller_mirrored_set(wd->scr, rtl);
726 }
727
728 static void
729 _theme_hook(Evas_Object *obj)
730 {
731    Widget_Data *wd = elm_widget_data_get(obj);
732    Item_Block *itb;
733    if (!wd) return;
734    _item_cache_zero(wd);
735    _elm_widget_mirrored_reload(obj);
736    _mirrored_set(obj, elm_widget_mirrored_get(obj));
737    elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
738                                        elm_widget_style_get(obj));
739    edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
740    wd->item_width = wd->item_height = 0;
741    wd->group_item_width = wd->group_item_height = 0;
742    wd->minw = wd->minh = wd->realminw = 0;
743    EINA_INLIST_FOREACH(wd->blocks, itb)
744      {
745         Eina_List *l;
746         Elm_Genlist_Item *it;
747
748         if (itb->realized) _item_block_unrealize(itb);
749         EINA_LIST_FOREACH(itb->items, l, it)
750           it->mincalcd = EINA_FALSE;
751
752         itb->changed = EINA_TRUE;
753      }
754    if (wd->calc_job) ecore_job_del(wd->calc_job);
755    wd->calc_job = ecore_job_add(_calc_job, wd);
756    _sizing_eval(obj);
757 }
758
759 static void
760 _show_region_hook(void        *data,
761                   Evas_Object *obj)
762 {
763    Widget_Data *wd = elm_widget_data_get(data);
764    Evas_Coord x, y, w, h;
765    if (!wd) return;
766    elm_widget_show_region_get(obj, &x, &y, &w, &h);
767    //x & y are screen coordinates, Add with pan coordinates
768    x += wd->pan_x;
769    y += wd->pan_y;
770    elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
771 }
772
773 static void
774 _sizing_eval(Evas_Object *obj)
775 {
776    Widget_Data *wd = elm_widget_data_get(obj);
777    Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
778    if (!wd) return;
779    evas_object_size_hint_min_get(wd->scr, &minw, &minh);
780    evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
781    minh = -1;
782    if (wd->height_for_width)
783      {
784         Evas_Coord vw, vh;
785
786         elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
787         if ((vw != 0) && (vw != wd->prev_viewport_w))
788           {
789              Item_Block *itb;
790
791              wd->prev_viewport_w = vw;
792              EINA_INLIST_FOREACH(wd->blocks, itb)
793                {
794                   itb->must_recalc = EINA_TRUE;
795                }
796              if (wd->calc_job) ecore_job_del(wd->calc_job);
797              wd->calc_job = ecore_job_add(_calc_job, wd);
798           }
799      }
800    if (wd->mode == ELM_LIST_LIMIT)
801      {
802         Evas_Coord vmw, vmh, vw, vh;
803
804         minw = wd->realminw;
805         maxw = -1;
806         elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
807         if ((minw > 0) && (vw < minw)) vw = minw;
808         else if ((maxw > 0) && (vw > maxw))
809           vw = maxw;
810         edje_object_size_min_calc
811           (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
812         minw = vmw + minw;
813      }
814    else
815      {
816         Evas_Coord vmw, vmh;
817
818         edje_object_size_min_calc
819           (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
820         minw = vmw;
821         minh = vmh;
822      }
823    evas_object_size_hint_min_set(obj, minw, minh);
824    evas_object_size_hint_max_set(obj, maxw, maxh);
825 }
826
827 static void
828 _signal_emit_hook(Evas_Object *obj,
829                   const char  *emission,
830                   const char  *source)
831 {
832    Widget_Data *wd = elm_widget_data_get(obj);
833    edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
834                            emission, source);
835 }
836
837 static void
838 _item_highlight(Elm_Genlist_Item *it)
839 {
840    const char *selectraise;
841    if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
842        (it->disabled) || (it->display_only) || (it->mode_view))
843      return;
844    edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
845    selectraise = edje_object_data_get(it->base.view, "selectraise");
846    if ((selectraise) && (!strcmp(selectraise, "on")))
847      {
848         evas_object_raise(it->base.view);
849         if ((it->group_item) && (it->group_item->realized))
850           evas_object_raise(it->group_item->base.view);
851      }
852    it->highlighted = EINA_TRUE;
853 }
854
855 static void
856 _item_block_del(Elm_Genlist_Item *it)
857 {
858    Eina_Inlist *il;
859    Item_Block *itb = it->block;
860
861    itb->items = eina_list_remove(itb->items, it);
862    itb->count--;
863    itb->changed = EINA_TRUE;
864    if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
865    it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
866    if (itb->count < 1)
867      {
868         il = EINA_INLIST_GET(itb);
869         Item_Block *itbn = (Item_Block *)(il->next);
870         if (it->parent)
871           it->parent->items = eina_list_remove(it->parent->items, it);
872         else
873           it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
874         free(itb);
875         if (itbn) itbn->changed = EINA_TRUE;
876      }
877    else
878      {
879         if (itb->count < 16)
880           {
881              il = EINA_INLIST_GET(itb);
882              Item_Block *itbp = (Item_Block *)(il->prev);
883              Item_Block *itbn = (Item_Block *)(il->next);
884              if ((itbp) && ((itbp->count + itb->count) < 48))
885                {
886                   Elm_Genlist_Item *it2;
887
888                   EINA_LIST_FREE(itb->items, it2)
889                     {
890                        it2->block = itbp;
891                        itbp->items = eina_list_append(itbp->items, it2);
892                        itbp->count++;
893                        itbp->changed = EINA_TRUE;
894                     }
895                   it->wd->blocks = eina_inlist_remove(it->wd->blocks,
896                                                       EINA_INLIST_GET(itb));
897                   free(itb);
898                }
899              else if ((itbn) && ((itbn->count + itb->count) < 48))
900                {
901                   while (itb->items)
902                     {
903                        Eina_List *last = eina_list_last(itb->items);
904                        Elm_Genlist_Item *it2 = last->data;
905
906                        it2->block = itbn;
907                        itb->items = eina_list_remove_list(itb->items, last);
908                        itbn->items = eina_list_prepend(itbn->items, it2);
909                        itbn->count++;
910                        itbn->changed = EINA_TRUE;
911                     }
912                   it->wd->blocks =
913                     eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
914                   free(itb);
915                }
916           }
917      }
918 }
919
920 static void
921 _item_del(Elm_Genlist_Item *it)
922 {
923    elm_widget_item_pre_notify_del(it);
924    elm_genlist_item_subitems_clear(it);
925    it->wd->walking -= it->walking;
926    if (it->wd->show_item == it) it->wd->show_item = NULL;
927    if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
928    if (it->realized) _item_unrealize(it, EINA_FALSE);
929    if (it->block) _item_block_del(it);
930    if ((!it->delete_me) && (it->itc->func.del))
931      it->itc->func.del((void *)it->base.data, it->base.widget);
932    it->delete_me = EINA_TRUE;
933    if (it->queued)
934      it->wd->queue = eina_list_remove(it->wd->queue, it);
935    if (it->wd->anchor_item == it)
936      {
937         it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
938         if (!it->wd->anchor_item)
939           it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
940      }
941    it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
942    if (it->parent)
943      it->parent->items = eina_list_remove(it->parent->items, it);
944    if (it->flags & ELM_GENLIST_ITEM_GROUP)
945      it->wd->group_items = eina_list_remove(it->wd->group_items, it);
946    if (it->long_timer) ecore_timer_del(it->long_timer);
947    if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
948
949    if (it->tooltip.del_cb)
950      it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
951
952    elm_widget_item_del(it);
953 }
954
955 static void
956 _item_select(Elm_Genlist_Item *it)
957 {
958    if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
959    if (it->selected)
960      {
961         if (it->wd->always_select) goto call;
962         return;
963      }
964    it->selected = EINA_TRUE;
965    it->wd->selected = eina_list_append(it->wd->selected, it);
966 call:
967    it->walking++;
968    it->wd->walking++;
969    if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
970    if (!it->delete_me)
971      evas_object_smart_callback_call(it->base.widget, "selected", it);
972    it->walking--;
973    it->wd->walking--;
974    if ((it->wd->clear_me) && (!it->wd->walking))
975      elm_genlist_clear(it->base.widget);
976    else
977      {
978         if ((!it->walking) && (it->delete_me))
979           {
980              if (!it->relcount) _item_del(it);
981           }
982      }
983    it->wd->last_selected_item = it;
984 }
985
986 static void
987 _item_unselect(Elm_Genlist_Item *it)
988 {
989    const char *stacking, *selectraise;
990
991    if ((it->delete_me) || (!it->highlighted)) return;
992    edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
993    stacking = edje_object_data_get(it->base.view, "stacking");
994    selectraise = edje_object_data_get(it->base.view, "selectraise");
995    if ((selectraise) && (!strcmp(selectraise, "on")))
996      {
997         if ((stacking) && (!strcmp(stacking, "below")))
998           evas_object_lower(it->base.view);
999      }
1000    it->highlighted = EINA_FALSE;
1001    if (it->selected)
1002      {
1003         it->selected = EINA_FALSE;
1004         it->wd->selected = eina_list_remove(it->wd->selected, it);
1005         evas_object_smart_callback_call(it->base.widget, "unselected", it);
1006      }
1007 }
1008
1009 static void
1010 _mouse_move(void        *data,
1011             Evas        *evas __UNUSED__,
1012             Evas_Object *obj,
1013             void        *event_info)
1014 {
1015    Elm_Genlist_Item *it = data;
1016    Evas_Event_Mouse_Move *ev = event_info;
1017    Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1018
1019    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1020      {
1021         if (!it->wd->on_hold)
1022           {
1023              it->wd->on_hold = EINA_TRUE;
1024              if (!it->wd->wasselected)
1025                _item_unselect(it);
1026           }
1027      }
1028    if (it->wd->multitouched)
1029      {
1030         it->wd->cur_x = ev->cur.canvas.x;
1031         it->wd->cur_y = ev->cur.canvas.y;
1032         return;
1033      }
1034    if ((it->dragging) && (it->down))
1035      {
1036         if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1037         else
1038           {
1039              it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1040              it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1041              if (abs((it->wd->history[it->wd->movements].x -
1042                       it->wd->history[0].x)) > 40)
1043                it->wd->swipe = EINA_TRUE;
1044              else
1045                it->wd->movements++;
1046           }
1047         if (it->long_timer)
1048           {
1049              ecore_timer_del(it->long_timer);
1050              it->long_timer = NULL;
1051           }
1052         evas_object_smart_callback_call(it->base.widget, "drag", it);
1053         return;
1054      }
1055    if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1056      {
1057         if (it->long_timer)
1058           {
1059              ecore_timer_del(it->long_timer);
1060              it->long_timer = NULL;
1061           }
1062         return;
1063      }
1064    if (!it->display_only)
1065      elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1066    evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1067    x = ev->cur.canvas.x - x;
1068    y = ev->cur.canvas.y - y;
1069    dx = x - it->dx;
1070    adx = dx;
1071    if (adx < 0) adx = -dx;
1072    dy = y - it->dy;
1073    ady = dy;
1074    if (ady < 0) ady = -dy;
1075    minw /= 2;
1076    minh /= 2;
1077    if ((adx > minw) || (ady > minh))
1078      {
1079         it->dragging = EINA_TRUE;
1080         if (it->long_timer)
1081           {
1082              ecore_timer_del(it->long_timer);
1083              it->long_timer = NULL;
1084           }
1085         if (!it->wd->wasselected)
1086           _item_unselect(it);
1087         if (dy < 0)
1088           {
1089              if (ady > adx)
1090                evas_object_smart_callback_call(it->base.widget,
1091                                                "drag,start,up", it);
1092              else
1093                {
1094                   if (dx < 0)
1095                     evas_object_smart_callback_call(it->base.widget,
1096                                                     "drag,start,left", it);
1097                   else
1098                     evas_object_smart_callback_call(it->base.widget,
1099                                                     "drag,start,right", it);
1100                }
1101           }
1102         else
1103           {
1104              if (ady > adx)
1105                evas_object_smart_callback_call(it->base.widget,
1106                                                "drag,start,down", it);
1107              else
1108                {
1109                   if (dx < 0)
1110                     evas_object_smart_callback_call(it->base.widget,
1111                                                     "drag,start,left", it);
1112                   else
1113                     evas_object_smart_callback_call(it->base.widget,
1114                                                     "drag,start,right", it);
1115                }
1116           }
1117      }
1118 }
1119
1120 static Eina_Bool
1121 _long_press(void *data)
1122 {
1123    Elm_Genlist_Item *it = data;
1124
1125    it->long_timer = NULL;
1126    if ((it->disabled) || (it->dragging) || (it->display_only))
1127      return ECORE_CALLBACK_CANCEL;
1128    it->wd->longpressed = EINA_TRUE;
1129    evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1130    return ECORE_CALLBACK_CANCEL;
1131 }
1132
1133 static void
1134 _swipe(Elm_Genlist_Item *it)
1135 {
1136    int i, sum = 0;
1137
1138    if (!it) return;
1139    if ((it->display_only) || (it->disabled)) return;
1140    it->wd->swipe = EINA_FALSE;
1141    for (i = 0; i < it->wd->movements; i++)
1142      {
1143         sum += it->wd->history[i].x;
1144         if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1145      }
1146
1147    sum /= it->wd->movements;
1148    if (abs(sum - it->wd->history[0].x) <= 10) return;
1149    evas_object_smart_callback_call(it->base.widget, "swipe", it);
1150 }
1151
1152 static Eina_Bool
1153 _swipe_cancel(void *data)
1154 {
1155    Elm_Genlist_Item *it = data;
1156
1157    if (!it) return ECORE_CALLBACK_CANCEL;
1158    it->wd->swipe = EINA_FALSE;
1159    it->wd->movements = 0;
1160    return ECORE_CALLBACK_RENEW;
1161 }
1162
1163 static Eina_Bool
1164 _multi_cancel(void *data)
1165 {
1166    Widget_Data *wd = data;
1167
1168    if (!wd) return ECORE_CALLBACK_CANCEL;
1169    wd->multi_timeout = EINA_TRUE;
1170    return ECORE_CALLBACK_RENEW;
1171 }
1172
1173 static void
1174 _multi_touch_gesture_eval(void *data)
1175 {
1176    Elm_Genlist_Item *it = data;
1177
1178    it->wd->multitouched = EINA_FALSE;
1179    if (it->wd->multi_timer)
1180      {
1181         ecore_timer_del(it->wd->multi_timer);
1182         it->wd->multi_timer = NULL;
1183      }
1184    if (it->wd->multi_timeout)
1185      {
1186         it->wd->multi_timeout = EINA_FALSE;
1187         return;
1188      }
1189
1190    Evas_Coord minw = 0, minh = 0;
1191    Evas_Coord off_x, off_y, off_mx, off_my;
1192
1193    elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1194    off_x = abs(it->wd->cur_x - it->wd->prev_x);
1195    off_y = abs(it->wd->cur_y - it->wd->prev_y);
1196    off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1197    off_my = abs(it->wd->cur_my - it->wd->prev_my);
1198
1199    if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1200      {
1201         if ((off_x + off_mx) > (off_y + off_my))
1202           {
1203              if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1204                evas_object_smart_callback_call(it->base.widget,
1205                                                "multi,swipe,right", it);
1206              else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1207                evas_object_smart_callback_call(it->base.widget,
1208                                                "multi,swipe,left", it);
1209              else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1210                evas_object_smart_callback_call(it->base.widget,
1211                                                "multi,pinch,out", it);
1212              else
1213                evas_object_smart_callback_call(it->base.widget,
1214                                                "multi,pinch,in", it);
1215           }
1216         else
1217           {
1218              if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1219                evas_object_smart_callback_call(it->base.widget,
1220                                                "multi,swipe,down", it);
1221              else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1222                evas_object_smart_callback_call(it->base.widget,
1223                                                "multi,swipe,up", it);
1224              else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1225                evas_object_smart_callback_call(it->base.widget,
1226                                                "multi,pinch,out", it);
1227              else
1228                evas_object_smart_callback_call(it->base.widget,
1229                                                "multi,pinch,in", it);
1230           }
1231      }
1232    it->wd->multi_timeout = EINA_FALSE;
1233 }
1234
1235 static void
1236 _multi_down(void        *data,
1237             Evas        *evas __UNUSED__,
1238             Evas_Object *obj __UNUSED__,
1239             void        *event_info)
1240 {
1241    Elm_Genlist_Item *it = data;
1242    Evas_Event_Multi_Down *ev = event_info;
1243
1244    if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1245    it->wd->multi_device = ev->device;
1246    it->wd->multi_down = EINA_TRUE;
1247    it->wd->multitouched = EINA_TRUE;
1248    it->wd->prev_mx = ev->canvas.x;
1249    it->wd->prev_my = ev->canvas.y;
1250    if (!it->wd->wasselected) _item_unselect(it);
1251    it->wd->wasselected = EINA_FALSE;
1252    it->wd->longpressed = EINA_FALSE;
1253    if (it->long_timer)
1254      {
1255         ecore_timer_del(it->long_timer);
1256         it->long_timer = NULL;
1257      }
1258    if (it->dragging)
1259      {
1260         it->dragging = EINA_FALSE;
1261         evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1262      }
1263    if (it->swipe_timer)
1264      {
1265         ecore_timer_del(it->swipe_timer);
1266         it->swipe_timer = NULL;
1267      }
1268    if (it->wd->on_hold)
1269      {
1270         it->wd->swipe = EINA_FALSE;
1271         it->wd->movements = 0;
1272         it->wd->on_hold = EINA_FALSE;
1273      }
1274 }
1275
1276 static void
1277 _multi_up(void        *data,
1278           Evas        *evas __UNUSED__,
1279           Evas_Object *obj __UNUSED__,
1280           void        *event_info)
1281 {
1282    Elm_Genlist_Item *it = data;
1283    Evas_Event_Multi_Up *ev = event_info;
1284
1285    if (it->wd->multi_device != ev->device) return;
1286    it->wd->multi_device = 0;
1287    it->wd->multi_down = EINA_FALSE;
1288    if (it->wd->mouse_down) return;
1289    _multi_touch_gesture_eval(data);
1290 }
1291
1292 static void
1293 _multi_move(void        *data,
1294             Evas        *evas __UNUSED__,
1295             Evas_Object *obj __UNUSED__,
1296             void        *event_info)
1297 {
1298    Elm_Genlist_Item *it = data;
1299    Evas_Event_Multi_Move *ev = event_info;
1300
1301    if (it->wd->multi_device != ev->device) return;
1302    it->wd->cur_mx = ev->cur.canvas.x;
1303    it->wd->cur_my = ev->cur.canvas.y;
1304 }
1305
1306 static void
1307 _mouse_down(void        *data,
1308             Evas        *evas __UNUSED__,
1309             Evas_Object *obj,
1310             void        *event_info)
1311 {
1312    Elm_Genlist_Item *it = data;
1313    Evas_Event_Mouse_Down *ev = event_info;
1314    Evas_Coord x, y;
1315
1316    if (ev->button != 1) return;
1317    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1318      {
1319         it->wd->on_hold = EINA_TRUE;
1320      }
1321
1322    it->down = EINA_TRUE;
1323    it->dragging = EINA_FALSE;
1324    evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1325    it->dx = ev->canvas.x - x;
1326    it->dy = ev->canvas.y - y;
1327    it->wd->mouse_down = EINA_TRUE;
1328    if (!it->wd->multitouched)
1329      {
1330         it->wd->prev_x = ev->canvas.x;
1331         it->wd->prev_y = ev->canvas.y;
1332         it->wd->multi_timeout = EINA_FALSE;
1333         if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1334         it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1335      }
1336    it->wd->longpressed = EINA_FALSE;
1337    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1338    else it->wd->on_hold = EINA_FALSE;
1339    if (it->wd->on_hold) return;
1340    it->wd->wasselected = it->selected;
1341    _item_highlight(it);
1342    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1343      if ((!it->disabled) && (!it->display_only))
1344        {
1345           evas_object_smart_callback_call(it->base.widget, "clicked,double", it);
1346           evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
1347        }
1348    if (it->long_timer) ecore_timer_del(it->long_timer);
1349    if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1350    it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1351    if (it->realized)
1352      it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1353                                       it);
1354    else
1355      it->long_timer = NULL;
1356    it->wd->swipe = EINA_FALSE;
1357    it->wd->movements = 0;
1358 }
1359
1360 static void
1361 _mouse_up(void        *data,
1362           Evas        *evas __UNUSED__,
1363           Evas_Object *obj __UNUSED__,
1364           void        *event_info)
1365 {
1366    Elm_Genlist_Item *it = data;
1367    Evas_Event_Mouse_Up *ev = event_info;
1368    Eina_Bool dragged = EINA_FALSE;
1369
1370    if (ev->button != 1) return;
1371    it->down = EINA_FALSE;
1372    it->wd->mouse_down = EINA_FALSE;
1373    if (it->wd->multitouched)
1374      {
1375         if (it->wd->multi_down) return;
1376         _multi_touch_gesture_eval(data);
1377         return;
1378      }
1379    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1380    else it->wd->on_hold = EINA_FALSE;
1381    if (it->long_timer)
1382      {
1383         ecore_timer_del(it->long_timer);
1384         it->long_timer = NULL;
1385      }
1386    if (it->dragging)
1387      {
1388         it->dragging = EINA_FALSE;
1389         evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1390         dragged = 1;
1391      }
1392    if (it->swipe_timer)
1393      {
1394         ecore_timer_del(it->swipe_timer);
1395         it->swipe_timer = NULL;
1396      }
1397    if (it->wd->multi_timer)
1398      {
1399         ecore_timer_del(it->wd->multi_timer);
1400         it->wd->multi_timer = NULL;
1401         it->wd->multi_timeout = EINA_FALSE;
1402      }
1403    if (it->wd->on_hold)
1404      {
1405         if (it->wd->swipe) _swipe(data);
1406         it->wd->longpressed = EINA_FALSE;
1407         it->wd->on_hold = EINA_FALSE;
1408         return;
1409      }
1410    if (it->wd->longpressed)
1411      {
1412         it->wd->longpressed = EINA_FALSE;
1413         if (!it->wd->wasselected)
1414           _item_unselect(it);
1415         it->wd->wasselected = EINA_FALSE;
1416         return;
1417      }
1418    if (dragged)
1419      {
1420         if (it->want_unrealize)
1421           {
1422              _item_unrealize(it, EINA_FALSE);
1423              if (it->block->want_unrealize)
1424                _item_block_unrealize(it->block);
1425           }
1426      }
1427    if ((it->disabled) || (dragged) || (it->display_only)) return;
1428    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1429    if (it->wd->multi)
1430      {
1431         if (!it->selected)
1432           {
1433              _item_highlight(it);
1434              _item_select(it);
1435           }
1436         else _item_unselect(it);
1437      }
1438    else
1439      {
1440         if (!it->selected)
1441           {
1442              Widget_Data *wd = it->wd;
1443              if (wd)
1444                {
1445                   while (wd->selected) _item_unselect(wd->selected->data);
1446                }
1447           }
1448         else
1449           {
1450              const Eina_List *l, *l_next;
1451              Elm_Genlist_Item *it2;
1452
1453              EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1454                if (it2 != it) _item_unselect(it2);
1455              //_item_highlight(it);
1456              //_item_select(it);
1457           }
1458         _item_highlight(it);
1459         _item_select(it);
1460      }
1461 }
1462
1463 static void
1464 _signal_expand_toggle(void        *data,
1465                       Evas_Object *obj __UNUSED__,
1466                       const char  *emission __UNUSED__,
1467                       const char  *source __UNUSED__)
1468 {
1469    Elm_Genlist_Item *it = data;
1470
1471    if (it->expanded)
1472      evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1473    else
1474      evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1475 }
1476
1477 static void
1478 _signal_expand(void        *data,
1479                Evas_Object *obj __UNUSED__,
1480                const char  *emission __UNUSED__,
1481                const char  *source __UNUSED__)
1482 {
1483    Elm_Genlist_Item *it = data;
1484
1485    if (!it->expanded)
1486      evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1487 }
1488
1489 static void
1490 _signal_contract(void        *data,
1491                  Evas_Object *obj __UNUSED__,
1492                  const char  *emission __UNUSED__,
1493                  const char  *source __UNUSED__)
1494 {
1495    Elm_Genlist_Item *it = data;
1496
1497    if (it->expanded)
1498      evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1499 }
1500
1501 static Eina_Bool
1502 _scr_hold_timer_cb(void *data)
1503 {
1504    if (!data) return ECORE_CALLBACK_CANCEL;
1505    Widget_Data *wd = data;
1506    elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1507    wd->scr_hold_timer = NULL;
1508    return ECORE_CALLBACK_CANCEL;
1509 }
1510
1511 static void
1512 _mode_finished_signal_cb(void        *data,
1513                          Evas_Object *obj,
1514                          const char  *emission __UNUSED__,
1515                          const char  *source __UNUSED__)
1516 {
1517    if (!data) return;
1518    if (!obj) return;
1519    Elm_Genlist_Item *it = data;
1520    if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1521    char buf[1024];
1522
1523    it->nocache = EINA_FALSE;
1524    _mode_item_unrealize(it);
1525    snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1526    edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1527 }
1528
1529 static void
1530 _item_cache_clean(Widget_Data *wd)
1531 {
1532    while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1533      {
1534         Item_Cache *itc;
1535
1536         itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1537         wd->item_cache = eina_inlist_remove(wd->item_cache,
1538                                             wd->item_cache->last);
1539         wd->item_cache_count--;
1540         if (itc->spacer) evas_object_del(itc->spacer);
1541         if (itc->base_view) evas_object_del(itc->base_view);
1542         if (itc->item_style) eina_stringshare_del(itc->item_style);
1543         free(itc);
1544      }
1545 }
1546
1547 static void
1548 _item_cache_zero(Widget_Data *wd)
1549 {
1550    int pmax = wd->item_cache_max;
1551    wd->item_cache_max = 0;
1552    _item_cache_clean(wd);
1553    wd->item_cache_max = pmax;
1554 }
1555
1556 static void
1557 _item_cache_add(Elm_Genlist_Item *it)
1558 {
1559    Item_Cache *itc;
1560
1561    if (it->wd->item_cache_max <= 0)
1562      {
1563         evas_object_del(it->base.view);
1564         it->base.view = NULL;
1565         evas_object_del(it->spacer);
1566         it->spacer = NULL;
1567         return;
1568      }
1569
1570    it->wd->item_cache_count++;
1571    itc = calloc(1, sizeof(Item_Cache));
1572    it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1573                                             EINA_INLIST_GET(itc));
1574    itc->spacer = it->spacer;
1575    it->spacer = NULL;
1576    itc->base_view = it->base.view;
1577    it->base.view = NULL;
1578    evas_object_hide(itc->base_view);
1579    evas_object_move(itc->base_view, -9999, -9999);
1580    itc->item_style = eina_stringshare_add(it->itc->item_style);
1581    if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1582    itc->compress = (it->wd->compress);
1583    itc->odd = (it->order_num_in & 0x1);
1584    itc->selected = it->selected;
1585    itc->disabled = it->disabled;
1586    itc->expanded = it->expanded;
1587    if (it->long_timer)
1588      {
1589         ecore_timer_del(it->long_timer);
1590         it->long_timer = NULL;
1591      }
1592    if (it->swipe_timer)
1593      {
1594         ecore_timer_del(it->swipe_timer);
1595         it->swipe_timer = NULL;
1596      }
1597    // FIXME: other callbacks?
1598    edje_object_signal_callback_del_full(itc->base_view,
1599                                         "elm,action,expand,toggle",
1600                                         "elm", _signal_expand_toggle, it);
1601    edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1602                                         "elm",
1603                                         _signal_expand, it);
1604    edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1605                                         "elm", _signal_contract, it);
1606    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1607                                        _mouse_down, it);
1608    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1609                                        _mouse_up, it);
1610    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1611                                        _mouse_move, it);
1612    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1613                                        _multi_down, it);
1614    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1615                                        _multi_up, it);
1616    evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1617                                        _multi_move, it);
1618    _item_cache_clean(it->wd);
1619 }
1620
1621 static Item_Cache *
1622 _item_cache_find(Elm_Genlist_Item *it)
1623 {
1624    Item_Cache *itc;
1625    Eina_Bool tree = 0, odd;
1626
1627    if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1628    odd = (it->order_num_in & 0x1);
1629    EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1630      {
1631         if ((itc->selected) || (itc->disabled) || (itc->expanded))
1632           continue;
1633         if ((itc->tree == tree) &&
1634             (itc->odd == odd) &&
1635             (itc->compress == it->wd->compress) &&
1636             (!strcmp(it->itc->item_style, itc->item_style)))
1637           {
1638              it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1639                                                      EINA_INLIST_GET(itc));
1640              it->wd->item_cache_count--;
1641              return itc;
1642           }
1643      }
1644    return NULL;
1645 }
1646
1647 static void
1648 _item_cache_free(Item_Cache *itc)
1649 {
1650    if (itc->spacer) evas_object_del(itc->spacer);
1651    if (itc->base_view) evas_object_del(itc->base_view);
1652    if (itc->item_style) eina_stringshare_del(itc->item_style);
1653    free(itc);
1654 }
1655
1656 static void
1657 _item_realize(Elm_Genlist_Item *it,
1658               int               in,
1659               Eina_Bool         calc)
1660 {
1661    Elm_Genlist_Item *it2;
1662    const char *stacking;
1663    const char *treesize;
1664    char buf[1024];
1665    int depth, tsize = 20;
1666    Item_Cache *itc = NULL;
1667
1668    if ((it->realized) || (it->delete_me)) return;
1669    it->order_num_in = in;
1670
1671    if (it->nocache)
1672      it->nocache = EINA_FALSE;
1673    else
1674      itc = _item_cache_find(it);
1675    if (itc)
1676      {
1677         it->base.view = itc->base_view;
1678         itc->base_view = NULL;
1679         it->spacer = itc->spacer;
1680         itc->spacer = NULL;
1681      }
1682    else
1683      {
1684         it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1685         edje_object_scale_set(it->base.view,
1686                               elm_widget_scale_get(it->base.widget) *
1687                               _elm_config->scale);
1688         evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1689         elm_widget_sub_object_add(it->base.widget, it->base.view);
1690
1691         if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1692           strncpy(buf, "tree", sizeof(buf));
1693         else strncpy(buf, "item", sizeof(buf));
1694         if (it->wd->compress)
1695           strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1696
1697         if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1698         strncat(buf, "/", sizeof(buf) - strlen(buf));
1699         strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1700
1701         _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1702                               elm_widget_style_get(it->base.widget));
1703         edje_object_mirrored_set(it->base.view,
1704                                  elm_widget_mirrored_get(it->base.widget));
1705         it->spacer =
1706           evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1707         evas_object_color_set(it->spacer, 0, 0, 0, 0);
1708         elm_widget_sub_object_add(it->base.widget, it->spacer);
1709      }
1710    for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1711      {
1712         if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1713      }
1714    it->expanded_depth = depth;
1715    treesize = edje_object_data_get(it->base.view, "treesize");
1716    if (treesize) tsize = atoi(treesize);
1717    evas_object_size_hint_min_set(it->spacer,
1718                                  (depth * tsize) * _elm_config->scale, 1);
1719    edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1720    if (!calc)
1721      {
1722         edje_object_signal_callback_add(it->base.view,
1723                                         "elm,action,expand,toggle",
1724                                         "elm", _signal_expand_toggle, it);
1725         edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1726                                         "elm", _signal_expand, it);
1727         edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1728                                         "elm", _signal_contract, it);
1729         stacking = edje_object_data_get(it->base.view, "stacking");
1730         if (stacking)
1731           {
1732              if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1733              else if (!strcmp(stacking, "above"))
1734                evas_object_raise(it->base.view);
1735           }
1736         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1737                                        _mouse_down, it);
1738         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1739                                        _mouse_up, it);
1740         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1741                                        _mouse_move, it);
1742         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1743                                        _multi_down, it);
1744         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1745                                        _multi_up, it);
1746         evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1747                                        _multi_move, it);
1748         if (itc)
1749           {
1750              if (it->selected != itc->selected)
1751                {
1752                   if (it->selected)
1753                     edje_object_signal_emit(it->base.view,
1754                                             "elm,state,selected", "elm");
1755                }
1756              if (it->disabled != itc->disabled)
1757                {
1758                   if (it->disabled)
1759                     edje_object_signal_emit(it->base.view,
1760                                             "elm,state,disabled", "elm");
1761                }
1762              if (it->expanded != itc->expanded)
1763                {
1764                   if (it->expanded)
1765                     edje_object_signal_emit(it->base.view,
1766                                             "elm,state,expanded", "elm");
1767                }
1768           }
1769         else
1770           {
1771              if (it->selected)
1772                edje_object_signal_emit(it->base.view,
1773                                        "elm,state,selected", "elm");
1774              if (it->disabled)
1775                edje_object_signal_emit(it->base.view,
1776                                        "elm,state,disabled", "elm");
1777              if (it->expanded)
1778                edje_object_signal_emit(it->base.view,
1779                                        "elm,state,expanded", "elm");
1780           }
1781      }
1782
1783    if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1784      {
1785         /* homogenous genlist shortcut */
1786         if (!it->mincalcd)
1787           {
1788              if (it->flags & ELM_GENLIST_ITEM_GROUP)
1789                {
1790                   it->w = it->minw = it->wd->group_item_width;
1791                   it->h = it->minh = it->wd->group_item_height;
1792                }
1793              else
1794                {
1795                   it->w = it->minw = it->wd->item_width;
1796                   it->h = it->minh = it->wd->item_height;
1797                }
1798              it->mincalcd = EINA_TRUE;
1799           }
1800      }
1801    else
1802      {
1803         if (it->itc->func.label_get)
1804           {
1805              const Eina_List *l;
1806              const char *key;
1807
1808              it->labels =
1809                elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1810                                                               "labels"));
1811              EINA_LIST_FOREACH(it->labels, l, key)
1812                {
1813                   char *s = it->itc->func.label_get
1814                       ((void *)it->base.data, it->base.widget, l->data);
1815
1816                   if (s)
1817                     {
1818                        edje_object_part_text_set(it->base.view, l->data, s);
1819                        free(s);
1820                     }
1821                   else if (itc)
1822                     edje_object_part_text_set(it->base.view, l->data, "");
1823                }
1824           }
1825         if (it->itc->func.icon_get)
1826           {
1827              const Eina_List *l;
1828              const char *key;
1829
1830              it->icons =
1831                elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1832                                                               "icons"));
1833              EINA_LIST_FOREACH(it->icons, l, key)
1834                {
1835                   Evas_Object *ic = it->itc->func.icon_get
1836                       ((void *)it->base.data, it->base.widget, l->data);
1837
1838                   if (ic)
1839                     {
1840                        it->icon_objs = eina_list_append(it->icon_objs, ic);
1841                        edje_object_part_swallow(it->base.view, key, ic);
1842                        evas_object_show(ic);
1843                        elm_widget_sub_object_add(it->base.widget, ic);
1844                     }
1845                }
1846           }
1847         if (it->itc->func.state_get)
1848           {
1849              const Eina_List *l;
1850              const char *key;
1851
1852              it->states =
1853                elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1854                                                               "states"));
1855              EINA_LIST_FOREACH(it->states, l, key)
1856                {
1857                   Eina_Bool on = it->itc->func.state_get
1858                       ((void *)it->base.data, it->base.widget, l->data);
1859
1860                   if (on)
1861                     {
1862                        snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
1863                        edje_object_signal_emit(it->base.view, buf, "elm");
1864                     }
1865                   else if (itc)
1866                     {
1867                        snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
1868                        edje_object_signal_emit(it->base.view, buf, "elm");
1869                     }
1870                }
1871           }
1872         if (!it->mincalcd)
1873           {
1874              Evas_Coord mw = -1, mh = -1;
1875
1876              if (it->wd->height_for_width) mw = it->wd->w;
1877
1878              if (!it->display_only)
1879                elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1880              if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
1881              edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
1882                                                   mh);
1883              if (!it->display_only)
1884                elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1885              it->w = it->minw = mw;
1886              it->h = it->minh = mh;
1887              it->mincalcd = EINA_TRUE;
1888
1889              if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
1890                {
1891                   it->wd->group_item_width = mw;
1892                   it->wd->group_item_height = mh;
1893                }
1894              else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
1895                {
1896                   it->wd->item_width = mw;
1897                   it->wd->item_height = mh;
1898                }
1899           }
1900         if (!calc) evas_object_show(it->base.view);
1901      }
1902
1903    if (it->tooltip.content_cb)
1904      {
1905         elm_widget_item_tooltip_content_cb_set(it,
1906                                                it->tooltip.content_cb,
1907                                                it->tooltip.data, NULL);
1908         elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1909      }
1910
1911    if (it->mouse_cursor)
1912      elm_widget_item_cursor_set(it, it->mouse_cursor);
1913
1914    it->realized = EINA_TRUE;
1915    it->want_unrealize = EINA_FALSE;
1916
1917    if (itc) _item_cache_free(itc);
1918    if (!calc) evas_object_smart_callback_call(it->base.widget, "realized", it);
1919 }
1920
1921 static void
1922 _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc)
1923 {
1924    Evas_Object *icon;
1925
1926    if (!it->realized) return;
1927    if (!calc) evas_object_smart_callback_call(it->base.widget, "unrealized", it);
1928    if (it->long_timer)
1929      {
1930         ecore_timer_del(it->long_timer);
1931         it->long_timer = NULL;
1932      }
1933    if (it->nocache)
1934      {
1935         evas_object_del(it->base.view);
1936         it->base.view = NULL;
1937         evas_object_del(it->spacer);
1938         it->spacer = NULL;
1939      }
1940    else
1941      {
1942         edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
1943         _item_cache_add(it);
1944      }
1945    elm_widget_stringlist_free(it->labels);
1946    it->labels = NULL;
1947    elm_widget_stringlist_free(it->icons);
1948    it->icons = NULL;
1949    elm_widget_stringlist_free(it->states);
1950
1951    EINA_LIST_FREE(it->icon_objs, icon)
1952      evas_object_del(icon);
1953
1954    _mode_item_unrealize(it);
1955    it->states = NULL;
1956    it->realized = EINA_FALSE;
1957    it->want_unrealize = EINA_FALSE;
1958 }
1959
1960 static Eina_Bool
1961 _item_block_recalc(Item_Block *itb,
1962                    int         in,
1963                    int         qadd,
1964                    int         norender)
1965 {
1966    const Eina_List *l;
1967    Elm_Genlist_Item *it;
1968    Evas_Coord minw = 0, minh = 0;
1969    Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
1970    Evas_Coord y = 0;
1971
1972    itb->num = in;
1973    EINA_LIST_FOREACH(itb->items, l, it)
1974      {
1975         if (it->delete_me) continue;
1976         showme |= it->showme;
1977         if (!itb->realized)
1978           {
1979              if (qadd)
1980                {
1981                   if (!it->mincalcd) changed = EINA_TRUE;
1982                   if (changed)
1983                     {
1984                        _item_realize(it, in, EINA_TRUE);
1985                        _item_unrealize(it, EINA_TRUE);
1986                     }
1987                }
1988              else
1989                {
1990                   _item_realize(it, in, EINA_TRUE);
1991                   _item_unrealize(it, EINA_TRUE);
1992                }
1993           }
1994         else
1995           _item_realize(it, in, EINA_FALSE);
1996         minh += it->minh;
1997         if (minw < it->minw) minw = it->minw;
1998         in++;
1999         it->x = 0;
2000         it->y = y;
2001         y += it->h;
2002      }
2003    itb->minw = minw;
2004    itb->minh = minh;
2005    itb->changed = EINA_FALSE;
2006    /* force an evas norender to garbage collect deleted objects */
2007    if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2008    return showme;
2009 }
2010
2011 static void
2012 _item_block_realize(Item_Block *itb,
2013                     int         in,
2014                     int         full)
2015 {
2016    const Eina_List *l;
2017    Elm_Genlist_Item *it;
2018
2019    if (itb->realized) return;
2020    EINA_LIST_FOREACH(itb->items, l, it)
2021      {
2022         if (it->delete_me) continue;
2023         if (full) _item_realize(it, in, EINA_FALSE);
2024         in++;
2025      }
2026    itb->realized = EINA_TRUE;
2027    itb->want_unrealize = EINA_FALSE;
2028 }
2029
2030 static void
2031 _item_block_unrealize(Item_Block *itb)
2032 {
2033    const Eina_List *l;
2034    Elm_Genlist_Item *it;
2035    Eina_Bool dragging = EINA_FALSE;
2036
2037    if (!itb->realized) return;
2038    EINA_LIST_FOREACH(itb->items, l, it)
2039      {
2040         if (it->flags != ELM_GENLIST_ITEM_GROUP)
2041           {
2042              if (it->dragging)
2043                {
2044                   dragging = EINA_TRUE;
2045                   it->want_unrealize = EINA_TRUE;
2046                }
2047              else
2048                _item_unrealize(it, EINA_FALSE);
2049           }
2050      }
2051    if (!dragging)
2052      {
2053         itb->realized = EINA_FALSE;
2054         itb->want_unrealize = EINA_TRUE;
2055      }
2056    else
2057      itb->want_unrealize = EINA_FALSE;
2058 }
2059
2060 static void
2061 _item_position(Elm_Genlist_Item *it, Evas_Object *view)
2062 {
2063    if (!it) return;
2064    if (!view) return;
2065
2066    evas_object_resize(view, it->w, it->h);
2067    evas_object_move(view, it->scrl_x, it->scrl_y);
2068    evas_object_show(view);
2069 }
2070
2071 static void
2072 _item_block_position(Item_Block *itb,
2073                      int         in)
2074 {
2075    const Eina_List *l;
2076    Elm_Genlist_Item *it;
2077    Elm_Genlist_Item *git;
2078    Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2079    int vis;
2080
2081    evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2082    evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2083                             &cvw, &cvh);
2084    EINA_LIST_FOREACH(itb->items, l, it)
2085      {
2086         if (it->delete_me) continue;
2087         it->x = 0;
2088         it->y = y;
2089         it->w = itb->w;
2090         it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2091         it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2092
2093         vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2094                                    cvx, cvy, cvw, cvh));
2095         if (it->flags != ELM_GENLIST_ITEM_GROUP)
2096           {
2097              if ((itb->realized) && (!it->realized))
2098                {
2099                   if (vis) _item_realize(it, in, EINA_FALSE);
2100                }
2101              if (it->realized)
2102                {
2103                   if (vis)
2104                     {
2105                        git = it->group_item;
2106                        if (git)
2107                          {
2108                             if (git->scrl_y < oy)
2109                               git->scrl_y = oy;
2110                             if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2111                               git->scrl_y = (it->scrl_y + it->h) - git->h;
2112                             git->want_realize = EINA_TRUE;
2113                          }
2114                        if (it->mode_view)
2115                           _item_position(it, it->mode_view);
2116                        else
2117                           _item_position(it, it->base.view);
2118                     }
2119                   else
2120                     {
2121                        if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2122                     }
2123                }
2124              in++;
2125           }
2126         else
2127           {
2128              if (vis) it->want_realize = EINA_TRUE;
2129           }
2130         y += it->h;
2131      }
2132 }
2133
2134 static void
2135 _group_items_recalc(void *data)
2136 {
2137    Widget_Data *wd = data;
2138    Eina_List *l;
2139    Elm_Genlist_Item *git;
2140
2141    EINA_LIST_FOREACH(wd->group_items, l, git)
2142      {
2143         if (git->want_realize)
2144           {
2145              if (!git->realized)
2146                _item_realize(git, 0, EINA_FALSE);
2147              evas_object_resize(git->base.view, wd->minw, git->h);
2148              evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2149              evas_object_show(git->base.view);
2150              evas_object_raise(git->base.view);
2151           }
2152         else if (!git->want_realize && git->realized)
2153           {
2154              if (!git->dragging)
2155                _item_unrealize(git, EINA_FALSE);
2156           }
2157      }
2158 }
2159
2160 static Eina_Bool
2161 _must_recalc_idler(void *data)
2162 {
2163    Widget_Data *wd = data;
2164    if (wd->calc_job) ecore_job_del(wd->calc_job);
2165    wd->calc_job = ecore_job_add(_calc_job, wd);
2166    wd->must_recalc_idler = NULL;
2167    return ECORE_CALLBACK_CANCEL;
2168 }
2169
2170 static void
2171 _calc_job(void *data)
2172 {
2173    Widget_Data *wd = data;
2174    Item_Block *itb;
2175    Evas_Coord minw = -1, minh = 0, y = 0, ow;
2176    Item_Block *chb = NULL;
2177    int in = 0, minw_change = 0;
2178    Eina_Bool changed = EINA_FALSE;
2179    double t0, t;
2180    Eina_Bool did_must_recalc = EINA_FALSE;
2181    if (!wd) return;
2182
2183    t0 = ecore_time_get();
2184    evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2185    if (wd->w != ow)
2186      {
2187         wd->w = ow;
2188         //        if (wd->height_for_width) changed = EINA_TRUE;
2189      }
2190
2191    EINA_INLIST_FOREACH(wd->blocks, itb)
2192      {
2193         Eina_Bool showme = EINA_FALSE;
2194
2195         itb->num = in;
2196         showme = itb->showme;
2197         itb->showme = EINA_FALSE;
2198         if (chb)
2199           {
2200              if (itb->realized) _item_block_unrealize(itb);
2201           }
2202         if ((itb->changed) || (changed) ||
2203             ((itb->must_recalc) && (!did_must_recalc)))
2204           {
2205              if ((changed) || (itb->must_recalc))
2206                {
2207                   Eina_List *l;
2208                   Elm_Genlist_Item *it;
2209                   EINA_LIST_FOREACH(itb->items, l, it)
2210                     if (it->mincalcd) it->mincalcd = EINA_FALSE;
2211                   itb->changed = EINA_TRUE;
2212                   if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2213                   itb->must_recalc = EINA_FALSE;
2214                }
2215              if (itb->realized) _item_block_unrealize(itb);
2216              showme = _item_block_recalc(itb, in, 0, 1);
2217              chb = itb;
2218           }
2219         itb->y = y;
2220         itb->x = 0;
2221         minh += itb->minh;
2222         if (minw == -1) minw = itb->minw;
2223         else if ((!itb->must_recalc) && (minw < itb->minw))
2224           {
2225              minw = itb->minw;
2226              minw_change = 1;
2227           }
2228         itb->w = minw;
2229         itb->h = itb->minh;
2230         y += itb->h;
2231         in += itb->count;
2232         if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2233           {
2234              wd->show_item->showme = EINA_FALSE;
2235              if (wd->bring_in)
2236                elm_smart_scroller_region_bring_in(wd->scr,
2237                                                   wd->show_item->x +
2238                                                   wd->show_item->block->x,
2239                                                   wd->show_item->y +
2240                                                   wd->show_item->block->y,
2241                                                   wd->show_item->block->w,
2242                                                   wd->show_item->h);
2243              else
2244                elm_smart_scroller_child_region_show(wd->scr,
2245                                                     wd->show_item->x +
2246                                                     wd->show_item->block->x,
2247                                                     wd->show_item->y +
2248                                                     wd->show_item->block->y,
2249                                                     wd->show_item->block->w,
2250                                                     wd->show_item->h);
2251              wd->show_item = NULL;
2252           }
2253      }
2254    if (minw_change)
2255      {
2256         EINA_INLIST_FOREACH(wd->blocks, itb)
2257           {
2258              itb->minw = minw;
2259              itb->w = itb->minw;
2260           }
2261      }
2262    if ((chb) && (EINA_INLIST_GET(chb)->next))
2263      {
2264         EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2265           {
2266              if (itb->realized) _item_block_unrealize(itb);
2267           }
2268      }
2269    wd->realminw = minw;
2270    if (minw < wd->w) minw = wd->w;
2271    if ((minw != wd->minw) || (minh != wd->minh))
2272      {
2273         wd->minw = minw;
2274         wd->minh = minh;
2275         evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2276         _sizing_eval(wd->obj);
2277         if ((wd->anchor_item) && (wd->anchor_item->block))
2278           {
2279              Elm_Genlist_Item *it;
2280              Evas_Coord it_y;
2281
2282              it = wd->anchor_item;
2283              it_y = wd->anchor_y;
2284              elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2285                                               it->block->y + it->y + it_y);
2286              wd->anchor_item = it;
2287              wd->anchor_y = it_y;
2288           }
2289      }
2290    t = ecore_time_get();
2291    if (did_must_recalc)
2292      {
2293         if (!wd->must_recalc_idler)
2294           wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2295      }
2296    wd->calc_job = NULL;
2297    evas_object_smart_changed(wd->pan_smart);
2298 }
2299
2300 static void
2301 _update_job(void *data)
2302 {
2303    Widget_Data *wd = data;
2304    Eina_List *l2;
2305    Item_Block *itb;
2306    int num, num0, position = 0, recalc = 0;
2307    if (!wd) return;
2308    wd->update_job = NULL;
2309    num = 0;
2310    EINA_INLIST_FOREACH(wd->blocks, itb)
2311      {
2312         Evas_Coord itminw, itminh;
2313         Elm_Genlist_Item *it;
2314
2315         if (!itb->updateme)
2316           {
2317              num += itb->count;
2318              if (position)
2319                _item_block_position(itb, num);
2320              continue;
2321           }
2322         num0 = num;
2323         recalc = 0;
2324         EINA_LIST_FOREACH(itb->items, l2, it)
2325           {
2326              if (it->updateme)
2327                {
2328                   itminw = it->minw;
2329                   itminh = it->minh;
2330
2331                   it->updateme = EINA_FALSE;
2332                   if (it->realized)
2333                     {
2334                        _item_unrealize(it, EINA_FALSE);
2335                        _item_realize(it, num, EINA_FALSE);
2336                        position = 1;
2337                     }
2338                   else
2339                     {
2340                        _item_realize(it, num, EINA_TRUE);
2341                        _item_unrealize(it, EINA_TRUE);
2342                     }
2343                   if ((it->minw != itminw) || (it->minh != itminh))
2344                     recalc = 1;
2345                }
2346              num++;
2347           }
2348         itb->updateme = EINA_FALSE;
2349         if (recalc)
2350           {
2351              position = 1;
2352              itb->changed = EINA_TRUE;
2353              _item_block_recalc(itb, num0, 0, 1);
2354              _item_block_position(itb, num0);
2355           }
2356      }
2357    if (position)
2358      {
2359         if (wd->calc_job) ecore_job_del(wd->calc_job);
2360         wd->calc_job = ecore_job_add(_calc_job, wd);
2361      }
2362 }
2363
2364 static void
2365 _pan_set(Evas_Object *obj,
2366          Evas_Coord   x,
2367          Evas_Coord   y)
2368 {
2369    Pan *sd = evas_object_smart_data_get(obj);
2370    Item_Block *itb;
2371
2372    //   Evas_Coord ow, oh;
2373    //   evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2374    //   ow = sd->wd->minw - ow;
2375    //   if (ow < 0) ow = 0;
2376    //   oh = sd->wd->minh - oh;
2377    //   if (oh < 0) oh = 0;
2378    //   if (x < 0) x = 0;
2379    //   if (y < 0) y = 0;
2380    //   if (x > ow) x = ow;
2381    //   if (y > oh) y = oh;
2382    if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2383    sd->wd->pan_x = x;
2384    sd->wd->pan_y = y;
2385
2386    EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2387      {
2388         if ((itb->y + itb->h) > y)
2389           {
2390              Elm_Genlist_Item *it;
2391              Eina_List *l2;
2392
2393              EINA_LIST_FOREACH(itb->items, l2, it)
2394                {
2395                   if ((itb->y + it->y) >= y)
2396                     {
2397                        sd->wd->anchor_item = it;
2398                        sd->wd->anchor_y = -(itb->y + it->y - y);
2399                        goto done;
2400                     }
2401                }
2402           }
2403      }
2404 done:
2405    evas_object_smart_changed(obj);
2406 }
2407
2408 static void
2409 _pan_get(Evas_Object *obj,
2410          Evas_Coord  *x,
2411          Evas_Coord  *y)
2412 {
2413    Pan *sd = evas_object_smart_data_get(obj);
2414
2415    if (x) *x = sd->wd->pan_x;
2416    if (y) *y = sd->wd->pan_y;
2417 }
2418
2419 static void
2420 _pan_max_get(Evas_Object *obj,
2421              Evas_Coord  *x,
2422              Evas_Coord  *y)
2423 {
2424    Pan *sd = evas_object_smart_data_get(obj);
2425    Evas_Coord ow, oh;
2426
2427    evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2428    ow = sd->wd->minw - ow;
2429    if (ow < 0) ow = 0;
2430    oh = sd->wd->minh - oh;
2431    if (oh < 0) oh = 0;
2432    if (x) *x = ow;
2433    if (y) *y = oh;
2434 }
2435
2436 static void
2437 _pan_min_get(Evas_Object *obj __UNUSED__,
2438              Evas_Coord  *x,
2439              Evas_Coord  *y)
2440 {
2441    if (x) *x = 0;
2442    if (y) *y = 0;
2443 }
2444
2445 static void
2446 _pan_child_size_get(Evas_Object *obj,
2447                     Evas_Coord  *w,
2448                     Evas_Coord  *h)
2449 {
2450    Pan *sd = evas_object_smart_data_get(obj);
2451
2452    if (w) *w = sd->wd->minw;
2453    if (h) *h = sd->wd->minh;
2454 }
2455
2456 static void
2457 _pan_add(Evas_Object *obj)
2458 {
2459    Pan *sd;
2460    Evas_Object_Smart_Clipped_Data *cd;
2461
2462    _pan_sc.add(obj);
2463    cd = evas_object_smart_data_get(obj);
2464    sd = ELM_NEW(Pan);
2465    if (!sd) return;
2466    sd->__clipped_data = *cd;
2467    free(cd);
2468    evas_object_smart_data_set(obj, sd);
2469 }
2470
2471 static void
2472 _pan_del(Evas_Object *obj)
2473 {
2474    Pan *sd = evas_object_smart_data_get(obj);
2475
2476    if (!sd) return;
2477    if (sd->resize_job)
2478      {
2479         ecore_job_del(sd->resize_job);
2480         sd->resize_job = NULL;
2481      }
2482    _pan_sc.del(obj);
2483 }
2484
2485 static void
2486 _pan_resize_job(void *data)
2487 {
2488    Pan *sd = data;
2489    _sizing_eval(sd->wd->obj);
2490    sd->resize_job = NULL;
2491 }
2492
2493 static void
2494 _pan_resize(Evas_Object *obj,
2495             Evas_Coord   w,
2496             Evas_Coord   h)
2497 {
2498    Pan *sd = evas_object_smart_data_get(obj);
2499    Evas_Coord ow, oh;
2500
2501    evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2502    if ((ow == w) && (oh == h)) return;
2503    if ((sd->wd->height_for_width) && (ow != w))
2504      {
2505         if (sd->resize_job) ecore_job_del(sd->resize_job);
2506         sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2507      }
2508    if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2509    sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2510 }
2511
2512 static void
2513 _pan_calculate(Evas_Object *obj)
2514 {
2515    Pan *sd = evas_object_smart_data_get(obj);
2516    Item_Block *itb;
2517    Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2518    int in = 0;
2519    Elm_Genlist_Item *git;
2520    Eina_List *l;
2521
2522    evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2523    evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2524    EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2525      {
2526         git->want_realize = EINA_FALSE;
2527      }
2528    EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2529      {
2530         itb->w = sd->wd->minw;
2531         if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2532                                 itb->y - sd->wd->pan_y + oy,
2533                                 itb->w, itb->h,
2534                                 cvx, cvy, cvw, cvh))
2535           {
2536              if ((!itb->realized) || (itb->changed))
2537                _item_block_realize(itb, in, 0);
2538              _item_block_position(itb, in);
2539           }
2540         else
2541           {
2542              if (itb->realized) _item_block_unrealize(itb);
2543           }
2544         in += itb->count;
2545      }
2546    _group_items_recalc(sd->wd);
2547 }
2548
2549 static void
2550 _pan_move(Evas_Object *obj,
2551           Evas_Coord   x __UNUSED__,
2552           Evas_Coord   y __UNUSED__)
2553 {
2554    Pan *sd = evas_object_smart_data_get(obj);
2555
2556    if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2557    sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2558 }
2559
2560 static void
2561 _hold_on(void        *data __UNUSED__,
2562          Evas_Object *obj,
2563          void        *event_info __UNUSED__)
2564 {
2565    Widget_Data *wd = elm_widget_data_get(obj);
2566    if (!wd) return;
2567    elm_smart_scroller_hold_set(wd->scr, 1);
2568 }
2569
2570 static void
2571 _hold_off(void        *data __UNUSED__,
2572           Evas_Object *obj,
2573           void        *event_info __UNUSED__)
2574 {
2575    Widget_Data *wd = elm_widget_data_get(obj);
2576    if (!wd) return;
2577    elm_smart_scroller_hold_set(wd->scr, 0);
2578 }
2579
2580 static void
2581 _freeze_on(void        *data __UNUSED__,
2582            Evas_Object *obj,
2583            void        *event_info __UNUSED__)
2584 {
2585    Widget_Data *wd = elm_widget_data_get(obj);
2586    if (!wd) return;
2587    elm_smart_scroller_freeze_set(wd->scr, 1);
2588 }
2589
2590 static void
2591 _freeze_off(void        *data __UNUSED__,
2592             Evas_Object *obj,
2593             void        *event_info __UNUSED__)
2594 {
2595    Widget_Data *wd = elm_widget_data_get(obj);
2596    if (!wd) return;
2597    elm_smart_scroller_freeze_set(wd->scr, 0);
2598 }
2599
2600 static void
2601 _scroll_edge_left(void        *data,
2602                   Evas_Object *scr __UNUSED__,
2603                   void        *event_info __UNUSED__)
2604 {
2605    Evas_Object *obj = data;
2606    evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2607 }
2608
2609 static void
2610 _scroll_edge_right(void        *data,
2611                    Evas_Object *scr __UNUSED__,
2612                    void        *event_info __UNUSED__)
2613 {
2614    Evas_Object *obj = data;
2615    evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2616 }
2617
2618 static void
2619 _scroll_edge_top(void        *data,
2620                  Evas_Object *scr __UNUSED__,
2621                  void        *event_info __UNUSED__)
2622 {
2623    Evas_Object *obj = data;
2624    evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2625 }
2626
2627 static void
2628 _scroll_edge_bottom(void        *data,
2629                     Evas_Object *scr __UNUSED__,
2630                     void        *event_info __UNUSED__)
2631 {
2632    Evas_Object *obj = data;
2633    evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2634 }
2635
2636 static void
2637 _mode_item_realize(Elm_Genlist_Item *it)
2638 {
2639    char buf[1024];
2640
2641    if ((it->mode_view) || (it->delete_me)) return;
2642
2643    it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
2644    edje_object_scale_set(it->mode_view,
2645                          elm_widget_scale_get(it->base.widget) *
2646                          _elm_config->scale);
2647    evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
2648    elm_widget_sub_object_add(it->base.widget, it->mode_view);
2649
2650    strncpy(buf, "item", sizeof(buf));
2651    if (it->wd->compress)
2652      strncat(buf, "_compress", sizeof(buf) - strlen(buf));
2653
2654    if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
2655    strncat(buf, "/", sizeof(buf) - strlen(buf));
2656    strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
2657
2658    _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
2659                          elm_widget_style_get(it->base.widget));
2660    edje_object_mirrored_set(it->mode_view,
2661                             elm_widget_mirrored_get(it->base.widget));
2662
2663    /* signal callback add */
2664    evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
2665                                   _mouse_down, it);
2666    evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
2667                                   _mouse_up, it);
2668    evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
2669                                   _mouse_move, it);
2670
2671    /* label_get, icon_get, state_get */
2672    if (it->itc->func.label_get)
2673      {
2674         const Eina_List *l;
2675         const char *key;
2676
2677         it->mode_labels =
2678            elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
2679                                                           "labels"));
2680         EINA_LIST_FOREACH(it->mode_labels, l, key)
2681           {
2682              char *s = it->itc->func.label_get
2683                 ((void *)it->base.data, it->base.widget, l->data);
2684
2685              if (s)
2686                {
2687                   edje_object_part_text_set(it->mode_view, l->data, s);
2688                   free(s);
2689                }
2690           }
2691      }
2692    if (it->itc->func.icon_get)
2693      {
2694         const Eina_List *l;
2695         const char *key;
2696
2697         it->mode_icons =
2698            elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
2699                                                           "icons"));
2700         EINA_LIST_FOREACH(it->mode_icons, l, key)
2701           {
2702              Evas_Object *ic = it->itc->func.icon_get
2703                 ((void *)it->base.data, it->base.widget, l->data);
2704
2705              if (ic)
2706                {
2707                   it->mode_icon_objs = eina_list_append(it->mode_icon_objs, ic);
2708                   edje_object_part_swallow(it->mode_view, key, ic);
2709                   evas_object_show(ic);
2710                   elm_widget_sub_object_add(it->base.widget, ic);
2711                }
2712           }
2713      }
2714    if (it->itc->func.state_get)
2715      {
2716         const Eina_List *l;
2717         const char *key;
2718
2719         it->mode_states =
2720            elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
2721                                                           "states"));
2722         EINA_LIST_FOREACH(it->mode_states, l, key)
2723           {
2724              Eina_Bool on = it->itc->func.state_get
2725                 ((void *)it->base.data, it->base.widget, l->data);
2726
2727              if (on)
2728                {
2729                   snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
2730                   edje_object_signal_emit(it->mode_view, buf, "elm");
2731                }
2732           }
2733      }
2734
2735    edje_object_part_swallow(it->mode_view,
2736                             edje_object_data_get(it->mode_view, "mode_part"),
2737                             it->base.view);
2738
2739    it->want_unrealize = EINA_FALSE;
2740 }
2741
2742 static void
2743 _mode_item_unrealize(Elm_Genlist_Item *it)
2744 {
2745    Widget_Data *wd = it->wd;
2746    Evas_Object *icon;
2747    if (!it->mode_view) return;
2748
2749    elm_widget_stringlist_free(it->mode_labels);
2750    it->mode_labels = NULL;
2751    elm_widget_stringlist_free(it->mode_icons);
2752    it->mode_icons = NULL;
2753    elm_widget_stringlist_free(it->mode_states);
2754
2755    EINA_LIST_FREE(it->mode_icon_objs, icon)
2756      evas_object_del(icon);
2757
2758    edje_object_part_unswallow(it->mode_view, it->base.view);
2759    evas_object_smart_member_add(it->base.view, wd->pan_smart);
2760    evas_object_del(it->mode_view);
2761    it->mode_view = NULL;
2762
2763    if (wd->mode_item == it)
2764      wd->mode_item = NULL;
2765 }
2766
2767 static void
2768 _item_mode_set(Elm_Genlist_Item *it)
2769 {
2770    if (!it) return;
2771    Widget_Data *wd = it->wd;
2772    if (!wd) return;
2773    char buf[1024];
2774
2775    wd->mode_item = it;
2776    it->nocache = EINA_TRUE;
2777
2778    if (wd->scr_hold_timer)
2779      {
2780         ecore_timer_del(wd->scr_hold_timer);
2781         wd->scr_hold_timer = NULL;
2782      }
2783    elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
2784    wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
2785
2786    _mode_item_realize(it);
2787    _item_position(it, it->mode_view);
2788
2789    snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
2790    edje_object_signal_emit(it->mode_view, buf, "elm");
2791 }
2792
2793 static void
2794 _item_mode_unset(Widget_Data *wd)
2795 {
2796    if (!wd) return;
2797    if (!wd->mode_item) return;
2798    char buf[1024], buf2[1024];
2799    Elm_Genlist_Item *it;
2800
2801    it = wd->mode_item;
2802    it->nocache = EINA_TRUE;
2803
2804    snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
2805    snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
2806
2807    edje_object_signal_emit(it->mode_view, buf, "elm");
2808    edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
2809
2810    wd->mode_item = NULL;
2811 }
2812
2813 /**
2814  * Add a new Genlist object
2815  *
2816  * @param parent The parent object
2817  * @return The new object or NULL if it cannot be created
2818  *
2819  * @ingroup Genlist
2820  */
2821 EAPI Evas_Object *
2822 elm_genlist_add(Evas_Object *parent)
2823 {
2824    Evas_Object *obj;
2825    Evas *e;
2826    Widget_Data *wd;
2827    Evas_Coord minw, minh;
2828    static Evas_Smart *smart = NULL;
2829
2830    if (!smart)
2831      {
2832         static Evas_Smart_Class sc;
2833
2834         evas_object_smart_clipped_smart_set(&_pan_sc);
2835         sc = _pan_sc;
2836         sc.name = "elm_genlist_pan";
2837         sc.version = EVAS_SMART_CLASS_VERSION;
2838         sc.add = _pan_add;
2839         sc.del = _pan_del;
2840         sc.resize = _pan_resize;
2841         sc.move = _pan_move;
2842         sc.calculate = _pan_calculate;
2843         if (!(smart = evas_smart_class_new(&sc))) return NULL;
2844      }
2845
2846    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2847
2848    ELM_SET_WIDTYPE(widtype, "genlist");
2849    elm_widget_type_set(obj, "genlist");
2850    elm_widget_sub_object_add(parent, obj);
2851    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2852    elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
2853    elm_widget_data_set(obj, wd);
2854    elm_widget_del_hook_set(obj, _del_hook);
2855    elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2856    elm_widget_theme_hook_set(obj, _theme_hook);
2857    elm_widget_can_focus_set(obj, EINA_TRUE);
2858    elm_widget_event_hook_set(obj, _event_hook);
2859    elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
2860
2861    wd->scr = elm_smart_scroller_add(e);
2862    elm_smart_scroller_widget_set(wd->scr, obj);
2863    elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2864                                        elm_widget_style_get(obj));
2865    elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2866                                        _elm_config->thumbscroll_bounce_enable);
2867    elm_widget_resize_object_set(obj, wd->scr);
2868
2869    evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2870    evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2871                                   obj);
2872    evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2873    evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2874                                   obj);
2875
2876    wd->obj = obj;
2877    wd->mode = ELM_LIST_SCROLL;
2878    wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2879    wd->item_cache_max = wd->max_items_per_block * 2;
2880    wd->longpress_timeout = _elm_config->longpress_timeout;
2881
2882    evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2883    evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2884    evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2885    evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2886
2887    wd->pan_smart = evas_object_smart_add(e, smart);
2888    wd->pan = evas_object_smart_data_get(wd->pan_smart);
2889    wd->pan->wd = wd;
2890
2891    elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2892                                      _pan_set, _pan_get, _pan_max_get,
2893                                      _pan_min_get, _pan_child_size_get);
2894
2895    edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2896                              &minw, &minh);
2897    evas_object_size_hint_min_set(obj, minw, minh);
2898
2899    _mirrored_set(obj, elm_widget_mirrored_get(obj));
2900    _sizing_eval(obj);
2901    return obj;
2902 }
2903
2904 static Elm_Genlist_Item *
2905 _item_new(Widget_Data                  *wd,
2906           const Elm_Genlist_Item_Class *itc,
2907           const void                   *data,
2908           Elm_Genlist_Item             *parent,
2909           Elm_Genlist_Item_Flags        flags,
2910           Evas_Smart_Cb                 func,
2911           const void                   *func_data)
2912 {
2913    Elm_Genlist_Item *it;
2914
2915    it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
2916    if (!it) return NULL;
2917    it->wd = wd;
2918    it->itc = itc;
2919    it->base.data = data;
2920    it->parent = parent;
2921    it->flags = flags;
2922    it->func.func = func;
2923    it->func.data = func_data;
2924    it->mouse_cursor = NULL;
2925    it->expanded_depth = 0;
2926    return it;
2927 }
2928
2929 static void
2930 _item_block_add(Widget_Data      *wd,
2931                 Elm_Genlist_Item *it)
2932 {
2933    Item_Block *itb = NULL;
2934
2935    if (!it->rel)
2936      {
2937 newblock:
2938         if (it->rel)
2939           {
2940              itb = calloc(1, sizeof(Item_Block));
2941              if (!itb) return;
2942              itb->wd = wd;
2943              if (!it->rel->block)
2944                {
2945                   wd->blocks =
2946                     eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
2947                   itb->items = eina_list_append(itb->items, it);
2948                }
2949              else
2950                {
2951                   if (it->before)
2952                     {
2953                        wd->blocks = eina_inlist_prepend_relative
2954                            (wd->blocks, EINA_INLIST_GET(itb),
2955                            EINA_INLIST_GET(it->rel->block));
2956                        itb->items =
2957                          eina_list_prepend_relative(itb->items, it, it->rel);
2958                     }
2959                   else
2960                     {
2961                        wd->blocks = eina_inlist_append_relative
2962                            (wd->blocks, EINA_INLIST_GET(itb),
2963                            EINA_INLIST_GET(it->rel->block));
2964                        itb->items =
2965                          eina_list_append_relative(itb->items, it, it->rel);
2966                     }
2967                }
2968           }
2969         else
2970           {
2971              if (it->before)
2972                {
2973                   if (wd->blocks)
2974                     {
2975                        itb = (Item_Block *)(wd->blocks);
2976                        if (itb->count >= wd->max_items_per_block)
2977                          {
2978                             itb = calloc(1, sizeof(Item_Block));
2979                             if (!itb) return;
2980                             itb->wd = wd;
2981                             wd->blocks =
2982                               eina_inlist_prepend(wd->blocks,
2983                                                   EINA_INLIST_GET(itb));
2984                          }
2985                     }
2986                   else
2987                     {
2988                        itb = calloc(1, sizeof(Item_Block));
2989                        if (!itb) return;
2990                        itb->wd = wd;
2991                        wd->blocks =
2992                          eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
2993                     }
2994                   itb->items = eina_list_prepend(itb->items, it);
2995                }
2996              else
2997                {
2998                   if (wd->blocks)
2999                     {
3000                        itb = (Item_Block *)(wd->blocks->last);
3001                        if (itb->count >= wd->max_items_per_block)
3002                          {
3003                             itb = calloc(1, sizeof(Item_Block));
3004                             if (!itb) return;
3005                             itb->wd = wd;
3006                             wd->blocks =
3007                               eina_inlist_append(wd->blocks,
3008                                                  EINA_INLIST_GET(itb));
3009                          }
3010                     }
3011                   else
3012                     {
3013                        itb = calloc(1, sizeof(Item_Block));
3014                        if (!itb) return;
3015                        itb->wd = wd;
3016                        wd->blocks =
3017                          eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3018                     }
3019                   itb->items = eina_list_append(itb->items, it);
3020                }
3021           }
3022      }
3023    else
3024      {
3025         itb = it->rel->block;
3026         if (!itb) goto newblock;
3027         if (it->before)
3028           itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3029         else
3030           itb->items = eina_list_append_relative(itb->items, it, it->rel);
3031      }
3032    itb->count++;
3033    itb->changed = EINA_TRUE;
3034    it->block = itb;
3035    if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3036    itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3037    if (it->rel)
3038      {
3039         it->rel->relcount--;
3040         if ((it->rel->delete_me) && (!it->rel->relcount))
3041           _item_del(it->rel);
3042         it->rel = NULL;
3043      }
3044    if (itb->count > itb->wd->max_items_per_block)
3045      {
3046         int newc;
3047         Item_Block *itb2;
3048         Elm_Genlist_Item *it2;
3049
3050         newc = itb->count / 2;
3051         itb2 = calloc(1, sizeof(Item_Block));
3052         if (!itb2) return;
3053         itb2->wd = wd;
3054         wd->blocks =
3055           eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3056                                       EINA_INLIST_GET(itb));
3057         itb2->changed = EINA_TRUE;
3058         while ((itb->count > newc) && (itb->items))
3059           {
3060              Eina_List *l;
3061
3062              l = eina_list_last(itb->items);
3063              it2 = l->data;
3064              itb->items = eina_list_remove_list(itb->items, l);
3065              itb->count--;
3066
3067              itb2->items = eina_list_prepend(itb2->items, it2);
3068              it2->block = itb2;
3069              itb2->count++;
3070           }
3071      }
3072 }
3073
3074 static int
3075 _queue_process(Widget_Data *wd,
3076                int          norender)
3077 {
3078    int n;
3079    Eina_Bool showme = EINA_FALSE;
3080    double t0, t;
3081
3082    t0 = ecore_time_get();
3083    for (n = 0; (wd->queue) && (n < 128); n++)
3084      {
3085         Elm_Genlist_Item *it;
3086
3087         it = wd->queue->data;
3088         wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3089         it->queued = EINA_FALSE;
3090         _item_block_add(wd, it);
3091         t = ecore_time_get();
3092         if (it->block->changed)
3093           {
3094              showme = _item_block_recalc(it->block, it->block->num, 1,
3095                                          norender);
3096              it->block->changed = 0;
3097           }
3098         if (showme) it->block->showme = EINA_TRUE;
3099         if (eina_inlist_count(wd->blocks) > 1)
3100           {
3101              if ((t - t0) > (ecore_animator_frametime_get())) break;
3102           }
3103      }
3104    return n;
3105 }
3106
3107 static Eina_Bool
3108 _item_idler(void *data)
3109 {
3110    Widget_Data *wd = data;
3111
3112    //xxx
3113    //static double q_start = 0.0;
3114    //if (q_start == 0.0) q_start = ecore_time_get();
3115    //xxx
3116
3117    if (_queue_process(wd, 1) > 0)
3118      {
3119         if (wd->calc_job) ecore_job_del(wd->calc_job);
3120         wd->calc_job = ecore_job_add(_calc_job, wd);
3121      }
3122    if (!wd->queue)
3123      {
3124         //xxx
3125         //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3126         //xxx
3127         wd->queue_idler = NULL;
3128         return ECORE_CALLBACK_CANCEL;
3129      }
3130    return ECORE_CALLBACK_RENEW;
3131 }
3132
3133 static void
3134 _item_queue(Widget_Data      *wd,
3135             Elm_Genlist_Item *it)
3136 {
3137    if (it->queued) return;
3138    it->queued = EINA_TRUE;
3139    wd->queue = eina_list_append(wd->queue, it);
3140    while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3141      {
3142         if (wd->queue_idler)
3143           {
3144              ecore_idler_del(wd->queue_idler);
3145              wd->queue_idler = NULL;
3146           }
3147         _queue_process(wd, 0);
3148      }
3149    if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
3150 }
3151
3152 /**
3153  * Append item to the end of the genlist
3154  *
3155  * This appends the given item to the end of the list or the end of
3156  * the children if the parent is given.
3157  *
3158  * @param obj The genlist object
3159  * @param itc The item class for the item
3160  * @param data The item data
3161  * @param parent The parent item, or NULL if none
3162  * @param flags Item flags
3163  * @param func Convenience function called when item selected
3164  * @param func_data Data passed to @p func above.
3165  * @return A handle to the item added or NULL if not possible
3166  *
3167  * @ingroup Genlist
3168  */
3169 EAPI Elm_Genlist_Item *
3170 elm_genlist_item_append(Evas_Object                  *obj,
3171                         const Elm_Genlist_Item_Class *itc,
3172                         const void                   *data,
3173                         Elm_Genlist_Item             *parent,
3174                         Elm_Genlist_Item_Flags        flags,
3175                         Evas_Smart_Cb                 func,
3176                         const void                   *func_data)
3177 {
3178    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3179    Widget_Data *wd = elm_widget_data_get(obj);
3180    if (!wd) return NULL;
3181    Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3182                                     func_data);
3183    if (!it) return NULL;
3184    if (!it->parent)
3185      {
3186         if (flags & ELM_GENLIST_ITEM_GROUP)
3187           wd->group_items = eina_list_append(wd->group_items, it);
3188         wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3189         it->rel = NULL;
3190      }
3191    else
3192      {
3193         Elm_Genlist_Item *it2 = NULL;
3194         Eina_List *ll = eina_list_last(it->parent->items);
3195         if (ll) it2 = ll->data;
3196         it->parent->items = eina_list_append(it->parent->items, it);
3197         if (!it2) it2 = it->parent;
3198         wd->items =
3199           eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3200                                       EINA_INLIST_GET(it2));
3201         it->rel = it2;
3202         it->rel->relcount++;
3203
3204         if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3205           it->group_item = parent;
3206         else if (it->parent->group_item)
3207           it->group_item = it->parent->group_item;
3208      }
3209    it->before = EINA_FALSE;
3210    _item_queue(wd, it);
3211    return it;
3212 }
3213
3214 /**
3215  * Prepend item at start of the genlist
3216  *
3217  * This adds an item to the beginning of the list or beginning of the
3218  * children of the parent if given.
3219  *
3220  * @param obj The genlist object
3221  * @param itc The item class for the item
3222  * @param data The item data
3223  * @param parent The parent item, or NULL if none
3224  * @param flags Item flags
3225  * @param func Convenience function called when item selected
3226  * @param func_data Data passed to @p func above.
3227  * @return A handle to the item added or NULL if not possible
3228  *
3229  * @ingroup Genlist
3230  */
3231 EAPI Elm_Genlist_Item *
3232 elm_genlist_item_prepend(Evas_Object                  *obj,
3233                          const Elm_Genlist_Item_Class *itc,
3234                          const void                   *data,
3235                          Elm_Genlist_Item             *parent,
3236                          Elm_Genlist_Item_Flags        flags,
3237                          Evas_Smart_Cb                 func,
3238                          const void                   *func_data)
3239 {
3240    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3241    Widget_Data *wd = elm_widget_data_get(obj);
3242    if (!wd) return NULL;
3243    Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3244                                     func_data);
3245    if (!it) return NULL;
3246    if (!it->parent)
3247      {
3248         if (flags & ELM_GENLIST_ITEM_GROUP)
3249           wd->group_items = eina_list_prepend(wd->group_items, it);
3250         wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3251         it->rel = NULL;
3252      }
3253    else
3254      {
3255         Elm_Genlist_Item *it2 = NULL;
3256         Eina_List *ll = it->parent->items;
3257         if (ll) it2 = ll->data;
3258         it->parent->items = eina_list_prepend(it->parent->items, it);
3259         if (!it2) it2 = it->parent;
3260         wd->items =
3261           eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3262                                        EINA_INLIST_GET(it2));
3263         it->rel = it2;
3264         it->rel->relcount++;
3265      }
3266    it->before = EINA_TRUE;
3267    _item_queue(wd, it);
3268    return it;
3269 }
3270
3271 /**
3272  * Insert item before another in the genlist
3273  *
3274  * This inserts an item before another in the list. It will be in the
3275  * same tree level or group as the item it is inseted before.
3276  *
3277  * @param obj The genlist object
3278  * @param itc The item class for the item
3279  * @param data The item data
3280  * @param before The item to insert before
3281  * @param flags Item flags
3282  * @param func Convenience function called when item selected
3283  * @param func_data Data passed to @p func above.
3284  * @return A handle to the item added or NULL if not possible
3285  *
3286  * @ingroup Genlist
3287  */
3288 EAPI Elm_Genlist_Item *
3289 elm_genlist_item_insert_before(Evas_Object                  *obj,
3290                                const Elm_Genlist_Item_Class *itc,
3291                                const void                   *data,
3292                                Elm_Genlist_Item             *parent,
3293                                Elm_Genlist_Item             *before,
3294                                Elm_Genlist_Item_Flags        flags,
3295                                Evas_Smart_Cb                 func,
3296                                const void                   *func_data)
3297 {
3298    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3299    EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3300    Widget_Data *wd = elm_widget_data_get(obj);
3301    if (!wd) return NULL;
3302    Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3303                                     func_data);
3304    if (!it) return NULL;
3305    if (it->parent)
3306      {
3307         it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3308                                                        before);
3309      }
3310    wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3311                                             EINA_INLIST_GET(before));
3312    it->rel = before;
3313    it->rel->relcount++;
3314    it->before = EINA_TRUE;
3315    _item_queue(wd, it);
3316    return it;
3317 }
3318
3319 /**
3320  * Insert an item after another in the genlst
3321  *
3322  * This inserts an item after another in the list. It will be in the
3323  * same tree level or group as the item it is inseted after.
3324  *
3325  * @param obj The genlist object
3326  * @param itc The item class for the item
3327  * @param data The item data
3328  * @param after The item to insert after
3329  * @param flags Item flags
3330  * @param func Convenience function called when item selected
3331  * @param func_data Data passed to @p func above.
3332  * @return A handle to the item added or NULL if not possible
3333  *
3334  * @ingroup Genlist
3335  */
3336 EAPI Elm_Genlist_Item *
3337 elm_genlist_item_insert_after(Evas_Object                  *obj,
3338                               const Elm_Genlist_Item_Class *itc,
3339                               const void                   *data,
3340                               Elm_Genlist_Item             *parent,
3341                               Elm_Genlist_Item             *after,
3342                               Elm_Genlist_Item_Flags        flags,
3343                               Evas_Smart_Cb                 func,
3344                               const void                   *func_data)
3345 {
3346    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3347    EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3348    Widget_Data *wd = elm_widget_data_get(obj);
3349    if (!wd) return NULL;
3350    Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3351                                     func_data);
3352    if (!it) return NULL;
3353    wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3354                                            EINA_INLIST_GET(after));
3355    if (it->parent)
3356      {
3357         it->parent->items = eina_list_append_relative(it->parent->items, it,
3358                                                       after);
3359      }
3360    it->rel = after;
3361    it->rel->relcount++;
3362    it->before = EINA_FALSE;
3363    _item_queue(wd, it);
3364    return it;
3365 }
3366
3367 /**
3368  * Clear the genlist
3369  *
3370  * This clears all items in the list, leaving it empty.
3371  *
3372  * @param obj The genlist object
3373  *
3374  * @ingroup Genlist
3375  */
3376 EAPI void
3377 elm_genlist_clear(Evas_Object *obj)
3378 {
3379    ELM_CHECK_WIDTYPE(obj, widtype);
3380    Widget_Data *wd = elm_widget_data_get(obj);
3381    if (!wd) return;
3382    if (wd->walking > 0)
3383      {
3384         Elm_Genlist_Item *it;
3385
3386         wd->clear_me = EINA_TRUE;
3387         EINA_INLIST_FOREACH(wd->items, it)
3388           {
3389              it->delete_me = EINA_TRUE;
3390           }
3391         return;
3392      }
3393    while (wd->items)
3394      {
3395         Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3396
3397         if (wd->anchor_item == it)
3398           {
3399              wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3400              if (!wd->anchor_item)
3401                wd->anchor_item =
3402                  ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3403           }
3404         wd->items = eina_inlist_remove(wd->items, wd->items);
3405         if (it->flags & ELM_GENLIST_ITEM_GROUP)
3406           it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3407         elm_widget_item_pre_notify_del(it);
3408         if (it->realized) _item_unrealize(it, EINA_FALSE);
3409         if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3410           it->itc->func.del((void *)it->base.data, it->base.widget);
3411         if (it->long_timer) ecore_timer_del(it->long_timer);
3412         if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3413         elm_widget_item_del(it);
3414      }
3415    wd->clear_me = EINA_FALSE;
3416    wd->anchor_item = NULL;
3417    while (wd->blocks)
3418      {
3419         Item_Block *itb = (Item_Block *)(wd->blocks);
3420
3421         wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3422         if (itb->items) eina_list_free(itb->items);
3423         free(itb);
3424      }
3425    if (wd->calc_job)
3426      {
3427         ecore_job_del(wd->calc_job);
3428         wd->calc_job = NULL;
3429      }
3430    if (wd->queue_idler)
3431      {
3432         ecore_idler_del(wd->queue_idler);
3433         wd->queue_idler = NULL;
3434      }
3435    if (wd->must_recalc_idler)
3436      {
3437         ecore_idler_del(wd->must_recalc_idler);
3438         wd->must_recalc_idler = NULL;
3439      }
3440    if (wd->queue)
3441      {
3442         eina_list_free(wd->queue);
3443         wd->queue = NULL;
3444      }
3445    if (wd->selected)
3446      {
3447         eina_list_free(wd->selected);
3448         wd->selected = NULL;
3449      }
3450    wd->show_item = NULL;
3451    wd->pan_x = 0;
3452    wd->pan_y = 0;
3453    wd->minw = 0;
3454    wd->minh = 0;
3455    if (wd->pan_smart)
3456      {
3457         evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3458         evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3459      }
3460    _sizing_eval(obj);
3461 }
3462
3463 /**
3464  * Enable or disable multi-select in the genlist
3465  *
3466  * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3467  * the list. This allows more than 1 item to be selected.
3468  *
3469  * @param obj The genlist object
3470  * @param multi Multi-select enable/disable
3471  *
3472  * @ingroup Genlist
3473  */
3474 EAPI void
3475 elm_genlist_multi_select_set(Evas_Object *obj,
3476                              Eina_Bool    multi)
3477 {
3478    ELM_CHECK_WIDTYPE(obj, widtype);
3479    Widget_Data *wd = elm_widget_data_get(obj);
3480    if (!wd) return;
3481    wd->multi = multi;
3482 }
3483
3484 /**
3485  * Gets if multi-select in genlist is enable or disable
3486  *
3487  * @param obj The genlist object
3488  * @return Multi-select enable/disable
3489  * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3490  *
3491  * @ingroup Genlist
3492  */
3493 EAPI Eina_Bool
3494 elm_genlist_multi_select_get(const Evas_Object *obj)
3495 {
3496    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3497    Widget_Data *wd = elm_widget_data_get(obj);
3498    if (!wd) return EINA_FALSE;
3499    return wd->multi;
3500 }
3501
3502 /**
3503  * Get the selectd item in the genlist
3504  *
3505  * This gets the selected item in the list (if multi-select is enabled
3506  * only the first item in the list is selected - which is not very
3507  * useful, so see elm_genlist_selected_items_get() for when
3508  * multi-select is used).
3509  *
3510  * If no item is selected, NULL is returned.
3511  *
3512  * @param obj The genlist object
3513  * @return The selected item, or NULL if none.
3514  *
3515  * @ingroup Genlist
3516  */
3517 EAPI Elm_Genlist_Item *
3518 elm_genlist_selected_item_get(const Evas_Object *obj)
3519 {
3520    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3521    Widget_Data *wd = elm_widget_data_get(obj);
3522    if (!wd) return NULL;
3523    if (wd->selected) return wd->selected->data;
3524    return NULL;
3525 }
3526
3527 /**
3528  * Get a list of selected items in the genlist
3529  *
3530  * This returns a list of the selected items. This list pointer is
3531  * only valid so long as no items are selected or unselected (or
3532  * unselected implicitly by deletion). The list contains
3533  * Elm_Genlist_Item pointers.
3534  *
3535  * @param obj The genlist object
3536  * @return The list of selected items, nor NULL if none are selected.
3537  *
3538  * @ingroup Genlist
3539  */
3540 EAPI const Eina_List *
3541 elm_genlist_selected_items_get(const Evas_Object *obj)
3542 {
3543    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3544    Widget_Data *wd = elm_widget_data_get(obj);
3545    if (!wd) return NULL;
3546    return wd->selected;
3547 }
3548
3549 /**
3550  * Get a list of realized items in genlist
3551  *
3552  * This returns a list of the realized items in the genlist. The list
3553  * contains Elm_Genlist_Item pointers. The list must be freed by the
3554  * caller when done with eina_list_free(). The item pointers in the
3555  * list are only valid so long as those items are not deleted or the
3556  * genlist is not deleted.
3557  *
3558  * @param obj The genlist object
3559  * @return The list of realized items, nor NULL if none are realized.
3560  *
3561  * @ingroup Genlist
3562  */
3563 EAPI Eina_List *
3564 elm_genlist_realized_items_get(const Evas_Object *obj)
3565 {
3566    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3567    Widget_Data *wd = elm_widget_data_get(obj);
3568    Eina_List *list = NULL;
3569    Item_Block *itb;
3570    Eina_Bool done = EINA_FALSE;
3571    if (!wd) return NULL;
3572    EINA_INLIST_FOREACH(wd->blocks, itb)
3573      {
3574         if (itb->realized)
3575           {
3576              Eina_List *l;
3577              Elm_Genlist_Item *it;
3578
3579              done = 1;
3580              EINA_LIST_FOREACH(itb->items, l, it)
3581                {
3582                   if (it->realized) list = eina_list_append(list, it);
3583                }
3584           }
3585         else
3586           {
3587              if (done) break;
3588           }
3589      }
3590    return list;
3591 }
3592
3593 /**
3594  * Get the item that is at the x, y canvas coords
3595  *
3596  * This returns the item at the given coordinates (which are canvas
3597  * relative not object-relative). If an item is at that coordinate,
3598  * that item handle is returned, and if @p posret is not NULL, the
3599  * integer pointed to is set to a value of -1, 0 or 1, depending if
3600  * the coordinate is on the upper portion of that item (-1), on the
3601  * middle section (0) or on the lower part (1). If NULL is returned as
3602  * an item (no item found there), then posret may indicate -1 or 1
3603  * based if the coordinate is above or below all items respectively in
3604  * the genlist.
3605  *
3606  * @param it The item
3607  * @param x The input x coordinate
3608  * @param y The input y coordinate
3609  * @param posret The position relative to the item returned here
3610  * @return The item at the coordinates or NULL if none
3611  *
3612  * @ingroup Genlist
3613  */
3614 EAPI Elm_Genlist_Item *
3615 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3616                            Evas_Coord         x,
3617                            Evas_Coord         y,
3618                            int               *posret)
3619 {
3620    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3621    Widget_Data *wd = elm_widget_data_get(obj);
3622    Evas_Coord ox, oy, ow, oh;
3623    Item_Block *itb;
3624    Evas_Coord lasty;
3625    if (!wd) return NULL;
3626    evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3627    lasty = oy;
3628    EINA_INLIST_FOREACH(wd->blocks, itb)
3629      {
3630         Eina_List *l;
3631         Elm_Genlist_Item *it;
3632
3633         if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3634                                  oy + itb->y - itb->wd->pan_y,
3635                                  itb->w, itb->h, x, y, 1, 1))
3636           continue;
3637         EINA_LIST_FOREACH(itb->items, l, it)
3638           {
3639              Evas_Coord itx, ity;
3640
3641              itx = ox + itb->x + it->x - itb->wd->pan_x;
3642              ity = oy + itb->y + it->y - itb->wd->pan_y;
3643              if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3644                {
3645                   if (posret)
3646                     {
3647                        if (y <= (ity + (it->h / 4))) *posret = -1;
3648                        else if (y >= (ity + it->h - (it->h / 4)))
3649                          *posret = 1;
3650                        else *posret = 0;
3651                     }
3652                   return it;
3653                }
3654              lasty = ity + it->h;
3655           }
3656      }
3657    if (posret)
3658      {
3659         if (y > lasty) *posret = 1;
3660         else *posret = -1;
3661      }
3662    return NULL;
3663 }
3664
3665 /**
3666  * Get the first item in the genlist
3667  *
3668  * This returns the first item in the list.
3669  *
3670  * @param obj The genlist object
3671  * @return The first item, or NULL if none
3672  *
3673  * @ingroup Genlist
3674  */
3675 EAPI Elm_Genlist_Item *
3676 elm_genlist_first_item_get(const Evas_Object *obj)
3677 {
3678    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3679    Widget_Data *wd = elm_widget_data_get(obj);
3680    if (!wd) return NULL;
3681    if (!wd->items) return NULL;
3682    Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3683    while ((it) && (it->delete_me))
3684      it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3685    return it;
3686 }
3687
3688 /**
3689  * Get the last item in the genlist
3690  *
3691  * This returns the last item in the list.
3692  *
3693  * @return The last item, or NULL if none
3694  *
3695  * @ingroup Genlist
3696  */
3697 EAPI Elm_Genlist_Item *
3698 elm_genlist_last_item_get(const Evas_Object *obj)
3699 {
3700    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3701    Widget_Data *wd = elm_widget_data_get(obj);
3702    if (!wd) return NULL;
3703    if (!wd->items) return NULL;
3704    Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3705    while ((it) && (it->delete_me))
3706      it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3707    return it;
3708 }
3709
3710 /**
3711  * Get the next item in the genlist
3712  *
3713  * This returns the item after the item @p it.
3714  *
3715  * @param it The item
3716  * @return The item after @p it, or NULL if none
3717  *
3718  * @ingroup Genlist
3719  */
3720 EAPI Elm_Genlist_Item *
3721 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3722 {
3723    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3724    while (it)
3725      {
3726         it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3727         if ((it) && (!it->delete_me)) break;
3728      }
3729    return (Elm_Genlist_Item *)it;
3730 }
3731
3732 /**
3733  * Get the previous item in the genlist
3734  *
3735  * This returns the item before the item @p it.
3736  *
3737  * @param it The item
3738  * @return The item before @p it, or NULL if none
3739  *
3740  * @ingroup Genlist
3741  */
3742 EAPI Elm_Genlist_Item *
3743 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3744 {
3745    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3746    while (it)
3747      {
3748         it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3749         if ((it) && (!it->delete_me)) break;
3750      }
3751    return (Elm_Genlist_Item *)it;
3752 }
3753
3754 /**
3755  * Get the genlist object from an item
3756  *
3757  * This returns the genlist object itself that an item belongs to.
3758  *
3759  * @param it The item
3760  * @return The genlist object
3761  *
3762  * @ingroup Genlist
3763  */
3764 EAPI Evas_Object *
3765 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3766 {
3767    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3768    return it->base.widget;
3769 }
3770
3771 /**
3772  * Get the parent item of the given item
3773  *
3774  * This returns the parent item of the item @p it given.
3775  *
3776  * @param it The item
3777  * @return The parent of the item or NULL if none
3778  *
3779  * @ingroup Genlist
3780  */
3781 EAPI Elm_Genlist_Item *
3782 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3783 {
3784    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3785    return it->parent;
3786 }
3787
3788 /**
3789  * Clear all sub-items (children) of the given item
3790  *
3791  * This clears all items that are children (or their descendants) of the
3792  * given item @p it.
3793  *
3794  * @param it The item
3795  *
3796  * @ingroup Genlist
3797  */
3798 EAPI void
3799 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3800 {
3801    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3802    Eina_List *tl = NULL, *l;
3803    Elm_Genlist_Item *it2;
3804
3805    EINA_LIST_FOREACH(it->items, l, it2)
3806      tl = eina_list_append(tl, it2);
3807    EINA_LIST_FREE(tl, it2)
3808      elm_genlist_item_del(it2);
3809 }
3810
3811 /**
3812  * Set the selected state of an item
3813  *
3814  * This sets the selected state (1 selected, 0 not selected) of the given
3815  * item @p it.
3816  *
3817  * @param it The item
3818  * @param selected The selected state
3819  *
3820  * @ingroup Genlist
3821  */
3822 EAPI void
3823 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
3824                               Eina_Bool         selected)
3825 {
3826    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3827    Widget_Data *wd = elm_widget_data_get(it->base.widget);
3828    if (!wd) return;
3829    if (it->delete_me) return;
3830    selected = !!selected;
3831    if (it->selected == selected) return;
3832
3833    if (selected)
3834      {
3835         if (!wd->multi)
3836           {
3837              while (wd->selected)
3838                _item_unselect(wd->selected->data);
3839           }
3840         _item_highlight(it);
3841         _item_select(it);
3842      }
3843    else
3844      _item_unselect(it);
3845 }
3846
3847 /**
3848  * Get the selected state of an item
3849  *
3850  * This gets the selected state of an item (1 selected, 0 not selected).
3851  *
3852  * @param it The item
3853  * @return The selected state
3854  *
3855  * @ingroup Genlist
3856  */
3857 EAPI Eina_Bool
3858 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
3859 {
3860    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3861    return it->selected;
3862 }
3863
3864 /**
3865  * Sets the expanded state of an item (if it's a parent)
3866  *
3867  * This expands or contracts a parent item (thus showing or hiding the
3868  * children).
3869  *
3870  * @param it The item
3871  * @param expanded The expanded state (1 expanded, 0 not expanded).
3872  *
3873  * @ingroup Genlist
3874  */
3875 EAPI void
3876 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
3877                               Eina_Bool         expanded)
3878 {
3879    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3880    if (it->expanded == expanded) return;
3881    it->expanded = expanded;
3882    if (it->expanded)
3883      {
3884         if (it->realized)
3885           edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
3886         evas_object_smart_callback_call(it->base.widget, "expanded", it);
3887      }
3888    else
3889      {
3890         if (it->realized)
3891           edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
3892         evas_object_smart_callback_call(it->base.widget, "contracted", it);
3893      }
3894 }
3895
3896 /**
3897  * Get the expanded state of an item
3898  *
3899  * This gets the expanded state of an item
3900  *
3901  * @param it The item
3902  * @return Thre expanded state
3903  *
3904  * @ingroup Genlist
3905  */
3906 EAPI Eina_Bool
3907 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
3908 {
3909    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3910    return it->expanded;
3911 }
3912
3913 /**
3914  * Get the depth of expanded item
3915  *
3916  * @param it The genlist item object
3917  * @return The depth of expanded item
3918  *
3919  * @ingroup Genlist
3920  */
3921 EAPI int
3922 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
3923 {
3924    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
3925    return it->expanded_depth;
3926 }
3927
3928 /**
3929  * Sets the disabled state of an item.
3930  *
3931  * A disabled item cannot be selected or unselected. It will also
3932  * change appearance to appear disabled. This sets the disabled state
3933  * (1 disabled, 0 not disabled).
3934  *
3935  * @param it The item
3936  * @param disabled The disabled state
3937  *
3938  * @ingroup Genlist
3939  */
3940 EAPI void
3941 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
3942                               Eina_Bool         disabled)
3943 {
3944    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3945    if (it->disabled == disabled) return;
3946    if (it->delete_me) return;
3947    it->disabled = disabled;
3948    if (it->realized)
3949      {
3950         if (it->disabled)
3951           edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
3952         else
3953           edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
3954      }
3955 }
3956
3957 /**
3958  * Get the disabled state of an item
3959  *
3960  * This gets the disabled state of the given item.
3961  *
3962  * @param it The item
3963  * @return The disabled state
3964  *
3965  * @ingroup Genlist
3966  */
3967 EAPI Eina_Bool
3968 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
3969 {
3970    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
3971    if (it->delete_me) return EINA_FALSE;
3972    return it->disabled;
3973 }
3974
3975 /**
3976  * Sets the display only state of an item.
3977  *
3978  * A display only item cannot be selected or unselected. It is for
3979  * display only and not selecting or otherwise clicking, dragging
3980  * etc. by the user, thus finger size rules will not be applied to
3981  * this item.
3982  *
3983  * @param it The item
3984  * @param display_only The display only state
3985  *
3986  * @ingroup Genlist
3987  */
3988 EAPI void
3989 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
3990                                   Eina_Bool         display_only)
3991 {
3992    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3993    if (it->display_only == display_only) return;
3994    if (it->delete_me) return;
3995    it->display_only = display_only;
3996    it->mincalcd = EINA_FALSE;
3997    it->updateme = EINA_TRUE;
3998    if (it->block) it->block->updateme = EINA_TRUE;
3999    if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4000    it->wd->update_job = ecore_job_add(_update_job, it->wd);
4001 }
4002
4003 /**
4004  * Get the display only state of an item
4005  *
4006  * This gets the display only state of the given item.
4007  *
4008  * @param it The item
4009  * @return The display only state
4010  *
4011  * @ingroup Genlist
4012  */
4013 EAPI Eina_Bool
4014 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4015 {
4016    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4017    if (it->delete_me) return EINA_FALSE;
4018    return it->display_only;
4019 }
4020
4021 /**
4022  * Show the given item
4023  *
4024  * This causes genlist to jump to the given item @p it and show it (by
4025  * scrolling), if it is not fully visible.
4026  *
4027  * @param it The item
4028  *
4029  * @ingroup Genlist
4030  */
4031 EAPI void
4032 elm_genlist_item_show(Elm_Genlist_Item *it)
4033 {
4034    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4035    Evas_Coord gith = 0;
4036    if (it->delete_me) return;
4037    if ((it->queued) || (!it->mincalcd))
4038      {
4039         it->wd->show_item = it;
4040         it->wd->bring_in = EINA_TRUE;
4041         it->showme = EINA_TRUE;
4042         return;
4043      }
4044    if (it->wd->show_item)
4045      {
4046         it->wd->show_item->showme = EINA_FALSE;
4047         it->wd->show_item = NULL;
4048      }
4049    if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4050      gith = it->group_item->h;
4051    elm_smart_scroller_child_region_show(it->wd->scr,
4052                                         it->x + it->block->x,
4053                                         it->y + it->block->y - gith,
4054                                         it->block->w, it->h);
4055 }
4056
4057 /**
4058  * Bring in the given item
4059  *
4060  * This causes genlist to jump to the given item @p it and show it (by
4061  * scrolling), if it is not fully visible. This may use animation to
4062  * do so and take a period of time
4063  *
4064  * @param it The item
4065  *
4066  * @ingroup Genlist
4067  */
4068 EAPI void
4069 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4070 {
4071    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4072    Evas_Coord gith = 0;
4073    if (it->delete_me) return;
4074    if ((it->queued) || (!it->mincalcd))
4075      {
4076         it->wd->show_item = it;
4077         it->wd->bring_in = EINA_TRUE;
4078         it->showme = EINA_TRUE;
4079         return;
4080      }
4081    if (it->wd->show_item)
4082      {
4083         it->wd->show_item->showme = EINA_FALSE;
4084         it->wd->show_item = NULL;
4085      }
4086    if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4087      gith = it->group_item->h;
4088    elm_smart_scroller_region_bring_in(it->wd->scr,
4089                                       it->x + it->block->x,
4090                                       it->y + it->block->y - gith,
4091                                       it->block->w, it->h);
4092 }
4093
4094 /**
4095  * Show the given item at the top
4096  *
4097  * This causes genlist to jump to the given item @p it and show it (by
4098  * scrolling), if it is not fully visible.
4099  *
4100  * @param it The item
4101  *
4102  * @ingroup Genlist
4103  */
4104 EAPI void
4105 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4106 {
4107    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4108    Evas_Coord ow, oh;
4109    Evas_Coord gith = 0;
4110
4111    if (it->delete_me) return;
4112    if ((it->queued) || (!it->mincalcd))
4113      {
4114         it->wd->show_item = it;
4115         it->wd->bring_in = EINA_TRUE;
4116         it->showme = EINA_TRUE;
4117         return;
4118      }
4119    if (it->wd->show_item)
4120      {
4121         it->wd->show_item->showme = EINA_FALSE;
4122         it->wd->show_item = NULL;
4123      }
4124    evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4125    if (it->group_item) gith = it->group_item->h;
4126    elm_smart_scroller_child_region_show(it->wd->scr,
4127                                         it->x + it->block->x,
4128                                         it->y + it->block->y - gith,
4129                                         it->block->w, oh);
4130 }
4131
4132 /**
4133  * Bring in the given item at the top
4134  *
4135  * This causes genlist to jump to the given item @p it and show it (by
4136  * scrolling), if it is not fully visible. This may use animation to
4137  * do so and take a period of time
4138  *
4139  * @param it The item
4140  *
4141  * @ingroup Genlist
4142  */
4143 EAPI void
4144 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4145 {
4146    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4147    Evas_Coord ow, oh;
4148    Evas_Coord gith = 0;
4149
4150    if (it->delete_me) return;
4151    if ((it->queued) || (!it->mincalcd))
4152      {
4153         it->wd->show_item = it;
4154         it->wd->bring_in = EINA_TRUE;
4155         it->showme = EINA_TRUE;
4156         return;
4157      }
4158    if (it->wd->show_item)
4159      {
4160         it->wd->show_item->showme = EINA_FALSE;
4161         it->wd->show_item = NULL;
4162      }
4163    evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4164    if (it->group_item) gith = it->group_item->h;
4165    elm_smart_scroller_region_bring_in(it->wd->scr,
4166                                       it->x + it->block->x,
4167                                       it->y + it->block->y - gith,
4168                                       it->block->w, oh);
4169 }
4170
4171 /**
4172  * Show the given item at the middle
4173  *
4174  * This causes genlist to jump to the given item @p it and show it (by
4175  * scrolling), if it is not fully visible.
4176  *
4177  * @param it The item
4178  *
4179  * @ingroup Genlist
4180  */
4181 EAPI void
4182 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4183 {
4184    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4185    Evas_Coord ow, oh;
4186
4187    if (it->delete_me) return;
4188    if ((it->queued) || (!it->mincalcd))
4189      {
4190         it->wd->show_item = it;
4191         it->wd->bring_in = EINA_TRUE;
4192         it->showme = EINA_TRUE;
4193         return;
4194      }
4195    if (it->wd->show_item)
4196      {
4197         it->wd->show_item->showme = EINA_FALSE;
4198         it->wd->show_item = NULL;
4199      }
4200    evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4201    elm_smart_scroller_child_region_show(it->wd->scr,
4202                                         it->x + it->block->x,
4203                                         it->y + it->block->y - oh / 2 +
4204                                         it->h / 2, it->block->w, oh);
4205 }
4206
4207 /**
4208  * Bring in the given item at the middle
4209  *
4210  * This causes genlist to jump to the given item @p it and show it (by
4211  * scrolling), if it is not fully visible. This may use animation to
4212  * do so and take a period of time
4213  *
4214  * @param it The item
4215  *
4216  * @ingroup Genlist
4217  */
4218 EAPI void
4219 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4220 {
4221    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4222    Evas_Coord ow, oh;
4223
4224    if (it->delete_me) return;
4225    if ((it->queued) || (!it->mincalcd))
4226      {
4227         it->wd->show_item = it;
4228         it->wd->bring_in = EINA_TRUE;
4229         it->showme = EINA_TRUE;
4230         return;
4231      }
4232    if (it->wd->show_item)
4233      {
4234         it->wd->show_item->showme = EINA_FALSE;
4235         it->wd->show_item = NULL;
4236      }
4237    evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4238    elm_smart_scroller_region_bring_in(it->wd->scr,
4239                                       it->x + it->block->x,
4240                                       it->y + it->block->y - oh / 2 + it->h / 2,
4241                                       it->block->w, oh);
4242 }
4243
4244 /**
4245  * Delete a given item
4246  *
4247  * This deletes the item from genlist and calls the genlist item del
4248  * class callback defined in the item class, if it is set. This clears all
4249  * subitems if it is a tree.
4250  *
4251  * @param it The item
4252  *
4253  * @ingroup Genlist
4254  */
4255 EAPI void
4256 elm_genlist_item_del(Elm_Genlist_Item *it)
4257 {
4258    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4259    if ((it->relcount > 0) || (it->walking > 0))
4260      {
4261         elm_widget_item_pre_notify_del(it);
4262         elm_genlist_item_subitems_clear(it);
4263         it->delete_me = EINA_TRUE;
4264         if (it->wd->show_item == it) it->wd->show_item = NULL;
4265         if (it->selected)
4266           it->wd->selected = eina_list_remove(it->wd->selected,
4267                                               it);
4268         if (it->block)
4269           {
4270              if (it->realized) _item_unrealize(it, EINA_FALSE);
4271              it->block->changed = EINA_TRUE;
4272              if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4273              it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4274           }
4275         if (it->itc->func.del)
4276           it->itc->func.del((void *)it->base.data, it->base.widget);
4277         return;
4278      }
4279    _item_del(it);
4280 }
4281
4282 /**
4283  * Set the data item from the genlist item
4284  *
4285  * This set the data value passed on the elm_genlist_item_append() and
4286  * related item addition calls. This function will also call
4287  * elm_genlist_item_update() so the item will be updated to reflect the
4288  * new data.
4289  *
4290  * @param it The item
4291  * @param data The new data pointer to set
4292  *
4293  * @ingroup Genlist
4294  */
4295 EAPI void
4296 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4297                           const void       *data)
4298 {
4299    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4300    elm_widget_item_data_set(it, data);
4301    elm_genlist_item_update(it);
4302 }
4303
4304 /**
4305  * Get the data item from the genlist item
4306  *
4307  * This returns the data value passed on the elm_genlist_item_append()
4308  * and related item addition calls and elm_genlist_item_data_set().
4309  *
4310  * @param it The item
4311  * @return The data pointer provided when created
4312  *
4313  * @ingroup Genlist
4314  */
4315 EAPI void *
4316 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4317 {
4318    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4319    return elm_widget_item_data_get(it);
4320 }
4321
4322 /**
4323  * Tells genlist to "orphan" icons fetchs by the item class
4324  *
4325  * This instructs genlist to release references to icons in the item,
4326  * meaning that they will no longer be managed by genlist and are
4327  * floating "orphans" that can be re-used elsewhere if the user wants
4328  * to.
4329  *
4330  * @param it The item
4331  *
4332  * @ingroup Genlist
4333  */
4334 EAPI void
4335 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4336 {
4337    Evas_Object *icon;
4338    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4339    EINA_LIST_FREE(it->icon_objs, icon)
4340      {
4341         elm_widget_sub_object_del(it->base.widget, icon);
4342         evas_object_smart_member_del(icon);
4343         evas_object_hide(icon);
4344      }
4345 }
4346
4347 /**
4348  * Get the real evas object of the genlist item
4349  *
4350  * This returns the actual evas object used for the specified genlist
4351  * item. This may be NULL as it may not be created, and may be deleted
4352  * at any time by genlist. Do not modify this object (move, resize,
4353  * show, hide etc.) as genlist is controlling it. This function is for
4354  * querying, emitting custom signals or hooking lower level callbacks
4355  * for events. Do not delete this object under any circumstances.
4356  *
4357  * @param it The item
4358  * @return The object pointer
4359  *
4360  * @ingroup Genlist
4361  */
4362 EAPI const Evas_Object *
4363 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4364 {
4365    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4366    return it->base.view;
4367 }
4368
4369 /**
4370  * Update the contents of an item
4371  *
4372  * This updates an item by calling all the item class functions again
4373  * to get the icons, labels and states. Use this when the original
4374  * item data has changed and the changes are desired to be reflected.
4375  *
4376  * @param it The item
4377  *
4378  * @ingroup Genlist
4379  */
4380 EAPI void
4381 elm_genlist_item_update(Elm_Genlist_Item *it)
4382 {
4383    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4384    if (!it->block) return;
4385    if (it->delete_me) return;
4386    it->mincalcd = EINA_FALSE;
4387    it->updateme = EINA_TRUE;
4388    it->block->updateme = EINA_TRUE;
4389    if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4390    it->wd->update_job = ecore_job_add(_update_job, it->wd);
4391 }
4392
4393 /**
4394  * Update the item class of an item
4395  *
4396  * @param it The item
4397  * @parem itc The item class for the item
4398  *
4399  * @ingroup Genlist
4400  */
4401 EAPI void
4402 elm_genlist_item_item_class_update(Elm_Genlist_Item             *it,
4403                                    const Elm_Genlist_Item_Class *itc)
4404 {
4405    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4406    if (!it->block) return;
4407    EINA_SAFETY_ON_NULL_RETURN(itc);
4408    if (it->delete_me) return;
4409    it->itc = itc;
4410    it->nocache = EINA_TRUE;
4411    elm_genlist_item_update(it);
4412 }
4413
4414 static Evas_Object *
4415 _elm_genlist_item_label_create(void        *data,
4416                                Evas_Object *obj,
4417                                void        *item __UNUSED__)
4418 {
4419    Evas_Object *label = elm_label_add(obj);
4420    if (!label)
4421      return NULL;
4422    elm_object_style_set(label, "tooltip");
4423    elm_label_label_set(label, data);
4424    return label;
4425 }
4426
4427 static void
4428 _elm_genlist_item_label_del_cb(void        *data,
4429                                Evas_Object *obj __UNUSED__,
4430                                void        *event_info __UNUSED__)
4431 {
4432    eina_stringshare_del(data);
4433 }
4434
4435 /**
4436  * Set the text to be shown in the genlist item.
4437  *
4438  * @param item Target item
4439  * @param text The text to set in the content
4440  *
4441  * Setup the text as tooltip to object. The item can have only one
4442  * tooltip, so any previous tooltip data is removed.
4443  *
4444  * @ingroup Genlist
4445  */
4446 EAPI void
4447 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4448                                   const char       *text)
4449 {
4450    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4451    text = eina_stringshare_add(text);
4452    elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4453                                            text,
4454                                            _elm_genlist_item_label_del_cb);
4455 }
4456
4457 /**
4458  * Set the content to be shown in the tooltip item
4459  *
4460  * Setup the tooltip to item. The item can have only one tooltip, so
4461  * any previous tooltip data is removed. @p func(with @p data) will be
4462  * called every time that need to show the tooltip and it should return a
4463  * valid Evas_Object. This object is then managed fully by tooltip
4464  * system and is deleted when the tooltip is gone.
4465  *
4466  * @param item the genlist item being attached by a tooltip.
4467  * @param func the function used to create the tooltip contents.
4468  * @param data what to provide to @a func as callback data/context.
4469  * @param del_cb called when data is not needed anymore, either when
4470  *        another callback replaces @func, the tooltip is unset with
4471  *        elm_genlist_item_tooltip_unset() or the owner @a item
4472  *        dies. This callback receives as the first parameter the
4473  *        given @a data, and @c event_info is the item.
4474  *
4475  * @ingroup Genlist
4476  */
4477 EAPI void
4478 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item           *item,
4479                                         Elm_Tooltip_Item_Content_Cb func,
4480                                         const void                 *data,
4481                                         Evas_Smart_Cb               del_cb)
4482 {
4483    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4484
4485    if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4486      return;
4487
4488    if (item->tooltip.del_cb)
4489      item->tooltip.del_cb((void *)item->tooltip.data,
4490                           item->base.widget, item);
4491
4492    item->tooltip.content_cb = func;
4493    item->tooltip.data = data;
4494    item->tooltip.del_cb = del_cb;
4495
4496    if (item->base.view)
4497      {
4498         elm_widget_item_tooltip_content_cb_set(item,
4499                                                item->tooltip.content_cb,
4500                                                item->tooltip.data, NULL);
4501         elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4502      }
4503
4504    return;
4505
4506 error:
4507    if (del_cb) del_cb((void *)data, NULL, NULL);
4508 }
4509
4510 /**
4511  * Unset tooltip from item
4512  *
4513  * @param item genlist item to remove previously set tooltip.
4514  *
4515  * Remove tooltip from item. The callback provided as del_cb to
4516  * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4517  * it is not used anymore.
4518  *
4519  * @see elm_genlist_item_tooltip_content_cb_set()
4520  *
4521  * @ingroup Genlist
4522  */
4523 EAPI void
4524 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4525 {
4526    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4527    if ((item->base.view) && (item->tooltip.content_cb))
4528      elm_widget_item_tooltip_unset(item);
4529
4530    if (item->tooltip.del_cb)
4531      item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4532    item->tooltip.del_cb = NULL;
4533    item->tooltip.content_cb = NULL;
4534    item->tooltip.data = NULL;
4535    if (item->tooltip.style)
4536      elm_genlist_item_tooltip_style_set(item, NULL);
4537 }
4538
4539 /**
4540  * Sets a different style for this item tooltip.
4541  *
4542  * @note before you set a style you should define a tooltip with
4543  *       elm_genlist_item_tooltip_content_cb_set() or
4544  *       elm_genlist_item_tooltip_text_set()
4545  *
4546  * @param item genlist item with tooltip already set.
4547  * @param style the theme style to use (default, transparent, ...)
4548  *
4549  * @ingroup Genlist
4550  */
4551 EAPI void
4552 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4553                                    const char       *style)
4554 {
4555    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4556    eina_stringshare_replace(&item->tooltip.style, style);
4557    if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4558 }
4559
4560 /**
4561  * Get the style for this item tooltip.
4562  *
4563  * @param item genlist item with tooltip already set.
4564  * @return style the theme style in use, defaults to "default". If the
4565  *         object does not have a tooltip set, then NULL is returned.
4566  *
4567  * @ingroup Genlist
4568  */
4569 EAPI const char *
4570 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4571 {
4572    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4573    return item->tooltip.style;
4574 }
4575
4576 /**
4577  * Set the cursor to be shown when mouse is over the genlist item
4578  *
4579  * @param item Target item
4580  * @param cursor the cursor name to be used.
4581  *
4582  * @see elm_object_cursor_set()
4583  * @ingroup Genlist
4584  */
4585 EAPI void
4586 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4587                             const char       *cursor)
4588 {
4589    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4590    eina_stringshare_replace(&item->mouse_cursor, cursor);
4591    if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4592 }
4593
4594 /**
4595  * Get the cursor to be shown when mouse is over the genlist item
4596  *
4597  * @param item genlist item with cursor already set.
4598  * @return the cursor name.
4599  *
4600  * @ingroup Genlist
4601  */
4602 EAPI const char *
4603 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4604 {
4605    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4606    return elm_widget_item_cursor_get(item);
4607 }
4608
4609 /**
4610  * Unset the cursor to be shown when mouse is over the genlist item
4611  *
4612  * @param item Target item
4613  *
4614  * @see elm_object_cursor_unset()
4615  * @ingroup Genlist
4616  */
4617 EAPI void
4618 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4619 {
4620    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4621    if (!item->mouse_cursor)
4622      return;
4623
4624    if (item->base.view)
4625      elm_widget_item_cursor_unset(item);
4626
4627    eina_stringshare_del(item->mouse_cursor);
4628    item->mouse_cursor = NULL;
4629 }
4630
4631 /**
4632  * Sets a different style for this item cursor.
4633  *
4634  * @note before you set a style you should define a cursor with
4635  *       elm_genlist_item_cursor_set()
4636  *
4637  * @param item genlist item with cursor already set.
4638  * @param style the theme style to use (default, transparent, ...)
4639  *
4640  * @ingroup Genlist
4641  */
4642 EAPI void
4643 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4644                                   const char       *style)
4645 {
4646    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4647    elm_widget_item_cursor_style_set(item, style);
4648 }
4649
4650 /**
4651  * Get the style for this item cursor.
4652  *
4653  * @param item genlist item with cursor already set.
4654  * @return style the theme style in use, defaults to "default". If the
4655  *         object does not have a cursor set, then NULL is returned.
4656  *
4657  * @ingroup Genlist
4658  */
4659 EAPI const char *
4660 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4661 {
4662    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4663    return elm_widget_item_cursor_style_get(item);
4664 }
4665
4666 /**
4667  * Set if the cursor set should be searched on the theme or should use
4668  * the provided by the engine, only.
4669  *
4670  * @note before you set if should look on theme you should define a
4671  * cursor with elm_object_cursor_set(). By default it will only look
4672  * for cursors provided by the engine.
4673  *
4674  * @param item widget item with cursor already set.
4675  * @param engine_only boolean to define it cursors should be looked
4676  * only between the provided by the engine or searched on widget's
4677  * theme as well.
4678  *
4679  * @ingroup Genlist
4680  */
4681 EAPI void
4682 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4683                                         Eina_Bool         engine_only)
4684 {
4685    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4686    elm_widget_item_cursor_engine_only_set(item, engine_only);
4687 }
4688
4689 /**
4690  * Get the cursor engine only usage for this item cursor.
4691  *
4692  * @param item widget item with cursor already set.
4693  * @return engine_only boolean to define it cursors should be looked
4694  * only between the provided by the engine or searched on widget's
4695  * theme as well. If the object does not have a cursor set, then
4696  * EINA_FALSE is returned.
4697  *
4698  * @ingroup Genlist
4699  */
4700 EAPI Eina_Bool
4701 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4702 {
4703    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4704    return elm_widget_item_cursor_engine_only_get(item);
4705 }
4706
4707 /**
4708  * This sets the horizontal stretching mode
4709  *
4710  * This sets the mode used for sizing items horizontally. Valid modes
4711  * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4712  * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4713  * the scroller will scroll horizontally. Otherwise items are expanded
4714  * to fill the width of the viewport of the scroller. If it is
4715  * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4716  * limited to that size.
4717  *
4718  * @param obj The genlist object
4719  * @param mode The mode to use
4720  *
4721  * @ingroup Genlist
4722  */
4723 EAPI void
4724 elm_genlist_horizontal_mode_set(Evas_Object  *obj,
4725                                 Elm_List_Mode mode)
4726 {
4727    ELM_CHECK_WIDTYPE(obj, widtype);
4728    Widget_Data *wd = elm_widget_data_get(obj);
4729    if (!wd) return;
4730    if (wd->mode == mode) return;
4731    wd->mode = mode;
4732    _sizing_eval(obj);
4733 }
4734
4735 /**
4736  * Gets the horizontal stretching mode
4737  *
4738  * @param obj The genlist object
4739  * @return The mode to use
4740  * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4741  *
4742  * @ingroup Genlist
4743  */
4744 EAPI Elm_List_Mode
4745 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4746 {
4747    ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4748    Widget_Data *wd = elm_widget_data_get(obj);
4749    if (!wd) return ELM_LIST_LAST;
4750    return wd->mode;
4751 }
4752
4753 /**
4754  * Set the always select mode.
4755  *
4756  * Items will only call their selection func and callback when first
4757  * becoming selected. Any further clicks will do nothing, unless you
4758  * enable always select with elm_genlist_always_select_mode_set().
4759  * This means even if selected, every click will make the selected
4760  * callbacks be called.
4761  *
4762  * @param obj The genlist object
4763  * @param always_select The always select mode
4764  * (EINA_TRUE = on, EINA_FALSE = off)
4765  *
4766  * @ingroup Genlist
4767  */
4768 EAPI void
4769 elm_genlist_always_select_mode_set(Evas_Object *obj,
4770                                    Eina_Bool    always_select)
4771 {
4772    ELM_CHECK_WIDTYPE(obj, widtype);
4773    Widget_Data *wd = elm_widget_data_get(obj);
4774    if (!wd) return;
4775    wd->always_select = always_select;
4776 }
4777
4778 /**
4779  * Get the always select mode.
4780  *
4781  * @param obj The genlist object
4782  * @return The always select mode
4783  * (EINA_TRUE = on, EINA_FALSE = off)
4784  *
4785  * @ingroup Genlist
4786  */
4787 EAPI Eina_Bool
4788 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4789 {
4790    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4791    Widget_Data *wd = elm_widget_data_get(obj);
4792    if (!wd) return EINA_FALSE;
4793    return wd->always_select;
4794 }
4795
4796 /**
4797  * Set no select mode
4798  *
4799  * This will turn off the ability to select items entirely and they
4800  * will neither appear selected nor call selected callback functions.
4801  *
4802  * @param obj The genlist object
4803  * @param no_select The no select mode
4804  * (EINA_TRUE = on, EINA_FALSE = off)
4805  *
4806  * @ingroup Genlist
4807  */
4808 EAPI void
4809 elm_genlist_no_select_mode_set(Evas_Object *obj,
4810                                Eina_Bool    no_select)
4811 {
4812    ELM_CHECK_WIDTYPE(obj, widtype);
4813    Widget_Data *wd = elm_widget_data_get(obj);
4814    if (!wd) return;
4815    wd->no_select = no_select;
4816 }
4817
4818 /**
4819  * Gets no select mode
4820  *
4821  * @param obj The genlist object
4822  * @return The no select mode
4823  * (EINA_TRUE = on, EINA_FALSE = off)
4824  *
4825  * @ingroup Genlist
4826  */
4827 EAPI Eina_Bool
4828 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4829 {
4830    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4831    Widget_Data *wd = elm_widget_data_get(obj);
4832    if (!wd) return EINA_FALSE;
4833    return wd->no_select;
4834 }
4835
4836 /**
4837  * Set compress mode
4838  *
4839  * This will enable the compress mode where items are "compressed"
4840  * horizontally to fit the genlist scrollable viewport width. This is
4841  * special for genlist.  Do not rely on
4842  * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
4843  * work as genlist needs to handle it specially.
4844  *
4845  * @param obj The genlist object
4846  * @param compress The compress mode
4847  * (EINA_TRUE = on, EINA_FALSE = off)
4848  *
4849  * @ingroup Genlist
4850  */
4851 EAPI void
4852 elm_genlist_compress_mode_set(Evas_Object *obj,
4853                               Eina_Bool    compress)
4854 {
4855    ELM_CHECK_WIDTYPE(obj, widtype);
4856    Widget_Data *wd = elm_widget_data_get(obj);
4857    if (!wd) return;
4858    wd->compress = compress;
4859 }
4860
4861 /**
4862  * Get the compress mode
4863  *
4864  * @param obj The genlist object
4865  * @return The compress mode
4866  * (EINA_TRUE = on, EINA_FALSE = off)
4867  *
4868  * @ingroup Genlist
4869  */
4870 EAPI Eina_Bool
4871 elm_genlist_compress_mode_get(const Evas_Object *obj)
4872 {
4873    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4874    Widget_Data *wd = elm_widget_data_get(obj);
4875    if (!wd) return EINA_FALSE;
4876    return wd->compress;
4877 }
4878
4879 /**
4880  * Set height-for-width mode
4881  *
4882  * With height-for-width mode the item width will be fixed (restricted
4883  * to a minimum of) to the list width when calculating its size in
4884  * order to allow the height to be calculated based on it. This allows,
4885  * for instance, text block to wrap lines if the Edje part is
4886  * configured with "text.min: 0 1".
4887  *
4888  * @note This mode will make list resize slower as it will have to
4889  *       recalculate every item height again whenever the list width
4890  *       changes!
4891  *
4892  * @note When height-for-width mode is enabled, it also enables
4893  *       compress mode (see elm_genlist_compress_mode_set()) and
4894  *       disables homogeneous (see elm_genlist_homogeneous_set()).
4895  *
4896  * @param obj The genlist object
4897  * @param setting The height-for-width mode (EINA_TRUE = on,
4898  * EINA_FALSE = off)
4899  *
4900  * @ingroup Genlist
4901  */
4902 EAPI void
4903 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
4904                                       Eina_Bool    height_for_width)
4905 {
4906    ELM_CHECK_WIDTYPE(obj, widtype);
4907    Widget_Data *wd = elm_widget_data_get(obj);
4908    if (!wd) return;
4909    wd->height_for_width = !!height_for_width;
4910    if (wd->height_for_width)
4911      {
4912         elm_genlist_homogeneous_set(obj, EINA_FALSE);
4913         elm_genlist_compress_mode_set(obj, EINA_TRUE);
4914      }
4915 }
4916
4917 /**
4918  * Get the height-for-width mode
4919  *
4920  * @param obj The genlist object
4921  * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
4922  * off)
4923  *
4924  * @ingroup Genlist
4925  */
4926 EAPI Eina_Bool
4927 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
4928 {
4929    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4930    Widget_Data *wd = elm_widget_data_get(obj);
4931    if (!wd) return EINA_FALSE;
4932    return wd->height_for_width;
4933 }
4934
4935 /**
4936  * Set bounce mode
4937  *
4938  * This will enable or disable the scroller bounce mode for the
4939  * genlist. See elm_scroller_bounce_set() for details
4940  *
4941  * @param obj The genlist object
4942  * @param h_bounce Allow bounce horizontally
4943  * @param v_bounce Allow bounce vertically
4944  *
4945  * @ingroup Genlist
4946  */
4947 EAPI void
4948 elm_genlist_bounce_set(Evas_Object *obj,
4949                        Eina_Bool    h_bounce,
4950                        Eina_Bool    v_bounce)
4951 {
4952    ELM_CHECK_WIDTYPE(obj, widtype);
4953    Widget_Data *wd = elm_widget_data_get(obj);
4954    if (!wd) return;
4955    elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
4956 }
4957
4958 /**
4959  * Get the bounce mode
4960  *
4961  * @param obj The genlist object
4962  * @param h_bounce Allow bounce horizontally
4963  * @param v_bounce Allow bounce vertically
4964  *
4965  * @ingroup Genlist
4966  */
4967 EAPI void
4968 elm_genlist_bounce_get(const Evas_Object *obj,
4969                        Eina_Bool         *h_bounce,
4970                        Eina_Bool         *v_bounce)
4971 {
4972    ELM_CHECK_WIDTYPE(obj, widtype);
4973    Widget_Data *wd = elm_widget_data_get(obj);
4974    if (!wd) return;
4975    elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
4976 }
4977
4978 /**
4979  * Set homogenous mode
4980  *
4981  * This will enable the homogeneous mode where items are of the same
4982  * height and width so that genlist may do the lazy-loading at its
4983  * maximum. This implies 'compressed' mode.
4984  *
4985  * @param obj The genlist object
4986  * @param homogeneous Assume the items within the genlist are of the
4987  * same height and width (EINA_TRUE = on, EINA_FALSE = off)
4988  *
4989  * @ingroup Genlist
4990  */
4991 EAPI void
4992 elm_genlist_homogeneous_set(Evas_Object *obj,
4993                             Eina_Bool    homogeneous)
4994 {
4995    ELM_CHECK_WIDTYPE(obj, widtype);
4996    Widget_Data *wd = elm_widget_data_get(obj);
4997    if (!wd) return;
4998    if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
4999    wd->homogeneous = homogeneous;
5000 }
5001
5002 /**
5003  * Get the homogenous mode
5004  *
5005  * @param obj The genlist object
5006  * @return Assume the items within the genlist are of the same height
5007  * and width (EINA_TRUE = on, EINA_FALSE = off)
5008  *
5009  * @ingroup Genlist
5010  */
5011 EAPI Eina_Bool
5012 elm_genlist_homogeneous_get(const Evas_Object *obj)
5013 {
5014    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5015    Widget_Data *wd = elm_widget_data_get(obj);
5016    if (!wd) return EINA_FALSE;
5017    return wd->homogeneous;
5018 }
5019
5020 /**
5021  * Set the maximum number of items within an item block
5022  *
5023  * This will configure the block count to tune to the target with
5024  * particular performance matrix.
5025  *
5026  * @param obj The genlist object
5027  * @param n   Maximum number of items within an item block
5028  *
5029  * @ingroup Genlist
5030  */
5031 EAPI void
5032 elm_genlist_block_count_set(Evas_Object *obj,
5033                             int          n)
5034 {
5035    ELM_CHECK_WIDTYPE(obj, widtype);
5036    Widget_Data *wd = elm_widget_data_get(obj);
5037    if (!wd) return;
5038    wd->max_items_per_block = n;
5039    wd->item_cache_max = wd->max_items_per_block * 2;
5040    _item_cache_clean(wd);
5041 }
5042
5043 /**
5044  * Get the maximum number of items within an item block
5045  *
5046  * @param obj The genlist object
5047  * @return Maximum number of items within an item block
5048  *
5049  * @ingroup Genlist
5050  */
5051 EAPI int
5052 elm_genlist_block_count_get(const Evas_Object *obj)
5053 {
5054    ELM_CHECK_WIDTYPE(obj, widtype) 0;
5055    Widget_Data *wd = elm_widget_data_get(obj);
5056    if (!wd) return 0;
5057    return wd->max_items_per_block;
5058 }
5059
5060 /**
5061  * Set the timeout in seconds for the longpress event
5062  *
5063  * @param obj The genlist object
5064  * @param timeout timeout in seconds
5065  *
5066  * @ingroup Genlist
5067  */
5068 EAPI void
5069 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5070                                   double       timeout)
5071 {
5072    ELM_CHECK_WIDTYPE(obj, widtype);
5073    Widget_Data *wd = elm_widget_data_get(obj);
5074    if (!wd) return;
5075    wd->longpress_timeout = timeout;
5076 }
5077
5078 /**
5079  * Get the timeout in seconds for the longpress event
5080  *
5081  * @param obj The genlist object
5082  * @return timeout in seconds
5083  *
5084  * @ingroup Genlist
5085  */
5086 EAPI double
5087 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5088 {
5089    ELM_CHECK_WIDTYPE(obj, widtype) 0;
5090    Widget_Data *wd = elm_widget_data_get(obj);
5091    if (!wd) return 0;
5092    return wd->longpress_timeout;
5093 }
5094
5095 /**
5096  * Set the scrollbar policy
5097  *
5098  * This sets the scrollbar visibility policy for the given genlist
5099  * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5100  * made visible if it is needed, and otherwise kept hidden.
5101  * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5102  * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5103  * respectively for the horizontal and vertical scrollbars.
5104  *
5105  * @param obj The genlist object
5106  * @param policy_h Horizontal scrollbar policy
5107  * @param policy_v Vertical scrollbar policy
5108  *
5109  * @ingroup Genlist
5110  */
5111 EAPI void
5112 elm_genlist_scroller_policy_set(Evas_Object        *obj,
5113                                 Elm_Scroller_Policy policy_h,
5114                                 Elm_Scroller_Policy policy_v)
5115 {
5116    ELM_CHECK_WIDTYPE(obj, widtype);
5117    Widget_Data *wd = elm_widget_data_get(obj);
5118    if (!wd) return;
5119    if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5120        (policy_v >= ELM_SCROLLER_POLICY_LAST))
5121      return;
5122    if (wd->scr)
5123      elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5124 }
5125
5126 /**
5127  * Get the scrollbar policy
5128  *
5129  * @param obj The genlist object
5130  * @param policy_h Horizontal scrollbar policy
5131  * @param policy_v Vertical scrollbar policy
5132  *
5133  * @ingroup Genlist
5134  */
5135 EAPI void
5136 elm_genlist_scroller_policy_get(const Evas_Object   *obj,
5137                                 Elm_Scroller_Policy *policy_h,
5138                                 Elm_Scroller_Policy *policy_v)
5139 {
5140    ELM_CHECK_WIDTYPE(obj, widtype);
5141    Widget_Data *wd = elm_widget_data_get(obj);
5142    Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5143    if ((!wd) || (!wd->scr)) return;
5144    elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5145    if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5146    if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5147 }
5148
5149 /**
5150  * Update the contents of all realized items
5151  *
5152  * This updates all realized items by calling all the item class functions again
5153  * to get the icons, labels and states. Use this when the original
5154  * item data has changed and the changes are desired to be reflected.
5155  *
5156  * @param it The item
5157  *
5158  * @ingroup Genlist
5159  */
5160 EAPI void
5161 elm_genlist_realized_items_update(Evas_Object *obj)
5162 {
5163    ELM_CHECK_WIDTYPE(obj, widtype);
5164
5165    Eina_List *list, *l;
5166    Elm_Genlist_Item *it;
5167
5168    list = elm_genlist_realized_items_get(obj);
5169    EINA_LIST_FOREACH(list, l, it)
5170      elm_genlist_item_update(it);
5171 }
5172
5173 /**
5174  * Set genlist item mode
5175  *
5176  * @param item The genlist item
5177  * @param mode Mode name
5178  * @param mode_set Boolean to define set or unset mode.
5179  *
5180  * @ingroup Genlist
5181  */
5182 EAPI void
5183 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
5184                           const char       *mode_type,
5185                           Eina_Bool         mode_set)
5186 {
5187    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5188    Widget_Data *wd = it->wd;
5189    Eina_List *l;
5190    Elm_Genlist_Item *it2;
5191
5192    if (!wd) return;
5193    if (!mode_type) return;
5194
5195    if ((wd->mode_item == it) &&
5196        (!strcmp(mode_type, wd->mode_type)) &&
5197        (mode_set))
5198       return;
5199    if (!it->itc->mode_item_style) return;
5200
5201    if (wd->multi)
5202      {
5203         EINA_LIST_FOREACH(wd->selected, l, it2)
5204           if (it2->realized)
5205             elm_genlist_item_selected_set(it2, EINA_FALSE);
5206      }
5207    else
5208      {
5209         it2 = elm_genlist_selected_item_get(wd->obj);
5210         if ((it2) && (it2->realized))
5211           elm_genlist_item_selected_set(it2, EINA_FALSE);
5212      }
5213
5214    if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
5215        (mode_set) ||
5216        ((it == wd->mode_item) && (!mode_set)))
5217      _item_mode_unset(wd);
5218
5219    eina_stringshare_replace(&wd->mode_type, mode_type);
5220    if (mode_set) _item_mode_set(it);
5221 }
5222
5223 /**
5224  * Get active genlist mode type
5225  *
5226  * @param obj The genlist object
5227  *
5228  * @ingroup Genlist
5229  */
5230 EAPI const char *
5231 elm_genlist_mode_get(const Evas_Object *obj)
5232 {
5233    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5234    Widget_Data *wd = elm_widget_data_get(obj);
5235    if (!wd) return NULL;
5236    return wd->mode_type;
5237 }
5238
5239 /**
5240  * Get active genlist mode item
5241  *
5242  * @param obj The genlist object
5243  *
5244  * @ingroup Genlist
5245  */
5246 EAPI const Elm_Genlist_Item *
5247 elm_genlist_mode_item_get(const Evas_Object *obj)
5248 {
5249    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5250    Widget_Data *wd = elm_widget_data_get(obj);
5251    if (!wd) return NULL;
5252    return wd->mode_item;
5253 }