Change the toolbar item by using button object.
[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)
942 {
943    const char *s;
944
945    if ((label) && (item->label) && (!strcmp(label, item->label))) return;
946
947    eina_stringshare_replace(&item->label, label);
948    elm_object_text_set(VIEW(item), label);
949
950    _resize(WIDGET(item), NULL, NULL, NULL);
951 }
952
953 static void
954 _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)
955 {
956    Evas_Object *old_icon;
957    int ms = 0;
958    const char *s;
959
960    if (icon_str)
961      eina_stringshare_replace(&item->icon_str, icon_str);
962    else
963      {
964         eina_stringshare_del(item->icon_str);
965         item->icon_str = NULL;
966      }
967    item->icon = icon_obj;
968    if (icon_obj)
969      {
970         ms = (icon_size * _elm_config->scale);
971         evas_object_size_hint_min_set(item->icon, ms, ms);
972         evas_object_size_hint_max_set(item->icon, ms, ms);
973         evas_object_show(item->icon);
974         elm_widget_sub_object_add(obj, item->icon);
975      }
976    elm_object_part_content_set(VIEW(item), "icon", item->icon);
977
978    _resize(obj, NULL, NULL, NULL);
979 }
980
981 static void
982 _elm_toolbar_item_state_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
983 {
984    Elm_Toolbar_Item *it = event_info;
985    Elm_Toolbar_Item_State *it_state;
986
987    it_state = eina_list_data_get(it->current_state);
988    if (it_state->func)
989      it_state->func((void *)it_state->data, obj, event_info);
990 }
991
992 static Elm_Toolbar_Item_State *
993 _item_state_new(const char *label, const char *icon_str, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
994 {
995    Elm_Toolbar_Item_State *it_state;
996    it_state = ELM_NEW(Elm_Toolbar_Item_State);
997    it_state->label = eina_stringshare_add(label);
998    it_state->icon_str = eina_stringshare_add(icon_str);
999    it_state->icon = icon;
1000    it_state->func = func;
1001    it_state->data = data;
1002    return it_state;
1003 }
1004
1005 EAPI Evas_Object *
1006 elm_toolbar_add(Evas_Object *parent)
1007 {
1008    Evas_Object *obj;
1009    Evas *e;
1010    Widget_Data *wd;
1011
1012    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1013
1014    ELM_SET_WIDTYPE(widtype, "toolbar");
1015    elm_widget_type_set(obj, "toolbar");
1016    elm_widget_sub_object_add(parent, obj);
1017    elm_widget_data_set(obj, wd);
1018    elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1019    elm_widget_del_hook_set(obj, _del_hook);
1020    elm_widget_theme_hook_set(obj, _theme_hook);
1021    elm_widget_translate_hook_set(obj, _translate_hook);
1022    elm_widget_can_focus_set(obj, EINA_FALSE);
1023
1024    wd->more_item = NULL;
1025    wd->selected_item = NULL;
1026    wd->scr = elm_smart_scroller_add(e);
1027    elm_smart_scroller_widget_set(wd->scr, obj);
1028    elm_smart_scroller_object_theme_set(obj, wd->scr, "toolbar", "base", "default");
1029    elm_smart_scroller_bounce_allow_set(wd->scr,
1030                                        _elm_config->thumbscroll_bounce_enable,
1031                                        EINA_FALSE);
1032    elm_widget_resize_object_set(obj, wd->scr);
1033    elm_smart_scroller_policy_set(wd->scr,
1034                                  ELM_SMART_SCROLLER_POLICY_AUTO,
1035                                  ELM_SMART_SCROLLER_POLICY_OFF);
1036
1037
1038    wd->icon_size = _elm_toolbar_icon_size_get(wd);
1039
1040
1041    wd->homogeneous = EINA_TRUE;
1042    wd->align = 0.5;
1043
1044    wd->bx = evas_object_box_add(e);
1045    evas_object_size_hint_align_set(wd->bx, wd->align, 0.5);
1046    evas_object_box_layout_set(wd->bx, _layout, obj, NULL);
1047    elm_widget_sub_object_add(obj, wd->bx);
1048    elm_smart_scroller_child_set(wd->scr, wd->bx);
1049    evas_object_show(wd->bx);
1050
1051    elm_toolbar_shrink_mode_set(obj, _elm_config->toolbar_shrink_mode);
1052    evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_RESIZE, _resize, obj);
1053    evas_object_event_callback_add(wd->bx, EVAS_CALLBACK_RESIZE, _resize, obj);
1054    elm_toolbar_icon_order_lookup_set(obj, ELM_ICON_LOOKUP_THEME_FDO);
1055
1056    evas_object_smart_callbacks_descriptions_set(obj, _signals);
1057
1058    _sizing_eval(obj);
1059    return obj;
1060 }
1061
1062 EAPI void
1063 elm_toolbar_icon_size_set(Evas_Object *obj, int icon_size)
1064 {
1065    ELM_CHECK_WIDTYPE(obj, widtype);
1066    Widget_Data *wd = elm_widget_data_get(obj);
1067    if (!wd) return;
1068    if (wd->icon_size == icon_size) return;
1069    wd->icon_size = icon_size;
1070    _theme_hook(obj);
1071 }
1072
1073 EAPI int
1074 elm_toolbar_icon_size_get(const Evas_Object *obj)
1075 {
1076    ELM_CHECK_WIDTYPE(obj, widtype) 0;
1077    Widget_Data *wd = elm_widget_data_get(obj);
1078    if (!wd) return 0;
1079    return wd->icon_size;
1080 }
1081
1082 EAPI Elm_Object_Item *
1083 elm_toolbar_item_append(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1084 {
1085    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1086    Widget_Data *wd = elm_widget_data_get(obj);
1087    if (!wd) return NULL;
1088
1089    Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data);
1090    if (!it) return NULL;
1091    double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1092
1093    wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
1094    evas_object_box_append(wd->bx, VIEW(it));
1095    evas_object_show(VIEW(it));
1096
1097    _theme_hook_item(obj, it, scale, wd->icon_size);
1098    _sizing_eval(obj);
1099
1100    return (Elm_Object_Item *) it;
1101 }
1102
1103 EAPI Elm_Object_Item *
1104 elm_toolbar_item_prepend(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1105 {
1106    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1107    Widget_Data *wd = elm_widget_data_get(obj);
1108    if (!wd) return NULL;
1109
1110    Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data);
1111    if (!it) return NULL;
1112    double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1113
1114    wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
1115    evas_object_box_prepend(wd->bx, VIEW(it));
1116    evas_object_show(VIEW(it));
1117    _theme_hook_item(obj, it, scale, wd->icon_size);
1118    _sizing_eval(obj);
1119
1120    return (Elm_Object_Item *) it;
1121 }
1122
1123 EAPI Elm_Object_Item *
1124 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)
1125 {
1126    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1127    ELM_OBJ_ITEM_CHECK_OR_RETURN(before, NULL);
1128    Widget_Data *wd;
1129    Elm_Toolbar_Item *it, *_before;
1130
1131    wd = elm_widget_data_get(obj);
1132    if (!wd) return NULL;
1133    _before = (Elm_Toolbar_Item *) before;
1134    it = _item_new(obj, icon, label, func, data);
1135    if (!it) return NULL;
1136    double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1137
1138    wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
1139                                             EINA_INLIST_GET(_before));
1140    evas_object_box_insert_before(wd->bx, VIEW(it), VIEW(_before));
1141    evas_object_show(VIEW(it));
1142    _theme_hook_item(obj, it, scale, wd->icon_size);
1143    _sizing_eval(obj);
1144
1145    return (Elm_Object_Item *) it;
1146 }
1147
1148 EAPI Elm_Object_Item *
1149 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)
1150 {
1151    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1152    ELM_OBJ_ITEM_CHECK_OR_RETURN(after, NULL);
1153    Widget_Data *wd;
1154    Elm_Toolbar_Item *it, *_after;
1155
1156    wd = elm_widget_data_get(obj);
1157    if (!wd) return NULL;
1158    _after = (Elm_Toolbar_Item *) after;
1159    it = _item_new(obj, icon, label, func, data);
1160    if (!it) return NULL;
1161    double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1162
1163    wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
1164                                            EINA_INLIST_GET(_after));
1165    evas_object_box_insert_after(wd->bx, VIEW(it), VIEW(_after));
1166    evas_object_show(VIEW(it));
1167    _theme_hook_item(obj, it, scale, wd->icon_size);
1168    _sizing_eval(obj);
1169
1170    return (Elm_Object_Item *) it;
1171 }
1172
1173 EAPI Elm_Object_Item *
1174 elm_toolbar_first_item_get(const Evas_Object *obj)
1175 {
1176    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1177    Widget_Data *wd = elm_widget_data_get(obj);
1178    if (!wd || !wd->items) return NULL;
1179    return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items);
1180 }
1181
1182 EAPI Elm_Object_Item *
1183 elm_toolbar_last_item_get(const Evas_Object *obj)
1184 {
1185    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1186    Widget_Data *wd = elm_widget_data_get(obj);
1187    if (!wd || !wd->items) return NULL;
1188    return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items->last);
1189 }
1190
1191 EAPI Elm_Object_Item *
1192 elm_toolbar_item_next_get(const Elm_Object_Item *it)
1193 {
1194    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1195    return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST(
1196       EINA_INLIST_GET(((Elm_Toolbar_Item *) it))->next);
1197 }
1198
1199 EAPI Elm_Object_Item *
1200 elm_toolbar_item_prev_get(const Elm_Object_Item *it)
1201 {
1202    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1203    return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST(
1204       EINA_INLIST_GET(((Elm_Toolbar_Item *) it))->prev);
1205 }
1206
1207 EAPI Evas_Object *
1208 elm_toolbar_item_toolbar_get(const Elm_Object_Item *it)
1209 {
1210    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1211    return elm_object_item_widget_get(it);
1212 }
1213
1214 EAPI void
1215 elm_toolbar_item_priority_set(Elm_Object_Item *it, int priority)
1216 {
1217    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1218    Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
1219    if (item->prio.priority == priority) return;
1220    item->prio.priority = priority;
1221    _resize(WIDGET(item), NULL, NULL, NULL);
1222 }
1223
1224 EAPI int
1225 elm_toolbar_item_priority_get(const Elm_Object_Item *it)
1226 {
1227    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, 0);
1228    return ((Elm_Toolbar_Item *) it)->prio.priority;
1229 }
1230
1231 EAPI const char *
1232 elm_toolbar_item_label_get(const Elm_Object_Item *it)
1233 {
1234    return _item_text_get_hook(it, NULL);
1235 }
1236
1237 EAPI void
1238 elm_toolbar_item_label_set(Elm_Object_Item *it, const char *label)
1239 {
1240    _item_text_set_hook(it, NULL, label);
1241 }
1242
1243 EAPI void *
1244 elm_toolbar_item_data_get(const Elm_Object_Item *it)
1245 {
1246    return elm_object_item_data_get(it);
1247 }
1248
1249 EAPI void
1250 elm_toolbar_item_data_set(Elm_Object_Item *it, const void *data)
1251 {
1252    elm_object_item_data_set(it, (void *) data);
1253 }
1254
1255 EAPI Elm_Object_Item *
1256 elm_toolbar_item_find_by_label(const Evas_Object *obj, const char *label)
1257 {
1258    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1259    Elm_Toolbar_Item *it;
1260    Widget_Data *wd = elm_widget_data_get(obj);
1261    if (!wd) return NULL;
1262
1263    EINA_INLIST_FOREACH(wd->items, it)
1264      {
1265         if (!strcmp(it->label, label))
1266           return (Elm_Object_Item *) it;
1267      }
1268    return NULL;
1269 }
1270
1271 EAPI void
1272 elm_toolbar_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
1273 {
1274    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1275    Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
1276    Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1277    if (!wd) return;
1278
1279    if (item->selected == selected) return;
1280    if (selected) _item_select(item);
1281    else _item_unselect(item);
1282 }
1283
1284 EAPI Eina_Bool
1285 elm_toolbar_item_selected_get(const Elm_Object_Item *it)
1286 {
1287    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1288    return ((Elm_Toolbar_Item *) it)->selected;
1289 }
1290
1291 EAPI Elm_Object_Item *
1292 elm_toolbar_selected_item_get(const Evas_Object *obj)
1293 {
1294    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1295    Widget_Data *wd = elm_widget_data_get(obj);
1296    if (!wd) return NULL;
1297    return (Elm_Object_Item *) wd->selected_item;
1298 }
1299
1300 EAPI void
1301 elm_toolbar_item_icon_set(Elm_Object_Item *it, const char *icon)
1302 {
1303    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1304
1305    Evas_Object *icon_obj;
1306    Widget_Data *wd;
1307    Evas_Object *obj;
1308    Elm_Toolbar_Item * item = (Elm_Toolbar_Item *) it;
1309
1310    obj = WIDGET(item);
1311    wd = elm_widget_data_get(obj);
1312    if (!wd) return;
1313    if ((icon) && (item->icon_str) && (!strcmp(icon, item->icon_str))) return;
1314
1315    icon_obj = elm_icon_add(obj);
1316    if (!icon_obj) return;
1317    if (_item_icon_set(icon_obj, "toolbar/", icon))
1318      _elm_toolbar_item_icon_obj_set(obj, item, icon_obj, icon, wd->icon_size,
1319                                     "elm,state,icon_set");
1320    else
1321      {
1322         _elm_toolbar_item_icon_obj_set(obj, item, NULL, NULL, 0,
1323                                        "elm,state,icon_set");
1324         evas_object_del(icon_obj);
1325      }
1326 }
1327
1328 EAPI const char *
1329 elm_toolbar_item_icon_get(const Elm_Object_Item *it)
1330 {
1331    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1332    return ((Elm_Toolbar_Item *) it)->icon_str;
1333 }
1334
1335 EAPI Evas_Object *
1336 elm_toolbar_item_object_get(const Elm_Object_Item *it)
1337 {
1338    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1339
1340    Widget_Data *wd;
1341    Evas_Object *obj;
1342    Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
1343
1344    obj = WIDGET(item);
1345    wd = elm_widget_data_get(obj);
1346    if (!wd) return NULL;
1347
1348    return VIEW(item);
1349 }
1350
1351 EAPI Evas_Object *
1352 elm_toolbar_item_icon_object_get(Elm_Object_Item *it)
1353 {
1354    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1355    return ((Elm_Toolbar_Item *) it)->icon;
1356 }
1357
1358 EAPI Eina_Bool
1359 elm_toolbar_item_icon_memfile_set(Elm_Object_Item *it, const void *img, size_t size, const char *format, const char *key)
1360 {
1361    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1362
1363    Evas_Object *icon_obj;
1364    Widget_Data *wd;
1365    Evas_Object *obj;
1366    Eina_Bool ret;
1367    Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
1368
1369    obj = WIDGET(item);
1370    wd = elm_widget_data_get(obj);
1371    if (!wd) return EINA_FALSE;
1372
1373    if (img && size)
1374      {
1375         icon_obj = _els_smart_icon_add(evas_object_evas_get(obj));
1376         evas_object_repeat_events_set(icon_obj, EINA_TRUE);
1377         ret = _els_smart_icon_memfile_set(icon_obj, img, size, format, key);
1378         if (!ret)
1379           {
1380              evas_object_del(icon_obj);
1381              return EINA_FALSE;
1382           }
1383         _elm_toolbar_item_icon_obj_set(obj, item, icon_obj, NULL, wd->icon_size,
1384                                          "elm,state,icon_set");
1385      }
1386    else
1387      _elm_toolbar_item_icon_obj_set(obj, item, NULL, NULL, 0, "elm,state,icon_set");
1388    return EINA_TRUE;
1389 }
1390
1391 EAPI Eina_Bool
1392 elm_toolbar_item_icon_file_set(Elm_Object_Item *it, const char *file, const char *key)
1393 {
1394    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1395
1396    Evas_Object *icon_obj;
1397    Widget_Data *wd;
1398    Evas_Object *obj;
1399    Eina_Bool ret;
1400    Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
1401
1402    obj = WIDGET(item);
1403    wd = elm_widget_data_get(obj);
1404    if (!wd) return EINA_FALSE;
1405
1406    if (file)
1407      {
1408         icon_obj = _els_smart_icon_add(evas_object_evas_get(obj));
1409         evas_object_repeat_events_set(icon_obj, EINA_TRUE);
1410         ret = _els_smart_icon_file_key_set(icon_obj, file, key);
1411         if (!ret)
1412           {
1413              evas_object_del(icon_obj);
1414              return EINA_FALSE;
1415           }
1416         _elm_toolbar_item_icon_obj_set(obj, item, icon_obj, NULL, wd->icon_size,
1417                                          "elm,state,icon_set");
1418      }
1419    else
1420      _elm_toolbar_item_icon_obj_set(obj, item, NULL, NULL, 0, "elm,state,icon_set");
1421    return EINA_TRUE;
1422 }
1423
1424 EAPI void
1425 elm_toolbar_item_del(Elm_Object_Item *it)
1426 {
1427    elm_object_item_del(it);
1428 }
1429
1430 EAPI void
1431 elm_toolbar_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func)
1432 {
1433    elm_object_item_del_cb_set(it, func);
1434 }
1435
1436 EAPI Eina_Bool
1437 elm_toolbar_item_disabled_get(const Elm_Object_Item *it)
1438 {
1439    return elm_object_item_disabled_get(it);
1440 }
1441
1442 EAPI void
1443 elm_toolbar_item_disabled_set(Elm_Object_Item *it, Eina_Bool disabled)
1444 {
1445    elm_object_item_disabled_set(it, disabled);
1446 }
1447
1448 EAPI void
1449 elm_toolbar_item_separator_set(Elm_Object_Item *it, Eina_Bool separator)
1450 {
1451    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1452    Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
1453    Evas_Object *obj = WIDGET(item);
1454    Widget_Data *wd = elm_widget_data_get(obj);
1455    double scale;
1456    if (item->separator == separator) return;
1457    item->separator = separator;
1458    scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1459    _theme_hook_item(obj, item, scale, wd->icon_size);
1460 }
1461
1462 EAPI Eina_Bool
1463 elm_toolbar_item_separator_get(const Elm_Object_Item *it)
1464 {
1465    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1466    return ((Elm_Toolbar_Item *) it)->separator;
1467 }
1468
1469 EAPI void
1470 elm_toolbar_shrink_mode_set(Evas_Object *obj, Elm_Toolbar_Shrink_Mode shrink_mode)
1471 {
1472    ELM_CHECK_WIDTYPE(obj, widtype);
1473    Widget_Data *wd = elm_widget_data_get(obj);
1474    Eina_Bool bounce;
1475
1476    if (!wd) return;
1477    wd->shrink_mode = shrink_mode;
1478    bounce = (_elm_config->thumbscroll_bounce_enable) &&
1479       (shrink_mode == ELM_TOOLBAR_SHRINK_SCROLL);
1480    elm_smart_scroller_bounce_allow_set(wd->scr, bounce, EINA_FALSE);
1481
1482    if (wd->more_item)
1483      {
1484         _item_del(wd->more_item);
1485         elm_widget_item_free(wd->more_item);
1486         wd->more_item = NULL;
1487      }
1488
1489    if (shrink_mode == ELM_TOOLBAR_SHRINK_MENU)
1490      {
1491         elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_OFF, 
1492                                       ELM_SMART_SCROLLER_POLICY_OFF);
1493         wd->more_item = _item_new(obj, "more_menu", "More", NULL, NULL);
1494      }
1495    else if (shrink_mode == ELM_TOOLBAR_SHRINK_HIDE)
1496      elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_OFF,
1497                                    ELM_SMART_SCROLLER_POLICY_OFF);
1498    else
1499      elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_AUTO,
1500                                    ELM_SMART_SCROLLER_POLICY_OFF);
1501    _sizing_eval(obj);
1502 }
1503
1504 EAPI Elm_Toolbar_Shrink_Mode
1505 elm_toolbar_shrink_mode_get(const Evas_Object *obj)
1506 {
1507    ELM_CHECK_WIDTYPE(obj, widtype) ELM_TOOLBAR_SHRINK_NONE;
1508    Widget_Data *wd = elm_widget_data_get(obj);
1509
1510    if (!wd) return ELM_TOOLBAR_SHRINK_NONE;
1511    return wd->shrink_mode;
1512 }
1513
1514 EAPI void
1515 elm_toolbar_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
1516 {
1517    ELM_CHECK_WIDTYPE(obj, widtype);
1518    Widget_Data *wd = elm_widget_data_get(obj);
1519
1520    if (!wd) return;
1521    wd->homogeneous = !!homogeneous;
1522    evas_object_smart_calculate(wd->bx);
1523 }
1524
1525 EAPI Eina_Bool
1526 elm_toolbar_homogeneous_get(const Evas_Object *obj)
1527 {
1528    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1529    Widget_Data *wd = elm_widget_data_get(obj);
1530
1531    if (!wd) return EINA_FALSE;
1532    return wd->homogeneous;
1533 }
1534
1535 EAPI void
1536 elm_toolbar_menu_parent_set(Evas_Object *obj, Evas_Object *parent)
1537 {
1538    Elm_Toolbar_Item *it;
1539    ELM_CHECK_WIDTYPE(obj, widtype);
1540    Widget_Data *wd = elm_widget_data_get(obj);
1541
1542    if (!wd) return;
1543    EINA_SAFETY_ON_NULL_RETURN(parent);
1544    wd->menu_parent = parent;
1545    EINA_INLIST_FOREACH(wd->items, it)
1546      {
1547         if (it->o_menu)
1548           elm_menu_parent_set(it->o_menu, wd->menu_parent);
1549      }
1550    if ((wd->more_item) && (wd->more_item->o_menu))
1551      elm_menu_parent_set(wd->more_item->o_menu, wd->menu_parent);
1552 }
1553
1554 EAPI Evas_Object *
1555 elm_toolbar_menu_parent_get(const Evas_Object *obj)
1556 {
1557    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1558    Widget_Data *wd = elm_widget_data_get(obj);
1559
1560    if (!wd) return NULL;
1561    return wd->menu_parent;
1562 }
1563
1564 EAPI void
1565 elm_toolbar_align_set(Evas_Object *obj, double align)
1566 {
1567    ELM_CHECK_WIDTYPE(obj, widtype);
1568    Widget_Data *wd = elm_widget_data_get(obj);
1569
1570    if (!wd) return;
1571    if (wd->vertical)
1572      {
1573         if (wd->align != align)
1574           evas_object_size_hint_align_set(wd->bx, 0.5, align);
1575      }
1576    else
1577      {
1578         if (wd->align != align)
1579           evas_object_size_hint_align_set(wd->bx, align, 0.5);
1580      }
1581    wd->align = align;
1582 }
1583
1584 EAPI double
1585 elm_toolbar_align_get(const Evas_Object *obj)
1586 {
1587    ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
1588    Widget_Data *wd = elm_widget_data_get(obj);
1589
1590    if (!wd) return 0.0;
1591    return wd->align;
1592 }
1593
1594 EAPI void
1595 elm_toolbar_item_menu_set(Elm_Object_Item *it, Eina_Bool menu)
1596 {
1597    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1598    Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
1599    Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1600    if (!wd) return;
1601
1602    if (item->menu == menu) return;
1603    if (menu) _item_menu_create(wd, item);
1604    else _item_menu_destroy(item);
1605 }
1606
1607 EAPI Evas_Object *
1608 elm_toolbar_item_menu_get(const Elm_Object_Item *it)
1609 {
1610    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1611    Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
1612    if (!item->menu) return NULL;
1613    Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1614    if (!wd) return NULL;
1615    return item->o_menu;
1616 }
1617
1618 EAPI Elm_Toolbar_Item_State *
1619 elm_toolbar_item_state_add(Elm_Object_Item *it, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1620 {
1621    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1622
1623    Elm_Toolbar_Item_State *it_state;
1624    Evas_Object *icon_obj;
1625    Evas_Object *obj;
1626    Widget_Data *wd;
1627    Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
1628    obj = WIDGET(item);
1629    wd = elm_widget_data_get(WIDGET(item));
1630    if (!wd) return NULL;
1631
1632    if (!item->states)
1633      {
1634         it_state = _item_state_new(item->label, item->icon_str, item->icon,
1635                                    item->func, item->base.data);
1636         item->states = eina_list_append(item->states, it_state);
1637         item->current_state = item->states;
1638      }
1639
1640    icon_obj = elm_icon_add(obj);
1641    elm_icon_order_lookup_set(icon_obj, wd->lookup_order);
1642    if (!icon_obj) goto error_state_add;
1643
1644    if (!_item_icon_set(icon_obj, "toolbar/", icon))
1645      {
1646         evas_object_del(icon_obj);
1647         icon_obj = NULL;
1648         icon = NULL;
1649      }
1650
1651    it_state = _item_state_new(label, icon, icon_obj, func, data);
1652    item->states = eina_list_append(item->states, it_state);
1653    item->func = _elm_toolbar_item_state_cb;
1654    item->base.data = NULL;
1655
1656    return it_state;
1657
1658 error_state_add:
1659    if (item->states && !eina_list_next(item->states))
1660      {
1661         eina_stringshare_del(item->label);
1662         eina_stringshare_del(item->icon_str);
1663         free(eina_list_data_get(item->states));
1664         eina_list_free(item->states);
1665         item->states = NULL;
1666      }
1667    return NULL;
1668 }
1669
1670 EAPI Eina_Bool
1671 elm_toolbar_item_state_del(Elm_Object_Item *it, Elm_Toolbar_Item_State *state)
1672 {
1673    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1674
1675    Eina_List *del_state;
1676    Elm_Toolbar_Item_State *it_state;
1677    Elm_Toolbar_Item *item;
1678
1679    if (!state) return EINA_FALSE;
1680
1681    item = (Elm_Toolbar_Item *) it;
1682    if (!item->states) return EINA_FALSE;
1683
1684    del_state = eina_list_data_find_list(item->states, state);
1685    if (del_state == item->states) return EINA_FALSE;
1686    if (del_state == item->current_state)
1687      elm_toolbar_item_state_unset(it);
1688
1689    eina_stringshare_del(state->label);
1690    eina_stringshare_del(state->icon_str);
1691    if (state->icon) evas_object_del(state->icon);
1692    free(state);
1693    item->states = eina_list_remove_list(item->states, del_state);
1694    if (item->states && !eina_list_next(item->states))
1695      {
1696         it_state = eina_list_data_get(item->states);
1697         item->base.data = it_state->data;
1698         item->func = it_state->func;
1699         eina_stringshare_del(it_state->label);
1700         eina_stringshare_del(it_state->icon_str);
1701         free(eina_list_data_get(item->states));
1702         eina_list_free(item->states);
1703         item->states = NULL;
1704      }
1705    return EINA_TRUE;
1706 }
1707
1708 EAPI Eina_Bool
1709 elm_toolbar_item_state_set(Elm_Object_Item *it, Elm_Toolbar_Item_State *state)
1710 {
1711    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1712
1713    Widget_Data *wd;
1714    Eina_List *next_state;
1715    Elm_Toolbar_Item_State *it_state;
1716    Evas_Object *obj;
1717    Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
1718
1719    obj = WIDGET(item);
1720    wd = elm_widget_data_get(obj);
1721    if (!wd) return EINA_FALSE;
1722    if (!item->states) return EINA_FALSE;
1723
1724    if (state)
1725      {
1726         next_state = eina_list_data_find_list(item->states, state);
1727         if (!next_state) return EINA_FALSE;
1728      }
1729    else
1730      next_state = item->states;
1731
1732    if (next_state == item->current_state) return EINA_TRUE;
1733
1734    it_state = eina_list_data_get(next_state);
1735    if (eina_list_data_find(item->current_state, state))
1736      {
1737         _item_label_set(item, it_state->label, "elm,state,label_set,forward");
1738         _elm_toolbar_item_icon_obj_set(obj, item, it_state->icon, it_state->icon_str,
1739                                        wd->icon_size, "elm,state,icon_set,forward");
1740      }
1741    else
1742      {
1743         _item_label_set(item, it_state->label, "elm,state,label_set,backward");
1744         _elm_toolbar_item_icon_obj_set(obj,
1745                                        item,
1746                                        it_state->icon,
1747                                        it_state->icon_str,
1748                                        wd->icon_size,
1749                                        "elm,state,icon_set,backward");
1750      }
1751    if (elm_widget_item_disabled_get(item))
1752      elm_widget_signal_emit(item->icon, "elm,state,disabled", "elm");
1753    else
1754      elm_widget_signal_emit(item->icon, "elm,state,enabled", "elm");
1755
1756    item->current_state = next_state;
1757    return EINA_TRUE;
1758 }
1759
1760 EAPI void
1761 elm_toolbar_item_state_unset(Elm_Object_Item *it)
1762 {
1763    elm_toolbar_item_state_set(it, NULL);
1764 }
1765
1766 EAPI Elm_Toolbar_Item_State *
1767 elm_toolbar_item_state_get(const Elm_Object_Item *it)
1768 {
1769    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1770    Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
1771
1772    if ((!item->states) || (!item->current_state)) return NULL;
1773    if (item->current_state == item->states) return NULL;
1774
1775    return eina_list_data_get(item->current_state);
1776 }
1777
1778 EAPI Elm_Toolbar_Item_State *
1779 elm_toolbar_item_state_next(Elm_Object_Item *it)
1780 {
1781    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1782
1783    Widget_Data *wd;
1784    Evas_Object *obj;
1785    Eina_List *next_state;
1786    Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
1787
1788    obj = WIDGET(item);
1789    wd = elm_widget_data_get(obj);
1790    if (!wd) return NULL;
1791    if (!item->states) return NULL;
1792
1793    next_state = eina_list_next(item->current_state);
1794    if (!next_state)
1795      next_state = eina_list_next(item->states);
1796    return eina_list_data_get(next_state);
1797 }
1798
1799 EAPI Elm_Toolbar_Item_State *
1800 elm_toolbar_item_state_prev(Elm_Object_Item *it)
1801 {
1802    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1803
1804    Widget_Data *wd;
1805    Evas_Object *obj;
1806    Eina_List *prev_state;
1807    Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
1808
1809    obj = WIDGET(item);
1810    wd = elm_widget_data_get(obj);
1811    if (!wd) return NULL;
1812    if (!item->states) return NULL;
1813
1814    prev_state = eina_list_prev(item->current_state);
1815    if ((!prev_state) || (prev_state == item->states))
1816      prev_state = eina_list_last(item->states);
1817    return eina_list_data_get(prev_state);
1818 }
1819
1820 EAPI void
1821 elm_toolbar_item_tooltip_text_set(Elm_Object_Item *it, const char *text)
1822 {
1823    elm_object_item_tooltip_text_set(it, text);
1824 }
1825
1826 EAPI void
1827 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)
1828 {
1829    elm_object_item_tooltip_content_cb_set(it, func, data, del_cb);
1830 }
1831
1832 EAPI void
1833 elm_toolbar_item_tooltip_unset(Elm_Object_Item *it)
1834 {
1835    elm_object_item_tooltip_unset(it);
1836 }
1837
1838 EAPI void
1839 elm_toolbar_item_tooltip_style_set(Elm_Object_Item *it, const char *style)
1840 {
1841    elm_object_item_tooltip_style_set(it, style);
1842 }
1843
1844 EAPI const char *
1845 elm_toolbar_item_tooltip_style_get(const Elm_Object_Item *it)
1846 {
1847    return elm_object_item_tooltip_style_get(it);
1848 }
1849
1850 EAPI void
1851 elm_toolbar_item_cursor_set(Elm_Object_Item *it, const char *cursor)
1852 {
1853    elm_object_item_cursor_set(it, cursor);
1854 }
1855
1856 EAPI const char *
1857 elm_toolbar_item_cursor_get(const Elm_Object_Item *it)
1858 {
1859    return elm_object_item_cursor_get(it);
1860 }
1861
1862 EAPI void
1863 elm_toolbar_item_cursor_unset(Elm_Object_Item *it)
1864 {
1865    elm_object_item_cursor_unset(it);
1866 }
1867
1868 EAPI void
1869 elm_toolbar_item_cursor_style_set(Elm_Object_Item *it, const char *style)
1870 {
1871    elm_object_item_cursor_style_set(it, style);
1872 }
1873
1874 EAPI const char *
1875 elm_toolbar_item_cursor_style_get(const Elm_Object_Item *it)
1876 {
1877    return elm_object_item_cursor_style_get(it);
1878 }
1879
1880 EAPI void
1881 elm_toolbar_item_cursor_engine_only_set(Elm_Object_Item *it, Eina_Bool engine_only)
1882 {
1883    elm_object_item_cursor_engine_only_set(it, engine_only);
1884 }
1885
1886 EAPI Eina_Bool
1887 elm_toolbar_item_cursor_engine_only_get(const Elm_Object_Item *it)
1888 {
1889    return elm_object_item_cursor_engine_only_get(it);
1890 }
1891
1892 EAPI void
1893 elm_toolbar_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
1894 {
1895    ELM_CHECK_WIDTYPE(obj, widtype);
1896    Widget_Data *wd = elm_widget_data_get(obj);
1897    if (!wd) return;
1898    if (always_select && (!wd->always_select) && wd->items)
1899      _item_select(ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items));
1900    wd->always_select = always_select;
1901 }
1902
1903 EAPI Eina_Bool
1904 elm_toolbar_always_select_mode_get(const Evas_Object *obj)
1905 {
1906    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1907    Widget_Data *wd = elm_widget_data_get(obj);
1908    if (!wd) return EINA_FALSE;
1909    return wd->always_select;
1910 }
1911
1912 EAPI void
1913 elm_toolbar_no_select_mode_set(Evas_Object *obj, Eina_Bool no_select)
1914 {
1915    ELM_CHECK_WIDTYPE(obj, widtype);
1916    Widget_Data *wd = elm_widget_data_get(obj);
1917    if (!wd) return;
1918    wd->no_select = no_select;
1919 }
1920
1921 EAPI Eina_Bool
1922 elm_toolbar_no_select_mode_get(const Evas_Object *obj)
1923 {
1924    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1925    Widget_Data *wd = elm_widget_data_get(obj);
1926    if (!wd) return EINA_FALSE;
1927    return wd->no_select;
1928 }
1929
1930 EAPI void
1931 elm_toolbar_icon_order_lookup_set(Evas_Object *obj, Elm_Icon_Lookup_Order order)
1932 {
1933    ELM_CHECK_WIDTYPE(obj, widtype);
1934    Elm_Toolbar_Item *it;
1935    Widget_Data *wd = elm_widget_data_get(obj);
1936    if (!wd) return;
1937
1938    wd->lookup_order = order;
1939    EINA_INLIST_FOREACH(wd->items, it)
1940       elm_icon_order_lookup_set(it->icon, order);
1941    if (wd->more_item)
1942      elm_icon_order_lookup_set(wd->more_item->icon, order);
1943 }
1944
1945 EAPI Elm_Icon_Lookup_Order
1946 elm_toolbar_icon_order_lookup_get(const Evas_Object *obj)
1947 {
1948    ELM_CHECK_WIDTYPE(obj, widtype) ELM_ICON_LOOKUP_THEME_FDO;
1949    Widget_Data *wd = elm_widget_data_get(obj);
1950    if (!wd) return ELM_ICON_LOOKUP_THEME_FDO;
1951    return wd->lookup_order;
1952 }
1953
1954 EINA_DEPRECATED EAPI void
1955 elm_toolbar_orientation_set(Evas_Object *obj, Eina_Bool vertical)
1956 {
1957    elm_toolbar_horizontal_set(obj, !vertical);
1958 }
1959
1960 EINA_DEPRECATED EAPI Eina_Bool
1961 elm_toolbar_orientation_get(const Evas_Object *obj)
1962 {
1963    return !elm_toolbar_horizontal_get(obj);
1964 }
1965
1966 EAPI void
1967 elm_toolbar_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
1968 {
1969    ELM_CHECK_WIDTYPE(obj, widtype);
1970    Widget_Data *wd = elm_widget_data_get(obj);
1971    if (!wd) return;
1972    wd->vertical = !horizontal;
1973    if (wd->vertical)
1974      evas_object_size_hint_align_set(wd->bx, 0.5, wd->align);
1975    else
1976      evas_object_size_hint_align_set(wd->bx, wd->align, 0.5);
1977    _sizing_eval(obj);
1978 }
1979
1980 EAPI Eina_Bool
1981 elm_toolbar_horizontal_get(const Evas_Object *obj)
1982 {
1983    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1984    Widget_Data *wd = elm_widget_data_get(obj);
1985    if (!wd) return EINA_FALSE;
1986    return !wd->vertical;
1987 }
1988
1989 EAPI unsigned int
1990 elm_toolbar_items_count(const Evas_Object *obj)
1991 {
1992    ELM_CHECK_WIDTYPE(obj, widtype) 0;
1993    Widget_Data *wd = elm_widget_data_get(obj);
1994    if (!wd) return 0;
1995    return wd->item_count;
1996 }
1997
1998 EINA_DEPRECATED EAPI void
1999 elm_toolbar_mode_shrink_set(Evas_Object *obj, Elm_Toolbar_Shrink_Mode shrink_mode)
2000 {
2001    elm_toolbar_shrink_mode_set(obj, shrink_mode);
2002 }
2003
2004 EINA_DEPRECATED EAPI Elm_Toolbar_Shrink_Mode
2005 elm_toolbar_mode_shrink_get(const Evas_Object *obj)
2006 {
2007    return elm_toolbar_shrink_mode_get(obj);
2008 }