elementary/index - merged with opensource for page control
authorChunEon Park <chuneon.park@samsung.com>
Fri, 9 Mar 2012 12:45:16 +0000 (21:45 +0900)
committerChunEon Park <chuneon.park@samsung.com>
Fri, 9 Mar 2012 12:47:00 +0000 (21:47 +0900)
Change-Id: I4799da7f1b090fb1a906e370eeef7ee724af91f1

src/lib/elm_index.c
src/lib/elm_index.h

index c700e03..64c6ba6 100644 (file)
@@ -18,6 +18,7 @@ struct _Widget_Data
    Evas_Object *bx[2]; // 2 - for now all that's supported
    Eina_List *items; // 1 list. yes N levels, but only 2 for now and # of items will be small
    int level;
+   int max_supp_items_count;
    int tot_items_count[2];
    int min_obj_height, max_grp_size;
    int min_1st_level_obj_height;
@@ -28,7 +29,7 @@ struct _Widget_Data
    const char *special_char;
    Eina_Bool level_active[2];
    Eina_Bool horizontal : 1;
-   Eina_Bool active : 1;
+   Eina_Bool autohide_disabled : 1;
    Eina_Bool down : 1;
    Eina_Bool indicator_disabled : 1;
 };
@@ -38,6 +39,7 @@ struct _Elm_Index_Item
    ELM_WIDGET_ITEM;
    const char *letter, *vis_letter;
    int level, size;
+   Evas_Smart_Cb func;
    Eina_Bool selected : 1;
 };
 
@@ -195,9 +197,14 @@ _theme_hook(Evas_Object *obj)
    edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
    _sizing_eval(obj);
    _index_box_auto_fill(obj, wd->bx[0], 0);
-   if (wd->active)
-     if (wd->level == 1)
-       _index_box_auto_fill(obj, wd->bx[1], 1);
+
+   if (wd->autohide_disabled)
+     {
+        if (wd->level == 1) _index_box_auto_fill(obj, wd->bx[1], 1);
+        edje_object_signal_emit(wd->base, "elm,state,active", "elm");
+     }
+   else
+     edje_object_signal_emit(wd->base, "elm,state,inactive", "elm");
 }
 
 static void
@@ -216,13 +223,13 @@ _item_del_pre_hook(Elm_Object_Item *it)
 {
    Widget_Data *wd = elm_widget_data_get(WIDGET(it));
    if (!wd) return EINA_FALSE;
-   _item_free((Elm_Index_Item *) it);
+   _item_free((Elm_Index_Item *)it);
    _index_box_clear(WIDGET(it), wd->bx[wd->level], wd->level);
    return EINA_TRUE;
 }
 
 static Elm_Index_Item *
-_item_new(Evas_Object *obj, const char *letter, const void *item)
+_item_new(Evas_Object *obj, const char *letter, Evas_Smart_Cb func, const void *data)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
    Elm_Index_Item *it;
@@ -230,7 +237,8 @@ _item_new(Evas_Object *obj, const char *letter, const void *item)
    it = elm_widget_item_new(obj, Elm_Index_Item);
    if (!it) return NULL;
    elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
-   it->base.data = item;
+   it->func = func;
+   it->base.data = data;
    it->level = wd->level;
    if(wd->level == 0)
      it->size =  wd->min_obj_height;
@@ -245,14 +253,14 @@ _item_new(Evas_Object *obj, const char *letter, const void *item)
 }
 
 static Elm_Index_Item *
-_item_find(Evas_Object *obj, const void *item)
+_item_find(Evas_Object *obj, const void *data)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
    Eina_List *l;
    Elm_Index_Item *it;
    if (!wd) return NULL;
    EINA_LIST_FOREACH(wd->items, l, it)
-     if (it->base.data == item) return it;
+     if (it->base.data == data) return it;
    return NULL;
 }
 
@@ -286,22 +294,46 @@ _index_box_auto_fill(Evas_Object *obj, Evas_Object *box, int level)
         const char *stacking;
 
         if (it->level != level) continue;
+
+//FIXME: Need to check. This cause one less items show up.
+//        if(i > wd->max_supp_items_count) break;
+
         o = edje_object_add(evas_object_evas_get(obj));
         VIEW(it) = o;
         edje_object_mirrored_set(VIEW(it), rtl);
