|
这段代码演示如何自定义日历:-设置自定义的名称为平日-set 的方法来设置格式的字符串,用来显示月份和年份-设置周第一天
- char *_format_month_year(struct tm *selected_time) {
- char buf[32];
-
- //e.g. output: "August 2015"
- if (!strftime(buf, sizeof(buf), "%B %Y", selected_time))
- return NULL;
-
- // //e.g. output: "Aug 15"
- //if (!strftime(buf, sizeof(buf), "%b %u", selected_time))
- //return NULL;
-
- return strdup(buf);
- }
- void show_calendar(appdata_s *ad) {
- Evas_Object *calendar = elm_calendar_add(ad->win);
- evas_object_size_hint_weight_set(calendar, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- elm_win_resize_object_add(ad->win, calendar);
- evas_object_show(calendar);
-
- //set method to format the string used to display month and year
- elm_calendar_format_function_set(calendar, _format_month_year);
-
- //set custom names for weekdays
- const char *days[] = { ";(", ":(", ":(", ":|", ":)", ":D", ":)" };
- elm_calendar_weekdays_names_set(calendar, days);
-
- //set first day of week, here Sunday (=0)
- elm_calendar_first_day_of_week_set(calendar, 0);
- }
复制代码 |
|