1 #ifdef HAVE_CONFIG_H
2 # include "elementary_config.h"
3 #endif
4 #include <Elementary.h>
5
6 void
_sel_cb(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info)7 _sel_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
8 {
9 Elm_Object_Item *it;
10
11 it = event_info;
12 printf("label of selected item is: %s\n", elm_object_item_text_get(it));
13 }
14
15 void
_unsel_cb(void * data,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)16 _unsel_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
17 {
18 Elm_Object_Item *it;
19 Evas_Object *fp = data;
20 it = elm_flipselector_selected_item_get(fp);
21 elm_flipselector_item_selected_set(it, EINA_FALSE);
22 }
23
24 void
_last_cb(void * data,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)25 _last_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
26 {
27 Elm_Object_Item *it;
28 Evas_Object *fp = data;
29 it = elm_flipselector_last_item_get(fp);
30 elm_flipselector_item_selected_set(it, EINA_TRUE);
31 }
32
33 void
_third_from_end_cb(void * data,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)34 _third_from_end_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
35 {
36 Elm_Object_Item *it;
37 Evas_Object *fp = data;
38 it = elm_flipselector_last_item_get(fp);
39 it = elm_flipselector_item_prev_get(it);
40 it = elm_flipselector_item_prev_get(it);
41 elm_flipselector_item_selected_set(it, EINA_TRUE);
42 }
43
44 void
_underflow_cb(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)45 _underflow_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
46 {
47 printf("underflow!\n");
48 }
49
50 void
_overflow_cb(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)51 _overflow_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
52 {
53 printf("overflow!\n");
54 }
55
56 void
slider_change_cb(void * data,Evas_Object * obj,void * event_info EINA_UNUSED)57 slider_change_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
58 {
59 Evas_Object *fl = (Evas_Object *)data;
60
61 double val = elm_slider_value_get(obj);
62 elm_flipselector_first_interval_set(fl, val);
63 }
64
65 void
flip_next_cb(void * data,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)66 flip_next_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
67 {
68 Evas_Object *fp = data;
69 elm_flipselector_flip_next(fp);
70 }
71
72 void
flip_prev_cb(void * data,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)73 flip_prev_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
74 {
75 Evas_Object *fp = data;
76 elm_flipselector_flip_prev(fp);
77 }
78
79 void
test_flipselector(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)80 test_flipselector(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
81 {
82 char buf[8];
83 unsigned int i;
84 Evas_Object *win, *bx, *fp, *fpd, *bt, *bx2, *sl;
85 Elm_Object_Item *it;
86 static const char *lbl[] = {
87 "Elementary",
88 "Evas",
89 "Eina",
90 "Edje",
91 "Eet",
92 "Ecore",
93 "Efreet",
94 "Eldbus"
95 };
96
97 win = elm_win_util_standard_add("flipselector", "Flip Selector");
98 elm_win_autodel_set(win, EINA_TRUE);
99
100 bx = elm_box_add(win);
101 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
102 elm_win_resize_object_add(win, bx);
103 evas_object_show(bx);
104
105 fp = elm_flipselector_add(bx);
106 evas_object_size_hint_weight_set(fp, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
107 evas_object_smart_callback_add(fp, "selected", _sel_cb, NULL);
108 evas_object_smart_callback_add(fp, "underflowed", _overflow_cb, NULL);
109 evas_object_smart_callback_add(fp, "overflowed", _underflow_cb, NULL);
110 for (i = 0; i < sizeof(lbl)/sizeof(char *); i++)
111 {
112 it = elm_flipselector_item_append(fp, lbl[i], NULL, NULL);
113 if (i == 3)
114 elm_flipselector_item_selected_set(it, EINA_TRUE);
115 }
116 elm_box_pack_end(bx, fp);
117 evas_object_show(fp);
118
119 bx2 = elm_box_add(bx);
120 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
121 elm_box_horizontal_set(bx2, EINA_TRUE);
122 elm_box_pack_end(bx, bx2);
123 evas_object_show(bx2);
124
125 fp = elm_flipselector_add(bx2);
126 evas_object_smart_callback_add(fp, "underflowed", _overflow_cb, NULL);
127 evas_object_smart_callback_add(fp, "overflowed", _underflow_cb, NULL);
128 evas_object_size_hint_weight_set(fp, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
129 for (i = 1990; i <= 2099; i++)
130 {
131 snprintf(buf, 8, "%u", i);
132 elm_flipselector_item_append(fp, buf, _sel_cb, NULL);
133 }
134
135 bt = elm_button_add(bx2);
136 elm_object_text_set(bt, "Flip Prev");
137 evas_object_smart_callback_add(bt, "clicked", flip_prev_cb, fp);
138
139 elm_box_pack_end(bx2, bt);
140 evas_object_show(bt);
141
142 elm_box_pack_end(bx2, fp);
143 evas_object_show(fp);
144
145 bt = elm_button_add(bx2);
146 elm_object_text_set(bt, "Flip Next");
147 evas_object_smart_callback_add(bt, "clicked", flip_next_cb, fp);
148 elm_box_pack_end(bx2, bt);
149 evas_object_show(bt);
150
151 fpd = elm_flipselector_add(bx);
152 evas_object_size_hint_weight_set(fpd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
153 elm_flipselector_item_append(fpd, "disabled", NULL, NULL);
154 elm_object_disabled_set(fpd, EINA_TRUE);
155 elm_box_pack_end(bx, fpd);
156 evas_object_show(fpd);
157
158 sl = elm_slider_add(bx);
159 elm_object_text_set(sl, "Flip Interval:");
160 elm_slider_unit_format_set(sl, "%1.2f");
161 elm_slider_min_max_set(sl, 0, 3.0);
162 elm_slider_value_set(sl, 0.85);
163 evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, EVAS_HINT_FILL);
164 evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
165 elm_box_pack_end(bx, sl);
166 evas_object_show(sl);
167 evas_object_smart_callback_add(sl, "changed", slider_change_cb, fp);
168
169 bt = elm_button_add(bx);
170 elm_object_text_set(bt, "Select Last");
171 evas_object_smart_callback_add(bt, "clicked", _last_cb, fp);
172 elm_box_pack_end(bx, bt);
173 evas_object_show(bt);
174
175 bt = elm_button_add(bx);
176 elm_object_text_set(bt, "Select 2097");
177 evas_object_smart_callback_add(bt, "clicked", _third_from_end_cb, fp);
178 elm_box_pack_end(bx, bt);
179 evas_object_show(bt);
180
181 bt = elm_button_add(bx);
182 elm_object_text_set(bt, "Unselect year");
183 evas_object_smart_callback_add(bt, "clicked", _unsel_cb, fp);
184 elm_box_pack_end(bx, bt);
185 evas_object_show(bt);
186
187 fpd = elm_flipselector_add(bx);
188 evas_object_size_hint_weight_set(fpd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
189 efl_ui_range_step_set(fpd, 1.5);
190 efl_ui_range_limits_set(fpd, 2.3, 10.1);
191 efl_ui_range_value_set(fpd, 5.3);
192 printf("Current value is %f\n", efl_ui_range_value_get(fpd));
193 elm_box_pack_end(bx, fpd);
194 evas_object_show(fpd);
195
196 evas_object_show(win);
197 }
198