-        if (i & 0x1)
-          _elm_theme_object_set(obj, o, "index", "item_odd/vertical", elm_widget_style_get(obj));
+
+        if (wd->horizontal)
+          {
+             if (i & 0x1)
+               _elm_theme_object_set(obj, o, "index", "item_odd/horizontal",
+                                     elm_widget_style_get(obj));
+             else
+               _elm_theme_object_set(obj, o, "index", "item/horizontal",
+                                     elm_widget_style_get(obj));
+          }
         else
-          _elm_theme_object_set(obj, o, "index", "item/vertical", elm_widget_style_get(obj));
+          {
+             if (i & 0x1)
+               _elm_theme_object_set(obj, o, "index", "item_odd/vertical",
+                                     elm_widget_style_get(obj));
+             else
+               _elm_theme_object_set(obj, o, "index", "item/vertical",
+                                     elm_widget_style_get(obj));
+          }
+
         edje_object_part_text_set(o, "elm.text", it->letter);
         edje_object_size_min_restricted_calc(o, &mw, &mh, 0, 0);
         evas_object_size_hint_min_set(o, mw, mh);
         evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
         evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
         edje_object_part_text_set(o, "elm.text", it->vis_letter);
-        evas_object_size_hint_min_set(o, mw, it->size);
+
+        //FIXME: Need to check. This cause the page index size incorrect.
+/*      evas_object_size_hint_min_set(o, mw, it->size);
         evas_object_size_hint_max_set(o, mw, it->size);
-        evas_object_resize(o, mw, it->size);
+        evas_object_resize(o, mw, it->size); */
+
         elm_widget_sub_object_add(obj, o);
         evas_object_box_append(box, o);
         stacking = edje_object_data_get(o, "stacking");
@@ -354,7 +386,7 @@ _delay_change(void *data)
    Elm_Object_Item *item;
    if (!wd) return ECORE_CALLBACK_CANCEL;
    wd->delay = NULL;
-   item = elm_index_item_selected_get(data, wd->level);
+   item = elm_index_selected_item_get(data, wd->level);
    if (item) evas_object_smart_callback_call(data, SIG_DELAY_CHANGED, item);
    return ECORE_CALLBACK_CANCEL;
 }
@@ -367,8 +399,6 @@ _sel_eval(Evas_Object *obj, Evas_Coord evx, Evas_Coord evy)
    Eina_List *l;
    Evas_Coord x, y, w, h, bx, by, bw, bh, xx, yy;
    double cdv = 0.5;
-   double dmax = 0.0;
-   double dmin = 0.0;
    Evas_Coord dist;
    char *label = NULL, *last = NULL;
    int i;
@@ -379,13 +409,10 @@ _sel_eval(Evas_Object *obj, Evas_Coord evx, Evas_Coord evy)
         it_closest  = NULL;
         dist = 0x7fffffff;
         evas_object_geometry_get(wd->bx[i], &bx, &by, &bw, &bh);
