static void set_api_state(api_data *api) { const Eina_List *items = elm_box_children_get(api->box); static Elm_Calendar_Mark *m = NULL; if (!eina_list_count(items)) return; switch(api->state) { /* Put all api-changes under switch */ case STATE_MARK_MONTHLY: { Evas_Object *cal = eina_list_nth(items, 0); time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 9); /* Set date to DEC 31, 2010 */ m = elm_calendar_mark_add(cal, "checked", gmtime(&the_time), ELM_CALENDAR_MONTHLY); elm_calendar_selected_time_set(cal, gmtime(&the_time)); } break; case STATE_MARK_WEEKLY: { Evas_Object *cal = eina_list_nth(items, 0); time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 4); /* Set date to DEC 26, 2010 */ elm_calendar_mark_del(m); m = elm_calendar_mark_add(cal, "checked", gmtime(&the_time), ELM_CALENDAR_WEEKLY); elm_calendar_selected_time_set(cal, gmtime(&the_time)); } break; case STATE_SUNDAY_HIGHLIGHT: { Evas_Object *cal = eina_list_nth(items, 0); time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 3); /* Set date to DEC 25, 2010 */ /* elm_calendar_mark_del(m); */ m = elm_calendar_mark_add(cal, "holiday", gmtime(&the_time), ELM_CALENDAR_WEEKLY); elm_calendar_selected_time_set(cal, gmtime(&the_time)); } break; case STATE_SELECT_DATE_DISABLED_WITH_MARKS: { Evas_Object *cal = eina_list_nth(items, 0); time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 10); /* Set date to JAN 01, 2011 */ elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_MODE_NONE); elm_calendar_selected_time_set(cal, gmtime(&the_time)); } break; case STATE_SELECT_DATE_DISABLED_NO_MARKS: { Evas_Object *cal = eina_list_nth(items, 0); time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 40); /* Set date to FEB 01, 2011 */ elm_calendar_marks_clear(cal); elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_MODE_NONE); elm_calendar_selected_time_set(cal, gmtime(&the_time)); } break; case API_STATE_LAST: break; default: return; } }
EAPI_MAIN int elm_main(int argc, char **argv) { Evas_Object *win, *bg, *bx, *cal, *cal2; struct tm selected_time; time_t current_time; win = elm_win_add(NULL, "calendar", ELM_WIN_BASIC); elm_win_title_set(win, "Calendar Day Selection Example"); elm_win_autodel_set(win, EINA_TRUE); elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); bg = elm_bg_add(win); elm_win_resize_object_add(win, bg); evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(bg); bx = elm_box_add(win); elm_win_resize_object_add(win, bx); evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(bx); cal = elm_calendar_add(win); evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(cal, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_MODE_NONE); evas_object_show(cal); elm_box_pack_end(bx, cal); cal2 = elm_calendar_add(win); evas_object_size_hint_weight_set(cal2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(cal2, EVAS_HINT_FILL, EVAS_HINT_FILL); current_time = time(NULL) + 2 * SECS_DAY; localtime_r(¤t_time, &selected_time); elm_calendar_selected_time_set(cal2, &selected_time); evas_object_show(cal2); elm_box_pack_end(bx, cal2); evas_object_show(win); elm_run(); elm_shutdown(); return 0; }