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