summaryrefslogtreecommitdiff
path: root/src/examples/elementary/calendar_cxx_example_02.cc
blob: dba2b1a3ec76051afb247a6994a95a6f6d3b728a (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
#define EFL_CXXPERIMENTAL

#include <Efl_Ui.hh>

using namespace std::placeholders;
using efl::eo::add;

struct appData
{
   appData() : m_win(nullptr) {}

   ~appData() {
      std::cout << "Good bye!" << std::endl;
   }

   void create() {
      std::cout << "Hello!" << std::endl;

      add(m_win);
      m_win.text_set("Calendar Layout Formatting Example");
      m_win.delete_request_event_cb_add([&](){ destroy(); });

      efl::ui::Calendar cal(add, m_win);
      m_win.content_set(cal);

      auto wcal(cal._get_wref());

      // FIXME: How does one figure out the argument types for the function?
      auto cb_a = std::bind([](
                            efl::eina::strbuf_wrapper& sb,
                            efl::eina::value_view const& value) -> bool {
           try {
              sb.append_strftime("%b. %y", efl::eina::get<tm>(value));
           } catch (std::system_error const&)  {
              sb.append(value.to_string());
           }
           std::cout << "Month: " << std::string(sb) << std::endl;
           return true;
        }, _1, _2);
      // FIXME XAR: I broke this and I do not know how to fix it
      // cal.format_func_set(cb_a);
      (void)cb_a;
   }

   void destroy() {
      // FIXME: need del() function and no error on unref().
      ::efl_allow_parent_unref_set(m_win, true);
      m_win = nullptr;
   }

private:
   efl::ui::Win m_win;
};

static appData app;

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_CLOSED);
   app.create();
}
EFL_MAIN()