2 * Elementary's <b>calendar widget</b> example to add / del / clear marks.
4 * See stdout/stderr for output. Compile with:
7 * gcc -o calendar_example_06 calendar_example_06.c -g `pkg-config --cflags --libs elementary`
11 #include <Elementary.h>
13 #define SECS_DAY 86400
16 _btn_clear_cb(void *data, Evas_Object *btn, void *ev)
18 Evas_Object *cal = data;
19 elm_calendar_marks_clear(cal);
20 elm_calendar_marks_draw(cal);
24 elm_main(int argc, char **argv)
26 Evas_Object *win, *bg, *bt, *bx, *cal;
27 Elm_Calendar_Mark *mark;
28 struct tm selected_time;
30 struct tm sunday = { 0, 0, 12, 7, 0, 0, 0, 0, -1, 0, NULL };
31 /* tm {sec, min, hour, mday, mon, year, wday, yday, isdst } */
32 /* weekdays since Sunday, range 0 to 6 */
34 christmas.tm_mday = 25;
35 /* months since Jan, in the range 0 to 11 */
36 christmas.tm_mon = 11;
38 win = elm_win_add(NULL, "calendar", ELM_WIN_BASIC);
39 elm_win_title_set(win, "Calendar Marks Example");
40 elm_win_autodel_set(win, EINA_TRUE);
41 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
44 elm_win_resize_object_add(win, bg);
45 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
48 bx = elm_box_add(win);
49 elm_win_resize_object_add(win, bx);
50 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
53 cal = elm_calendar_add(win);
54 evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
55 evas_object_size_hint_align_set(cal, EVAS_HINT_FILL, EVAS_HINT_FILL);
56 elm_box_pack_end(bx, cal);
57 evas_object_show(cal);
59 /* check today - we'll remove it later */
60 current_time = time(NULL);
61 localtime_r(¤t_time, &selected_time);
62 mark = elm_calendar_mark_add(cal, "checked", &selected_time,
66 current_time = time(NULL) + 1 * SECS_DAY;
67 localtime_r(¤t_time, &selected_time);
68 elm_calendar_mark_add(cal, "checked", &selected_time, ELM_CALENDAR_UNIQUE);
70 /* mark christmas as holiday */
71 elm_calendar_mark_add(cal, "holiday", &christmas, ELM_CALENDAR_ANNUALLY);
73 /* mark Sundays as holidays */
74 elm_calendar_mark_add(cal, "holiday", &sunday, ELM_CALENDAR_WEEKLY);
76 /* ok, let's remove today's check */
77 elm_calendar_mark_del(mark);
79 elm_calendar_marks_draw(cal);
81 bt = elm_button_add(win);
82 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
83 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
84 elm_object_text_set(bt, "Clear marks");
85 evas_object_smart_callback_add(bt, "clicked", _btn_clear_cb, cal);
86 elm_box_pack_end(bx, bt);
89 evas_object_show(win);