cxx: Added examples and tutorial for C++ binding
[platform/upstream/elementary.git] / src / examples / calendar_cxx_example_02.cc
1 #include <Elementary.hh>
2
3 static char *
4 _format_month_year(struct tm *format_time)
5 {
6    char buf[32];
7    if (!strftime(buf, sizeof(buf), "%b %y", format_time)) return NULL;
8    return strdup(buf);
9 }
10
11 EAPI_MAIN int
12 elm_main (int argc, char *argv[])
13 {
14    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
15
16    const char *weekdays[] =
17      {
18        "S", "M", "T", "W", "T", "F", "S"
19      };
20
21    ::elm::win_standard win;
22    win.title_set("Calendar Layout Formatting Example");
23    win.autohide_set(true);
24
25    ::elm::calendar cal(efl::eo::parent = win);
26    cal.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
27    win.resize_object_add(cal);
28
29    cal.format_function_set(_format_month_year);
30    cal.weekdays_names_set(weekdays);
31
32    cal.visible_set(true);
33    win.visible_set(true);
34
35    elm_run();
36    return 0;
37 }
38 ELM_MAIN()