summaryrefslogtreecommitdiff
path: root/src/lib/elm_menu.c
blob: dcced6445461d4241976470c284d29bc0c2308cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
#include <Elementary.h>
#include "elm_priv.h"

/**
 * @defgroup Menu Menu
 *
 * A menu is a list of items displayed above the window. Each item can
 * have a sub-menu. The menu object can be used to display a menu on right
 * click, in a toolbar, anywhere.
 *
 * Signals that you can add callbacks for are:
 *
 * "clicked" - the user clicked the empty space in the menu to dismiss.
 *             event_info is NULL.
 */

typedef struct _Widget_Data Widget_Data;

struct _Elm_Menu_Item
{
   Elm_Widget_Item base;
   Elm_Menu_Item *parent;
   Evas_Object *content;
   const char *icon_str;
   const char *label;
   Evas_Smart_Cb func;
   unsigned int idx;

   struct {
      Evas_Object *hv, *bx, *location;
      Eina_List *items;
      Eina_Bool open : 1;
   } submenu;

   Eina_Bool separator : 1;
   Eina_Bool disabled : 1;
   Eina_Bool selected : 1;
   Eina_Bool object_item : 1;
};

struct _Widget_Data
{
   Evas_Object *hv, *bx, *location, *parent, *obj;
   Eina_List *items;
   Evas_Coord xloc, yloc;
};

static const char *widtype = NULL;
static void _del_hook(Evas_Object *obj);
static void _theme_hook(Evas_Object *obj);
static void _sizing_eval(Evas_Object *obj);
static void _submenu_sizing_eval(Elm_Menu_Item *parent);
static void _item_sizing_eval(Elm_Menu_Item *item);
static void _submenu_hide(Elm_Menu_Item *item);
static void _submenu_open(void *data, Evas_Object *obj, const char *emission, const char *source);
static void _parent_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _menu_hide(void *data, Evas_Object *obj, void *event_info);

static const char SIG_CLICKED[] = "clicked";

static const Evas_Smart_Cb_Description _signals[] = {
   {SIG_CLICKED, ""},
   {NULL, NULL}
};


static void
_del_item(Elm_Menu_Item *item)
{
   Elm_Menu_Item *child;

   elm_widget_item_pre_notify_del(item);

   EINA_LIST_FREE(item->submenu.items, child)
     _del_item(child);

   if (item->label) eina_stringshare_del(item->label);
   if (item->submenu.hv) evas_object_del(item->submenu.hv);
   if (item->submenu.location) evas_object_del(item->submenu.location);
   if (item->icon_str) eina_stringshare_del(item->icon_str);
   elm_widget_item_del(item);
}

static void
_del_pre_hook(Evas_Object *obj)
{
   Elm_Menu_Item *item;
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return;

   evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_RESIZE, _parent_resize, obj);
   evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_DEL, _parent_del, wd);

   EINA_LIST_FREE(wd->items, item)
      _del_item(item);

   if (wd->hv) evas_object_del(wd->hv);
   if (wd->location) evas_object_del(wd->location);
}

static void
_del_hook(Evas_Object *obj)
{
   Widget_Data *wd = elm_widget_data_get(obj);
   free(wd);
}

static void
_theme_hook(Evas_Object *obj)
{
   Eina_List *l, *_l, *_ll, *ll = NULL;
   Elm_Menu_Item *item;
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return;
   _elm_widget_mirrored_reload(obj);
   ll = eina_list_append(ll, wd->items);
   EINA_LIST_FOREACH(ll, _ll, l)
     {
        EINA_LIST_FOREACH(l, _l, item)
          {
             edje_object_mirrored_set(item->base.view, elm_widget_mirrored_get(obj));
             ll = eina_list_append(ll, item->submenu.items);
             if (item->separator)
               _elm_theme_object_set(obj, item->base.view, "menu", "separator",
                                     elm_widget_style_get(obj));
             else if (item->submenu.bx)
               {
                  _elm_theme_object_set
                     (obj, item->base.view, "menu", "item_with_submenu",
                      elm_widget_style_get(obj));
                  elm_menu_item_label_set(item, item->label);
                  elm_menu_item_object_icon_name_set(item, item->icon_str);
               }
             else
               {
                  _elm_theme_object_set(obj, item->base.view, "menu", "item",
                                        elm_widget_style_get(obj));
                  elm_menu_item_label_set(item, item->label);
                  elm_menu_item_object_icon_name_set(item, item->icon_str);
               }
             if (item->disabled)
               edje_object_signal_emit
                  (item->base.view, "elm,state,disabled", "elm");
             else
               edje_object_signal_emit
                  (item->base.view, "elm,state,enabled", "elm");
             edje_object_message_signal_process(item->base.view);
             edje_object_scale_set(item->base.view, elm_widget_scale_get(obj) *
                                   _elm_config->scale);
          }
     }
   _sizing_eval(obj);
}

