SVN Merging for button, radio, check and toggle
[framework/uifw/elementary.git] / src / examples / diskselector_example_01.c
1 /**
2  * Simple Elementary's <b>diskselector widget</b> example, illustrating its
3  * usage and API.
4  *
5  * See stdout/stderr for output. Compile with:
6  *
7  * @verbatim
8  * gcc -g `pkg-config --cflags --libs elementary` diskselector_example_01.c -o diskselector_example_01
9  * @endverbatim
10  */
11
12 #include <Elementary.h>
13 #ifdef HAVE_CONFIG_H
14 # include "elementary_config.h"
15 #else
16 # define __UNUSED__
17 #endif
18
19 static void
20 _on_done(void *data __UNUSED__,
21          Evas_Object *obj __UNUSED__,
22          void *event_info __UNUSED__)
23 {
24    elm_exit();
25 }
26
27 EAPI_MAIN int
28 elm_main(int argc __UNUSED__, char **argv __UNUSED__)
29 {
30    Evas_Object *win, *bg, *bx, *ds;
31    unsigned int i;
32    static const char *lbl[] =
33    {
34       "Sunday",
35       "Monday",
36       "Tuesday",
37       "Wednesday",
38       "Thursday",
39       "Friday",
40       "Saturday"
41    };
42
43    win = elm_win_add(NULL, "diskselector", ELM_WIN_BASIC);
44    elm_win_title_set(win, "Diskselector Example");
45    evas_object_smart_callback_add(win, "delete,request", _on_done, NULL);
46
47    bg = elm_bg_add(win);
48    elm_win_resize_object_add(win, bg);
49    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
50    evas_object_show(bg);
51
52    bx = elm_box_add(win);
53    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
54    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
55    elm_win_resize_object_add(win, bx);
56    evas_object_show(bx);
57
58    /* default */
59    ds = elm_diskselector_add(win);
60    evas_object_size_hint_weight_set(ds, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
61    evas_object_size_hint_align_set(ds, EVAS_HINT_FILL, EVAS_HINT_FILL);
62    elm_box_pack_end(bx, ds);
63    for (i = 0; i < sizeof(lbl) / sizeof(lbl[0]); i++)
64      elm_diskselector_item_append(ds, lbl[i], NULL, NULL, NULL);
65    evas_object_show(ds);
66
67    /* set round mode and define side label length */
68    ds = elm_diskselector_add(win);
69    evas_object_size_hint_weight_set(ds, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
70    evas_object_size_hint_align_set(ds, EVAS_HINT_FILL, EVAS_HINT_FILL);
71    elm_box_pack_end(bx, ds);
72    for (i = 0; i < sizeof(lbl) / sizeof(lbl[0]); i++)
73      elm_diskselector_item_append(ds, lbl[i], NULL, NULL, NULL);
74 <<<<<<< HEAD
75    elm_diskselector_round_set(ds, EINA_TRUE);
76    elm_diskselector_side_label_length_set(ds, 2);
77 =======
78    elm_diskselector_round_enabled_set(ds, EINA_TRUE);
79    elm_diskselector_side_text_max_length_set(ds, 2);
80 >>>>>>> remotes/origin/upstream
81    evas_object_show(ds);
82
83    /* display more than 3 items */
84    ds = elm_diskselector_add(win);
85    evas_object_size_hint_weight_set(ds, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
86    evas_object_size_hint_align_set(ds, EVAS_HINT_FILL, EVAS_HINT_FILL);
87    elm_box_pack_end(bx, ds);
88    for (i = 0; i < sizeof(lbl) / sizeof(lbl[0]); i++)
89      elm_diskselector_item_append(ds, lbl[i], NULL, NULL, NULL);
90    elm_diskselector_display_item_num_set(ds, 5);
91    printf("Number of Items in DiskSelector : %d\n", elm_diskselector_display_item_num_get(ds));
92    evas_object_show(ds);
93
94    /* set bounce and scroller policy */
95    ds = elm_diskselector_add(win);
96    evas_object_size_hint_weight_set(ds, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
97    evas_object_size_hint_align_set(ds, EVAS_HINT_FILL, EVAS_HINT_FILL);
98    elm_box_pack_end(bx, ds);
99    for (i = 0; i < sizeof(lbl) / sizeof(lbl[0]); i++)
100      elm_diskselector_item_append(ds, lbl[i], NULL, NULL, NULL);
101    elm_diskselector_bounce_set(ds, EINA_TRUE, EINA_TRUE);
102    elm_diskselector_scroller_policy_set(ds, ELM_SCROLLER_POLICY_AUTO,
103                                         ELM_SCROLLER_POLICY_ON);
104    evas_object_show(ds);
105
106    evas_object_resize(win, 320, 480);
107    evas_object_show(win);
108
109    elm_run();
110    return 0;
111 }
112 ELM_MAIN()