2 * @defgroup Calendar Calendar
4 * This is a Calendar widget. Calender widget helps applications to flexibly
5 * display a calender with day of the week, day, year and month. Applications will be
6 * able to choose a specific date that will be reported in the smart_callbacks for
7 * the calendar widget. The APIs of calendar widget let the applications perform
8 * other functions like,
9 * placing marks on specific dates
10 * Setting the bounds for the calendar (minimum and maximum years)
11 * Setting the day names of the week. ( for ex. Thu. or Thursday)
12 * Setting the year and month format.
14 * Signals that you can add callbacks for are:
15 * - @c "changed" - emitted when the date in the calendar is changed.
17 * Supported elm_object common APIs.
18 * @li elm_object_signal_emit
19 * @li elm_object_signal_callback_add
20 * @li elm_object_signal_callback_del
25 * @addtogroup Calendar
31 ELM_CALENDAR_UNIQUE, /**< Default value. Marks will be displayed only on event day. */
32 ELM_CALENDAR_DAILY, /**< Marks will be displayed every day after event day (inclusive). */
33 ELM_CALENDAR_WEEKLY, /**< Marks will be displayed every week after event day (inclusive) - i.e. each seven days. */
34 ELM_CALENDAR_MONTHLY, /**< Marks will be displayed every month day that coincides to event day. E.g.: if an event is set to 30th Jan, no marks will be displayed on Feb, but will be displayed on 30th Mar*/
35 ELM_CALENDAR_ANNUALLY /**< Marks will be displayed every year that coincides to event day (and month). E.g. an event added to 30th Jan 2012 will be repeated on 30th Jan 2013. */
36 } _Elm_Calendar_Mark_Repeat_Type;
39 * @enum _Elm_Calendar_Mark_Repeat_Type
40 * @typedef Elm_Calendar_Mark_Repeat_Type
42 * Event periodicity, used to define if a mark should be repeated
43 * @b beyond event's day. It's set when a mark is added.
45 * So, for a mark added to 13th May with periodicity set to WEEKLY,
46 * there will be marks every week after this date. Marks will be displayed
47 * at 13th, 20th, 27th, 3rd June ...
49 * Values don't work as bitmask, only one can be chosen.
51 * @see elm_calendar_mark_add()
55 typedef _Elm_Calendar_Mark_Repeat_Type Elm_Calendar_Mark_Repeat_Type;
57 typedef struct _Elm_Calendar_Mark Elm_Calendar_Mark; /**< Item handle for a calendar mark. Created with elm_calendar_mark_add() and deleted with elm_calendar_mark_del(). */
60 * Add a new calendar widget to the given parent Elementary
63 * @param parent The parent object.
64 * @return a new calendar widget handle or @c NULL, on errors.
66 * This function inserts a new calendar widget on the canvas.
68 * @ref calendar_example_01
72 EAPI Evas_Object *elm_calendar_add(Evas_Object *parent);
75 * Get weekdays names displayed by the calendar.
77 * @param obj The calendar object.
78 * @return Array of seven strings to be used as weekday names.
80 * By default, weekdays abbreviations get from system are displayed:
81 * E.g. for an en_US locale: "Sun, Mon, Tue, Wed, Thu, Fri, Sat"
82 * The first string is related to Sunday, the second to Monday...
84 * @see elm_calendar_weekdays_name_set()
86 * @ref calendar_example_05
90 EAPI const char **elm_calendar_weekdays_names_get(const Evas_Object *obj);
93 * Set weekdays names to be displayed by the calendar.
95 * @param obj The calendar object.
96 * @param weekdays Array of seven strings to be used as weekday names.
97 * @warning It must have 7 elements, or it will access invalid memory.
98 * @warning The strings must be NULL terminated ('@\0').
100 * By default, weekdays abbreviations get from system are displayed:
101 * E.g. for an en_US locale: "Sun, Mon, Tue, Wed, Thu, Fri, Sat"
103 * The first string should be related to Sunday, the second to Monday...
105 * The usage should be like this:
107 * const char *weekdays[] =
109 * "Sunday", "Monday", "Tuesday", "Wednesday",
110 * "Thursday", "Friday", "Saturday"
112 * elm_calendar_weekdays_names_set(calendar, weekdays);
115 * @see elm_calendar_weekdays_name_get()
117 * @ref calendar_example_02
121 EAPI void elm_calendar_weekdays_names_set(Evas_Object *obj, const char *weekdays[]);
124 * Set the minimum and maximum values for the year
126 * @param obj The calendar object
127 * @param min The minimum year, greater than 1901;
128 * @param max The maximum year;
130 * Maximum must be greater than minimum, except if you don't want to set
132 * Default values are 1902 and -1.
134 * If the maximum year is a negative value, it will be limited depending
135 * on the platform architecture (year 2037 for 32 bits);
137 * @see elm_calendar_min_max_year_get()
139 * @ref calendar_example_03
143 EAPI void elm_calendar_min_max_year_set(Evas_Object *obj, int min, int max);
146 * Get the minimum and maximum values for the year
148 * @param obj The calendar object.
149 * @param min The minimum year.
150 * @param max The maximum year.
152 * Default values are 1902 and -1.
154 * @see elm_calendar_min_max_year_get() for more details.
156 * @ref calendar_example_05
160 EAPI void elm_calendar_min_max_year_get(const Evas_Object *obj, int *min, int *max);
163 * Enable or disable day selection
165 * @param obj The calendar object.
166 * @param disabled @c EINA_TRUE to disable selection or @c EINA_FALSE to
169 * Enabled by default. If disabled, the user still can select months,
170 * but not days. Selected days are highlighted on calendar.
171 * It should be used if you won't need such selection for the widget usage.
173 * When a day is selected, or month is changed, smart callbacks for
174 * signal "changed" will be called.
176 * @see elm_calendar_day_selection_disabled_get()
178 * @ref calendar_example_04
182 EAPI void elm_calendar_day_selection_disabled_set(Evas_Object *obj, Eina_Bool disabled);
185 * Get a value whether day selection is disabled or not.
187 * @param obj The calendar object.
188 * @return EINA_TRUE means day selection is disabled. EINA_FALSE indicates
189 * it's enabled. If @p obj is NULL, EINA_FALSE is returned.
191 * @see elm_calendar_day_selection_disabled_set() for details.
193 * @ref calendar_example_05
197 EAPI Eina_Bool elm_calendar_day_selection_disabled_get(const Evas_Object *obj);
200 * Set selected date to be highlighted on calendar.
202 * @param obj The calendar object.
203 * @param selected_time A @b tm struct to represent the selected date.
205 * Set the selected date, changing the displayed month if needed.
206 * Selected date changes when the user goes to next/previous month or
207 * select a day pressing over it on calendar.
209 * @see elm_calendar_selected_time_get()
211 * @ref calendar_example_04
215 EAPI void elm_calendar_selected_time_set(Evas_Object *obj, struct tm *selected_time);
220 * @param obj The calendar object
221 * @param selected_time A @b tm struct to point to selected date
222 * @return EINA_FALSE means an error occurred and returned time shouldn't
225 * Get date selected by the user or set by function
226 * elm_calendar_selected_time_set().
227 * Selected date changes when the user goes to next/previous month or
228 * select a day pressing over it on calendar.
230 * @see elm_calendar_selected_time_get()
232 * @ref calendar_example_05
236 EAPI Eina_Bool elm_calendar_selected_time_get(const Evas_Object *obj, struct tm *selected_time);
239 * Set a function to format the string that will be used to display
242 * @param obj The calendar object
243 * @param format_function Function to set the month-year string given
246 * By default it uses strftime with "%B %Y" format string.
247 * It should allocate the memory that will be used by the string,
248 * that will be freed by the widget after usage.
249 * A pointer to the string and a pointer to the time struct will be provided.
254 * _format_month_year(struct tm *selected_time)
257 * if (!strftime(buf, sizeof(buf), "%B %Y", selected_time)) return NULL;
258 * return strdup(buf);
261 * elm_calendar_format_function_set(calendar, _format_month_year);
264 * @ref calendar_example_02
268 EAPI void elm_calendar_format_function_set(Evas_Object *obj, char *(*format_function)(struct tm *stime));
271 * Add a new mark to the calendar
273 * @param obj The calendar object
274 * @param mark_type A string used to define the type of mark. It will be
275 * emitted to the theme, that should display a related modification on these
276 * days representation.
277 * @param mark_time A time struct to represent the date of inclusion of the
278 * mark. For marks that repeats it will just be displayed after the inclusion
279 * date in the calendar.
280 * @param repeat Repeat the event following this periodicity. Can be a unique
281 * mark (that don't repeat), daily, weekly, monthly or annually.
282 * @return The created mark or @p NULL upon failure.
284 * Add a mark that will be drawn in the calendar respecting the insertion
285 * time and periodicity. It will emit the type as signal to the widget theme.
286 * Default theme supports "holiday" and "checked", but it can be extended.
288 * It won't immediately update the calendar, drawing the marks.
289 * For this, call elm_calendar_marks_draw(). However, when user selects
290 * next or previous month calendar forces marks drawn.
292 * Marks created with this method can be deleted with
293 * elm_calendar_mark_del().
297 * struct tm selected_time;
298 * time_t current_time;
300 * current_time = time(NULL) + 5 * 84600;
301 * localtime_r(¤t_time, &selected_time);
302 * elm_calendar_mark_add(cal, "holiday", selected_time,
303 * ELM_CALENDAR_ANNUALLY);
305 * current_time = time(NULL) + 1 * 84600;
306 * localtime_r(¤t_time, &selected_time);
307 * elm_calendar_mark_add(cal, "checked", selected_time, ELM_CALENDAR_UNIQUE);
309 * elm_calendar_marks_draw(cal);
312 * @see elm_calendar_marks_draw()
313 * @see elm_calendar_mark_del()
315 * @ref calendar_example_06
319 EAPI Elm_Calendar_Mark *elm_calendar_mark_add(Evas_Object *obj, const char *mark_type, struct tm *mark_time, Elm_Calendar_Mark_Repeat_Type repeat);
322 * Delete mark from the calendar.
324 * @param mark The mark to be deleted.
326 * If deleting all calendar marks is required, elm_calendar_marks_clear()
327 * should be used instead of getting marks list and deleting each one.
329 * @see elm_calendar_mark_add()
331 * @ref calendar_example_06
335 EAPI void elm_calendar_mark_del(Elm_Calendar_Mark *mark);
338 * Remove all calendar's marks
340 * @param obj The calendar object.
342 * @see elm_calendar_mark_add()
343 * @see elm_calendar_mark_del()
347 EAPI void elm_calendar_marks_clear(Evas_Object *obj);
350 * Get a list of all the calendar marks.
352 * @param obj The calendar object.
353 * @return An @c Eina_List of calendar marks objects, or @c NULL on failure.
355 * @see elm_calendar_mark_add()
356 * @see elm_calendar_mark_del()
357 * @see elm_calendar_marks_clear()
361 EAPI const Eina_List *elm_calendar_marks_get(const Evas_Object *obj);
364 * Draw calendar marks.
366 * @param obj The calendar object.
368 * Should be used after adding, removing or clearing marks.
369 * It will go through the entire marks list updating the calendar.
370 * If lots of marks will be added, add all the marks and then call
373 * When the month is changed, i.e. user selects next or previous month,
374 * marks will be drawn.
376 * @see elm_calendar_mark_add()
377 * @see elm_calendar_mark_del()
378 * @see elm_calendar_marks_clear()
380 * @ref calendar_example_06
384 EAPI void elm_calendar_marks_draw(Evas_Object *obj);
387 * Set the interval on time updates for an user mouse button hold
388 * on calendar widgets' month selection.
390 * @param obj The calendar object
391 * @param interval The (first) interval value in seconds
393 * This interval value is @b decreased while the user holds the
394 * mouse pointer either selecting next or previous month.
396 * This helps the user to get to a given month distant from the
397 * current one easier/faster, as it will start to change quicker and
398 * quicker on mouse button holds.
400 * The calculation for the next change interval value, starting from
401 * the one set with this call, is the previous interval divided by
402 * 1.05, so it decreases a little bit.
404 * The default starting interval value for automatic changes is
407 * @see elm_calendar_interval_get()
411 EAPI void elm_calendar_interval_set(Evas_Object *obj, double interval);
414 * Get the interval on time updates for an user mouse button hold
415 * on calendar widgets' month selection.
417 * @param obj The calendar object
418 * @return The (first) interval value, in seconds, set on it
420 * @see elm_calendar_interval_set() for more details
424 EAPI double elm_calendar_interval_get(const Evas_Object *obj);