Merge branch 'svn_merge'
[framework/uifw/elementary.git] / src / bin / test_flipselector.c
1 #include <Elementary.h>
2 #ifdef HAVE_CONFIG_H
3 # include "elementary_config.h"
4 #endif
5 #ifndef ELM_LIB_QUICKLAUNCH
6
7 void
8 _sel_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
9 {
10    Elm_Flipselector_Item *it;
11
12    it = event_info;
13    printf("label of selected item is: %s\n", elm_flipselector_item_label_get(it));
14 }
15
16 void
17 _unsel_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
18 {
19    Elm_Flipselector_Item *it;
20    Evas_Object *fp = data;
21    it = elm_flipselector_selected_item_get(fp);
22    elm_flipselector_item_selected_set(it, EINA_FALSE);
23 }
24
25 void
26 _third_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
27 {
28    Elm_Flipselector_Item *it;
29    Evas_Object *fp = data;
30    it = elm_flipselector_first_item_get(fp);
31    it = elm_flipselector_item_next_get(it);
32    it = elm_flipselector_item_next_get(it);
33    elm_flipselector_item_selected_set(it, EINA_TRUE);
34 }
35
36 void
37 _underflow_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
38 {
39    printf("underflow!\n");
40 }
41
42 void
43 _overflow_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
44 {
45    printf("overflow!\n");
46 }
47
48 void
49 test_flipselector(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
50 {
51    char buf[8];
52    unsigned int i;
53    Evas_Object *win, *bg, *bx, *fp, *bt;
54    static const char *lbl[] = {
55      "Elementary",
56      "Evas",
57      "Eina",
58      "Edje",
59      "Eet",
60      "Ecore",
61      "Efreet",
62      "Edbus"
63    };
64
65    win = elm_win_add(NULL, "flipselector", ELM_WIN_BASIC);
66    elm_win_title_set(win, "Flip Selector");
67    elm_win_autodel_set(win, EINA_TRUE);
68
69    bg = elm_bg_add(win);
70    elm_win_resize_object_add(win, bg);
71    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
72    evas_object_show(bg);
73
74    bx = elm_box_add(win);
75    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
76    elm_win_resize_object_add(win, bx);
77    evas_object_show(bx);
78
79    fp = elm_flipselector_add(win);
80    evas_object_size_hint_weight_set(fp, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
81    evas_object_smart_callback_add(fp, "selected", _sel_cb, NULL);
82    evas_object_smart_callback_add(fp, "underflowed", _overflow_cb, NULL);
83    evas_object_smart_callback_add(fp, "overflowed", _underflow_cb, NULL);
84    for (i = 0; i < sizeof(lbl)/sizeof(char *); i++)
85      elm_flipselector_item_append(fp, lbl[i], NULL, NULL);
86    elm_box_pack_end(bx, fp);
87    evas_object_show(fp);
88
89    fp = elm_flipselector_add(win);
90    evas_object_smart_callback_add(fp, "underflowed", _overflow_cb, NULL);
91    evas_object_smart_callback_add(fp, "overflowed", _underflow_cb, NULL);
92    evas_object_size_hint_weight_set(fp, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
93    for (i = 2099; i >= 1990; i--)
94      {
95         snprintf(buf, 8, "%d", i);
96         elm_flipselector_item_append(fp, buf, _sel_cb, NULL);
97      }
98    elm_box_pack_end(bx, fp);
99    evas_object_show(fp);
100
101    bt = elm_button_add(win);
102    elm_object_text_set(bt, "Select 2097");
103    evas_object_smart_callback_add(bt, "clicked", _third_cb, fp);
104    elm_box_pack_end(bx, bt);
105    evas_object_show(bt);
106
107    bt = elm_button_add(win);
108    elm_object_text_set(bt, "Unselect year");
109    evas_object_smart_callback_add(bt, "clicked", _unsel_cb, fp);
110    elm_box_pack_end(bx, bt);
111    evas_object_show(bt);
112
113    evas_object_show(win);
114 }
115 #endif