static void
_sizing_eval(Evas_Object *obj)
{
   Eina_List *l;
   Elm_Menu_Item *item;
   Evas_Coord x_p, y_p, w_p, h_p, x2, y2, w2, h2, bx, by, bw, bh;
   Widget_Data *wd = elm_widget_data_get(obj);
   if ((!wd) || (!wd->parent)) return;
   EINA_LIST_FOREACH(wd->items,l,item) _item_sizing_eval(item);
   evas_object_geometry_get(wd->location, &x_p, &y_p, &w_p, &h_p);
   evas_object_geometry_get(wd->parent, &x2, &y2, &w2, &h2);
   evas_object_geometry_get(wd->bx, &bx, &by, &bw, &bh);

   x_p = wd->xloc;
   y_p = wd->yloc;

   if (elm_widget_mirrored_get(obj))
     x_p -= w_p;

   if (x_p+bw > x2+w2) x_p -= x_p+bw - (x2+w2);
   if (x_p < x2) x_p += x2 - x_p;

   if (y_p+h_p+bh > y2+h2) y_p -= y_p+h_p+bh - (y2+h2);
   if (y_p < y2) y_p += y2 - y_p;


   evas_object_move(wd->location, x_p, y_p);
   evas_object_resize(wd->location, bw, h_p);
   evas_object_size_hint_min_set(wd->location, bw, h_p);
   evas_object_size_hint_max_set(wd->location, bw, h_p);
   elm_hover_target_set(wd->hv, wd->location);

   EINA_LIST_FOREACH(wd->items,l,item)
     {
        if (item->submenu.open) _submenu_sizing_eval(item);
     }
}

static void
_submenu_sizing_eval(Elm_Menu_Item *parent)
{
   Eina_List *l;
   Elm_Menu_Item *item;
   Evas_Coord x_p, y_p, w_p, h_p, x2, y2, w2, h2, bx, by, bw, bh, px, py, pw, ph;
   Widget_Data *wd = elm_widget_data_get(parent->base.widget);
   if (!wd) return;
   EINA_LIST_FOREACH(parent->submenu.items, l, item) _item_sizing_eval(item);
   evas_object_geometry_get(parent->submenu.location, &x_p, &y_p, &w_p, &h_p);
   evas_object_geometry_get(parent->base.view, &x2, &y2, &w2, &h2);
   evas_object_geometry_get(parent->submenu.bx, &bx, &by, &bw, &bh);
   evas_object_geometry_get(wd->parent, &px, &py, &pw, &ph);

   x_p = x2+w2;
   y_p = y2;

   /* If it overflows on the right, adjust the x */
   if ((x_p + bw > px + pw) || elm_widget_mirrored_get(parent->base.widget))
     x_p = x2-bw;

   /* If it overflows on the left, adjust the x - usually only happens
    * with an RTL interface */
   if (x_p < px)
     x_p = x2 + w2;

   /* If after all the adjustments it still overflows, fix it */
   if (x_p + bw > px + pw)
     x_p = x2-bw;

   if (y_p+bh > py+ph)
     y_p -= y_p+bh - (py+ph);
   if (y_p < py)
     y_p += y_p - y_p;

   evas_object_move(parent->submenu.location, x_p, y_p);
   evas_object_resize(parent->submenu.location, bw, h_p);
   evas_object_size_hint_min_set(parent->submenu.location, bw, h_p);
   evas_object_size_hint_max_set(parent->submenu.location, bw, h_p);
   elm_hover_target_set(parent->submenu.hv, parent->submenu.location);

   EINA_LIST_FOREACH(parent->submenu.items, l, item)
     {
        if (item->submenu.open)
          _submenu_sizing_eval(item);
     }
}

static void
_item_sizing_eval(Elm_Menu_Item *item)
{
   Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
   if (!item->separator)
     elm_coords_finger_size_adjust(1, &minw, 1, &minh);
   edje_object_size_min_restricted_calc(item->base.view, &minw, &minh, minw, minh);
   if (!item->separator)
     elm_coords_finger_size_adjust(1, &minw, 1, &minh);
   evas_object_size_hint_min_set(item->base.view, minw, minh);
   evas_object_size_hint_max_set(item->base.view, maxw, maxh);
}

static void
_menu_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
   _sizing_eval(data);
}

static void
_parent_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
   _sizing_eval(data);
}

static void
_parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
{
   Widget_Data *wd = data;
   evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE, _parent_resize, wd->obj);
   wd->parent = NULL;
}

static void
_item_move_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
   Elm_Menu_Item *item = data;
   if (item->submenu.open) _submenu_sizing_eval(item);
}

static void
_hover_clicked_cb(void *data, Evas_Object *obj, void *event_info)
{
   _menu_hide(data, obj, event_info);
   evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
}

