1 #include <Elementary.h>
5 typedef struct _Widget_Data Widget_Data;
6 typedef struct _Elm_Index_Item Elm_Index_Item;
11 Evas_Object *event[2];
12 Evas_Object *bx[2]; // 2 - for now all that's supported
13 Eina_List *items; // 1 list. yes N levels, but only 2 for now and # of items will be small
17 Eina_Bool level_active[2];
18 Eina_Bool horizontal : 1;
21 Eina_Bool indicator_disabled : 1;
24 struct _Elm_Index_Item
29 Eina_Bool selected : 1;
32 static const char *widtype = NULL;
34 static void _del_hook(Evas_Object *obj);
35 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
36 static void _theme_hook(Evas_Object *obj);
37 static void _sizing_eval(Evas_Object *obj);
38 static void _index_box_auto_fill(Evas_Object *obj, Evas_Object *box, int level);
39 static void _index_box_clear(Evas_Object *obj, Evas_Object *box, int level);
40 static void _item_free(Elm_Index_Item *it);
42 static const char SIG_CHANGED[] = "changed";
43 static const char SIG_DELAY_CHANGED[] = "delay,changed";
44 static const char SIG_SELECTED[] = "selected";
45 static const char SIG_LEVEL_UP[] = "level,up";
46 static const char SIG_LEVEL_DOWN[] = "level,down";
48 static const Evas_Smart_Cb_Description _signals[] = {
50 {SIG_DELAY_CHANGED, ""},
58 _del_pre_hook(Evas_Object *obj)
60 Widget_Data *wd = elm_widget_data_get(obj);
63 _index_box_clear(obj, wd->bx[wd->level], wd->level);
64 _index_box_clear(obj, wd->bx[0], 0);
69 elm_widget_item_free(it);
71 if (wd->delay) ecore_timer_del(wd->delay);
75 _del_hook(Evas_Object *obj)
77 Widget_Data *wd = elm_widget_data_get(obj);
82 _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
84 Widget_Data *wd = data;
86 _els_box_layout(o, priv, wd->horizontal, 1, 0);
90 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
92 Widget_Data *wd = elm_widget_data_get(obj);
94 edje_object_signal_emit(wd->base, emission, source);
98 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
100 Widget_Data *wd = elm_widget_data_get(obj);
102 edje_object_signal_callback_add(wd->base, emission, source, func_cb, data);
106 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
108 Widget_Data *wd = elm_widget_data_get(obj);
109 edje_object_signal_callback_del_full(wd->base, emission, source, func_cb,
114 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
116 Widget_Data *wd = elm_widget_data_get(obj);
119 edje_object_mirrored_set(wd->base, rtl);
123 _theme_hook(Evas_Object *obj)
125 Evas_Coord minw = 0, minh = 0;
126 Widget_Data *wd = elm_widget_data_get(obj);
128 _elm_widget_mirrored_reload(obj);
130 _index_box_clear(obj, wd->bx[0], 0);
131 _index_box_clear(obj, wd->bx[1], 1);
133 _elm_theme_object_set(obj, wd->base, "index", "base/horizontal", elm_widget_style_get(obj));
136 _elm_theme_object_set(obj, wd->base, "index", "base/vertical", elm_widget_style_get(obj));
137 _mirrored_set(obj, elm_widget_mirrored_get(obj));
139 edje_object_part_swallow(wd->base, "elm.swallow.event.0", wd->event[0]);
140 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
141 evas_object_size_hint_min_set(wd->event[0], minw, minh);
142 edje_object_part_swallow(wd->base, "elm.swallow.index.0", wd->bx[0]);
143 if (edje_object_part_exists(wd->base, "elm.swallow.index.1"))
147 wd->bx[1] = evas_object_box_add(evas_object_evas_get(wd->base));
148 evas_object_box_layout_set(wd->bx[1], _layout, wd, NULL);
149 elm_widget_sub_object_add(obj, wd->bx[1]);
151 edje_object_part_swallow(wd->base, "elm.swallow.index.1", wd->bx[1]);
152 evas_object_show(wd->bx[1]);
156 evas_object_del(wd->bx[1]);
159 if (edje_object_part_exists(wd->base, "elm.swallow.event.1"))
163 wd->event[1] = evas_object_rectangle_add(evas_object_evas_get(wd->base));
164 evas_object_color_set(wd->event[1], 0, 0, 0, 0);
165 elm_widget_sub_object_add(obj, wd->event[1]);
167 edje_object_part_swallow(wd->base, "elm.swallow.event.1", wd->event[1]);
168 evas_object_size_hint_min_set(wd->event[1], minw, minh);
170 else if (wd->event[1])
172 evas_object_del(wd->event[1]);
175 edje_object_message_signal_process(wd->base);
176 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
178 _index_box_auto_fill(obj, wd->bx[0], 0);
181 _index_box_auto_fill(obj, wd->bx[1], 1);
185 _sizing_eval(Evas_Object *obj)
187 Widget_Data *wd = elm_widget_data_get(obj);
188 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
190 edje_object_size_min_calc(wd->base, &minw, &minh);
191 evas_object_size_hint_min_set(obj, minw, minh);
192 evas_object_size_hint_max_set(obj, maxw, maxh);
196 _item_del_pre_hook(Elm_Object_Item *it)
198 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
199 if (!wd) return EINA_FALSE;
200 _item_free((Elm_Index_Item *) it);
201 _index_box_clear(WIDGET(it), wd->bx[wd->level], wd->level);
205 static Elm_Index_Item *
206 _item_new(Evas_Object *obj, const char *letter, const void *item)
208 Widget_Data *wd = elm_widget_data_get(obj);
210 if (!wd) return NULL;
211 it = elm_widget_item_new(obj, Elm_Index_Item);
212 if (!it) return NULL;
213 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
214 if (letter) it->letter = eina_stringshare_add(letter);
215 it->base.data = item;
216 it->level = wd->level;
220 static Elm_Index_Item *
221 _item_find(Evas_Object *obj, const void *item)
223 Widget_Data *wd = elm_widget_data_get(obj);
226 if (!wd) return NULL;
227 EINA_LIST_FOREACH(wd->items, l, it)
228 if (it->base.data == item) return it;
233 _item_free(Elm_Index_Item *it)
235 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
237 wd->items = eina_list_remove(wd->items, it);
238 if (it->letter) eina_stringshare_del(it->letter);
241 // FIXME: always have index filled
243 _index_box_auto_fill(Evas_Object *obj, Evas_Object *box, int level)
245 Widget_Data *wd = elm_widget_data_get(obj);
249 Evas_Coord mw, mh, w, h;
252 if (wd->level_active[level]) return;
253 rtl = elm_widget_mirrored_get(obj);
254 evas_object_geometry_get(box, NULL, NULL, &w, &h);
255 EINA_LIST_FOREACH(wd->items, l, it)
258 const char *stacking;
260 if (it->level != level) continue;
261 o = edje_object_add(evas_object_evas_get(obj));
263 edje_object_mirrored_set(VIEW(it), rtl);
265 _elm_theme_object_set(obj, o, "index", "item_odd/vertical", elm_widget_style_get(obj));
267 _elm_theme_object_set(obj, o, "index", "item/vertical", elm_widget_style_get(obj));
268 edje_object_part_text_set(o, "elm.text", it->letter);
269 edje_object_size_min_restricted_calc(o, &mw, &mh, 0, 0);
270 evas_object_size_hint_min_set(o, mw, mh);
271 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
272 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
273 elm_widget_sub_object_add(obj, o);
274 evas_object_box_append(box, o);
275 stacking = edje_object_data_get(o, "stacking");
278 if (!strcmp(stacking, "below")) evas_object_lower(o);
279 else if (!strcmp(stacking, "above")) evas_object_raise(o);
283 evas_object_smart_calculate(box); // force a calc so we know the size
284 evas_object_size_hint_min_get(box, &mw, &mh);
287 _index_box_clear(obj, box, level);
290 // FIXME: only i objects fit! try again. overflows right now
294 evas_object_smart_calculate(box);
295 wd->level_active[level] = 1;
299 _index_box_clear(Evas_Object *obj, Evas_Object *box __UNUSED__, int level)
301 Widget_Data *wd = elm_widget_data_get(obj);
305 if (!wd->level_active[level]) return;
306 EINA_LIST_FOREACH(wd->items, l, it)
308 if (!VIEW(it)) continue;
309 if (it->level != level) continue;
310 evas_object_del(VIEW(it));
313 wd->level_active[level] = 0;
317 _delay_change(void *data)
319 Widget_Data *wd = elm_widget_data_get(data);
320 Elm_Object_Item *item;
321 if (!wd) return ECORE_CALLBACK_CANCEL;
323 item = elm_index_item_selected_get(data, wd->level);
324 if (item) evas_object_smart_callback_call(data, SIG_DELAY_CHANGED, item);
325 return ECORE_CALLBACK_CANCEL;
329 _sel_eval(Evas_Object *obj, Evas_Coord evx, Evas_Coord evy)
331 Widget_Data *wd = elm_widget_data_get(obj);
332 Elm_Index_Item *it, *it_closest, *it_last;
334 Evas_Coord x, y, w, h, bx, by, bw, bh, xx, yy;
337 char *label = NULL, *last = NULL;
340 for (i = 0; i <= wd->level; i++)
345 evas_object_geometry_get(wd->bx[i], &bx, &by, &bw, &bh);
346 EINA_LIST_FOREACH(wd->items, l, it)
348 if (!((it->level == i) && (VIEW(it)))) continue;
349 if ((VIEW(it)) && (it->level != wd->level))
363 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
368 x = (x * x) + (y * y);
369 if ((x < dist) || (!it_closest))
372 cdv = (double)(xx - bx) / (double)bw;
374 cdv = (double)(yy - by) / (double)bh;
379 if ((i == 0) && (wd->level == 0))
380 edje_object_part_drag_value_set(wd->base, "elm.dragable.index.1",
382 if (it_closest) it_closest->selected = 1;
383 if (it_closest != it_last)
387 const char *stacking, *selectraise;
390 edje_object_signal_emit(VIEW(it), "elm,state,inactive", "elm");
391 stacking = edje_object_data_get(VIEW(it), "stacking");
392 selectraise = edje_object_data_get(VIEW(it), "selectraise");
393 if ((selectraise) && (!strcmp(selectraise, "on")))
395 if ((stacking) && (!strcmp(stacking, "below")))
396 evas_object_lower(VIEW(it));
401 const char *selectraise;
404 edje_object_signal_emit(VIEW(it), "elm,state,active", "elm");
405 selectraise = edje_object_data_get(VIEW(it), "selectraise");
406 if ((selectraise) && (!strcmp(selectraise, "on")))
407 evas_object_raise(VIEW(it));
408 evas_object_smart_callback_call((void *)obj, SIG_CHANGED, (void *)it);
409 if (wd->delay) ecore_timer_del(wd->delay);
410 wd->delay = ecore_timer_add(0.2, _delay_change, obj);
417 last = strdup(it->letter);
420 if (!label) label = strdup(last);
423 /* FIXME: realloc return NULL if the request fails */
424 label = realloc(label, strlen(label) + strlen(last) + 1);
428 last = strdup(it->letter);
432 if (!label) label = strdup("");
433 if (!last) last = strdup("");
434 edje_object_part_text_set(wd->base, "elm.text.body", label);
435 edje_object_part_text_set(wd->base, "elm.text", last);
441 _wheel(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
443 Widget_Data *wd = elm_widget_data_get(data);
444 // Evas_Event_Mouse_Wheel *ev = event_info;
445 // Evas_Object *obj = o;
450 _mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info)
452 Widget_Data *wd = elm_widget_data_get(data);
453 Evas_Event_Mouse_Down *ev = event_info;
456 if (ev->button != 1) return;
458 evas_object_geometry_get(wd->base, &x, &y, &w, NULL);
459 wd->dx = ev->canvas.x - x;
460 wd->dy = ev->canvas.y - y;
461 elm_index_active_set(data, 1);
462 _sel_eval(data, ev->canvas.x, ev->canvas.y);
463 edje_object_part_drag_value_set(wd->base, "elm.dragable.pointer",
464 (!edje_object_mirrored_get(wd->base)) ? wd->dx : (wd->dx - w), wd->dy);
465 if (wd->items && !wd->indicator_disabled)
466 edje_object_signal_emit(wd->base, "elm,indicator,state,active", "elm");
470 _mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info)
472 Widget_Data *wd = elm_widget_data_get(data);
473 Evas_Event_Mouse_Up *ev = event_info;
474 Elm_Object_Item *item;
476 if (ev->button != 1) return;
478 item = elm_index_item_selected_get(data, wd->level);
479 if (item) evas_object_smart_callback_call(data, SIG_SELECTED, item);
480 elm_index_active_set(data, 0);
481 edje_object_signal_emit(wd->base, "elm,state,level,0", "elm");
482 if (wd->items && !wd->indicator_disabled)
483 edje_object_signal_emit(wd->base, "elm,indicator,state,inactive", "elm");
487 _mouse_move(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info)
489 Widget_Data *wd = elm_widget_data_get(data);
490 Evas_Event_Mouse_Move *ev = event_info;
491 Evas_Coord minw = 0, minh = 0, x, y, dx, adx, w;
494 if (!wd->down) return;
495 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
496 evas_object_geometry_get(wd->base, &x, &y, &w, NULL);
497 x = ev->cur.canvas.x - x;
498 y = ev->cur.canvas.y - y;
501 if (adx < 0) adx = -dx;
502 edje_object_part_drag_value_set(wd->base, "elm.dragable.pointer"
503 , (!edje_object_mirrored_get(wd->base)) ? x : (x - w), y);
511 snprintf(buf, sizeof(buf), "elm,state,level,%i", wd->level);
512 edje_object_signal_emit(wd->base, buf, "elm");
513 evas_object_smart_callback_call(data, SIG_LEVEL_UP, NULL);
521 snprintf(buf, sizeof(buf), "elm,state,level,%i", wd->level);
522 edje_object_signal_emit(wd->base, buf, "elm");
523 evas_object_smart_callback_call(data, SIG_LEVEL_DOWN, NULL);
527 _sel_eval(data, ev->cur.canvas.x, ev->cur.canvas.y);
531 elm_index_add(Evas_Object *parent)
537 Evas_Coord minw, minh;
539 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
541 ELM_SET_WIDTYPE(widtype, "index");
542 elm_widget_type_set(obj, "index");
543 elm_widget_sub_object_add(parent, obj);
544 elm_widget_data_set(obj, wd);
545 elm_widget_del_hook_set(obj, _del_hook);
546 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
547 elm_widget_theme_hook_set(obj, _theme_hook);
548 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
549 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
550 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
551 elm_widget_can_focus_set(obj, EINA_FALSE);
553 wd->indicator_disabled = EINA_FALSE;
554 wd->horizontal = EINA_FALSE;
556 wd->base = edje_object_add(e);
557 _elm_theme_object_set(obj, wd->base, "index", "base/vertical", "default");
558 elm_widget_resize_object_set(obj, wd->base);
560 o = evas_object_rectangle_add(e);
562 evas_object_color_set(o, 0, 0, 0, 0);
564 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
565 evas_object_size_hint_min_set(o, minw, minh);
566 edje_object_part_swallow(wd->base, "elm.swallow.event.0", o);
567 elm_widget_sub_object_add(obj, o);
568 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_WHEEL, _wheel, obj);
569 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, obj);
570 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _mouse_up, obj);
571 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move, obj);
573 if (edje_object_part_exists(wd->base, "elm.swallow.event.1"))
575 o = evas_object_rectangle_add(e);
577 evas_object_color_set(o, 0, 0, 0, 0);
578 evas_object_size_hint_min_set(o, minw, minh);
579 edje_object_part_swallow(wd->base, "elm.swallow.event.1", o);
580 elm_widget_sub_object_add(obj, o);
583 wd->bx[0] = evas_object_box_add(e);
584 evas_object_box_layout_set(wd->bx[0], _layout, wd, NULL);
585 elm_widget_sub_object_add(obj, wd->bx[0]);
586 edje_object_part_swallow(wd->base, "elm.swallow.index.0", wd->bx[0]);
587 evas_object_show(wd->bx[0]);
589 if (edje_object_part_exists(wd->base, "elm.swallow.index.1"))
591 wd->bx[1] = evas_object_box_add(e);
592 evas_object_box_layout_set(wd->bx[1], _layout, wd, NULL);
593 elm_widget_sub_object_add(obj, wd->bx[1]);
594 edje_object_part_swallow(wd->base, "elm.swallow.index.1", wd->bx[1]);
595 evas_object_show(wd->bx[1]);
598 evas_object_smart_callbacks_descriptions_set(obj, _signals);
600 _mirrored_set(obj, elm_widget_mirrored_get(obj));
606 elm_index_active_set(Evas_Object *obj, Eina_Bool active)
608 ELM_CHECK_WIDTYPE(obj, widtype);
609 Widget_Data *wd = elm_widget_data_get(obj);
611 if (wd->active == active) return;
616 _index_box_clear(obj, wd->bx[1], 1);
617 _index_box_auto_fill(obj, wd->bx[0], 0);
618 edje_object_signal_emit(wd->base, "elm,state,active", "elm");
621 edje_object_signal_emit(wd->base, "elm,state,inactive", "elm");
625 elm_index_active_get(const Evas_Object *obj)
627 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
628 Widget_Data *wd = elm_widget_data_get(obj);
629 if (!wd) return EINA_FALSE;
634 elm_index_item_level_set(Evas_Object *obj, int level)
636 ELM_CHECK_WIDTYPE(obj, widtype);
637 Widget_Data *wd = elm_widget_data_get(obj);
639 if (wd->level == level) return;
644 elm_index_item_level_get(const Evas_Object *obj)
646 ELM_CHECK_WIDTYPE(obj, widtype) 0;
647 Widget_Data *wd = elm_widget_data_get(obj);
652 EAPI Elm_Object_Item *
653 elm_index_item_selected_get(const Evas_Object *obj, int level)
655 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
656 Widget_Data *wd = elm_widget_data_get(obj);
659 if (!wd) return NULL;
660 EINA_LIST_FOREACH(wd->items, l, it)
662 if ((it->selected) && (it->level == level))
663 return (Elm_Object_Item *) it;
668 EAPI Elm_Object_Item *
669 elm_index_item_append(Evas_Object *obj, const char *letter, const void *item)
671 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
672 Widget_Data *wd = elm_widget_data_get(obj);
674 if (!wd) return NULL;
675 it = _item_new(obj, letter, item);
676 if (!it) return NULL;
677 wd->items = eina_list_append(wd->items, it);
678 _index_box_clear(obj, wd->bx[wd->level], wd->level);
679 return (Elm_Object_Item *) it;
682 EAPI Elm_Object_Item *
683 elm_index_item_prepend(Evas_Object *obj, const char *letter, const void *item)
685 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
686 Widget_Data *wd = elm_widget_data_get(obj);
689 if (!wd) return NULL;
690 it = _item_new(obj, letter, item);
691 if (!it) return NULL;
692 wd->items = eina_list_prepend(wd->items, it);
693 _index_box_clear(obj, wd->bx[wd->level], wd->level);
694 return (Elm_Object_Item *) it;
697 EAPI Elm_Object_Item *
698 elm_index_item_append_relative(Evas_Object *obj, const char *letter, const void *item, const Elm_Object_Item *relative)
700 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
701 Widget_Data *wd = elm_widget_data_get(obj);
703 if (!wd) return NULL;
705 return elm_index_item_append(obj, letter, item);
706 it = _item_new(obj, letter, item);
707 if (!it) return NULL;
708 wd->items = eina_list_append_relative(wd->items, it, relative);
709 _index_box_clear(obj, wd->bx[wd->level], wd->level);
710 return (Elm_Object_Item *) it;
714 EAPI Elm_Object_Item *
715 elm_index_item_prepend_relative(Evas_Object *obj, const char *letter, const void *item, const Elm_Object_Item *relative)
717 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
718 Widget_Data *wd = elm_widget_data_get(obj);
720 if (!wd) return NULL;
722 return elm_index_item_prepend(obj, letter, item);
723 it = _item_new(obj, letter, item);
724 if (!it) return NULL;
725 wd->items = eina_list_prepend_relative(wd->items, it, relative);
726 _index_box_clear(obj, wd->bx[wd->level], wd->level);
727 return (Elm_Object_Item *) it;
730 EAPI Elm_Object_Item *
731 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)
733 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
734 Widget_Data *wd = elm_widget_data_get(obj);
739 if (!wd) return NULL;
741 return elm_index_item_append(obj, letter, item);
743 it = _item_new(obj, letter, item);
744 if (!it) return NULL;
746 lnear = eina_list_search_sorted_near_list(wd->items, cmp_func, it, &cmp);
748 wd->items = eina_list_append_relative_list(wd->items, it, lnear);
750 wd->items = eina_list_prepend_relative_list(wd->items, it, lnear);
753 /* If cmp_data_func is not provided, append a duplicated item */
755 wd->items = eina_list_append_relative_list(wd->items, it, lnear);
758 Elm_Index_Item *p_it = eina_list_data_get(lnear);
759 if (cmp_data_func(p_it->base.data, it->base.data) >= 0)
760 p_it->base.data = it->base.data;
762 elm_widget_item_free(it);
766 _index_box_clear(obj, wd->bx[wd->level], wd->level);
768 return (Elm_Object_Item *) it;
772 elm_index_item_del(Evas_Object *obj __UNUSED__, Elm_Object_Item *it)
774 elm_object_item_del(it);
777 EAPI Elm_Object_Item *
778 elm_index_item_find(Evas_Object *obj, const void *item)
780 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
781 Widget_Data *wd = elm_widget_data_get(obj);
782 if (!wd) return NULL;
783 return (Elm_Object_Item *) _item_find(obj, item);
787 elm_index_item_clear(Evas_Object *obj)
789 ELM_CHECK_WIDTYPE(obj, widtype);
790 Widget_Data *wd = elm_widget_data_get(obj);
792 Eina_List *l, *clear = NULL;
794 _index_box_clear(obj, wd->bx[wd->level], wd->level);
795 EINA_LIST_FOREACH(wd->items, l, it)
797 if (it->level != wd->level) continue;
798 clear = eina_list_append(clear, it);
800 EINA_LIST_FREE(clear, it)
803 elm_widget_item_free(it);
808 elm_index_item_go(Evas_Object *obj, int level __UNUSED__)
810 ELM_CHECK_WIDTYPE(obj, widtype);
811 Widget_Data *wd = elm_widget_data_get(obj);
813 _index_box_auto_fill(obj, wd->bx[0], 0);
814 if (wd->level == 1) _index_box_auto_fill(obj, wd->bx[1], 1);
818 elm_index_item_data_get(const Elm_Object_Item *it)
820 return elm_object_item_data_get(it);
824 elm_index_item_data_set(Elm_Object_Item *it, const void *data)
826 elm_object_item_data_set(it, (void *) data);
830 elm_index_indicator_disabled_set(Evas_Object *obj, Eina_Bool disabled)
832 ELM_CHECK_WIDTYPE(obj, widtype);
833 Widget_Data *wd = elm_widget_data_get(obj);
836 disabled = !!disabled;
837 if (wd->indicator_disabled == disabled) return;
838 wd->indicator_disabled = disabled;
839 if (!wd->items) return;
841 edje_object_signal_emit(wd->base, "elm,indicator,state,inactive", "elm");
843 edje_object_signal_emit(wd->base, "elm,indicator,state,active", "elm");
847 elm_index_indicator_disabled_get(const Evas_Object *obj)
849 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
850 Widget_Data *wd = elm_widget_data_get(obj);
851 if (!wd) return EINA_FALSE;
853 return wd->indicator_disabled;
857 elm_index_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func)
859 elm_object_item_del_cb_set(it, func);
863 elm_index_item_letter_get(const Elm_Object_Item *it)
865 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
866 return ((Elm_Index_Item *) it)->letter;