Calendar
PUBLISHED
The calendar UI component displays month views. For more information, see the Calendar [1] API.
This feature is supported in mobile applications only.
Figure: Calendar component
Basic Usage
To use a calendar component in your application:
- Add a calendar with the
elm_calendar_add()
function. - Select the month to display with the
elm_calendar_selected_time_set()
function:
Evas_Object *calendar; Evas_Object *parent; time_t the_time; /* Set the current time to display the current month */ time(&the_time); /* Get the current time */ calendar = elm_calendar_add(parent); elm_calendar_selected_time_set(calendar, gmtime(&the_time));
- Configure the month view:
-
Change the first day of the week (by default, Sunday).
To change the first weekday to Monday:
elm_calendar_first_day_of_week_set(calendar, ELM_DAY_MONDAY);
-
Modify the names of the weekdays using the
elm_calendar_weekdays_names_set()
function:const char *weekname[7] = {"A", "B", "C", "D", "E", "F", "G"}; elm_calendar_weekdays_names_set(calendar, &weekname);
- Mark holidays with the
elm_calendar_mark_add()
function.The following example shows how to mark a Sunday as holiday:
struct tm *sunday = gmtime(&the_time); sunday->tm_mday -= sunday->tm_wday; sunday->tm_wday = 0; elm_calendar_mark_add(calendar, "holiday", sunday, ELM_CALENDAR_WEEKLY);
-
- Register the callback functions.
The following example shows how to define and register a callback for the
changed
signal:evas_object_smart_callback_add(calendar, "changed", changed_cb, data); void changed_cb(void *data, Evas_Object *obj, void *event_info) { dlog_print(DLOG_INFO, LOG_TAG, "Calendar is changed. \n"); }
Styles
The following table lists the available component styles.
Table: Calendar styles
Style | Sample |
---|---|
elm/check/base/default |
Callbacks
You can register callback functions connected to the following signals for a calendar object.
Table: Calendar callback signals
Signal | Description | event_info |
---|---|---|
changed |
The selected date is changed. | NULL |