tizen 2.4 release
[framework/uifw/elementary.git] / src / examples / calendar_example_04.c
1 /**
2  * Elementary's <b>calendar widget</b> example, regarding date selection.
3  * Shows how to disable day selection by user and how to select a date.
4  * It selects two days from current day.
5  *
6  * See stdout/stderr for output. Compile with:
7  *
8  * @verbatim
9  * gcc -o calendar_example_04 calendar_example_04.c -g `pkg-config --cflags --libs elementary`
10  * @endverbatim
11  */
12
13 #include <Elementary.h>
14
15 #define SECS_DAY 86400
16
17 EAPI_MAIN int
18 elm_main(int argc, char **argv)
19 {
20    Evas_Object *win, *bx, *cal, *cal2;
21    struct tm selected_time;
22    time_t current_time;
23
24    win = elm_win_util_standard_add("calendar", "Calendar Day Selection Example");
25    elm_win_autodel_set(win, EINA_TRUE);
26    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
27
28    bx = elm_box_add(win);
29    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
30    elm_win_resize_object_add(win, bx);
31    evas_object_show(bx);
32
33    cal = elm_calendar_add(win);
34    evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
35    evas_object_size_hint_align_set(cal, EVAS_HINT_FILL, EVAS_HINT_FILL);
36    elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_MODE_NONE);
37    evas_object_show(cal);
38    elm_box_pack_end(bx, cal);
39
40    cal2 = elm_calendar_add(win);
41    evas_object_size_hint_weight_set(cal2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
42    evas_object_size_hint_align_set(cal2, EVAS_HINT_FILL, EVAS_HINT_FILL);
43    current_time = time(NULL) + 2 * SECS_DAY;
44    localtime_r(&current_time, &selected_time);
45    elm_calendar_selected_time_set(cal2, &selected_time);
46    evas_object_show(cal2);
47    elm_box_pack_end(bx, cal2);
48
49    evas_object_show(win);
50
51    elm_run();
52
53    return 0;
54 }
55 ELM_MAIN()