aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/elementary/src/examples/dayselector_example.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libraries/elementary/src/examples/dayselector_example.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/libraries/elementary/src/examples/dayselector_example.c b/libraries/elementary/src/examples/dayselector_example.c
new file mode 100644
index 0000000..56fdea5
--- /dev/null
+++ b/libraries/elementary/src/examples/dayselector_example.c
@@ -0,0 +1,92 @@
1/**
2 * Simple Elementary's <b>dayselector widget</b> example, illustrating its
3 * usage and API.
4 *
5 * See stdout/stderr for output. Compile with:
6 *
7 * @verbatim
8 * gcc -g dayselector_example.c -o dayselector_example `pkg-config --cflags --libs elementary`
9 * @endverbatim
10 */
11
12#include <Elementary.h>
13
14static void
15_on_done(void *data,
16 Evas_Object *obj,
17 void *event_info)
18{
19 elm_exit();
20}
21
22/* Callback function when a day is clicked. */
23static void _changed_cb(void* data, Evas_Object* obj, void* event_info)
24{
25 char buf[256];
26 Elm_Dayselector_Day day;
27 Eina_Bool selected;
28
29 /* get which day's state is changed */
30 day = (Elm_Dayselector_Day) event_info;
31 /* get the state of corresponding day's check object */
32 selected = elm_dayselector_day_selected_get(obj, day);
33 switch(day)
34 {
35 case ELM_DAYSELECTOR_SUN: snprintf(buf, sizeof(buf), "%s", "Sun"); break;
36 case ELM_DAYSELECTOR_MON: snprintf(buf, sizeof(buf), "%s", "Mon"); break;
37 case ELM_DAYSELECTOR_TUE: snprintf(buf, sizeof(buf), "%s", "Tue"); break;
38 case ELM_DAYSELECTOR_WED: snprintf(buf, sizeof(buf), "%s", "Wed"); break;
39 case ELM_DAYSELECTOR_THU: snprintf(buf, sizeof(buf), "%s", "Thu"); break;
40 case ELM_DAYSELECTOR_FRI: snprintf(buf, sizeof(buf), "%s", "Fri"); break;
41 case ELM_DAYSELECTOR_SAT: snprintf(buf, sizeof(buf), "%s", "Sat"); break;
42 default: snprintf(buf, sizeof(buf), "%s", "???"); break;
43 }
44 fprintf(stderr, "%s state is %d\n", buf, selected);
45}
46/* End of clicked callback */
47
48EAPI_MAIN int
49elm_main(int argc, char **argv)
50{
51 Evas_Object *win, *bg, *bx, *dayselector;
52
53 win = elm_win_add(NULL, "dayselector", ELM_WIN_BASIC);
54 elm_win_title_set(win, "Dayselector Example");
55 evas_object_smart_callback_add(win, "delete,request", _on_done, NULL);
56
57 bg = elm_bg_add(win);
58 elm_win_resize_object_add(win, bg);
59 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
60 evas_object_show(bg);
61
62 bx = elm_box_add(win);
63 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
64 elm_win_resize_object_add(win, bx);
65 evas_object_show(bx);
66
67 /* add a dayselector widget showing weekdays starting from Sunday */
68 dayselector = elm_dayselector_add(win);
69 evas_object_size_hint_weight_set(dayselector, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
70 evas_object_size_hint_align_set(dayselector, EVAS_HINT_FILL, 0.5);
71 evas_object_smart_callback_add(dayselector, "dayselector,changed", _changed_cb, NULL);
72 elm_box_pack_end(bx, dayselector);
73 evas_object_show(dayselector);
74
75 /* add a dayselector widget showing weekdays starting from Monday */
76 dayselector = elm_dayselector_add(win);
77 evas_object_size_hint_weight_set(dayselector, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
78 evas_object_size_hint_align_set(dayselector, EVAS_HINT_FILL, 0.5);
79 evas_object_smart_callback_add(dayselector, "dayselector,changed", _changed_cb, NULL);
80 elm_object_style_set(dayselector, "mon_first");
81 elm_box_pack_end(bx, dayselector);
82 evas_object_show(dayselector);
83
84 evas_object_resize(win, 350, 120);
85 evas_object_show(win);
86
87 elm_run();
88 elm_shutdown();
89
90 return 0;
91}
92ELM_MAIN()