2 # include "elementary_config.h"
9 #include <Elementary.h>
12 typedef enum _Day_Color // EINA_DEPRECATED
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 *selected_time);
30 const char *weekdays[7];
31 struct tm current_time, selected_time;
32 Day_Color day_color[42]; // EINA_DEPRECATED
33 Eina_Bool selection_enabled : 1;
36 struct _Elm_Calendar_Mark
41 const char *mark_type;
42 Elm_Calendar_Mark_Repeat repeat;
45 static const char *widtype = NULL;
46 static void _on_focus_hook(void *data, Evas_Object *obj);
47 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
49 static const char SIG_CHANGED[] = "changed";
51 static const Evas_Smart_Cb_Description _signals[] = {
57 /* Should not be translated, it's used if we failed
58 * getting from locale. */
59 static const char *_days_abbrev[] =
61 "Sun", "Mon", "Tue", "Wed",
65 static int _days_in_month[2][12] =
67 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
68 {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
71 static Elm_Calendar_Mark *
72 _mark_new(Evas_Object *obj, const char *mark_type, struct tm *mark_time, Elm_Calendar_Mark_Repeat repeat)
74 Widget_Data *wd = elm_widget_data_get(obj);
75 Elm_Calendar_Mark *mark;
78 mark = calloc(1, sizeof(Elm_Calendar_Mark));
79 if (!mark) return NULL;
81 mark->mark_type = eina_stringshare_add(mark_type);
82 mark->mark_time = *mark_time;
83 mark->repeat = repeat;
88 _mark_free(Elm_Calendar_Mark *mark)
90 eina_stringshare_del(mark->mark_type);
95 _sizing_eval(Evas_Object *obj)
97 Widget_Data *wd = elm_widget_data_get(obj);
98 Evas_Coord minw = -1, minh = -1;
100 elm_coords_finger_size_adjust(8, &minw, 7, &minh);
101 edje_object_size_min_restricted_calc(wd->calendar, &minw, &minh, minw, minh);
102 evas_object_size_hint_min_set(obj, minw, minh);
103 evas_object_size_hint_max_set(obj, -1, -1);
107 _maxdays_get(struct tm *selected_time)
111 month = selected_time->tm_mon;
112 year = selected_time->tm_year + 1900;
114 return _days_in_month[((!(year % 4)) &&
121 _unselect(Widget_Data *wd, int selected)
124 snprintf(emission, sizeof(emission), "cit_%i,unselected", selected);
125 edje_object_signal_emit(wd->calendar, emission, "elm");
129 _select(Widget_Data *wd, int selected)
132 snprintf(emission, sizeof(emission), "cit_%i,selected", selected);
133 edje_object_signal_emit(wd->calendar, emission, "elm");
137 _not_today(Widget_Data *wd)
140 snprintf(emission, sizeof(emission), "cit_%i,not_today", wd->today_it);
141 edje_object_signal_emit(wd->calendar, emission, "elm");
146 _today(Widget_Data *wd, int it)
149 snprintf(emission, sizeof(emission), "cit_%i,today", it);
150 edje_object_signal_emit(wd->calendar, emission, "elm");
155 _format_month_year(struct tm *selected_time)
158 if (!strftime(buf, sizeof(buf), "%B %Y", selected_time)) return NULL;
163 _cit_mark(Evas_Object *cal, int cit, const char *mtype)
166 snprintf(sign, sizeof(sign), "cit_%i,%s", cit, mtype);
167 edje_object_signal_emit(cal, sign, "elm");
171 _weekday_get(int first_week_day, int day)
173 return (day + first_week_day - 1) % 7;
178 _text_day_color_update(Widget_Data *wd, int pos)
182 switch (wd->day_color[pos])
185 snprintf(emission, sizeof(emission), "cit_%i,weekday", pos);
188 snprintf(emission, sizeof(emission), "cit_%i,saturday", pos);
191 snprintf(emission, sizeof(emission), "cit_%i,sunday", pos);
197 edje_object_signal_emit(wd->calendar, emission, "elm");
202 _text_day_color_set(Widget_Data *wd, Day_Color col, int pos)
204 if ((pos < 0) || (pos >= 42)) return;
205 if (wd->day_color[pos] == col) return;
206 wd->day_color[pos] = col;
207 _text_day_color_update(wd, pos);
211 _set_month_year(Widget_Data *wd)
215 /* Set selected month */
216 buf = wd->format_func(&wd->selected_time);
219 edje_object_part_text_set(wd->calendar, "month_text", buf);
223 edje_object_part_text_set(wd->calendar, "month_text", "");
227 _populate(Evas_Object *obj)
229 int maxdays, day, mon, year, i;
230 Elm_Calendar_Mark *mark;
231 char part[12], day_s[3];
234 Eina_Bool last_row = EINA_TRUE;
235 Widget_Data *wd = elm_widget_data_get(obj);
239 if (wd->today_it > 0) _not_today(wd);
241 maxdays = _maxdays_get(&wd->selected_time);
242 mon = wd->selected_time.tm_mon;
243 year = wd->selected_time.tm_year;
249 first_day = wd->selected_time;
250 first_day.tm_mday = 1;
253 // Layout of the calendar is changed for removing the unfilled last row.
254 wd->first_day_it = first_day.tm_wday;
256 if ((35 - wd->first_day_it) > (maxdays - 1)) last_row = EINA_FALSE;
262 for (i = 0; i < 5; i++)
264 snprintf(emission, sizeof(emission), "cseph_%i,row_hide", i);
265 edje_object_signal_emit(wd->calendar, emission, "elm");
267 snprintf(emission, sizeof(emission), "cseph_%i,row_invisible", 5);
268 edje_object_signal_emit(wd->calendar, emission, "elm");
269 for (i = 0; i < 35; i++)
271 snprintf(emission, sizeof(emission), "cit_%i,cell_expanded", i);
272 edje_object_signal_emit(wd->calendar, emission, "elm");
274 for (i = 35; i < 42; i++)
276 snprintf(emission, sizeof(emission), "cit_%i,cell_invisible", i);
277 edje_object_signal_emit(wd->calendar, emission, "elm");
284 for (i = 0; i < 6; i++)
286 snprintf(emission, sizeof(emission), "cseph_%i,row_show", i);
287 edje_object_signal_emit(wd->calendar, emission, "elm");
289 for (i = 0; i < 42; i++)
291 snprintf(emission, sizeof(emission), "cit_%i,cell_default", i);
292 edje_object_signal_emit(wd->calendar, emission, "elm");
296 for (i = 0; i < 42; i++)
298 _text_day_color_update(wd, i); // EINA_DEPRECATED
299 if ((!day) && (i == first_day.tm_wday)) day = 1;
301 if ((day == wd->current_time.tm_mday)
302 && (mon == wd->current_time.tm_mon)
303 && (year == wd->current_time.tm_year))
306 if (day == wd->selected_time.tm_mday)
308 if ((wd->selected_it > -1) && (wd->selected_it != i))
309 _unselect(wd, wd->selected_it);
311 if (wd->selection_enabled) _select(wd, i);
316 if ((day) && (day <= maxdays))
317 snprintf(day_s, sizeof(day_s), "%i", day++);
321 snprintf(part, sizeof(part), "cit_%i.text", i);
322 edje_object_part_text_set(wd->calendar, part, day_s);
323 /* Clear previous marks */
324 _cit_mark(wd->calendar, i, "clear");
328 EINA_LIST_FOREACH(wd->marks, l, mark)
330 struct tm *mtime = &mark->mark_time;
331 int month = wd->selected_time.tm_mon;
332 int year = wd->selected_time.tm_year;
333 int mday_it = mtime->tm_mday + wd->first_day_it - 1;
335 switch (mark->repeat)
337 case ELM_CALENDAR_UNIQUE:
338 if ((mtime->tm_mon == month) && (mtime->tm_year == year))
339 _cit_mark(wd->calendar, mday_it, mark->mark_type);
341 case ELM_CALENDAR_DAILY:
342 if (((mtime->tm_year == year) && (mtime->tm_mon < month)) ||
343 (mtime->tm_year < year))
345 else if ((mtime->tm_year == year) && (mtime->tm_mon == month))
346 day = mtime->tm_mday;
349 for (; day <= maxdays; day++)
350 _cit_mark(wd->calendar, day + wd->first_day_it - 1,
353 case ELM_CALENDAR_WEEKLY:
354 if (((mtime->tm_year == year) && (mtime->tm_mon < month)) ||
355 (mtime->tm_year < year))
357 else if ((mtime->tm_year == year) && (mtime->tm_mon == month))
358 day = mtime->tm_mday;
361 for (; day <= maxdays; day++)
362 if (mtime->tm_wday == _weekday_get(wd->first_day_it, day))
363 _cit_mark(wd->calendar, day + wd->first_day_it - 1,
366 case ELM_CALENDAR_MONTHLY:
367 if (((mtime->tm_year < year) ||
368 ((mtime->tm_year == year) && (mtime->tm_mon <= month))) &&
369 (mtime->tm_mday <= maxdays))
370 _cit_mark(wd->calendar, mday_it, mark->mark_type);
372 case ELM_CALENDAR_ANNUALLY:
373 if ((mtime->tm_year <= year) && (mtime->tm_mon == month) &&
374 (mtime->tm_mday <= maxdays))
375 _cit_mark(wd->calendar, mday_it, mark->mark_type);
382 _set_headers(Evas_Object *obj)
384 static char part[] = "ch_0.text";
386 Widget_Data *wd = elm_widget_data_get(obj);
389 for (i = 0; i < 7; i++)
392 edje_object_part_text_set(wd->calendar, part, wd->weekdays[i]);
397 _del_hook(Evas_Object *obj)
400 Elm_Calendar_Mark *mark;
401 Widget_Data *wd = elm_widget_data_get(obj);
405 if (wd->spin) ecore_timer_del(wd->spin);
406 if (wd->update_timer) ecore_timer_del(wd->update_timer);
410 EINA_LIST_FREE(wd->marks, mark)
416 for (i = 0; i < 7; i++)
417 eina_stringshare_del(wd->weekdays[i]);
423 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
425 Widget_Data *wd = elm_widget_data_get(obj);
427 if (elm_widget_focus_get(obj))
429 edje_object_signal_emit(wd->calendar, "elm,action,focus", "elm");
430 evas_object_focus_set(wd->calendar, EINA_TRUE);
434 edje_object_signal_emit(wd->calendar, "elm,action,unfocus", "elm");
435 evas_object_focus_set(wd->calendar, EINA_FALSE);
440 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
442 Widget_Data *wd = elm_widget_data_get(obj);
444 edje_object_mirrored_set(wd->calendar, rtl);
448 _theme_hook(Evas_Object *obj)
450 Widget_Data *wd = elm_widget_data_get(obj);
452 _elm_widget_mirrored_reload(obj);
453 _elm_theme_object_set(obj, wd->calendar, "calendar", "base",
454 elm_widget_style_get(obj));
455 _mirrored_set(obj, elm_widget_mirrored_get(obj));
458 edje_object_message_signal_process(wd->calendar);
459 edje_object_scale_set(wd->calendar,
460 elm_widget_scale_get(obj) * _elm_config->scale);
465 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
467 Widget_Data *wd = elm_widget_data_get(obj);
469 edje_object_signal_emit(wd->calendar, emission, source);
473 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
475 Widget_Data *wd = elm_widget_data_get(obj);
477 edje_object_signal_callback_add(wd->calendar, emission,
478 source, func_cb, data);
482 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
484 Widget_Data *wd = elm_widget_data_get(obj);
486 edje_object_signal_callback_del_full(wd->calendar, emission, source, func_cb,
490 /* Set correct tm_wday and tm_yday after other fields changes*/
492 _fix_selected_time(Widget_Data *wd)
494 mktime(&wd->selected_time);
498 _update_month(Evas_Object *obj, int delta)
500 struct tm time_check;
502 Widget_Data *wd = elm_widget_data_get(obj);
503 if (!wd) return EINA_FALSE;
505 /* check if it's a valid time. for 32 bits, year greater than 2037 is not */
506 time_check = wd->selected_time;
507 time_check.tm_mon += delta;
508 if (mktime(&time_check) == -1)
511 wd->selected_time.tm_mon += delta;
512 if (wd->selected_time.tm_mon < 0)
514 if (wd->selected_time.tm_year == wd->year_min)
516 wd->selected_time.tm_mon++;
519 wd->selected_time.tm_mon = 11;
520 wd->selected_time.tm_year--;
522 else if (wd->selected_time.tm_mon > 11)
524 if (wd->selected_time.tm_year == wd->year_max)
526 wd->selected_time.tm_mon--;
529 wd->selected_time.tm_mon = 0;
530 wd->selected_time.tm_year++;
533 maxdays = _maxdays_get(&wd->selected_time);
534 if (wd->selected_time.tm_mday > maxdays)
535 wd->selected_time.tm_mday = maxdays;
537 _fix_selected_time(wd);
538 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
544 _spin_value(void *data)
546 Widget_Data *wd = elm_widget_data_get(data);
547 if (!wd) return ECORE_CALLBACK_CANCEL;
548 if (_update_month(data, wd->spin_speed)) _populate(data);
549 wd->interval = wd->interval / 1.05;
550 ecore_timer_interval_set(wd->spin, wd->interval);
551 return ECORE_CALLBACK_RENEW;
555 _button_inc_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
557 Widget_Data *wd = elm_widget_data_get(data);
559 wd->interval = wd->first_interval;
561 if (wd->spin) ecore_timer_del(wd->spin);
562 wd->spin = ecore_timer_add(wd->interval, _spin_value, data);
567 _button_dec_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
569 Widget_Data *wd = elm_widget_data_get(data);
571 wd->interval = wd->first_interval;
573 if (wd->spin) ecore_timer_del(wd->spin);
574 wd->spin = ecore_timer_add(wd->interval, _spin_value, data);
579 _button_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
581 Widget_Data *wd = elm_widget_data_get(data);
583 wd->interval = wd->first_interval;
584 if (wd->spin) ecore_timer_del(wd->spin);
589 _get_item_day(Evas_Object *obj, int selected_it)
592 Widget_Data *wd = elm_widget_data_get(obj);
595 day = selected_it - wd->first_day_it + 1;
596 if ((day < 0) || (day > _maxdays_get(&wd->selected_time)))
603 _update_sel_it(Evas_Object *obj, int sel_it)
606 Widget_Data *wd = elm_widget_data_get(obj);
607 if ((!wd) || (!wd->selection_enabled))
610 day = _get_item_day(obj, sel_it);
614 _unselect(wd, wd->selected_it);
616 wd->selected_it = sel_it;
617 wd->selected_time.tm_mday = day;
618 _select(wd, wd->selected_it);
619 _fix_selected_time(wd);
620 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
624 _day_selected(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source)
627 Widget_Data *wd = elm_widget_data_get(data);
628 if ((!wd) || (!wd->selection_enabled))
630 sel_it = atoi(source);
632 _update_sel_it(data, sel_it);
636 _time_to_next_day(struct tm *t)
638 return ((((24 - t->tm_hour) * 60) - t->tm_min) * 60) - t->tm_sec;
642 _update_cur_date(void *data)
646 Widget_Data *wd = elm_widget_data_get(data);
647 if (!wd) return ECORE_CALLBACK_RENEW;
649 if (wd->today_it > 0) _not_today(wd);
651 current_time = time(NULL);
652 localtime_r(¤t_time, &wd->current_time);
653 t = _time_to_next_day(&wd->current_time);
654 ecore_timer_interval_set(wd->update_timer, t);
656 if ((wd->current_time.tm_mon != wd->selected_time.tm_mon) ||
657 (wd->current_time.tm_year!= wd->selected_time.tm_year))
658 return ECORE_CALLBACK_RENEW;
660 day = wd->current_time.tm_mday + wd->first_day_it - 1;
663 return ECORE_CALLBACK_RENEW;
667 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
669 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
670 Evas_Event_Key_Down *ev = event_info;
671 Widget_Data *wd = elm_widget_data_get(obj);
673 if (!wd) return EINA_FALSE;
674 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
675 if (!wd->selection_enabled) return EINA_FALSE;
677 if ((!strcmp(ev->keyname, "Left")) ||
678 (!strcmp(ev->keyname, "KP_Left")))
680 _update_sel_it(obj, wd->selected_it-1);
682 else if ((!strcmp(ev->keyname, "Right")) ||
683 (!strcmp(ev->keyname, "KP_Right")))
685 _update_sel_it(obj, wd->selected_it+1);
687 else if ((!strcmp(ev->keyname, "Up")) ||
688 (!strcmp(ev->keyname, "KP_Up")))
690 _update_sel_it(obj, wd->selected_it-7);
692 else if ((!strcmp(ev->keyname, "Down")) ||
693 (!strcmp(ev->keyname, "KP_Down")))
695 _update_sel_it(obj, wd->selected_it+7);
697 else if ((!strcmp(ev->keyname, "Prior")) ||
698 (!strcmp(ev->keyname, "KP_Prior")))
700 if (_update_month(obj, -1)) _populate(obj);
702 else if ((!strcmp(ev->keyname, "Next")) ||
703 (!strcmp(ev->keyname, "KP_Next")))
705 if (_update_month(obj, 1)) _populate(obj);
707 else return EINA_FALSE;
713 elm_calendar_add(Evas_Object *parent)
716 time_t weekday = 259200; /* Just the first sunday since epoch */
722 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
724 ELM_SET_WIDTYPE(widtype, "calendar");
725 elm_widget_type_set(obj, "calendar");
726 elm_widget_sub_object_add(parent, obj);
727 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
728 elm_widget_data_set(obj, wd);
729 elm_widget_del_hook_set(obj, _del_hook);
730 elm_widget_theme_hook_set(obj, _theme_hook);
731 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
732 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
733 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
734 elm_widget_can_focus_set(obj, EINA_TRUE);
735 elm_widget_event_hook_set(obj, _event_hook);
737 wd->first_interval = 0.85;
741 wd->selected_it = -1;
742 wd->first_day_it = -1;
743 wd->selection_enabled = EINA_TRUE;
744 wd->format_func = _format_month_year;
747 wd->calendar = edje_object_add(e);
748 _elm_theme_object_set(obj, wd->calendar, "calendar", "base", "default");
749 elm_widget_resize_object_set(obj, wd->calendar);
751 edje_object_signal_callback_add(wd->calendar, "elm,action,increment,start",
752 "*", _button_inc_start, obj);
753 edje_object_signal_callback_add(wd->calendar, "elm,action,decrement,start",
754 "*", _button_dec_start, obj);
755 edje_object_signal_callback_add(wd->calendar, "elm,action,stop",
756 "*", _button_stop, obj);
757 edje_object_signal_callback_add(wd->calendar, "elm,action,selected",
758 "*", _day_selected, obj);
760 evas_object_smart_callbacks_descriptions_set(obj, _signals);
762 for (i = 0; i < 7; i++)
764 /* FIXME: I'm not aware of a known max, so if it fails,
765 * just make it larger. :| */
767 /* I don't know of a better way of doing it */
768 if (strftime(buf, sizeof(buf), "%a", gmtime(&weekday)))
770 wd->weekdays[i] = eina_stringshare_add(buf);
774 /* If we failed getting day, get a default value */
775 wd->weekdays[i] = _days_abbrev[i];
776 WRN("Failed getting weekday name for '%s' from locale.",
779 weekday += 86400; /* Advance by a day */
782 current_time = time(NULL);
783 localtime_r(¤t_time, &wd->selected_time);
784 wd->current_time = wd->selected_time;
785 t = _time_to_next_day(&wd->current_time);
786 wd->update_timer = ecore_timer_add(t, _update_cur_date, obj);
790 _mirrored_set(obj, elm_widget_mirrored_get(obj));
796 elm_calendar_weekdays_names_set(Evas_Object *obj, const char *weekdays[])
799 ELM_CHECK_WIDTYPE(obj, widtype);
800 Widget_Data *wd = elm_widget_data_get(obj);
803 EINA_SAFETY_ON_NULL_RETURN(weekdays);
805 for (i = 0; i < 7; i++)
807 eina_stringshare_replace(&wd->weekdays[i], weekdays[i]);
813 elm_calendar_weekdays_names_get(const Evas_Object *obj)
815 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
816 Widget_Data *wd = elm_widget_data_get(obj);
817 if (!wd) return NULL;
822 elm_calendar_interval_set(Evas_Object *obj, double interval)
824 ELM_CHECK_WIDTYPE(obj, widtype);
825 Widget_Data *wd = elm_widget_data_get(obj);
827 wd->first_interval = interval;
831 elm_calendar_interval_get(const Evas_Object *obj)
833 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
834 Widget_Data *wd = elm_widget_data_get(obj);
836 return wd->first_interval;
840 elm_calendar_min_max_year_set(Evas_Object *obj, int min, int max)
842 ELM_CHECK_WIDTYPE(obj, widtype);
843 Widget_Data *wd = elm_widget_data_get(obj);
847 if ((wd->year_min == min) && (wd->year_max == max)) return;
848 wd->year_min = min > 2 ? min : 2;
850 if ((max >= wd->year_min) && (wd->selected_time.tm_year > wd->year_max))
851 wd->selected_time.tm_year = wd->year_max;
852 if (wd->selected_time.tm_year < wd->year_min)
853 wd->selected_time.tm_year = wd->year_min;
854 _fix_selected_time(wd);
859 elm_calendar_min_max_year_get(const Evas_Object *obj, int *min, int *max)
861 ELM_CHECK_WIDTYPE(obj, widtype);
862 Widget_Data *wd = elm_widget_data_get(obj);
864 if (min) *min = wd->year_min + 1900;
865 if (max) *max = wd->year_max + 1900;
869 elm_calendar_day_selection_enabled_set(Evas_Object *obj, Eina_Bool enabled)
871 ELM_CHECK_WIDTYPE(obj, widtype);
872 Widget_Data *wd = elm_widget_data_get(obj);
874 wd->selection_enabled = enabled;
876 _select(wd, wd->selected_it);
878 _unselect(wd, wd->selected_it);
882 elm_calendar_day_selection_enabled_get(const Evas_Object *obj)
884 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
885 Widget_Data *wd = elm_widget_data_get(obj);
886 if (!wd) return EINA_FALSE;
887 return wd->selection_enabled;
891 elm_calendar_selected_time_set(Evas_Object *obj, struct tm *selected_time)
893 ELM_CHECK_WIDTYPE(obj, widtype);
894 Widget_Data *wd = elm_widget_data_get(obj);
897 EINA_SAFETY_ON_NULL_RETURN(selected_time);
898 wd->selected_time = *selected_time;
904 elm_calendar_selected_time_get(const Evas_Object *obj, struct tm *selected_time)
906 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
907 Widget_Data *wd = elm_widget_data_get(obj);
908 if (!wd) return EINA_FALSE;
909 EINA_SAFETY_ON_NULL_RETURN_VAL(selected_time, EINA_FALSE);
910 *selected_time = wd->selected_time;
915 elm_calendar_format_function_set(Evas_Object *obj, char * (*format_function) (struct tm *selected_time))
917 ELM_CHECK_WIDTYPE(obj, widtype);
918 Widget_Data *wd = elm_widget_data_get(obj);
920 wd->format_func = format_function;
924 EAPI Elm_Calendar_Mark *
925 elm_calendar_mark_add(Evas_Object *obj, const char *mark_type, struct tm *mark_time, Elm_Calendar_Mark_Repeat repeat)
927 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
928 Widget_Data *wd = elm_widget_data_get(obj);
929 Elm_Calendar_Mark *mark;
930 if (!wd) return NULL;
932 mark = _mark_new(obj, mark_type, mark_time, repeat);
933 wd->marks = eina_list_append(wd->marks, mark);
934 mark->node = eina_list_last(wd->marks);
939 elm_calendar_mark_del(Elm_Calendar_Mark *mark)
944 EINA_SAFETY_ON_NULL_RETURN(mark);
947 wd = elm_widget_data_get(obj);
950 wd->marks = eina_list_remove_list(wd->marks, mark->node);
955 elm_calendar_marks_clear(Evas_Object *obj)
957 ELM_CHECK_WIDTYPE(obj, widtype);
958 Widget_Data *wd = elm_widget_data_get(obj);
959 Elm_Calendar_Mark *mark;
962 EINA_LIST_FREE(wd->marks, mark)
966 EAPI const Eina_List *
967 elm_calendar_marks_get(const Evas_Object *obj)
969 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
970 Widget_Data *wd = elm_widget_data_get(obj);
971 if (!wd) return NULL;
976 elm_calendar_marks_draw(Evas_Object *obj)
978 ELM_CHECK_WIDTYPE(obj, widtype);
979 Widget_Data *wd = elm_widget_data_get(obj);
984 EINA_DEPRECATED EAPI void
985 elm_calendar_text_saturday_color_set(Evas_Object *obj, int pos)
987 ELM_CHECK_WIDTYPE(obj, widtype);
988 Widget_Data *wd = elm_widget_data_get(obj);
990 _text_day_color_set(wd, DAY_SATURDAY, pos);
993 EINA_DEPRECATED EAPI void
994 elm_calendar_text_sunday_color_set(Evas_Object *obj, int pos)
996 ELM_CHECK_WIDTYPE(obj, widtype);
997 Widget_Data *wd = elm_widget_data_get(obj);
999 _text_day_color_set(wd, DAY_SUNDAY, pos);
1002 EINA_DEPRECATED EAPI void
1003 elm_calendar_text_weekday_color_set(Evas_Object *obj, int pos)
1005 ELM_CHECK_WIDTYPE(obj, widtype);
1006 Widget_Data *wd = elm_widget_data_get(obj);
1008 _text_day_color_set(wd, DAY_WEEKDAY, pos);