static void
_menu_hide(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
   Eina_List *l;
   Elm_Menu_Item *item2;
   Widget_Data *wd = elm_widget_data_get(data);
   if (!wd) return;
   evas_object_hide(wd->hv);
   evas_object_hide(data);

   EINA_LIST_FOREACH(wd->items, l, item2)
     {
        if (item2->submenu.open) _submenu_hide(item2);
     }
}

static void
_submenu_hide(Elm_Menu_Item *item)
{
   Eina_List *l;
   Elm_Menu_Item *item2;
   evas_object_hide(item->submenu.hv);
   item->submenu.open = EINA_FALSE;
   EINA_LIST_FOREACH(item->submenu.items, l, item2)
     {
        if (item2->submenu.open) _submenu_hide(item2);
     }
}

static void
_menu_item_select(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
{
   Elm_Menu_Item *item = data;
   if (item->submenu.items)
     {
        if (!item->submenu.open) _submenu_open(item, NULL, NULL, NULL);
        else _submenu_hide(item);
     }
   else
     _menu_hide(item->base.widget, NULL, NULL);

   if (item->func) item->func((void *)(item->base.data), item->base.widget, item);
}

static void
_menu_item_activate(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
{
   Eina_List *l;
   Elm_Menu_Item *item2;
   Elm_Menu_Item *item = data;
   item->selected = 1;
   if (item->parent)
     {
        EINA_LIST_FOREACH(item->parent->submenu.items, l, item2)
          {
             if (item2 != item) elm_menu_item_selected_set(item2, 0);
          }
     }
   else
     {
        Widget_Data *wd = elm_widget_data_get(item->base.widget);
        EINA_LIST_FOREACH(wd->items, l, item2)
          {
             if (item2 != item) elm_menu_item_selected_set(item2, 0);
          }
     }
}

static void
_menu_item_inactivate(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
{
   Elm_Menu_Item *item = data;
   item->selected = 0;
   if (item->submenu.open) _submenu_hide(item);
}

static void
_submenu_open(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
{
   Elm_Menu_Item *item = data;
   item->submenu.open = EINA_TRUE;
   evas_object_show(item->submenu.hv);
   _sizing_eval(item->base.widget);
}

static void
_show(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
   Widget_Data *wd = elm_widget_data_get(data);
   if (!wd) return;
   evas_object_show(wd->hv);
}

static void
_item_obj_create(Elm_Menu_Item *item)
{
   Widget_Data *wd = elm_widget_data_get(item->base.widget);
   if (!wd) return;
   item->base.view = edje_object_add(evas_object_evas_get(wd->bx));
   edje_object_mirrored_set(item->base.view, elm_widget_mirrored_get(item->base.widget));
   evas_object_size_hint_weight_set(item->base.view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_size_hint_fill_set(item->base.view, EVAS_HINT_FILL, EVAS_HINT_FILL);
   _elm_theme_object_set(item->base.widget, item->base.view, "menu", "item",  elm_widget_style_get(item->base.widget));
   edje_object_signal_callback_add(item->base.view, "elm,action,click", "",
                                   _menu_item_select, item);
   edje_object_signal_callback_add(item->base.view, "elm,action,activate", "",
                                   _menu_item_activate, item);
   edje_object_signal_callback_add(item->base.view, "elm,action,inactivate", "",
                                   _menu_item_inactivate, item);
   evas_object_show(item->base.view);
}

static void
_item_separator_obj_create(Elm_Menu_Item *item)
{
   Widget_Data *wd = elm_widget_data_get(item->base.widget);
   if (!wd) return;
   item->base.view = edje_object_add(evas_object_evas_get(wd->bx));
   evas_object_size_hint_weight_set(item->base.view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_size_hint_fill_set(item->base.view, EVAS_HINT_FILL, EVAS_HINT_FILL);
   _elm_theme_object_set(item->base.widget, item->base.view, "menu", "separator",  elm_widget_style_get(item->base.widget));
   edje_object_signal_callback_add(item->base.view, "elm,action,activate", "",
                                   _menu_item_activate, item);
   evas_object_show(item->base.view);
}

static void
_item_submenu_obj_create(Elm_Menu_Item *item)
{
   Widget_Data *wd = elm_widget_data_get(item->base.widget);
   if (!wd) return;
   item->submenu.location = elm_icon_add(wd->bx);
   item->submenu.hv = elm_hover_add(wd->bx);
   elm_widget_mirrored_set(item->submenu.hv, EINA_FALSE);
   elm_hover_target_set(item->submenu.hv, item->submenu.location);
   elm_hover_parent_set(item->submenu.hv, wd->parent);
   elm_object_style_set(item->submenu.hv, "submenu");

   item->submenu.bx = elm_box_add(wd->bx);
   elm_widget_mirrored_set(item->submenu.bx, EINA_FALSE);
   evas_object_size_hint_weight_set(item->submenu.bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_show(item->submenu.bx);
   elm_hover_content_set(item->submenu.hv, elm_hover_best_content_location_get(item->submenu.hv, ELM_HOVER_AXIS_VERTICAL), item->submenu.bx);

   edje_object_mirrored_set(item->base.view, elm_widget_mirrored_get(item->base.widget));
   _elm_theme_object_set(item->base.widget, item->base.view, "menu", "item_with_submenu",  elm_widget_style_get(item->base.widget));
   elm_menu_item_label_set(item, item->label);
   if (item->icon_str) elm_menu_item_object_icon_name_set(item, item->icon_str);

   edje_object_signal_callback_add(item->base.view, "elm,action,open", "",
                                   _submenu_open, item);
   evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_MOVE, _item_move_resize, item);
   evas_object_event_callback_add(item->base.view, EVAS_CALLBACK_RESIZE, _item_move_resize, item);

   evas_object_event_callback_add(item->submenu.bx, EVAS_CALLBACK_RESIZE, _menu_resize, item->base.widget);
}

/**
 * Add a new menu to the parent
 *
 * @param parent The parent object.
 * @return The new object or NULL if it cannot be created.
 *
 * @ingroup Menu
 */
EAPI Evas_Object *
elm_menu_add(Evas_Object *parent)
{
   Evas_Object *obj;
   Evas *e;
   Widget_Data *wd;

   ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);

   ELM_SET_WIDTYPE(widtype, "menu");
   elm_widget_type_set(obj, "menu");
   elm_widget_sub_object_add(parent, obj);
   elm_widget_data_set(obj, wd);
   elm_widget_del_pre_hook_set(obj, _del_pre_hook);
   elm_widget_del_hook_set(obj, _del_hook);
   elm_widget_theme_hook_set(obj, _theme_hook);
   elm_widget_can_focus_set(obj, EINA_FALSE);

   wd->location = elm_icon_add(obj);
   wd->parent = parent;
   wd->obj = obj;

   wd->hv = elm_hover_add(obj);
   elm_widget_mirrored_set(wd->hv, EINA_FALSE);
   elm_hover_parent_set(wd->hv, parent);
   elm_hover_target_set(wd->hv, wd->location);
   elm_object_style_set(wd->hv, "menu");
   evas_object_smart_callback_add(wd->hv, "clicked", _hover_clicked_cb, obj);

   wd->bx = elm_box_add(obj);
   elm_widget_mirrored_set(wd->bx, EINA_FALSE);
   evas_object_size_hint_weight_set(wd->bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_show(wd->bx);
   elm_hover_content_set(wd->hv, elm_hover_best_content_location_get(wd->hv, ELM_HOVER_AXIS_VERTICAL), wd->bx);

   evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_RESIZE, _parent_resize, wd->obj);
   evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_DEL, _parent_del, wd);

   evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _show, obj);

   evas_object_event_callback_add(wd->bx, EVAS_CALLBACK_RESIZE, _menu_resize, obj);

   evas_object_smart_callbacks_descriptions_set(obj, _signals);

   _sizing_eval(obj);
   return obj;
}

/**
 * Set the parent
 *
 * @param obj The menu object.
 * @param parent The new parent.
 *
 * @ingroup Menu
 */
EAPI void
elm_menu_parent_set(Evas_Object *obj, Evas_Object *parent)
{
   Eina_List *l, *_l, *_ll, *ll = NULL;
   Elm_Menu_Item *item;
   ELM_CHECK_WIDTYPE(obj, widtype);
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return;

   if (wd->parent == parent) return;
   if (wd->parent)
     {
        evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_RESIZE, _parent_resize, wd->obj);
        evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_DEL, _parent_del, wd);
     }
   wd->parent = parent;
   if (wd->parent)
     {
        evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_RESIZE, _parent_resize, wd->obj);
        evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_DEL, _parent_del, wd);
     }
   elm_hover_parent_set(wd->hv, parent);

   ll = eina_list_append(ll, wd->items);
   EINA_LIST_FOREACH(ll, _ll, l)
     {
        EINA_LIST_FOREACH(l, _l, item)
          {
             if (item->submenu.hv)
               {
                  elm_hover_parent_set(item->submenu.hv, parent);
                  ll = eina_list_append(ll, item->submenu.items);
               }
          }
     }
   _sizing_eval(obj);
}