-
-        dmin = (double)(wd->min_1st_level_obj_height*wd->tot_items_count[1])/(2*(double)bh);
-        dmax = 1.0-dmin-0.08;
         EINA_LIST_FOREACH(wd->items, l, it)
           {
-             if (!((it->level == i) && (VIEW(it)))) continue;
-             if ((VIEW(it)) && (it->level != wd->level))
+             if (it->level != i) continue;
+             if (it->level != wd->level)
                {
                   if (it->selected)
                     {
@@ -459,8 +486,8 @@ _sel_eval(Evas_Object *obj, Evas_Coord evx, Evas_Coord evy)
                   if (!label) label = strdup(last);
                   else
                     {
-                       /* FIXME: realloc return NULL if the request fails */
                        label = realloc(label, strlen(label) + strlen(last) + 1);
+                       if (!label) return;
                        strcat(label, last);
                     }
                   free(last);
@@ -472,7 +499,6 @@ _sel_eval(Evas_Object *obj, Evas_Coord evx, Evas_Coord evy)
    if (!last) last = strdup("");
    edje_object_part_text_set(wd->base, "elm.text.body", label);
    edje_object_part_text_set(wd->base, "elm.text", last);
-                  edje_object_signal_emit(wd->base, "hide_2nd_level", "");
    free(label);
    free(last);
 }
@@ -498,7 +524,12 @@ _mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *eve
    evas_object_geometry_get(wd->base, &x, &y, &w, NULL);
    wd->dx = ev->canvas.x - x;
    wd->dy = ev->canvas.y - y;
-   elm_index_active_set(data, 1);
+   if (!wd->autohide_disabled)
+     {
+        _index_box_clear(data, wd->bx[1], 1);
+        _index_box_auto_fill(data, wd->bx[0], 0);
+        edje_object_signal_emit(wd->base, "elm,state,active", "elm");
+     }
    _sel_eval(data, ev->canvas.x, ev->canvas.y);
    edje_object_part_drag_value_set(wd->base, "elm.dragable.pointer",
                                    (!edje_object_mirrored_get(wd->base)) ? wd->dx : (wd->dx - w), wd->dy);
@@ -512,14 +543,22 @@ _mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event
    Widget_Data *wd = elm_widget_data_get(data);
    Evas_Event_Mouse_Up *ev = event_info;
    Elm_Object_Item *item;
+   Elm_Index_Item *id_item;
    if (!wd) return;
    if (ev->button != 1) return;
    if (wd->level == 1 && wd->delay) ecore_timer_del(wd->delay);
    wd->delay = NULL;
    wd->down = 0;
-   item = elm_index_item_selected_get(data, wd->level);
-   if (item) evas_object_smart_callback_call(data, SIG_SELECTED, item);
-   elm_index_active_set(data, 0);
+   item = elm_index_selected_item_get(data, wd->level);
+   if (item)
+     {
+        evas_object_smart_callback_call(data, SIG_SELECTED, item);
+        id_item = (Elm_Index_Item *)item;
+        if (id_item->func)
+          id_item->func((void *)id_item->base.data, WIDGET(id_item), id_item);
+     }
+   if (!wd->autohide_disabled)
+     edje_object_signal_emit(wd->base, "elm,state,inactive", "elm");
    edje_object_signal_emit(wd->base, "elm,state,level,0", "elm");
    if (wd->items && !wd->indicator_disabled)
      edje_object_signal_emit(wd->base, "elm,indicator,state,inactive", "elm");
@@ -589,14 +628,12 @@ _index_box_refill_job(void *data)
 
    wd->max_grp_size = wd->min_obj_height - 2*MIN_GRP_SIZE;
    wd->items_count = ph/wd->min_obj_height;
+   wd->max_supp_items_count = wd->max_grp_size*(int)((wd->items_count-1)*0.5)+wd->items_count;
 
    if(pw != wd->pwidth && ph != wd->pheight)
      {
         if(wd->down == 1)
-          {
-             wd->active = 0;
-             elm_index_active_set(data, 1);
-          }
+          edje_object_signal_emit(wd->base, "elm,state,active", "elm");
         _index_box_clear((Evas_Object *)data, wd->bx[0], 0);
         evas_object_smart_calculate( wd->bx[0]);
         elm_index_item_go((Evas_Object *)data, wd->level);
@@ -639,6 +676,7 @@ elm_index_add(Evas_Object *parent)
 
    wd->indicator_disabled = EINA_FALSE;
    wd->horizontal = EINA_FALSE;
+   wd->autohide_disabled = EINA_FALSE;
    wd->min_obj_height = 0;
    wd->max_grp_size = 0;
    wd->items_count = 0;
@@ -721,6 +759,8 @@ _group_count(Evas_Object *obj, int extraIndex, int adj_pos)
 static void
 _index_process(Evas_Object *obj)
 {
+//FIXME: It seems max_supp_items_count has incorrect value.
+   return;
    int extraIndex;
    int j,i, group_count;
    Eina_List *l;
@@ -734,7 +774,10 @@ _index_process(Evas_Object *obj)
    if (wd->items_count == 0) return;
 
    const int adj_pos = (wd->items_count-1)*0.5;
-   n = wd->tot_items_count[wd->level];
+   if(wd->tot_items_count[wd->level] <= wd->max_supp_items_count)
+      n = wd->tot_items_count[wd->level];
+   else
+      n = wd->max_supp_items_count;
    group_count = MIN_GRP_SIZE;
 
    int *indx = (int*)calloc(n, sizeof(int));
@@ -821,16 +864,29 @@ _index_process(Evas_Object *obj)
      }
 }
 
-EAPI void
+EINA_DEPRECATED EAPI void
 elm_index_active_set(Evas_Object *obj, Eina_Bool active)
 {
+   elm_index_autohide_disabled_set(obj, !active);
+}
+
+EINA_DEPRECATED EAPI Eina_Bool
+elm_index_active_get(const Evas_Object *obj)
+{
+   return !elm_index_autohide_disabled_get(obj);
+}
+
+EAPI void
+elm_index_autohide_disabled_set(Evas_Object *obj, Eina_Bool disabled)
+{
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
-   if (wd->active == active) return;
-   wd->active = active;
+   disabled = !!disabled;
+   if (wd->autohide_disabled == disabled) return;
+   wd->autohide_disabled = disabled;
    wd->level = 0;
-   if (wd->active)
+   if (wd->autohide_disabled)
      {
         _index_box_clear(obj, wd->bx[1], 1);
         _index_process(obj);
@@ -839,15 +895,17 @@ elm_index_active_set(Evas_Object *obj, Eina_Bool active)
      }
    else
      edje_object_signal_emit(wd->base, "elm,state,inactive", "elm");
+
+   //FIXME: Should be update indicator based on the indicator visiblility
 }
 
 EAPI Eina_Bool
-elm_index_active_get(const Evas_Object *obj)
+elm_index_autohide_disabled_get(const Evas_Object *obj)
 {
    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return EINA_FALSE;
-   return wd->active;
+   return wd->autohide_disabled;
 }
 
 EAPI void
@@ -869,9 +927,35 @@ elm_index_item_level_get(const Evas_Object *obj)
    return wd->level;
 }
 
-EAPI Elm_Object_Item *
+EAPI void
+elm_index_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
+{
+   ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
+   Evas_Coord x, y, w, h;
+   Widget_Data *wd = elm_widget_data_get(WIDGET(it));
+   if (!wd) return;
+
+   //FIXME: Should be update indicator based on the autohidden status & indicator visiblility
+
+   if (selected)
+     {
+        evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
+        _sel_eval(WIDGET(it), x + (w/2), y + (h/2));
+     }
+   else
+     _sel_eval(WIDGET(it), -99999, -9999);
+
+}
+
+EINA_DEPRECATED EAPI Elm_Object_Item *
 elm_index_item_selected_get(const Evas_Object *obj, int level)
 {
+   return elm_index_selected_item_get(obj, level);
+}
+
+EAPI Elm_Object_Item *
+elm_index_selected_item_get(const Evas_Object *obj, int level)
+{
    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
    Widget_Data *wd = elm_widget_data_get(obj);
    Eina_List *l;
@@ -880,98 +964,111 @@ elm_index_item_selected_get(const Evas_Object *obj, int level)
    EINA_LIST_FOREACH(wd->items, l, it)
      {
         if ((it->selected) && (it->level == level))
-          return (Elm_Object_Item *) it;
+          return (Elm_Object_Item *)it;
      }
    return NULL;
 }
 
-EAPI void
-elm_index_item_append(Evas_Object *obj, const char *letter, const void *item)
+EAPI Elm_Object_Item *
+elm_index_item_append(Evas_Object *obj, const char *letter, const void *data)
 {
-   ELM_CHECK_WIDTYPE(obj, widtype);
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
    Widget_Data *wd = elm_widget_data_get(obj);
    Elm_Index_Item *it;
-   if (!wd) return;
-   it = _item_new(obj, letter, item);
-   if (!it) return;
+   if (!wd) return NULL;
+   it = _item_new(obj, letter, NULL, data);
+   if (!it) return NULL;
    wd->items = eina_list_append(wd->items, it);
    wd->tot_items_count[wd->level]++;
    _index_box_clear(obj, wd->bx[wd->level], wd->level);
+   return (Elm_Object_Item *)it;
 }
 
-EAPI void
-elm_index_item_prepend(Evas_Object *obj, const char *letter, const void *item)
+EAPI Elm_Object_Item *
+elm_index_item_prepend(Evas_Object *obj, const char *letter, const void *data)
 {
-   ELM_CHECK_WIDTYPE(obj, widtype);
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
    Widget_Data *wd = elm_widget_data_get(obj);
    Elm_Index_Item *it;
 
-   if (!wd) return;
-   it = _item_new(obj, letter, item);
-   if (!it) return;
+   if (!wd) return NULL;
+   it = _item_new(obj, letter, NULL, data);
+   if (!it) return NULL;
    wd->items = eina_list_prepend(wd->items, it);
    wd->tot_items_count[wd->level]++;
    _index_box_clear(obj, wd->bx[wd->level], wd->level);
+   return (Elm_Object_Item *)it;
 }
 
-EAPI void
+EINA_DEPRECATED EAPI Elm_Object_Item *
 elm_index_item_append_relative(Evas_Object *obj, const char *letter, const void *item, const Elm_Object_Item *relative)
 {
-   ELM_CHECK_WIDTYPE(obj, widtype);
+   return elm_index_item_insert_after(obj, (Elm_Object_Item *) relative, letter, NULL, item);
+}
+
+EINA_DEPRECATED EAPI Elm_Object_Item *
+elm_index_item_prepend_relative(Evas_Object *obj, const char *letter, const void *item, const Elm_Object_Item *relative)
+{
+   return elm_index_item_insert_before(obj, (Elm_Object_Item *) relative, letter, NULL, item);
+}
+
+EAPI Elm_Object_Item *
+elm_index_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *letter, Evas_Smart_Cb func, const void *data)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
    Widget_Data *wd = elm_widget_data_get(obj);
    Elm_Index_Item *it;
