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 * @typedef Elm_Calendar_Format_Cb
62 * This callback type is used to format the string that will be used
63 * to display month and year.
65 * @param stime Struct representing time.
66 * @return String represeting time that will be set to calendar's text.
68 * @see elm_calendar_format_function_set()
70 typedef char * (*Elm_Calendar_Format_Cb)(struct tm *stime);
73 * Add a new calendar widget to the given parent Elementary
76 * @param parent The parent object.
77 * @return a new calendar widget handle or @c NULL, on errors.
79 * This function inserts a new calendar widget on the canvas.
81 * @ref calendar_example_01
85 EAPI Evas_Object *elm_calendar_add(Evas_Object *parent);
88 * Get weekdays names displayed by the calendar.
90 * @param obj The calendar object.
91 * @return Array of seven strings to be used as weekday names.
93 * By default, weekdays abbreviations get from system are displayed:
94 * E.g. for an en_US locale: "Sun, Mon, Tue, Wed, Thu, Fri, Sat"
95 * The first string is related to Sunday, the second to Monday...
97 * @see elm_calendar_weekdays_name_set()
99 * @ref calendar_example_05
103 EAPI const char **elm_calendar_weekdays_names_get(const Evas_Object *obj);
106 * Set weekdays names to be displayed by the calendar.
108 * @param obj The calendar object.
109 * @param weekdays Array of seven strings to be used as weekday names.
110 * @warning It must have 7 elements, or it will access invalid memory.
111 * @warning The strings must be NULL terminated ('@\0').
113 * By default, weekdays abbreviations get from system are displayed:
114 * E.g. for an en_US locale: "Sun, Mon, Tue, Wed, Thu, Fri, Sat"
116 * The first string should be related to Sunday, the second to Monday...
118 * The usage should be like this:
120 * const char *weekdays[] =
122 * "Sunday", "Monday", "Tuesday", "Wednesday",
123 * "Thursday", "Friday", "Saturday"
125 * elm_calendar_weekdays_names_set(calendar, weekdays);
128 * @see elm_calendar_weekdays_name_get()
130 * @ref calendar_example_02
134 EAPI void elm_calendar_weekdays_names_set(Evas_Object *obj, const char *weekdays[]);
137 * Set the minimum and maximum values for the year
139 * @param obj The calendar object
140 * @param min The minimum year, greater than 1901;
141 * @param max The maximum year;
143 * Maximum must be greater than minimum, except if you don't want to set
145 * Default values are 1902 and -1.
147 * If the maximum year is a negative value, it will be limited depending
148 * on the platform architecture (year 2037 for 32 bits);
150 * @see elm_calendar_min_max_year_get()
152 * @ref calendar_example_03
156 EAPI void elm_calendar_min_max_year_set(Evas_Object *obj, int min, int max);
159 * Get the minimum and maximum values for the year
161 * @param obj The calendar object.
162 * @param min The minimum year.
163 * @param max The maximum year.
165 * Default values are 1902 and -1.
167 * @see elm_calendar_min_max_year_get() for more details.
169 * @ref calendar_example_05
173 EAPI void elm_calendar_min_max_year_get(const Evas_Object *obj, int *min, int *max);
176 * Enable or disable day selection
178 * @param obj The calendar object.
179 * @param disabled @c EINA_TRUE to disable selection or @c EINA_FALSE to
182 * Enabled by default. If disabled, the user still can select months,
183 * but not days. Selected days are highlighted on calendar.
184 * It should be used if you won't need such selection for the widget usage.
186 * When a day is selected, or month is changed, smart callbacks for
187 * signal "changed" will be called.
189 * @see elm_calendar_day_selection_disabled_get()
191 * @ref calendar_example_04
195 EAPI void elm_calendar_day_selection_disabled_set(Evas_Object *obj, Eina_Bool disabled);
198 * Get a value whether day selection is disabled or not.
200 * @param obj The calendar object.
201 * @return EINA_TRUE means day selection is disabled. EINA_FALSE indicates
202 * it's enabled. If @p obj is NULL, EINA_FALSE is returned.
204 * @see elm_calendar_day_selection_disabled_set() for details.
206 * @ref calendar_example_05
210 EAPI Eina_Bool elm_calendar_day_selection_disabled_get(const Evas_Object *obj);
213 * Set selected date to be highlighted on calendar.
215 * @param obj The calendar object.
216 * @param selected_time A @b tm struct to represent the selected date.
218 * Set the selected date, changing the displayed month if needed.
219 * Selected date changes when the user goes to next/previous month or
220 * select a day pressing over it on calendar.
222 * @see elm_calendar_selected_time_get()
224 * @ref calendar_example_04
228 EAPI void elm_calendar_selected_time_set(Evas_Object *obj, struct tm *selected_time);
233 * @param obj The calendar object
234 * @param selected_time A @b tm struct to point to selected date
235 * @return EINA_FALSE means an error occurred and returned time shouldn't
238 * Get date selected by the user or set by function
239 * elm_calendar_selected_time_set().
240 * Selected date changes when the user goes to next/previous month or
241 * select a day pressing over it on calendar.
243 * @see elm_calendar_selected_time_get()
245 * @ref calendar_example_05
249 EAPI Eina_Bool elm_calendar_selected_time_get(const Evas_Object *obj, struct tm *selected_time);
252 * Set a function to format the string that will be used to display
255 * @param obj The calendar object
256 * @param format_function Function to set the month-year string given
259 * By default it uses strftime with "%B %Y" format string.
260 * It should allocate the memory that will be used by the string,
261 * that will be freed by the widget after usage.
262 * A pointer to the string and a pointer to the time struct will be provided.
267 * _format_month_year(struct tm *selected_time)
270 * if (!strftime(buf, sizeof(buf), "%B %Y", selected_time)) return NULL;
271 * return strdup(buf);
274 * elm_calendar_format_function_set(calendar, _format_month_year);
277 * @ref calendar_example_02
281 EAPI void elm_calendar_format_function_set(Evas_Object *obj, Elm_Calendar_Format_Cb format_func);
284 * Add a new mark to the calendar
286 * @param obj The calendar object
287 * @param mark_type A string used to define the type of mark. It will be
288 * emitted to the theme, that should display a related modification on these
289 * days representation.
290 * @param mark_time A time struct to represent the date of inclusion of the
291 * mark. For marks that repeats it will just be displayed after the inclusion
292 * date in the calendar.
293 * @param repeat Repeat the event following this periodicity. Can be a unique
294 * mark (that don't repeat), daily, weekly, monthly or annually.
295 * @return The created mark or @p NULL upon failure.
297 * Add a mark that will be drawn in the calendar respecting the insertion
298 * time and periodicity. It will emit the type as signal to the widget theme.
299 * Default theme supports "holiday" and "checked", but it can be extended.
301 * It won't immediately update the calendar, drawing the marks.
302 * For this, call elm_calendar_marks_draw(). However, when user selects
303 * next or previous month calendar forces marks drawn.
305 * Marks created with this method can be deleted with
306 * elm_calendar_mark_del().
310 * struct tm selected_time;
311 * time_t current_time;
313 * current_time = time(NULL) + 5 * 84600;
314 * localtime_r(¤t_time, &selected_time);
315 * elm_calendar_mark_add(cal, "holiday", selected_time,
316 * ELM_CALENDAR_ANNUALLY);
318 * current_time = time(NULL) + 1 * 84600;
319 * localtime_r(¤t_time, &selected_time);
320 * elm_calendar_mark_add(cal, "checked", selected_time, ELM_CALENDAR_UNIQUE);
322 * elm_calendar_marks_draw(cal);
325 * @see elm_calendar_marks_draw()
326 * @see elm_calendar_mark_del()
328 * @ref calendar_example_06
332 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);
335 * Delete mark from the calendar.
337 * @param mark The mark to be deleted.
339 * If deleting all calendar marks is required, elm_calendar_marks_clear()
340 * should be used instead of getting marks list and deleting each one.
342 * @see elm_calendar_mark_add()
344 * @ref calendar_example_06
348 EAPI void elm_calendar_mark_del(Elm_Calendar_Mark *mark);
351 * Remove all calendar's marks
353 * @param obj The calendar object.
355 * @see elm_calendar_mark_add()
356 * @see elm_calendar_mark_del()
360 EAPI void elm_calendar_marks_clear(Evas_Object *obj);
363 * Get a list of all the calendar marks.
365 * @param obj The calendar object.
366 * @return An @c Eina_List of calendar marks objects, or @c NULL on failure.
368 * @see elm_calendar_mark_add()
369 * @see elm_calendar_mark_del()
370 * @see elm_calendar_marks_clear()
374 EAPI const Eina_List *elm_calendar_marks_get(const Evas_Object *obj);
377 * Draw calendar marks.
379 * @param obj The calendar object.
381 * Should be used after adding, removing or clearing marks.
382 * It will go through the entire marks list updating the calendar.
383 * If lots of marks will be added, add all the marks and then call
386 * When the month is changed, i.e. user selects next or previous month,
387 * marks will be drawn.
389 * @see elm_calendar_mark_add()
390 * @see elm_calendar_mark_del()
391 * @see elm_calendar_marks_clear()
393 * @ref calendar_example_06
397 EAPI void elm_calendar_marks_draw(Evas_Object *obj);
400 * Set the interval on time updates for an user mouse button hold
401 * on calendar widgets' month selection.
403 * @param obj The calendar object
404 * @param interval The (first) interval value in seconds
406 * This interval value is @b decreased while the user holds the
407 * mouse pointer either selecting next or previous month.
409 * This helps the user to get to a given month distant from the
410 * current one easier/faster, as it will start to change quicker and
411 * quicker on mouse button holds.
413 * The calculation for the next change interval value, starting from
414 * the one set with this call, is the previous interval divided by
415 * 1.05, so it decreases a little bit.
417 * The default starting interval value for automatic changes is
420 * @see elm_calendar_interval_get()
424 EAPI void elm_calendar_interval_set(Evas_Object *obj, double interval);
427 * Get the interval on time updates for an user mouse button hold
428 * on calendar widgets' month selection.
430 * @param obj The calendar object
431 * @return The (first) interval value, in seconds, set on it
433 * @see elm_calendar_interval_set() for more details
437 EAPI double elm_calendar_interval_get(const Evas_Object *obj);