/**
 * Get the parent
 *
 * @param obj The menu object.
 * @return The parent.
 *
 * @ingroup Menu
 */
EAPI Evas_Object *
elm_menu_parent_get(const Evas_Object *obj)
{
   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return NULL;
   return wd->parent;
}

/**
 * Move the menu to a new position
 *
 * @param obj The menu object.
 * @param x The new position.
 * @param y The new position.
 *
 * @ingroup Menu
 */
EAPI void
elm_menu_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
{
   ELM_CHECK_WIDTYPE(obj, widtype);
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return;
   wd->xloc = x;
   wd->yloc = y;
   _sizing_eval(obj);
}

/**
 * Close a opened menu
 *
 * @param obj the menu object
 * @return void
 *
 * @ingroup Menu
 */
EAPI void
elm_menu_close(Evas_Object *obj)
{
   ELM_CHECK_WIDTYPE(obj, widtype);
   Widget_Data *wd = elm_widget_data_get(obj);
   _menu_hide(obj, wd->hv, NULL);
}

/**
 * Get the Evas_Object of an Elm_Menu_Item
 *
 * @param item The menu item object.
 * @return The edje object containing the swallowed content
 *
 * @ingroup Menu
 */
EAPI Evas_Object *
elm_menu_item_object_get(const Elm_Menu_Item *item)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
   return item->base.view;
}