-   if (!wd) return;
-   if (!relative)
+   if (!wd) return NULL;
+   if (!after)
      {
-        elm_index_item_append(obj, letter, item);
+        it = (Elm_Index_Item *)elm_index_item_append(obj, letter, data);
         wd->tot_items_count[wd->level]++;
-        return;
+        return (Elm_Object_Item *)it;
      }
-   it = _item_new(obj, letter, item);
-   if (!it) return;
-   wd->items = eina_list_append_relative(wd->items, it, relative);
+   it = _item_new(obj, letter, func, data);
+   if (!it) return NULL;
+   wd->items = eina_list_append_relative(wd->items, it, after);
    wd->tot_items_count[wd->level]++;
    _index_box_clear(obj, wd->bx[wd->level], wd->level);
+   return (Elm_Object_Item *)it;
 }
 
-EAPI void
-elm_index_item_prepend_relative(Evas_Object *obj, const char *letter, const void *item, const Elm_Object_Item *relative)
+EAPI Elm_Object_Item *
+elm_index_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *letter, Evas_Smart_Cb func, const void *data)
 {
-   ELM_CHECK_WIDTYPE(obj, widtype);
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
    Widget_Data *wd = elm_widget_data_get(obj);
    Elm_Index_Item *it;
-   if (!wd) return;
-   if (!relative)
+   if (!wd) return NULL;
+   if (!before)
      {
-        elm_index_item_prepend(obj, letter, item);
+        it = (Elm_Index_Item *)elm_index_item_prepend(obj, letter, data);
         wd->tot_items_count[wd->level]++;
-        return;
+        return (Elm_Object_Item *)it;
      }
-   it = _item_new(obj, letter, item);
-   if (!it) return;
-   wd->items = eina_list_prepend_relative(wd->items, it, relative);
+   it = _item_new(obj, letter, func, data);
+   if (!it) return NULL;
+   wd->items = eina_list_prepend_relative(wd->items, it, before);
    wd->tot_items_count[wd->level]++;
    _index_box_clear(obj, wd->bx[wd->level], wd->level);
+   return (Elm_Object_Item *)it;
 }
 
