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