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