elementary/genlist - Elm_Genlist_Item -> Elm_Object_Item
[framework/uifw/elementary.git] / src / lib / elm_gengrid.c
1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
3 #include "elm_priv.h"
4 #include "els_scroller.h"
5 #include "elm_gen_common.h"
6
7 /* --
8  * TODO:
9  * Handle non-homogeneous objects too.
10  */
11
12 #define PRELOAD 1
13 #define REORDER_EFFECT_TIME 0.5
14
15 #define ELM_GEN_SETUP(wd) \
16    (wd)->calc_cb = (Ecore_Cb)_calc_job
17
18 #define ELM_GEN_ITEM_SETUP(it) \
19    (it)->del_cb = (Ecore_Cb)_item_del; \
20    (it)->highlight_cb = (Ecore_Cb)_item_highlight; \
21    (it)->unsel_cb = (Ecore_Cb)_item_unselect; \
22    (it)->unrealize_cb = (Ecore_Cb)_item_unrealize_cb
23
24 struct Elm_Gen_Item_Type
25 {
26    Elm_Gen_Item   *it;
27    Ecore_Animator *item_moving_effect_timer;
28    Evas_Coord   gx, gy, ox, oy, tx, ty, rx, ry;
29    unsigned int moving_effect_start_time;
30    int          prev_group;
31
32    Eina_Bool   group_realized : 1;
33    Eina_Bool   moving : 1;
34 };
35
36 #if 0
37 struct _Widget_Data
38 {
39    Eina_Inlist_Sorted_State *state;
40    Evas_Object      *obj; /* the gengrid object */
41    Evas_Object      *scr; /* a smart scroller object which is used internally in genlist */
42    Evas_Object      *pan_smart; /* "elm_genlist_pan" evas smart object. this is an extern pan of smart scroller(scr). */
43    Eina_List        *selected;
44    Eina_List        *group_items; /* list of groups index items */
45    Eina_Inlist      *items; /* inlist of all items */
46    Elm_Gen_Item     *reorder_it; /* item currently being repositioned */
47    Elm_Gen_Item     *last_selected_item;
48    Pan              *pan; /* pan_smart object's smart data */
49    Ecore_Job        *calc_job;
50    int               walking;
51    int               item_width, item_height;
52    int               group_item_width, group_item_height;
53    int               minw, minh;
54    long              count;
55    Evas_Coord        pan_x, pan_y;
56    Eina_Bool         reorder_mode : 1;
57    Eina_Bool         on_hold : 1;
58    Eina_Bool         multi : 1;
59    Eina_Bool         no_select : 1;
60    Eina_Bool         wasselected : 1;
61    Eina_Bool         always_select : 1;
62    Eina_Bool         clear_me : 1;
63    Eina_Bool         h_bounce : 1;
64    Eina_Bool         v_bounce : 1;
65    Ecore_Cb          del_cb, calc_cb, sizing_cb;
66    Ecore_Cb          clear_cb;
67    ////////////////////////////////////
68    double            align_x, align_y;
69
70    Evas_Coord        old_pan_x, old_pan_y;
71    Evas_Coord        reorder_item_x, reorder_item_y;
72    unsigned int      nmax;
73    long              items_lost;
74
75    int               generation;
76
77    Eina_Bool         horizontal : 1;
78    Eina_Bool         longpressed : 1;
79    Eina_Bool         reorder_item_changed : 1;
80    Eina_Bool         move_effect_enabled : 1;
81 };
82 #endif
83
84 static const char *widtype = NULL;
85 static void      _item_highlight(Elm_Gen_Item *it);
86 static void      _item_unrealize_cb(Elm_Gen_Item *it);
87 static void      _item_unselect(Elm_Gen_Item *it);
88 static void      _calc_job(void *data);
89 static void      _on_focus_hook(void        *data,
90                                 Evas_Object *obj);
91 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
92 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
93 static Eina_Bool _item_multi_select_left(Widget_Data *wd);
94 static Eina_Bool _item_multi_select_right(Widget_Data *wd);
95 static Eina_Bool _item_single_select_up(Widget_Data *wd);
96 static Eina_Bool _item_single_select_down(Widget_Data *wd);
97 static Eina_Bool _item_single_select_left(Widget_Data *wd);
98 static Eina_Bool _item_single_select_right(Widget_Data *wd);
99 static Eina_Bool _event_hook(Evas_Object       *obj,
100                              Evas_Object       *src,
101                              Evas_Callback_Type type,
102                              void              *event_info);
103 static Eina_Bool _deselect_all_items(Widget_Data *wd);
104
105 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
106 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
107
108 static const char SIG_ACTIVATED[] = "activated";
109 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
110 static const char SIG_LONGPRESSED[] = "longpressed";
111 static const char SIG_SELECTED[] = "selected";
112 static const char SIG_UNSELECTED[] = "unselected";
113 static const char SIG_REALIZED[] = "realized";
114 static const char SIG_UNREALIZED[] = "unrealized";
115 static const char SIG_CHANGED[] = "changed";
116 static const char SIG_DRAG_START_UP[] = "drag,start,up";
117 static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
118 static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
119 static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
120 static const char SIG_DRAG_STOP[] = "drag,stop";
121 static const char SIG_DRAG[] = "drag";
122 static const char SIG_SCROLL[] = "scroll";
123 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
124 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
125 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
126 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
127 static const char SIG_EDGE_TOP[] = "edge,top";
128 static const char SIG_EDGE_BOTTOM[] = "edge,bottom";
129 static const char SIG_EDGE_LEFT[] = "edge,left";
130 static const char SIG_EDGE_RIGHT[] = "edge,right";
131 static const char SIG_MOVED[] = "moved";
132
133 static const Evas_Smart_Cb_Description _signals[] = {
134    {SIG_ACTIVATED, ""},
135    {SIG_CLICKED_DOUBLE, ""},
136    {SIG_LONGPRESSED, ""},
137    {SIG_SELECTED, ""},
138    {SIG_UNSELECTED, ""},
139    {SIG_REALIZED, ""},
140    {SIG_UNREALIZED, ""},
141    {SIG_CHANGED, ""},
142    {SIG_DRAG_START_UP, ""},
143    {SIG_DRAG_START_DOWN, ""},
144    {SIG_DRAG_START_LEFT, ""},
145    {SIG_DRAG_START_RIGHT, ""},
146    {SIG_DRAG_STOP, ""},
147    {SIG_DRAG, ""},
148    {SIG_SCROLL, ""},
149    {SIG_SCROLL_ANIM_START, ""},
150    {SIG_SCROLL_ANIM_STOP, ""},
151    {SIG_SCROLL_DRAG_START, ""},
152    {SIG_SCROLL_DRAG_STOP, ""},
153    {SIG_EDGE_TOP, ""},
154    {SIG_EDGE_BOTTOM, ""},
155    {SIG_EDGE_LEFT, ""},
156    {SIG_EDGE_RIGHT, ""},
157    {SIG_MOVED, ""},
158    {NULL, NULL}
159 };
160
161 static Eina_Bool
162 _event_hook(Evas_Object        *obj,
163             Evas_Object        *src __UNUSED__,
164             Evas_Callback_Type  type,
165             void               *event_info)
166 {
167    if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
168    Evas_Event_Key_Down *ev = event_info;
169    Widget_Data *wd = elm_widget_data_get(obj);
170    if (!wd) return EINA_FALSE;
171    if (!wd->items) return EINA_FALSE;
172    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
173    if (elm_widget_disabled_get(obj)) return EINA_FALSE;
174
175    Elm_Gen_Item *it = NULL;
176    Evas_Coord x = 0;
177    Evas_Coord y = 0;
178    Evas_Coord step_x = 0;
179    Evas_Coord step_y = 0;
180    Evas_Coord v_w = 0;
181    Evas_Coord v_h = 0;
182    Evas_Coord page_x = 0;
183    Evas_Coord page_y = 0;
184
185    elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
186    elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
187    elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
188    elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
189
190    if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
191      {
192         if ((wd->horizontal) &&
193             (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
194               (_item_multi_select_up(wd)))
195              || (_item_single_select_up(wd))))
196           {
197              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
198              return EINA_TRUE;
199           }
200         else if ((!wd->horizontal) &&
201                  (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
202                    (_item_multi_select_left(wd)))
203                   || (_item_single_select_left(wd))))
204           {
205              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
206              return EINA_TRUE;
207           }
208         else
209           x -= step_x;
210      }
211    else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
212      {
213         if ((wd->horizontal) &&
214             (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
215               (_item_multi_select_down(wd)))
216              || (_item_single_select_down(wd))))
217           {
218              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
219              return EINA_TRUE;
220           }
221         else if ((!wd->horizontal) &&
222                  (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
223                    (_item_multi_select_right(wd)))
224                   || (_item_single_select_right(wd))))
225           {
226              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
227              return EINA_TRUE;
228           }
229         else
230           x += step_x;
231      }
232    else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
233      {
234         if ((wd->horizontal) &&
235             (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
236               (_item_multi_select_left(wd)))
237              || (_item_single_select_left(wd))))
238           {
239              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
240              return EINA_TRUE;
241           }
242         else if ((!wd->horizontal) &&
243                  (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
244                    (_item_multi_select_up(wd)))
245                   || (_item_single_select_up(wd))))
246           {
247              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
248              return EINA_TRUE;
249           }
250         else
251           y -= step_y;
252      }
253    else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
254      {
255         if ((wd->horizontal) &&
256             (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
257               (_item_multi_select_right(wd)))
258              || (_item_single_select_right(wd))))
259           {
260              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
261              return EINA_TRUE;
262           }
263         else if ((!wd->horizontal) &&
264                  (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
265                    (_item_multi_select_down(wd)))
266                   || (_item_single_select_down(wd))))
267           {
268              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
269              return EINA_TRUE;
270           }
271         else
272           y += step_y;
273      }
274    else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
275      {
276         it = elm_gengrid_first_item_get(obj);
277         elm_gengrid_item_bring_in(it);
278         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
279         return EINA_TRUE;
280      }
281    else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
282      {
283         it = elm_gengrid_last_item_get(obj);
284         elm_gengrid_item_bring_in(it);
285         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
286         return EINA_TRUE;
287      }
288    else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
289      {
290         if (wd->horizontal)
291           {
292              if (page_x < 0)
293                x -= -(page_x * v_w) / 100;
294              else
295                x -= page_x;
296           }
297         else
298           {
299              if (page_y < 0)
300                y -= -(page_y * v_h) / 100;
301              else
302                y -= page_y;
303           }
304      }
305    else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
306      {
307         if (wd->horizontal)
308           {
309              if (page_x < 0)
310                x += -(page_x * v_w) / 100;
311              else
312                x += page_x;
313           }
314         else
315           {
316              if (page_y < 0)
317                y += -(page_y * v_h) / 100;
318              else
319                y += page_y;
320           }
321      }
322    else if (!strcmp(ev->keyname, "Escape"))
323      {
324         if (!_deselect_all_items(wd)) return EINA_FALSE;
325         ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
326         return EINA_TRUE;
327      }
328    else if (((!strcmp(ev->keyname, "Return")) ||
329              (!strcmp(ev->keyname, "KP_Enter")) ||
330              (!strcmp(ev->keyname, "space")))
331             && (!wd->multi) && (wd->selected))
332      {
333         it = elm_gengrid_selected_item_get(obj);
334         evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
335      }
336    else return EINA_FALSE;
337
338    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
339    elm_smart_scroller_child_pos_set(wd->scr, x, y);
340    return EINA_TRUE;
341 }
342
343 static Eina_Bool
344 _deselect_all_items(Widget_Data *wd)
345 {
346    if (!wd->selected) return EINA_FALSE;
347    while (wd->selected)
348      elm_gengrid_item_selected_set(wd->selected->data, EINA_FALSE);
349
350    return EINA_TRUE;
351 }
352
353 static Eina_Bool
354 _item_multi_select_left(Widget_Data *wd)
355 {
356    if (!wd->selected) return EINA_FALSE;
357
358    Elm_Gen_Item *prev = elm_gengrid_item_prev_get(wd->last_selected_item);
359    if (!prev) return EINA_TRUE;
360    if (elm_gengrid_item_selected_get(prev))
361      {
362         elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
363         wd->last_selected_item = prev;
364         elm_gengrid_item_show(wd->last_selected_item);
365      }
366    else
367      {
368         elm_gengrid_item_selected_set(prev, EINA_TRUE);
369         elm_gengrid_item_show(prev);
370      }
371
372    return EINA_TRUE;
373 }
374
375 static Eina_Bool
376 _item_multi_select_right(Widget_Data *wd)
377 {
378    if (!wd->selected) return EINA_FALSE;
379
380    Elm_Gen_Item *next = elm_gengrid_item_next_get(wd->last_selected_item);
381    if (!next) return EINA_TRUE;
382    if (elm_gengrid_item_selected_get(next))
383      {
384         elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
385         wd->last_selected_item = next;
386         elm_gengrid_item_show(wd->last_selected_item);
387      }
388    else
389      {
390         elm_gengrid_item_selected_set(next, EINA_TRUE);
391         elm_gengrid_item_show(next);
392      }
393
394    return EINA_TRUE;
395 }
396
397 static Eina_Bool
398 _item_multi_select_up(Widget_Data *wd)
399 {
400    unsigned int i;
401    Eina_Bool r = EINA_TRUE;
402
403    if (!wd->selected) return EINA_FALSE;
404
405    for (i = 0; (r) && (i < wd->nmax); i++)
406      r &= _item_multi_select_left(wd);
407
408    return r;
409 }
410
411 static Eina_Bool
412 _item_multi_select_down(Widget_Data *wd)
413 {
414    unsigned int i;
415    Eina_Bool r = EINA_TRUE;
416
417    if (!wd->selected) return EINA_FALSE;
418
419    for (i = 0; (r) && (i < wd->nmax); i++)
420      r &= _item_multi_select_right(wd);
421
422    return r;
423 }
424
425 static Eina_Bool
426 _item_single_select_up(Widget_Data *wd)
427 {
428    unsigned int i;
429
430    Elm_Gen_Item *prev;
431
432    if (!wd->selected)
433      {
434         prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
435         while ((prev) && (prev->generation < wd->generation))
436           prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
437         elm_gengrid_item_selected_set(prev, EINA_TRUE);
438         elm_gengrid_item_show(prev);
439         return EINA_TRUE;
440      }
441    else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
442
443    if (!prev) return EINA_FALSE;
444
445    for (i = 1; i < wd->nmax; i++)
446      {
447         Elm_Gen_Item *tmp = elm_gengrid_item_prev_get(prev);
448         if (!tmp) return EINA_FALSE;
449         prev = tmp;
450      }
451
452    _deselect_all_items(wd);
453
454    elm_gengrid_item_selected_set(prev, EINA_TRUE);
455    elm_gengrid_item_show(prev);
456    return EINA_TRUE;
457 }
458
459 static Eina_Bool
460 _item_single_select_down(Widget_Data *wd)
461 {
462    unsigned int i;
463
464    Elm_Gen_Item *next;
465
466    if (!wd->selected)
467      {
468         next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
469         while ((next) && (next->generation < wd->generation))
470           next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
471         elm_gengrid_item_selected_set(next, EINA_TRUE);
472         elm_gengrid_item_show(next);
473         return EINA_TRUE;
474      }
475    else next = elm_gengrid_item_next_get(wd->last_selected_item);
476
477    if (!next) return EINA_FALSE;
478
479    for (i = 1; i < wd->nmax; i++)
480      {
481         Elm_Gen_Item *tmp = elm_gengrid_item_next_get(next);
482         if (!tmp) return EINA_FALSE;
483         next = tmp;
484      }
485
486    _deselect_all_items(wd);
487
488    elm_gengrid_item_selected_set(next, EINA_TRUE);
489    elm_gengrid_item_show(next);
490    return EINA_TRUE;
491 }
492
493 static Eina_Bool
494 _item_single_select_left(Widget_Data *wd)
495 {
496    Elm_Gen_Item *prev;
497    if (!wd->selected)
498      {
499         prev = ELM_GEN_ITEM_FROM_INLIST(wd->items->last);
500         while ((prev) && (prev->generation < wd->generation))
501           prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
502      }
503    else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
504
505    if (!prev) return EINA_FALSE;
506
507    _deselect_all_items(wd);
508
509    elm_gengrid_item_selected_set(prev, EINA_TRUE);
510    elm_gengrid_item_show(prev);
511    return EINA_TRUE;
512 }
513
514 static Eina_Bool
515 _item_single_select_right(Widget_Data *wd)
516 {
517    Elm_Gen_Item *next;
518    if (!wd->selected)
519      {
520         next = ELM_GEN_ITEM_FROM_INLIST(wd->items);
521         while ((next) && (next->generation < wd->generation))
522           next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
523      }
524    else next = elm_gengrid_item_next_get(wd->last_selected_item);
525
526    if (!next) return EINA_FALSE;
527
528    _deselect_all_items(wd);
529
530    elm_gengrid_item_selected_set(next, EINA_TRUE);
531    elm_gengrid_item_show(next);
532    return EINA_TRUE;
533 }
534
535 static void
536 _on_focus_hook(void *data   __UNUSED__,
537                Evas_Object *obj)
538 {
539    Widget_Data *wd = elm_widget_data_get(obj);
540    if (!wd) return;
541    if (elm_widget_focus_get(obj))
542      {
543         edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
544         evas_object_focus_set(wd->obj, EINA_TRUE);
545         if ((wd->selected) && (!wd->last_selected_item))
546           wd->last_selected_item = eina_list_data_get(wd->selected);
547      }
548    else
549      {
550         edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
551         evas_object_focus_set(wd->obj, EINA_FALSE);
552      }
553 }
554
555 static void
556 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
557 {
558    Widget_Data *wd = elm_widget_data_get(obj);
559    Elm_Gen_Item *it;
560    if (!wd) return;
561    elm_smart_scroller_mirrored_set(wd->scr, rtl);
562    if (!wd->items) return;
563    it = ELM_GEN_ITEM_FROM_INLIST(wd->items);
564
565    while (it)
566      {
567         edje_object_mirrored_set(VIEW(it), rtl);
568         elm_gengrid_item_update(it);
569         it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
570      }
571 }
572
573 static void
574 _theme_hook(Evas_Object *obj)
575 {
576    Widget_Data *wd = elm_widget_data_get(obj);
577    if (!wd) return;
578    _elm_widget_mirrored_reload(obj);
579    _mirrored_set(obj, elm_widget_mirrored_get(obj));
580    elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
581                                        elm_widget_style_get(obj));
582 }
583
584 static void
585 _del_pre_hook(Evas_Object *obj)
586 {
587    Widget_Data *wd = elm_widget_data_get(obj);
588    if (!wd) return;
589    elm_gengrid_clear(obj);
590    evas_object_del(wd->pan_smart);
591    wd->pan_smart = NULL;
592 }
593
594 static void
595 _del_hook(Evas_Object *obj)
596 {
597    Widget_Data *wd = elm_widget_data_get(obj);
598    if (wd->calc_job) ecore_job_del(wd->calc_job);
599    free(wd);
600 }
601
602 static void
603 _signal_emit_hook(Evas_Object *obj,
604                   const char  *emission,
605                   const char  *source)
606 {
607    Widget_Data *wd = elm_widget_data_get(obj);
608    if (!wd) return;
609    edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
610                            emission, source);
611 }
612
613 static void
614 _signal_callback_add_hook(Evas_Object *obj,
615                           const char  *emission,
616                           const char  *source,
617                           Edje_Signal_Cb func_cb,
618                           void *data)
619 {
620    Widget_Data *wd = elm_widget_data_get(obj);
621    if (!wd) return;
622    edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
623                                    emission, source, func_cb, data);
624 }
625
626 static void
627 _signal_callback_del_hook(Evas_Object *obj,
628                           const char  *emission,
629                           const char  *source,
630                           Edje_Signal_Cb func_cb,
631                           void *data)
632 {
633    Widget_Data *wd = elm_widget_data_get(obj);
634    if (!wd) return;
635    edje_object_signal_callback_del_full(elm_smart_scroller_edje_object_get(wd->scr),
636                                         emission, source, func_cb, data);
637 }
638
639 static void
640 _mouse_move(void        *data,
641             Evas *evas   __UNUSED__,
642             Evas_Object *obj,
643             void        *event_info)
644 {
645    Elm_Gen_Item *it = data;
646    Evas_Event_Mouse_Move *ev = event_info;
647    Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
648    Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
649
650    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
651      {
652         if (!it->wd->on_hold)
653           {
654              it->wd->on_hold = EINA_TRUE;
655              if (!it->wd->wasselected)
656                _item_unselect(it);
657           }
658      }
659    if ((it->dragging) && (it->down))
660      {
661         if (it->long_timer)
662           {
663              ecore_timer_del(it->long_timer);
664              it->long_timer = NULL;
665           }
666         evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, it);
667         return;
668      }
669    if ((!it->down) || (it->wd->longpressed))
670      {
671         if (it->long_timer)
672           {
673              ecore_timer_del(it->long_timer);
674              it->long_timer = NULL;
675           }
676         if ((it->wd->reorder_mode) && (it->wd->reorder_it))
677           {
678              evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
679
680              it_scrl_x = ev->cur.canvas.x - it->wd->reorder_it->dx;
681              it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
682
683              if (it_scrl_x < ox) it->wd->reorder_item_x = ox;
684              else if (it_scrl_x + it->wd->item_width > ox + ow)
685                it->wd->reorder_item_x = ox + ow - it->wd->item_width;
686              else it->wd->reorder_item_x = it_scrl_x;
687
688              if (it_scrl_y < oy) it->wd->reorder_item_y = oy;
689              else if (it_scrl_y + it->wd->item_height > oy + oh)
690                it->wd->reorder_item_y = oy + oh - it->wd->item_height;
691              else it->wd->reorder_item_y = it_scrl_y;
692
693              if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
694              it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
695           }
696         return;
697      }
698    if (!it->display_only)
699      elm_coords_finger_size_adjust(1, &minw, 1, &minh);
700    evas_object_geometry_get(obj, &x, &y, NULL, NULL);
701    x = ev->cur.canvas.x - x;
702    y = ev->cur.canvas.y - y;
703    dx = x - it->dx;
704    adx = dx;
705    if (adx < 0) adx = -dx;
706    dy = y - it->dy;
707    ady = dy;
708    if (ady < 0) ady = -dy;
709    minw /= 2;
710    minh /= 2;
711    if ((adx > minw) || (ady > minh))
712      {
713         const char *left_drag, *right_drag;
714         if (!elm_widget_mirrored_get(WIDGET(it)))
715           {
716              left_drag = SIG_DRAG_START_LEFT;
717              right_drag = SIG_DRAG_START_RIGHT;
718           }
719         else
720           {
721              left_drag = SIG_DRAG_START_RIGHT;
722              right_drag = SIG_DRAG_START_LEFT;
723           }
724
725         it->dragging = 1;
726         if (it->long_timer)
727           {
728              ecore_timer_del(it->long_timer);
729              it->long_timer = NULL;
730           }
731         if (!it->wd->wasselected)
732           _item_unselect(it);
733         if (dy < 0)
734           {
735              if (ady > adx)
736                evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_START_UP,
737                                                it);
738              else
739                {
740                   if (dx < 0)
741                     evas_object_smart_callback_call(WIDGET(it),
742                                                     left_drag, it);
743                }
744           }
745         else
746           {
747              if (ady > adx)
748                evas_object_smart_callback_call(WIDGET(it),
749                                                SIG_DRAG_START_DOWN, it);
750              else
751                {
752                   if (dx < 0)
753                     evas_object_smart_callback_call(WIDGET(it),
754                                                     left_drag, it);
755                   else
756                     evas_object_smart_callback_call(WIDGET(it),
757                                                     right_drag, it);
758                }
759           }
760      }
761 }
762
763 static Eina_Bool
764 _long_press(void *data)
765 {
766    Elm_Gen_Item *it = data;
767
768    it->long_timer = NULL;
769    if ((it->disabled) || (it->dragging)) return ECORE_CALLBACK_CANCEL;
770    it->wd->longpressed = EINA_TRUE;
771    evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
772    if (it->wd->reorder_mode)
773      {
774         it->wd->reorder_it = it;
775         evas_object_raise(VIEW(it));
776         elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
777         elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
778         edje_object_signal_emit(VIEW(it), "elm,state,reorder,enabled", "elm");
779      }
780    return ECORE_CALLBACK_CANCEL;
781 }
782
783 static void
784 _mouse_down(void        *data,
785             Evas *evas   __UNUSED__,
786             Evas_Object *obj,
787             void        *event_info)
788 {
789    Elm_Gen_Item *it = data;
790    Evas_Event_Mouse_Down *ev = event_info;
791    Evas_Coord x, y;
792
793    if (ev->button != 1) return;
794    it->down = 1;
795    it->dragging = 0;
796    evas_object_geometry_get(obj, &x, &y, NULL, NULL);
797    it->dx = ev->canvas.x - x;
798    it->dy = ev->canvas.y - y;
799    it->wd->longpressed = EINA_FALSE;
800    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
801    else it->wd->on_hold = EINA_FALSE;
802    if (it->wd->on_hold) return;
803    it->wd->wasselected = it->selected;
804    _item_highlight(it);
805    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
806      {
807         evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
808         evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
809      }
810    if (it->long_timer) ecore_timer_del(it->long_timer);
811    if (it->realized)
812      it->long_timer = ecore_timer_add(_elm_config->longpress_timeout,
813                                         _long_press, it);
814    else
815      it->long_timer = NULL;
816 }
817
818 static void
819 _mouse_up(void            *data,
820           Evas *evas       __UNUSED__,
821           Evas_Object *obj __UNUSED__,
822           void            *event_info)
823 {
824    Elm_Gen_Item *it = data;
825    Evas_Event_Mouse_Up *ev = event_info;
826    Eina_Bool dragged = EINA_FALSE;
827
828    if (ev->button != 1) return;
829    it->down = EINA_FALSE;
830    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
831    else it->wd->on_hold = EINA_FALSE;
832    if (it->long_timer)
833      {
834         ecore_timer_del(it->long_timer);
835         it->long_timer = NULL;
836      }
837    if (it->dragging)
838      {
839         it->dragging = EINA_FALSE;
840         evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, it);
841         dragged = EINA_TRUE;
842      }
843    if (it->wd->on_hold)
844      {
845         it->wd->longpressed = EINA_FALSE;
846         it->wd->on_hold = EINA_FALSE;
847         return;
848      }
849    if ((it->wd->reorder_mode) && (it->wd->reorder_it))
850      {
851         evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it->wd->reorder_it);
852         it->wd->reorder_it = NULL;
853         it->wd->move_effect_enabled = EINA_FALSE;
854         if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
855           it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
856
857         elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
858         elm_smart_scroller_bounce_allow_set(it->wd->scr, it->wd->h_bounce, it->wd->v_bounce);
859         edje_object_signal_emit(VIEW(it), "elm,state,reorder,disabled", "elm");
860      }
861    if (it->wd->longpressed)
862      {
863         it->wd->longpressed = EINA_FALSE;
864         if (!it->wd->wasselected) _item_unselect(it);
865         it->wd->wasselected = EINA_FALSE;
866         return;
867      }
868    if (dragged)
869      {
870         if (it->want_unrealize)
871           _elm_genlist_item_unrealize(it, EINA_FALSE);
872      }
873    if ((it->disabled) || (dragged)) return;
874    if (it->wd->multi)
875      {
876         if (!it->selected)
877           {
878              _item_highlight(it);
879              it->sel_cb(it);
880           }
881         else _item_unselect(it);
882      }
883    else
884      {
885         if (!it->selected)
886           {
887              while (it->wd->selected)
888                _item_unselect(it->wd->selected->data);
889           }
890         else
891           {
892              const Eina_List *l, *l_next;
893              Elm_Gen_Item *item2;
894
895              EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, item2)
896                 if (item2 != it) _item_unselect(item2);
897           }
898         _item_highlight(it);
899         it->sel_cb(it);
900      }
901 }
902
903 static void
904 _item_highlight(Elm_Gen_Item *it)
905 {
906    if ((it->wd->no_select) || (it->generation < it->wd->generation) || (it->highlighted)) return;
907    edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
908    it->highlighted = EINA_TRUE;
909 }
910
911 static void
912 _item_realize(Elm_Gen_Item *it)
913 {
914    char buf[1024];
915    char style[1024];
916
917    if ((it->realized) || (it->generation < it->wd->generation)) return;
918    VIEW(it) = edje_object_add(evas_object_evas_get(WIDGET(it)));
919    edje_object_scale_set(VIEW(it), elm_widget_scale_get(WIDGET(it)) *
920                          _elm_config->scale);
921    edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(WIDGET(it)));
922    evas_object_smart_member_add(VIEW(it), it->wd->pan_smart);
923    elm_widget_sub_object_add(WIDGET(it), VIEW(it));
924    snprintf(style, sizeof(style), "item/%s",
925             it->itc->item_style ? it->itc->item_style : "default");
926    _elm_theme_object_set(WIDGET(it), VIEW(it), "gengrid", style,
927                          elm_widget_style_get(WIDGET(it)));
928    it->spacer =
929       evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
930    evas_object_color_set(it->spacer, 0, 0, 0, 0);
931    elm_widget_sub_object_add(WIDGET(it), it->spacer);
932    evas_object_size_hint_min_set(it->spacer, 2 * _elm_config->scale, 1);
933    edje_object_part_swallow(VIEW(it), "elm.swallow.pad", it->spacer);
934
935    if (it->itc->func.text_get)
936      {
937         const Eina_List *l;
938         const char *key;
939
940         it->texts =
941            elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
942                                                           "texts"));
943         EINA_LIST_FOREACH(it->texts, l, key)
944           {
945              char *s = it->itc->func.text_get
946                 ((void *)it->base.data, WIDGET(it), key);
947              if (s)
948                {
949                   edje_object_part_text_set(VIEW(it), key, s);
950                   free(s);
951                }
952           }
953      }
954
955    if (it->itc->func.content_get)
956      {
957         const Eina_List *l;
958         const char *key;
959         Evas_Object *ic = NULL;
960
961         it->contents =
962            elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
963                                                           "contents"));
964         EINA_LIST_FOREACH(it->contents, l, key)
965           {
966              if (it->itc->func.content_get)
967                ic = it->itc->func.content_get
968                   ((void *)it->base.data, WIDGET(it), key);
969              if (ic)
970                {
971                   it->content_objs = eina_list_append(it->content_objs, ic);
972                   edje_object_part_swallow(VIEW(it), key, ic);
973                   evas_object_show(ic);
974                   elm_widget_sub_object_add(WIDGET(it), ic);
975                }
976           }
977      }
978
979    if (it->itc->func.state_get)
980      {
981         const Eina_List *l;
982         const char *key;
983
984         it->states =
985            elm_widget_stringlist_get(edje_object_data_get(VIEW(it),
986                                                           "states"));
987         EINA_LIST_FOREACH(it->states, l, key)
988           {
989              Eina_Bool on = it->itc->func.state_get
990                 ((void *)it->base.data, WIDGET(it), l->data);
991              if (on)
992                {
993                   snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
994                   edje_object_signal_emit(VIEW(it), buf, "elm");
995                }
996           }
997      }
998
999    if (it->group)
1000      {
1001         if ((!it->wd->group_item_width) && (!it->wd->group_item_height))
1002           {
1003              edje_object_size_min_restricted_calc(VIEW(it),
1004                                                   &it->wd->group_item_width,
1005                                                   &it->wd->group_item_height,
1006                                                   it->wd->group_item_width,
1007                                                   it->wd->group_item_height);
1008           }
1009      }
1010    else
1011      {
1012         if ((!it->wd->item_width) && (!it->wd->item_height))
1013           {
1014              edje_object_size_min_restricted_calc(VIEW(it),
1015                                                   &it->wd->item_width,
1016                                                   &it->wd->item_height,
1017                                                   it->wd->item_width,
1018                                                   it->wd->item_height);
1019              elm_coords_finger_size_adjust(1, &it->wd->item_width,
1020                                            1, &it->wd->item_height);
1021           }
1022
1023         evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1024                                        _mouse_down, it);
1025         evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1026                                        _mouse_up, it);
1027         evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1028                                        _mouse_move, it);
1029
1030         if (it->selected)
1031           edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
1032         if (it->disabled)
1033           edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
1034      }
1035    evas_object_show(VIEW(it));
1036
1037    if (it->tooltip.content_cb)
1038      {
1039         elm_widget_item_tooltip_content_cb_set(it,
1040                                                it->tooltip.content_cb,
1041                                                it->tooltip.data, NULL);
1042         elm_widget_item_tooltip_style_set(it, it->tooltip.style);
1043         elm_widget_item_tooltip_window_mode_set(it, it->tooltip.free_size);
1044      }
1045
1046    if (it->mouse_cursor)
1047      elm_widget_item_cursor_set(it, it->mouse_cursor);
1048
1049    it->realized = EINA_TRUE;
1050    it->want_unrealize = EINA_FALSE;
1051 }
1052
1053 static void
1054 _item_unrealize_cb(Elm_Gen_Item *it)
1055 {
1056    evas_object_del(VIEW(it));
1057    VIEW(it) = NULL;
1058    evas_object_del(it->spacer);
1059    it->spacer = NULL;
1060 }
1061
1062 static Eina_Bool
1063 _reorder_item_moving_effect_timer_cb(void *data)
1064 {
1065    Elm_Gen_Item *it = data;
1066    double time, t;
1067    Evas_Coord dx, dy;
1068
1069    time = REORDER_EFFECT_TIME;
1070    t = ((0.0 > (t = ecore_loop_time_get()-it->item->moving_effect_start_time)) ? 0.0 : t);
1071    dx = ((it->item->tx - it->item->ox) / 10) * _elm_config->scale;
1072    dy = ((it->item->ty - it->item->oy) / 10) * _elm_config->scale;
1073
1074    if (t <= time)
1075      {
1076         it->item->rx += (1 * sin((t / time) * (M_PI / 2)) * dx);
1077         it->item->ry += (1 * sin((t / time) * (M_PI / 2)) * dy);
1078      }
1079    else
1080      {
1081         it->item->rx += dx;
1082         it->item->ry += dy;
1083      }
1084
1085    if ((((dx > 0) && (it->item->rx >= it->item->tx)) || ((dx <= 0) && (it->item->rx <= it->item->tx))) &&
1086        (((dy > 0) && (it->item->ry >= it->item->ty)) || ((dy <= 0) && (it->item->ry <= it->item->ty))))
1087      {
1088         evas_object_move(VIEW(it), it->item->tx, it->item->ty);
1089         if (it->group)
1090           {
1091              Evas_Coord vw, vh;
1092              evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1093              if (it->wd->horizontal)
1094                evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1095              else
1096                evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1097           }
1098         else
1099           evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1100         it->item->moving = EINA_FALSE;
1101         it->item->item_moving_effect_timer = NULL;
1102         return ECORE_CALLBACK_CANCEL;
1103      }
1104
1105    evas_object_move(VIEW(it), it->item->rx, it->item->ry);
1106    if (it->group)
1107      {
1108         Evas_Coord vw, vh;
1109         evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &vw, &vh);
1110         if (it->wd->horizontal)
1111           evas_object_resize(VIEW(it), it->wd->group_item_width, vh);
1112         else
1113           evas_object_resize(VIEW(it), vw, it->wd->group_item_height);
1114      }
1115    else
1116      evas_object_resize(VIEW(it), it->wd->item_width, it->wd->item_height);
1117
1118    return ECORE_CALLBACK_RENEW;
1119 }
1120
1121 static void
1122 _group_item_place(Pan *sd)
1123 {
1124    Evas_Coord iw, ih, vw, vh;
1125    Eina_List *l;
1126    Eina_Bool was_realized;
1127    Elm_Gen_Item *it;
1128    evas_object_geometry_get(sd->wd->pan_smart, NULL, NULL, &vw, &vh);
1129    if (sd->wd->horizontal)
1130      {
1131         iw = sd->wd->group_item_width;
1132         ih = vh;
1133      }
1134    else
1135      {
1136         iw = vw;
1137         ih = sd->wd->group_item_height;
1138      }
1139    EINA_LIST_FOREACH(sd->wd->group_items, l, it)
1140      {
1141         was_realized = it->realized;
1142         if (it->item->group_realized)
1143           {
1144              _item_realize(it);
1145              if (!was_realized)
1146                evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1147              evas_object_move(VIEW(it), it->item->gx, it->item->gy);
1148              evas_object_resize(VIEW(it), iw, ih);
1149              evas_object_raise(VIEW(it));
1150           }
1151         else
1152           _elm_genlist_item_unrealize(it, EINA_FALSE);
1153      }
1154 }
1155
1156
1157 static void
1158 _item_place(Elm_Gen_Item *it,
1159             Evas_Coord        cx,
1160             Evas_Coord        cy)
1161 {
1162    Evas_Coord x, y, ox, oy, cvx, cvy, cvw, cvh, iw, ih, ww;
1163    Evas_Coord tch, tcw, alignw = 0, alignh = 0, vw, vh;
1164    Eina_Bool reorder_item_move_forward = EINA_FALSE;
1165    long items_count;
1166    it->x = cx;
1167    it->y = cy;
1168    evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &vw, &vh);
1169
1170    /* Preload rows/columns at each side of the Gengrid */
1171    cvx = ox - PRELOAD * it->wd->item_width;
1172    cvy = oy - PRELOAD * it->wd->item_height;
1173    cvw = vw + 2 * PRELOAD * it->wd->item_width;
1174    cvh = vh + 2 * PRELOAD * it->wd->item_height;
1175
1176    alignh = 0;
1177    alignw = 0;
1178
1179    items_count = it->wd->count - eina_list_count(it->wd->group_items) + it->wd->items_lost;
1180    if (it->wd->horizontal)
1181      {
1182         int columns, items_visible = 0, items_row;
1183
1184         if (it->wd->item_height > 0)
1185           items_visible = vh / it->wd->item_height;
1186         if (items_visible < 1)
1187           items_visible = 1;
1188
1189         columns = items_count / items_visible;
1190         if (items_count % items_visible)
1191           columns++;
1192
1193         tcw = (it->wd->item_width * columns) + (it->wd->group_item_width * eina_list_count(it->wd->group_items));
1194         alignw = (vw - tcw) * it->wd->align_x;
1195
1196         items_row = items_visible;
1197         if (items_row > it->wd->count)
1198           items_row = it->wd->count;
1199          if (it->wd->filled
1200              && (unsigned int)it->wd->nmax > (unsigned int)it->wd->count)
1201            tch = it->wd->nmax * it->wd->item_height;
1202          else
1203            tch = items_row * it->wd->item_height;
1204         alignh = (vh - tch) * it->wd->align_y;
1205      }
1206    else
1207      {
1208         int rows, items_visible = 0, items_col;
1209
1210         if (it->wd->item_width > 0)
1211           items_visible = vw / it->wd->item_width;
1212         if (items_visible < 1)
1213           items_visible = 1;
1214
1215         rows = items_count / items_visible;
1216         if (items_count % items_visible)
1217           rows++;
1218
1219         tch = (it->wd->item_height * rows) + (it->wd->group_item_height * eina_list_count(it->wd->group_items));
1220         alignh = (vh - tch) * it->wd->align_y;
1221
1222         items_col = items_visible;
1223         if (items_col > it->wd->count)
1224           items_col = it->wd->count;
1225          if (it->wd->filled
1226              && (unsigned int)it->wd->nmax > (unsigned int)it->wd->count)
1227            tcw = it->wd->nmax * it->wd->item_width;
1228          else
1229            tcw = items_col * it->wd->item_width;
1230         alignw = (vw - tcw) * it->wd->align_x;
1231      }
1232
1233    if (it->group)
1234      {
1235         if (it->wd->horizontal)
1236           {
1237              x = (((cx - it->item->prev_group) * it->wd->item_width) + (it->item->prev_group * it->wd->group_item_width)) - it->wd->pan_x + ox + alignw;
1238              y = oy;
1239              iw = it->wd->group_item_width;
1240              ih = vh;
1241           }
1242         else
1243           {
1244              x = ox;
1245              y = (((cy - it->item->prev_group) * it->wd->item_height) + (it->item->prev_group * it->wd->group_item_height)) - it->wd->pan_y + oy + alignh;
1246              iw = vw;
1247              ih = it->wd->group_item_height;
1248           }
1249         it->item->gx = x;
1250         it->item->gy = y;
1251      }
1252    else
1253      {
1254         if (it->wd->horizontal)
1255           {
1256              x = (((cx - it->item->prev_group) * it->wd->item_width) + (it->item->prev_group * it->wd->group_item_width)) - it->wd->pan_x + ox + alignw;
1257              y = (cy * it->wd->item_height) - it->wd->pan_y + oy + alignh;
1258           }
1259         else
1260           {
1261              x = (cx * it->wd->item_width) - it->wd->pan_x + ox + alignw;
1262              y = (((cy - it->item->prev_group) * it->wd->item_height) + (it->item->prev_group * it->wd->group_item_height)) - it->wd->pan_y + oy + alignh;
1263           }
1264         if (elm_widget_mirrored_get(WIDGET(it)))
1265           {  /* Switch items side and componsate for pan_x when in RTL mode */
1266              evas_object_geometry_get(WIDGET(it), NULL, NULL, &ww, NULL);
1267              x = ww - x - it->wd->item_width - it->wd->pan_x - it->wd->pan_x;
1268           }
1269         iw = it->wd->item_width;
1270         ih = it->wd->item_height;
1271      }
1272
1273    Eina_Bool was_realized = it->realized;
1274    if (ELM_RECTS_INTERSECT(x, y, iw, ih, cvx, cvy, cvw, cvh))
1275      {
1276         _item_realize(it);
1277         if (!was_realized)
1278           evas_object_smart_callback_call(WIDGET(it), SIG_REALIZED, it);
1279         if (it->parent)
1280           {
1281              if (it->wd->horizontal)
1282                {
1283                   if (it->parent->item->gx < ox)
1284                     {
1285                        it->parent->item->gx = x + it->wd->item_width - it->wd->group_item_width;
1286                        if (it->parent->item->gx > ox)
1287                          it->parent->item->gx = ox;
1288                     }
1289                   it->parent->item->group_realized = EINA_TRUE;
1290                }
1291              else
1292                {
1293                   if (it->parent->item->gy < oy)
1294                     {
1295                        it->parent->item->gy = y + it->wd->item_height - it->wd->group_item_height;
1296                        if (it->parent->item->gy > oy)
1297                          it->parent->item->gy = oy;
1298                     }
1299                   it->parent->item->group_realized = EINA_TRUE;
1300                }
1301           }
1302         if (it->wd->reorder_mode)
1303           {
1304              if (it->wd->reorder_it)
1305                {
1306                   if (it->item->moving) return;
1307
1308                   if (!it->wd->move_effect_enabled)
1309                     {
1310                        it->item->ox = x;
1311                        it->item->oy = y;
1312                     }
1313                   if (it->wd->reorder_it == it)
1314                     {
1315                        evas_object_move(VIEW(it),
1316                                         it->wd->reorder_item_x, it->wd->reorder_item_y);
1317                        evas_object_resize(VIEW(it), iw, ih);
1318                        return;
1319                     }
1320                   else
1321                     {
1322                        if (it->wd->move_effect_enabled)
1323                          {
1324                             if ((it->item->ox != x) || (it->item->oy != y))
1325                               {
1326                                  if (((it->wd->old_pan_x == it->wd->pan_x) && (it->wd->old_pan_y == it->wd->pan_y)) ||
1327                                      ((it->wd->old_pan_x != it->wd->pan_x) && !(it->item->ox - it->wd->pan_x + it->wd->old_pan_x == x)) ||
1328                                      ((it->wd->old_pan_y != it->wd->pan_y) && !(it->item->oy - it->wd->pan_y + it->wd->old_pan_y == y)))
1329                                    {
1330                                       it->item->tx = x;
1331                                       it->item->ty = y;
1332                                       it->item->rx = it->item->ox;
1333                                       it->item->ry = it->item->oy;
1334                                       it->item->moving = EINA_TRUE;
1335                                       it->item->moving_effect_start_time = ecore_loop_time_get();
1336                                       it->item->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
1337                                       return;
1338                                    }
1339                               }
1340                          }
1341
1342                        /* need fix here */
1343                        Evas_Coord nx, ny, nw, nh;
1344                        if (it->group)
1345                          {
1346                             if (it->wd->horizontal)
1347                               {
1348                                  nx = x + (it->wd->group_item_width / 2);
1349                                  ny = y;
1350                                  nw = 1;
1351                                  nh = vh;
1352                               }
1353                             else
1354                               {
1355                                  nx = x;
1356                                  ny = y + (it->wd->group_item_height / 2);
1357                                  nw = vw;
1358                                  nh = 1;
1359                               }
1360                          }
1361                        else
1362                          {
1363                             nx = x + (it->wd->item_width / 2);
1364                             ny = y + (it->wd->item_height / 2);
1365                             nw = 1;
1366                             nh = 1;
1367                          }
1368
1369                        if ( ELM_RECTS_INTERSECT(it->wd->reorder_item_x, it->wd->reorder_item_y,
1370                                                 it->wd->item_width, it->wd->item_height,
1371                                                 nx, ny, nw, nh))
1372                          {
1373                             if (it->wd->horizontal)
1374                               {
1375                                  if ((it->wd->nmax * it->wd->reorder_it->x + it->wd->reorder_it->y) >
1376                                      (it->wd->nmax * it->x + it->y))
1377                                    reorder_item_move_forward = EINA_TRUE;
1378                               }
1379                             else
1380                               {
1381                                  if ((it->wd->nmax * it->wd->reorder_it->y + it->wd->reorder_it->x) >
1382                                      (it->wd->nmax * it->y + it->x))
1383                                    reorder_item_move_forward = EINA_TRUE;
1384                               }
1385
1386                             it->wd->items = eina_inlist_remove(it->wd->items,
1387                                                                  EINA_INLIST_GET(it->wd->reorder_it));
1388                             if (reorder_item_move_forward)
1389                               it->wd->items = eina_inlist_prepend_relative(it->wd->items,
1390                                                                              EINA_INLIST_GET(it->wd->reorder_it),
1391                                                                              EINA_INLIST_GET(it));
1392                             else
1393                               it->wd->items = eina_inlist_append_relative(it->wd->items,
1394                                                                             EINA_INLIST_GET(it->wd->reorder_it),
1395                                                                             EINA_INLIST_GET(it));
1396
1397                             it->wd->reorder_item_changed = EINA_TRUE;
1398                             it->wd->move_effect_enabled = EINA_TRUE;
1399                             if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1400                               it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1401
1402                             return;
1403                          }
1404                     }
1405                }
1406              else if (it->item->item_moving_effect_timer)
1407                {
1408                   ecore_animator_del(it->item->item_moving_effect_timer);
1409                   it->item->item_moving_effect_timer = NULL;
1410                   it->item->moving = EINA_FALSE;
1411                }
1412           }
1413         if (!it->group)
1414           {
1415              evas_object_move(VIEW(it), x, y);
1416              evas_object_resize(VIEW(it), iw, ih);
1417           }
1418         else
1419           it->item->group_realized = EINA_TRUE;
1420      }
1421    else
1422      {
1423         if (!it->group)
1424           _elm_genlist_item_unrealize(it, EINA_FALSE);
1425         else
1426           it->item->group_realized = EINA_FALSE;
1427      }
1428 }
1429
1430 static void
1431 _item_del(Elm_Gen_Item *it)
1432 {
1433    Evas_Object *obj = WIDGET(it);
1434
1435    evas_event_freeze(evas_object_evas_get(obj));
1436    it->wd->selected = eina_list_remove(it->wd->selected, it);
1437    if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
1438    it->wd->count--;
1439    _elm_genlist_item_del_serious(it);
1440    evas_event_thaw(evas_object_evas_get(obj));
1441    evas_event_thaw_eval(evas_object_evas_get(obj));
1442 }
1443
1444 static void
1445 _item_unselect(Elm_Gen_Item *it)
1446 {
1447    if ((it->generation < it->wd->generation) || (!it->highlighted)) return;
1448    edje_object_signal_emit(VIEW(it), "elm,state,unselected", "elm");
1449    it->highlighted = EINA_FALSE;
1450    if (it->selected)
1451      {
1452         it->selected = EINA_FALSE;
1453         it->wd->selected = eina_list_remove(it->wd->selected, it);
1454         evas_object_smart_callback_call(WIDGET(it), SIG_UNSELECTED, it);
1455      }
1456 }
1457
1458 static void
1459 _calc_job(void *data)
1460 {
1461    Widget_Data *wd = data;
1462    Evas_Coord minw = 0, minh = 0, nmax = 0, cvw, cvh;
1463    Elm_Gen_Item *it, *group_item = NULL;
1464    int count_group = 0;
1465    long count = 0;
1466    wd->items_lost = 0;
1467
1468    evas_object_geometry_get(wd->pan_smart, NULL, NULL, &cvw, &cvh);
1469    if ((cvw != 0) || (cvh != 0))
1470      {
1471         if ((wd->horizontal) && (wd->item_height > 0))
1472           nmax = cvh / wd->item_height;
1473         else if (wd->item_width > 0)
1474           nmax = cvw / wd->item_width;
1475
1476         if (nmax < 1)
1477           nmax = 1;
1478
1479         EINA_INLIST_FOREACH(wd->items, it)
1480           {
1481              if (it->item->prev_group != count_group)
1482                it->item->prev_group = count_group;
1483              if (it->group)
1484                {
1485                   count = count % nmax;
1486                   if (count)
1487                     wd->items_lost += nmax - count;
1488                   //printf("%d items and I lost %d\n", count, wd->items_lost);
1489                   count_group++;
1490                   if (count) count = 0;
1491                   group_item = it;
1492                }
1493              else
1494                {
1495                   if (it->parent != group_item)
1496                     it->parent = group_item;
1497                   count++;
1498                }
1499           }
1500         count = wd->count + wd->items_lost - count_group;
1501         if (wd->horizontal)
1502           {
1503              minw = (ceil(count / (float)nmax) * wd->item_width) + (count_group * wd->group_item_width);
1504              minh = nmax * wd->item_height;
1505           }
1506         else
1507           {
1508              minw = nmax * wd->item_width;
1509              minh = (ceil(count / (float)nmax) * wd->item_height) + (count_group * wd->group_item_height);
1510           }
1511
1512         if ((minw != wd->minw) || (minh != wd->minh))
1513           {
1514              wd->minh = minh;
1515              wd->minw = minw;
1516              evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1517           }
1518
1519         wd->nmax = nmax;
1520         evas_object_smart_changed(wd->pan_smart);
1521      }
1522    wd->calc_job = NULL;
1523 }
1524
1525 static void
1526 _pan_add(Evas_Object *obj)
1527 {
1528    Pan *sd;
1529    Evas_Object_Smart_Clipped_Data *cd;
1530
1531    _pan_sc.add(obj);
1532    cd = evas_object_smart_data_get(obj);
1533    sd = ELM_NEW(Pan);
1534    if (!sd) return;
1535    sd->__clipped_data = *cd;
1536    free(cd);
1537    evas_object_smart_data_set(obj, sd);
1538 }
1539
1540 static void
1541 _pan_del(Evas_Object *obj)
1542 {
1543    Pan *sd = evas_object_smart_data_get(obj);
1544
1545    if (!sd) return;
1546    _pan_sc.del(obj);
1547 }
1548
1549 static void
1550 _pan_set(Evas_Object *obj,
1551          Evas_Coord   x,
1552          Evas_Coord   y)
1553 {
1554    Pan *sd = evas_object_smart_data_get(obj);
1555    if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1556    sd->wd->pan_x = x;
1557    sd->wd->pan_y = y;
1558    evas_object_smart_changed(obj);
1559 }
1560
1561 static void
1562 _pan_get(Evas_Object *obj,
1563          Evas_Coord  *x,
1564          Evas_Coord  *y)
1565 {
1566    Pan *sd = evas_object_smart_data_get(obj);
1567    if (x) *x = sd->wd->pan_x;
1568    if (y) *y = sd->wd->pan_y;
1569 }
1570
1571 static void
1572 _pan_child_size_get(Evas_Object *obj,
1573                     Evas_Coord  *w,
1574                     Evas_Coord  *h)
1575 {
1576    Pan *sd = evas_object_smart_data_get(obj);
1577    if (w) *w = sd->wd->minw;
1578    if (h) *h = sd->wd->minh;
1579 }
1580
1581 static void
1582 _pan_max_get(Evas_Object *obj,
1583              Evas_Coord  *x,
1584              Evas_Coord  *y)
1585 {
1586    Pan *sd = evas_object_smart_data_get(obj);
1587    Evas_Coord ow, oh;
1588
1589    if (!sd) return;
1590    evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1591    if (x)
1592      *x = (ow < sd->wd->minw) ? sd->wd->minw - ow : 0;
1593    if (y)
1594      *y = (oh < sd->wd->minh) ? sd->wd->minh - oh : 0;
1595 }
1596
1597 static void
1598 _pan_min_get(Evas_Object *obj,
1599              Evas_Coord  *x,
1600              Evas_Coord  *y)
1601 {
1602    Pan *sd = evas_object_smart_data_get(obj);
1603    Evas_Coord mx, my;
1604
1605    if (!sd) return;
1606    _pan_max_get(obj, &mx, &my);
1607    if (x)
1608      *x = -mx * sd->wd->align_x;
1609    if (y)
1610      *y = -my * sd->wd->align_y;
1611 }
1612
1613 static void
1614 _pan_resize(Evas_Object *obj,
1615             Evas_Coord   w,
1616             Evas_Coord   h)
1617 {
1618    Pan *sd = evas_object_smart_data_get(obj);
1619    Evas_Coord ow, oh;
1620
1621    evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1622    if ((ow == w) && (oh == h)) return;
1623    if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1624    sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1625 }
1626
1627 static void
1628 _pan_calculate(Evas_Object *obj)
1629 {
1630    Pan *sd = evas_object_smart_data_get(obj);
1631    Evas_Coord cx = 0, cy = 0;
1632    Elm_Gen_Item *it;
1633
1634    if (!sd) return;
1635    if (!sd->wd->nmax) return;
1636
1637    sd->wd->reorder_item_changed = EINA_FALSE;
1638
1639    EINA_INLIST_FOREACH(sd->wd->items, it)
1640      {
1641         if (it->group)
1642           {
1643              if (sd->wd->horizontal)
1644                {
1645                   if (cy)
1646                     {
1647                        cx++;
1648                        cy = 0;
1649                     }
1650                }
1651              else
1652                {
1653                   if (cx)
1654                     {
1655                        cx = 0;
1656                        cy++;
1657                     }
1658                }
1659           }
1660         _item_place(it, cx, cy);
1661         if (sd->wd->reorder_item_changed) return;
1662         if (it->group)
1663           {
1664              if (sd->wd->horizontal)
1665                {
1666                   cx++;
1667                   cy = 0;
1668                }
1669              else
1670                {
1671                   cx = 0;
1672                   cy++;
1673                }
1674           }
1675         else
1676           {
1677              if (sd->wd->horizontal)
1678                {
1679                   cy = (cy + 1) % sd->wd->nmax;
1680                   if (!cy) cx++;
1681                }
1682              else
1683                {
1684                   cx = (cx + 1) % sd->wd->nmax;
1685                   if (!cx) cy++;
1686                }
1687           }
1688      }
1689    _group_item_place(sd);
1690
1691
1692    if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
1693      {
1694         if (!sd->wd->reorder_item_changed)
1695           {
1696              sd->wd->old_pan_x = sd->wd->pan_x;
1697              sd->wd->old_pan_y = sd->wd->pan_y;
1698           }
1699         sd->wd->move_effect_enabled = EINA_FALSE;
1700      }
1701    evas_object_smart_callback_call(sd->wd->obj, SIG_CHANGED, NULL);
1702 }
1703
1704 static void
1705 _pan_move(Evas_Object *obj,
1706           Evas_Coord x __UNUSED__,
1707           Evas_Coord y __UNUSED__)
1708 {
1709    Pan *sd = evas_object_smart_data_get(obj);
1710    if (!sd) return;
1711    if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1712    sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1713 }
1714
1715 static void
1716 _hold_on(void *data       __UNUSED__,
1717          Evas_Object     *obj,
1718          void *event_info __UNUSED__)
1719 {
1720    Widget_Data *wd = elm_widget_data_get(obj);
1721    if (!wd) return;
1722    elm_smart_scroller_hold_set(wd->scr, 1);
1723 }
1724
1725 static void
1726 _hold_off(void *data       __UNUSED__,
1727           Evas_Object     *obj,
1728           void *event_info __UNUSED__)
1729 {
1730    Widget_Data *wd = elm_widget_data_get(obj);
1731    if (!wd) return;
1732    elm_smart_scroller_hold_set(wd->scr, 0);
1733 }
1734
1735 static void
1736 _freeze_on(void *data       __UNUSED__,
1737            Evas_Object     *obj,
1738            void *event_info __UNUSED__)
1739 {
1740    Widget_Data *wd = elm_widget_data_get(obj);
1741    if (!wd) return;
1742    elm_smart_scroller_freeze_set(wd->scr, 1);
1743 }
1744
1745 static void
1746 _freeze_off(void *data       __UNUSED__,
1747             Evas_Object     *obj,
1748             void *event_info __UNUSED__)
1749 {
1750    Widget_Data *wd = elm_widget_data_get(obj);
1751    if (!wd) return;
1752    elm_smart_scroller_freeze_set(wd->scr, 0);
1753 }
1754
1755 static void
1756 _scr_anim_start(void        *data,
1757                 Evas_Object *obj __UNUSED__,
1758                 void        *event_info __UNUSED__)
1759 {
1760    evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
1761 }
1762
1763 static void
1764 _scr_anim_stop(void        *data,
1765                 Evas_Object *obj __UNUSED__,
1766                 void        *event_info __UNUSED__)
1767 {
1768    evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
1769 }
1770
1771 static void
1772 _scr_drag_start(void            *data,
1773                 Evas_Object *obj __UNUSED__,
1774                 void *event_info __UNUSED__)
1775 {
1776    evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1777 }
1778
1779 static void
1780 _scr_drag_stop(void            *data,
1781                Evas_Object *obj __UNUSED__,
1782                void *event_info __UNUSED__)
1783 {
1784    evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1785 }
1786
1787 static void
1788 _edge_left(void        *data,
1789            Evas_Object *scr __UNUSED__,
1790            void        *event_info __UNUSED__)
1791 {
1792    evas_object_smart_callback_call(data, SIG_EDGE_LEFT, NULL);
1793 }
1794
1795 static void
1796 _edge_right(void        *data,
1797             Evas_Object *scr __UNUSED__,
1798             void        *event_info __UNUSED__)
1799 {
1800    evas_object_smart_callback_call(data, SIG_EDGE_RIGHT, NULL);
1801 }
1802
1803 static void
1804 _edge_top(void        *data,
1805           Evas_Object *scr __UNUSED__,
1806           void        *event_info __UNUSED__)
1807 {
1808    evas_object_smart_callback_call(data, SIG_EDGE_TOP, NULL);
1809 }
1810
1811 static void
1812 _edge_bottom(void        *data,
1813              Evas_Object *scr __UNUSED__,
1814              void        *event_info __UNUSED__)
1815 {
1816    evas_object_smart_callback_call(data, SIG_EDGE_BOTTOM, NULL);
1817 }
1818
1819 static void
1820 _scr_scroll(void            *data,
1821             Evas_Object *obj __UNUSED__,
1822             void *event_info __UNUSED__)
1823 {
1824    evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1825 }
1826
1827 static int
1828 _elm_gengrid_item_compare_data(const void *data, const void *data1)
1829 {
1830    const Elm_Gen_Item *it = data;
1831    const Elm_Gen_Item *item1 = data1;
1832
1833    return it->wd->item_compare_data_cb(it->base.data, item1->base.data);
1834 }
1835
1836 static int
1837 _elm_gengrid_item_compare(const void *data, const void *data1)
1838 {
1839    Elm_Gen_Item *it, *item1;
1840    it = ELM_GEN_ITEM_FROM_INLIST(data);
1841    item1 = ELM_GEN_ITEM_FROM_INLIST(data1);
1842    return it->wd->item_compare_cb(it, item1);
1843 }
1844
1845 static Elm_Gen_Item *
1846 _item_new(Widget_Data                  *wd,
1847           const Elm_Gengrid_Item_Class *itc,
1848           const void                   *data,
1849           Evas_Smart_Cb                 func,
1850           const void                   *func_data)
1851 {
1852    Elm_Gen_Item *it;
1853
1854    it = _elm_genlist_item_new(wd, itc, data, NULL, func, func_data);
1855    if (!it) return NULL;
1856    it->item = ELM_NEW(Elm_Gen_Item_Type);
1857    wd->count++;
1858    it->group = it->itc->item_style && (!strcmp(it->itc->item_style, "group_index"));
1859    ELM_GEN_ITEM_SETUP(it);
1860
1861    return it;
1862 }
1863
1864 EAPI Evas_Object *
1865 elm_gengrid_add(Evas_Object *parent)
1866 {
1867    Evas_Object *obj;
1868    Evas *e;
1869    Widget_Data *wd;
1870    static Evas_Smart *smart = NULL;
1871    Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1872
1873    if (!smart)
1874      {
1875         static Evas_Smart_Class sc;
1876
1877         evas_object_smart_clipped_smart_set(&_pan_sc);
1878         sc = _pan_sc;
1879         sc.name = "elm_gengrid_pan";
1880         sc.version = EVAS_SMART_CLASS_VERSION;
1881         sc.add = _pan_add;
1882         sc.del = _pan_del;
1883         sc.resize = _pan_resize;
1884         sc.move = _pan_move;
1885         sc.calculate = _pan_calculate;
1886         if (!(smart = evas_smart_class_new(&sc))) return NULL;
1887      }
1888
1889    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1890
1891    ELM_SET_WIDTYPE(widtype, "gengrid");
1892    ELM_GEN_SETUP(wd);
1893    elm_widget_type_set(obj, "gengrid");
1894    elm_widget_sub_object_add(parent, obj);
1895    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1896    elm_widget_data_set(obj, wd);
1897    elm_widget_del_hook_set(obj, _del_hook);
1898    elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1899    elm_widget_theme_hook_set(obj, _theme_hook);
1900    elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1901    elm_widget_can_focus_set(obj, EINA_TRUE);
1902    elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
1903    elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
1904    elm_widget_event_hook_set(obj, _event_hook);
1905
1906    wd->generation = 1;
1907    wd->scr = elm_smart_scroller_add(e);
1908    elm_smart_scroller_widget_set(wd->scr, obj);
1909    elm_smart_scroller_object_theme_set(obj, wd->scr, "gengrid", "base",
1910                                        "default");
1911    elm_smart_scroller_bounce_allow_set(wd->scr, bounce,
1912                                        _elm_config->thumbscroll_bounce_enable);
1913    elm_widget_resize_object_set(obj, wd->scr);
1914
1915    evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
1916    evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
1917    evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1918    evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1919    evas_object_smart_callback_add(wd->scr, "edge,left", _edge_left, obj);
1920    evas_object_smart_callback_add(wd->scr, "edge,right", _edge_right, obj);
1921    evas_object_smart_callback_add(wd->scr, "edge,top", _edge_top, obj);
1922    evas_object_smart_callback_add(wd->scr, "edge,bottom", _edge_bottom,
1923                                   obj);
1924    evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1925
1926    wd->obj = obj;
1927    wd->align_x = 0.5;
1928    wd->align_y = 0.5;
1929    wd->h_bounce = bounce;
1930    wd->v_bounce = bounce;
1931
1932    evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1933    evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1934    evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1935    evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1936
1937    wd->pan_smart = evas_object_smart_add(e, smart);
1938    wd->pan = evas_object_smart_data_get(wd->pan_smart);
1939    wd->pan->wd = wd;
1940
1941    elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1942                                      _pan_set, _pan_get, _pan_max_get,
1943                                      _pan_min_get, _pan_child_size_get);
1944
1945    evas_object_smart_callbacks_descriptions_set(obj, _signals);
1946
1947    _mirrored_set(obj, elm_widget_mirrored_get(obj));
1948    return obj;
1949 }
1950
1951 EAPI void
1952 elm_gengrid_item_size_set(Evas_Object *obj,
1953                           Evas_Coord   w,
1954                           Evas_Coord   h)
1955 {
1956    ELM_CHECK_WIDTYPE(obj, widtype);
1957    Widget_Data *wd = elm_widget_data_get(obj);
1958    if (!wd) return;
1959    if ((wd->item_width == w) && (wd->item_height == h)) return;
1960    wd->item_width = w;
1961    wd->item_height = h;
1962    if (wd->calc_job) ecore_job_del(wd->calc_job);
1963    wd->calc_job = ecore_job_add(_calc_job, wd);
1964 }
1965
1966 EAPI void
1967 elm_gengrid_item_size_get(const Evas_Object *obj,
1968                           Evas_Coord        *w,
1969                           Evas_Coord        *h)
1970 {
1971    ELM_CHECK_WIDTYPE(obj, widtype);
1972    Widget_Data *wd = elm_widget_data_get(obj);
1973    if (!wd) return;
1974    if (w) *w = wd->item_width;
1975    if (h) *h = wd->item_height;
1976 }
1977
1978 EAPI void
1979 elm_gengrid_group_item_size_set(Evas_Object *obj,
1980                           Evas_Coord   w,
1981                           Evas_Coord   h)
1982 {
1983    ELM_CHECK_WIDTYPE(obj, widtype);
1984    Widget_Data *wd = elm_widget_data_get(obj);
1985    if (!wd) return;
1986    if ((wd->group_item_width == w) && (wd->group_item_height == h)) return;
1987    wd->group_item_width = w;
1988    wd->group_item_height = h;
1989    if (wd->calc_job) ecore_job_del(wd->calc_job);
1990    wd->calc_job = ecore_job_add(_calc_job, wd);
1991 }
1992
1993 EAPI void
1994 elm_gengrid_group_item_size_get(const Evas_Object *obj,
1995                           Evas_Coord        *w,
1996                           Evas_Coord        *h)
1997 {
1998    ELM_CHECK_WIDTYPE(obj, widtype);
1999    Widget_Data *wd = elm_widget_data_get(obj);
2000    if (!wd) return;
2001    if (w) *w = wd->group_item_width;
2002    if (h) *h = wd->group_item_height;
2003 }
2004
2005 EAPI void
2006 elm_gengrid_align_set(Evas_Object *obj,
2007                       double       align_x,
2008                       double       align_y)
2009 {
2010    ELM_CHECK_WIDTYPE(obj, widtype);
2011
2012    Widget_Data *wd = elm_widget_data_get(obj);
2013    double old_h = wd->align_x, old_y = wd->align_y;
2014
2015    if (align_x > 1.0)
2016      align_x = 1.0;
2017    else if (align_x < 0.0)
2018      align_x = 0.0;
2019    wd->align_x = align_x;
2020
2021    if (align_y > 1.0)
2022      align_y = 1.0;
2023    else if (align_y < 0.0)
2024      align_y = 0.0;
2025    wd->align_y = align_y;
2026
2027    if ((old_h != wd->align_x) || (old_y != wd->align_y))
2028      evas_object_smart_calculate(wd->pan_smart);
2029 }
2030
2031 EAPI void
2032 elm_gengrid_align_get(const Evas_Object *obj,
2033                       double            *align_x,
2034                       double            *align_y)
2035 {
2036    ELM_CHECK_WIDTYPE(obj, widtype);
2037    Widget_Data *wd = elm_widget_data_get(obj);
2038    if (align_x) *align_x = wd->align_x;
2039    if (align_y) *align_y = wd->align_y;
2040 }
2041
2042 EAPI Elm_Gen_Item *
2043 elm_gengrid_item_append(Evas_Object                  *obj,
2044                         const Elm_Gengrid_Item_Class *itc,
2045                         const void                   *data,
2046                         Evas_Smart_Cb                 func,
2047                         const void                   *func_data)
2048 {
2049    Elm_Gen_Item *it;
2050    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2051    Widget_Data *wd = elm_widget_data_get(obj);
2052    if (!wd) return NULL;
2053
2054    it = _item_new(wd, itc, data, func, func_data);
2055    if (!it) return NULL;
2056    wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
2057
2058    if (it->group)
2059      wd->group_items = eina_list_prepend(wd->group_items, it);
2060
2061    if (wd->calc_job) ecore_job_del(wd->calc_job);
2062    wd->calc_job = ecore_job_add(_calc_job, wd);
2063
2064    return it;
2065 }
2066
2067 EAPI Elm_Gen_Item *
2068 elm_gengrid_item_prepend(Evas_Object                  *obj,
2069                          const Elm_Gengrid_Item_Class *itc,
2070                          const void                   *data,
2071                          Evas_Smart_Cb                 func,
2072                          const void                   *func_data)
2073 {
2074    Elm_Gen_Item *it;
2075    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2076    Widget_Data *wd = elm_widget_data_get(obj);
2077    if (!wd) return NULL;
2078
2079    it = _item_new(wd, itc, data, func, func_data);
2080    if (!it) return NULL;
2081    wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
2082    if (it->group)
2083      wd->group_items = eina_list_append(wd->group_items, it);
2084
2085    if (wd->calc_job) ecore_job_del(wd->calc_job);
2086    wd->calc_job = ecore_job_add(_calc_job, wd);
2087
2088    return it;
2089 }
2090
2091 EAPI Elm_Gen_Item *
2092 elm_gengrid_item_insert_before(Evas_Object                  *obj,
2093                                const Elm_Gengrid_Item_Class *itc,
2094                                const void                   *data,
2095                                Elm_Gen_Item             *relative,
2096                                Evas_Smart_Cb                 func,
2097                                const void                   *func_data)
2098 {
2099    Elm_Gen_Item *it;
2100    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2101    EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
2102    Widget_Data *wd = elm_widget_data_get(obj);
2103    if (!wd) return NULL;
2104
2105    it = _item_new(wd, itc, data, func, func_data);
2106    if (!it) return NULL;
2107    wd->items = eina_inlist_prepend_relative
2108       (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(relative));
2109    if (it->group)
2110      wd->group_items = eina_list_append_relative(wd->group_items, it, relative->parent);
2111
2112    if (wd->calc_job) ecore_job_del(wd->calc_job);
2113    wd->calc_job = ecore_job_add(_calc_job, wd);
2114
2115    return it;
2116 }
2117
2118 EAPI Elm_Gen_Item *
2119 elm_gengrid_item_insert_after(Evas_Object                  *obj,
2120                               const Elm_Gengrid_Item_Class *itc,
2121                               const void                   *data,
2122                               Elm_Gen_Item             *relative,
2123                               Evas_Smart_Cb                 func,
2124                               const void                   *func_data)
2125 {
2126    Elm_Gen_Item *it;
2127    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2128    EINA_SAFETY_ON_NULL_RETURN_VAL(relative, NULL);
2129    Widget_Data *wd = elm_widget_data_get(obj);
2130    if (!wd) return NULL;
2131
2132    it = _item_new(wd, itc, data, func, func_data);
2133    if (!it) return NULL;
2134    wd->items = eina_inlist_append_relative
2135       (wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(relative));
2136    if (it->group)
2137      wd->group_items = eina_list_prepend_relative(wd->group_items, it, relative->parent);
2138
2139    if (wd->calc_job) ecore_job_del(wd->calc_job);
2140    wd->calc_job = ecore_job_add(_calc_job, wd);
2141
2142    return it;
2143 }
2144
2145 EAPI Elm_Gen_Item *
2146 elm_gengrid_item_direct_sorted_insert(Evas_Object                  *obj,
2147                                       const Elm_Gengrid_Item_Class *itc,
2148                                       const void                   *data,
2149                                       Eina_Compare_Cb               comp,
2150                                       Evas_Smart_Cb                 func,
2151                                       const void                   *func_data)
2152 {
2153    Elm_Gen_Item *it;
2154    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2155    Widget_Data *wd = elm_widget_data_get(obj);
2156    if (!wd) return NULL;
2157
2158    it = _item_new(wd, itc, data, func, func_data);
2159    if (!it) return NULL;
2160
2161    if (!wd->state)
2162      wd->state = eina_inlist_sorted_state_new();
2163
2164    wd->item_compare_cb = comp;
2165    wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
2166                                          _elm_gengrid_item_compare, wd->state);
2167    if (wd->calc_job) ecore_job_del(wd->calc_job);
2168    wd->calc_job = ecore_job_add(_calc_job, wd);
2169
2170    return it;
2171 }
2172
2173 EAPI Elm_Gen_Item *
2174 elm_gengrid_item_sorted_insert(Evas_Object                  *obj,
2175                                const Elm_Gengrid_Item_Class *itc,
2176                                const void                   *data,
2177                                Eina_Compare_Cb               comp,
2178                                Evas_Smart_Cb                 func,
2179                                const void                   *func_data)
2180 {
2181    Widget_Data *wd = elm_widget_data_get(obj);
2182    wd->item_compare_data_cb = comp;
2183
2184    return elm_gengrid_item_direct_sorted_insert(obj, itc, data, _elm_gengrid_item_compare_data, func, func_data);
2185 }
2186
2187 EAPI void
2188 elm_gengrid_item_del(Elm_Gen_Item *it)
2189 {
2190    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2191    if ((it->relcount > 0) || (it->walking > 0))
2192      {
2193         _elm_genlist_item_del_notserious(it);
2194         return;
2195      }
2196
2197    _item_del(it);
2198 }
2199
2200 EAPI void
2201 elm_gengrid_horizontal_set(Evas_Object *obj,
2202                            Eina_Bool    setting)
2203 {
2204    ELM_CHECK_WIDTYPE(obj, widtype);
2205    Widget_Data *wd = elm_widget_data_get(obj);
2206    if (!wd) return;
2207    if (setting == wd->horizontal) return;
2208    wd->horizontal = setting;
2209
2210    /* Update the items to conform to the new layout */
2211    if (wd->calc_job) ecore_job_del(wd->calc_job);
2212    wd->calc_job = ecore_job_add(_calc_job, wd);
2213 }
2214
2215 EAPI Eina_Bool
2216 elm_gengrid_horizontal_get(const Evas_Object *obj)
2217 {
2218    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2219    Widget_Data *wd = elm_widget_data_get(obj);
2220    if (!wd) return EINA_FALSE;
2221    return wd->horizontal;
2222 }
2223
2224 EAPI void
2225 elm_gengrid_clear(Evas_Object *obj)
2226 {
2227    elm_genlist_clear(obj);
2228 }
2229
2230 EAPI const Evas_Object *
2231 elm_gengrid_item_object_get(const Elm_Gen_Item *it)
2232 {
2233    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
2234    return VIEW(it);
2235 }
2236
2237 EAPI void
2238 elm_gengrid_item_update(Elm_Gen_Item *it)
2239 {
2240    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2241    if (!it->realized) return;
2242    if (it->want_unrealize) return;
2243    _elm_genlist_item_unrealize(it, EINA_FALSE);
2244    _item_realize(it);
2245    _item_place(it, it->x, it->y);
2246 }
2247
2248 EAPI void *
2249 elm_gengrid_item_data_get(const Elm_Gen_Item *it)
2250 {
2251    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
2252    return elm_widget_item_data_get(it);
2253 }
2254
2255 EAPI void
2256 elm_gengrid_item_data_set(Elm_Gen_Item *it,
2257                           const void       *data)
2258 {
2259    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2260    elm_widget_item_data_set(it, data);
2261 }
2262
2263 EAPI const Elm_Gengrid_Item_Class *
2264 elm_gengrid_item_item_class_get(const Elm_Gen_Item *it)
2265 {
2266    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
2267    if (it->generation < it->wd->generation) return NULL;
2268    return it->itc;
2269 }
2270
2271 EAPI void
2272 elm_gengrid_item_item_class_set(Elm_Gen_Item *it,
2273                                 const Elm_Gengrid_Item_Class *itc)
2274 {
2275    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2276    EINA_SAFETY_ON_NULL_RETURN(itc);
2277    if (it->generation < it->wd->generation) return;
2278    it->itc = itc;
2279    elm_gengrid_item_update(it);
2280 }
2281
2282 EAPI void
2283 elm_gengrid_item_pos_get(const Elm_Gen_Item *it,
2284                          unsigned int           *x,
2285                          unsigned int           *y)
2286 {
2287    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2288    if (x) *x = it->x;
2289    if (y) *y = it->y;
2290 }
2291
2292 EAPI void
2293 elm_gengrid_multi_select_set(Evas_Object *obj,
2294                              Eina_Bool    multi)
2295 {
2296    ELM_CHECK_WIDTYPE(obj, widtype);
2297    Widget_Data *wd = elm_widget_data_get(obj);
2298    if (!wd) return;
2299    wd->multi = multi;
2300 }
2301
2302 EAPI Eina_Bool
2303 elm_gengrid_multi_select_get(const Evas_Object *obj)
2304 {
2305    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2306    Widget_Data *wd = elm_widget_data_get(obj);
2307    if (!wd) return EINA_FALSE;
2308    return wd->multi;
2309 }
2310
2311 EAPI Elm_Gen_Item *
2312 elm_gengrid_selected_item_get(const Evas_Object *obj)
2313 {
2314    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2315    Widget_Data *wd = elm_widget_data_get(obj);
2316    if (!wd) return NULL;
2317    if (wd->selected) return wd->selected->data;
2318    return NULL;
2319 }
2320
2321 EAPI const Eina_List *
2322 elm_gengrid_selected_items_get(const Evas_Object *obj)
2323 {
2324    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2325    Widget_Data *wd = elm_widget_data_get(obj);
2326    if (!wd) return NULL;
2327    return wd->selected;
2328 }
2329
2330 EAPI void
2331 elm_gengrid_item_selected_set(Elm_Gen_Item *it,
2332                               Eina_Bool         selected)
2333 {
2334    elm_genlist_item_selected_set((Elm_Object_Item *) it, selected);
2335 }
2336
2337 EAPI Eina_Bool
2338 elm_gengrid_item_selected_get(const Elm_Gen_Item *it)
2339 {
2340    return elm_genlist_item_selected_get((const Elm_Object_Item *) it);
2341 }
2342
2343 EAPI void
2344 elm_gengrid_item_disabled_set(Elm_Gen_Item *it,
2345                               Eina_Bool         disabled)
2346 {
2347    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2348    if (it->disabled == disabled) return;
2349    if (it->generation < it->wd->generation) return;
2350    it->disabled = !!disabled;
2351    if (it->realized)
2352      {
2353         if (it->disabled)
2354           edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
2355         else
2356           edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
2357      }
2358 }
2359
2360 EAPI Eina_Bool
2361 elm_gengrid_item_disabled_get(const Elm_Gen_Item *it)
2362 {
2363    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
2364    if (it->generation < it->wd->generation) return EINA_FALSE;
2365    return it->disabled;
2366 }
2367
2368 static Evas_Object *
2369 _elm_gengrid_item_label_create(void        *data,
2370                                Evas_Object *obj __UNUSED__,
2371                                Evas_Object *tooltip,
2372                                void *it   __UNUSED__)
2373 {
2374    Evas_Object *label = elm_label_add(tooltip);
2375    if (!label)
2376      return NULL;
2377    elm_object_style_set(label, "tooltip");
2378    elm_object_text_set(label, data);
2379    return label;
2380 }
2381
2382 static void
2383 _elm_gengrid_item_label_del_cb(void            *data,
2384                                Evas_Object *obj __UNUSED__,
2385                                void *event_info __UNUSED__)
2386 {
2387    eina_stringshare_del(data);
2388 }
2389
2390 EAPI void
2391 elm_gengrid_item_tooltip_text_set(Elm_Gen_Item *it,
2392                                   const char       *text)
2393 {
2394    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2395    text = eina_stringshare_add(text);
2396    elm_gengrid_item_tooltip_content_cb_set(it, _elm_gengrid_item_label_create,
2397                                            text,
2398                                            _elm_gengrid_item_label_del_cb);
2399 }
2400
2401 EAPI void
2402 elm_gengrid_item_tooltip_content_cb_set(Elm_Gen_Item           *it,
2403                                         Elm_Tooltip_Item_Content_Cb func,
2404                                         const void                 *data,
2405                                         Evas_Smart_Cb               del_cb)
2406 {
2407    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(it, error);
2408
2409    if ((it->tooltip.content_cb == func) && (it->tooltip.data == data))
2410      return;
2411
2412    if (it->tooltip.del_cb)
2413      it->tooltip.del_cb((void *)it->tooltip.data,
2414                           WIDGET(it), it);
2415    it->tooltip.content_cb = func;
2416    it->tooltip.data = data;
2417    it->tooltip.del_cb = del_cb;
2418    if (VIEW(it))
2419      {
2420         elm_widget_item_tooltip_content_cb_set(it,
2421                                                it->tooltip.content_cb,
2422                                                it->tooltip.data, NULL);
2423         elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2424         elm_widget_item_tooltip_window_mode_set(it, it->tooltip.free_size);
2425      }
2426
2427    return;
2428
2429 error:
2430    if (del_cb) del_cb((void *)data, NULL, NULL);
2431 }
2432
2433 EAPI void
2434 elm_gengrid_item_tooltip_unset(Elm_Gen_Item *it)
2435 {
2436    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2437    if ((VIEW(it)) && (it->tooltip.content_cb))
2438      elm_widget_item_tooltip_unset(it);
2439
2440    if (it->tooltip.del_cb)
2441      it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
2442    it->tooltip.del_cb = NULL;
2443    it->tooltip.content_cb = NULL;
2444    it->tooltip.data = NULL;
2445    it->tooltip.free_size = EINA_FALSE;
2446    if (it->tooltip.style)
2447      elm_gengrid_item_tooltip_style_set(it, NULL);
2448 }
2449
2450 EAPI void
2451 elm_gengrid_item_tooltip_style_set(Elm_Gen_Item *it,
2452                                    const char       *style)
2453 {
2454    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2455    eina_stringshare_replace(&it->tooltip.style, style);
2456    if (VIEW(it)) elm_widget_item_tooltip_style_set(it, style);
2457 }
2458
2459 EAPI const char *
2460 elm_gengrid_item_tooltip_style_get(const Elm_Gen_Item *it)
2461 {
2462    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
2463    return it->tooltip.style;
2464 }
2465
2466 EAPI Eina_Bool
2467 elm_gengrid_item_tooltip_window_mode_set(Elm_Gen_Item *it, Eina_Bool disable)
2468 {
2469    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
2470    it->tooltip.free_size = disable;
2471    if (VIEW(it)) return elm_widget_item_tooltip_window_mode_set(it, disable);
2472    return EINA_TRUE;
2473 }
2474
2475 EAPI Eina_Bool
2476 elm_gengrid_item_tooltip_window_mode_get(const Elm_Gen_Item *it)
2477 {
2478    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
2479    return it->tooltip.free_size;
2480 }
2481
2482 EAPI void
2483 elm_gengrid_item_cursor_set(Elm_Gen_Item *it,
2484                             const char       *cursor)
2485 {
2486    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2487    eina_stringshare_replace(&it->mouse_cursor, cursor);
2488    if (VIEW(it)) elm_widget_item_cursor_set(it, cursor);
2489 }
2490
2491 EAPI const char *
2492 elm_gengrid_item_cursor_get(const Elm_Gen_Item *it)
2493 {
2494    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
2495    return elm_widget_item_cursor_get(it);
2496 }
2497
2498 EAPI void
2499 elm_gengrid_item_cursor_unset(Elm_Gen_Item *it)
2500 {
2501    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2502    if (!it->mouse_cursor)
2503      return;
2504
2505    if (VIEW(it))
2506      elm_widget_item_cursor_unset(it);
2507
2508    eina_stringshare_del(it->mouse_cursor);
2509    it->mouse_cursor = NULL;
2510 }
2511
2512 EAPI void
2513 elm_gengrid_item_cursor_style_set(Elm_Gen_Item *it,
2514                                   const char       *style)
2515 {
2516    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2517    elm_widget_item_cursor_style_set(it, style);
2518 }
2519
2520 EAPI const char *
2521 elm_gengrid_item_cursor_style_get(const Elm_Gen_Item *it)
2522 {
2523    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
2524    return elm_widget_item_cursor_style_get(it);
2525 }
2526
2527 EAPI void
2528 elm_gengrid_item_cursor_engine_only_set(Elm_Gen_Item *it,
2529                                         Eina_Bool         engine_only)
2530 {
2531    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2532    elm_widget_item_cursor_engine_only_set(it, engine_only);
2533 }
2534
2535 EAPI Eina_Bool
2536 elm_gengrid_item_cursor_engine_only_get(const Elm_Gen_Item *it)
2537 {
2538    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
2539    return elm_widget_item_cursor_engine_only_get(it);
2540 }
2541
2542 EAPI void
2543 elm_gengrid_reorder_mode_set(Evas_Object *obj,
2544                              Eina_Bool    reorder_mode)
2545 {
2546    ELM_CHECK_WIDTYPE(obj, widtype);
2547    Widget_Data *wd = elm_widget_data_get(obj);
2548    if (!wd) return;
2549    wd->reorder_mode = reorder_mode;
2550 }
2551
2552 EAPI Eina_Bool
2553 elm_gengrid_reorder_mode_get(const Evas_Object *obj)
2554 {
2555    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2556    Widget_Data *wd = elm_widget_data_get(obj);
2557    if (!wd) return EINA_FALSE;
2558    return wd->reorder_mode;
2559 }
2560
2561 EAPI void
2562 elm_gengrid_always_select_mode_set(Evas_Object *obj,
2563                                    Eina_Bool    always_select)
2564 {
2565    elm_genlist_always_select_mode_set(obj, always_select);
2566 }
2567
2568 EAPI Eina_Bool
2569 elm_gengrid_always_select_mode_get(const Evas_Object *obj)
2570 {
2571    return elm_genlist_always_select_mode_get(obj);
2572 }
2573
2574 EAPI void
2575 elm_gengrid_no_select_mode_set(Evas_Object *obj,
2576                                Eina_Bool    no_select)
2577 {
2578    elm_genlist_no_select_mode_set(obj, no_select);
2579 }
2580
2581 EAPI Eina_Bool
2582 elm_gengrid_no_select_mode_get(const Evas_Object *obj)
2583 {
2584    return elm_genlist_no_select_mode_get(obj);
2585 }
2586
2587 EAPI void
2588 elm_gengrid_bounce_set(Evas_Object *obj,
2589                        Eina_Bool    h_bounce,
2590                        Eina_Bool    v_bounce)
2591 {
2592    elm_genlist_bounce_set(obj, h_bounce, v_bounce);
2593 }
2594
2595 EAPI void
2596 elm_gengrid_bounce_get(const Evas_Object *obj,
2597                        Eina_Bool         *h_bounce,
2598                        Eina_Bool         *v_bounce)
2599 {
2600    elm_genlist_bounce_get(obj, h_bounce, v_bounce);
2601 }
2602
2603 EAPI void
2604 elm_gengrid_page_relative_set(Evas_Object *obj,
2605                               double       h_pagerel,
2606                               double       v_pagerel)
2607 {
2608    _elm_genlist_page_relative_set(obj, h_pagerel, v_pagerel);
2609 }
2610
2611 EAPI void
2612 elm_gengrid_page_relative_get(const Evas_Object *obj, double *h_pagerel, double *v_pagerel)
2613 {
2614    _elm_genlist_page_relative_get(obj, h_pagerel, v_pagerel);
2615 }
2616
2617 EAPI void
2618 elm_gengrid_page_size_set(Evas_Object *obj,
2619                           Evas_Coord   h_pagesize,
2620                           Evas_Coord   v_pagesize)
2621 {
2622    _elm_genlist_page_size_set(obj, h_pagesize, v_pagesize);
2623 }
2624
2625 EAPI void
2626 elm_gengrid_current_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2627 {
2628    _elm_genlist_current_page_get(obj, h_pagenumber, v_pagenumber);
2629 }
2630
2631 EAPI void
2632 elm_gengrid_last_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
2633 {
2634    _elm_genlist_last_page_get(obj, h_pagenumber, v_pagenumber);
2635 }
2636
2637 EAPI void
2638 elm_gengrid_page_show(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2639 {
2640    _elm_genlist_page_show(obj, h_pagenumber, v_pagenumber);
2641 }
2642
2643 EAPI void
2644 elm_gengrid_page_bring_in(const Evas_Object *obj, int h_pagenumber, int v_pagenumber)
2645 {
2646    _elm_genlist_page_bring_in(obj, h_pagenumber, v_pagenumber);
2647 }
2648
2649 EAPI Elm_Gen_Item *
2650 elm_gengrid_first_item_get(const Evas_Object *obj)
2651 {
2652    return (Elm_Gen_Item *) elm_genlist_first_item_get(obj);
2653 }
2654
2655 EAPI Elm_Gen_Item *
2656 elm_gengrid_last_item_get(const Evas_Object *obj)
2657 {
2658    return (Elm_Gen_Item *) elm_genlist_last_item_get(obj);
2659 }
2660
2661 EAPI Elm_Gen_Item *
2662 elm_gengrid_item_next_get(const Elm_Gen_Item *it)
2663 {
2664    return (Elm_Gen_Item *) elm_genlist_item_next_get((Elm_Object_Item *) it);
2665 }
2666
2667 EAPI Elm_Gen_Item *
2668 elm_gengrid_item_prev_get(const Elm_Gen_Item *it)
2669 {
2670    return (Elm_Gen_Item *) elm_genlist_item_prev_get((Elm_Object_Item *) it);
2671 }
2672
2673 EAPI Evas_Object *
2674 elm_gengrid_item_gengrid_get(const Elm_Gen_Item *it)
2675 {
2676    return _elm_genlist_item_widget_get(it);
2677 }
2678
2679 EAPI void
2680 elm_gengrid_item_show(Elm_Gen_Item *it)
2681 {
2682    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2683    Widget_Data *wd = it->wd;
2684    Evas_Coord minx = 0, miny = 0;
2685
2686    if (!wd) return;
2687    if ((!it) || (it->generation < it->wd->generation)) return;
2688    _pan_min_get(wd->pan_smart, &minx, &miny);
2689
2690    if (wd->horizontal)
2691      elm_smart_scroller_region_bring_in(it->wd->scr,
2692                                         ((it->x - it->item->prev_group) * wd->item_width) + (it->item->prev_group * it->wd->group_item_width) + minx,
2693                                         it->y * wd->item_height + miny,
2694                                         it->wd->item_width,
2695                                         it->wd->item_height);
2696    else
2697      elm_smart_scroller_region_bring_in(it->wd->scr,
2698                                         it->x * wd->item_width + minx,
2699                                         ((it->y - it->item->prev_group)* wd->item_height) + (it->item->prev_group * it->wd->group_item_height) + miny,
2700                                         it->wd->item_width,
2701                                         it->wd->item_height);
2702 }
2703
2704 EAPI void
2705 elm_gengrid_item_bring_in(Elm_Gen_Item *it)
2706 {
2707    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
2708    if (it->generation < it->wd->generation) return;
2709
2710    Evas_Coord minx = 0, miny = 0;
2711    Widget_Data *wd = it->wd;
2712    if (!wd) return;
2713    _pan_min_get(wd->pan_smart, &minx, &miny);
2714
2715    if (wd->horizontal)
2716      elm_smart_scroller_region_bring_in(it->wd->scr,
2717                                         ((it->x - it->item->prev_group) * wd->item_width) + (it->item->prev_group * it->wd->group_item_width) + minx,
2718                                         it->y * wd->item_height + miny,
2719                                         it->wd->item_width,
2720                                         it->wd->item_height);
2721    else
2722      elm_smart_scroller_region_bring_in(it->wd->scr,
2723                                         it->x * wd->item_width + minx,
2724                                         ((it->y - it->item->prev_group)* wd->item_height) + (it->item->prev_group * it->wd->group_item_height) + miny,
2725                                         it->wd->item_width,
2726                                         it->wd->item_height);
2727 }
2728
2729 EAPI void
2730 elm_gengrid_filled_set(Evas_Object *obj, Eina_Bool fill)
2731 {
2732    ELM_CHECK_WIDTYPE(obj, widtype);
2733    Widget_Data *wd = elm_widget_data_get(obj);
2734    if (!wd) return;
2735    fill = !!fill;
2736    if (wd->filled != fill)
2737      wd->filled = fill;
2738 }
2739
2740 EAPI Eina_Bool
2741 elm_gengrid_filled_get(const Evas_Object *obj)
2742 {
2743    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2744    Widget_Data *wd = elm_widget_data_get(obj);
2745    if (!wd) return EINA_FALSE;
2746    return wd->filled;
2747 }
2748