1 #include <Elementary.h>
3 # include "elementary_config.h"
5 #ifndef ELM_LIB_QUICKLAUNCH
7 /* A simple test, just displaying calendar in it's default state */
9 test_calendar(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
11 Evas_Object *win, *bg, *cal;
13 win = elm_win_add(NULL, "calendar", ELM_WIN_BASIC);
14 elm_win_title_set(win, "Calendar");
15 elm_win_autodel_set(win, 1);
18 elm_win_resize_object_add(win, bg);
19 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
22 cal = elm_calendar_add(win);
23 elm_win_resize_object_add(win, cal);
24 evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
25 evas_object_show(cal);
27 evas_object_show(win);
31 _print_cal_info(Evas_Object *cal, Evas_Object *en)
35 int year_min, year_max;
36 Eina_Bool sel_enabled;
40 if (!elm_calendar_selected_time_get(cal, &stime))
43 interval = elm_calendar_interval_get(cal);
44 elm_calendar_min_max_year_get(cal, &year_min, &year_max);
45 sel_enabled = elm_calendar_day_selection_enabled_get(cal);
46 wds = elm_calendar_weekdays_names_get(cal);
48 snprintf(info, sizeof(info),
49 " Day: %i, Mon: %i, Year %i, WeekDay: %i<br>"
50 " Interval: %0.2f, Year_Min: %i, Year_Max %i, Sel Enabled : %i<br>"
51 " Weekdays: %s, %s, %s, %s, %s, %s, %s<br>",
52 stime.tm_mday, stime.tm_mon, stime.tm_year + 1900, stime.tm_wday,
53 interval, year_min, year_max, sel_enabled,
54 wds[0], wds[1], wds[2], wds[3], wds[4], wds[5], wds[6]);
56 elm_entry_entry_set(en, info);
60 _print_cal_info_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
62 _print_cal_info(obj, data);
66 _format_month_year(struct tm *stime)
69 if (!strftime(buf, sizeof(buf), "%b %y", stime)) return NULL;
73 /* A test intended to cover all the calendar api and much use cases as
76 test_calendar2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
78 Evas_Object *win, *bg, *bx, *bxh, *cal, *cal2, *cal3, *en;
79 Elm_Calendar_Mark *mark;
80 struct tm selected_time;
82 const char *weekdays[] =
84 "Sunday", "Monday", "Tuesday", "Wednesday",
85 "Thursday", "Friday", "Saturday"
88 win = elm_win_add(NULL, "calendar2", ELM_WIN_BASIC);
89 elm_win_title_set(win, "Calendar 2");
90 elm_win_autodel_set(win, 1);
93 elm_win_resize_object_add(win, bg);
94 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
97 bx = elm_box_add(win);
98 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
99 elm_win_resize_object_add(win, bx);
100 evas_object_show(bx);
102 bxh = elm_box_add(win);
103 elm_box_horizontal_set(bxh, EINA_TRUE);
104 evas_object_size_hint_weight_set(bxh, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
105 evas_object_size_hint_align_set(bxh, EVAS_HINT_FILL, EVAS_HINT_FILL);
106 evas_object_show(bxh);
107 elm_box_pack_end(bx, bxh);
109 cal = elm_calendar_add(win);
110 evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
111 evas_object_size_hint_align_set(cal, EVAS_HINT_FILL, EVAS_HINT_FILL);
112 evas_object_show(cal);
113 elm_box_pack_end(bx, cal);
115 cal2 = elm_calendar_add(win);
116 evas_object_size_hint_weight_set(cal2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
117 evas_object_size_hint_align_set(cal2, EVAS_HINT_FILL, EVAS_HINT_FILL);
118 elm_calendar_day_selection_enabled_set(cal2, EINA_FALSE);
119 evas_object_show(cal2);
120 elm_box_pack_end(bxh, cal2);
122 cal3 = elm_calendar_add(win);
123 evas_object_size_hint_weight_set(cal3, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
124 evas_object_size_hint_align_set(cal3, EVAS_HINT_FILL, EVAS_HINT_FILL);
125 current_time = time(NULL) + 34 * 84600;
126 localtime_r(¤t_time, &selected_time);
127 elm_calendar_selected_time_set(cal3, &selected_time);
128 current_time = time(NULL) + 1 * 84600;
129 localtime_r(¤t_time, &selected_time);
130 elm_calendar_mark_add(cal3, "checked", &selected_time, ELM_CALENDAR_UNIQUE);
131 elm_calendar_marks_clear(cal3);
132 current_time = time(NULL);
133 localtime_r(¤t_time, &selected_time);
134 elm_calendar_mark_add(cal3, "checked", &selected_time, ELM_CALENDAR_DAILY);
135 elm_calendar_mark_add(cal3, "holiday", &selected_time, ELM_CALENDAR_DAILY);
136 elm_calendar_marks_draw(cal3);
137 evas_object_show(cal3);
138 elm_box_pack_end(bxh, cal3);
140 en = elm_entry_add(win);
141 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
142 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
143 evas_object_show(en);
144 elm_box_pack_end(bx, en);
145 elm_entry_editable_set(en, EINA_FALSE);
146 evas_object_show(win);
148 elm_calendar_min_max_year_set(cal3, -1, -1);
150 elm_calendar_weekdays_names_set(cal, weekdays);
151 elm_calendar_interval_set(cal, 0.4);
152 elm_calendar_format_function_set(cal, _format_month_year);
153 elm_calendar_min_max_year_set(cal, 2010, 2020);
155 current_time = time(NULL) + 4 * 84600;
156 localtime_r(¤t_time, &selected_time);
157 elm_calendar_mark_add(cal, "holiday", &selected_time, ELM_CALENDAR_ANNUALLY);
159 current_time = time(NULL) + 1 * 84600;
160 localtime_r(¤t_time, &selected_time);
161 elm_calendar_mark_add(cal, "checked", &selected_time, ELM_CALENDAR_UNIQUE);
163 current_time = time(NULL) - 363 * 84600;
164 localtime_r(¤t_time, &selected_time);
165 elm_calendar_mark_add(cal, "checked", &selected_time, ELM_CALENDAR_MONTHLY);
167 current_time = time(NULL) - 5 * 84600;
168 localtime_r(¤t_time, &selected_time);
169 mark = elm_calendar_mark_add(cal, "holiday", &selected_time,
170 ELM_CALENDAR_WEEKLY);
172 current_time = time(NULL) + 1 * 84600;
173 localtime_r(¤t_time, &selected_time);
174 elm_calendar_mark_add(cal, "holiday", &selected_time, ELM_CALENDAR_WEEKLY);
176 elm_calendar_mark_del(mark);
177 elm_calendar_marks_draw(cal);
179 _print_cal_info(cal, en);
180 evas_object_smart_callback_add(cal, "changed", _print_cal_info_cb, en);