elm elm_widget.c: Print error message when unsupported elm_object_item_part_content_s...
[framework/uifw/elementary.git] / src / lib / elc_dayselector.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3
4 typedef struct _Widget_Data Widget_Data;
5 typedef struct _Elm_Dayselector_Item Elm_Dayselector_Item;
6
7 /* signals to edc */
8 #define ITEM_TYPE_WEEKDAY_DEFAULT    "elm,type,weekday,default"
9 #define ITEM_TYPE_WEEKDAY_STYLE1     "elm,type,weekday,style1"
10 #define ITEM_TYPE_WEEKEND_DEFAULT    "elm,type,weekend,default"
11 #define ITEM_TYPE_WEEKEND_STYLE1     "elm,type,weekend,style1"
12 #define ITEM_POS_LEFT                "elm,pos,check,left"
13 #define ITEM_POS_RIGHT               "elm,pos,check,right"
14 #define ITEM_POS_MIDDLE              "elm,pos,check,middle"
15
16 struct _Widget_Data
17 {
18    Evas_Object *base;
19    Eina_List *items;
20    Elm_Dayselector_Day week_start;
21    Elm_Dayselector_Day weekend_start;
22    unsigned int weekend_len;
23 };
24
25 struct _Elm_Dayselector_Item
26 {
27    ELM_WIDGET_ITEM;
28    Elm_Dayselector_Day day;
29    const char *day_style;
30 };
31
32 static const char *widtype = NULL;
33 static void _del_hook(Evas_Object *obj);
34 static void _sizing_eval(Evas_Object* obj);
35 static void _dayselector_resize(void *data, Evas *e __UNUSED__,
36             Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
37 static void _disable_hook(Evas_Object *obj);
38 static Eina_Bool _focus_next_hook(const Evas_Object *obj,
39                                   Elm_Focus_Direction dir __UNUSED__,
40                                   Evas_Object **next __UNUSED__);
41 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
42 static void _translate_hook(Evas_Object *obj);
43 static void _theme_hook(Evas_Object *obj);
44 static void _item_text_set_hook(Evas_Object *obj, const char *item,
45                                 const char *label);
46 static const char *_item_text_get_hook(const Evas_Object *obj,
47                                        const char *item);
48 static void _content_set_hook(Evas_Object *obj, const char *item,
49                               Evas_Object *content);
50 static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *item);
51 static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *item);
52 static void _signal_emit_cb(void *data, Evas_Object *obj, const char *emission,
53                             const char *source __UNUSED__);
54 static void _item_clicked_cb(void *data, Evas_Object *obj,
55                              void *event_info __UNUSED__);
56 static Elm_Dayselector_Item * _item_find(const Evas_Object *obj,
57                                          Elm_Dayselector_Day day);
58 static void _items_style_set(Evas_Object *obj);
59 static void _update_items(Evas_Object *obj);
60 static void _create_items(Evas_Object *obj);
61
62 static const char SIG_CHANGED[] = "dayselector,changed";
63 static const char SIG_LANG_CHANGED[] = "language,changed";
64 static const Evas_Smart_Cb_Description _signals[] = {
65        {SIG_CHANGED, ""},
66        {SIG_LANG_CHANGED, ""},
67        {NULL, NULL}
68 };
69
70 static void
71 _del_hook(Evas_Object *obj)
72 {
73    Elm_Dayselector_Item *it;
74    Widget_Data *wd = elm_widget_data_get(obj);
75    if (!wd) return;
76
77    EINA_LIST_FREE(wd->items, it)
78      {
79         wd->items = eina_list_remove(wd->items, it);
80         eina_stringshare_del(it->day_style);
81         elm_widget_item_free(it);
82      }
83    free(wd);
84 }
85
86 static void
87 _sizing_eval(Evas_Object* obj)
88 {
89    Evas_Coord min_w = -1, min_h = -1;
90    Widget_Data *wd = elm_widget_data_get(obj);
91    if (!wd) return;
92
93    elm_coords_finger_size_adjust(ELM_DAYSELECTOR_MAX, &min_w, 1, &min_h);
94    edje_object_size_min_restricted_calc(wd->base, &min_w, &min_h, min_w, min_h);
95    elm_coords_finger_size_adjust(ELM_DAYSELECTOR_MAX, &min_w, 1, &min_h);
96    evas_object_size_hint_min_set(obj, min_w, min_h);
97 }
98
99 static void
100 _dayselector_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
101                     void *event_info __UNUSED__)
102 {
103    _sizing_eval(data);
104 }
105
106 static void
107 _disable_hook(Evas_Object *obj)
108 {
109    Widget_Data* wd = elm_widget_data_get(obj);
110    if (!wd) return;
111
112    if (elm_widget_disabled_get(obj))
113      edje_object_signal_emit(wd->base, "elm,state,disabled", "elm");
114    else
115      edje_object_signal_emit(wd->base, "elm,state,enabled", "elm");
116 }
117
118 static Eina_Bool
119 _focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir __UNUSED__,
120                  Evas_Object **next __UNUSED__)
121 {
122    Widget_Data *wd = elm_widget_data_get(obj);
123    if (!wd) return EINA_FALSE;
124
125    /* TODO: Focus switch support to Elm_widget_Item is not supported yet.*/
126    return EINA_FALSE;
127 }
128
129 static void
130 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
131 {
132    Widget_Data *wd = elm_widget_data_get(obj);
133    if (!wd) return;
134
135    edje_object_mirrored_set(wd->base, rtl);
136 }
137
138 static void
139 _translate_hook(Evas_Object *obj)
140 {
141    Eina_List *l;
142    Elm_Dayselector_Item *it;
143    struct tm time_daysel;
144    time_t t;
145    char buf[1024];
146    Widget_Data *wd = elm_widget_data_get(obj);
147    if (!wd) return;
148
149    t = time(NULL);
150    localtime_r(&t, &time_daysel);
151    EINA_LIST_FOREACH(wd->items, l, it)
152      {
153         time_daysel.tm_wday = it->day;
154         strftime(buf, sizeof(buf), "%a", &time_daysel);
155         elm_object_text_set(VIEW(it), buf);
156      }
157    evas_object_smart_callback_call(obj, SIG_LANG_CHANGED, NULL);
158 }
159
160 static void
161 _theme_hook(Evas_Object *obj)
162 {
163    Eina_List *l;
164    Elm_Dayselector_Item *it;
165    char buf[1024];
166    unsigned int loc;
167    Widget_Data* wd = elm_widget_data_get(obj);
168    if (!wd) return;
169
170    _elm_widget_mirrored_reload(obj);
171    _mirrored_set(obj, elm_widget_mirrored_get(obj));
172    _elm_theme_object_set(obj, wd->base, "dayselector", "base",
173                          elm_widget_style_get(obj));
174
175    EINA_LIST_FOREACH(wd->items, l, it)
176      {
177         snprintf(buf, sizeof(buf), "dayselector/%s", elm_object_style_get(obj));
178         elm_object_style_set(VIEW(it), buf);
179         loc = (ELM_DAYSELECTOR_MAX - wd->week_start + it->day) % ELM_DAYSELECTOR_MAX;
180         snprintf(buf, sizeof(buf), "day%d,visible", loc);
181         edje_object_signal_emit(wd->base, buf, "elm");
182         snprintf(buf, sizeof(buf), "day%d", loc);
183         edje_object_part_swallow(wd->base, buf, VIEW(it));
184      }
185    _update_items(obj);
186    _sizing_eval(obj);
187 }
188
189 static void
190 _item_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj,
191              void *event_info __UNUSED__)
192 {
193    ELM_CHECK_WIDTYPE(data, widtype);
194    Eina_List *l;
195    Elm_Dayselector_Item *it;
196    char buf[1024];
197    unsigned int loc = 0;
198    Widget_Data *wd = elm_widget_data_get(data);
199    if (!wd) return;
200
201    EINA_LIST_FOREACH(wd->items, l, it)
202      {
203         if (obj == VIEW(it))
204           {
205              wd->items = eina_list_remove(wd->items, it);
206              eina_stringshare_del(it->day_style);
207              evas_object_smart_callback_del(VIEW(it), "changed", _item_clicked_cb);
208              evas_object_event_callback_del(VIEW(it), EVAS_CALLBACK_DEL, _item_del_cb);
209              edje_object_part_unswallow(wd->base, VIEW(it));
210              loc = (ELM_DAYSELECTOR_MAX - wd->week_start + it->day) % ELM_DAYSELECTOR_MAX;
211              snprintf(buf, sizeof(buf), "day%d,default", loc);
212              edje_object_signal_emit(wd->base, buf, "elm");
213              elm_widget_item_free(it);
214              _sizing_eval(obj);
215              break;
216           }
217      }
218 }
219
220 static void
221 _signal_emit_cb(void *data, Evas_Object *obj, const char *emission, const char *source __UNUSED__)
222 {
223    Eina_List *l;
224    Elm_Dayselector_Item *it;
225    Widget_Data *wd = elm_widget_data_get(data);
226    if (!wd) return;
227
228    EINA_LIST_FOREACH(wd->items, l, it)
229      {
230         if (obj == VIEW(it))
231           {
232              eina_stringshare_replace(&it->day_style, emission);
233              return ;
234           }
235      }
236 }
237
238 static void
239 _item_text_set_hook(Evas_Object *obj, const char *item, const char *label)
240 {
241    ELM_CHECK_WIDTYPE(obj, widtype);
242    Eina_List *l;
243    Elm_Dayselector_Item *it;
244    char buf[1024];
245    Widget_Data *wd = elm_widget_data_get(obj);
246    if (item && !strcmp(item, "default")) return;
247    if (!wd) return;
248
249    EINA_LIST_FOREACH(wd->items, l, it)
250      {
251         snprintf(buf, sizeof(buf), "day%d", it->day);
252         if (!strncmp(buf, item, sizeof(buf)))
253           {
254              elm_object_text_set(VIEW(it), label);
255              _sizing_eval(obj);
256              break;
257           }
258      }
259 }
260
261 static const char *
262 _item_text_get_hook(const Evas_Object *obj, const char *item)
263 {
264    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
265    Eina_List *l;
266    Elm_Dayselector_Item *it;
267    char buf[1024];
268    Widget_Data *wd = elm_widget_data_get(obj);
269    if (item && !strcmp(item, "default")) return NULL;
270    if (!wd) return NULL;
271
272    EINA_LIST_FOREACH(wd->items, l, it)
273      {
274         snprintf(buf, sizeof(buf), "day%d", it->day);
275         if (!strncmp(buf, item, sizeof(buf)))
276           return elm_object_text_get(VIEW(it));
277      }
278    return NULL;
279 }
280
281 static void
282 _content_set_hook(Evas_Object *obj, const char *item, Evas_Object *content)
283 {
284    ELM_CHECK_WIDTYPE(obj, widtype);
285    Eina_List *l;
286    Elm_Dayselector_Item *it;
287    char buf[1024];
288    unsigned int idx, loc;
289    Widget_Data *wd = elm_widget_data_get(obj);
290    if (!wd || !content) return;
291    if (item && !strcmp(item, "default")) return;
292    if (strcmp(elm_object_widget_type_get(content), "check")) return;
293
294    EINA_LIST_FOREACH(wd->items, l, it)
295      {
296         snprintf(buf, sizeof(buf), "day%d", it->day);
297         if (!strncmp(buf, item, sizeof(buf)))
298           {
299              if (VIEW(it)) evas_object_del(VIEW(it));
300              break;
301           }
302      }
303    for (idx = 0; idx < ELM_DAYSELECTOR_MAX; idx++)
304      {
305         snprintf(buf, sizeof(buf), "day%d", idx);
306         if (!strncmp(buf, item, sizeof(buf)))
307           {
308              it = elm_widget_item_new(obj, Elm_Dayselector_Item);
309              if (!it) continue;
310              VIEW(it) = content;
311              it->day = idx;
312              wd->items = eina_list_append(wd->items, it);
313              elm_widget_sub_object_add(obj, content);
314              loc = (ELM_DAYSELECTOR_MAX - wd->week_start + idx) % ELM_DAYSELECTOR_MAX;
315              snprintf(buf, sizeof(buf), "day%d", loc);
316              edje_object_part_swallow(wd->base, buf, VIEW(it));
317              snprintf(buf, sizeof(buf), "day%d,visible", loc);
318              edje_object_signal_emit(wd->base, buf, "elm");
319              evas_object_smart_callback_add(VIEW(it), "changed", _item_clicked_cb, obj);
320              evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_DEL, _item_del_cb, obj);
321              elm_object_signal_callback_add(VIEW(it), ITEM_TYPE_WEEKDAY_DEFAULT, "", _signal_emit_cb, obj);
322              elm_object_signal_callback_add(VIEW(it), ITEM_TYPE_WEEKDAY_STYLE1, "", _signal_emit_cb, obj);
323              elm_object_signal_callback_add(VIEW(it), ITEM_TYPE_WEEKEND_DEFAULT, "", _signal_emit_cb, obj);
324              elm_object_signal_callback_add(VIEW(it), ITEM_TYPE_WEEKEND_STYLE1, "", _signal_emit_cb, obj);
325              _sizing_eval(obj);
326              _update_items(obj);
327              break;
328           }
329      }
330 }
331
332 static Evas_Object *
333 _content_get_hook(const Evas_Object *obj, const char *item)
334 {
335    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
336    Eina_List *l;
337    Elm_Dayselector_Item *it;
338    char buf[1024];
339    Widget_Data *wd = elm_widget_data_get(obj);
340    if (!wd) return NULL;
341    if (item && !strcmp(item, "default")) return NULL;
342
343    EINA_LIST_FOREACH(wd->items, l, it)
344      {
345         snprintf(buf, sizeof(buf), "day%d", it->day);
346         if (!strncmp(buf, item, sizeof(buf))) return VIEW(it);
347      }
348    return NULL;
349 }
350
351 static Evas_Object *
352 _content_unset_hook(Evas_Object *obj, const char *item)
353 {
354    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
355    Eina_List *l;
356    Elm_Dayselector_Item *it;
357    Evas_Object *content;
358    char buf[1024];
359    unsigned int loc;
360    Widget_Data *wd = elm_widget_data_get(obj);
361    if (!wd) return NULL;
362    if (item && !strcmp(item, "default")) return NULL;
363
364    EINA_LIST_FOREACH(wd->items, l, it)
365      {
366         snprintf(buf, sizeof(buf), "day%d", it->day);
367         if (!strncmp(buf, item, sizeof(buf)))
368           {
369              content = VIEW(it);
370              wd->items = eina_list_remove(wd->items, it);
371              elm_widget_sub_object_del(obj, VIEW(it));
372              evas_object_smart_callback_del(VIEW(it), "changed", _item_clicked_cb);
373              evas_object_event_callback_del(VIEW(it), EVAS_CALLBACK_DEL, _item_del_cb);
374              edje_object_part_unswallow(wd->base, VIEW(it));
375              loc = (ELM_DAYSELECTOR_MAX - wd->week_start + it->day) % ELM_DAYSELECTOR_MAX;
376              snprintf(buf, sizeof(buf), "day%d,default", loc);
377              edje_object_signal_emit(wd->base, buf, "elm");
378              _sizing_eval(obj);
379              return content;
380           }
381      }
382    return NULL;
383 }
384
385 static void
386 _item_clicked_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
387 {
388    Eina_List *l;
389    Elm_Dayselector_Item *it;
390    Widget_Data *wd = elm_widget_data_get(data);
391    if (!wd) return;
392
393    EINA_LIST_FOREACH(wd->items, l, it)
394      {
395         if (obj != VIEW(it)) continue;
396         evas_object_smart_callback_call(data, SIG_CHANGED, (void *)it->day);
397         return;
398      }
399 }
400
401 static Elm_Dayselector_Item *
402 _item_find(const Evas_Object *obj, Elm_Dayselector_Day day)
403 {
404    Eina_List *l;
405    Elm_Dayselector_Item *it;
406    Widget_Data* wd = elm_widget_data_get(obj);
407    if (!wd) return NULL;
408
409    EINA_LIST_FOREACH(wd->items, l, it)
410      if (day == it->day) return it;
411
412    return NULL;
413 }
414
415 static void
416 _items_style_set(Evas_Object *obj)
417 {
418    ELM_CHECK_WIDTYPE(obj, widtype);
419    Eina_List *l;
420    Elm_Dayselector_Item *it;
421    unsigned int weekend_last;
422    Widget_Data* wd = elm_widget_data_get(obj);
423    if (!wd) return;
424
425    weekend_last = wd->weekend_start + wd->weekend_len - 1;
426    if (weekend_last >= ELM_DAYSELECTOR_MAX)
427      weekend_last = weekend_last % ELM_DAYSELECTOR_MAX;
428
429    EINA_LIST_FOREACH(wd->items, l, it)
430      {
431         if (weekend_last >= wd->weekend_start)
432           {
433              if ((it->day >= wd->weekend_start) && (it->day <= weekend_last))
434                eina_stringshare_replace(&it->day_style,
435                                         ITEM_TYPE_WEEKEND_DEFAULT);
436              else
437                eina_stringshare_replace(&it->day_style,
438                                         ITEM_TYPE_WEEKDAY_DEFAULT);
439           }
440         else
441           {
442              if ((it->day >= wd->weekend_start) || (it->day <= weekend_last))
443                eina_stringshare_replace(&it->day_style,
444                                         ITEM_TYPE_WEEKEND_DEFAULT);
445              else
446                eina_stringshare_replace(&it->day_style,
447                                         ITEM_TYPE_WEEKDAY_DEFAULT);
448           }
449      }
450 }
451
452 static void
453 _update_items(Evas_Object *obj)
454 {
455    Eina_List *l;
456    Elm_Dayselector_Item *it;
457    unsigned int last_day;
458    Eina_Bool rtl;
459    Widget_Data* wd = elm_widget_data_get(obj);
460    if (!wd) return;
461
462    last_day = wd->week_start + ELM_DAYSELECTOR_MAX - 1;
463    if (last_day >= ELM_DAYSELECTOR_MAX)
464      last_day = last_day % ELM_DAYSELECTOR_MAX;
465
466    rtl = elm_widget_mirrored_get(obj);
467    EINA_LIST_FOREACH(wd->items, l, it)
468      {
469         elm_object_signal_emit(VIEW(it), it->day_style, "");
470         if (it->day == wd->week_start)
471           {
472              if (rtl) elm_object_signal_emit(VIEW(it), ITEM_POS_RIGHT, "elm");
473              else elm_object_signal_emit(VIEW(it), ITEM_POS_LEFT, "elm");
474           }
475         else if (it->day == last_day)
476           {
477              if (rtl) elm_object_signal_emit(VIEW(it), ITEM_POS_LEFT, "elm");
478              else elm_object_signal_emit(VIEW(it), ITEM_POS_RIGHT, "elm");
479           }
480         else
481           elm_object_signal_emit(VIEW(it), ITEM_POS_MIDDLE, "elm");
482      }
483 }
484
485 static void
486 _create_items(Evas_Object *obj)
487 {
488    Elm_Dayselector_Item *it;
489    struct tm time_daysel;
490    time_t t;
491    char buf[1024];
492    unsigned int idx, loc;
493    Widget_Data* wd = elm_widget_data_get(obj);
494    if (!wd) return;
495
496    t = time(NULL);
497    localtime_r(&t, &time_daysel);
498
499    for (idx = 0; idx < ELM_DAYSELECTOR_MAX; idx++)
500      {
501         it = elm_widget_item_new(obj, Elm_Dayselector_Item);
502         if (!it) continue;
503         VIEW(it) = elm_check_add(wd->base);
504         elm_widget_sub_object_add(obj, VIEW(it));
505         wd->items = eina_list_append(wd->items, it);
506         elm_object_style_set(VIEW(it), "dayselector/default");
507         time_daysel.tm_wday = idx;
508         strftime(buf, sizeof(buf), "%a", &time_daysel);
509         elm_object_text_set(VIEW(it), buf);
510         it->day = idx;
511         loc = (ELM_DAYSELECTOR_MAX - wd->week_start + idx) % ELM_DAYSELECTOR_MAX;
512         snprintf(buf, sizeof(buf), "day%d", loc);
513         edje_object_part_swallow(wd->base, buf, VIEW(it));
514         snprintf(buf, sizeof(buf), "day%d,visible", idx);
515         edje_object_signal_emit(wd->base, buf, "elm");
516         evas_object_smart_callback_add(VIEW(it), "changed", _item_clicked_cb,
517                                        obj);
518         evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_DEL,
519                                        _item_del_cb, obj);
520         elm_object_signal_callback_add(VIEW(it), ITEM_TYPE_WEEKDAY_DEFAULT, "",
521                                        _signal_emit_cb, obj);
522         elm_object_signal_callback_add(VIEW(it), ITEM_TYPE_WEEKDAY_STYLE1, "",
523                                        _signal_emit_cb, obj);
524         elm_object_signal_callback_add(VIEW(it), ITEM_TYPE_WEEKEND_DEFAULT, "",
525                                        _signal_emit_cb, obj);
526         elm_object_signal_callback_add(VIEW(it), ITEM_TYPE_WEEKEND_STYLE1, "",
527                                        _signal_emit_cb, obj);
528      }
529    _items_style_set(obj);
530    _update_items(obj);
531 }
532
533 EAPI Evas_Object *
534 elm_dayselector_add(Evas_Object *parent)
535 {
536    Evas_Object *obj;
537    Evas *e;
538    Widget_Data *wd;
539
540    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
541
542    ELM_SET_WIDTYPE(widtype, "dayselector");
543    elm_widget_type_set(obj, widtype);
544    elm_widget_sub_object_add(parent, obj);
545    elm_widget_data_set(obj, wd);
546    elm_widget_del_hook_set(obj, _del_hook);
547    elm_widget_theme_hook_set(obj, _theme_hook);
548    elm_widget_disable_hook_set(obj, _disable_hook);
549    elm_widget_focus_next_hook_set(obj, _focus_next_hook);
550    elm_widget_translate_hook_set(obj, _translate_hook);
551    elm_widget_text_set_hook_set(obj, _item_text_set_hook);
552    elm_widget_text_get_hook_set(obj, _item_text_get_hook);
553    elm_widget_content_set_hook_set(obj, _content_set_hook);
554    elm_widget_content_get_hook_set(obj, _content_get_hook);
555    elm_widget_content_unset_hook_set(obj, _content_unset_hook);
556
557    wd->base = edje_object_add(e);
558    _elm_theme_object_set(obj, wd->base, "dayselector", "base", "default");
559    elm_object_style_set(wd->base, "dayselector");
560    elm_widget_resize_object_set(obj, wd->base);
561
562    wd->week_start = _elm_config->week_start;
563    wd->weekend_start = _elm_config->weekend_start;
564    wd->weekend_len = _elm_config->weekend_len;
565    printf("%d %d %d\n", wd->week_start, wd->weekend_start, wd->weekend_len);
566    _create_items(obj);
567
568    evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
569                                   _dayselector_resize, obj);
570    evas_object_smart_callbacks_descriptions_set(obj, _signals);
571    _mirrored_set(obj, elm_widget_mirrored_get(obj));
572    _sizing_eval(obj);
573    return obj;
574 }
575
576 EAPI void
577 elm_dayselector_day_selected_set(Evas_Object *obj, Elm_Dayselector_Day day, Eina_Bool selected)
578 {
579    ELM_CHECK_WIDTYPE(obj, widtype);
580    Widget_Data* wd = elm_widget_data_get(obj);
581    if (!wd) return;
582
583    elm_check_state_set(VIEW(_item_find(obj, day)), selected);
584 }
585
586 EAPI Eina_Bool
587 elm_dayselector_day_selected_get(const Evas_Object *obj, Elm_Dayselector_Day day)
588 {
589    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
590    Widget_Data* wd = elm_widget_data_get(obj);
591    if (!wd) return EINA_FALSE;
592
593    return elm_check_state_get(VIEW(_item_find(obj, day)));
594 }
595
596 EAPI void
597 elm_dayselector_week_start_set(Evas_Object *obj, Elm_Dayselector_Day day)
598 {
599    ELM_CHECK_WIDTYPE(obj, widtype);
600    Eina_List *l;
601    Elm_Dayselector_Item *it;
602    char buf[1024];
603    unsigned int loc;
604    Widget_Data* wd = elm_widget_data_get(obj);
605    if (!wd) return;
606
607    wd->week_start = day;
608    EINA_LIST_FOREACH(wd->items, l, it)
609      {
610         loc = (ELM_DAYSELECTOR_MAX - wd->week_start + it->day) % ELM_DAYSELECTOR_MAX;
611         snprintf(buf, sizeof(buf), "day%d", loc);
612         edje_object_part_swallow(wd->base, buf, VIEW(it));
613      }
614    _update_items(obj);
615 }
616
617 EAPI Elm_Dayselector_Day
618 elm_dayselector_week_start_get(const Evas_Object *obj)
619 {
620    ELM_CHECK_WIDTYPE(obj, widtype) ELM_DAYSELECTOR_MAX;
621    Widget_Data* wd = elm_widget_data_get(obj);
622    if (!wd) return ELM_DAYSELECTOR_MAX;
623
624    return wd->week_start;
625 }
626
627 EAPI void
628 elm_dayselector_weekend_start_set(Evas_Object *obj, Elm_Dayselector_Day day)
629 {
630    ELM_CHECK_WIDTYPE(obj, widtype);
631    Widget_Data* wd = elm_widget_data_get(obj);
632    if (!wd) return;
633
634    wd->weekend_start = day;
635    _items_style_set(obj);
636    _update_items(obj);
637 }
638
639 EAPI Elm_Dayselector_Day
640 elm_dayselector_weekend_start_get(const Evas_Object *obj)
641 {
642    ELM_CHECK_WIDTYPE(obj, widtype) ELM_DAYSELECTOR_MAX;
643    Widget_Data* wd = elm_widget_data_get(obj);
644    if (!wd) return ELM_DAYSELECTOR_MAX;
645
646    return wd->weekend_start;
647 }
648
649 EAPI void
650 elm_dayselector_weekend_length_set(Evas_Object *obj, unsigned int length)
651 {
652    ELM_CHECK_WIDTYPE(obj, widtype);
653    Widget_Data* wd = elm_widget_data_get(obj);
654    if (!wd) return;
655
656    wd->weekend_len = length;
657    _items_style_set(obj);
658    _update_items(obj);
659 }
660
661 EAPI unsigned int
662 elm_dayselector_weekend_length_get(const Evas_Object *obj)
663 {
664    ELM_CHECK_WIDTYPE(obj, widtype) 0;
665    Widget_Data* wd = elm_widget_data_get(obj);
666    if (!wd) return 0;
667
668    return wd->weekend_len;
669 }