1 #include <Elementary.h>
7 * A calendar is a widget that allows the user to select a date. It has
8 * support to adding check marks (holidays and checks by default). The calendar
9 * is displayed one month at a time.
11 * Weekday names and the function used to format month and year to
12 * be displayed can be set, giving more flexibility to this widget.
14 * Signals that you can add callbacks for are:
16 * changed - emitted when the user selects a day or changes the displayed
17 * month, what actually changes the selected day as well.
19 typedef struct _Widget_Data Widget_Data;
23 Evas_Object *calendar;
25 double interval, first_interval;
26 int year_min, year_max, spin_speed;
27 int today_it, selected_it, first_day_it;
28 Ecore_Timer *spin, *update_timer;
29 char * (*format_func) (struct tm *stime);
30 const char *weekdays[7];
31 struct tm current_time, selected_time;
32 Eina_Bool selection_enabled : 1;
35 struct _Elm_Calendar_Mark
40 const char *mark_type;
41 Elm_Calendar_Mark_Repeat repeat;
44 static const char *widtype = NULL;
46 static const char *_days_abbrev[] =
48 "Sun", "Mon", "Tue", "Wed",
52 static int _days_in_month[2][12] =
54 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
55 {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
58 static Elm_Calendar_Mark *
59 _mark_new(Evas_Object *obj, const char *mark_type, struct tm *mark_time, Elm_Calendar_Mark_Repeat repeat)
61 Widget_Data *wd = elm_widget_data_get(obj);
62 Elm_Calendar_Mark *mark;
65 mark = calloc(1, sizeof(Elm_Calendar_Mark));
66 if (!mark) return NULL;
68 mark->mark_type = eina_stringshare_add(mark_type);
69 mark->mark_time = *mark_time;
70 mark->repeat = repeat;
75 _mark_free(Elm_Calendar_Mark *mark)
77 eina_stringshare_del(mark->mark_type);
82 _sizing_eval(Evas_Object *obj)
84 Widget_Data *wd = elm_widget_data_get(obj);
85 Evas_Coord minw = -1, minh = -1;
87 elm_coords_finger_size_adjust(8, &minw, 7, &minh);
88 edje_object_size_min_restricted_calc(wd->calendar, &minw, &minh, minw, minh);
89 evas_object_size_hint_min_set(obj, minw, minh);
90 evas_object_size_hint_max_set(obj, -1, -1);
94 _maxdays_get(struct tm *time)
99 year = time->tm_year + 1900;
101 return _days_in_month[(!(year % 4) && (!(year % 400) || (year % 100)))]
106 _unselect(Widget_Data *wd, int selected)
109 snprintf(emission, sizeof(emission), "cit_%i,unselected", selected);
110 edje_object_signal_emit(wd->calendar, emission, "elm");
114 _select(Widget_Data *wd, int selected)
117 snprintf(emission, sizeof(emission), "cit_%i,selected", selected);
118 edje_object_signal_emit(wd->calendar, emission, "elm");
122 _not_today(Widget_Data *wd)
125 snprintf(emission, sizeof(emission), "cit_%i,not_today", wd->today_it);
126 edje_object_signal_emit(wd->calendar, emission, "elm");
131 _today(Widget_Data *wd, int it)
134 snprintf(emission, sizeof(emission), "cit_%i,today", it);
135 edje_object_signal_emit(wd->calendar, emission, "elm");
140 _format_month_year(struct tm *stime)
143 if (!strftime(buf, sizeof(buf), "%B %Y", stime)) return NULL;
148 _cit_mark(Evas_Object *cal, int cit, const char *mtype)
151 snprintf(sign, sizeof(sign), "cit_%i,%s", cit, mtype);
152 edje_object_signal_emit(cal, sign, "elm");
156 _weekday_get(int first_week_day, int day)
158 return (day + first_week_day - 1) % 7;
162 _populate(Evas_Object *obj)
164 int maxdays, day, mon, year, i;
165 Elm_Calendar_Mark *mark;
166 char part[12], day_s[3];
170 Widget_Data *wd = elm_widget_data_get(obj);
174 if (wd->today_it > 0) _not_today(wd);
176 maxdays = _maxdays_get(&wd->selected_time);
177 mon = wd->selected_time.tm_mon;
178 year = wd->selected_time.tm_year;
180 /* Set selected month */
181 buf = wd->format_func(&wd->selected_time);
183 edje_object_part_text_set(wd->calendar, "month_text", buf);
187 edje_object_part_text_set(wd->calendar, "month_text", "");
191 first_day = wd->selected_time;
192 first_day.tm_mday = 1;
195 for (i = 0; i < 42; i++)
197 if ((!day) && (i == first_day.tm_wday))
200 wd->first_day_it = i;
203 if ((day == wd->current_time.tm_mday)
204 && (mon == wd->current_time.tm_mon)
205 && (year == wd->current_time.tm_year))
208 if (day == wd->selected_time.tm_mday)
210 if ((wd->selected_it > -1) && (wd->selected_it != i))
211 _unselect(wd, wd->selected_it);
213 if (wd->selection_enabled) _select(wd, i);
218 if (day && (day <= maxdays))
219 snprintf(day_s, sizeof(day_s), "%d", day++);
223 snprintf(part, sizeof(part), "cit_%i.text", i);
224 edje_object_part_text_set(wd->calendar, part, day_s);
225 /* Clear previous marks */
226 _cit_mark(wd->calendar, i, "clear");
230 EINA_LIST_FOREACH(wd->marks, l, mark)
232 struct tm *mtime = &mark->mark_time;
233 int mon = wd->selected_time.tm_mon;
234 int year = wd->selected_time.tm_year;
235 int mday_it = mtime->tm_mday + wd->first_day_it - 1;
237 switch (mark->repeat)
239 case ELM_CALENDAR_UNIQUE:
240 if ((mtime->tm_mon == mon) && (mtime->tm_year == year))
241 _cit_mark(wd->calendar, mday_it, mark->mark_type);
243 case ELM_CALENDAR_DAILY:
244 if (((mtime->tm_year == year) && (mtime->tm_mon < mon)) ||
245 (mtime->tm_year < year))
247 else if ((mtime->tm_year == year) && (mtime->tm_mon == mon))
248 day = mtime->tm_mday;
251 for (; day <= maxdays; day++)
252 _cit_mark(wd->calendar, day + wd->first_day_it - 1,
255 case ELM_CALENDAR_WEEKLY:
256 if (((mtime->tm_year == year) && (mtime->tm_mon < mon)) ||
257 (mtime->tm_year < year))
259 else if ((mtime->tm_year == year) && (mtime->tm_mon == mon))
260 day = mtime->tm_mday;
263 for (; day <= maxdays; day++)
264 if (mtime->tm_wday == _weekday_get(wd->first_day_it, day))
265 _cit_mark(wd->calendar, day + wd->first_day_it - 1,
268 case ELM_CALENDAR_MONTHLY:
269 if (((mtime->tm_year < year) ||
270 ((mtime->tm_year == year) && (mtime->tm_mon <= mon))) &&
271 (mtime->tm_mday <= maxdays))
272 _cit_mark(wd->calendar, mday_it, mark->mark_type);
274 case ELM_CALENDAR_ANNUALLY:
275 if ((mtime->tm_year <= year) && (mtime->tm_mon == mon) &&
276 (mtime->tm_mday <= maxdays))
277 _cit_mark(wd->calendar, mday_it, mark->mark_type);
284 _set_headers(Evas_Object *obj)
286 static char part[] = "ch_0.text";
288 Widget_Data *wd = elm_widget_data_get(obj);
291 for (i = 0; i < 7; i++)
294 edje_object_part_text_set(wd->calendar, part, wd->weekdays[i]);
299 _del_hook(Evas_Object *obj)
302 Elm_Calendar_Mark *mark;
303 Widget_Data *wd = elm_widget_data_get(obj);
307 if (wd->spin) ecore_timer_del(wd->spin);
308 if (wd->update_timer) ecore_timer_del(wd->update_timer);
311 EINA_LIST_FREE(wd->marks, mark)
316 for (i = 0; i < 7; i++)
317 eina_stringshare_del(wd->weekdays[i]);
323 _theme_hook(Evas_Object *obj)
325 Widget_Data *wd = elm_widget_data_get(obj);
327 _elm_theme_object_set(obj, wd->calendar, "calendar", "base",
328 elm_widget_style_get(obj));
331 edje_object_message_signal_process(wd->calendar);
332 edje_object_scale_set(wd->calendar,
333 elm_widget_scale_get(obj) * _elm_config->scale);
338 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
340 Widget_Data *wd = elm_widget_data_get(obj);
342 edje_object_signal_emit(wd->calendar, emission, source);
346 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
348 Widget_Data *wd = elm_widget_data_get(obj);
350 edje_object_signal_callback_add(wd->calendar, emission,
351 source, func_cb, data);
355 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source))
357 Widget_Data *wd = elm_widget_data_get(obj);
358 if (!wd) return NULL;
359 return edje_object_signal_callback_del(wd->calendar, emission, source,
363 /* Set correct tm_wday and tm_yday after other fields changes*/
365 _fix_selected_time(Widget_Data *wd)
367 mktime(&wd->selected_time);
371 _update_month(Evas_Object *obj, int delta)
373 struct tm time_check;
375 Widget_Data *wd = elm_widget_data_get(obj);
376 if (!wd) return EINA_FALSE;
378 /* check if it's a valid time. for 32 bits, year greater than 2037 is not */
379 time_check = wd->selected_time;
380 time_check.tm_mon += delta;
381 if (mktime(&time_check) == -1)
384 wd->selected_time.tm_mon += delta;
385 if (wd->selected_time.tm_mon < 0)
387 if (wd->selected_time.tm_year == wd->year_min)
389 wd->selected_time.tm_mon++;
392 wd->selected_time.tm_mon = 11;
393 wd->selected_time.tm_year--;
395 else if (wd->selected_time.tm_mon > 11)
397 if (wd->selected_time.tm_year == wd->year_max)
399 wd->selected_time.tm_mon--;
402 wd->selected_time.tm_mon = 0;
403 wd->selected_time.tm_year++;
406 maxdays = _maxdays_get(&wd->selected_time);
407 if (wd->selected_time.tm_mday > maxdays)
408 wd->selected_time.tm_mday = maxdays;
410 _fix_selected_time(wd);
411 evas_object_smart_callback_call(obj, "changed", NULL);
417 _spin_value(void *data)
419 Widget_Data *wd = elm_widget_data_get(data);
420 if (!wd) return ECORE_CALLBACK_CANCEL;
421 if (_update_month(data, wd->spin_speed)) _populate(data);
422 wd->interval = wd->interval / 1.05;
423 ecore_timer_interval_set(wd->spin, wd->interval);
424 return ECORE_CALLBACK_RENEW;
428 _button_inc_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
430 Widget_Data *wd = elm_widget_data_get(data);
432 wd->interval = wd->first_interval;
434 if (wd->spin) ecore_timer_del(wd->spin);
435 wd->spin = ecore_timer_add(wd->interval, _spin_value, data);
440 _button_dec_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
442 Widget_Data *wd = elm_widget_data_get(data);
444 wd->interval = wd->first_interval;
446 if (wd->spin) ecore_timer_del(wd->spin);
447 wd->spin = ecore_timer_add(wd->interval, _spin_value, data);
452 _button_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
454 Widget_Data *wd = elm_widget_data_get(data);
456 wd->interval = wd->first_interval;
457 if (wd->spin) ecore_timer_del(wd->spin);
462 _get_item_day(Evas_Object *obj, int selected_it)
465 Widget_Data *wd = elm_widget_data_get(obj);
468 day = selected_it - wd->first_day_it + 1;
469 if ((day < 0) || (day > _maxdays_get(&wd->selected_time)))
476 _day_selected(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source)
479 Widget_Data *wd = elm_widget_data_get(data);
480 if ((!wd) || (!wd->selection_enabled))
482 sel_it = atoi(source);
483 day = _get_item_day(data, sel_it);
486 _unselect(wd, wd->selected_it);
487 wd->selected_it = sel_it;
488 wd->selected_time.tm_mday = day;
489 _select(wd, wd->selected_it);
490 _fix_selected_time(wd);
491 evas_object_smart_callback_call(data, "changed", NULL);
495 _time_to_next_day(struct tm *t)
497 return (((24 - t->tm_hour) * 60) - t->tm_min) * 60 - t->tm_sec;
501 _update_cur_date(void *data)
505 Widget_Data *wd = elm_widget_data_get(data);
506 if (!wd) return ECORE_CALLBACK_RENEW;
508 if (wd->today_it > 0) _not_today(wd);
510 current_time = time(NULL);
511 localtime_r(¤t_time, &wd->current_time);
512 t = _time_to_next_day(&wd->current_time);
513 ecore_timer_interval_set(wd->update_timer, t);
515 if ((wd->current_time.tm_mon != wd->selected_time.tm_mon) ||
516 (wd->current_time.tm_year!= wd->selected_time.tm_year))
517 return ECORE_CALLBACK_RENEW;
519 day = wd->current_time.tm_mday + wd->first_day_it - 1;
522 return ECORE_CALLBACK_RENEW;
526 * Add a new calendar to the parent
528 * @param parent The parent object
529 * @return The new object or NULL if it cannot be created
534 elm_calendar_add(Evas_Object *parent)
542 wd = ELM_NEW(Widget_Data);
543 e = evas_object_evas_get(parent);
544 obj = elm_widget_add(e);
545 ELM_SET_WIDTYPE(widtype, "calendar");
546 elm_widget_type_set(obj, "calendar");
547 elm_widget_sub_object_add(parent, obj);
548 elm_widget_data_set(obj, wd);
549 elm_widget_del_hook_set(obj, _del_hook);
550 elm_widget_theme_hook_set(obj, _theme_hook);
551 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
552 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
553 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
555 wd->first_interval = 0.85;
559 wd->selected_it = -1;
560 wd->first_day_it = -1;
561 wd->selection_enabled = EINA_TRUE;
562 wd->format_func = _format_month_year;
565 wd->calendar = edje_object_add(e);
566 _elm_theme_object_set(obj, wd->calendar, "calendar", "base", "default");
567 elm_widget_resize_object_set(obj, wd->calendar);
569 edje_object_signal_callback_add(wd->calendar, "elm,action,increment,start",
570 "*", _button_inc_start, obj);
571 edje_object_signal_callback_add(wd->calendar, "elm,action,decrement,start",
572 "*", _button_dec_start, obj);
573 edje_object_signal_callback_add(wd->calendar, "elm,action,stop",
574 "*", _button_stop, obj);
575 edje_object_signal_callback_add(wd->calendar, "elm,action,selected",
576 "*", _day_selected, obj);
578 for (i = 0; i < 7; i++)
579 wd->weekdays[i] = eina_stringshare_add(_days_abbrev[i]);
581 current_time = time(NULL);
582 localtime_r(¤t_time, &wd->selected_time);
583 wd->current_time = wd->selected_time;
584 t = _time_to_next_day(&wd->current_time);
585 wd->update_timer = ecore_timer_add(t, _update_cur_date, obj);
594 * Set weekdays names to display in the calendar.
596 * By default, the following abbreviations are displayed:
597 * "Sun, Mon, Tue, Wed, Thu, Fri, Sat"
598 * The first string should be related to Sunday, the second to Monday...
600 * The usage should be like this:
602 * const char *weekdays[] =
604 * "Sunday", "Monday", "Tuesday", "Wednesday",
605 * "Thursday", "Friday", "Saturday"
607 * elm_calendar_weekdays_names_set(calendar, weekdays);
610 * @param obj The calendar object
611 * @param weedays Array of seven strings to be used as weekday names.
612 * Warning: it must have 7 elements, or it will access invalid memory.
613 * The strings must be NULL terminated ('@\0').
618 elm_calendar_weekdays_names_set(Evas_Object *obj, const char *weekdays[])
621 ELM_CHECK_WIDTYPE(obj, widtype);
622 Widget_Data *wd = elm_widget_data_get(obj);
625 for (i = 0; i < 7; i++)
627 eina_stringshare_replace(&wd->weekdays[i], weekdays[i]);
633 * Get weekdays names displayed in the calendar.
635 * By default, the following abbreviations are displayed:
636 * "Sun, Mon, Tue, Wed, Thu, Fri, Sat"
637 * The first string is related to Sunday, the second to Monday...
639 * @param obj The calendar object
640 * @return Array of seven strings to used as weekday names.
645 elm_calendar_weekdays_names_get(const Evas_Object *obj)
647 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
648 Widget_Data *wd = elm_widget_data_get(obj);
649 if (!wd) return NULL;
654 * Set the interval for the calendar
656 * The interval value is decreased while the user increments or decrements
657 * the calendar value. The next interval value is the previous interval / 1.05,
658 * so it speed up a bit. Default value is 0.85 seconds.
660 * @param obj The calendar object
661 * @param interval The interval value in seconds
666 elm_calendar_interval_set(Evas_Object *obj, double interval)
668 ELM_CHECK_WIDTYPE(obj, widtype);
669 Widget_Data *wd = elm_widget_data_get(obj);
671 wd->first_interval = interval;
675 * Get the interval of the calendar
677 * The interval value is decreased while the user increments or decrements
678 * the calendar value. The next interval value is the previous interval / 1.05,
679 * so it speed up a bit. Default value is 0.85 seconds.
681 * @param obj The calendar object
682 * @return The value of the first interval in seconds
687 elm_calendar_interval_get(const Evas_Object *obj)
689 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
690 Widget_Data *wd = elm_widget_data_get(obj);
692 return wd->first_interval;
696 * Set the minimum and maximum values for the year
698 * Maximum must be greater than minimum, except if you don't wan't to set
700 * Default values are 1902 and -1.
702 * If the maximum year is a negative value, it will be limited depending of the
703 * platform architecture (2037 for 32 bits);
705 * @param obj The calendar object
706 * @param min The minimum year, greater than 1901;
707 * @param max The maximum year;
712 elm_calendar_min_max_year_set(Evas_Object *obj, int min, int max)
714 ELM_CHECK_WIDTYPE(obj, widtype);
715 Widget_Data *wd = elm_widget_data_get(obj);
719 if ((wd->year_min == min) && (wd->year_max == max)) return;
720 wd->year_min = min > 2 ? min : 2;
721 if (wd->selected_time.tm_year > wd->year_max)
722 wd->selected_time.tm_year = wd->year_max;
723 if (wd->selected_time.tm_year < wd->year_min)
724 wd->selected_time.tm_year = wd->year_min;
725 _fix_selected_time(wd);
730 * Get the minimum and maximum values for the year
732 * Default values are 1902 and -1.
734 * If the maximum year is a negative value, it will be limited depending of the
735 * platform architecture (2037 for 32 bits);
737 * @param obj The calendar object
738 * @param min The minimum year
739 * @param max The maximum year
744 elm_calendar_min_max_year_get(const Evas_Object *obj, int *min, int *max)
748 ELM_CHECK_WIDTYPE(obj, widtype);
749 Widget_Data *wd = elm_widget_data_get(obj);
751 if (min) *min = wd->year_min + 1900;
752 if (max) *max = wd->year_max + 1900;
756 * Enable or disable day selection
758 * Enabled by default. If disabled, the user can select months, but not days.
759 * It should be used if you won't need such selection for the widget usage.
761 * @param obj The calendar object
762 * @param enabled Boolean to enable (true) or disable (false) day selection
767 elm_calendar_day_selection_enabled_set(Evas_Object *obj, Eina_Bool enabled)
769 ELM_CHECK_WIDTYPE(obj, widtype);
770 Widget_Data *wd = elm_widget_data_get(obj);
772 wd->selection_enabled = enabled;
774 _select(wd, wd->selected_it);
776 _unselect(wd, wd->selected_it);
780 * Get day selection state
782 * Enabled by default. If disabled, the user can select months, but not days.
783 * It should be used if you won't need such selection for the widget usage.
785 * @param obj The calendar object
786 * @return True if day selection is enabled, or false otherwise. It will
787 * return false if it can't get widget data.
792 elm_calendar_day_selection_enabled_get(const Evas_Object *obj)
794 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
795 Widget_Data *wd = elm_widget_data_get(obj);
796 if (!wd) return EINA_FALSE;
797 return wd->selection_enabled;
803 * Set the time selected, changing the displayed month if needed.
804 * Selected time changes when the user changes the month or select a day.
806 * @param obj The calendar object
807 * @param selected_time A tm struct to represent the selected date
812 elm_calendar_selected_time_set(Evas_Object *obj, struct tm *selected_time)
814 ELM_CHECK_WIDTYPE(obj, widtype);
815 Widget_Data *wd = elm_widget_data_get(obj);
817 wd->selected_time = *selected_time;
825 * Get the time selected by the user.
826 * Selected time changes when the user changes the month or select a day.
828 * @param obj The calendar object
829 * @param selected_time A tm struct to represent the selected date
830 * @return It will return false if it can't get widget data, or true otherwise
835 elm_calendar_selected_time_get(const Evas_Object *obj, struct tm *selected_time)
837 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
838 Widget_Data *wd = elm_widget_data_get(obj);
839 if (!wd) return EINA_FALSE;
840 if (selected_time) *selected_time = wd->selected_time;
845 * Set a function to format the string that will be used to display
848 * By default it uses strftime with "%B %Y" format string.
849 * It should allocate the memory that will be used by the string,
850 * that will be freed by the widget after usage.
851 * A pointer to the string and a pointer to the time struct will be provided.
856 * _format_month_year(struct tm *stime)
859 * if (!strftime(buf, sizeof(buf), "%B %Y", stime)) return NULL;
860 * return strdup(buf);
862 * elm_calendar_format_function_set(calendar, _format_month_year);
865 * @param obj The calendar object
866 * @param format_function Function to set the month-year string given
872 elm_calendar_format_function_set(Evas_Object *obj, char * (*format_function) (struct tm *stime))
874 ELM_CHECK_WIDTYPE(obj, widtype);
875 Widget_Data *wd = elm_widget_data_get(obj);
877 wd->format_func = format_function;
881 * Add a new mark to the calendar
883 * Add a mark that will be drawn in the calendar respecting the insertion time
884 * and periodicity. It will emit the type as signal to the widget theme.
885 * By default, it supports "holiday" and "checked", but it can be extended.
887 * It won't immediately update the calendar, drawing the marks. For this, call
888 * elm_calendar_marks_draw().
892 * struct tm selected_time;
893 * time_t current_time;
895 * current_time = time(NULL) + 5 * 84600;
896 * localtime_r(¤t_time, &selected_time);
897 * elm_calendar_mark_add(cal, "holiday", selected_time, ELM_CALENDAR_ANNUALLY);
899 * current_time = time(NULL) + 1 * 84600;
900 * localtime_r(¤t_time, &selected_time);
901 * elm_calendar_mark_add(cal, "checked", selected_time, ELM_CALENDAR_UNIQUE);
903 * elm_calendar_marks_draw(cal);
906 * @param obj The calendar object
907 * @param mark_type A string used to define the type of mark. It will be
908 * emmitted to the theme, that should display a related modification on these
909 * days representation.
910 * @param mark_time A time struct to represent the date of inclusion of the
911 * mark. For marks that repeats it will just be displayed after the inclusion
912 * date in the calendar.
913 * @param repeat Repeat the event following this periodicity. Can be a unique
914 * mark (that don't repeat), daily, weekly, monthly or annually.
916 * @return The created mark or NULL upon failure
920 EAPI Elm_Calendar_Mark *
921 elm_calendar_mark_add(Evas_Object *obj, const char *mark_type, struct tm *mark_time, Elm_Calendar_Mark_Repeat repeat)
923 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
924 Widget_Data *wd = elm_widget_data_get(obj);
925 Elm_Calendar_Mark *mark;
926 if (!wd) return NULL;
928 mark = _mark_new(obj, mark_type, mark_time, repeat);
929 wd->marks = eina_list_append(wd->marks, mark);
930 mark->node = eina_list_last(wd->marks);
935 * Delete mark from the calendar.
937 * @param mark The mark to delete
942 elm_calendar_mark_del(Elm_Calendar_Mark *mark)
950 wd = elm_widget_data_get(obj);
953 wd->marks = eina_list_remove_list(wd->marks, mark->node);
958 * Remove all the marks from the calendar
960 * @param obj The calendar object
965 elm_calendar_marks_clear(Evas_Object *obj)
967 ELM_CHECK_WIDTYPE(obj, widtype);
968 Widget_Data *wd = elm_widget_data_get(obj);
969 Elm_Calendar_Mark *mark;
972 EINA_LIST_FREE(wd->marks, mark)
977 * Returns a list of all the calendar marks.
979 * @param obj The calendar object
980 * @return An Eina_List* of the calendar marks, or NULL on failure
984 EAPI const Eina_List *
985 elm_calendar_marks_get(const Evas_Object *obj)
987 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
988 Widget_Data *wd = elm_widget_data_get(obj);
989 if (!wd) return NULL;
994 * Draw calendar marks.
996 * Should be used after adding, removing or clearing marks.
997 * It will go through the entire marks list updating the calendar
998 * (not a cheap function). So if lots of marks will be added,
999 * add all the marks and then call this function.
1001 * When the month is changed marks will be drawed.
1003 * @param obj The calendar object
1008 elm_calendar_marks_draw(Evas_Object *obj)
1010 ELM_CHECK_WIDTYPE(obj, widtype);
1011 Widget_Data *wd = elm_widget_data_get(obj);
1017 * Set a text color - blue.
1019 * @param obj The calendar object
1020 * @param pos The text position
1025 elm_calendar_text_saturday_color_set(const Evas_Object *obj, int pos)
1027 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1028 Widget_Data *wd = elm_widget_data_get(obj);
1029 if (!wd) return NULL;
1032 snprintf(emission, sizeof(emission), "cit_%d,saturday", pos);
1033 edje_object_signal_emit(wd->calendar, emission, "elm");
1037 * Set a text color - red.
1039 * @param obj The calendar object
1040 * @param pos The text position
1045 elm_calendar_text_sunday_color_set(const Evas_Object *obj, int pos)
1047 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1048 Widget_Data *wd = elm_widget_data_get(obj);
1049 if (!wd) return NULL;
1052 snprintf(emission, sizeof(emission), "cit_%d,sunday", pos);
1053 edje_object_signal_emit(wd->calendar, emission, "elm");
1057 * Set a text color - black.
1059 * @param obj The calendar object
1060 * @param pos The text position
1065 elm_calendar_text_weekday_color_set(const Evas_Object *obj, int pos)
1067 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1068 Widget_Data *wd = elm_widget_data_get(obj);
1069 if (!wd) return NULL;
1072 snprintf(emission, sizeof(emission), "cit_%d,weekday", pos);
1073 edje_object_signal_emit(wd->calendar, emission, "elm");