-EAPI void
-elm_index_item_sorted_insert(Evas_Object *obj, const char *letter, const void *item, Eina_Compare_Cb cmp_func, Eina_Compare_Cb cmp_data_func)
+EAPI Elm_Object_Item *
+elm_index_item_sorted_insert(Evas_Object *obj, const char *letter, const void *data, Eina_Compare_Cb cmp_func, Eina_Compare_Cb cmp_data_func)
 {
-   ELM_CHECK_WIDTYPE(obj, widtype);
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
    Widget_Data *wd = elm_widget_data_get(obj);
    Eina_List *lnear;
    Elm_Index_Item *it;
    int cmp;
 
-   if (!wd) return;
+   if (!wd) return NULL;
    if (!(wd->items))
-     {
-        elm_index_item_append(obj, letter, item);
-        return;
-     }
+     return elm_index_item_append(obj, letter, data);
 
-   it = _item_new(obj, letter, item);
-   if (!it) return;
+   it = _item_new(obj, letter, NULL, data);
+   if (!it) return NULL;
 
    lnear = eina_list_search_sorted_near_list(wd->items, cmp_func, it, &cmp);
    if (cmp < 0)
@@ -992,8 +1089,8 @@ elm_index_item_sorted_insert(Evas_Object *obj, const char *letter, const void *i
              elm_widget_item_free(it);
           }
      }
-
    _index_box_clear(obj, wd->bx[wd->level], wd->level);
+   return (Elm_Object_Item *)it;
 }
 
 EAPI void