static void
_item_clone(Evas_Object *obj, Elm_Menu_Item *parent, Elm_Menu_Item *item)
{
   Elm_Menu_Item *new_item, *subitem;
   Eina_List *iter;

   if (item->separator)
     new_item = elm_menu_item_separator_add(obj, parent);
   else
     new_item = elm_menu_item_add(obj, parent, item->icon_str, item->label, item->func, item->base.data);
   elm_menu_item_disabled_set(new_item, item->disabled);

   EINA_LIST_FOREACH(item->submenu.items, iter, subitem)
      _item_clone(obj, new_item, subitem);
}

void
elm_menu_clone(Evas_Object *from_menu, Evas_Object *to_menu, Elm_Menu_Item *parent)
{
   ELM_CHECK_WIDTYPE(from_menu, widtype);
   ELM_CHECK_WIDTYPE(to_menu, widtype);
   Widget_Data *from_wd = elm_widget_data_get(from_menu);
   Eina_List *iter;
   Elm_Menu_Item *item;

   if (!from_wd) return;
   EINA_LIST_FOREACH(from_wd->items, iter, item)
      _item_clone(to_menu, parent, item);
}

static void
_elm_menu_item_add_helper(Evas_Object *obj, Elm_Menu_Item *parent, Elm_Menu_Item *subitem, Widget_Data *wd)
{
   if (parent)
     {
        if (!parent->submenu.bx) _item_submenu_obj_create(parent);
        elm_box_pack_end(parent->submenu.bx, subitem->base.view);
        parent->submenu.items = eina_list_append(parent->submenu.items, subitem);
        subitem->idx = eina_list_count(parent->submenu.items) - 1;
     }
   else
     {
        elm_box_pack_end(wd->bx, subitem->base.view);
        wd->items = eina_list_append(wd->items, subitem);
        subitem->idx = eina_list_count(wd->items) - 1;
     }

   _sizing_eval(obj);
}

/**
 * Add an item at the end
 *
 * @param obj The menu object.
 * @param parent The parent menu item (optional)
 * @param icon A icon display on the item. The icon will be destryed by the menu.
 * @param label The label of the item.
 * @param func Function called when the user select the item.
 * @param data Data sent by the callback.
 * @return Returns the new item.
 *
 * @ingroup Menu
 */
EAPI Elm_Menu_Item *
elm_menu_item_add(Evas_Object *obj, Elm_Menu_Item *parent, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
{
   Elm_Menu_Item *subitem;
   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
   Widget_Data *wd = elm_widget_data_get(obj);
   Evas_Object *icon_obj;

   if (!wd) return NULL;
   icon_obj = elm_icon_add(obj);
   if (!icon_obj) return NULL;
   subitem = elm_widget_item_new(obj, Elm_Menu_Item);
   if (!subitem)
     {
        evas_object_del(icon_obj);
        return NULL;
     }
   subitem->base.data = data;
   subitem->func = func;
   subitem->parent = parent;
   subitem->content = icon_obj;

   _item_obj_create(subitem);
   elm_menu_item_label_set(subitem, label);

   elm_widget_sub_object_add(subitem->base.widget, subitem->content);
   edje_object_part_swallow(subitem->base.view, "elm.swallow.content", subitem->content);
   if (icon) elm_menu_item_object_icon_name_set(subitem, icon);

   _elm_menu_item_add_helper(obj, parent, subitem, wd);

   return subitem;
}

/**
 * Add an object swallowed in an item at the end
 *
 * @param obj The menu object.
 * @param parent The parent menu item (optional)
 * @param subobj The object to swallow
 * @param func Function called when the user select the item.
 * @param data Data sent by the callback.
 * @return Returns the new item.
 *
 * @ingroup Menu
 */
EAPI Elm_Menu_Item *
elm_menu_item_add_object(Evas_Object *obj, Elm_Menu_Item *parent, Evas_Object *subobj, Evas_Smart_Cb func, const void *data)
{
   Elm_Menu_Item *subitem;
   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
   Widget_Data *wd = elm_widget_data_get(obj);

   if (!wd) return NULL;
   subitem = elm_widget_item_new(obj, Elm_Menu_Item);
   if (!subitem) return NULL;

   subitem->base.data = data;
   subitem->func = func;
   subitem->parent = parent;
   subitem->object_item = EINA_TRUE;
   subitem->content = subobj;

   _item_obj_create(subitem);

   elm_widget_sub_object_add(subitem->base.widget, subitem->content);
   edje_object_part_swallow(subitem->base.view, "elm.swallow.content", subobj);
   _sizing_eval(subitem->base.widget);

   _elm_menu_item_add_helper(obj, parent, subitem, wd);

   return subitem;
}

/**
 * Get the position of a menu item
 *
 * This function returns the index position of a menu item in a menu.
 * For a sub-menu, this number is relative to the first item in the sub-menu.
 * @param item The menu item
 * @return The item's index
 * @note Index values begin with 0
 * @ingroup Menu
 */
EAPI unsigned int
elm_menu_item_index_get(const Elm_Menu_Item *item)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, 0);
   return item->idx;
}

