2 * Simple Elementary's <b>dayselector widget</b> example, illustrating its
5 * See stdout/stderr for output. Compile with:
8 * gcc -g `pkg-config --cflags --libs elementary` dayselector_example.c -o dayselector_example
12 #include <Elementary.h>
14 # include "elementary_config.h"
20 _on_done(void *data __UNUSED__,
21 Evas_Object *obj __UNUSED__,
22 void *event_info __UNUSED__)
27 /* Callback function when a day is clicked. */
28 static void _changed_cb(void* data __UNUSED__, Evas_Object* obj, void* event_info)
31 Elm_Dayselector_Day day;
34 /* get which day's state is changed */
35 day = (Elm_Dayselector_Day) event_info;
36 /* get the state of corresponding day's check object */
37 selected = elm_dayselector_day_selected_get(obj, day);
40 case ELM_DAYSELECTOR_SUN: snprintf(buf, sizeof(buf), "%s", "Sun"); break;
41 case ELM_DAYSELECTOR_MON: snprintf(buf, sizeof(buf), "%s", "Mon"); break;
42 case ELM_DAYSELECTOR_TUE: snprintf(buf, sizeof(buf), "%s", "Tue"); break;
43 case ELM_DAYSELECTOR_WED: snprintf(buf, sizeof(buf), "%s", "Wed"); break;
44 case ELM_DAYSELECTOR_THU: snprintf(buf, sizeof(buf), "%s", "Thu"); break;
45 case ELM_DAYSELECTOR_FRI: snprintf(buf, sizeof(buf), "%s", "Fri"); break;
46 case ELM_DAYSELECTOR_SAT: snprintf(buf, sizeof(buf), "%s", "Sat"); break;
47 default: snprintf(buf, sizeof(buf), "%s", "???"); break;
49 fprintf(stderr, "%s state is %d\n", buf, selected);
51 /* End of clicked callback */
54 elm_main(int argc __UNUSED__, char **argv __UNUSED__)
56 Evas_Object *win, *bg, *bx, *dayselector;
58 win = elm_win_add(NULL, "dayselector", ELM_WIN_BASIC);
59 elm_win_title_set(win, "Dayselector Example");
60 evas_object_smart_callback_add(win, "delete,request", _on_done, NULL);
63 elm_win_resize_object_add(win, bg);
64 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
67 bx = elm_box_add(win);
68 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
69 elm_win_resize_object_add(win, bx);
72 /* add a dayselector widget showing weekdays starting from Sunday */
73 dayselector = elm_dayselector_add(win);
74 evas_object_size_hint_weight_set(dayselector, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
75 evas_object_size_hint_align_set(dayselector, EVAS_HINT_FILL, 0.5);
76 evas_object_smart_callback_add(dayselector, "dayselector,changed", _changed_cb, NULL);
77 elm_box_pack_end(bx, dayselector);
78 evas_object_show(dayselector);
80 /* add a dayselector widget showing weekdays starting from Monday */
81 dayselector = elm_dayselector_add(win);
82 evas_object_size_hint_weight_set(dayselector, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
83 evas_object_size_hint_align_set(dayselector, EVAS_HINT_FILL, 0.5);
84 evas_object_smart_callback_add(dayselector, "dayselector,changed", _changed_cb, NULL);
85 elm_object_style_set(dayselector, "mon_first");
86 elm_box_pack_end(bx, dayselector);
87 evas_object_show(dayselector);
89 evas_object_resize(win, 350, 120);
90 evas_object_show(win);