Tizen Native API
6.0
|
Most of setters explained on previous examples have associated getters. That's the subject of this example. We'll add a callback to display all calendar information every time user interacts with the calendar.
Let's check our callback function:
static void _print_cal_info_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) { int year_min, year_max; Eina_Bool sel_enabled; const char **wds; struct tm sel_time; double interval;
To get selected day, we need to call elm_calendar_selected_time_get(), but to assure nothing wrong happened, we must check for function return. It'll return EINA_FALSE
if fail. Otherwise we can use time set to our structure stime
.
if (!elm_calendar_selected_time_get(obj, &sel_time)) return;
Next we'll get information from calendar and place on declared vars:
interval = elm_calendar_interval_get(obj); elm_calendar_min_max_year_get(obj, &year_min, &year_max); sel_enabled = (elm_calendar_select_mode_get(obj) != ELM_CALENDAR_SELECT_MODE_NONE); wds = elm_calendar_weekdays_names_get(obj);
The only tricky part is that last line gets an array of strings (char arrays), one for each weekday.
Then we can simple print that to stdin:
printf("Day: %i, Mon: %i, Year %i, WeekDay: %i<br>\n" "Interval: %0.2f, Year_Min: %i, Year_Max %i, Sel Enabled : %i<br>\n" "Weekdays: %s, %s, %s, %s, %s, %s, %s<br>\n\n", sel_time.tm_mday, sel_time.tm_mon, sel_time.tm_year + 1900, sel_time.tm_wday, interval, year_min, year_max, sel_enabled, wds[0], wds[1], wds[2], wds[3], wds[4], wds[5], wds[6]); }
struct tm
is declared on time.h
. You can check ctime
manpage to read about it.
To register this callback, that will be called every time user selects a day or goes to next or previous month, just add a callback for signal changed.
evas_object_smart_callback_add(cal, "changed", _print_cal_info_cb, NULL);
See the full source code calendar_example_05::c here.