Customizing calendar widget

This code snippet shows how to customize calendar: - set custom names for weekdays - set method to format the string used to display month and year - set first day of the week
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);

}

Responses

0 Replies