2 * @defgroup Calendar Calendar
5 * This is a Calendar widget. Calender widget helps applications to flexibly
6 * display a calender with day of the week, day, year and month. Applications will be
7 * able to choose a specific date that will be reported in the smart_callbacks for
8 * the calendar widget. The APIs of calendar widget let the applications perform
9 * other functions like,
10 * placing marks on specific dates
11 * Setting the bounds for the calendar (minimum and maximum years)
12 * Setting the day names of the week. ( for ex. Thu. or Thursday)
13 * Setting the year and month format.
15 * Signals that you can add callbacks for are:
16 * - @c "changed" - emitted when the date in the calendar is changed.
18 * Supported elm_object common APIs.
19 * @li @ref elm_object_signal_emit
20 * @li @ref elm_object_signal_callback_add
21 * @li @ref elm_object_signal_callback_del
23 * Here is some sample code using it:
24 * @li @ref calendar_example_01
25 * @li @ref calendar_example_02
26 * @li @ref calendar_example_03
27 * @li @ref calendar_example_04
28 * @li @ref calendar_example_05
29 * @li @ref calendar_example_06
33 * @addtogroup Calendar
39 ELM_CALENDAR_UNIQUE, /**< Default value. Marks will be displayed only on event day. */
40 ELM_CALENDAR_DAILY, /**< Marks will be displayed every day after event day (inclusive). */
41 ELM_CALENDAR_WEEKLY, /**< Marks will be displayed every week after event day (inclusive) - i.e. each seven days. */
42 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*/
43 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. */
44 } _Elm_Calendar_Mark_Repeat_Type;
47 * @enum _Elm_Calendar_Mark_Repeat_Type
48 * @typedef Elm_Calendar_Mark_Repeat_Type
50 * Event periodicity, used to define if a mark should be repeated
51 * @b beyond event's day. It's set when a mark is added.
53 * So, for a mark added to 13th May with periodicity set to WEEKLY,
54 * there will be marks every week after this date. Marks will be displayed
55 * at 13th, 20th, 27th, 3rd June ...
57 * Values don't work as bitmask, only one can be chosen.
59 * @see elm_calendar_mark_add()
63 typedef _Elm_Calendar_Mark_Repeat_Type Elm_Calendar_Mark_Repeat_Type;
75 } _Elm_Calendar_Weekday;
78 * @enum _Elm_Calendar_Weekday
79 * @typedef Elm_Calendar_Weekday
83 * @see elm_calendar_first_day_of_week_set()
87 typedef _Elm_Calendar_Weekday Elm_Calendar_Weekday;
89 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(). */
92 * @typedef Elm_Calendar_Format_Cb
94 * This callback type is used to format the string that will be used
95 * to display month and year.
97 * @param stime Struct representing time.
98 * @return String representing time that will be set to calendar's text.
100 * @see elm_calendar_format_function_set()
104 typedef char * (*Elm_Calendar_Format_Cb)(struct tm *stime);
107 * Add a new calendar widget to the given parent Elementary
108 * (container) object.
110 * @param parent The parent object.
111 * @return a new calendar widget handle or @c NULL, on errors.
113 * This function inserts a new calendar widget on the canvas.
115 * @ref calendar_example_01
119 EAPI Evas_Object *elm_calendar_add(Evas_Object *parent);
122 * Get weekdays names displayed by the calendar.
124 * @param obj The calendar object.
125 * @return Array of seven strings to be used as weekday names.
127 * By default, weekdays abbreviations get from system are displayed:
128 * E.g. for an en_US locale: "Sun, Mon, Tue, Wed, Thu, Fri, Sat"
129 * The first string is related to Sunday, the second to Monday...
131 * @see elm_calendar_weekdays_name_set()
133 * @ref calendar_example_05
137 EAPI const char **elm_calendar_weekdays_names_get(const Evas_Object *obj);
140 * Set weekdays names to be displayed by the calendar.
142 * @param obj The calendar object.
143 * @param weekdays Array of seven strings to be used as weekday names.
144 * @warning It must have 7 elements, or it will access invalid memory.
145 * @warning The strings must be NULL terminated ('@\0').
147 * By default, weekdays abbreviations get from system are displayed:
148 * E.g. for an en_US locale: "Sun, Mon, Tue, Wed, Thu, Fri, Sat"
150 * The first string should be related to Sunday, the second to Monday...
152 * The usage should be like this:
154 * const char *weekdays[] =
156 * "Sunday", "Monday", "Tuesday", "Wednesday",
157 * "Thursday", "Friday", "Saturday"
159 * elm_calendar_weekdays_names_set(calendar, weekdays);
162 * @see elm_calendar_weekdays_name_get()
164 * @ref calendar_example_02
168 EAPI void elm_calendar_weekdays_names_set(Evas_Object *obj, const char *weekdays[]);
171 * Set the minimum and maximum values for the year
173 * @param obj The calendar object
174 * @param min The minimum year, greater than 1901;
175 * @param max The maximum year;
177 * Maximum must be greater than minimum, except if you don't want to set
179 * Default values are 1902 and -1.
181 * If the maximum year is a negative value, it will be limited depending
182 * on the platform architecture (year 2037 for 32 bits);
184 * @see elm_calendar_min_max_year_get()
186 * @ref calendar_example_03
190 EAPI void elm_calendar_min_max_year_set(Evas_Object *obj, int min, int max);
193 * Get the minimum and maximum values for the year
195 * @param obj The calendar object.
196 * @param min The minimum year.
197 * @param max The maximum year.
199 * Default values are 1902 and -1.
201 * @see elm_calendar_min_max_year_get() for more details.
203 * @ref calendar_example_05
207 EAPI void elm_calendar_min_max_year_get(const Evas_Object *obj, int *min, int *max);
210 * Enable or disable day selection
212 * @param obj The calendar object.
213 * @param disabled @c EINA_TRUE to disable selection or @c EINA_FALSE to
216 * Enabled by default. If disabled, the user still can select months,
217 * but not days. Selected days are highlighted on calendar.
218 * It should be used if you won't need such selection for the widget usage.
220 * When a day is selected, or month is changed, smart callbacks for
221 * signal "changed" will be called.
223 * @see elm_calendar_day_selection_disabled_get()
225 * @ref calendar_example_04
229 EAPI void elm_calendar_day_selection_disabled_set(Evas_Object *obj, Eina_Bool disabled);
232 * Get a value whether day selection is disabled or not.
234 * @param obj The calendar object.
235 * @return EINA_TRUE means day selection is disabled. EINA_FALSE indicates
236 * it's enabled. If @p obj is NULL, EINA_FALSE is returned.
238 * @see elm_calendar_day_selection_disabled_set() for details.
240 * @ref calendar_example_05
244 EAPI Eina_Bool elm_calendar_day_selection_disabled_get(const Evas_Object *obj);
247 * Set selected date to be highlighted on calendar.
249 * @param obj The calendar object.
250 * @param selected_time A @b tm struct to represent the selected date.
252 * Set the selected date, changing the displayed month if needed.
253 * Selected date changes when the user goes to next/previous month or
254 * select a day pressing over it on calendar.
256 * @see elm_calendar_selected_time_get()
258 * @ref calendar_example_04
262 EAPI void elm_calendar_selected_time_set(Evas_Object *obj, struct tm *selected_time);
267 * @param obj The calendar object
268 * @param selected_time A @b tm struct to point to selected date
269 * @return EINA_FALSE means an error occurred and returned time shouldn't
272 * Get date selected by the user or set by function
273 * elm_calendar_selected_time_set().
274 * Selected date changes when the user goes to next/previous month or
275 * select a day pressing over it on calendar.
277 * @see elm_calendar_selected_time_get()
279 * @ref calendar_example_05
283 EAPI Eina_Bool elm_calendar_selected_time_get(const Evas_Object *obj, struct tm *selected_time);
286 * Set a function to format the string that will be used to display
289 * @param obj The calendar object
290 * @param format_func Function to set the month-year string given
293 * By default it uses strftime with "%B %Y" format string.
294 * It should allocate the memory that will be used by the string,
295 * that will be freed by the widget after usage.
296 * A pointer to the string and a pointer to the time struct will be provided.
301 * _format_month_year(struct tm *selected_time)
304 * if (!strftime(buf, sizeof(buf), "%B %Y", selected_time)) return NULL;
305 * return strdup(buf);
308 * elm_calendar_format_function_set(calendar, _format_month_year);
311 * @ref calendar_example_02
315 EAPI void elm_calendar_format_function_set(Evas_Object *obj, Elm_Calendar_Format_Cb format_func);
318 * Add a new mark to the calendar
320 * @param obj The calendar object
321 * @param mark_type A string used to define the type of mark. It will be
322 * emitted to the theme, that should display a related modification on these
323 * days representation.
324 * @param mark_time A time struct to represent the date of inclusion of the
325 * mark. For marks that repeats it will just be displayed after the inclusion
326 * date in the calendar.
327 * @param repeat Repeat the event following this periodicity. Can be a unique
328 * mark (that don't repeat), daily, weekly, monthly or annually.
329 * @return The created mark or @p NULL upon failure.
331 * Add a mark that will be drawn in the calendar respecting the insertion
332 * time and periodicity. It will emit the type as signal to the widget theme.
333 * Default theme supports "holiday" and "checked", but it can be extended.
335 * It won't immediately update the calendar, drawing the marks.
336 * For this, call elm_calendar_marks_draw(). However, when user selects
337 * next or previous month calendar forces marks drawn.
339 * Marks created with this method can be deleted with
340 * elm_calendar_mark_del().
344 * struct tm selected_time;
345 * time_t current_time;
347 * current_time = time(NULL) + 5 * 84600;
348 * localtime_r(¤t_time, &selected_time);
349 * elm_calendar_mark_add(cal, "holiday", selected_time,
350 * ELM_CALENDAR_ANNUALLY);
352 * current_time = time(NULL) + 1 * 84600;
353 * localtime_r(¤t_time, &selected_time);
354 * elm_calendar_mark_add(cal, "checked", selected_time, ELM_CALENDAR_UNIQUE);
356 * elm_calendar_marks_draw(cal);
359 * @see elm_calendar_marks_draw()
360 * @see elm_calendar_mark_del()
362 * @ref calendar_example_06
366 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);
369 * Delete mark from the calendar.
371 * @param mark The mark to be deleted.
373 * If deleting all calendar marks is required, elm_calendar_marks_clear()
374 * should be used instead of getting marks list and deleting each one.
376 * @see elm_calendar_mark_add()
378 * @ref calendar_example_06
382 EAPI void elm_calendar_mark_del(Elm_Calendar_Mark *mark);
385 * Remove all calendar's marks
387 * @param obj The calendar object.
389 * @see elm_calendar_mark_add()
390 * @see elm_calendar_mark_del()
394 EAPI void elm_calendar_marks_clear(Evas_Object *obj);
397 * Get a list of all the calendar marks.
399 * @param obj The calendar object.
400 * @return An @c Eina_List of calendar marks objects, or @c NULL on failure.
402 * @see elm_calendar_mark_add()
403 * @see elm_calendar_mark_del()
404 * @see elm_calendar_marks_clear()
408 EAPI const Eina_List *elm_calendar_marks_get(const Evas_Object *obj);
411 * Draw calendar marks.
413 * @param obj The calendar object.
415 * Should be used after adding, removing or clearing marks.
416 * It will go through the entire marks list updating the calendar.
417 * If lots of marks will be added, add all the marks and then call
420 * When the month is changed, i.e. user selects next or previous month,
421 * marks will be drawn.
423 * @see elm_calendar_mark_add()
424 * @see elm_calendar_mark_del()
425 * @see elm_calendar_marks_clear()
427 * @ref calendar_example_06
431 EAPI void elm_calendar_marks_draw(Evas_Object *obj);
434 * Set the interval on time updates for an user mouse button hold
435 * on calendar widgets' month selection.
437 * @param obj The calendar object
438 * @param interval The (first) interval value in seconds
440 * This interval value is @b decreased while the user holds the
441 * mouse pointer either selecting next or previous month.
443 * This helps the user to get to a given month distant from the
444 * current one easier/faster, as it will start to change quicker and
445 * quicker on mouse button holds.
447 * The calculation for the next change interval value, starting from
448 * the one set with this call, is the previous interval divided by
449 * 1.05, so it decreases a little bit.
451 * The default starting interval value for automatic changes is
454 * @see elm_calendar_interval_get()
458 EAPI void elm_calendar_interval_set(Evas_Object *obj, double interval);
461 * Get the interval on time updates for an user mouse button hold
462 * on calendar widgets' month selection.
464 * @param obj The calendar object
465 * @return The (first) interval value, in seconds, set on it
467 * @see elm_calendar_interval_set() for more details
471 EAPI double elm_calendar_interval_get(const Evas_Object *obj);
474 * Set the first day of week to use on calendar widgets'.
476 * @param obj The calendar object
477 * @param day An int which correspond to the first day of the week (Sunday = 0, monday = 1,
482 EAPI void elm_calendar_first_day_of_week_set(Evas_Object *obj, Elm_Calendar_Weekday day);
485 * Get the first day of week, who are used on calendar widgets'.
487 * @param obj The calendar object
488 * @return An int which correspond to the first day of the week (Sunday = 0, monday = 1,
491 * @see elm_calendar_first_day_of_week_set() for more details
495 EAPI Elm_Calendar_Weekday elm_calendar_first_day_of_week_get(const Evas_Object *obj);