summaryrefslogtreecommitdiff
path: root/src/examples/elementary/button_cxx_example_00.cc
blob: ae0a0fa44f4a6bd34a7c1f59dd6af8e3c7471ff7 (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
// g++ -g `pkg-config --cflags --libs elementary-cxx efl-cxx eina-cxx eo-cxx ecore-cxx evas-cxx edje-cxx` button_cxx_example_00.cc -o button_cxx_example_00

#define EFL_CXXPERIMENTAL
#ifndef EFL_BETA_API_SUPPORT
#define EFL_BETA_API_SUPPORT
#endif
#include <Efl_Ui.hh>
#include <iostream>

using efl::eo::instantiate;

static void
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);

   efl::ui::Win win(instantiate);
   win.text_set("Button Example");
   win.autohide_set(true);

   efl::ui::Box box(instantiate, win);
   win.content_set(box);

   efl::ui::Button bt(instantiate, win);
   bt.text_set("Hello world!");
   box.pack(bt);

   auto wbt(bt._get_wref());
   auto cb(std::bind([wbt]() {
        std::cout << wbt->text_get() << std::endl;
     }));
   efl::eolian::event_add(efl::input::Clickable::clicked_event, bt, cb);

   efl::ui::Button bt2(instantiate, win);
   bt2.text_set("Click to quit");
   box.pack(bt2);

   auto wwin(win._get_wref());
   auto cb2(std::bind([wwin]() {
        ::efl_del(wwin->_eo_ptr()); // FIXME: No proper C++ API to delete win
     }));
   efl::eolian::event_add(efl::input::Clickable::clicked_event, bt2, cb2);

   win.size_set({320,160});
}
EFL_MAIN()