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;
64 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(). */
67 * @typedef Elm_Calendar_Format_Cb
69 * This callback type is used to format the string that will be used
70 * to display month and year.
72 * @param stime Struct representing time.
73 * @return String representing time that will be set to calendar's text.
75 * @see elm_calendar_format_function_set()
77 typedef char * (*Elm_Calendar_Format_Cb)(struct tm *stime);
80 * Add a new calendar widget to the given parent Elementary
83 * @param parent The parent object.
84 * @return a new calendar widget handle or @c NULL, on errors.
86 * This function inserts a new calendar widget on the canvas.
88 * @ref calendar_example_01
92 EAPI Evas_Object *elm_calendar_add(Evas_Object *parent);
95 * Get weekdays names displayed by the calendar.
97 * @param obj The calendar object.
98 * @return Array of seven strings to be used as weekday names.
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"
102 * The first string is related to Sunday, the second to Monday...
104 * @see elm_calendar_weekdays_name_set()
106 * @ref calendar_example_05
110 EAPI const char **elm_calendar_weekdays_names_get(const Evas_Object *obj);
113 * Set weekdays names to be displayed by the calendar.
115 * @param obj The calendar object.
116 * @param weekdays Array of seven strings to be used as weekday names.
117 * @warning It must have 7 elements, or it will access invalid memory.
118 * @warning The strings must be NULL terminated ('@\0').
120 * By default, weekdays abbreviations get from system are displayed:
121 * E.g. for an en_US locale: "Sun, Mon, Tue, Wed, Thu, Fri, Sat"
123 * The first string should be related to Sunday, the second to Monday...
125 * The usage should be like this:
127 * const char *weekdays[] =
129 * "Sunday", "Monday", "Tuesday", "Wednesday",
130 * "Thursday", "Friday", "Saturday"
132 * elm_calendar_weekdays_names_set(calendar, weekdays);
135 * @see elm_calendar_weekdays_name_get()
137 * @ref calendar_example_02
141 EAPI void elm_calendar_weekdays_names_set(Evas_Object *obj, const char *weekdays[]);
144 * Set the minimum and maximum values for the year
146 * @param obj The calendar object
147 * @param min The minimum year, greater than 1901;
148 * @param max The maximum year;
150 * Maximum must be greater than minimum, except if you don't want to set
152 * Default values are 1902 and -1.
154 * If the maximum year is a negative value, it will be limited depending
155 * on the platform architecture (year 2037 for 32 bits);
157 * @see elm_calendar_min_max_year_get()
159 * @ref calendar_example_03
163 EAPI void elm_calendar_min_max_year_set(Evas_Object *obj, int min, int max);
166 * Get the minimum and maximum values for the year
168 * @param obj The calendar object.
169 * @param min The minimum year.
170 * @param max The maximum year.
172 * Default values are 1902 and -1.
174 * @see elm_calendar_min_max_year_get() for more details.
176 * @ref calendar_example_05
180 EAPI void elm_calendar_min_max_year_get(const Evas_Object *obj, int *min, int *max);
183 * Enable or disable day selection
185 * @param obj The calendar object.
186 * @param disabled @c EINA_TRUE to disable selection or @c EINA_FALSE to
189 * Enabled by default. If disabled, the user still can select months,
190 * but not days. Selected days are highlighted on calendar.
191 * It should be used if you won't need such selection for the widget usage.
193 * When a day is selected, or month is changed, smart callbacks for
194 * signal "changed" will be called.
196 * @see elm_calendar_day_selection_disabled_get()
198 * @ref calendar_example_04
202 EAPI void elm_calendar_day_selection_disabled_set(Evas_Object *obj, Eina_Bool disabled);
205 * Get a value whether day selection is disabled or not.
207 * @param obj The calendar object.
208 * @return EINA_TRUE means day selection is disabled. EINA_FALSE indicates
209 * it's enabled. If @p obj is NULL, EINA_FALSE is returned.
211 * @see elm_calendar_day_selection_disabled_set() for details.
213 * @ref calendar_example_05
217 EAPI Eina_Bool elm_calendar_day_selection_disabled_get(const Evas_Object *obj);
220 * Set selected date to be highlighted on calendar.
222 * @param obj The calendar object.
223 * @param selected_time A @b tm struct to represent the selected date.
225 * Set the selected date, changing the displayed month if needed.
226 * Selected date changes when the user goes to next/previous month or
227 * select a day pressing over it on calendar.
229 * @see elm_calendar_selected_time_get()
231 * @ref calendar_example_04
235 EAPI void elm_calendar_selected_time_set(Evas_Object *obj, struct tm *selected_time);
240 * @param obj The calendar object
241 * @param selected_time A @b tm struct to point to selected date
242 * @return EINA_FALSE means an error occurred and returned time shouldn't
245 * Get date selected by the user or set by function
246 * elm_calendar_selected_time_set().
247 * Selected date changes when the user goes to next/previous month or
248 * select a day pressing over it on calendar.
250 * @see elm_calendar_selected_time_get()
252 * @ref calendar_example_05
256 EAPI Eina_Bool elm_calendar_selected_time_get(const Evas_Object *obj, struct tm *selected_time);
259 * Set a function to format the string that will be used to display
262 * @param obj The calendar object
263 * @param format_func Function to set the month-year string given
266 * By default it uses strftime with "%B %Y" format string.
267 * It should allocate the memory that will be used by the string,
268 * that will be freed by the widget after usage.
269 * A pointer to the string and a pointer to the time struct will be provided.
274 * _format_month_year(struct tm *selected_time)
277 * if (!strftime(buf, sizeof(buf), "%B %Y", selected_time)) return NULL;
278 * return strdup(buf);
281 * elm_calendar_format_function_set(calendar, _format_month_year);
284 * @ref calendar_example_02
288 EAPI void elm_calendar_format_function_set(Evas_Object *obj, Elm_Calendar_Format_Cb format_func);
291 * Add a new mark to the calendar
293 * @param obj The calendar object
294 * @param mark_type A string used to define the type of mark. It will be
295 * emitted to the theme, that should display a related modification on these
296 * days representation.
297 * @param mark_time A time struct to represent the date of inclusion of the
298 * mark. For marks that repeats it will just be displayed after the inclusion
299 * date in the calendar.
300 * @param repeat Repeat the event following this periodicity. Can be a unique
301 * mark (that don't repeat), daily, weekly, monthly or annually.
302 * @return The created mark or @p NULL upon failure.
304 * Add a mark that will be drawn in the calendar respecting the insertion
305 * time and periodicity. It will emit the type as signal to the widget theme.
306 * Default theme supports "holiday" and "checked", but it can be extended.
308 * It won't immediately update the calendar, drawing the marks.
309 * For this, call elm_calendar_marks_draw(). However, when user selects
310 * next or previous month calendar forces marks drawn.
312 * Marks created with this method can be deleted with
313 * elm_calendar_mark_del().
317 * struct tm selected_time;
318 * time_t current_time;
320 * current_time = time(NULL) + 5 * 84600;
321 * localtime_r(¤t_time, &selected_time);
322 * elm_calendar_mark_add(cal, "holiday", selected_time,
323 * ELM_CALENDAR_ANNUALLY);
325 * current_time = time(NULL) + 1 * 84600;
326 * localtime_r(¤t_time, &selected_time);
327 * elm_calendar_mark_add(cal, "checked", selected_time, ELM_CALENDAR_UNIQUE);
329 * elm_calendar_marks_draw(cal);
332 * @see elm_calendar_marks_draw()
333 * @see elm_calendar_mark_del()
335 * @ref calendar_example_06
339 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);
342 * Delete mark from the calendar.
344 * @param mark The mark to be deleted.
346 * If deleting all calendar marks is required, elm_calendar_marks_clear()
347 * should be used instead of getting marks list and deleting each one.
349 * @see elm_calendar_mark_add()
351 * @ref calendar_example_06
355 EAPI void elm_calendar_mark_del(Elm_Calendar_Mark *mark);
358 * Remove all calendar's marks
360 * @param obj The calendar object.
362 * @see elm_calendar_mark_add()
363 * @see elm_calendar_mark_del()
367 EAPI void elm_calendar_marks_clear(Evas_Object *obj);
370 * Get a list of all the calendar marks.
372 * @param obj The calendar object.
373 * @return An @c Eina_List of calendar marks objects, or @c NULL on failure.
375 * @see elm_calendar_mark_add()
376 * @see elm_calendar_mark_del()
377 * @see elm_calendar_marks_clear()
381 EAPI const Eina_List *elm_calendar_marks_get(const Evas_Object *obj);
384 * Draw calendar marks.
386 * @param obj The calendar object.
388 * Should be used after adding, removing or clearing marks.
389 * It will go through the entire marks list updating the calendar.
390 * If lots of marks will be added, add all the marks and then call
393 * When the month is changed, i.e. user selects next or previous month,
394 * marks will be drawn.
396 * @see elm_calendar_mark_add()
397 * @see elm_calendar_mark_del()
398 * @see elm_calendar_marks_clear()
400 * @ref calendar_example_06
404 EAPI void elm_calendar_marks_draw(Evas_Object *obj);
407 * Set the interval on time updates for an user mouse button hold
408 * on calendar widgets' month selection.
410 * @param obj The calendar object
411 * @param interval The (first) interval value in seconds
413 * This interval value is @b decreased while the user holds the
414 * mouse pointer either selecting next or previous month.
416 * This helps the user to get to a given month distant from the
417 * current one easier/faster, as it will start to change quicker and
418 * quicker on mouse button holds.
420 * The calculation for the next change interval value, starting from
421 * the one set with this call, is the previous interval divided by
422 * 1.05, so it decreases a little bit.
424 * The default starting interval value for automatic changes is
427 * @see elm_calendar_interval_get()
431 EAPI void elm_calendar_interval_set(Evas_Object *obj, double interval);
434 * Get the interval on time updates for an user mouse button hold
435 * on calendar widgets' month selection.
437 * @param obj The calendar object
438 * @return The (first) interval value, in seconds, set on it
440 * @see elm_calendar_interval_set() for more details
444 EAPI double elm_calendar_interval_get(const Evas_Object *obj);
447 * Set the first day of week to use on calendar widgets'.
449 * @param obj The calendar object
450 * @param day An int which correspond to the first day of the week (Sunday = 0, monday = 1,
455 EAPI void elm_calendar_first_day_of_week_set(Evas_Object *obj, int day);
458 * Get the first day of week, who are used on calendar widgets'.
460 * @param obj The calendar object
461 * @return An int which correspond to the first day of the week (Sunday = 0, monday = 1,
464 * @see elm_calendar_first_day_of_week_set() for more details
468 EAPI int elm_calendar_first_day_of_week_get(const Evas_Object *obj);