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