/**
 * Set the label of a menu item
 *
 * @param item The menu item object.
 * @param label The label to set for @p item
 *
 * @ingroup Menu
 */
EAPI void
elm_menu_item_label_set(Elm_Menu_Item *item, const char *label)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
   eina_stringshare_replace(&item->label, label);

   if (label)
     edje_object_signal_emit(item->base.view, "elm,state,text,visible", "elm");
   else
     edje_object_signal_emit(item->base.view, "elm,state,text,hidden", "elm");

   edje_object_message_signal_process(item->base.view);
   edje_object_part_text_set(item->base.view, "elm.text", label);
   _sizing_eval(item->base.widget);
}

/**
 * Get the label of a menu item
 *
 * @param item The menu item object.
 * @return The label of @p item
 *
 * @ingroup Menu
 */
EAPI const char *
elm_menu_item_label_get(const Elm_Menu_Item *item)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
   return item->label;
}

/**
 * Set the content of a menu item to an icon
 *
 * Once this content object is set, any previously set object will be deleted.
 *
 * @param item The menu item object.
 * @param icon The icon object to set for the content of @p item
 *
 * @ingroup Menu
 */
EAPI void
elm_menu_item_object_icon_name_set(Elm_Menu_Item *item, const char *icon)
{
   char icon_tmp[512];
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
   EINA_SAFETY_ON_NULL_RETURN(icon);
   if (!*icon) return;
   if ((item->icon_str) && (!strcmp(item->icon_str, icon))) return;
   if ((snprintf(icon_tmp, sizeof(icon_tmp), "menu/%s", icon) > 0) &&
       (elm_icon_standard_set(item->content, icon_tmp)))
     {
        eina_stringshare_replace(&item->icon_str, icon);
        edje_object_signal_emit(item->base.view, "elm,state,icon,visible", "elm");
     }
   else
     edje_object_signal_emit(item->base.view, "elm,state,icon,hidden", "elm");
   edje_object_message_signal_process(item->base.view);
   _sizing_eval(item->base.widget);
}

EAPI void
elm_menu_item_icon_set(Elm_Menu_Item *item, const char *icon)
{
   elm_menu_item_object_icon_name_set(item, icon);
}

/**
 * Set the disabled state of @p item.
 *
 * @param item The menu item object.
 * @param disabled The enabled/disabled state of the item
 *
 * @ingroup Menu
 */
EAPI void
elm_menu_item_disabled_set(Elm_Menu_Item *item, Eina_Bool disabled)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
   if (disabled == item->disabled) return;
   item->disabled = !!disabled;
   if (disabled)
     {
        edje_object_signal_emit(item->base.view, "elm,state,disabled", "elm");
        if (item->submenu.open) _submenu_hide(item);
     }
   else
     edje_object_signal_emit(item->base.view, "elm,state,enabled", "elm");
   edje_object_message_signal_process(item->base.view);
}

/**
 * Get the disabled state of @p item.
 *
 * @param item The menu item object.
 * @return The enabled/disabled state of the item
 *
 * @ingroup Menu
 */
EAPI Eina_Bool
elm_menu_item_disabled_get(const Elm_Menu_Item *item)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
   return item->disabled;
}

/**
 * Add a separator item to menu @p obj under @p parent.
 *
 * @param obj The menu object
 * @param parent The item to add the separator under
 *
 * @return The created item or NULL on failure
 *
 * @ingroup Menu
 */
