1 #include <Elementary.h>
3 #include <Elementary_Cursor.h>
5 # include "elementary_config.h"
7 #ifndef ELM_LIB_QUICKLAUNCH
10 unsigned int state; /* What state we are testing */
11 void *box; /* Use this to get box content */
13 typedef struct _api_data api_data;
17 SCROLLER_POLICY_SET_ON,
18 SCROLLER_POLICY_SET_OFF,
28 ITEM_DEL_NOT_SELECTED,
29 ITEM_DEL, /* delete when selected */
33 typedef enum _api_state api_state;
36 set_api_state(api_data *api)
38 const Eina_List *disks = elm_box_children_get(api->box);
39 if (!eina_list_count(disks))
43 { /* Put all api-changes under switch */
44 case SCROLLER_POLICY_SET_ON: /* 0 */
45 { /* Get first disk */
46 Evas_Object *disk = eina_list_nth(disks, 0);
47 elm_diskselector_scroller_policy_set(disk, ELM_SCROLLER_POLICY_ON, ELM_SCROLLER_POLICY_ON);
51 case SCROLLER_POLICY_SET_OFF: /* 1 */
52 { /* Get first disk */
53 Evas_Object *disk = eina_list_nth(disks, 0);
54 elm_diskselector_scroller_policy_set(disk, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
58 case BOUNCE_SET: /* 2 */
59 { /* Get second disk, cancel bounce */
60 Evas_Object *disk = eina_list_nth(disks, 1);
61 elm_diskselector_bounce_set(disk, EINA_FALSE, EINA_FALSE);
65 case ITEM_LABEL_SET: /* 3 */
66 elm_object_item_text_set(elm_diskselector_selected_item_get(eina_list_nth(disks, 0)), "Label from API");
69 case TOOLTIP_TEXT_SET: /* 4 */
70 elm_object_item_tooltip_text_set(elm_diskselector_selected_item_get(eina_list_nth(disks, 0)), "Tooltip from API");
73 case ITEM_TOOLTIP_UNSET: /* 5 */
74 elm_object_item_tooltip_unset(elm_diskselector_selected_item_get(eina_list_nth(disks, 0)));
77 case ITEM_CURSOR_SET: /* 6 */
78 elm_object_item_cursor_set(elm_diskselector_selected_item_get(eina_list_nth(disks, 0)), ELM_CURSOR_HAND2);
81 case ITEM_CURSOR_UNSET: /* 7 */
82 elm_object_item_cursor_unset(elm_diskselector_selected_item_get(eina_list_nth(disks, 0)));
85 case ITEM_ICON_SET: /* 8 */
86 { /* Set icon of selected item in first disk */
88 Evas_Object *ic = elm_icon_add(elm_object_parent_widget_get(eina_list_nth(disks, 0)));
89 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
90 elm_icon_file_set(ic, buf, NULL);
91 elm_object_item_part_content_set(elm_diskselector_selected_item_get(eina_list_nth(disks, 0)), NULL, ic);
96 case SELECTED_SET: /* 9 */
97 { /* Select NEXT item of third disk */
98 elm_diskselector_item_selected_set(elm_diskselector_last_item_get(eina_list_nth(disks, 1)), EINA_TRUE);
99 elm_diskselector_item_selected_set(elm_diskselector_item_next_get(elm_diskselector_selected_item_get(eina_list_nth(disks, 2))), EINA_TRUE);
103 case ITEM_PREV_GET: /* 10 */
104 { /* Select PREV item of third disk */
105 elm_diskselector_item_selected_set(elm_diskselector_item_prev_get(elm_diskselector_selected_item_get(eina_list_nth(disks, 2))), EINA_TRUE);
109 case ITEM_DEL_NOT_SELECTED: /* 11 */
110 { /* Remove selected item of third disk */
111 elm_object_item_del(elm_diskselector_item_prev_get(elm_diskselector_selected_item_get(eina_list_nth(disks, 2))));
115 case ITEM_DEL: /* 12 */
116 { /* Remove selected item of first disk */
117 elm_object_item_del(elm_diskselector_selected_item_get(eina_list_nth(disks, 1)));
122 elm_diskselector_clear(eina_list_nth(disks, 0));
131 _api_bt_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
132 { /* Will add here a SWITCH command containing code to modify test-object */
133 /* in accordance a->state value. */
137 printf("clicked event on API Button: api_state=<%d>\n", a->state);
140 sprintf(str, "Next API function (%u)", a->state);
141 elm_object_text_set(obj, str);
142 elm_object_disabled_set(obj, a->state == API_STATE_LAST);
146 _disk_sel(void *data __UNUSED__, Evas_Object * obj __UNUSED__, void *event_info)
148 Elm_Object_Item *ds_it = event_info;
149 printf("Equinox: %s\n", elm_object_item_text_get(ds_it));
153 _disk_next(void *data __UNUSED__, Evas_Object * obj __UNUSED__, void *event_info)
155 Elm_Object_Item *next_ds_it, *prev_ds_it, *ds_it = event_info;
156 prev_ds_it = elm_diskselector_item_prev_get(ds_it);
157 next_ds_it = elm_diskselector_item_next_get(ds_it);
158 printf("Prev: %s, Next: %s\n", elm_object_item_text_get(prev_ds_it),
159 elm_object_item_text_get(next_ds_it));
163 _print_disk_info_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
165 Elm_Object_Item *ds_it = event_info;
166 printf("Selected label: %s\n", elm_object_item_text_get(ds_it));
170 _disk_create(Evas_Object *win, Eina_Bool rnd)
172 Elm_Object_Item *ds_it;
175 di = elm_diskselector_add(win);
177 elm_diskselector_item_append(di, "January", NULL, NULL, NULL);
178 elm_diskselector_item_append(di, "February", NULL, _disk_next, NULL);
179 elm_diskselector_item_append(di, "March", NULL, _disk_sel, NULL);
180 elm_diskselector_item_append(di, "April", NULL, NULL, NULL);
181 elm_diskselector_item_append(di, "May", NULL, NULL, NULL);
182 elm_diskselector_item_append(di, "June", NULL, NULL, NULL);
183 elm_diskselector_item_append(di, "July", NULL, NULL, NULL);
184 ds_it = elm_diskselector_item_append(di, "August", NULL, NULL, NULL);
185 elm_diskselector_item_append(di, "September", NULL, _disk_sel, NULL);
186 elm_diskselector_item_append(di, "October", NULL, NULL, NULL);
187 elm_diskselector_item_append(di, "November", NULL, NULL, NULL);
188 elm_diskselector_item_append(di, "December", NULL, NULL, NULL);
190 elm_diskselector_item_selected_set(ds_it, EINA_TRUE);
191 elm_diskselector_round_enabled_set(di, rnd);
197 _cleanup_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
203 test_diskselector(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
205 Evas_Object *win, *bg, *bx, *disk, *ic, *bxx, *bt;
206 Elm_Object_Item *ds_it;
208 api_data *api = calloc(1, sizeof(api_data));
211 char *month_list[] = {
219 win = elm_win_add(NULL, "diskselector", ELM_WIN_BASIC);
220 elm_win_title_set(win, "Disk Selector");
221 elm_win_autodel_set(win, EINA_TRUE);
222 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
224 bg = elm_bg_add(win);
225 elm_win_resize_object_add(win, bg);
226 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
227 evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
228 evas_object_show(bg);
230 bxx = elm_box_add(win);
231 elm_win_resize_object_add(win, bxx);
232 evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
233 evas_object_show(bxx);
235 bx = elm_box_add(win);
236 elm_win_resize_object_add(win, bx);
237 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
238 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
240 evas_object_show(bx);
242 bt = elm_button_add(win);
243 elm_object_text_set(bt, "Next API function");
244 evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked, (void *) api);
245 elm_box_pack_end(bxx, bt);
246 elm_object_disabled_set(bt, api->state == API_STATE_LAST);
247 evas_object_show(bt);
249 elm_box_pack_end(bxx, bx);
251 disk = _disk_create(win, EINA_TRUE);
252 evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
253 evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
254 elm_box_pack_end(bx, disk);
255 evas_object_show(disk);
256 evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
257 ds_it = elm_diskselector_selected_item_get(disk);
258 elm_diskselector_item_selected_set(ds_it, EINA_FALSE);
260 disk = _disk_create(win, EINA_FALSE);
261 evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
262 evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
263 elm_box_pack_end(bx, disk);
264 evas_object_show(disk);
265 evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
266 ds_it = elm_diskselector_first_item_get(disk);
267 ds_it = elm_diskselector_item_next_get(ds_it);
268 elm_diskselector_item_selected_set(ds_it, EINA_TRUE);
270 disk = _disk_create(win, EINA_FALSE);
271 evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
272 evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
273 elm_box_pack_end(bx, disk);
274 evas_object_show(disk);
275 evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
276 elm_diskselector_side_text_max_length_set(disk, 4);
278 disk = elm_diskselector_add(win);
279 ic = elm_icon_add(win);
280 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
281 elm_icon_file_set(ic, buf, NULL);
282 elm_icon_resizable_set(ic, 1, 1);
283 elm_diskselector_item_append(disk, "Sunday", ic, NULL, NULL);
284 elm_diskselector_item_append(disk, "Monday", NULL, NULL, NULL);
285 elm_diskselector_item_append(disk, "Tuesday", NULL, NULL, NULL);
286 elm_diskselector_item_append(disk, "Wednesday", NULL, NULL, NULL);
287 elm_diskselector_item_append(disk, "Thursday", NULL, NULL, NULL);
288 elm_diskselector_item_append(disk, "Friday", NULL, NULL, NULL);
289 elm_diskselector_item_append(disk, "Saturday", NULL, NULL, NULL);
290 elm_diskselector_round_enabled_set(disk, EINA_TRUE);
291 evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
292 evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
293 elm_box_pack_end(bx, disk);
294 evas_object_show(disk);
295 evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
297 disk = elm_diskselector_add(win);
298 ic = elm_icon_add(win);
299 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
300 elm_icon_file_set(ic, buf, NULL);
301 elm_icon_resizable_set(ic, 1, 1);
302 elm_diskselector_item_append(disk, "머리스타일", ic, NULL, NULL);
303 elm_diskselector_item_append(disk, "プロが伝授する", NULL, NULL, NULL);
304 elm_diskselector_item_append(disk, "生上访要求政府", NULL, NULL, NULL);
305 elm_diskselector_item_append(disk, "English", NULL, NULL, NULL);
306 elm_diskselector_item_append(disk, "والشريعة", NULL, NULL, NULL);
307 elm_diskselector_item_append(disk, "עִבְרִית", NULL, NULL, NULL);
308 elm_diskselector_item_append(disk, "Grüßen", NULL, NULL, NULL);
309 elm_diskselector_round_enabled_set(disk, EINA_TRUE);
310 evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
311 evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
312 elm_box_pack_end(bx, disk);
313 evas_object_show(disk);
314 evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
316 // displayed item number setting example
317 disk = elm_diskselector_add(win);
318 elm_diskselector_display_item_num_set(disk, 5);
319 printf("Number of Items in DiskSelector : %d\n",
320 elm_diskselector_display_item_num_get(disk));
322 for (idx = 0; idx < (int)(sizeof(month_list) / sizeof(month_list[0])); idx++)
324 ds_it = elm_diskselector_item_append(disk, month_list[idx], NULL, NULL,
328 elm_diskselector_item_selected_set(ds_it, EINA_TRUE);
329 elm_diskselector_round_enabled_set(disk, EINA_TRUE);
330 evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
331 evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
332 elm_box_pack_end(bx, disk);
333 evas_object_show(disk);
334 evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
336 // displayed item number setting example
337 disk = elm_diskselector_add(win);
338 elm_diskselector_display_item_num_set(disk, 7);
339 printf("Number of Items in DiskSelector : %d\n",
340 elm_diskselector_display_item_num_get(disk));
342 for (idx = 1; idx < 31; idx++)
344 snprintf(date, sizeof(date), "%d", idx);
345 ds_it = elm_diskselector_item_append(disk, date, NULL, NULL, NULL);
348 elm_diskselector_item_selected_set(ds_it, EINA_TRUE);
349 elm_diskselector_round_enabled_set(disk, EINA_TRUE);
350 evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
351 evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
352 elm_box_pack_end(bx, disk);
353 evas_object_show(disk);
354 evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
356 evas_object_resize(win, 320, 480);
357 evas_object_show(win);