1 #include <Elementary.h>
5 * @defgroup Toolbar Toolbar
8 * A toolbar is a widget that displays a list of buttons inside
9 * a box. It is scrollable, and only one item can be selected at a time.
12 typedef struct _Widget_Data Widget_Data;
16 Evas_Object *scr, *bx;
19 Eina_Bool scrollable : 1;
20 Evas_Object *menu_parent;
21 Eina_Bool homogeneous : 1;
25 struct _Elm_Toolbar_Item
34 Eina_Bool selected : 1;
35 Eina_Bool disabled : 1;
36 Eina_Bool separator : 1;
41 static const char *widtype = NULL;
42 static void _item_show(Elm_Toolbar_Item *it);
43 static void _item_select(Elm_Toolbar_Item *it);
44 static void _item_disable(Elm_Toolbar_Item *it, Eina_Bool disabled);
45 static void _del_pre_hook(Evas_Object *obj);
46 static void _del_hook(Evas_Object *obj);
47 static void _theme_hook(Evas_Object *obj);
48 static void _sizing_eval(Evas_Object *obj);
49 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
50 static void _menu_move_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
51 static void _menu_hide(void *data, Evas *e, Evas_Object *obj, void *event_info);
52 static void _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
55 _item_show(Elm_Toolbar_Item *it)
57 Widget_Data *wd = elm_widget_data_get(it->obj);
58 Evas_Coord x, y, w, h, bx, by;
61 evas_object_geometry_get(wd->bx, &bx, &by, NULL, NULL);
62 evas_object_geometry_get(it->base, &x, &y, &w, &h);
63 elm_smart_scroller_child_region_show(wd->scr, x - bx, y - by, w, h);
67 _item_select(Elm_Toolbar_Item *it)
69 Elm_Toolbar_Item *it2;
70 Widget_Data *wd = elm_widget_data_get(it->obj);
75 if ((it->selected) || (it->disabled) || (it->separator)) return;
76 EINA_LIST_FOREACH(wd->items, l, it2)
80 it2->selected = EINA_FALSE;
81 edje_object_signal_emit(it2->base, "elm,state,unselected", "elm");
85 it->selected = EINA_TRUE;
86 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
91 evas_object_show(it->o_menu);
92 evas_object_event_callback_add(it->base, EVAS_CALLBACK_RESIZE,
93 _menu_move_resize, it);
94 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOVE,
95 _menu_move_resize, it);
97 _menu_move_resize(it, NULL, NULL, NULL);
99 if (it->func) it->func((void *)(it->data), it->obj, it);
100 evas_object_smart_callback_call(obj2, "clicked", it);
104 _menu_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
106 Elm_Toolbar_Item *it = data;
107 elm_toolbar_item_unselect_all(it->obj);
111 _menu_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
113 // avoid hide being emitted during object deletion
114 evas_object_event_callback_del_full
115 (obj, EVAS_CALLBACK_HIDE, _menu_hide, data);
119 _menu_move_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
121 Elm_Toolbar_Item *it = data;
123 Widget_Data *wd = elm_widget_data_get(it->obj);
125 if ((!wd) || (!wd->menu_parent)) return;
126 evas_object_geometry_get(it->base, &x, &y, &w, &h);
127 elm_menu_move(it->o_menu, x, y+h);
131 _item_disable(Elm_Toolbar_Item *it, Eina_Bool disabled)
133 Widget_Data *wd = elm_widget_data_get(it->obj);
136 if (it->disabled == disabled) return;
137 it->disabled = disabled;
139 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
141 edje_object_signal_emit(it->base, "elm,state,enabled", "elm");
145 _del_pre_hook(Evas_Object *obj)
147 Widget_Data *wd = elm_widget_data_get(obj);
148 Elm_Toolbar_Item *it;
151 EINA_LIST_FREE(wd->items, it)
153 if (it->del_cb) it->del_cb((void *)it->data, it->obj, it);
154 eina_stringshare_del(it->label);
155 if (it->icon) evas_object_del(it->icon);
156 if ((!wd->menu_parent) && (it->o_menu)) evas_object_del(it->o_menu);
157 evas_object_del(it->base);
163 _del_hook(Evas_Object *obj)
165 Widget_Data *wd = elm_widget_data_get(obj);
172 _theme_hook(Evas_Object *obj)
174 Widget_Data *wd = elm_widget_data_get(obj);
176 Elm_Toolbar_Item *it;
177 const char *style = elm_widget_style_get(obj);
181 elm_smart_scroller_object_theme_set(obj, wd->scr, "toolbar", "base", elm_widget_style_get(obj));
182 scale = (elm_widget_scale_get(obj) * _elm_config->scale);
183 // edje_object_scale_set(wd->scr, scale);
184 EINA_LIST_FOREACH(wd->items, l, it)
188 edje_object_scale_set(it->base, scale);
192 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
194 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
195 _elm_theme_object_set(obj, it->base, "toolbar", "item", style);
200 ms = ((double)wd->icon_size * _elm_config->scale);
201 evas_object_size_hint_min_set(it->icon, ms, ms);
202 evas_object_size_hint_max_set(it->icon, ms, ms);
203 edje_object_part_swallow(it->base, "elm.swallow.icon",
206 edje_object_part_text_set(it->base, "elm.text", it->label);
209 _elm_theme_object_set(obj, it->base, "toolbar", "separator", style);
213 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
214 edje_object_size_min_restricted_calc(it->base, &mw, &mh, mw, mh);
216 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
217 evas_object_size_hint_min_set(it->base, mw, mh);
223 _sizing_eval(Evas_Object *obj)
225 Widget_Data *wd = elm_widget_data_get(obj);
226 Evas_Coord minw = -1, minh = -1;
227 Evas_Coord vw = 0, vh = 0;
231 evas_object_smart_calculate(wd->bx);
232 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
234 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
235 if (w < minw) w = minw;
236 if (h < minh) h = minh;
238 evas_object_resize(wd->scr, w, h);
240 evas_object_size_hint_min_get(wd->bx, &minw, &minh);
241 if (w > minw) minw = w;
242 evas_object_resize(wd->bx, minw, minh);
243 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
247 minw = minw + (w - vw);
248 minh = minh + (h - vh);
249 evas_object_size_hint_min_set(obj, minw, minh);
250 evas_object_size_hint_max_set(obj, -1, -1);
254 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
256 Widget_Data *wd = elm_widget_data_get(data);
257 Evas_Coord mw, mh, vw, vh, w, h;
259 Elm_Toolbar_Item *it;
262 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
263 evas_object_size_hint_min_get(wd->bx, &mw, &mh);
264 evas_object_geometry_get(wd->bx, NULL, NULL, &w, &h);
267 if (w != vw) evas_object_resize(wd->bx, vw, h);
269 EINA_LIST_FOREACH(wd->items, l, it)
280 _select(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
286 _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
288 Widget_Data *wd = data;
290 _els_box_layout(o, priv, 1, wd->homogeneous);
294 * Add a toolbar object to @p parent.
296 * @param parent The parent object
298 * @return The created object, or NULL on failure
303 elm_toolbar_add(Evas_Object *parent)
309 wd = ELM_NEW(Widget_Data);
310 e = evas_object_evas_get(parent);
311 obj = elm_widget_add(e);
312 ELM_SET_WIDTYPE(widtype, "toolbar");
313 elm_widget_type_set(obj, "toolbar");
314 elm_widget_sub_object_add(parent, obj);
315 elm_widget_data_set(obj, wd);
316 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
317 elm_widget_del_hook_set(obj, _del_hook);
318 elm_widget_theme_hook_set(obj, _theme_hook);
319 elm_widget_can_focus_set(obj, 0);
321 wd->scr = elm_smart_scroller_add(e);
322 elm_smart_scroller_widget_set(wd->scr, obj);
323 elm_smart_scroller_object_theme_set(obj, wd->scr, "toolbar", "base", "default");
324 elm_smart_scroller_bounce_allow_set(wd->scr, 1, 0);
325 elm_widget_resize_object_set(obj, wd->scr);
326 elm_smart_scroller_policy_set(wd->scr,
327 ELM_SMART_SCROLLER_POLICY_AUTO,
328 ELM_SMART_SCROLLER_POLICY_OFF);
331 wd->scrollable = EINA_TRUE;
332 wd->homogeneous = EINA_TRUE;
335 wd->bx = evas_object_box_add(e);
336 evas_object_size_hint_align_set(wd->bx, wd->align, 0.5);
337 evas_object_box_layout_set(wd->bx, _layout, wd, NULL);
338 elm_widget_sub_object_add(obj, wd->bx);
339 elm_smart_scroller_child_set(wd->scr, wd->bx);
340 evas_object_show(wd->bx);
342 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_RESIZE, _resize, obj);
349 * Set the icon size (in pixels) for the toolbar.
351 * @param obj The toolbar object
352 * @param icon_size The icon size in pixels
357 elm_toolbar_icon_size_set(Evas_Object *obj, int icon_size)
359 ELM_CHECK_WIDTYPE(obj, widtype);
360 Widget_Data *wd = elm_widget_data_get(obj);
362 if (icon_size > 48) return;
363 if (wd->icon_size == icon_size) return;
364 wd->icon_size = icon_size;
369 * Get the icon size (in pixels) for the toolbar.
371 * @param obj The toolbar object
372 * @return The icon size in pixels
377 elm_toolbar_icon_size_get(const Evas_Object *obj)
379 ELM_CHECK_WIDTYPE(obj, widtype) 0;
380 Widget_Data *wd = elm_widget_data_get(obj);
382 return wd->icon_size;
386 * Add an item to the toolbar.
388 * @param obj The toolbar object
389 * @param icon The icon object of the item
390 * @param label The label of the item
391 * @param func The function to call when the item is clicked
392 * @param data The data to associate with the item
394 * @return The toolbar item, or NULL upon failure
398 EAPI Elm_Toolbar_Item *
399 elm_toolbar_item_add(Evas_Object *obj, Evas_Object *icon, const char *label, Evas_Smart_Cb func, const void *data)
401 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
402 Widget_Data *wd = elm_widget_data_get(obj);
404 Elm_Toolbar_Item *it;
406 if (!wd) return NULL;
407 it = ELM_NEW(Elm_Toolbar_Item);
408 if (!it) return NULL;
409 wd->items = eina_list_append(wd->items, it);
411 it->label = eina_stringshare_add(label);
415 it->separator = EINA_FALSE;
416 it->base = edje_object_add(evas_object_evas_get(obj));
417 _elm_theme_object_set(obj, it->base, "toolbar", "item", elm_widget_style_get(obj));
418 edje_object_signal_callback_add(it->base, "elm,action,click", "elm",
420 elm_widget_sub_object_add(obj, it->base);
425 ms = ((double)wd->icon_size * _elm_config->scale);
426 evas_object_size_hint_min_set(it->icon, ms, ms);
427 evas_object_size_hint_max_set(it->icon, ms, ms);
428 edje_object_part_swallow(it->base, "elm.swallow.icon", it->icon);
429 evas_object_show(it->icon);
430 elm_widget_sub_object_add(obj, it->icon);
432 edje_object_part_text_set(it->base, "elm.text", it->label);
434 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
435 edje_object_size_min_restricted_calc(it->base, &mw, &mh, mw, mh);
436 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
437 evas_object_size_hint_weight_set(it->base, -1.0, EVAS_HINT_EXPAND);
438 evas_object_size_hint_align_set(it->base, 0.5, EVAS_HINT_FILL);
439 evas_object_size_hint_min_set(it->base, mw, mh);
440 evas_object_box_append(wd->bx, it->base);
441 evas_object_show(it->base);
447 * Get the icon associated with @p item.
449 * @param item The toolbar item
450 * @return The icon object
455 elm_toolbar_item_icon_get(Elm_Toolbar_Item *item)
457 if (!item) return NULL;
462 * Get the label associated with @p item.
464 * @param item The toolbar item
470 elm_toolbar_item_label_get(const Elm_Toolbar_Item *item)
472 if (!item) return NULL;
477 * Get the selected state of @p item.
479 * @param item The toolbar item
480 * @return If true, the item is selected
485 elm_toolbar_item_selected_get(const Elm_Toolbar_Item *item)
487 if (!item) return EINA_FALSE;
488 return item->selected;
492 * Set the label associated with @p item.
494 * @param item The toolbar item
495 * @param label The label of @p item
500 elm_toolbar_item_label_set(Elm_Toolbar_Item *item, const char *label)
502 Evas_Coord mw = -1, mh = -1;
505 eina_stringshare_replace(&item->label, label);
506 edje_object_part_text_set(item->base, "elm.text", item->label);
508 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
509 edje_object_size_min_restricted_calc(item->base, &mw, &mh, mw, mh);
510 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
511 evas_object_size_hint_weight_set(item->base, -1.0, EVAS_HINT_EXPAND);
512 evas_object_size_hint_align_set(item->base, 0.5, EVAS_HINT_FILL);
513 evas_object_size_hint_min_set(item->base, mw, mh);
518 * Delete a toolbar item.
520 * @param it The toolbar item
525 elm_toolbar_item_del(Elm_Toolbar_Item *it)
527 Widget_Data *wd = elm_widget_data_get(it->obj);
528 Evas_Object *obj2 = it->obj;
530 if ((!wd) || (!it)) return;
531 if (it->del_cb) it->del_cb((void *)it->data, it->obj, it);
532 wd->items = eina_list_remove(wd->items, it);
533 eina_stringshare_del(it->label);
534 if (it->icon) evas_object_del(it->icon);
535 evas_object_del(it->base);
541 * Set the function called when a toolbar item is freed.
543 * @param it The item to set the callback on
544 * @param func The function called
549 elm_toolbar_item_del_cb_set(Elm_Toolbar_Item *it, Evas_Smart_Cb func)
555 * Select the toolbar item @p item.
557 * @param item The toolbar item
562 elm_toolbar_item_select(Elm_Toolbar_Item *item)
569 * Get the disabled state of @p item.
571 * @param item The toolbar item
572 * @return If true, the item is disabled
577 elm_toolbar_item_disabled_get(Elm_Toolbar_Item *item)
579 if (!item) return EINA_FALSE;
580 return item->disabled;
584 * Set the disabled state of @p item.
586 * @param item The toolbar item
587 * @param disabled If true, the item is disabled
592 elm_toolbar_item_disabled_set(Elm_Toolbar_Item *item, Eina_Bool disabled)
595 _item_disable(item, disabled);
599 * Get the separator state of @p item.
601 * @param item The toolbar item
602 * @param separator If true, the item is a separator
607 elm_toolbar_item_separator_set(Elm_Toolbar_Item *item, Eina_Bool separator)
610 if (item->separator == separator) return;
611 item->separator = separator;
612 _theme_hook(item->obj);
616 * Set the separator state of @p item.
618 * @param item The toolbar item
619 * @return If true, the item is a separator
624 elm_toolbar_item_separator_get(Elm_Toolbar_Item *item)
626 if (!item) return EINA_FALSE;
627 return item->separator;
631 * Set the scrollable state of toolbar @p obj.
633 * @param obj The toolbar object
634 * @param scrollable If true, the toolbar will be scrollable
639 elm_toolbar_scrollable_set(Evas_Object *obj, Eina_Bool scrollable)
641 ELM_CHECK_WIDTYPE(obj, widtype);
642 Widget_Data *wd = elm_widget_data_get(obj);
645 wd->scrollable = scrollable;
646 elm_smart_scroller_bounce_allow_set(wd->scr, wd->scrollable, 0);
651 * Get the scrollable state of toolbar @p obj.
653 * @param obj The toolbar object
654 * @return If true, the toolbar is scrollable
659 elm_toolbar_scrollable_get(Evas_Object *obj)
661 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
662 Widget_Data *wd = elm_widget_data_get(obj);
664 if (!wd) return EINA_FALSE;
665 return wd->scrollable;
669 * Set the homogenous mode of toolbar @p obj.
671 * @param obj The toolbar object
672 * @param homogenous If true, the toolbar items will be uniform in size
677 elm_toolbar_homogenous_set(Evas_Object *obj, Eina_Bool homogenous)
679 ELM_CHECK_WIDTYPE(obj, widtype);
680 Widget_Data *wd = elm_widget_data_get(obj);
683 wd->homogeneous = !!homogenous;
684 evas_object_smart_calculate(wd->bx);
688 * Get the homogenous mode of toolbar @p obj.
690 * @param obj The toolbar object
691 * @return If true, the toolbar items are uniform in size
696 elm_toolbar_homogenous_get(Evas_Object *obj)
698 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
699 Widget_Data *wd = elm_widget_data_get(obj);
701 if (!wd) return EINA_FALSE;
702 return wd->homogeneous;
706 * Set the parent object of the toolbar menu
708 * @param obj The toolbar object
709 * @param parent The parent of the menu object
714 elm_toolbar_menu_parent_set(Evas_Object *obj, Evas_Object *parent)
717 Elm_Toolbar_Item *it;
718 ELM_CHECK_WIDTYPE(obj, widtype);
719 Widget_Data *wd = elm_widget_data_get(obj);
721 if ((!wd) || (!parent)) return;
722 wd->menu_parent = parent;
723 EINA_LIST_FOREACH(wd->items, l, it)
726 elm_menu_parent_set(it->o_menu, wd->menu_parent);
731 * Get the parent object of the toolbar menu
733 * @param obj The toolbar object
734 * @return The parent of the menu object
739 elm_toolbar_menu_parent_get(Evas_Object *obj)
741 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
742 Widget_Data *wd = elm_widget_data_get(obj);
743 if (!wd) return NULL;
745 return wd->menu_parent;
749 * Unselect all of the items in the toolbar.
751 * @param obj The toolbar object
756 elm_toolbar_item_unselect_all(Evas_Object *obj)
759 Elm_Toolbar_Item *it;
760 ELM_CHECK_WIDTYPE(obj, widtype);
761 Widget_Data *wd = elm_widget_data_get(obj);
764 EINA_LIST_FOREACH(wd->items, l, it)
768 it->selected = EINA_FALSE;
769 edje_object_signal_emit(it->base, "elm,state,unselected", "elm");
776 * Unselect the specified toolbar item.
778 * @param item The toolbar item
783 elm_toolbar_item_unselect(Elm_Toolbar_Item *item)
785 if ((!item) || (!item->selected)) return;
786 item->selected = EINA_FALSE;
787 edje_object_signal_emit(item->base, "elm,state,unselected", "elm");
791 * Set the alignment of the items.
793 * @param obj The toolbar object
794 * @param align The new alignment. (left) 0.0 ... 1.0 (right)
799 elm_toolbar_align_set(Evas_Object *obj, double align)
801 ELM_CHECK_WIDTYPE(obj, widtype);
802 Widget_Data *wd = elm_widget_data_get(obj);
805 if (wd->align != align)
806 evas_object_size_hint_align_set(wd->bx, align, 0.5);
811 * Get the alignment of the items.
813 * @param obj The toolbar object
814 * @return The alignment. (left) 0.0 ... 1.0 (right)
819 elm_toolbar_align_get(const Evas_Object *obj)
821 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
822 Widget_Data *wd = elm_widget_data_get(obj);
829 * Set whether the toolbar item opens a menu.
831 * @param item The toolbar item
832 * @param menu If true, @p item will open a menu when selected
837 elm_toolbar_item_menu_set(Elm_Toolbar_Item *item, Eina_Bool menu)
840 Widget_Data *wd = elm_widget_data_get(item->obj);
843 if (item->menu == menu) return;
847 item->o_menu = elm_menu_add(item->base);
849 elm_menu_parent_set(item->o_menu, wd->menu_parent);
850 evas_object_event_callback_add(item->o_menu, EVAS_CALLBACK_HIDE,
852 evas_object_event_callback_add(item->o_menu, EVAS_CALLBACK_DEL,
855 else if (item->o_menu)
857 evas_object_del(item->o_menu);
863 * Get whether the toolbar item opens a menu.
865 * @param item The toolbar item
866 * @return If true, @p item opens a menu when selected
871 elm_toolbar_item_menu_get(Elm_Toolbar_Item *item)
873 if (!item) return NULL;
874 Widget_Data *wd = elm_widget_data_get(item->obj);
875 if (!wd) return NULL;
876 elm_toolbar_item_menu_set(item, 1);
881 * Return a list of all toolbar items.
883 * @param obj The toolbar object
885 * @return An Eina_List* of the toolbar items in @p obj
890 elm_toolbar_item_get_all(Evas_Object *obj)
892 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
893 Widget_Data *wd = elm_widget_data_get(obj);
894 if (!wd) return NULL;
900 * Return the first toolbar item in the list of toolbar items.
902 * @param obj The toolbar object
904 * @return The first toolbar item, or NULL on failure
908 EAPI Elm_Toolbar_Item *
909 elm_toolbar_item_get_first(Evas_Object *obj)
911 Elm_Toolbar_Item *it;
912 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
913 Widget_Data *wd = elm_widget_data_get(obj);
914 if (!wd) return NULL;
915 if (!(it = eina_list_data_get(wd->items))) return NULL;
921 * Return the last toolbar item in the list of toolbar items.
923 * @param obj The toolbar object
925 * @return The last toolbar item, or NULL on failure
929 EAPI Elm_Toolbar_Item *
930 elm_toolbar_item_get_last(Evas_Object *obj)
933 Elm_Toolbar_Item *it;
934 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
935 Widget_Data *wd = elm_widget_data_get(obj);
936 if (!wd) return NULL;
937 if (!(last = eina_list_last(wd->items))) return NULL;
938 it = eina_list_data_get(last);
944 * Return the next toolbar item (relative to the currently selected
945 * toolbar item) in the list of toolbar items.
947 * @param obj The toolbar object
949 * @return The next toolbar item, or NULL on failure
953 EAPI Elm_Toolbar_Item *
954 elm_toolbar_item_get_next(Evas_Object *obj)
957 Elm_Toolbar_Item *it, *next;
958 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
959 Widget_Data *wd = elm_widget_data_get(obj);
961 if (!wd) return NULL;
962 EINA_LIST_FOREACH_SAFE(wd->items, l, l2, it)
966 if (!(next = eina_list_data_get(l2))) return NULL;
974 * Selects the next non-disabled, non-separator toolbar item in the list
977 * @param obj The toolbar object
979 * @return The newly selected toolbar item, or NULL on failure
983 EAPI Elm_Toolbar_Item *
984 elm_toolbar_item_select_next(Evas_Object *obj)
987 Elm_Toolbar_Item *it, *next;
988 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
989 Widget_Data *wd = elm_widget_data_get(obj);
991 if (!wd) return NULL;
992 EINA_LIST_FOREACH(wd->items, l, it)
996 EINA_LIST_FOREACH(l, l2, next)
997 if ((!next->disabled) && (next->separator))
1008 * Selects the first non-disabled, non-separator toolbar item in the list
1011 * @param obj The toolbar object
1013 * @return The newly selected toolbar item, or NULL on failure
1017 EAPI Elm_Toolbar_Item *
1018 elm_toolbar_item_select_first(Evas_Object *obj)
1021 Elm_Toolbar_Item *it;
1022 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1023 Widget_Data *wd = elm_widget_data_get(obj);
1024 if (!wd) return NULL;
1025 EINA_LIST_FOREACH(wd->items, l, it)
1027 if ((!it->disabled) && (!it->separator))
1038 * Selects the last non-disabled, non-separator toolbar item in the list
1041 * @param obj The toolbar object
1043 * @return The newly selected toolbar item, or NULL on failure
1047 EAPI Elm_Toolbar_Item *
1048 elm_toolbar_item_select_last(Evas_Object *obj)
1051 Elm_Toolbar_Item *it;
1052 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1053 Widget_Data *wd = elm_widget_data_get(obj);
1054 if (!wd) return NULL;
1055 EINA_LIST_REVERSE_FOREACH(wd->items, l, it)
1057 if ((!it->disabled) && (!it->separator))
1068 * Returns a pointer to a toolbar item by its label
1070 * @param obj The toolbar object
1071 * @param label The label of the item to find
1073 * @return The pointer to the toolbar item matching @p label
1074 * Returns NULL on failure.
1078 EAPI Elm_Toolbar_Item *
1079 elm_toolbar_item_find_by_label(Evas_Object *obj, const char *label)
1082 Elm_Toolbar_Item *it;
1083 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1084 Widget_Data *wd = elm_widget_data_get(obj);
1086 if (!wd) return NULL;
1087 EINA_LIST_FOREACH(wd->items, l, it)
1089 if (!strcmp(it->label, label)) return it;