EAPI Elm_Menu_Item *
elm_menu_item_separator_add(Evas_Object *obj, Elm_Menu_Item *parent)
{
   Elm_Menu_Item *subitem;
   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return NULL;
   /* don't add a separator as the first item */
   if (!wd->items) return NULL;
   /* don't allow adding more than one separator in a row */
   if (parent) subitem = eina_list_last(parent->submenu.items)->data;
   else subitem = eina_list_last(wd->items)->data;
   if (subitem->separator) return NULL;

   subitem = elm_widget_item_new(obj, Elm_Menu_Item);
   if (!subitem) return NULL;
   subitem->base.widget = obj;
   subitem->separator = 1;
   _item_separator_obj_create(subitem);
   if (!parent)
     {
        elm_box_pack_end(wd->bx, subitem->base.view);
        wd->items = eina_list_append(wd->items, subitem);
     }
   else
     {
        if (!parent->submenu.bx) _item_submenu_obj_create(parent);
        elm_box_pack_end(parent->submenu.bx, subitem->base.view);
        parent->submenu.items = eina_list_append(parent->submenu.items, subitem);
     }
   _sizing_eval(obj);
   return subitem;
}

/**
 * Set the content object of a menu item
 *
 * Use this function to change the object swallowed by a menu item,
 * deleting any previously swallowed object.
 * @param item The menu item object
 * @param The content object or NULL
 * @return EINA_TRUE on success, else EINA_FALSE
 *
 * @ingroup Menu
 */
EAPI Eina_Bool
elm_menu_item_object_content_set(Elm_Menu_Item *item, Evas_Object *obj)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
   if (item->content)
     {
        elm_widget_sub_object_del(item->base.widget, item->content);
        evas_object_del(item->content);
     }
     
   item->content = obj;

   elm_widget_sub_object_add(item->base.widget, item->content);
   edje_object_part_swallow(item->base.view, "elm.swallow.content", item->content);
   _sizing_eval(item->base.widget);
   return EINA_TRUE;
}

/**
 * Get the content object of a menu item
 *
 * @param item The menu item object
 * @return The content object or NULL
 * @note If @p item was added with elm_menu_item_add_object, this
 * function will return the object passed, else it will return the
 * icon object.
 *
 * @ingroup Menu
 */
EAPI Evas_Object *
elm_menu_item_object_content_get(const Elm_Menu_Item *item)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
   return item->content;
}

EAPI Evas_Object *
elm_menu_item_object_icon_get(const Elm_Menu_Item *item)
{
   return elm_menu_item_object_content_get(item);
}

/**
 * Get the string representation from the icon of a menu item
 *
 * @param item The menu item object.
 * @return The string representation of @p item's icon or NULL
 *
 * @ingroup Menu
 */
EAPI const char *
elm_menu_item_object_icon_name_get(const Elm_Menu_Item *item)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
   return item->icon_str;
}

EAPI const char *
elm_menu_item_icon_get(const Elm_Menu_Item *item)
{
   return elm_menu_item_object_icon_name_get(item);
}

/**
 * Returns whether @p item is a separator.
 *
 * @param item The item to check
 * @return If true, @p item is a separator
 *
 * @ingroup Menu
 */
EAPI Eina_Bool
elm_menu_item_is_separator(Elm_Menu_Item *item)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
   return item->separator;
}

/**
 * Deletes an item from the menu.
 *
 * @param item The item to delete.
 *
 * @ingroup Menu
 */
EAPI void
elm_menu_item_del(Elm_Menu_Item *item)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
   Elm_Menu_Item *_item;

   elm_widget_item_pre_notify_del(item);

   EINA_LIST_FREE(item->submenu.items, _item) elm_menu_item_del(_item);
   if (item->label) eina_stringshare_del(item->label);
   if (item->content) evas_object_del(item->content);
   if (item->submenu.hv) evas_object_del(item->submenu.hv);
   if (item->submenu.location) evas_object_del(item->submenu.location);

   if (item->parent)
     item->parent->submenu.items = eina_list_remove(item->parent->submenu.items, item);
   else
     {
        Widget_Data *wd = elm_widget_data_get(item->base.widget);
        wd->items = eina_list_remove(wd->items, item);
     }

   elm_widget_item_del(item);
}

/**
 * Set the function called when a menu item is freed.
 *
 * @param item The item to set the callback on
 * @param func The function called
 *
 * @ingroup Menu
 */
EAPI void
elm_menu_item_del_cb_set(Elm_Menu_Item *item, Evas_Smart_Cb func)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
   elm_widget_item_del_cb_set(item, func);
}

/**
 * Returns the data associated with menu item @p item.
 *
 * @param item The item
 * @return The data associated with @p item
 *
 * @ingroup Menu
 */
EAPI void *
elm_menu_item_data_get(const Elm_Menu_Item *item)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
   return elm_widget_item_data_get(item);
}

/**
 * Sets the data to be associated with menu item @p item.
 *
 * @param item The item
 * @param data The data to be associated with @p item
 *
 * @ingroup Menu
 */
