summaryrefslogtreecommitdiff
path: root/src/examples/elementary/menu_cxx_example_01.cc
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-03-23 12:56:14 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-03-23 13:24:41 -0700
commitc2a1c49ab2042f559b28e840e54feb8494888e0e (patch)
treec6eb110b7c479499854eede9d0c3ab0a80c9a11a /src/examples/elementary/menu_cxx_example_01.cc
parent9340855597e7e465435c69b6278650346688da14 (diff)
elementary: move all legacy files to their expected new location.
Diffstat (limited to 'src/examples/elementary/menu_cxx_example_01.cc')
-rw-r--r--src/examples/elementary/menu_cxx_example_01.cc69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/examples/elementary/menu_cxx_example_01.cc b/src/examples/elementary/menu_cxx_example_01.cc
new file mode 100644
index 0000000000..9aeb35e580
--- /dev/null
+++ b/src/examples/elementary/menu_cxx_example_01.cc
@@ -0,0 +1,69 @@
1#include <Elementary.hh>
2#include <Eina.hh>
3#include <Evas.hh>
4
5EAPI_MAIN int
6elm_main (int argc, char *argv[])
7{
8 efl::eina::eina_init eina_init;
9
10 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
11
12 ::elm::win_standard win;
13 win.title_set("Menu");
14 win.autohide_set(true);
15
16 evas::rectangle rect(efl::eo::parent = win);
17 win.resize_object_add(rect);
18 rect.size_hint_min_set(0, 0);
19 rect.color_set( 0, 0, 0, 0);
20 rect.visible_set(true);
21
22 ::elm::widget_item no_parent(nullptr);
23 ::elm::menu menu(efl::eo::parent = win);
24 menu.item_add(no_parent, nullptr, "first item", nullptr, nullptr);
25 elm::widget_item
26 menu_it = menu.item_add(no_parent, "mail-reply-all", "second item", nullptr, nullptr);
27
28 menu.item_add(menu_it, "object-rotate-left", "menu 1", NULL, NULL);
29 ::elm::button button(efl::eo::parent = win);
30 button.text_set("elm.text", "button - delete items");
31 elm::widget_item menu_it1
32 = menu.item_add(menu_it, nullptr, nullptr, NULL, NULL);
33 menu_it1.part_content_set(nullptr, button);
34
35 auto del_it = std::bind([&] ()
36 {
37 auto list = efl::eo::downcast<elm::menu_item>(menu_it).subitems_get();
38 for(auto& item : list)
39 {
40 elm_object_item_del(item._eo_ptr());
41 }
42 });
43
44 button.callback_clicked_add(del_it);
45 menu.item_separator_add(menu_it);
46 menu.item_add(menu_it, nullptr, "third item", NULL, NULL);
47 menu.item_add(menu_it, nullptr, "fourth item", NULL, NULL);
48 menu.item_add(menu_it, "window-new", "sub menu", NULL, NULL);
49
50 elm::widget_item menu_it2 = menu.item_add(no_parent, nullptr, "third item", nullptr, nullptr);
51 menu_it2.disabled_set(EINA_TRUE);
52
53 auto show = std::bind([&] (void *event_info)
54 {
55 Evas_Event_Mouse_Down *ev = static_cast<Evas_Event_Mouse_Down*>(event_info);
56 menu.move(ev->canvas.x, ev->canvas.y);
57 menu.visible_set(true);
58 }, std::placeholders::_3);
59
60 rect.callback_mouse_down_add( show );
61 menu.visible_set(true);
62
63 win.size_set(250, 350);
64 win.visible_set(true);
65
66 elm_run();
67 return 0;
68}
69ELM_MAIN()