cxx: Added examples and tutorial for C++ binding
[platform/upstream/elementary.git] / src / examples / bubble_cxx_example_01.cc
1 #include <Elementary.hh>
2 #include <Evas.hh>
3
4 EAPI_MAIN int
5 elm_main (int argc, char *argv[])
6 {
7    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
8
9    ::elm::win_standard win;
10    win.title_set("Bg Plain");
11    win.autohide_set(true);
12
13    ::elm::bg bg(efl::eo::parent = win);
14    bg.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
15    win.resize_object_add(bg);
16    bg.visible_set(true);
17
18    ::elm::label label1(efl::eo::parent = win);
19    label1.text_set(nullptr, "Bubble with no icon, info or label");
20    label1.visible_set(true);
21
22    evas::rectangle icon(efl::eo::parent = win);
23    icon.color_set( 0, 0, 255, 255);
24    icon.visible_set(true);
25
26    ::elm::bubble bubble1(efl::eo::parent = win);
27    bubble1.content_set("icon", icon);
28    bubble1.text_set("info", "INFO");
29    bubble1.text_set(nullptr, "LABEL");
30    bubble1.content_set(nullptr, label1);
31    bubble1.size_set(300, 100);
32    bubble1.visible_set(true);
33
34    auto on_click = std::bind([&] ()
35                    {
36                       static unsigned char corner = 0;
37                       ++corner;
38                       if (corner > 3)
39                         bubble1.pos_set(ELM_BUBBLE_POS_TOP_LEFT);
40                       else
41                         bubble1.pos_set(static_cast<Elm_Bubble_Pos>(corner));
42                    });
43
44    bubble1.callback_clicked_add(on_click);
45
46    ::elm::label label2(efl::eo::parent = win);
47    label2.text_set(nullptr, "Bubble with no icon, info or label");
48    label2.visible_set(true);
49
50    ::elm::bubble bubble2(efl::eo::parent = win);
51    bubble2.content_set(nullptr, label2);
52    bubble2.size_set(200, 50);
53    bubble2.position_set(0, 110);
54    bubble2.visible_set(true);
55
56    win.size_set(300, 200);
57    win.visible_set(true);
58
59    elm_run();
60    return 0;
61 }
62 ELM_MAIN()