EAPI void
elm_menu_item_data_set(Elm_Menu_Item *item, const void *data)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
   elm_widget_item_data_set(item, data);
}

/**
 * Returns a list of @p item's subitems.
 *
 * @param item The item
 * @return An Eina_List* of @p item's subitems
 *
 * @ingroup Menu
 */
EAPI const Eina_List *
elm_menu_item_subitems_get(const Elm_Menu_Item *item)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
   return item->submenu.items;
}

/**
 * Returns a list of @p item's items.
 *
 * @param obj The menu object
 * @return An Eina_List* of @p item's items
 *
 * @ingroup Menu
 */
EAPI const Eina_List *
elm_menu_items_get(const Evas_Object * obj)
{
   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
   Widget_Data *wd = elm_widget_data_get(obj);
   return wd->items;
}

/**
 * Set the selected state of @p item.
 *
 * @param item The menu item object.
 * @param selected The selected/unselected state of the item
 *
 * @ingroup Menu
 */
EAPI void
elm_menu_item_selected_set(Elm_Menu_Item *item, Eina_Bool selected)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
   if (selected == item->selected) return;
   item->selected = selected;
   if (selected)
     {
        edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
        _menu_item_activate(item, NULL, NULL, NULL);
     }
   else
     {
        edje_object_signal_emit(item->base.view, "elm,state,unselected", "elm");
        _menu_item_inactivate(item, NULL, NULL, NULL);
     }
   edje_object_message_signal_process(item->base.view);
}

/**
 * Get the selected state of @p item.
 *
 * @param item The menu item object.
 * @return The selected/unselected state of the item
 *
 * @ingroup Menu
 */
EAPI Eina_Bool
elm_menu_item_selected_get(const Elm_Menu_Item *item)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
   return item->selected;
}

/**
 * Get the previous item in the menu.
 *
 * @param item The menu item object.
 * @return The item before it, or NULL if none
 *
 * @ingroup Menu
 */
EAPI Elm_Menu_Item *
elm_menu_item_prev_get(const Elm_Menu_Item *it)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
   if (it->parent)
     {
        Eina_List *l = eina_list_data_find_list(it->parent->submenu.items, it);
        l = eina_list_prev(l);
        if (!l) return NULL;
        return l->data;
     }
   else
     {
        Widget_Data *wd = elm_widget_data_get(it->base.widget);
        if (!wd | !wd->items) return NULL;
        Eina_List *l = eina_list_data_find_list(wd->items, it);
        l = eina_list_prev(l);
        if (!l) return NULL;
        return l->data;
     }
   return NULL;
}

/**
 * Get the next item in the menu.
 *
 * @param item The menu item object.
 * @return The item after it, or NULL if none
 *
 * @ingroup Menu
 */
EAPI Elm_Menu_Item *
elm_menu_item_next_get(const Elm_Menu_Item *it)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
   if (it->parent)
     {
        Eina_List *l = eina_list_data_find_list(it->parent->submenu.items, it);
        l = eina_list_next(l);
        if (!l) return NULL;
        return l->data;
     }
   else
     {
        Widget_Data *wd = elm_widget_data_get(it->base.widget);
        if (!wd | !wd->items) return NULL;
        Eina_List *l = eina_list_data_find_list(wd->items, it);
        l = eina_list_next(l);
        if (!l) return NULL;
        return l->data;
     }
   return NULL;
}

/**
 * @brief Return a menu item's owner menu
 *
 * Use this function to get the menu object owning an item.
 * @param item The menu item
 * @return The menu object owning @p item, or NULL on failure
 */
EAPI Evas_Object *
elm_menu_item_menu_get(const Elm_Menu_Item *item)
{
   ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
   return item->base.widget;
}

/**
 * Get the first item in the menu
 *
 * @param obj The menu object
 * @return The first item, or NULL if none
 *
 * @ingroup Menu
 */
EAPI Elm_Menu_Item *
elm_menu_first_item_get(const Evas_Object * obj)
{
   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return NULL;
   if (wd->items) return wd->items->data;
   return NULL;
}

/**
 * Get the last item in the menu
 *
 * @param obj The menu object
 * @return The last item, or NULL if none
 *
 * @ingroup Menu
 */
EAPI Elm_Menu_Item *
elm_menu_last_item_get(const Evas_Object * obj)
{
   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return NULL;
   Eina_List *l = eina_list_last(wd->items);
   if (l) return l->data;
   return NULL;
}

/**
 * Get the selected item in the menu
 *
 * @param obj The menu object
 * @return The selected item, or NULL if none
 *
 * @ingroup Menu
 */
EAPI Elm_Menu_Item *
elm_menu_selected_item_get(const Evas_Object * obj)
{
   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return NULL;
   Eina_List *l;
   Elm_Menu_Item *item;
   EINA_LIST_FOREACH(wd->items, l, item)
     {
        if (item->selected) return item;
     }
   return NULL;
}