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, *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_util_standard_add("calendar", "Calendar Marks Example");
39 elm_win_autodel_set(win, EINA_TRUE);
40 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
42 bx = elm_box_add(win);
43 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
44 elm_win_resize_object_add(win, bx);
47 cal = elm_calendar_add(win);
48 evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
49 evas_object_size_hint_align_set(cal, EVAS_HINT_FILL, EVAS_HINT_FILL);
50 elm_box_pack_end(bx, cal);
51 evas_object_show(cal);
53 /* check today - we'll remove it later */
54 current_time = time(NULL);
55 localtime_r(¤t_time, &selected_time);
56 mark = elm_calendar_mark_add(cal, "checked", &selected_time,
60 current_time = time(NULL) + 1 * SECS_DAY;
61 localtime_r(¤t_time, &selected_time);
62 elm_calendar_mark_add(cal, "checked", &selected_time, ELM_CALENDAR_UNIQUE);
64 /* mark christmas as holiday */
65 elm_calendar_mark_add(cal, "holiday", &christmas, ELM_CALENDAR_ANNUALLY);
67 /* mark Sundays as holidays */
68 elm_calendar_mark_add(cal, "holiday", &sunday, ELM_CALENDAR_WEEKLY);
70 /* ok, let's remove today's check */
71 elm_calendar_mark_del(mark);
73 elm_calendar_marks_draw(cal);
75 bt = elm_button_add(win);
76 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
77 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
78 elm_object_text_set(bt, "Clear marks");
79 evas_object_smart_callback_add(bt, "clicked", _btn_clear_cb, cal);
80 elm_box_pack_end(bx, bt);
83 evas_object_show(win);