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 Elm_Calendar_Weekday first_week_day;
29 Ecore_Timer *spin, *update_timer;
30 Elm_Calendar_Format_Cb format_func;
31 const char *weekdays[ELM_DAY_LAST];
32 struct tm current_time, selected_time;
33 Day_Color day_color[42]; // EINA_DEPRECATED
34 Elm_Calendar_Select_Mode select_mode;
37 struct _Elm_Calendar_Mark
42 const char *mark_type;
43 Elm_Calendar_Mark_Repeat_Type repeat;
46 static const char *widtype = NULL;
47 static void _on_focus_hook(void *data, Evas_Object *obj);
48 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
50 static const char SIG_CHANGED[] = "changed";
52 static const Evas_Smart_Cb_Description _signals[] = {
58 /* Should not be translated, it's used if we failed
59 * getting from locale. */
60 static const char *_days_abbrev[] =
62 "Sun", "Mon", "Tue", "Wed",
66 static int _days_in_month[2][12] =
68 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
69 {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
72 static Elm_Calendar_Mark *
73 _mark_new(Evas_Object *obj, const char *mark_type, struct tm *mark_time, Elm_Calendar_Mark_Repeat_Type repeat)
75 Widget_Data *wd = elm_widget_data_get(obj);
76 Elm_Calendar_Mark *mark;
79 mark = calloc(1, sizeof(Elm_Calendar_Mark));
80 if (!mark) return NULL;
82 mark->mark_type = eina_stringshare_add(mark_type);
83 mark->mark_time = *mark_time;
84 mark->repeat = repeat;
89 _mark_free(Elm_Calendar_Mark *mark)
91 eina_stringshare_del(mark->mark_type);
96 _sizing_eval(Evas_Object *obj)
98 Widget_Data *wd = elm_widget_data_get(obj);
99 Evas_Coord minw = -1, minh = -1;
101 elm_coords_finger_size_adjust(8, &minw, 7, &minh);
102 edje_object_size_min_restricted_calc(wd->calendar, &minw, &minh, minw, minh);
103 evas_object_size_hint_min_set(obj, minw, minh);
104 evas_object_size_hint_max_set(obj, -1, -1);
108 _maxdays_get(struct tm *selected_time)
112 month = selected_time->tm_mon;
113 year = selected_time->tm_year + 1900;
115 return _days_in_month[((!(year % 4)) &&
122 _unselect(Widget_Data *wd, int selected)
125 snprintf(emission, sizeof(emission), "cit_%i,unselected", selected);
126 edje_object_signal_emit(wd->calendar, emission, "elm");
130 _select(Widget_Data *wd, int selected)
133 snprintf(emission, sizeof(emission), "cit_%i,selected", selected);
134 edje_object_signal_emit(wd->calendar, emission, "elm");
138 _not_today(Widget_Data *wd)
141 snprintf(emission, sizeof(emission), "cit_%i,not_today", wd->today_it);
142 edje_object_signal_emit(wd->calendar, emission, "elm");
147 _today(Widget_Data *wd, int it)
150 snprintf(emission, sizeof(emission), "cit_%i,today", it);
151 edje_object_signal_emit(wd->calendar, emission, "elm");
156 _format_month_year(struct tm *selected_time)
159 if (!strftime(buf, sizeof(buf), E_("%B %Y"), selected_time)) return NULL;
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) % ELM_DAY_LAST;
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");
202 _set_month_year(Widget_Data *wd)
206 /* Set selected month */
207 buf = wd->format_func(&wd->selected_time);
210 edje_object_part_text_set(wd->calendar, "month_text", buf);
214 edje_object_part_text_set(wd->calendar, "month_text", "");
218 _populate(Evas_Object *obj)
220 int maxdays, day, mon, yr, i;
221 Elm_Calendar_Mark *mark;
222 char part[12], day_s[3];
225 Eina_Bool last_row = EINA_TRUE;
226 Widget_Data *wd = elm_widget_data_get(obj);
230 if (wd->today_it > 0) _not_today(wd);
232 maxdays = _maxdays_get(&wd->selected_time);
233 mon = wd->selected_time.tm_mon;
234 yr = wd->selected_time.tm_year;
240 first_day = wd->selected_time;
241 first_day.tm_mday = 1;
244 // Layout of the calendar is changed for removing the unfilled last row.
245 if (first_day.tm_wday < (int)wd->first_week_day)
246 wd->first_day_it = first_day.tm_wday + ELM_DAY_LAST - wd->first_week_day;
248 wd->first_day_it = first_day.tm_wday - wd->first_week_day;
250 if ((35 - wd->first_day_it) > (maxdays - 1)) last_row = EINA_FALSE;
256 for (i = 0; i < 5; i++)
258 snprintf(emission, sizeof(emission), "cseph_%i,row_hide", i);
259 edje_object_signal_emit(wd->calendar, emission, "elm");
261 snprintf(emission, sizeof(emission), "cseph_%i,row_invisible", 5);
262 edje_object_signal_emit(wd->calendar, emission, "elm");
263 for (i = 0; i < 35; i++)
265 snprintf(emission, sizeof(emission), "cit_%i,cell_expanded", i);
266 edje_object_signal_emit(wd->calendar, emission, "elm");
268 for (i = 35; i < 42; i++)
270 snprintf(emission, sizeof(emission), "cit_%i,cell_invisible", i);
271 edje_object_signal_emit(wd->calendar, emission, "elm");
278 for (i = 0; i < 6; i++)
280 snprintf(emission, sizeof(emission), "cseph_%i,row_show", i);
281 edje_object_signal_emit(wd->calendar, emission, "elm");
283 for (i = 0; i < 42; i++)
285 snprintf(emission, sizeof(emission), "cit_%i,cell_default", i);
286 edje_object_signal_emit(wd->calendar, emission, "elm");
290 for (i = 0; i < 42; i++)
292 _text_day_color_update(wd, i); // EINA_DEPRECATED
293 if ((!day) && (i == wd->first_day_it)) day = 1;
295 if ((day == wd->current_time.tm_mday)
296 && (mon == wd->current_time.tm_mon)
297 && (yr == wd->current_time.tm_year))
300 if (day == wd->selected_time.tm_mday)
302 if ((wd->selected_it > -1) && (wd->selected_it != i))
303 _unselect(wd, wd->selected_it);
305 if (wd->select_mode != ELM_CALENDAR_SELECT_NONE) _select(wd, i);
310 if ((day) && (day <= maxdays))
311 snprintf(day_s, sizeof(day_s), "%i", day++);
315 snprintf(part, sizeof(part), "cit_%i.text", i);
316 edje_object_part_text_set(wd->calendar, part, day_s);
317 /* Clear previous marks */
318 _cit_mark(wd->calendar, i, "clear");
322 EINA_LIST_FOREACH(wd->marks, l, mark)
324 struct tm *mtime = &mark->mark_time;
325 int month = wd->selected_time.tm_mon;
326 int year = wd->selected_time.tm_year;
327 int mday_it = mtime->tm_mday + wd->first_day_it - 1;
329 switch (mark->repeat)
331 case ELM_CALENDAR_UNIQUE:
332 if ((mtime->tm_mon == month) && (mtime->tm_year == year))
333 _cit_mark(wd->calendar, mday_it, mark->mark_type);
335 case ELM_CALENDAR_DAILY:
336 if (((mtime->tm_year == year) && (mtime->tm_mon < month)) ||
337 (mtime->tm_year < year))
339 else if ((mtime->tm_year == year) && (mtime->tm_mon == month))
340 day = mtime->tm_mday;
343 for (; day <= maxdays; day++)
344 _cit_mark(wd->calendar, day + wd->first_day_it - 1,
347 case ELM_CALENDAR_WEEKLY:
348 if (((mtime->tm_year == year) && (mtime->tm_mon < month)) ||
349 (mtime->tm_year < year))
351 else if ((mtime->tm_year == year) && (mtime->tm_mon == month))
352 day = mtime->tm_mday;
355 for (; day <= maxdays; day++)
356 if (mtime->tm_wday == _weekday_get(wd->first_day_it, day))
357 _cit_mark(wd->calendar, day + wd->first_day_it - 1,
360 case ELM_CALENDAR_MONTHLY:
361 if (((mtime->tm_year < year) ||
362 ((mtime->tm_year == year) && (mtime->tm_mon <= month))) &&
363 (mtime->tm_mday <= maxdays))
364 _cit_mark(wd->calendar, mday_it, mark->mark_type);
366 case ELM_CALENDAR_ANNUALLY:
367 if ((mtime->tm_year <= year) && (mtime->tm_mon == month) &&
368 (mtime->tm_mday <= maxdays))
369 _cit_mark(wd->calendar, mday_it, mark->mark_type);
376 _set_headers(Evas_Object *obj)
378 static char part[] = "ch_0.text";
380 Widget_Data *wd = elm_widget_data_get(obj);
383 for (i = 0; i < ELM_DAY_LAST; i++)
386 edje_object_part_text_set(
388 wd->weekdays[(i + wd->first_week_day) % ELM_DAY_LAST]);
393 _del_hook(Evas_Object *obj)
396 Elm_Calendar_Mark *mark;
397 Widget_Data *wd = elm_widget_data_get(obj);
401 if (wd->spin) ecore_timer_del(wd->spin);
402 if (wd->update_timer) ecore_timer_del(wd->update_timer);
406 EINA_LIST_FREE(wd->marks, mark)
412 for (i = 0; i < ELM_DAY_LAST; i++)
413 eina_stringshare_del(wd->weekdays[i]);
419 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
421 Widget_Data *wd = elm_widget_data_get(obj);
423 if (elm_widget_focus_get(obj))
425 edje_object_signal_emit(wd->calendar, "elm,action,focus", "elm");
426 evas_object_focus_set(wd->calendar, EINA_TRUE);
430 edje_object_signal_emit(wd->calendar, "elm,action,unfocus", "elm");
431 evas_object_focus_set(wd->calendar, EINA_FALSE);
436 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
438 Widget_Data *wd = elm_widget_data_get(obj);
440 edje_object_mirrored_set(wd->calendar, rtl);
444 _theme_hook(Evas_Object *obj)
446 Widget_Data *wd = elm_widget_data_get(obj);
448 _elm_widget_mirrored_reload(obj);
449 _elm_theme_object_set(obj, wd->calendar, "calendar", "base",
450 elm_widget_style_get(obj));
451 _mirrored_set(obj, elm_widget_mirrored_get(obj));
454 edje_object_message_signal_process(wd->calendar);
455 edje_object_scale_set(wd->calendar,
456 elm_widget_scale_get(obj) * _elm_config->scale);
461 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
463 Widget_Data *wd = elm_widget_data_get(obj);
465 edje_object_signal_emit(wd->calendar, emission, source);
469 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
471 Widget_Data *wd = elm_widget_data_get(obj);
473 edje_object_signal_callback_add(wd->calendar, emission,
474 source, func_cb, data);
478 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
480 Widget_Data *wd = elm_widget_data_get(obj);
482 edje_object_signal_callback_del_full(wd->calendar, emission, source, func_cb,
486 /* Set correct tm_wday and tm_yday after other fields changes*/
488 _fix_selected_time(Widget_Data *wd)
490 mktime(&wd->selected_time);
494 _update_month(Evas_Object *obj, int delta)
496 struct tm time_check;
498 Widget_Data *wd = elm_widget_data_get(obj);
499 if (!wd) return EINA_FALSE;
501 /* check if it's a valid time. for 32 bits, year greater than 2037 is not */
502 time_check = wd->selected_time;
503 time_check.tm_mon += delta;
504 if (mktime(&time_check) == -1)
507 wd->selected_time.tm_mon += delta;
508 if (wd->selected_time.tm_mon < 0)
510 if (wd->selected_time.tm_year == wd->year_min)
512 wd->selected_time.tm_mon++;
515 wd->selected_time.tm_mon = 11;
516 wd->selected_time.tm_year--;
518 else if (wd->selected_time.tm_mon > 11)
520 if (wd->selected_time.tm_year == wd->year_max)
522 wd->selected_time.tm_mon--;
525 wd->selected_time.tm_mon = 0;
526 wd->selected_time.tm_year++;
529 maxdays = _maxdays_get(&wd->selected_time);
530 if (wd->selected_time.tm_mday > maxdays)
531 wd->selected_time.tm_mday = maxdays;
533 _fix_selected_time(wd);
534 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
540 _spin_value(void *data)
542 Widget_Data *wd = elm_widget_data_get(data);
543 if (!wd) return ECORE_CALLBACK_CANCEL;
544 if (_update_month(data, wd->spin_speed)) _populate(data);
545 wd->interval = wd->interval / 1.05;
546 ecore_timer_interval_set(wd->spin, wd->interval);
547 return ECORE_CALLBACK_RENEW;
551 _button_inc_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
553 Widget_Data *wd = elm_widget_data_get(data);
555 wd->interval = wd->first_interval;
557 if (wd->spin) ecore_timer_del(wd->spin);
558 wd->spin = ecore_timer_add(wd->interval, _spin_value, data);
563 _button_dec_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
565 Widget_Data *wd = elm_widget_data_get(data);
567 wd->interval = wd->first_interval;
569 if (wd->spin) ecore_timer_del(wd->spin);
570 wd->spin = ecore_timer_add(wd->interval, _spin_value, data);
575 _button_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
577 Widget_Data *wd = elm_widget_data_get(data);
579 wd->interval = wd->first_interval;
580 if (wd->spin) ecore_timer_del(wd->spin);
585 _get_item_day(Evas_Object *obj, int selected_it)
588 Widget_Data *wd = elm_widget_data_get(obj);
591 day = selected_it - wd->first_day_it + 1;
592 if ((day < 0) || (day > _maxdays_get(&wd->selected_time)))
599 _update_sel_it(Evas_Object *obj, int sel_it)
602 Widget_Data *wd = elm_widget_data_get(obj);
603 if ((!wd) || (wd->select_mode == ELM_CALENDAR_SELECT_NONE))
606 day = _get_item_day(obj, sel_it);
610 _unselect(wd, wd->selected_it);
612 wd->selected_it = sel_it;
613 wd->selected_time.tm_mday = day;
614 _select(wd, wd->selected_it);
615 _fix_selected_time(wd);
616 evas_object_smart_callback_call(obj, SIG_CHANGED, NULL);
620 _day_selected(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source)
623 Widget_Data *wd = elm_widget_data_get(data);
624 if ((!wd) || (wd->select_mode == ELM_CALENDAR_SELECT_NONE))
626 sel_it = atoi(source);
628 _update_sel_it(data, sel_it);
632 _time_to_next_day(struct tm *t)
634 return ((((24 - t->tm_hour) * 60) - t->tm_min) * 60) - t->tm_sec;
638 _update_cur_date(void *data)
642 Widget_Data *wd = elm_widget_data_get(data);
643 if (!wd) return ECORE_CALLBACK_RENEW;
645 if (wd->today_it > 0) _not_today(wd);
647 current_time = time(NULL);
648 localtime_r(¤t_time, &wd->current_time);
649 t = _time_to_next_day(&wd->current_time);
650 ecore_timer_interval_set(wd->update_timer, t);
652 if ((wd->current_time.tm_mon != wd->selected_time.tm_mon) ||
653 (wd->current_time.tm_year!= wd->selected_time.tm_year))
654 return ECORE_CALLBACK_RENEW;
656 day = wd->current_time.tm_mday + wd->first_day_it - 1;
659 return ECORE_CALLBACK_RENEW;
663 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
665 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
666 Evas_Event_Key_Down *ev = event_info;
667 Widget_Data *wd = elm_widget_data_get(obj);
669 if (!wd) return EINA_FALSE;
670 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
671 if (wd->select_mode == ELM_CALENDAR_SELECT_NONE) return EINA_FALSE;
673 if ((!strcmp(ev->keyname, "Left")) ||
674 ((!strcmp(ev->keyname, "KP_Left")) && (!ev->string)))
676 _update_sel_it(obj, wd->selected_it-1);
678 else if ((!strcmp(ev->keyname, "Right")) ||
679 ((!strcmp(ev->keyname, "KP_Right")) && (!ev->string)))
681 _update_sel_it(obj, wd->selected_it+1);
683 else if ((!strcmp(ev->keyname, "Up")) ||
684 ((!strcmp(ev->keyname, "KP_Up")) && (!ev->string)))
686 _update_sel_it(obj, wd->selected_it-ELM_DAY_LAST);
688 else if ((!strcmp(ev->keyname, "Down")) ||
689 ((!strcmp(ev->keyname, "KP_Down")) && (!ev->string)))
691 _update_sel_it(obj, wd->selected_it+ELM_DAY_LAST);
693 else if ((!strcmp(ev->keyname, "Prior")) ||
694 ((!strcmp(ev->keyname, "KP_Prior")) && (!ev->string)))
696 if (_update_month(obj, -1)) _populate(obj);
698 else if ((!strcmp(ev->keyname, "Next")) ||
699 ((!strcmp(ev->keyname, "KP_Next")) && (!ev->string)))
701 if (_update_month(obj, 1)) _populate(obj);
703 else return EINA_FALSE;
709 elm_calendar_add(Evas_Object *parent)
712 time_t weekday = 259200; /* Just the first sunday since epoch */
718 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
720 ELM_SET_WIDTYPE(widtype, "calendar");
721 elm_widget_type_set(obj, "calendar");
722 elm_widget_sub_object_add(parent, obj);
723 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
724 elm_widget_data_set(obj, wd);
725 elm_widget_del_hook_set(obj, _del_hook);
726 elm_widget_theme_hook_set(obj, _theme_hook);
727 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
728 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
729 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
730 elm_widget_can_focus_set(obj, EINA_TRUE);
731 elm_widget_event_hook_set(obj, _event_hook);
733 wd->first_interval = 0.85;
737 wd->selected_it = -1;
738 wd->first_day_it = -1;
739 wd->format_func = _format_month_year;
742 wd->calendar = edje_object_add(e);
743 _elm_theme_object_set(obj, wd->calendar, "calendar", "base", "default");
744 elm_widget_resize_object_set(obj, wd->calendar);
746 edje_object_signal_callback_add(wd->calendar, "elm,action,increment,start",
747 "*", _button_inc_start, obj);
748 edje_object_signal_callback_add(wd->calendar, "elm,action,decrement,start",
749 "*", _button_dec_start, obj);
750 edje_object_signal_callback_add(wd->calendar, "elm,action,stop",
751 "*", _button_stop, obj);
752 edje_object_signal_callback_add(wd->calendar, "elm,action,selected",
753 "*", _day_selected, obj);
755 evas_object_smart_callbacks_descriptions_set(obj, _signals);
757 for (i = 0; i < ELM_DAY_LAST; i++)
759 /* FIXME: I'm not aware of a known max, so if it fails,
760 * just make it larger. :| */
762 /* I don't know of a better way of doing it */
763 if (strftime(buf, sizeof(buf), "%a", gmtime(&weekday)))
765 wd->weekdays[i] = eina_stringshare_add(buf);
769 /* If we failed getting day, get a default value */
770 wd->weekdays[i] = _days_abbrev[i];
771 WRN("Failed getting weekday name for '%s' from locale.",
774 weekday += 86400; /* Advance by a day */
777 current_time = time(NULL);
778 localtime_r(¤t_time, &wd->selected_time);
779 wd->current_time = wd->selected_time;
780 t = _time_to_next_day(&wd->current_time);
781 wd->update_timer = ecore_timer_add(t, _update_cur_date, obj);
785 _mirrored_set(obj, elm_widget_mirrored_get(obj));
791 elm_calendar_weekdays_names_set(Evas_Object *obj, const char *weekdays[])
794 ELM_CHECK_WIDTYPE(obj, widtype);
795 Widget_Data *wd = elm_widget_data_get(obj);
798 EINA_SAFETY_ON_NULL_RETURN(weekdays);
800 for (i = 0; i < ELM_DAY_LAST; i++)
802 eina_stringshare_replace(&wd->weekdays[i], weekdays[i]);
808 elm_calendar_weekdays_names_get(const Evas_Object *obj)
810 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
811 Widget_Data *wd = elm_widget_data_get(obj);
812 if (!wd) return NULL;
817 elm_calendar_interval_set(Evas_Object *obj, double interval)
819 ELM_CHECK_WIDTYPE(obj, widtype);
820 Widget_Data *wd = elm_widget_data_get(obj);
822 wd->first_interval = interval;
826 elm_calendar_interval_get(const Evas_Object *obj)
828 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
829 Widget_Data *wd = elm_widget_data_get(obj);
831 return wd->first_interval;
835 elm_calendar_min_max_year_set(Evas_Object *obj, int min, int max)
837 ELM_CHECK_WIDTYPE(obj, widtype);
838 Widget_Data *wd = elm_widget_data_get(obj);
842 if ((wd->year_min == min) && (wd->year_max == max)) return;
843 wd->year_min = min > 2 ? min : 2;
844 if (max > wd->year_min)
847 wd->year_max = wd->year_min;
848 if (wd->selected_time.tm_year > wd->year_max)
849 wd->selected_time.tm_year = wd->year_max;
850 if (wd->selected_time.tm_year < wd->year_min)
851 wd->selected_time.tm_year = wd->year_min;
852 _fix_selected_time(wd);
857 elm_calendar_min_max_year_get(const Evas_Object *obj, int *min, int *max)
859 ELM_CHECK_WIDTYPE(obj, widtype);
860 Widget_Data *wd = elm_widget_data_get(obj);
862 if (min) *min = wd->year_min + 1900;
863 if (max) *max = wd->year_max + 1900;
866 EINA_DEPRECATED EAPI void
867 elm_calendar_day_selection_disabled_set(Evas_Object *obj, Eina_Bool disabled)
870 elm_calendar_select_mode_set(obj, ELM_CALENDAR_SELECT_NONE);
872 elm_calendar_select_mode_set(obj, ELM_CALENDAR_SELECT_DEFAULT);
875 EINA_DEPRECATED EAPI Eina_Bool
876 elm_calendar_day_selection_disabled_get(const Evas_Object *obj)
878 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
879 Widget_Data *wd = elm_widget_data_get(obj);
880 if (!wd) return EINA_FALSE;
881 return !!(wd->select_mode == ELM_CALENDAR_SELECT_NONE);
885 elm_calendar_selected_time_set(Evas_Object *obj, struct tm *selected_time)
887 ELM_CHECK_WIDTYPE(obj, widtype);
888 Widget_Data *wd = elm_widget_data_get(obj);
891 EINA_SAFETY_ON_NULL_RETURN(selected_time);
892 wd->selected_time = *selected_time;
898 elm_calendar_selected_time_get(const Evas_Object *obj, struct tm *selected_time)
900 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
901 Widget_Data *wd = elm_widget_data_get(obj);
902 if (!wd) return EINA_FALSE;
903 EINA_SAFETY_ON_NULL_RETURN_VAL(selected_time, EINA_FALSE);
904 *selected_time = wd->selected_time;
909 elm_calendar_format_function_set(Evas_Object *obj, Elm_Calendar_Format_Cb format_function)
911 ELM_CHECK_WIDTYPE(obj, widtype);
912 Widget_Data *wd = elm_widget_data_get(obj);
914 wd->format_func = format_function;
918 EAPI Elm_Calendar_Mark *
919 elm_calendar_mark_add(Evas_Object *obj, const char *mark_type, struct tm *mark_time, Elm_Calendar_Mark_Repeat_Type repeat)
921 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
922 Widget_Data *wd = elm_widget_data_get(obj);
923 Elm_Calendar_Mark *mark;
924 if (!wd) return NULL;
926 mark = _mark_new(obj, mark_type, mark_time, repeat);
927 wd->marks = eina_list_append(wd->marks, mark);
928 mark->node = eina_list_last(wd->marks);
933 elm_calendar_mark_del(Elm_Calendar_Mark *mark)
938 EINA_SAFETY_ON_NULL_RETURN(mark);
941 wd = elm_widget_data_get(obj);
944 wd->marks = eina_list_remove_list(wd->marks, mark->node);
949 elm_calendar_marks_clear(Evas_Object *obj)
951 ELM_CHECK_WIDTYPE(obj, widtype);
952 Widget_Data *wd = elm_widget_data_get(obj);
953 Elm_Calendar_Mark *mark;
956 EINA_LIST_FREE(wd->marks, mark)
960 EAPI const Eina_List *
961 elm_calendar_marks_get(const Evas_Object *obj)
963 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
964 Widget_Data *wd = elm_widget_data_get(obj);
965 if (!wd) return NULL;
970 elm_calendar_marks_draw(Evas_Object *obj)
972 ELM_CHECK_WIDTYPE(obj, widtype);
973 Widget_Data *wd = elm_widget_data_get(obj);
979 elm_calendar_first_day_of_week_set(Evas_Object *obj, Elm_Calendar_Weekday day)
981 ELM_CHECK_WIDTYPE(obj, widtype);
982 Widget_Data *wd = elm_widget_data_get(obj);
984 if (day >= ELM_DAY_LAST) return;
985 if (wd->first_week_day != day)
987 wd->first_week_day = day;
993 EAPI Elm_Calendar_Weekday
994 elm_calendar_first_day_of_week_get(const Evas_Object *obj)
996 ELM_CHECK_WIDTYPE(obj, widtype) -1;
997 Widget_Data *wd = elm_widget_data_get(obj);
999 return wd->first_week_day;
1003 elm_calendar_select_mode_set(Evas_Object *obj, Elm_Calendar_Select_Mode mode)
1005 ELM_CHECK_WIDTYPE(obj, widtype);
1006 Widget_Data *wd = elm_widget_data_get(obj);
1008 if ((mode >= ELM_CALENDAR_SELECT_DEFAULT)
1009 && (mode <= ELM_CALENDAR_SELECT_ONDEMAND)
1010 && (wd->select_mode != mode))
1012 wd->select_mode = mode;
1013 if (wd->select_mode == ELM_CALENDAR_SELECT_ALWAYS)
1014 _select(wd, wd->selected_it);
1016 _unselect(wd, wd->selected_it);
1020 EAPI Elm_Calendar_Select_Mode
1021 elm_calendar_select_mode_get(const Evas_Object *obj)
1023 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1024 Widget_Data *wd = elm_widget_data_get(obj);
1026 return wd->select_mode;