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), E_("%B %Y"), selected_time)) return NULL;
159 fprintf(stderr, "%s\n", buf);
164 _cit_mark(Evas_Object *cal, int cit, const char *mtype)
167 snprintf(sign, sizeof(sign), "cit_%i,%s", cit, mtype);
168 edje_object_signal_emit(cal, sign, "elm");
172 _weekday_get(int first_week_day, int day)
174 return (day + first_week_day - 1) % 7;
179 _text_day_color_update(Widget_Data *wd, int pos)
183 switch (wd->day_color[pos])
186 snprintf(emission, sizeof(emission), "cit_%i,weekday", pos);
189 snprintf(emission, sizeof(emission), "cit_%i,saturday", pos);
192 snprintf(emission, sizeof(emission), "cit_%i,sunday", pos);
198 edje_object_signal_emit(wd->calendar, emission, "elm");
203 _text_day_color_set(Widget_Data *wd, Day_Color col, int pos)
205 if ((pos < 0) || (pos >= 42)) return;
206 if (wd->day_color[pos] == col) return;
207 wd->day_color[pos] = col;
208 _text_day_color_update(wd, pos);
212 _set_month_year(Widget_Data *wd)
216 /* Set selected month */
217 buf = wd->format_func(&wd->selected_time);
220 edje_object_part_text_set(wd->calendar, "month_text", buf);
224 edje_object_part_text_set(wd->calendar, "month_text", "");
228 _populate(Evas_Object *obj)
230 int maxdays, day, mon, year, i;
231 Elm_Calendar_Mark *mark;
232 char part[12], day_s[3];
235 Eina_Bool last_row = EINA_TRUE;
236 Widget_Data *wd = elm_widget_data_get(obj);
240 if (wd->today_it > 0) _not_today(wd);
242 maxdays = _maxdays_get(&wd->selected_time);
243 mon = wd->selected_time.tm_mon;
244 year = wd->selected_time.tm_year;
250 first_day = wd->selected_time;
251 first_day.tm_mday = 1;
254 // Layout of the calendar is changed for removing the unfilled last row.
255 wd->first_day_it = first_day.tm_wday;
257 if ((35 - wd->first_day_it) > (maxdays - 1)) last_row = EINA_FALSE;
263 for (i = 0; i < 5; i++)
265 snprintf(emission, sizeof(emission), "cseph_%i,row_hide", i);
266 edje_object_signal_emit(wd->calendar, emission, "elm");
268 snprintf(emission, sizeof(emission), "cseph_%i,row_invisible", 5);
269 edje_object_signal_emit(wd->calendar, emission, "elm");
270 for (i = 0; i < 35; i++)
272 snprintf(emission, sizeof(emission), "cit_%i,cell_expanded", i);
273 edje_object_signal_emit(wd->calendar, emission, "elm");
275 for (i = 35; i < 42; i++)
277 snprintf(emission, sizeof(emission), "cit_%i,cell_invisible", i);
278 edje_object_signal_emit(wd->calendar, emission, "elm");
285 for (i = 0; i < 6; i++)
287 snprintf(emission, sizeof(emission), "cseph_%i,row_show", i);
288 edje_object_signal_emit(wd->calendar, emission, "elm");
290 for (i = 0; i < 42; i++)
292 snprintf(emission, sizeof(emission), "cit_%i,cell_default", i);
293 edje_object_signal_emit(wd->calendar, emission, "elm");
297 for (i = 0; i < 42; i++)
299 _text_day_color_update(wd, i); // EINA_DEPRECATED
300 if ((!day) && (i == first_day.tm_wday)) day = 1;
302 if ((day == wd->current_time.tm_mday)
303 && (mon == wd->current_time.tm_mon)
304 && (year == wd->current_time.tm_year))
307 if (day == wd->selected_time.tm_mday)
309 if ((wd->selected_it > -1) && (wd->selected_it != i))
310 _unselect(wd, wd->selected_it);
312 if (wd->selection_enabled) _select(wd, i);
317 if ((day) && (day <= maxdays))
318 snprintf(day_s, sizeof(day_s), "%i", day++);
322 snprintf(part, sizeof(part), "cit_%i.text", i);
323 edje_object_part_text_set(wd->calendar, part, day_s);
324 /* Clear previous marks */
325 _cit_mark(wd->calendar, i, "clear");
329 EINA_LIST_FOREACH(wd->marks, l, mark)
331 struct tm *mtime = &mark->mark_time;
332 int month = wd->selected_time.tm_mon;
333 int year = wd->selected_time.tm_year;
334 int mday_it = mtime->tm_mday + wd->first_day_it - 1;
336 switch (mark->repeat)
338 case ELM_CALENDAR_UNIQUE:
339 if ((mtime->tm_mon == month) && (mtime->tm_year == year))
340 _cit_mark(wd->calendar, mday_it, mark->mark_type);
342 case ELM_CALENDAR_DAILY:
343 if (((mtime->tm_year == year) && (mtime->tm_mon < month)) ||
344 (mtime->tm_year < year))
346 else if ((mtime->tm_year == year) && (mtime->tm_mon == month))
347 day = mtime->tm_mday;
350 for (; day <= maxdays; day++)
351 _cit_mark(wd->calendar, day + wd->first_day_it - 1,
354 case ELM_CALENDAR_WEEKLY:
355 if (((mtime->tm_year == year) && (mtime->tm_mon < month)) ||
356 (mtime->tm_year < year))
358 else if ((mtime->tm_year == year) && (mtime->tm_mon == month))
359 day = mtime->tm_mday;
362 for (; day <= maxdays; day++)
363 if (mtime->tm_wday == _weekday_get(wd->first_day_it, day))
364 _cit_mark(wd->calendar, day + wd->first_day_it - 1,
367 case ELM_CALENDAR_MONTHLY:
368 if (((mtime->tm_year < year) ||
369 ((mtime->tm_year == year) && (mtime->tm_mon <= month))) &&
370 (mtime->tm_mday <= maxdays))
371 _cit_mark(wd->calendar, mday_it, mark->mark_type);
373 case ELM_CALENDAR_ANNUALLY:
374 if ((mtime->tm_year <= year) && (mtime->tm_mon == month) &&
375 (mtime->tm_mday <= maxdays))
376 _cit_mark(wd->calendar, mday_it, mark->mark_type);
383 _set_headers(Evas_Object *obj)
385 static char part[] = "ch_0.text";
387 Widget_Data *wd = elm_widget_data_get(obj);
390 for (i = 0; i < 7; i++)
393 edje_object_part_text_set(wd->calendar, part, wd->weekdays[i]);
398 _del_hook(Evas_Object *obj)
401 Elm_Calendar_Mark *mark;
402 Widget_Data *wd = elm_widget_data_get(obj);
406 if (wd->spin) ecore_timer_del(wd->spin);
407 if (wd->update_timer) ecore_timer_del(wd->update_timer);
411 EINA_LIST_FREE(wd->marks, mark)
417 for (i = 0; i < 7; i++)
418 eina_stringshare_del(wd->weekdays[i]);
424 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
426 Widget_Data *wd = elm_widget_data_get(obj);
428 if (elm_widget_focus_get(obj))
430 edje_object_signal_emit(wd->calendar, "elm,action,focus", "elm");
431 evas_object_focus_set(wd->calendar, EINA_TRUE);
435 edje_object_signal_emit(wd->calendar, "elm,action,unfocus", "elm");
436 evas_object_focus_set(wd->calendar, EINA_FALSE);
441 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
443 Widget_Data *wd = elm_widget_data_get(obj);
445 edje_object_mirrored_set(wd->calendar, rtl);
449 _theme_hook(Evas_Object *obj)
451 Widget_Data *wd = elm_widget_data_get(obj);
453 _elm_widget_mirrored_reload(obj);
454 _elm_theme_object_set(obj, wd->calendar, "calendar", "base",
455 elm_widget_style_get(obj));
456 _mirrored_set(obj, elm_widget_mirrored_get(obj));
459 edje_object_message_signal_process(wd->calendar);
460 edje_object_scale_set(wd->calendar,
461 elm_widget_scale_get(obj) * _elm_config->scale);
466 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
468 Widget_Data *wd = elm_widget_data_get(obj);
470 edje_object_signal_emit(wd->calendar, emission, source);
474 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
476 Widget_Data *wd = elm_widget_data_get(obj);
478 edje_object_signal_callback_add(wd->calendar, emission,
479 source, func_cb, data);
483 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
485 Widget_Data *wd = elm_widget_data_get(obj);
487 edje_object_signal_callback_del_full(wd->calendar, emission, source, func_cb,
491 /* Set correct tm_wday and tm_yday after other fields changes*/
493 _fix_selected_time(Widget_Data *wd)
495 mktime(&wd->selected_time);
499 _update_month(Evas_Object *obj, int delta)
501 struct tm time_check;
503 Widget_Data *wd = elm_widget_data_get(obj);
504 if (!wd) return EINA_FALSE;
506 /* check if it's a valid time. for 32 bits, year greater than 2037 is not */
507 time_check = wd->selected_time;
508 time_check.tm_mon += delta;
509 if (mktime(&time_check) == -1)
512 wd->selected_time.tm_mon += delta;
513 if (wd->selected_time.tm_mon < 0)
515 if (wd->selected_time.tm_year == wd->year_min)
517 wd->selected_time.tm_mon++;
520 wd->selected_time.tm_mon = 11;
521 wd->selected_time.tm_year--;
523 else if (wd->selected_time.tm_mon > 11)
525 if (wd->selected_time.tm_year == wd->year_max)
527 wd->selected_time.tm_mon--;
530 wd->selected_time.tm_mon = 0;
531 wd->selected_time.tm_year++;
534 maxdays = _maxdays_get(&wd->selected_time);
535 if (wd->selected_time.tm_mday > maxdays)
536 wd->selected_time.tm_mday = maxdays;
538 _fix_selected_time(wd);
539 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
545 _spin_value(void *data)
547 Widget_Data *wd = elm_widget_data_get(data);
548 if (!wd) return ECORE_CALLBACK_CANCEL;
549 if (_update_month(data, wd->spin_speed)) _populate(data);
550 wd->interval = wd->interval / 1.05;
551 ecore_timer_interval_set(wd->spin, wd->interval);
552 return ECORE_CALLBACK_RENEW;
556 _button_inc_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
558 Widget_Data *wd = elm_widget_data_get(data);
560 wd->interval = wd->first_interval;
562 if (wd->spin) ecore_timer_del(wd->spin);
563 wd->spin = ecore_timer_add(wd->interval, _spin_value, data);
568 _button_dec_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
570 Widget_Data *wd = elm_widget_data_get(data);
572 wd->interval = wd->first_interval;
574 if (wd->spin) ecore_timer_del(wd->spin);
575 wd->spin = ecore_timer_add(wd->interval, _spin_value, data);
580 _button_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
582 Widget_Data *wd = elm_widget_data_get(data);
584 wd->interval = wd->first_interval;
585 if (wd->spin) ecore_timer_del(wd->spin);
590 _get_item_day(Evas_Object *obj, int selected_it)
593 Widget_Data *wd = elm_widget_data_get(obj);
596 day = selected_it - wd->first_day_it + 1;
597 if ((day < 0) || (day > _maxdays_get(&wd->selected_time)))
604 _update_sel_it(Evas_Object *obj, int sel_it)
607 Widget_Data *wd = elm_widget_data_get(obj);
608 if ((!wd) || (!wd->selection_enabled))
611 day = _get_item_day(obj, sel_it);
615 _unselect(wd, wd->selected_it);
617 wd->selected_it = sel_it;
618 wd->selected_time.tm_mday = day;
619 _select(wd, wd->selected_it);
620 _fix_selected_time(wd);
621 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
625 _day_selected(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source)
628 Widget_Data *wd = elm_widget_data_get(data);
629 if ((!wd) || (!wd->selection_enabled))
631 sel_it = atoi(source);
633 _update_sel_it(data, sel_it);
637 _time_to_next_day(struct tm *t)
639 return ((((24 - t->tm_hour) * 60) - t->tm_min) * 60) - t->tm_sec;
643 _update_cur_date(void *data)
647 Widget_Data *wd = elm_widget_data_get(data);
648 if (!wd) return ECORE_CALLBACK_RENEW;
650 if (wd->today_it > 0) _not_today(wd);
652 current_time = time(NULL);
653 localtime_r(¤t_time, &wd->current_time);
654 t = _time_to_next_day(&wd->current_time);
655 ecore_timer_interval_set(wd->update_timer, t);
657 if ((wd->current_time.tm_mon != wd->selected_time.tm_mon) ||
658 (wd->current_time.tm_year!= wd->selected_time.tm_year))
659 return ECORE_CALLBACK_RENEW;
661 day = wd->current_time.tm_mday + wd->first_day_it - 1;
664 return ECORE_CALLBACK_RENEW;
668 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
670 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
671 Evas_Event_Key_Down *ev = event_info;
672 Widget_Data *wd = elm_widget_data_get(obj);
674 if (!wd) return EINA_FALSE;
675 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
676 if (!wd->selection_enabled) return EINA_FALSE;
678 if ((!strcmp(ev->keyname, "Left")) ||
679 (!strcmp(ev->keyname, "KP_Left")))
681 _update_sel_it(obj, wd->selected_it-1);
683 else if ((!strcmp(ev->keyname, "Right")) ||
684 (!strcmp(ev->keyname, "KP_Right")))
686 _update_sel_it(obj, wd->selected_it+1);
688 else if ((!strcmp(ev->keyname, "Up")) ||
689 (!strcmp(ev->keyname, "KP_Up")))
691 _update_sel_it(obj, wd->selected_it-7);
693 else if ((!strcmp(ev->keyname, "Down")) ||
694 (!strcmp(ev->keyname, "KP_Down")))
696 _update_sel_it(obj, wd->selected_it+7);
698 else if ((!strcmp(ev->keyname, "Prior")) ||
699 (!strcmp(ev->keyname, "KP_Prior")))
701 if (_update_month(obj, -1)) _populate(obj);
703 else if ((!strcmp(ev->keyname, "Next")) ||
704 (!strcmp(ev->keyname, "KP_Next")))
706 if (_update_month(obj, 1)) _populate(obj);
708 else return EINA_FALSE;
714 elm_calendar_add(Evas_Object *parent)
717 time_t weekday = 259200; /* Just the first sunday since epoch */
723 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
725 ELM_SET_WIDTYPE(widtype, "calendar");
726 elm_widget_type_set(obj, "calendar");
727 elm_widget_sub_object_add(parent, obj);
728 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
729 elm_widget_data_set(obj, wd);
730 elm_widget_del_hook_set(obj, _del_hook);
731 elm_widget_theme_hook_set(obj, _theme_hook);
732 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
733 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
734 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
735 elm_widget_can_focus_set(obj, EINA_TRUE);
736 elm_widget_event_hook_set(obj, _event_hook);
738 wd->first_interval = 0.85;
742 wd->selected_it = -1;
743 wd->first_day_it = -1;
744 wd->selection_enabled = EINA_TRUE;
745 wd->format_func = _format_month_year;
748 wd->calendar = edje_object_add(e);
749 _elm_theme_object_set(obj, wd->calendar, "calendar", "base", "default");
750 elm_widget_resize_object_set(obj, wd->calendar);
752 edje_object_signal_callback_add(wd->calendar, "elm,action,increment,start",
753 "*", _button_inc_start, obj);
754 edje_object_signal_callback_add(wd->calendar, "elm,action,decrement,start",
755 "*", _button_dec_start, obj);
756 edje_object_signal_callback_add(wd->calendar, "elm,action,stop",
757 "*", _button_stop, obj);
758 edje_object_signal_callback_add(wd->calendar, "elm,action,selected",
759 "*", _day_selected, obj);
761 evas_object_smart_callbacks_descriptions_set(obj, _signals);
763 for (i = 0; i < 7; i++)
765 /* FIXME: I'm not aware of a known max, so if it fails,
766 * just make it larger. :| */
768 /* I don't know of a better way of doing it */
769 if (strftime(buf, sizeof(buf), "%a", gmtime(&weekday)))
771 wd->weekdays[i] = eina_stringshare_add(buf);
775 /* If we failed getting day, get a default value */
776 wd->weekdays[i] = _days_abbrev[i];
777 WRN("Failed getting weekday name for '%s' from locale.",
780 weekday += 86400; /* Advance by a day */
783 current_time = time(NULL);
784 localtime_r(¤t_time, &wd->selected_time);
785 wd->current_time = wd->selected_time;
786 t = _time_to_next_day(&wd->current_time);
787 wd->update_timer = ecore_timer_add(t, _update_cur_date, obj);
791 _mirrored_set(obj, elm_widget_mirrored_get(obj));
797 elm_calendar_weekdays_names_set(Evas_Object *obj, const char *weekdays[])
800 ELM_CHECK_WIDTYPE(obj, widtype);
801 Widget_Data *wd = elm_widget_data_get(obj);
804 EINA_SAFETY_ON_NULL_RETURN(weekdays);
806 for (i = 0; i < 7; i++)
808 eina_stringshare_replace(&wd->weekdays[i], weekdays[i]);
814 elm_calendar_weekdays_names_get(const Evas_Object *obj)
816 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
817 Widget_Data *wd = elm_widget_data_get(obj);
818 if (!wd) return NULL;
823 elm_calendar_interval_set(Evas_Object *obj, double interval)
825 ELM_CHECK_WIDTYPE(obj, widtype);
826 Widget_Data *wd = elm_widget_data_get(obj);
828 wd->first_interval = interval;
832 elm_calendar_interval_get(const Evas_Object *obj)
834 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
835 Widget_Data *wd = elm_widget_data_get(obj);
837 return wd->first_interval;
841 elm_calendar_min_max_year_set(Evas_Object *obj, int min, int max)
843 ELM_CHECK_WIDTYPE(obj, widtype);
844 Widget_Data *wd = elm_widget_data_get(obj);
848 if ((wd->year_min == min) && (wd->year_max == max)) return;
849 wd->year_min = min > 2 ? min : 2;
850 if (max > wd->year_min)
853 wd->year_max = wd->year_min;
854 if (wd->selected_time.tm_year > wd->year_max)
855 wd->selected_time.tm_year = wd->year_max;
856 if (wd->selected_time.tm_year < wd->year_min)
857 wd->selected_time.tm_year = wd->year_min;
858 _fix_selected_time(wd);
863 elm_calendar_min_max_year_get(const Evas_Object *obj, int *min, int *max)
865 ELM_CHECK_WIDTYPE(obj, widtype);
866 Widget_Data *wd = elm_widget_data_get(obj);
868 if (min) *min = wd->year_min + 1900;
869 if (max) *max = wd->year_max + 1900;
873 elm_calendar_day_selection_enabled_set(Evas_Object *obj, Eina_Bool enabled)
875 ELM_CHECK_WIDTYPE(obj, widtype);
876 Widget_Data *wd = elm_widget_data_get(obj);
878 wd->selection_enabled = enabled;
880 _select(wd, wd->selected_it);
882 _unselect(wd, wd->selected_it);
886 elm_calendar_day_selection_enabled_get(const Evas_Object *obj)
888 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
889 Widget_Data *wd = elm_widget_data_get(obj);
890 if (!wd) return EINA_FALSE;
891 return wd->selection_enabled;
895 elm_calendar_selected_time_set(Evas_Object *obj, struct tm *selected_time)
897 ELM_CHECK_WIDTYPE(obj, widtype);
898 Widget_Data *wd = elm_widget_data_get(obj);
901 EINA_SAFETY_ON_NULL_RETURN(selected_time);
902 wd->selected_time = *selected_time;
908 elm_calendar_selected_time_get(const Evas_Object *obj, struct tm *selected_time)
910 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
911 Widget_Data *wd = elm_widget_data_get(obj);
912 if (!wd) return EINA_FALSE;
913 EINA_SAFETY_ON_NULL_RETURN_VAL(selected_time, EINA_FALSE);
914 *selected_time = wd->selected_time;
919 elm_calendar_format_function_set(Evas_Object *obj, char * (*format_function) (struct tm *selected_time))
921 ELM_CHECK_WIDTYPE(obj, widtype);
922 Widget_Data *wd = elm_widget_data_get(obj);
924 wd->format_func = format_function;
928 EAPI Elm_Calendar_Mark *
929 elm_calendar_mark_add(Evas_Object *obj, const char *mark_type, struct tm *mark_time, Elm_Calendar_Mark_Repeat repeat)
931 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
932 Widget_Data *wd = elm_widget_data_get(obj);
933 Elm_Calendar_Mark *mark;
934 if (!wd) return NULL;
936 mark = _mark_new(obj, mark_type, mark_time, repeat);
937 wd->marks = eina_list_append(wd->marks, mark);
938 mark->node = eina_list_last(wd->marks);
943 elm_calendar_mark_del(Elm_Calendar_Mark *mark)
948 EINA_SAFETY_ON_NULL_RETURN(mark);
951 wd = elm_widget_data_get(obj);
954 wd->marks = eina_list_remove_list(wd->marks, mark->node);
959 elm_calendar_marks_clear(Evas_Object *obj)
961 ELM_CHECK_WIDTYPE(obj, widtype);
962 Widget_Data *wd = elm_widget_data_get(obj);
963 Elm_Calendar_Mark *mark;
966 EINA_LIST_FREE(wd->marks, mark)
970 EAPI const Eina_List *
971 elm_calendar_marks_get(const Evas_Object *obj)
973 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
974 Widget_Data *wd = elm_widget_data_get(obj);
975 if (!wd) return NULL;
980 elm_calendar_marks_draw(Evas_Object *obj)
982 ELM_CHECK_WIDTYPE(obj, widtype);
983 Widget_Data *wd = elm_widget_data_get(obj);
988 EINA_DEPRECATED EAPI void
989 elm_calendar_text_saturday_color_set(Evas_Object *obj, int pos)
991 ELM_CHECK_WIDTYPE(obj, widtype);
992 Widget_Data *wd = elm_widget_data_get(obj);
994 _text_day_color_set(wd, DAY_SATURDAY, pos);
997 EINA_DEPRECATED EAPI void
998 elm_calendar_text_sunday_color_set(Evas_Object *obj, int pos)
1000 ELM_CHECK_WIDTYPE(obj, widtype);
1001 Widget_Data *wd = elm_widget_data_get(obj);
1003 _text_day_color_set(wd, DAY_SUNDAY, pos);
1006 EINA_DEPRECATED EAPI void
1007 elm_calendar_text_weekday_color_set(Evas_Object *obj, int pos)
1009 ELM_CHECK_WIDTYPE(obj, widtype);
1010 Widget_Data *wd = elm_widget_data_get(obj);
1012 _text_day_color_set(wd, DAY_WEEKDAY, pos);