@@ -1003,12 +1100,12 @@ elm_index_item_del(Evas_Object *obj __UNUSED__, Elm_Object_Item *it)
 }
 
 EAPI Elm_Object_Item *
-elm_index_item_find(Evas_Object *obj, const void *item)
+elm_index_item_find(Evas_Object *obj, const void *data)
 {
    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return NULL;
-   return (Elm_Object_Item *) _item_find(obj, item);
+   return (Elm_Object_Item *) _item_find(obj, data);
 }
 
 EAPI void
@@ -1033,13 +1130,20 @@ elm_index_item_clear(Evas_Object *obj)
      }
 }
 
+EINA_DEPRECATED EAPI void
+elm_index_item_go(Evas_Object *obj, int level __UNUSED__)
+{
+   elm_index_level_go(obj, level);
+}
+
 EAPI void
-elm_index_item_go(Evas_Object *obj, int level)
+elm_index_level_go(Evas_Object *obj, int level __UNUSED__)
 {
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
-   if(level == 0) _index_process(obj);
+   //FIXME: Check the crash problem
+//   if(level == 0) _index_process(obj);
    _index_box_auto_fill(obj, wd->bx[0], 0);
    if (wd->level == 1) _index_box_auto_fill(obj, wd->bx[1], 1);
 }
@@ -1093,6 +1197,29 @@ EAPI const char *
 elm_index_item_letter_get(const Elm_Object_Item *it)
 {
    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
-   return ((Elm_Index_Item *) it)->letter;
+   return ((Elm_Index_Item *)it)->letter;
 }
 
