cxx: Added examples and tutorial for C++ binding
[platform/upstream/elementary.git] / src / examples / calendar_cxx_example_05.cc
1 #include <Elementary.hh>
2
3 EAPI_MAIN int
4 elm_main (int argc, char *argv[])
5 {
6    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
7
8    ::elm::win_standard win;
9    win.title_set("Calendar Getters Example");
10    win.autohide_set(true);
11
12    ::elm::calendar cal(efl::eo::parent = win);
13    cal.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
14    win.resize_object_add(cal);
15
16    auto print_cal_info = std::bind([] (::elm::calendar obj)
17                          {
18                             int year_min, year_max;
19                             bool sel_enabled;
20                             const char **wds;
21                             struct tm sel_time;
22                             double interval;
23
24                             if (!obj.selected_time_get(&sel_time))
25                               return;
26
27                             interval = obj.interval_get();
28                             obj.min_max_year_get(&year_min, &year_max);
29                             sel_enabled = (obj.select_mode_get() != ELM_CALENDAR_SELECT_MODE_NONE);
30                             wds = obj.weekdays_names_get();
31
32                             std::cout << "Day: " << sel_time.tm_mday << ", Mon: " << sel_time.tm_mon << ", Year " <<
33                             sel_time.tm_year + 1900 << ", WeekDay: " << sel_time.tm_wday << "<br>" << std::endl;
34
35                             std::cout << "Interval: " << interval << ", Year_Min: " << year_min << ", Year_Max " <<
36                             year_max << ", Sel Enabled: " << sel_enabled << "<br>" << std::endl;
37
38                             std::cout << "Weekdays: " << wds[0] << ", " << wds[1] << ", " << wds[2] << ", " << wds[3] <<
39                             ", " <<  wds[4] << ", " <<  wds[5] << ", " << wds[6] << "<br>" << std::endl << std::endl;
40                          } , std::placeholders::_1 );
41
42    cal.callback_changed_add(print_cal_info);
43    cal.visible_set(true);
44
45    win.visible_set(true);
46
47    elm_run();
48    return 0;
49 }
50 ELM_MAIN()