\section{menu\-\_\-example\-\_\-01.\-c}

\begin{DoxyCodeInclude}
\textcolor{comment}{//Compile with:}
\textcolor{comment}{//gcc -g menu\_example\_01.c -o menu\_example\_01 `pkg-config --cflags --libs elementary`}

\textcolor{preprocessor}{#include <Elementary.h>}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_del\_it(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   \textcolor{keyword}{const} Eina\_List *l;
   Elm_Object_Item *menu\_it = elm_menu_first_item_get(data);
   menu\_it = elm_menu_item_next_get(menu\_it);
   l = elm_menu_item_subitems_get(menu\_it);
   elm_object_item_del(eina\_list\_data\_get(l));
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_show(\textcolor{keywordtype}{void} *data, Evas *e, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   Evas\_Event\_Mouse\_Down *ev = event\_info;
   elm_menu_move(data, ev->canvas.x, ev->canvas.y);
   evas\_object\_show(data);
\}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   Evas\_Object *win, *menu, *button, *rect;
   Elm_Object_Item *menu\_it, *menu\_it1;

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"menu"}, \textcolor{stringliteral}{"Menu"});
   elm_win_autodel_set(win, EINA\_TRUE);
   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   rect = evas\_object\_rectangle\_add(evas\_object\_evas\_get(win));
   elm_win_resize_object_add(win, rect);
   evas\_object\_size\_hint\_min\_set(rect, 0, 0);
   evas\_object\_color\_set(rect, 0, 0, 0, 0);
   evas\_object\_show(rect);

   menu = elm_menu_add(win);
   elm_menu_item_add(menu, NULL, NULL, \textcolor{stringliteral}{"first item"}, NULL, NULL);
   menu\_it = elm_menu_item_add(menu, NULL, \textcolor{stringliteral}{"mail-reply-all"}, \textcolor{stringliteral}{"second item"}, NULL, NULL);

   elm_menu_item_add(menu, menu\_it, \textcolor{stringliteral}{"object-rotate-left"}, \textcolor{stringliteral}{"menu 1"}, NULL, NULL);
   button = elm_button_add(win);
   elm\_object\_text\_set(button, \textcolor{stringliteral}{"button - delete items"});
   menu\_it1 = elm_menu_item_add(menu, menu\_it, NULL, NULL, NULL, NULL);
   elm\_object\_item\_content\_set(menu\_it1, button);
   evas\_object\_smart\_callback\_add(button, \textcolor{stringliteral}{"clicked"}, \_del\_it, menu);
   elm_menu_item_separator_add(menu, menu\_it);
   elm_menu_item_add(menu, menu\_it, NULL, \textcolor{stringliteral}{"third item"}, NULL, NULL);
   elm_menu_item_add(menu, menu\_it, NULL, \textcolor{stringliteral}{"fourth item"}, NULL, NULL);
   elm_menu_item_add(menu, menu\_it, \textcolor{stringliteral}{"window-new"}, \textcolor{stringliteral}{"sub menu"}, NULL, NULL);

   menu\_it = elm_menu_item_add(menu, NULL, NULL, \textcolor{stringliteral}{"third item"}, NULL, NULL);
   elm_object_item_disabled_set(menu\_it, EINA\_TRUE);

   evas\_object\_event\_callback\_add(rect, EVAS\_CALLBACK\_MOUSE\_DOWN, \_show, menu);
   evas\_object\_show(menu);

   evas\_object\_resize(win, 250, 350);
   evas\_object\_show(win);

   elm_run();
   elm_shutdown();

   \textcolor{keywordflow}{return} 0;
\}
ELM_MAIN()
\end{DoxyCodeInclude}
 