+EAPI void
+elm_index_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+
+   horizontal = !!horizontal;
+   if (horizontal == wd->horizontal) return;
+   wd->horizontal = horizontal;
+   _theme_hook(obj);
+}
+
+EAPI Eina_Bool
+elm_index_horizontal_get(const Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return EINA_FALSE;
+   return wd->horizontal;
+}
+
+
index 075e9bf..992cf57 100644 (file)
@@ -48,7 +48,6 @@
  * @addtogroup Index
  * @{
  */
-
 /**
  * Add a new index widget to the given parent Elementary
  * (container) object
@@ -66,24 +65,26 @@ EAPI Evas_Object          *elm_index_add(Evas_Object *parent);
  * Enable or disable auto hiding feature for a given index widget.
  *
  * @param obj The index object
- * @param active @c EINA_TRUE to enable auto hiding, @c EINA_FALSE to disable
+ * @param disabled @c EINA_TRUE to disable auto hiding, @c EINA_FALSE to enable
  *
- * @see elm_index_active_get()
+ * @see elm_index_autohide_disabled_get()
  *
  * @ingroup Index
  */
+EAPI void                  elm_index_autohide_disabled_set(Evas_Object *obj, Eina_Bool disabled);
 EAPI void                  elm_index_active_set(Evas_Object *obj, Eina_Bool active);
 
 /**
  * Get whether auto hiding feature is enabled or not for a given index widget.
  *
  * @param obj The index object
- * @return @c EINA_TRUE, if auto hiding is enabled, @c EINA_FALSE otherwise
+ * @return @c EINA_TRUE, if auto hiding is disabled, @c EINA_FALSE otherwise
  *
  * @see elm_index_active_set() for more details
  *
  * @ingroup Index
  */
+EAPI Eina_Bool             elm_index_autohide_disabled_get(const Evas_Object *obj);
 EAPI Eina_Bool             elm_index_active_get(const Evas_Object *obj);
 
 /**
@@ -111,6 +112,28 @@ EAPI void                  elm_index_item_level_set(Evas_Object *obj, int level)
 EAPI int                   elm_index_item_level_get(const Evas_Object *obj);
 
 /**
+ * Set the selected state of an item.
+ *
+ * @param it The index item
+ * @param selected The selected state
+ *
+ * This sets the selected state of the given item @p it.
+ * @c EINA_TRUE for selected, @c EINA_FALSE for not selected.
+ *
+ * If a new item is selected the previously selected will be unselected.
+ * Previously selected item can be get with function
+ * elm_index_selected_item_get().
+ *
+ * Selected items will be highlighted.
+ *
+ * @see elm_index_item_selected_get()
+ * @see elm_index_selected_item_get()
+ *
+ * @ingroup Index
+ */
+EAPI void                  elm_index_item_selected_set(Elm_Object_Item *it, Eina_Bool selected);
+
+/**
  * Returns the last selected item, for a given index widget.
  *
  * @param obj The index object.
@@ -118,6 +141,7 @@ EAPI int                   elm_index_item_level_get(const Evas_Object *obj);
  *
  * @ingroup Index
  */
+EAPI Elm_Object_Item      *elm_index_selected_item_get(const Evas_Object *obj, int level);
 EAPI Elm_Object_Item      *elm_index_item_selected_get(const Evas_Object *obj, int level);
 
 /**
@@ -125,7 +149,9 @@ EAPI Elm_Object_Item      *elm_index_item_selected_get(const Evas_Object *obj, i
  *
  * @param obj The index object.
  * @param letter Letter under which the item should be indexed
- * @param item The item data to set for the index's item
+ * @param func The function to call when the item is selected.
+ * @param data The item data to set for the index's item
+ * @return A handle to the item added or @c NULL, on errors 
  *
  * Despite the most common usage of the @p letter argument is for
  * single char strings, one could use arbitrary strings as index
@@ -136,14 +162,16 @@ EAPI Elm_Object_Item      *elm_index_item_selected_get(const Evas_Object *obj, i
  *
  * @ingroup Index
  */
-EAPI void                  elm_index_item_append(Evas_Object *obj, const char *letter, const void *item);
+EAPI Elm_Object_Item      *elm_index_item_append(Evas_Object *obj, const char *letter, const void *data);
 
 /**
  * Prepend a new item on a given index widget.
  *
  * @param obj The index object.
  * @param letter Letter under which the item should be indexed
- * @param item The item data to set for the index's item
+ * @param func The function to call when the item is selected.
+ * @param data The item data to set for the index's item
+ * @return A handle to the item added or @c NULL, on errors 
  *
  * Despite the most common usage of the @p letter argument is for
  * single char strings, one could use arbitrary strings as index
@@ -154,16 +182,17 @@ EAPI void                  elm_index_item_append(Evas_Object *obj, const char *l
  *
  * @ingroup Index
  */
-EAPI void                  elm_index_item_prepend(Evas_Object *obj, const char *letter, const void *item);
+EAPI Elm_Object_Item      *elm_index_item_prepend(Evas_Object *obj, const char *letter, const void *data);
 
 /**
- * Append a new item, on a given index widget, <b>after the item
- * having @p relative as data</b>.
+ * Insert a new item into the index object after item @p after.
  *
  * @param obj The index object.
+ * @param after The index item to insert after.
  * @param letter Letter under which the item should be indexed
- * @param item The item data to set for the index's item
- * @param relative The index item to be the predecessor of this new one
+ * @param func The function to call when the item is clicked.
+ * @param data The item data to set for the index's item
+ * @return A handle to the item added or @c NULL, on errors 
  *
  * Despite the most common usage of the @p letter argument is for
  * single char strings, one could use arbitrary strings as index
@@ -177,16 +206,18 @@ EAPI void                  elm_index_item_prepend(Evas_Object *obj, const char *
  *
  * @ingroup Index
  */
-EAPI void                  elm_index_item_append_relative(Evas_Object *obj, const char *letter, const void *item, const Elm_Object_Item *relative);
+EAPI Elm_Object_Item      *elm_index_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *letter, Evas_Smart_Cb func, const void *data);
+EAPI Elm_Object_Item      *elm_index_item_append_relative(Evas_Object *obj, const char *letter, const void *data, const Elm_Object_Item *relative);
 
 /**
- * Prepend a new item, on a given index widget, <b>after the item
- * having @p relative as data</b>.
+ * Insert a new item into the index object before item @p before.
  *
  * @param obj The index object.
+ * @param before The index item to insert after.
  * @param letter Letter under which the item should be indexed
- * @param item The item data to set for the index's item
- * @param relative The index item to be the successor of this new one
+ * @param func The function to call when the item is clicked.
+ * @param data The item data to set for the index's item
+ * @return A handle to the item added or @c NULL, on errors 
  *
  * Despite the most common usage of the @p letter argument is for
  * single char strings, one could use arbitrary strings as index
@@ -200,7 +231,8 @@ EAPI void                  elm_index_item_append_relative(Evas_Object *obj, cons
  *
  * @ingroup Index
  */
