more useless elm stuff: vertical toolbar orientation (by cedric's request) along...
[framework/uifw/elementary.git] / src / lib / elm_toolbar.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3 #include "els_scroller.h"
4 #include "els_box.h"
5 #include "els_icon.h"
6
7 typedef struct _Widget_Data Widget_Data;
8
9 struct _Widget_Data
10 {
11    Evas_Object *scr, *bx;
12    Evas_Object *menu_parent;
13    Eina_Inlist *items;
14    Elm_Toolbar_Item *more_item, *selected_item;
15    Elm_Toolbar_Shrink_Mode shrink_mode;
16    Elm_Icon_Lookup_Order lookup_order;
17    int icon_size;
18    double align;
19    Eina_Bool homogeneous : 1;
20    Eina_Bool no_select : 1;
21    Eina_Bool always_select : 1;
22    Eina_Bool vertical : 1;
23    Eina_Bool long_press : 1;
24    Ecore_Timer *long_timer;
25    Ecore_Job *resize_job;
26 };
27
28 struct _Elm_Toolbar_Item
29 {
30    ELM_WIDGET_ITEM;
31    EINA_INLIST;
32    const char *label;
33    const char *icon_str;
34    Evas_Object *icon;
35    Evas_Object *o_menu;
36    Evas_Smart_Cb func;
37    struct {
38       int priority;
39       Eina_Bool visible : 1;
40    } prio;
41    Eina_Bool selected : 1;
42    Eina_Bool disabled : 1;
43    Eina_Bool separator : 1;
44    Eina_Bool menu : 1;
45    Eina_List *states;
46    Eina_List *current_state;
47 };
48
49 #define ELM_TOOLBAR_ITEM_FROM_INLIST(item)      \
50   ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Toolbar_Item) : NULL)
51
52 struct _Elm_Toolbar_Item_State
53 {
54    const char *label;
55    const char *icon_str;
56    Evas_Object *icon;
57    Evas_Smart_Cb func;
58    const void *data;
59 };
60
61 static const char *widtype = NULL;
62 static void _item_show(Elm_Toolbar_Item *it);
63 static void _item_select(Elm_Toolbar_Item *it);
64 static void _item_unselect(Elm_Toolbar_Item *it);
65 static void _item_disable(Elm_Toolbar_Item *it, Eina_Bool disabled);
66 static void _del_pre_hook(Evas_Object *obj);
67 static void _del_hook(Evas_Object *obj);
68 static void _mirrored_set(Evas_Object *obj, Eina_Bool mirrored);
69 static void _mirrored_set_item(Evas_Object *obj, Elm_Toolbar_Item *it, Eina_Bool mirrored);
70 static void _theme_hook(Evas_Object *obj);
71 static void _sizing_eval(Evas_Object *obj);
72 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
73 static void _menu_move_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
74 static void _menu_hide(void *data, Evas *e, Evas_Object *obj, void *event_info);
75 static void _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
76 static void _elm_toolbar_item_icon_obj_set(Evas_Object *obj, Elm_Toolbar_Item *item, Evas_Object *icon_obj, const char *icon_str, double icon_size, const char *signal);
77 static void _item_label_set(Elm_Toolbar_Item *item, const char *label, const char *signal);
78
79 static const char SIG_CLICKED[] = "clicked";
80 static const char SIG_LONGPRESSED[] = "longpressed";
81 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
82
83 static const Evas_Smart_Cb_Description _signals[] = {
84    {SIG_CLICKED, ""},
85    {SIG_LONGPRESSED, ""},
86    {SIG_CLICKED_DOUBLE, ""},
87    {NULL, NULL}
88 };
89
90
91 static Eina_Bool
92 _item_icon_set(Evas_Object *icon_obj, const char *type, const char *icon)
93 {
94    char icon_str[512];
95
96    if ((!type) || (!*type)) goto end;
97    if ((!icon) || (!*icon)) return EINA_FALSE;
98    if ((snprintf(icon_str, sizeof(icon_str), "%s%s", type, icon) > 0)
99        && (elm_icon_standard_set(icon_obj, icon_str)))
100      return EINA_TRUE;
101 end:
102    if (elm_icon_standard_set(icon_obj, icon))
103      return EINA_TRUE;
104    WRN("couldn't find icon definition for '%s'", icon);
105    return EINA_FALSE;
106 }
107
108 static int
109 _elm_toolbar_icon_size_get(Widget_Data *wd)
110 {
111    const char *icon_size = edje_object_data_get(
112       elm_smart_scroller_edje_object_get(wd->scr), "icon_size");
113    if (icon_size)
114      return atoi(icon_size);
115    return _elm_config->icon_size;
116 }
117
118 static void
119 _item_show(Elm_Toolbar_Item *it)
120 {
121    Widget_Data *wd = elm_widget_data_get(WIDGET(it));
122    Evas_Coord x, y, w, h, bx, by;
123
124    if (!wd) return;
125    evas_object_geometry_get(wd->bx, &bx, &by, NULL, NULL);
126    evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
127    elm_smart_scroller_child_region_show(wd->scr, x - bx, y - by, w, h);
128 }
129
130 static void
131 _item_unselect(Elm_Toolbar_Item *item)
132 {
133    Widget_Data *wd;
134    if ((!item) || (!item->selected)) return;
135    wd = elm_widget_data_get(WIDGET(item));
136    if (!wd) return;
137    item->selected = EINA_FALSE;
138    wd->selected_item = NULL;
139    edje_object_signal_emit(VIEW(item), "elm,state,unselected", "elm");
140    elm_widget_signal_emit(item->icon, "elm,state,unselected", "elm");
141 }
142
143 static void
144 _item_select(Elm_Toolbar_Item *it)
145 {
146    Elm_Toolbar_Item *it2;
147    Widget_Data *wd = elm_widget_data_get(WIDGET(it));
148    Evas_Object *obj2;
149    Eina_Bool sel;
150
151    if (!wd) return;
152    if ((it->disabled) || (it->separator)) return;
153    sel = it->selected;
154
155    if (!wd->no_select)
156      {
157         if (sel)
158           {
159              if (wd->always_select) return;
160              _item_unselect(it);
161           }
162         else
163           {
164              it2 = elm_toolbar_selected_item_get(WIDGET(it));
165              _item_unselect(it2);
166
167              it->selected = EINA_TRUE;
168              wd->selected_item = it;
169              edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
170              elm_widget_signal_emit(it->icon, "elm,state,selected", "elm");
171              _item_show(it);
172           }
173      }
174    obj2 = WIDGET(it);
175    if (it->menu && (!sel))
176      {
177         evas_object_show(it->o_menu);
178         evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_RESIZE,
179                                        _menu_move_resize, it);
180         evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOVE,
181                                        _menu_move_resize, it);
182
183         _menu_move_resize(it, NULL, NULL, NULL);
184      }
185    if (it->func) it->func((void *)(it->base.data), WIDGET(it), it);
186    evas_object_smart_callback_call(obj2, SIG_CLICKED, it);
187 }
188
189 static void
190 _menu_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
191 {
192    Elm_Toolbar_Item *selected;
193    Elm_Toolbar_Item *it = data;
194    selected = elm_toolbar_selected_item_get(WIDGET(it));
195    _item_unselect(selected);
196 }
197
198 static void
199 _menu_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
200 {
201    // avoid hide being emitted during object deletion
202    evas_object_event_callback_del_full
203       (obj, EVAS_CALLBACK_HIDE, _menu_hide, data);
204 }
205
206 static void
207 _menu_move_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
208 {
209    Elm_Toolbar_Item *it = data;
210    Evas_Coord x,y,w,h;
211    Widget_Data *wd = elm_widget_data_get(WIDGET(it));
212
213    if ((!wd) || (!wd->menu_parent)) return;
214    evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
215    elm_menu_move(it->o_menu, x, y+h);
216 }
217
218 static void
219 _item_disable(Elm_Toolbar_Item *it, Eina_Bool disabled)
220 {
221    Widget_Data *wd = elm_widget_data_get(WIDGET(it));
222
223    if (!wd) return;
224    if (it->disabled == disabled) return;
225    it->disabled = !!disabled;
226    if (it->disabled)
227      {
228         edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
229         elm_widget_signal_emit(it->icon, "elm,state,disabled", "elm");
230      }
231    else
232      {
233         edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
234         elm_widget_signal_emit(it->icon, "elm,state,enabled", "elm");
235      }
236 }
237
238 static void
239 _item_del(Elm_Toolbar_Item *it)
240 {
241    Elm_Toolbar_Item_State *it_state;
242    _item_unselect(it);
243    elm_widget_item_pre_notify_del(it);
244    EINA_LIST_FREE(it->states, it_state)
245      {
246         if (it->icon == it_state->icon)
247           it->icon = NULL;
248         eina_stringshare_del(it_state->label);
249         eina_stringshare_del(it_state->icon_str);
250         if (it_state->icon) evas_object_del(it_state->icon);
251         free(it_state);
252      }
253    eina_stringshare_del(it->label);
254    eina_stringshare_del(it->icon_str);
255    if (it->icon) evas_object_del(it->icon);
256    //TODO: See if checking for wd->menu_parent is necessary before deleting menu
257    if (it->o_menu) evas_object_del(it->o_menu);
258    elm_widget_item_del(it);
259 }
260
261 static void
262 _del_pre_hook(Evas_Object *obj)
263 {
264    Widget_Data *wd = elm_widget_data_get(obj);
265    Elm_Toolbar_Item *it, *next;
266
267    if (!wd) return;
268    it = ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items);
269    while(it)
270      {
271         next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
272         _item_del(it);
273         it = next;
274      }
275    if (wd->more_item)
276      _item_del(wd->more_item);
277    if (wd->long_timer)
278      {
279         ecore_timer_del(wd->long_timer);
280         wd->long_timer = NULL;
281      }
282 }
283
284 static void
285 _del_hook(Evas_Object *obj)
286 {
287    Widget_Data *wd = elm_widget_data_get(obj);
288
289    if (!wd) return;
290    free(wd);
291 }
292
293
294 static void
295 _mirrored_set_item(Evas_Object *obj __UNUSED__, Elm_Toolbar_Item *it, Eina_Bool mirrored)
296 {
297    edje_object_mirrored_set(VIEW(it), mirrored);
298    elm_widget_mirrored_set(it->o_menu, mirrored);
299 }
300
301 static void
302 _theme_hook_item(Evas_Object *obj, Elm_Toolbar_Item *it, double scale, int icon_size)
303 {
304    Evas_Object *view = VIEW(it);
305    Evas_Coord mw, mh;
306    const char *style = elm_widget_style_get(obj);
307
308    _mirrored_set_item(obj, it, elm_widget_mirrored_get(obj));
309    edje_object_scale_set(view, scale);
310    if (!it->separator)
311      {
312         _elm_theme_object_set(obj, view, "toolbar", "item", style);
313         if (it->selected)
314           {
315              edje_object_signal_emit(view, "elm,state,selected", "elm");
316              elm_widget_signal_emit(it->icon, "elm,state,selected", "elm");
317           }
318         if (it->disabled)
319           {
320              edje_object_signal_emit(view, "elm,state,disabled", "elm");
321              elm_widget_signal_emit(it->icon, "elm,state,disabled", "elm");
322           }
323         if (it->icon)
324           {
325              int ms = 0;
326
327              ms = ((double)icon_size * scale);
328              evas_object_size_hint_min_set(it->icon, ms, ms);
329              evas_object_size_hint_max_set(it->icon, ms, ms);
330              edje_object_part_swallow(view, "elm.swallow.icon",
331                                       it->icon);
332           }
333         edje_object_part_text_set(view, "elm.text", it->label);
334      }
335    else
336      _elm_theme_object_set(obj, view, "toolbar", "separator", style);
337
338    mw = mh = -1;
339    if (!it->separator)
340      elm_coords_finger_size_adjust(1, &mw, 1, &mh);
341    edje_object_size_min_restricted_calc(view, &mw, &mh, mw, mh);
342    if (!it->separator)
343      elm_coords_finger_size_adjust(1, &mw, 1, &mh);
344    evas_object_size_hint_min_set(view, mw, mh);
345 }
346
347 static void
348 _mirrored_set(Evas_Object *obj, Eina_Bool mirrored)
349 {
350    Widget_Data *wd = elm_widget_data_get(obj);
351    Elm_Toolbar_Item *it;
352
353    EINA_INLIST_FOREACH(wd->items, it)
354       _mirrored_set_item(obj, it, mirrored);
355    if (wd->more_item)
356      _mirrored_set_item(obj, wd->more_item, mirrored);
357 }
358
359 static void
360 _theme_hook(Evas_Object *obj)
361 {
362    Widget_Data *wd = elm_widget_data_get(obj);
363    Elm_Toolbar_Item *it;
364    double scale = 0;
365
366    if (!wd) return;
367    _elm_widget_mirrored_reload(obj);
368    elm_smart_scroller_object_theme_set(obj, wd->scr, "toolbar", "base", elm_widget_style_get(obj));
369    _mirrored_set(obj, elm_widget_mirrored_get(obj));
370    scale = (elm_widget_scale_get(obj) * _elm_config->scale);
371    edje_object_scale_set(wd->scr, scale);
372    wd->icon_size = _elm_toolbar_icon_size_get(wd);
373    EINA_INLIST_FOREACH(wd->items, it)
374       _theme_hook_item(obj, it, scale, wd->icon_size);
375    if (wd->more_item)
376      _theme_hook_item(obj, wd->more_item, scale, wd->icon_size);
377    _sizing_eval(obj);
378 }
379
380 static void
381 _translate_hook(Evas_Object *obj)
382 {
383    evas_object_smart_callback_call(obj, "language,changed", NULL);
384 }
385
386 static void
387 _sizing_eval(Evas_Object *obj)
388 {
389    Widget_Data *wd = elm_widget_data_get(obj);
390    Evas_Coord minw = -1, minh = -1, minw_bx, minh_bx;
391    Evas_Coord vw = 0, vh = 0;
392    Evas_Coord w, h;
393
394    if (!wd) return;
395    evas_object_smart_calculate(wd->bx);
396    edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
397                              &minw, &minh);
398    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
399    if (w < minw) w = minw;
400    if (h < minh) h = minh;
401    evas_object_resize(wd->scr, w, h);
402
403    evas_object_size_hint_min_get(wd->bx, &minw, &minh);
404    minw_bx = minw;
405    minh_bx = minh;
406    evas_object_resize(wd->bx, minw, minh);
407    elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
408    if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_NONE)
409      {
410         if (wd->vertical) minh = minh_bx + (h - vh);
411         else minw = minw_bx + (w - vw);
412      }
413    else
414      {
415       case ELM_TOOLBAR_SHRINK_MENU: /* fallthrough */
416       case ELM_TOOLBAR_SHRINK_HIDE: /* fallthrough */
417       case ELM_TOOLBAR_SHRINK_SCROLL:
418         if (wd->vertical) minh = h - vh;
419         else minw = w - vw;
420         break;
421       case ELM_TOOLBAR_SHRINK_NONE:
422         if (wd->vertical) minh = minh_bx + (h - vh);
423         else minw = minw_bx + (w - vw);
424         break;
425      }
426    minh = minh + (h - vh);
427    evas_object_size_hint_min_set(obj, minw, minh);
428    evas_object_size_hint_max_set(obj, -1, -1);
429 }
430
431 static void
432 _item_menu_create(Widget_Data *wd, Elm_Toolbar_Item *item)
433 {
434    item->o_menu = elm_menu_add(VIEW(item));
435    item->menu = EINA_TRUE;
436    if (wd->menu_parent)
437      elm_menu_parent_set(item->o_menu, wd->menu_parent);
438    evas_object_event_callback_add(item->o_menu, EVAS_CALLBACK_HIDE,
439                                   _menu_hide, item);
440    evas_object_event_callback_add(item->o_menu, EVAS_CALLBACK_DEL,
441                                   _menu_del, item);
442 }
443
444 static void
445 _item_menu_destroy(Elm_Toolbar_Item *item)
446 {
447    if (item->o_menu)
448      {
449         evas_object_del(item->o_menu);
450         item->o_menu = NULL;
451      }
452    item->menu = EINA_FALSE;
453 }
454
455 static int
456 _toolbar_item_prio_compare_cb(const void *i1, const void *i2)
457 {
458    const Elm_Toolbar_Item *eti1 = i1;
459    const Elm_Toolbar_Item *eti2 = i2;
460
461    if (!eti2) return 1;
462    if (!eti1) return -1;
463
464    return eti2->prio.priority - eti1->prio.priority;
465 }
466
467 static void
468 _fix_items_visibility(Widget_Data *wd, Evas_Coord *iw, Evas_Coord vw)
469 {
470    Elm_Toolbar_Item *it;
471    Eina_List *sorted = NULL;
472    Evas_Coord ciw;
473
474    EINA_INLIST_FOREACH(wd->items, it)
475      {
476         sorted = eina_list_sorted_insert(sorted,
477                                          _toolbar_item_prio_compare_cb, it);
478      }
479
480    if (wd->more_item)
481      {
482         evas_object_geometry_get(wd->VIEW(more_item), NULL, NULL, &ciw, NULL);
483         *iw += ciw;
484      }
485    EINA_LIST_FREE(sorted, it)
486      {
487         evas_object_geometry_get(VIEW(it), NULL, NULL, &ciw, NULL);
488         *iw += ciw;
489         it->prio.visible = (*iw <= vw);
490      }
491 }
492
493 static void
494 _elm_toolbar_item_menu_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
495 {
496    Elm_Toolbar_Item *it = data;
497    if (it->func) it->func((void *)(it->base.data), WIDGET(it), it);
498 }
499
500 static void
501 _resize_job(void *data)
502 {
503    Widget_Data *wd = elm_widget_data_get(data);
504    Evas_Coord mw, mh, vw, vh, w, h;
505    Elm_Toolbar_Item *it;
506    Evas_Object *obj = (Evas_Object *) data;
507
508    if (!wd) return;
509    wd->resize_job = NULL;
510    elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
511    evas_object_size_hint_min_get(wd->bx, &mw, &mh);
512    evas_object_geometry_get(wd->bx, NULL, NULL, &w, &h);
513    if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_MENU)
514      {
515         Evas_Coord iw = 0, more_w;
516
517         evas_object_resize(wd->bx, vw, h);
518         _fix_items_visibility(wd, &iw, vw);
519         evas_object_geometry_get(wd->VIEW(more_item), NULL, NULL, &more_w, NULL);
520         if (iw - more_w <= vw)
521           iw -= more_w;
522
523         /* All items are removed from the box object, since removing individual
524          * items won't trigger a resize. Items are be readded below. */
525         evas_object_box_remove_all(wd->bx, EINA_FALSE);
526         if (iw > vw)
527           {
528              Evas_Object *menu;
529
530              _item_menu_destroy(wd->more_item);
531              _item_menu_create(wd, wd->more_item);
532              menu = elm_toolbar_item_menu_get(wd->more_item);
533
534              EINA_INLIST_FOREACH(wd->items, it)
535                {
536                   if (!it->prio.visible)
537                     {
538                        if (it->separator)
539                          elm_menu_item_separator_add(menu, NULL);
540                        else
541                          {
542                             Elm_Menu_Item *item;
543                             item = elm_menu_item_add(menu, NULL, it->icon_str, it->label,
544                                                      _elm_toolbar_item_menu_cb, it);
545                             elm_menu_item_disabled_set(item, it->disabled);
546                             if (it->o_menu) elm_menu_clone(it->o_menu, menu, item);
547                          }
548                        evas_object_hide(VIEW(it));
549                     }
550                   else
551                     {
552                        evas_object_box_append(wd->bx, VIEW(it));
553                        evas_object_show(VIEW(it));
554                     }
555                }
556
557              evas_object_box_append(wd->bx, wd->VIEW(more_item));
558              evas_object_show(wd->VIEW(more_item));
559           }
560         else
561           {
562              /* All items are visible, show them all (except for the "More"
563               * button, of course). */
564              EINA_INLIST_FOREACH(wd->items, it)
565                {
566                   evas_object_show(VIEW(it));
567                   evas_object_box_append(wd->bx, VIEW(it));
568                }
569              evas_object_hide(wd->VIEW(more_item));
570           }
571      }
572    else if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_HIDE)
573      {
574         Evas_Coord iw = 0;
575
576         evas_object_resize(wd->bx, vw, h);
577         _fix_items_visibility(wd, &iw, vw);
578         evas_object_box_remove_all(wd->bx, EINA_FALSE);
579         if (iw > vw)
580           {
581              EINA_INLIST_FOREACH(wd->items, it)
582                {
583                   if (!it->prio.visible)
584                     evas_object_hide(VIEW(it));
585                   else
586                     {
587                        evas_object_box_append(wd->bx, VIEW(it));
588                        evas_object_show(VIEW(it));
589                     }
590                }
591           }
592         else
593           {
594              /* All items are visible, show them all */
595              EINA_INLIST_FOREACH(wd->items, it)
596                {
597                   evas_object_show(VIEW(it));
598                   evas_object_box_append(wd->bx, VIEW(it));
599                }
600           }
601      }
602    else
603      {
604         if ((vw >= mw) && (w != vw)) evas_object_resize(wd->bx, vw, h);
605         EINA_INLIST_FOREACH(wd->items, it)
606           {
607              if (it->selected)
608                {
609                   _item_show(it);
610                   break;
611                }
612           }
613      }
614
615    _mirrored_set(obj, elm_widget_mirrored_get(obj));
616 }
617
618 static void
619 _resize_item(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
620 {
621    _sizing_eval(data);
622    _resize(data, NULL, NULL, NULL);
623 }
624
625 static void
626 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
627 {
628    Widget_Data *wd = elm_widget_data_get(data);
629    if (!wd->resize_job)
630      wd->resize_job = ecore_job_add(_resize_job, data);
631 }
632
633 static void
634 _select_filter(Elm_Toolbar_Item *it, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
635 {
636    int button;
637    char buf[sizeof("elm,action,click,") + 1];
638
639    button = atoi(emission + sizeof("mouse,clicked,") - 1);
640    if (button == 1) return; /* regular left click event */
641    snprintf(buf, sizeof(buf), "elm,action,click,%d", button);
642    edje_object_signal_emit(VIEW(it), buf, "elm");
643 }
644
645 static void
646 _select(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
647 {
648    Elm_Toolbar_Item *it = data;
649
650    if ((_elm_config->access_mode == ELM_ACCESS_MODE_OFF) ||
651        (_elm_access_2nd_click_timeout(VIEW(it))))
652      {
653         if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
654            _elm_access_say(E_("Selected"));
655         _item_select(it);
656      }
657 }
658
659 static Eina_Bool
660 _long_press(Elm_Toolbar_Item *it)
661 {
662    Widget_Data *wd = elm_widget_data_get(WIDGET(it));
663    wd->long_timer = NULL;
664    wd->long_press = EINA_TRUE;
665    evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
666    return ECORE_CALLBACK_CANCEL;
667 }
668
669 static void
670 _mouse_down(Elm_Toolbar_Item *it, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, Evas_Event_Mouse_Down *ev)
671 {
672    Widget_Data *wd = elm_widget_data_get(WIDGET(it));
673    if (!wd) return;
674    if (ev->button != 1) return;
675    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
676      evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
677    wd->long_press = EINA_FALSE;
678    if (wd->long_timer) ecore_timer_interval_set(wd->long_timer, _elm_config->longpress_timeout);
679    else wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, (Ecore_Task_Cb)_long_press, it);
680 }
681
682 static void
683 _mouse_up(Elm_Toolbar_Item *it, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, Evas_Event_Mouse_Up *ev)
684 {
685    Widget_Data *wd = elm_widget_data_get(WIDGET(it));
686    if (!wd) return;
687    if (ev->button != 1) return;
688    if (wd->long_timer)
689      {
690         ecore_timer_del(wd->long_timer);
691         wd->long_timer = NULL;
692      }
693 }
694
695 static void
696 _mouse_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
697 {
698    Elm_Toolbar_Item *it = data;
699    edje_object_signal_emit(VIEW(it), "elm,state,highlighted", "elm");
700    elm_widget_signal_emit(it->icon, "elm,state,highlighted", "elm");
701 }
702
703 static void
704 _mouse_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
705 {
706    Elm_Toolbar_Item *it = data;
707    edje_object_signal_emit(VIEW(it), "elm,state,unhighlighted", "elm");
708    elm_widget_signal_emit(it->icon, "elm,state,unhighlighted", "elm");
709 }
710
711 static void
712 _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
713 {
714    Evas_Object *obj = (Evas_Object *) data;
715    Widget_Data *wd = elm_widget_data_get(obj);
716    if (!wd) return;
717    _els_box_layout(o, priv, !wd->vertical, wd->homogeneous, elm_widget_mirrored_get(obj));
718 }
719
720 static char *
721 _access_info_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, Elm_Widget_Item *item __UNUSED__)
722 {
723    Elm_Toolbar_Item *it = (Elm_Toolbar_Item *)item;
724    char *txt = item->access_info;
725    if (!txt) txt = (char *)it->label;
726    if (txt) return strdup(txt);
727    return txt;
728 }
729
730 static char *
731 _access_state_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, Elm_Widget_Item *item __UNUSED__)
732 {
733    Elm_Toolbar_Item *it = (Elm_Toolbar_Item *)item;
734    if (it->separator)
735       return strdup(E_("Separator"));
736    else if (it->disabled)
737       return strdup(E_("State: Disabled"));
738    else if (it->selected)
739       return strdup(E_("State: Selected"));
740    else if (it->menu)
741       return strdup(E_("Has menu"));
742    return NULL;
743 }
744
745 static Elm_Toolbar_Item *
746 _item_new(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
747 {
748    Widget_Data *wd = elm_widget_data_get(obj);
749    Evas_Object *icon_obj;
750    Evas_Coord mw, mh;
751    Elm_Toolbar_Item *it;
752
753    icon_obj = elm_icon_add(obj);
754    elm_icon_order_lookup_set(icon_obj, wd->lookup_order);
755    if (!icon_obj) return NULL;
756    it = elm_widget_item_new(obj, Elm_Toolbar_Item);
757    if (!it)
758      {
759         evas_object_del(icon_obj);
760         return NULL;
761      }
762    it->label = eina_stringshare_add(label);
763    it->prio.visible = 1;
764    it->prio.priority = 0;
765    it->func = func;
766    it->separator = EINA_FALSE;
767    it->base.data = data;
768    VIEW(it) = edje_object_add(evas_object_evas_get(obj));
769    _elm_access_item_register((Elm_Widget_Item *)it, VIEW(it));
770    _elm_access_text_set(_elm_access_item_get((Elm_Widget_Item *)it),
771                         ELM_ACCESS_TYPE, E_("Tool Item"));
772    _elm_access_callback_set(_elm_access_item_get((Elm_Widget_Item *)it),
773                             ELM_ACCESS_INFO, _access_info_cb, it);
774    _elm_access_callback_set(_elm_access_item_get((Elm_Widget_Item *)it),
775                             ELM_ACCESS_STATE, _access_state_cb, it);
776
777    if (_item_icon_set(icon_obj, "toolbar/", icon))
778      {
779         it->icon = icon_obj;
780         it->icon_str = eina_stringshare_add(icon);
781      }
782    else
783      {
784         it->icon = NULL;
785         it->icon_str = NULL;
786         evas_object_del(icon_obj);
787      }
788
789    _elm_theme_object_set(obj, VIEW(it), "toolbar", "item",
790                          elm_widget_style_get(obj));
791    edje_object_signal_callback_add(VIEW(it), "elm,action,click", "elm",
792                                    _select, it);
793    edje_object_signal_callback_add(VIEW(it), "mouse,clicked,*", "*",
794                                    (Edje_Signal_Cb)_select_filter, it);
795    edje_object_signal_callback_add(VIEW(it), "elm,mouse,in", "elm",
796                                    _mouse_in, it);
797    edje_object_signal_callback_add(VIEW(it), "elm,mouse,out", "elm",
798                                    _mouse_out, it);
799    evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
800                                   (Evas_Object_Event_Cb)_mouse_down, it);
801    evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
802                                   (Evas_Object_Event_Cb)_mouse_up, it);
803    elm_widget_sub_object_add(obj, VIEW(it));
804    if (it->icon)
805      {
806         int ms = 0;
807
808         ms = ((double)wd->icon_size * _elm_config->scale);
809         evas_object_size_hint_min_set(it->icon, ms, ms);
810         evas_object_size_hint_max_set(it->icon, ms, ms);
811         edje_object_part_swallow(VIEW(it), "elm.swallow.icon", it->icon);
812         evas_object_show(it->icon);
813         elm_widget_sub_object_add(obj, it->icon);
814      }
815    edje_object_part_text_set(VIEW(it), "elm.text", it->label);
816    mw = mh = -1;
817    elm_coords_finger_size_adjust(1, &mw, 1, &mh);
818    edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh);
819    elm_coords_finger_size_adjust(1, &mw, 1, &mh);
820    if (wd->vertical)
821      {
822         evas_object_size_hint_weight_set(VIEW(it), EVAS_HINT_EXPAND, -1.0);
823         evas_object_size_hint_align_set(VIEW(it), EVAS_HINT_FILL, 0.5);
824      }
825    else
826      {
827         evas_object_size_hint_weight_set(VIEW(it), -1.0, EVAS_HINT_EXPAND);
828         evas_object_size_hint_align_set(VIEW(it), 0.5, EVAS_HINT_FILL);
829      }
830    evas_object_size_hint_min_set(VIEW(it), mw, mh);
831    evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_RESIZE,
832                                   _resize_item, obj);
833    if ((!wd->items) && wd->always_select) _item_select(it);
834    return it;
835 }
836
837 EAPI Evas_Object *
838 elm_toolbar_add(Evas_Object *parent)
839 {
840    Evas_Object *obj;
841    Evas *e;
842    Widget_Data *wd;
843
844    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
845
846    ELM_SET_WIDTYPE(widtype, "toolbar");
847    elm_widget_type_set(obj, "toolbar");
848    elm_widget_sub_object_add(parent, obj);
849    elm_widget_data_set(obj, wd);
850    elm_widget_del_pre_hook_set(obj, _del_pre_hook);
851    elm_widget_del_hook_set(obj, _del_hook);
852    elm_widget_theme_hook_set(obj, _theme_hook);
853    elm_widget_translate_hook_set(obj, _translate_hook);
854    elm_widget_can_focus_set(obj, EINA_FALSE);
855
856    wd->more_item = NULL;
857    wd->selected_item = NULL;
858    wd->scr = elm_smart_scroller_add(e);
859    elm_smart_scroller_widget_set(wd->scr, obj);
860    elm_smart_scroller_object_theme_set(obj, wd->scr, "toolbar", "base", "default");
861    elm_smart_scroller_bounce_allow_set(wd->scr,
862                                        _elm_config->thumbscroll_bounce_enable,
863                                        EINA_FALSE);
864    elm_widget_resize_object_set(obj, wd->scr);
865    elm_smart_scroller_policy_set(wd->scr,
866                                  ELM_SMART_SCROLLER_POLICY_AUTO,
867                                  ELM_SMART_SCROLLER_POLICY_OFF);
868
869
870    wd->icon_size = _elm_toolbar_icon_size_get(wd);
871
872
873    wd->homogeneous = EINA_TRUE;
874    wd->align = 0.5;
875
876    wd->bx = evas_object_box_add(e);
877    evas_object_size_hint_align_set(wd->bx, wd->align, 0.5);
878    evas_object_box_layout_set(wd->bx, _layout, obj, NULL);
879    elm_widget_sub_object_add(obj, wd->bx);
880    elm_smart_scroller_child_set(wd->scr, wd->bx);
881    evas_object_show(wd->bx);
882
883    elm_toolbar_mode_shrink_set(obj, _elm_config->toolbar_shrink_mode);
884    evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_RESIZE, _resize, obj);
885    evas_object_event_callback_add(wd->bx, EVAS_CALLBACK_RESIZE, _resize, obj);
886    elm_toolbar_icon_order_lookup_set(obj, ELM_ICON_LOOKUP_THEME_FDO);
887
888    evas_object_smart_callbacks_descriptions_set(obj, _signals);
889
890    _sizing_eval(obj);
891    return obj;
892 }
893
894 EAPI void
895 elm_toolbar_icon_size_set(Evas_Object *obj, int icon_size)
896 {
897    ELM_CHECK_WIDTYPE(obj, widtype);
898    Widget_Data *wd = elm_widget_data_get(obj);
899    if (!wd) return;
900    if (wd->icon_size == icon_size) return;
901    wd->icon_size = icon_size;
902    _theme_hook(obj);
903 }
904
905 EAPI int
906 elm_toolbar_icon_size_get(const Evas_Object *obj)
907 {
908    ELM_CHECK_WIDTYPE(obj, widtype) 0;
909    Widget_Data *wd = elm_widget_data_get(obj);
910    if (!wd) return 0;
911    return wd->icon_size;
912 }
913
914 EAPI Elm_Toolbar_Item *
915 elm_toolbar_item_append(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
916 {
917    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
918    Widget_Data *wd = elm_widget_data_get(obj);
919    if (!wd) return NULL;
920
921    Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data);
922    if (!it) return NULL;
923    double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
924
925    wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
926    evas_object_box_append(wd->bx, VIEW(it));
927    evas_object_show(VIEW(it));
928
929    _theme_hook_item(obj, it, scale, wd->icon_size);
930    _sizing_eval(obj);
931
932    return it;
933 }
934
935 static void
936 _elm_toolbar_item_state_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
937 {
938    Elm_Toolbar_Item *it = event_info;
939    Elm_Toolbar_Item_State *it_state;
940
941    it_state = eina_list_data_get(it->current_state);
942    if (it_state->func)
943      it_state->func((void *)it_state->data, obj, event_info);
944 }
945
946 EAPI Elm_Toolbar_Item_State *
947 elm_toolbar_item_state_next(Elm_Toolbar_Item *item)
948 {
949    Widget_Data *wd;
950    Evas_Object *obj;
951    Eina_List *next_state;
952    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
953
954    obj = WIDGET(item);
955    wd = elm_widget_data_get(obj);
956    if (!wd) return NULL;
957    if (!item->states) return NULL;
958
959    next_state = eina_list_next(item->current_state);
960    if (!next_state)
961      next_state = eina_list_next(item->states);
962    return eina_list_data_get(next_state);
963 }
964
965 EAPI Elm_Toolbar_Item_State *
966 elm_toolbar_item_state_prev(Elm_Toolbar_Item *item)
967 {
968    Widget_Data *wd;
969    Evas_Object *obj;
970    Eina_List *prev_state;
971    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
972
973    obj = WIDGET(item);
974    wd = elm_widget_data_get(obj);
975    if (!wd) return NULL;
976    if (!item->states) return NULL;
977
978    prev_state = eina_list_prev(item->current_state);
979    if ((!prev_state) || (prev_state == item->states))
980      prev_state = eina_list_last(item->states);
981    return eina_list_data_get(prev_state);
982 }
983
984 EAPI void
985 elm_toolbar_item_state_unset(Elm_Toolbar_Item *it)
986 {
987    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
988    elm_toolbar_item_state_set(it, NULL);
989 }
990
991 EAPI Eina_Bool
992 elm_toolbar_item_state_set(Elm_Toolbar_Item *it, Elm_Toolbar_Item_State *state)
993 {
994    Widget_Data *wd;
995    Eina_List *next_state;
996    Elm_Toolbar_Item_State *it_state;
997    Evas_Object *obj;
998    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
999
1000    obj = WIDGET(it);
1001    wd = elm_widget_data_get(obj);
1002    if (!wd) return EINA_FALSE;
1003    if (!it->states) return EINA_FALSE;
1004
1005    if (state)
1006      {
1007         next_state = eina_list_data_find_list(it->states, state);
1008         if (!next_state) return EINA_FALSE;
1009      }
1010    else
1011      next_state = it->states;
1012
1013    if (next_state == it->current_state) return EINA_TRUE;
1014
1015    it_state = eina_list_data_get(next_state);
1016    if (eina_list_data_find(it->current_state, state))
1017      {
1018         _item_label_set(it, it_state->label, "elm,state,label_set,forward");
1019         _elm_toolbar_item_icon_obj_set(obj, it, it_state->icon, it_state->icon_str,
1020                                        wd->icon_size, "elm,state,icon_set,forward");
1021      }
1022    else
1023      {
1024         _item_label_set(it, it_state->label, "elm,state,label_set,backward");
1025         _elm_toolbar_item_icon_obj_set(obj, it, it_state->icon, it_state->icon_str,
1026                                        wd->icon_size, "elm,state,icon_set,backward");
1027      }
1028    if (it->disabled)
1029      elm_widget_signal_emit(it->icon, "elm,state,disabled", "elm");
1030    else
1031      elm_widget_signal_emit(it->icon, "elm,state,enabled", "elm");
1032
1033    it->current_state = next_state;
1034    return EINA_TRUE;
1035 }
1036
1037 EAPI Elm_Toolbar_Item_State *
1038 elm_toolbar_item_state_get(const Elm_Toolbar_Item *it)
1039 {
1040    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
1041    if ((!it->states) || (!it->current_state)) return NULL;
1042    if (it->current_state == it->states) return NULL;
1043
1044    return eina_list_data_get(it->current_state);
1045 }
1046
1047 static Elm_Toolbar_Item_State *
1048 _item_state_new(const char *label, const char *icon_str, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
1049 {
1050    Elm_Toolbar_Item_State *it_state;
1051    it_state = ELM_NEW(Elm_Toolbar_Item_State);
1052    it_state->label = eina_stringshare_add(label);
1053    it_state->icon_str = eina_stringshare_add(icon_str);
1054    it_state->icon = icon;
1055    it_state->func = func;
1056    it_state->data = data;
1057    return it_state;
1058 }
1059
1060 EAPI Elm_Toolbar_Item_State *
1061 elm_toolbar_item_state_add(Elm_Toolbar_Item *item, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1062 {
1063    Elm_Toolbar_Item_State *it_state;
1064    Evas_Object *icon_obj;
1065    Evas_Object *obj;
1066    Widget_Data *wd;
1067    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1068    obj = WIDGET(item);
1069    wd = elm_widget_data_get(WIDGET(item));
1070    if (!wd) return NULL;
1071
1072    if (!item->states)
1073      {
1074         it_state = _item_state_new(item->label, item->icon_str, item->icon,
1075                                    item->func, item->base.data);
1076         item->states = eina_list_append(item->states, it_state);
1077         item->current_state = item->states;
1078      }
1079
1080    icon_obj = elm_icon_add(obj);
1081    elm_icon_order_lookup_set(icon_obj, wd->lookup_order);
1082    if (!icon_obj) goto error_state_add;
1083
1084    if (!_item_icon_set(icon_obj, "toolbar/", icon))
1085      {
1086         evas_object_del(icon_obj);
1087         icon_obj = NULL;
1088         icon = NULL;
1089      }
1090
1091    it_state = _item_state_new(label, icon, icon_obj, func, data);
1092    item->states = eina_list_append(item->states, it_state);
1093    item->func = _elm_toolbar_item_state_cb;
1094    item->base.data = NULL;
1095
1096    return it_state;
1097
1098 error_state_add:
1099    if (item->states && !eina_list_next(item->states))
1100      {
1101         eina_stringshare_del(item->label);
1102         eina_stringshare_del(item->icon_str);
1103         free(eina_list_data_get(item->states));
1104         eina_list_free(item->states);
1105         item->states = NULL;
1106      }
1107    return NULL;
1108 }
1109
1110 EAPI Eina_Bool
1111 elm_toolbar_item_state_del(Elm_Toolbar_Item *item, Elm_Toolbar_Item_State *state)
1112 {
1113    Eina_List *del_state;
1114    Elm_Toolbar_Item_State *it_state;
1115    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
1116
1117    if (!state) return EINA_FALSE;
1118    if (!item->states) return EINA_FALSE;
1119
1120    del_state = eina_list_data_find_list(item->states, state);
1121    if (del_state == item->states) return EINA_FALSE;
1122    if (del_state == item->current_state)
1123      elm_toolbar_item_state_unset(item);
1124
1125    eina_stringshare_del(state->label);
1126    eina_stringshare_del(state->icon_str);
1127    if (state->icon) evas_object_del(state->icon);
1128    free(state);
1129    item->states = eina_list_remove_list(item->states, del_state);
1130    if (item->states && !eina_list_next(item->states))
1131      {
1132         it_state = eina_list_data_get(item->states);
1133         item->base.data = it_state->data;
1134         item->func = it_state->func;
1135         eina_stringshare_del(it_state->label);
1136         eina_stringshare_del(it_state->icon_str);
1137         free(eina_list_data_get(item->states));
1138         eina_list_free(item->states);
1139         item->states = NULL;
1140      }
1141    return EINA_TRUE;
1142 }
1143
1144 EAPI Elm_Toolbar_Item *
1145 elm_toolbar_item_prepend(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1146 {
1147    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1148    Widget_Data *wd = elm_widget_data_get(obj);
1149    if (!wd) return NULL;
1150
1151    Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data);
1152    if (!it) return NULL;
1153    double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1154
1155    wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
1156    evas_object_box_prepend(wd->bx, VIEW(it));
1157    evas_object_show(VIEW(it));
1158    _theme_hook_item(obj, it, scale, wd->icon_size);
1159    _sizing_eval(obj);
1160
1161    return it;
1162 }
1163
1164 EAPI Elm_Toolbar_Item *
1165 elm_toolbar_item_insert_before(Evas_Object *obj, Elm_Toolbar_Item *before, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1166 {
1167    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1168    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(before, NULL);
1169    Widget_Data *wd = elm_widget_data_get(obj);
1170    if (!wd) return NULL;
1171
1172    Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data);
1173    if (!it) return NULL;
1174    double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1175
1176    wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
1177                                             EINA_INLIST_GET(before));
1178    evas_object_box_insert_before(wd->bx, VIEW(it), VIEW(before));
1179    evas_object_show(VIEW(it));
1180    _theme_hook_item(obj, it, scale, wd->icon_size);
1181    _sizing_eval(obj);
1182
1183    return it;
1184 }
1185
1186 EAPI Elm_Toolbar_Item *
1187 elm_toolbar_item_insert_after(Evas_Object *obj, Elm_Toolbar_Item *after, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1188 {
1189    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1190    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(after, NULL);
1191    Widget_Data *wd = elm_widget_data_get(obj);
1192    if (!wd) return NULL;
1193
1194    Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data);
1195    if (!it) return NULL;
1196    double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1197
1198    wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
1199                                            EINA_INLIST_GET(after));
1200    evas_object_box_insert_after(wd->bx, VIEW(it), VIEW(after));
1201    evas_object_show(VIEW(it));
1202    _theme_hook_item(obj, it, scale, wd->icon_size);
1203    _sizing_eval(obj);
1204
1205    return it;
1206 }
1207
1208 EAPI Elm_Toolbar_Item *
1209 elm_toolbar_first_item_get(const Evas_Object *obj)
1210 {
1211    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1212    Widget_Data *wd = elm_widget_data_get(obj);
1213    if (!wd || !wd->items) return NULL;
1214    Elm_Toolbar_Item *it = ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items);
1215    return it;
1216 }
1217
1218 EAPI Elm_Toolbar_Item *
1219 elm_toolbar_last_item_get(const Evas_Object *obj)
1220 {
1221    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1222    Widget_Data *wd = elm_widget_data_get(obj);
1223    if (!wd || !wd->items) return NULL;
1224    Elm_Toolbar_Item *it = ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items->last);
1225    return it;
1226 }
1227
1228 EAPI Elm_Toolbar_Item *
1229 elm_toolbar_item_next_get(const Elm_Toolbar_Item *item)
1230 {
1231    Elm_Toolbar_Item *next;
1232    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1233    next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
1234    return next;
1235 }
1236
1237 EAPI Elm_Toolbar_Item *
1238 elm_toolbar_item_prev_get(const Elm_Toolbar_Item *item)
1239 {
1240    Elm_Toolbar_Item *prev;
1241    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1242    prev = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
1243    return prev;
1244 }
1245
1246 EAPI Evas_Object *
1247 elm_toolbar_item_toolbar_get(const Elm_Toolbar_Item *item)
1248 {
1249    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1250    return WIDGET(item);
1251 }
1252
1253 EAPI void
1254 elm_toolbar_item_priority_set(Elm_Toolbar_Item *item, int priority)
1255 {
1256    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1257    if (item->prio.priority == priority) return;
1258    item->prio.priority = priority;
1259    _resize(WIDGET(item), NULL, NULL, NULL);
1260 }
1261
1262 EAPI int
1263 elm_toolbar_item_priority_get(const Elm_Toolbar_Item *item)
1264 {
1265    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, 0);
1266    return item->prio.priority;
1267 }
1268
1269 EAPI const char *
1270 elm_toolbar_item_icon_get(const Elm_Toolbar_Item *item)
1271 {
1272    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1273    return item->icon_str;
1274 }
1275
1276 EAPI const char *
1277 elm_toolbar_item_label_get(const Elm_Toolbar_Item *item)
1278 {
1279    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1280    return item->label;
1281 }
1282
1283 static void
1284 _elm_toolbar_item_label_update(Elm_Toolbar_Item *item)
1285 {
1286    Evas_Coord mw = -1, mh = -1;
1287    Widget_Data *wd = elm_widget_data_get(item->base.widget);
1288    edje_object_part_text_set(VIEW(item), "elm.text", item->label);
1289
1290    elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1291    edje_object_size_min_restricted_calc(VIEW(item), &mw, &mh, mw, mh);
1292    elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1293    if (wd->vertical)
1294      {
1295         evas_object_size_hint_weight_set(VIEW(item), EVAS_HINT_EXPAND, -1.0);
1296         evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, 0.5);
1297      }
1298    else
1299      {
1300         evas_object_size_hint_weight_set(VIEW(item), -1.0, EVAS_HINT_EXPAND);
1301         evas_object_size_hint_align_set(VIEW(item), 0.5, EVAS_HINT_FILL);
1302      }
1303    evas_object_size_hint_min_set(VIEW(item), mw, mh);
1304 }
1305
1306 static void
1307 _elm_toolbar_item_label_set_cb (void *data, Evas_Object *obj, const char *emission, const char *source)
1308 {
1309    Elm_Toolbar_Item *item = data;
1310    _elm_toolbar_item_label_update(item);
1311    edje_object_signal_callback_del(obj, emission, source,
1312                                    _elm_toolbar_item_label_set_cb);
1313    edje_object_signal_emit (VIEW(item), "elm,state,label,reset", "elm");
1314 }
1315
1316 static void
1317 _item_label_set(Elm_Toolbar_Item *item, const char *label, const char *signal)
1318 {
1319    const char *s;
1320
1321    if ((label) && (item->label) && (!strcmp(label, item->label))) return;
1322
1323    eina_stringshare_replace(&item->label, label);
1324    s = edje_object_data_get(VIEW(item), "transition_animation_on");
1325    if ((s) && (atoi(s)))
1326      {
1327         edje_object_part_text_set(VIEW(item), "elm.text_new", item->label);
1328         edje_object_signal_emit (VIEW(item), signal, "elm");
1329         edje_object_signal_callback_add(VIEW(item),
1330                                         "elm,state,label_set,done", "elm",
1331                                         _elm_toolbar_item_label_set_cb, item);
1332      }
1333    else
1334      _elm_toolbar_item_label_update(item);
1335    _resize(WIDGET(item), NULL, NULL, NULL);
1336 }
1337
1338 EAPI void
1339 elm_toolbar_item_label_set(Elm_Toolbar_Item *item, const char *label)
1340 {
1341    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1342    _item_label_set(item, label, "elm,state,label_set");
1343 }
1344
1345 static void
1346 _elm_toolbar_item_icon_update(Elm_Toolbar_Item *item)
1347 {
1348    Elm_Toolbar_Item_State *it_state;
1349    Eina_List *l;
1350    Evas_Coord mw = -1, mh = -1;
1351    Widget_Data *wd = elm_widget_data_get(item->base.widget);
1352    Evas_Object *old_icon = edje_object_part_swallow_get(VIEW(item),
1353                                                         "elm.swallow.icon");
1354    elm_widget_sub_object_del(VIEW(item), old_icon);
1355    evas_object_hide(old_icon);
1356    edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon);
1357    elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1358    edje_object_size_min_restricted_calc(VIEW(item), &mw, &mh, mw, mh);
1359    elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1360    if (wd->vertical)
1361      {
1362         evas_object_size_hint_weight_set(VIEW(item), -1.0, EVAS_HINT_EXPAND);
1363         evas_object_size_hint_align_set(VIEW(item), 0.5, EVAS_HINT_FILL);
1364      }
1365    else
1366      {
1367         evas_object_size_hint_weight_set(VIEW(item), -1.0, EVAS_HINT_EXPAND);
1368         evas_object_size_hint_align_set(VIEW(item), 0.5, EVAS_HINT_FILL);
1369      }
1370    evas_object_size_hint_min_set(VIEW(item), mw, mh);
1371
1372    EINA_LIST_FOREACH(item->states, l, it_state)
1373       if (it_state->icon == old_icon)
1374         return;
1375    evas_object_del(old_icon);
1376 }
1377
1378 EAPI Eina_Bool
1379 elm_toolbar_item_selected_get(const Elm_Toolbar_Item *item)
1380 {
1381    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
1382    return item->selected;
1383 }
1384
1385 EAPI void
1386 elm_toolbar_item_selected_set(Elm_Toolbar_Item *item, Eina_Bool selected)
1387 {
1388    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1389    Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1390    if (!wd) return;
1391
1392    if (item->selected == selected) return;
1393
1394    if (selected)
1395      _item_select(item);
1396    else
1397      _item_unselect(item);
1398 }
1399
1400 EAPI Elm_Toolbar_Item *
1401 elm_toolbar_selected_item_get(const Evas_Object *obj)
1402 {
1403    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1404    Widget_Data *wd = elm_widget_data_get(obj);
1405    if (!wd) return NULL;
1406    return wd->selected_item;
1407 }
1408
1409 static void
1410 _elm_toolbar_item_icon_set_cb (void *data, Evas_Object *obj, const char *emission, const char *source)
1411 {
1412    Elm_Toolbar_Item *item = data;
1413    edje_object_part_unswallow(VIEW(item), item->icon);
1414    _elm_toolbar_item_icon_update(item);
1415    edje_object_signal_callback_del(obj, emission, source,
1416                                    _elm_toolbar_item_icon_set_cb);
1417    edje_object_signal_emit (VIEW(item), "elm,state,icon,reset", "elm");
1418 }
1419
1420 static void
1421 _elm_toolbar_item_icon_obj_set(Evas_Object *obj, Elm_Toolbar_Item *item, Evas_Object *icon_obj, const char *icon_str, double icon_size, const char *signal)
1422 {
1423    Evas_Object *old_icon;
1424    int ms = 0;
1425    const char *s;
1426
1427    if (icon_str)
1428      eina_stringshare_replace(&item->icon_str, icon_str);
1429    else
1430      {
1431         eina_stringshare_del(item->icon_str);
1432         item->icon_str = NULL;
1433      }
1434    item->icon = icon_obj;
1435    if (icon_obj)
1436      {
1437         ms = (icon_size * _elm_config->scale);
1438         evas_object_size_hint_min_set(item->icon, ms, ms);
1439         evas_object_size_hint_max_set(item->icon, ms, ms);
1440         evas_object_show(item->icon);
1441         elm_widget_sub_object_add(obj, item->icon);
1442      }
1443    s = edje_object_data_get(VIEW(item), "transition_animation_on");
1444    if ((s) && (atoi(s)))
1445      {
1446         old_icon = edje_object_part_swallow_get(VIEW(item),
1447                                                 "elm.swallow.icon_new");
1448         if (old_icon)
1449           {
1450              elm_widget_sub_object_del(VIEW(item), old_icon);
1451              evas_object_hide(old_icon);
1452           }
1453         edje_object_part_swallow(VIEW(item), "elm.swallow.icon_new",
1454                                  item->icon);
1455         edje_object_signal_emit (VIEW(item), signal, "elm");
1456         edje_object_signal_callback_add(VIEW(item),
1457                                         "elm,state,icon_set,done", "elm",
1458                                         _elm_toolbar_item_icon_set_cb, item);
1459      }
1460    else
1461      _elm_toolbar_item_icon_update(item);
1462    _resize(obj, NULL, NULL, NULL);
1463 }
1464
1465 EAPI void
1466 elm_toolbar_item_icon_set(Elm_Toolbar_Item *item, const char *icon)
1467 {
1468    Evas_Object *icon_obj;
1469    Widget_Data *wd;
1470    Evas_Object *obj;
1471
1472    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1473    obj = WIDGET(item);
1474    wd = elm_widget_data_get(obj);
1475    if (!wd) return;
1476    if ((icon) && (item->icon_str) && (!strcmp(icon, item->icon_str))) return;
1477
1478    icon_obj = elm_icon_add(obj);
1479    if (!icon_obj) return;
1480    if (_item_icon_set(icon_obj, "toolbar/", icon))
1481      _elm_toolbar_item_icon_obj_set(obj, item, icon_obj, icon, wd->icon_size,
1482                                     "elm,state,icon_set");
1483    else
1484      {
1485         _elm_toolbar_item_icon_obj_set(obj, item, NULL, NULL, 0,
1486                                        "elm,state,icon_set");
1487         evas_object_del(icon_obj);
1488      }
1489 }
1490
1491 EAPI Eina_Bool
1492 elm_toolbar_item_icon_memfile_set(Elm_Toolbar_Item *item, const void *img, size_t size, const char *format, const char *key)
1493 {
1494    Evas_Object *icon_obj;
1495    Widget_Data *wd;
1496    Evas_Object *obj;
1497    Eina_Bool ret;
1498
1499    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
1500    obj = WIDGET(item);
1501    wd = elm_widget_data_get(obj);
1502    if (!wd) return EINA_FALSE;
1503
1504    if (img && size)
1505      {
1506         icon_obj = _els_smart_icon_add(evas_object_evas_get(obj));
1507         evas_object_repeat_events_set(icon_obj, EINA_TRUE);
1508         ret = _els_smart_icon_memfile_set(icon_obj, img, size, format, key);
1509         if (!ret)
1510           {
1511              evas_object_del(icon_obj);
1512              return EINA_FALSE;
1513           }
1514         _elm_toolbar_item_icon_obj_set(obj, item, icon_obj, NULL, wd->icon_size,
1515                                          "elm,state,icon_set");
1516      }
1517    else
1518      _elm_toolbar_item_icon_obj_set(obj, item, NULL, NULL, 0, "elm,state,icon_set");
1519    return EINA_TRUE;
1520 }
1521
1522 EAPI Evas_Object *
1523 elm_toolbar_item_object_get(const Elm_Toolbar_Item *item)
1524 {
1525    Widget_Data *wd;
1526    Evas_Object *obj = WIDGET(item);
1527
1528    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1529    wd = elm_widget_data_get(obj);
1530    if (!wd) return NULL;
1531
1532    return VIEW(item);
1533 }
1534
1535 EAPI Evas_Object *
1536 elm_toolbar_item_icon_object_get(Elm_Toolbar_Item *item)
1537 {
1538    Widget_Data *wd;
1539    Evas_Object *obj;
1540
1541    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1542    obj = WIDGET(item);
1543    wd = elm_widget_data_get(obj);
1544    if (!wd) return NULL;
1545
1546    return item->icon;
1547 }
1548
1549 EAPI void
1550 elm_toolbar_item_del(Elm_Toolbar_Item *item)
1551 {
1552    Widget_Data *wd;
1553    Evas_Object *obj2;
1554    Elm_Toolbar_Item *next;
1555
1556    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1557    wd = elm_widget_data_get(WIDGET(item));
1558    if (!wd) return;
1559    obj2 = WIDGET(item);
1560    next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
1561    wd->items = eina_inlist_remove(wd->items, EINA_INLIST_GET(item));
1562    if (!next) next = ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items);
1563    if (wd->always_select && item->selected && next) _item_select(next);
1564    _item_del(item);
1565    _theme_hook(obj2);
1566 }
1567
1568 EAPI void
1569 elm_toolbar_item_del_cb_set(Elm_Toolbar_Item *item, Evas_Smart_Cb func)
1570 {
1571    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1572    elm_widget_item_del_cb_set(item, func);
1573 }
1574
1575 EAPI Eina_Bool
1576 elm_toolbar_item_disabled_get(const Elm_Toolbar_Item *item)
1577 {
1578    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
1579    return item->disabled;
1580 }
1581
1582 EAPI void
1583 elm_toolbar_item_disabled_set(Elm_Toolbar_Item *item, Eina_Bool disabled)
1584 {
1585    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1586    _item_disable(item, disabled);
1587    _resize(WIDGET(item), NULL, NULL, NULL);
1588 }
1589
1590 EAPI void
1591 elm_toolbar_item_separator_set(Elm_Toolbar_Item *item, Eina_Bool separator)
1592 {
1593    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1594    if (item->separator == separator) return;
1595    item->separator = separator;
1596    _theme_hook(VIEW(item));
1597 }
1598
1599 EAPI Eina_Bool
1600 elm_toolbar_item_separator_get(const Elm_Toolbar_Item *item)
1601 {
1602    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
1603    return item->separator;
1604 }
1605
1606 EAPI void
1607 elm_toolbar_mode_shrink_set(Evas_Object *obj, Elm_Toolbar_Shrink_Mode shrink_mode)
1608 {
1609    ELM_CHECK_WIDTYPE(obj, widtype);
1610    Widget_Data *wd = elm_widget_data_get(obj);
1611    Eina_Bool bounce;
1612
1613    if (!wd) return;
1614    wd->shrink_mode = shrink_mode;
1615    bounce = (_elm_config->thumbscroll_bounce_enable) &&
1616       (shrink_mode == ELM_TOOLBAR_SHRINK_SCROLL);
1617    elm_smart_scroller_bounce_allow_set(wd->scr, bounce, EINA_FALSE);
1618
1619    if (wd->more_item)
1620      {
1621         _item_del(wd->more_item);
1622         wd->more_item = NULL;
1623      }
1624
1625    if (shrink_mode == ELM_TOOLBAR_SHRINK_MENU)
1626      {
1627         elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_OFF, ELM_SMART_SCROLLER_POLICY_OFF);
1628
1629         wd->more_item = _item_new(obj, "more_menu", "More",
1630                                   NULL, NULL);
1631      }
1632    else if (shrink_mode == ELM_TOOLBAR_SHRINK_HIDE)
1633      elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_OFF,
1634                                    ELM_SMART_SCROLLER_POLICY_OFF);
1635    else
1636      elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_AUTO,
1637                                    ELM_SMART_SCROLLER_POLICY_OFF);
1638    _sizing_eval(obj);
1639 }
1640
1641 EAPI Elm_Toolbar_Shrink_Mode
1642 elm_toolbar_mode_shrink_get(const Evas_Object *obj)
1643 {
1644    ELM_CHECK_WIDTYPE(obj, widtype) ELM_TOOLBAR_SHRINK_NONE;
1645    Widget_Data *wd = elm_widget_data_get(obj);
1646
1647    if (!wd) return ELM_TOOLBAR_SHRINK_NONE;
1648    return wd->shrink_mode;
1649 }
1650
1651 EAPI void
1652 elm_toolbar_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
1653 {
1654    ELM_CHECK_WIDTYPE(obj, widtype);
1655    Widget_Data *wd = elm_widget_data_get(obj);
1656
1657    if (!wd) return;
1658    wd->homogeneous = !!homogeneous;
1659    evas_object_smart_calculate(wd->bx);
1660 }
1661
1662 EINA_DEPRECATED EAPI void
1663 elm_toolbar_homogenous_set(Evas_Object *obj, Eina_Bool homogenous)
1664 {
1665    elm_toolbar_homogeneous_set(obj, homogenous);
1666 }
1667
1668 EAPI Eina_Bool
1669 elm_toolbar_homogeneous_get(const Evas_Object *obj)
1670 {
1671    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1672    Widget_Data *wd = elm_widget_data_get(obj);
1673
1674    if (!wd) return EINA_FALSE;
1675    return wd->homogeneous;
1676 }
1677
1678 EINA_DEPRECATED EAPI Eina_Bool
1679 elm_toolbar_homogenous_get(const Evas_Object *obj)
1680 {
1681    return elm_toolbar_homogeneous_get(obj);
1682 }
1683
1684 EAPI void
1685 elm_toolbar_menu_parent_set(Evas_Object *obj, Evas_Object *parent)
1686 {
1687    Elm_Toolbar_Item *it;
1688    ELM_CHECK_WIDTYPE(obj, widtype);
1689    Widget_Data *wd = elm_widget_data_get(obj);
1690
1691    if (!wd) return;
1692    EINA_SAFETY_ON_NULL_RETURN(parent);
1693    wd->menu_parent = parent;
1694    EINA_INLIST_FOREACH(wd->items, it)
1695      {
1696         if (it->o_menu)
1697           elm_menu_parent_set(it->o_menu, wd->menu_parent);
1698      }
1699    if ((wd->more_item) && (wd->more_item->o_menu))
1700      elm_menu_parent_set(wd->more_item->o_menu, wd->menu_parent);
1701 }
1702
1703 EAPI Evas_Object *
1704 elm_toolbar_menu_parent_get(const Evas_Object *obj)
1705 {
1706    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1707    Widget_Data *wd = elm_widget_data_get(obj);
1708
1709    if (!wd) return NULL;
1710    return wd->menu_parent;
1711 }
1712
1713 EAPI void
1714 elm_toolbar_align_set(Evas_Object *obj, double align)
1715 {
1716    ELM_CHECK_WIDTYPE(obj, widtype);
1717    Widget_Data *wd = elm_widget_data_get(obj);
1718
1719    if (!wd) return;
1720    if (wd->align != align)
1721      evas_object_size_hint_align_set(wd->bx, align, 0.5);
1722    wd->align = align;
1723 }
1724
1725 EAPI double
1726 elm_toolbar_align_get(const Evas_Object *obj)
1727 {
1728    ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
1729    Widget_Data *wd = elm_widget_data_get(obj);
1730
1731    if (!wd) return 0.0;
1732    return wd->align;
1733 }
1734
1735 EAPI void
1736 elm_toolbar_item_menu_set(Elm_Toolbar_Item *item, Eina_Bool menu)
1737 {
1738    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1739    Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1740    if (!wd) return;
1741
1742    if (item->menu == menu) return;
1743    if (menu) _item_menu_create(wd, item);
1744    else _item_menu_destroy(item);
1745 }
1746
1747 EAPI void
1748 elm_toolbar_item_tooltip_text_set(Elm_Toolbar_Item *item, const char *text)
1749 {
1750    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1751    elm_widget_item_tooltip_text_set(item, text);
1752 }
1753
1754 EAPI void
1755 elm_toolbar_item_tooltip_content_cb_set(Elm_Toolbar_Item *item, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb)
1756 {
1757    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1758    elm_widget_item_tooltip_content_cb_set(item, func, data, del_cb);
1759 }
1760
1761 EAPI void
1762 elm_toolbar_item_tooltip_unset(Elm_Toolbar_Item *item)
1763 {
1764    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1765    elm_widget_item_tooltip_unset(item);
1766 }
1767
1768 EAPI void
1769 elm_toolbar_item_tooltip_style_set(Elm_Toolbar_Item *item, const char *style)
1770 {
1771    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1772    elm_widget_item_tooltip_style_set(item, style);
1773 }
1774
1775 EAPI const char *
1776 elm_toolbar_item_tooltip_style_get(const Elm_Toolbar_Item *item)
1777 {
1778    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1779    return elm_widget_item_tooltip_style_get(item);
1780 }
1781
1782 EAPI void
1783 elm_toolbar_item_cursor_set(Elm_Toolbar_Item *item, const char *cursor)
1784 {
1785    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1786    elm_widget_item_cursor_set(item, cursor);
1787 }
1788
1789 EAPI const char *
1790 elm_toolbar_item_cursor_get(const Elm_Toolbar_Item *item)
1791 {
1792    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1793    return elm_widget_item_cursor_get(item);
1794 }
1795
1796 EAPI void
1797 elm_toolbar_item_cursor_unset(Elm_Toolbar_Item *item)
1798 {
1799    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1800    elm_widget_item_cursor_unset(item);
1801 }
1802
1803 EAPI void
1804 elm_toolbar_item_cursor_style_set(Elm_Toolbar_Item *item, const char *style)
1805 {
1806    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1807    elm_widget_item_cursor_style_set(item, style);
1808 }
1809
1810 EAPI const char *
1811 elm_toolbar_item_cursor_style_get(const Elm_Toolbar_Item *item)
1812 {
1813    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1814    return elm_widget_item_cursor_style_get(item);
1815 }
1816
1817 EAPI void
1818 elm_toolbar_item_cursor_engine_only_set(Elm_Toolbar_Item *item, Eina_Bool engine_only)
1819 {
1820    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1821    elm_widget_item_cursor_engine_only_set(item, engine_only);
1822 }
1823
1824 EAPI Eina_Bool
1825 elm_toolbar_item_cursor_engine_only_get(const Elm_Toolbar_Item *item)
1826 {
1827    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
1828    return elm_widget_item_cursor_engine_only_get(item);
1829 }
1830
1831 EAPI Evas_Object *
1832 elm_toolbar_item_menu_get(const Elm_Toolbar_Item *item)
1833 {
1834    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1835    Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1836    if ((!wd) || (!item->menu)) return NULL;
1837    return item->o_menu;
1838 }
1839
1840 EAPI Elm_Toolbar_Item *
1841 elm_toolbar_item_find_by_label(const Evas_Object *obj, const char *label)
1842 {
1843    Elm_Toolbar_Item *it;
1844    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1845    Widget_Data *wd = elm_widget_data_get(obj);
1846
1847    if (!wd) return NULL;
1848    EINA_INLIST_FOREACH(wd->items, it)
1849      {
1850         if (!strcmp(it->label, label)) return it;
1851      }
1852
1853    return NULL;
1854 }
1855
1856 EAPI void
1857 elm_toolbar_item_data_set(Elm_Toolbar_Item *item, const void *data)
1858 {
1859    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1860    elm_widget_item_data_set(item, data);
1861 }
1862
1863 EAPI void *
1864 elm_toolbar_item_data_get(const Elm_Toolbar_Item *item)
1865 {
1866    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1867    return elm_widget_item_data_get(item);
1868 }
1869
1870 EAPI void
1871 elm_toolbar_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
1872 {
1873    ELM_CHECK_WIDTYPE(obj, widtype);
1874    Widget_Data *wd = elm_widget_data_get(obj);
1875    if (!wd) return;
1876    if (always_select && (!wd->always_select) && wd->items)
1877      _item_select(ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items));
1878    wd->always_select = always_select;
1879 }
1880
1881 EAPI Eina_Bool
1882 elm_toolbar_always_select_mode_get(const Evas_Object *obj)
1883 {
1884    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1885    Widget_Data *wd = elm_widget_data_get(obj);
1886    if (!wd) return EINA_FALSE;
1887    return wd->always_select;
1888 }
1889
1890 EAPI void
1891 elm_toolbar_no_select_mode_set(Evas_Object *obj, Eina_Bool no_select)
1892 {
1893    ELM_CHECK_WIDTYPE(obj, widtype);
1894    Widget_Data *wd = elm_widget_data_get(obj);
1895    if (!wd) return;
1896    wd->no_select = no_select;
1897 }
1898
1899 EAPI Eina_Bool
1900 elm_toolbar_no_select_mode_get(const Evas_Object *obj)
1901 {
1902    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1903    Widget_Data *wd = elm_widget_data_get(obj);
1904    if (!wd) return EINA_FALSE;
1905    return wd->no_select;
1906 }
1907
1908 EAPI void
1909 elm_toolbar_icon_order_lookup_set(Evas_Object *obj, Elm_Icon_Lookup_Order order)
1910 {
1911    ELM_CHECK_WIDTYPE(obj, widtype);
1912    Elm_Toolbar_Item *it;
1913    Widget_Data *wd = elm_widget_data_get(obj);
1914    if (!wd) return;
1915
1916    wd->lookup_order = order;
1917    EINA_INLIST_FOREACH(wd->items, it)
1918       elm_icon_order_lookup_set(it->icon, order);
1919    if (wd->more_item)
1920      elm_icon_order_lookup_set(wd->more_item->icon, order);
1921 }
1922
1923 EAPI Elm_Icon_Lookup_Order
1924 elm_toolbar_icon_order_lookup_get(const Evas_Object *obj)
1925 {
1926    ELM_CHECK_WIDTYPE(obj, widtype) ELM_ICON_LOOKUP_THEME_FDO;
1927    Widget_Data *wd = elm_widget_data_get(obj);
1928    if (!wd) return ELM_ICON_LOOKUP_THEME_FDO;
1929    return wd->lookup_order;
1930 }
1931
1932 EINA_DEPRECATED EAPI void
1933 elm_toolbar_orientation_set(Evas_Object *obj, Eina_Bool vertical)
1934 {
1935    elm_toolbar_horizontal_set(obj, !vertical);
1936 }
1937
1938 EINA_DEPRECATED EAPI Eina_Bool
1939 elm_toolbar_orientation_get(const Evas_Object *obj)
1940 {
1941    return !elm_toolbar_horizontal_get(obj);
1942 }
1943
1944 EAPI void
1945 elm_toolbar_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
1946 {
1947    ELM_CHECK_WIDTYPE(obj, widtype);
1948    Widget_Data *wd = elm_widget_data_get(obj);
1949    if (!wd) return;
1950    wd->vertical = vertical;
1951    _sizing_eval(obj);
1952 }
1953
1954 EAPI Eina_Bool
1955 elm_toolbar_horizontal_get(const Evas_Object *obj)
1956 {
1957    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1958    Widget_Data *wd = elm_widget_data_get(obj);
1959    if (!wd) return EINA_FALSE;
1960    return !wd->vertical;
1961 }