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
22 * Here is some sample code using it:
23 * @li @ref calendar_example_01
24 * @li @ref calendar_example_02
25 * @li @ref calendar_example_03
26 * @li @ref calendar_example_04
27 * @li @ref calendar_example_05
28 * @li @ref calendar_example_06
32 * @addtogroup Calendar
38 ELM_CALENDAR_UNIQUE, /**< Default value. Marks will be displayed only on event day. */
39 ELM_CALENDAR_DAILY, /**< Marks will be displayed every day after event day (inclusive). */
40 ELM_CALENDAR_WEEKLY, /**< Marks will be displayed every week after event day (inclusive) - i.e. each seven days. */
41 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*/
42 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. */
43 } _Elm_Calendar_Mark_Repeat_Type;
46 * @enum _Elm_Calendar_Mark_Repeat_Type
47 * @typedef Elm_Calendar_Mark_Repeat_Type
49 * Event periodicity, used to define if a mark should be repeated
50 * @b beyond event's day. It's set when a mark is added.
52 * So, for a mark added to 13th May with periodicity set to WEEKLY,
53 * there will be marks every week after this date. Marks will be displayed
54 * at 13th, 20th, 27th, 3rd June ...
56 * Values don't work as bitmask, only one can be chosen.
58 * @see elm_calendar_mark_add()
62 typedef _Elm_Calendar_Mark_Repeat_Type Elm_Calendar_Mark_Repeat_Type;
74 } _Elm_Calendar_Weekday;
77 * @enum _Elm_Calendar_Weekday
78 * @typedef Elm_Calendar_Weekday
82 * @see elm_calendar_first_day_of_week_set()
86 typedef _Elm_Calendar_Weekday Elm_Calendar_Weekday;
88 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(). */
91 * @typedef Elm_Calendar_Format_Cb
93 * This callback type is used to format the string that will be used
94 * to display month and year.
96 * @param stime Struct representing time.
97 * @return String representing time that will be set to calendar's text.
99 * @see elm_calendar_format_function_set()
101 typedef char * (*Elm_Calendar_Format_Cb)(struct tm *stime);
104 * Add a new calendar widget to the given parent Elementary
105 * (container) object.
107 * @param parent The parent object.
108 * @return a new calendar widget handle or @c NULL, on errors.
110 * This function inserts a new calendar widget on the canvas.
112 * @ref calendar_example_01
116 EAPI Evas_Object *elm_calendar_add(Evas_Object *parent);
119 * Get weekdays names displayed by the calendar.
121 * @param obj The calendar object.
122 * @return Array of seven strings to be used as weekday names.
124 * By default, weekdays abbreviations get from system are displayed:
125 * E.g. for an en_US locale: "Sun, Mon, Tue, Wed, Thu, Fri, Sat"
126 * The first string is related to Sunday, the second to Monday...
128 * @see elm_calendar_weekdays_name_set()
130 * @ref calendar_example_05
134 EAPI const char **elm_calendar_weekdays_names_get(const Evas_Object *obj);
137 * Set weekdays names to be displayed by the calendar.
139 * @param obj The calendar object.
140 * @param weekdays Array of seven strings to be used as weekday names.
141 * @warning It must have 7 elements, or it will access invalid memory.
142 * @warning The strings must be NULL terminated ('@\0').
144 * By default, weekdays abbreviations get from system are displayed:
145 * E.g. for an en_US locale: "Sun, Mon, Tue, Wed, Thu, Fri, Sat"
147 * The first string should be related to Sunday, the second to Monday...
149 * The usage should be like this:
151 * const char *weekdays[] =
153 * "Sunday", "Monday", "Tuesday", "Wednesday",
154 * "Thursday", "Friday", "Saturday"
156 * elm_calendar_weekdays_names_set(calendar, weekdays);
159 * @see elm_calendar_weekdays_name_get()
161 * @ref calendar_example_02
165 EAPI void elm_calendar_weekdays_names_set(Evas_Object *obj, const char *weekdays[]);
168 * Set the minimum and maximum values for the year
170 * @param obj The calendar object
171 * @param min The minimum year, greater than 1901;
172 * @param max The maximum year;
174 * Maximum must be greater than minimum, except if you don't want to set
176 * Default values are 1902 and -1.
178 * If the maximum year is a negative value, it will be limited depending
179 * on the platform architecture (year 2037 for 32 bits);
181 * @see elm_calendar_min_max_year_get()
183 * @ref calendar_example_03
187 EAPI void elm_calendar_min_max_year_set(Evas_Object *obj, int min, int max);
190 * Get the minimum and maximum values for the year
192 * @param obj The calendar object.
193 * @param min The minimum year.
194 * @param max The maximum year.
196 * Default values are 1902 and -1.
198 * @see elm_calendar_min_max_year_get() for more details.
200 * @ref calendar_example_05
204 EAPI void elm_calendar_min_max_year_get(const Evas_Object *obj, int *min, int *max);
207 * Enable or disable day selection
209 * @param obj The calendar object.
210 * @param disabled @c EINA_TRUE to disable selection or @c EINA_FALSE to
213 * Enabled by default. If disabled, the user still can select months,
214 * but not days. Selected days are highlighted on calendar.
215 * It should be used if you won't need such selection for the widget usage.
217 * When a day is selected, or month is changed, smart callbacks for
218 * signal "changed" will be called.
220 * @see elm_calendar_day_selection_disabled_get()
222 * @ref calendar_example_04
226 EAPI void elm_calendar_day_selection_disabled_set(Evas_Object *obj, Eina_Bool disabled);
229 * Get a value whether day selection is disabled or not.
231 * @param obj The calendar object.
232 * @return EINA_TRUE means day selection is disabled. EINA_FALSE indicates
233 * it's enabled. If @p obj is NULL, EINA_FALSE is returned.
235 * @see elm_calendar_day_selection_disabled_set() for details.
237 * @ref calendar_example_05
241 EAPI Eina_Bool elm_calendar_day_selection_disabled_get(const Evas_Object *obj);
244 * Set selected date to be highlighted on calendar.
246 * @param obj The calendar object.
247 * @param selected_time A @b tm struct to represent the selected date.
249 * Set the selected date, changing the displayed month if needed.
250 * Selected date changes when the user goes to next/previous month or
251 * select a day pressing over it on calendar.
253 * @see elm_calendar_selected_time_get()
255 * @ref calendar_example_04
259 EAPI void elm_calendar_selected_time_set(Evas_Object *obj, struct tm *selected_time);
264 * @param obj The calendar object
265 * @param selected_time A @b tm struct to point to selected date
266 * @return EINA_FALSE means an error occurred and returned time shouldn't
269 * Get date selected by the user or set by function
270 * elm_calendar_selected_time_set().
271 * Selected date changes when the user goes to next/previous month or
272 * select a day pressing over it on calendar.
274 * @see elm_calendar_selected_time_get()
276 * @ref calendar_example_05
280 EAPI Eina_Bool elm_calendar_selected_time_get(const Evas_Object *obj, struct tm *selected_time);
283 * Set a function to format the string that will be used to display
286 * @param obj The calendar object
287 * @param format_func Function to set the month-year string given
290 * By default it uses strftime with "%B %Y" format string.
291 * It should allocate the memory that will be used by the string,
292 * that will be freed by the widget after usage.
293 * A pointer to the string and a pointer to the time struct will be provided.
298 * _format_month_year(struct tm *selected_time)
301 * if (!strftime(buf, sizeof(buf), "%B %Y", selected_time)) return NULL;
302 * return strdup(buf);
305 * elm_calendar_format_function_set(calendar, _format_month_year);
308 * @ref calendar_example_02
312 EAPI void elm_calendar_format_function_set(Evas_Object *obj, Elm_Calendar_Format_Cb format_func);
315 * Add a new mark to the calendar
317 * @param obj The calendar object
318 * @param mark_type A string used to define the type of mark. It will be
319 * emitted to the theme, that should display a related modification on these
320 * days representation.
321 * @param mark_time A time struct to represent the date of inclusion of the
322 * mark. For marks that repeats it will just be displayed after the inclusion
323 * date in the calendar.
324 * @param repeat Repeat the event following this periodicity. Can be a unique
325 * mark (that don't repeat), daily, weekly, monthly or annually.
326 * @return The created mark or @p NULL upon failure.
328 * Add a mark that will be drawn in the calendar respecting the insertion
329 * time and periodicity. It will emit the type as signal to the widget theme.
330 * Default theme supports "holiday" and "checked", but it can be extended.
332 * It won't immediately update the calendar, drawing the marks.
333 * For this, call elm_calendar_marks_draw(). However, when user selects
334 * next or previous month calendar forces marks drawn.
336 * Marks created with this method can be deleted with
337 * elm_calendar_mark_del().
341 * struct tm selected_time;
342 * time_t current_time;
344 * current_time = time(NULL) + 5 * 84600;
345 * localtime_r(¤t_time, &selected_time);
346 * elm_calendar_mark_add(cal, "holiday", selected_time,
347 * ELM_CALENDAR_ANNUALLY);
349 * current_time = time(NULL) + 1 * 84600;
350 * localtime_r(¤t_time, &selected_time);
351 * elm_calendar_mark_add(cal, "checked", selected_time, ELM_CALENDAR_UNIQUE);
353 * elm_calendar_marks_draw(cal);
356 * @see elm_calendar_marks_draw()
357 * @see elm_calendar_mark_del()
359 * @ref calendar_example_06
363 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);
366 * Delete mark from the calendar.
368 * @param mark The mark to be deleted.
370 * If deleting all calendar marks is required, elm_calendar_marks_clear()
371 * should be used instead of getting marks list and deleting each one.
373 * @see elm_calendar_mark_add()
375 * @ref calendar_example_06
379 EAPI void elm_calendar_mark_del(Elm_Calendar_Mark *mark);
382 * Remove all calendar's marks
384 * @param obj The calendar object.
386 * @see elm_calendar_mark_add()
387 * @see elm_calendar_mark_del()
391 EAPI void elm_calendar_marks_clear(Evas_Object *obj);
394 * Get a list of all the calendar marks.
396 * @param obj The calendar object.
397 * @return An @c Eina_List of calendar marks objects, or @c NULL on failure.
399 * @see elm_calendar_mark_add()
400 * @see elm_calendar_mark_del()
401 * @see elm_calendar_marks_clear()
405 EAPI const Eina_List *elm_calendar_marks_get(const Evas_Object *obj);
408 * Draw calendar marks.
410 * @param obj The calendar object.
412 * Should be used after adding, removing or clearing marks.
413 * It will go through the entire marks list updating the calendar.
414 * If lots of marks will be added, add all the marks and then call
417 * When the month is changed, i.e. user selects next or previous month,
418 * marks will be drawn.
420 * @see elm_calendar_mark_add()
421 * @see elm_calendar_mark_del()
422 * @see elm_calendar_marks_clear()
424 * @ref calendar_example_06
428 EAPI void elm_calendar_marks_draw(Evas_Object *obj);
431 * Set the interval on time updates for an user mouse button hold
432 * on calendar widgets' month selection.
434 * @param obj The calendar object
435 * @param interval The (first) interval value in seconds
437 * This interval value is @b decreased while the user holds the
438 * mouse pointer either selecting next or previous month.
440 * This helps the user to get to a given month distant from the
441 * current one easier/faster, as it will start to change quicker and
442 * quicker on mouse button holds.
444 * The calculation for the next change interval value, starting from
445 * the one set with this call, is the previous interval divided by
446 * 1.05, so it decreases a little bit.
448 * The default starting interval value for automatic changes is
451 * @see elm_calendar_interval_get()
455 EAPI void elm_calendar_interval_set(Evas_Object *obj, double interval);
458 * Get the interval on time updates for an user mouse button hold
459 * on calendar widgets' month selection.
461 * @param obj The calendar object
462 * @return The (first) interval value, in seconds, set on it
464 * @see elm_calendar_interval_set() for more details
468 EAPI double elm_calendar_interval_get(const Evas_Object *obj);
471 * Set the first day of week to use on calendar widgets'.
473 * @param obj The calendar object
474 * @param day An int which correspond to the first day of the week (Sunday = 0, monday = 1,
479 EAPI void elm_calendar_first_day_of_week_set(Evas_Object *obj, Elm_Calendar_Weekday day);
482 * Get the first day of week, who are used on calendar widgets'.
484 * @param obj The calendar object
485 * @return An int which correspond to the first day of the week (Sunday = 0, monday = 1,
488 * @see elm_calendar_first_day_of_week_set() for more details
492 EAPI Elm_Calendar_Weekday elm_calendar_first_day_of_week_get(const Evas_Object *obj);