-EAPI void                  elm_index_item_prepend_relative(Evas_Object *obj, const char *letter, const void *item, const Elm_Object_Item *relative);
+EAPI Elm_Object_Item      *elm_index_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *letter, Evas_Smart_Cb func, const void *data);
+EAPI Elm_Object_Item      *elm_index_item_prepend_relative(Evas_Object *obj, const char *letter, const void *data, const Elm_Object_Item *relative);
 
 /**
  * Insert a new item into the given index widget, using @p cmp_func
@@ -208,7 +240,8 @@ EAPI void                  elm_index_item_prepend_relative(Evas_Object *obj, con
  *
  * @param obj The index object.
  * @param letter Letter under which the item should be indexed
- * @param item The item data to set for the index's item
+ * @param func The function to call when the item is clicked.
+ * @param data The item data to set for the index's item
  * @param cmp_func The comparing function to be used to sort index
  * items <b>by #index item handles</b>
  * @param cmp_data_func A @b fallback function to be called for the
@@ -223,6 +256,7 @@ EAPI void                  elm_index_item_prepend_relative(Evas_Object *obj, con
  * because all references to it will be lost. If this function is
  * not provided (@c NULL is given), index items will be @b
  * duplicated, if @p cmp_func returns @c 0.
+ * @return A handle to the item added or @c NULL, on errors 
  *
  * Despite the most common usage of the @p letter argument is for
  * single char strings, one could use arbitrary strings as index
@@ -233,18 +267,18 @@ EAPI void                  elm_index_item_prepend_relative(Evas_Object *obj, con
  *
  * @ingroup Index
  */
-EAPI void                  elm_index_item_sorted_insert(Evas_Object *obj, const char *letter, const void *item, Eina_Compare_Cb cmp_func, Eina_Compare_Cb cmp_data_func);
+EAPI Elm_Object_Item     *elm_index_item_sorted_insert(Evas_Object *obj, const char *letter, const void *data, Eina_Compare_Cb cmp_func, Eina_Compare_Cb cmp_data_func);
 
 /**
  * Find a given index widget's item, <b>using item data</b>.
  *
  * @param obj The index object
- * @param item The item data pointed to by the desired index item
+ * @param data The item data pointed to by the desired index item
  * @return The index item handle, if found, or @c NULL otherwise
  *
  * @ingroup Index
  */
-EAPI Elm_Object_Item      *elm_index_item_find(Evas_Object *obj, const void *item);
+EAPI Elm_Object_Item      *elm_index_item_find(Evas_Object *obj, const void *data);
 
 /**
  * Removes @b all items from a given index widget.
@@ -266,6 +300,7 @@ EAPI void                  elm_index_item_clear(Evas_Object *obj);
  *
  * @ingroup Index
  */
+EAPI void                  elm_index_level_go(Evas_Object *obj, int level);
 EAPI void                  elm_index_item_go(Evas_Object *obj, int level);
 
 /**
@@ -302,9 +337,40 @@ EAPI void                 elm_index_indicator_disabled_set(Evas_Object *obj, Ein
  *
  * @ingroup Index
  */
-EAPI Eina_Bool                 elm_index_indicator_disabled_get(const Evas_Object *obj);
+EAPI Eina_Bool            elm_index_indicator_disabled_get(const Evas_Object *obj);
+
+/**
+ * Enable or disable horizontal mode on the index object
+ *
+ * @param obj The index object.
+ * @param horizontal @c EINA_TRUE to enable horizontal or @c EINA_FALSE to
+ * disable it, i.e., to enable vertical mode. it's an area one @ref Fingers
+ * "finger" wide on the bottom side of the index widget's container.
+ *
+ * @note Vertical mode is set by default.
+ *
+ * On horizontal mode items are displayed on index from left to right,
+ * instead of from top to bottom. Also, the index will scroll horizontally.
+ *
+ * @see elm_index_horizontal_get()
+ *
+ * @ingroup Index
+ */
+EAPI void                      elm_index_horizontal_set(Evas_Object *obj, Eina_Bool horizontal);
 
-EAPI void                  elm_index_button_image_invisible_set(Evas_Object *obj, Eina_Bool invisible);
+/**
+ * Get a value whether horizontal mode is enabled or not.
+ *
+ * @param obj The index object.
+ * @return @c EINA_TRUE means horizontal mode selection is enabled.
+ * @c EINA_FALSE indicates it's disabled. If @p obj is @c NULL,
+ * @c EINA_FALSE is returned.
+ *
+ * @see elm_index_horizontal_set() for details.
+ *
+ * @ingroup Index
+ */
+EAPI Eina_Bool                 elm_index_horizontal_get(const Evas_Object *obj);
 
 /**
  * @}