fix bug hermet added in font code! :)
[framework/uifw/elementary.git] / src / lib / elm_index.c
index a3a83df..b4670db 100644 (file)
@@ -265,14 +265,34 @@ _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));
-        edje_object_part_text_set(o, "elm.text", it->letter);
+          {
+             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_escaped_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);
@@ -352,8 +372,8 @@ _sel_eval(Evas_Object *obj, Evas_Coord evx, Evas_Coord evy)
         evas_object_geometry_get(wd->bx[i], &bx, &by, &bw, &bh);
         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)
                     {
@@ -420,26 +440,30 @@ _sel_eval(Evas_Object *obj, Evas_Coord evx, Evas_Coord evy)
         if (it_closest)
           {
              it = it_closest;
-             if (!last)
+             if (!last && it->letter)
                last = strdup(it->letter);
              else
                {
-                  if (!label) label = strdup(last);
+                  if (!label && last) label = strdup(last);
                   else
                     {
-                       /* FIXME: realloc return NULL if the request fails */
-                       label = realloc(label, strlen(label) + strlen(last) + 1);
-                       strcat(label, last);
+                       if (label && last)
+                         {
+                            label = realloc(label, strlen(label) +
+                                            strlen(last) + 1);
+                            if (!label) return;
+                            strcat(label, last);
+                         }
                     }
                   free(last);
-                  last = strdup(it->letter);
+                  if (it->letter) last = strdup(it->letter);
                }
           }
      }
    if (!label) label = strdup("");
    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_part_text_escaped_set(wd->base, "elm.text.body", label);
+   edje_object_part_text_escaped_set(wd->base, "elm.text", last);
    free(label);
    free(last);
 }
@@ -623,18 +647,6 @@ elm_index_add(Evas_Object *parent)
    return obj;
 }
 
-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)
 {
@@ -653,6 +665,8 @@ elm_index_autohide_disabled_set(Evas_Object *obj, Eina_Bool disabled)
      }
    else
      edje_object_signal_emit(wd->base, "elm,state,inactive", "elm");
+
+   //FIXME: Should be update indicator based on the indicator visiblility
 }
 
 EAPI Eina_Bool
@@ -683,10 +697,24 @@ elm_index_item_level_get(const Evas_Object *obj)
    return wd->level;
 }
 
-EINA_DEPRECATED EAPI Elm_Object_Item *
-elm_index_item_selected_get(const Evas_Object *obj, int level)
+EAPI void
+elm_index_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
 {
-   return elm_index_selected_item_get(obj, level);
+   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);
+
 }
 
 EAPI Elm_Object_Item *
@@ -735,12 +763,6 @@ elm_index_item_prepend(Evas_Object *obj, const char *letter, Evas_Smart_Cb func,
 }
 
 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)
-{
-   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);
@@ -815,12 +837,6 @@ elm_index_item_sorted_insert(Evas_Object *obj, const char *letter, Evas_Smart_Cb
    return (Elm_Object_Item *)it;
 }
 
-EAPI void
-elm_index_item_del(Evas_Object *obj __UNUSED__, Elm_Object_Item *it)
-{
-   elm_object_item_del(it);
-}
-
 EAPI Elm_Object_Item *
 elm_index_item_find(Evas_Object *obj, const void *data)
 {
@@ -851,12 +867,6 @@ 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_level_go(Evas_Object *obj, int level __UNUSED__)
 {
@@ -867,18 +877,6 @@ elm_index_level_go(Evas_Object *obj, int level __UNUSED__)
    if (wd->level == 1) _index_box_auto_fill(obj, wd->bx[1], 1);
 }
 
-EAPI void *
-elm_index_item_data_get(const Elm_Object_Item *it)
-{
-   return elm_object_item_data_get(it);
-}
-
-EAPI void
-elm_index_item_data_set(Elm_Object_Item *it, const void *data)
-{
-   elm_object_item_data_set(it, (void *) data);
-}
-
 EAPI void
 elm_index_indicator_disabled_set(Evas_Object *obj, Eina_Bool disabled)
 {
@@ -906,12 +904,6 @@ elm_index_indicator_disabled_get(const Evas_Object *obj)
    return wd->indicator_disabled;
 }
 
-EAPI void
-elm_index_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func)
-{
-   elm_object_item_del_cb_set(it, func);
-}
-
 EAPI const char *
 elm_index_item_letter_get(const Elm_Object_Item *it)
 {
@@ -919,3 +911,24 @@ elm_index_item_letter_get(const Elm_Object_Item *it)
    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;
+}