1 #include <Elementary.h>
3 # include "elementary_config.h"
5 #ifndef ELM_LIB_QUICKLAUNCH
8 * In this example some calls to elm_genlist_item_append() are used which give the
9 * value of an int as 'item data' and 'func data' after casting into (void*). For
10 * sure this works only on architectures where sizeof(int)==sizeof(void*).
11 * For real world usage you should hold a data structure or value in your
12 * application and then give only a pointer to this data as data pointer.
15 typedef struct _Testitem
17 Elm_Object_Item *item;
23 static Elm_Genlist_Item_Class itc1;
24 char *gl_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
27 snprintf(buf, sizeof(buf), "Item # %i", (int)(long)data);
31 Evas_Object *gl_content_get(void *data __UNUSED__, Evas_Object *obj, const char *part)
34 Evas_Object *ic = elm_icon_add(obj);
35 if (!strcmp(part, "elm.swallow.end"))
36 snprintf(buf, sizeof(buf), "%s/images/bubble.png", elm_app_data_dir_get());
38 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
39 elm_icon_file_set(ic, buf, NULL);
40 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
43 Eina_Bool gl_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
47 void gl_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
52 gl_sel(void *data, Evas_Object *obj, void *event_info)
54 printf("sel item data [%p] on genlist obj [%p], item pointer [%p]\n", data, obj, event_info);
58 _move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
60 Evas_Object *gl = data;
61 Evas_Event_Mouse_Move *ev = event_info;
64 gli = elm_genlist_at_xy_item_get(gl, ev->cur.canvas.x, ev->cur.canvas.y, &where);
66 printf("over %p, where %i\n", elm_object_item_data_get(gli), where);
68 printf("over none, where %i\n", where);
72 _bt50_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
74 elm_genlist_item_bring_in(data);
78 _bt1500_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
80 elm_genlist_item_middle_bring_in(data);
84 _gl_selected(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
86 printf("selected: %p\n", event_info);
90 _gl_double_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
92 printf("double clicked: %p\n", event_info);
96 _gl_longpress(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
98 printf("longpress %p\n", event_info);
102 test_genlist(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
104 Evas_Object *win, *bg, *gl, *bt_50, *bt_1500, *bx;
106 Elm_Object_Item *gli;
109 win = elm_win_add(NULL, "genlist", ELM_WIN_BASIC);
110 elm_win_title_set(win, "Genlist");
111 elm_win_autodel_set(win, EINA_TRUE);
113 bg = elm_bg_add(win);
114 elm_win_resize_object_add(win, bg);
115 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
116 evas_object_show(bg);
118 bx = elm_box_add(win);
119 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
120 elm_win_resize_object_add(win, bx);
121 evas_object_show(bx);
123 gl = elm_genlist_add(win);
124 evas_object_smart_callback_add(gl, "selected", _gl_selected, NULL);
125 evas_object_smart_callback_add(gl, "clicked,double", _gl_double_clicked, NULL);
126 evas_object_smart_callback_add(gl, "longpressed", _gl_longpress, NULL);
127 // FIXME: This causes genlist to resize the horiz axis very slowly :(
128 // Reenable this and resize the window horizontally, then try to resize it back
129 //elm_genlist_mode_set(gl, ELM_LIST_LIMIT);
130 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
131 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
132 elm_box_pack_end(bx, gl);
133 evas_object_show(gl);
135 over = evas_object_rectangle_add(evas_object_evas_get(win));
136 evas_object_color_set(over, 0, 0, 0, 0);
137 evas_object_event_callback_add(over, EVAS_CALLBACK_MOUSE_MOVE, _move, gl);
138 evas_object_repeat_events_set(over, 1);
139 evas_object_show(over);
140 evas_object_size_hint_weight_set(over, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
141 elm_win_resize_object_add(win, over);
143 itc1.item_style = "default";
144 itc1.func.text_get = gl_text_get;
145 itc1.func.content_get = gl_content_get;
146 itc1.func.state_get = gl_state_get;
147 itc1.func.del = gl_del;
149 bt_50 = elm_button_add(win);
150 elm_object_text_set(bt_50, "Go to 50");
151 evas_object_show(bt_50);
152 elm_box_pack_end(bx, bt_50);
154 bt_1500 = elm_button_add(win);
155 elm_object_text_set(bt_1500, "Go to 1500");
156 evas_object_show(bt_1500);
157 elm_box_pack_end(bx, bt_1500);
159 for (i = 0; i < 2000; i++)
161 gli = elm_genlist_item_append(gl, &itc1,
162 (void *)(long)i/* item data */,
164 ELM_GENLIST_ITEM_NONE,
166 (void *)(long)(i * 10)/* func data */);
168 evas_object_smart_callback_add(bt_50, "clicked", _bt50_cb, gli);
170 evas_object_smart_callback_add(bt_1500, "clicked", _bt1500_cb, gli);
172 evas_object_resize(win, 480, 800);
173 evas_object_show(win);
179 my_gl_clear(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
181 Evas_Object *gl = data;
182 elm_genlist_clear(gl);
186 my_gl_add(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
188 Evas_Object *gl = data;
191 itc1.item_style = "default";
192 itc1.func.text_get = gl_text_get;
193 itc1.func.content_get = gl_content_get;
194 itc1.func.state_get = gl_state_get;
195 itc1.func.del = gl_del;
197 elm_genlist_item_append(gl, &itc1,
198 (void *)(long)i/* item data */,
200 ELM_GENLIST_ITEM_NONE,
202 (void *)(long)(i * 10)/* func data */);
207 my_gl_insert_before(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
209 Evas_Object *gl = data;
211 Elm_Object_Item *gli_selected;
213 itc1.item_style = "default";
214 itc1.func.text_get = gl_text_get;
215 itc1.func.content_get = gl_content_get;
216 itc1.func.state_get = gl_state_get;
217 itc1.func.del = gl_del;
219 gli_selected = elm_genlist_selected_item_get(gl);
222 printf("no item selected\n");
226 elm_genlist_item_insert_before(gl, &itc1,
227 (void *)(long)i/* item data */,
229 gli_selected /* item before */,
230 ELM_GENLIST_ITEM_NONE,
232 (void *)(long)(i * 10)/* func data */);
237 my_gl_insert_after(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
239 Evas_Object *gl = data;
241 Elm_Object_Item *gli_selected;
243 itc1.item_style = "default";
244 itc1.func.text_get = gl_text_get;
245 itc1.func.content_get = gl_content_get;
246 itc1.func.state_get = gl_state_get;
247 itc1.func.del = gl_del;
249 gli_selected = elm_genlist_selected_item_get(gl);
252 printf("no item selected\n");
256 elm_genlist_item_insert_after(gl, &itc1,
257 (void *)(long)i/* item data */,
259 gli_selected /* item after */,
260 ELM_GENLIST_ITEM_NONE,
262 (void *)(long)(i * 10)/* func data */);
267 my_gl_del(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
269 Evas_Object *gl = data;
270 Elm_Object_Item *gli = elm_genlist_selected_item_get(gl);
273 printf("no item selected\n");
276 elm_object_item_del(gli);
280 my_gl_disable(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
282 Evas_Object *gl = data;
283 Elm_Object_Item *gli = elm_genlist_selected_item_get(gl);
286 printf("no item selected\n");
289 elm_object_item_disabled_set(gli, EINA_TRUE);
290 elm_genlist_item_selected_set(gli, EINA_FALSE);
291 elm_genlist_item_update(gli);
295 my_gl_update_all(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
297 Evas_Object *gl = data;
299 Elm_Object_Item *it = elm_genlist_first_item_get(gl);
302 elm_genlist_item_update(it);
305 it = elm_genlist_item_next_get(it);
310 my_gl_first(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
312 Evas_Object *gl = data;
313 Elm_Object_Item *gli = elm_genlist_first_item_get(gl);
315 elm_genlist_item_show(gli);
316 elm_genlist_item_selected_set(gli, 1);
320 my_gl_last(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
322 Evas_Object *gl = data;
323 Elm_Object_Item *gli = elm_genlist_last_item_get(gl);
325 elm_genlist_item_show(gli);
326 elm_genlist_item_selected_set(gli, 1);
330 my_gl_flush_delay(void *data __UNUSED__)
333 return ECORE_CALLBACK_CANCEL;
337 my_gl_flush(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
339 ecore_timer_add(1.2, my_gl_flush_delay, NULL);
343 test_genlist2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
345 Evas_Object *win, *bg, *gl, *bx, *bx2, *bx3, *bt;
346 Elm_Object_Item *gli[10];
349 win = elm_win_add(NULL, "genlist2", ELM_WIN_BASIC);
350 elm_win_title_set(win, "Genlist 2");
351 elm_win_autodel_set(win, EINA_TRUE);
353 bg = elm_bg_add(win);
354 snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
355 elm_bg_file_set(bg, buf, NULL);
356 elm_win_resize_object_add(win, bg);
357 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
358 evas_object_show(bg);
360 bx = elm_box_add(win);
361 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
362 elm_win_resize_object_add(win, bx);
363 evas_object_show(bx);
365 gl = elm_genlist_add(win);
366 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
367 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
368 evas_object_show(gl);
370 itc1.item_style = "default";
371 itc1.func.text_get = gl_text_get;
372 itc1.func.content_get = gl_content_get;
373 itc1.func.state_get = gl_state_get;
374 itc1.func.del = gl_del;
376 gli[0] = elm_genlist_item_append(gl, &itc1,
377 (void *)1001/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
378 (void *)1001/* func data */);
379 gli[1] = elm_genlist_item_append(gl, &itc1,
380 (void *)1002/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
381 (void *)1002/* func data */);
382 gli[2] = elm_genlist_item_append(gl, &itc1,
383 (void *)1003/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
384 (void *)1003/* func data */);
385 gli[3] = elm_genlist_item_prepend(gl, &itc1,
386 (void *)1004/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
387 (void *)1004/* func data */);
388 gli[4] = elm_genlist_item_prepend(gl, &itc1,
389 (void *)1005/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
390 (void *)1005/* func data */);
391 gli[5] = elm_genlist_item_insert_before(gl, &itc1,
392 (void *)1006/* item data */, NULL/* parent */, gli[2]/* rel */, ELM_GENLIST_ITEM_NONE,
393 gl_sel/* func */, (void *)1006/* func data */);
394 gli[6] = elm_genlist_item_insert_after(gl, &itc1,
395 (void *)1007/* item data */, NULL/* parent */, gli[2]/* rel */, ELM_GENLIST_ITEM_NONE,
396 gl_sel/* func */, (void *)1007/* func data */);
398 elm_box_pack_end(bx, gl);
400 bx2 = elm_box_add(win);
401 elm_box_horizontal_set(bx2, EINA_TRUE);
402 elm_box_homogeneous_set(bx2, EINA_TRUE);
403 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
404 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
406 bt = elm_button_add(win);
407 elm_object_text_set(bt, "/\\");
408 evas_object_smart_callback_add(bt, "clicked", my_gl_first, gl);
409 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
410 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
411 elm_box_pack_end(bx2, bt);
412 evas_object_show(bt);
414 bt = elm_button_add(win);
415 elm_object_text_set(bt, "\\/");
416 evas_object_smart_callback_add(bt, "clicked", my_gl_last, gl);
417 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
418 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
419 elm_box_pack_end(bx2, bt);
420 evas_object_show(bt);
422 bt = elm_button_add(win);
423 elm_object_text_set(bt, "#");
424 evas_object_smart_callback_add(bt, "clicked", my_gl_disable, gl);
425 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
426 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
427 elm_box_pack_end(bx2, bt);
428 evas_object_show(bt);
430 bt = elm_button_add(win);
431 elm_object_text_set(bt, "U");
432 evas_object_smart_callback_add(bt, "clicked", my_gl_update_all, gl);
433 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
434 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
435 elm_box_pack_end(bx2, bt);
436 evas_object_show(bt);
438 elm_box_pack_end(bx, bx2);
439 evas_object_show(bx2);
441 bx2 = elm_box_add(win);
442 elm_box_horizontal_set(bx2, EINA_TRUE);
443 elm_box_homogeneous_set(bx2, EINA_TRUE);
444 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
445 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
447 bt = elm_button_add(win);
448 elm_object_text_set(bt, "X");
449 evas_object_smart_callback_add(bt, "clicked", my_gl_clear, gl);
450 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
451 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
452 elm_box_pack_end(bx2, bt);
453 evas_object_show(bt);
455 bt = elm_button_add(win);
456 elm_object_text_set(bt, "+");
457 evas_object_smart_callback_add(bt, "clicked", my_gl_add, gl);
458 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
459 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
460 elm_box_pack_end(bx2, bt);
461 evas_object_show(bt);
463 bt = elm_button_add(win);
464 elm_object_text_set(bt, "-");
465 evas_object_smart_callback_add(bt, "clicked", my_gl_del, gl);
466 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
467 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
468 elm_box_pack_end(bx2, bt);
469 evas_object_show(bt);
471 elm_box_pack_end(bx, bx2);
472 evas_object_show(bx2);
474 bx3 = elm_box_add(win);
475 elm_box_horizontal_set(bx3, EINA_TRUE);
476 elm_box_homogeneous_set(bx3, EINA_TRUE);
477 evas_object_size_hint_weight_set(bx3, EVAS_HINT_EXPAND, 0.0);
478 evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL, EVAS_HINT_FILL);
480 bt = elm_button_add(win);
481 elm_object_text_set(bt, "+ before");
482 evas_object_smart_callback_add(bt, "clicked", my_gl_insert_before, gl);
483 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
484 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
485 elm_box_pack_end(bx3, bt);
486 evas_object_show(bt);
488 bt = elm_button_add(win);
489 elm_object_text_set(bt, "+ after");
490 evas_object_smart_callback_add(bt, "clicked", my_gl_insert_after, gl);
491 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
492 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
493 elm_box_pack_end(bx3, bt);
494 evas_object_show(bt);
496 bt = elm_button_add(win);
497 elm_object_text_set(bt, "Flush");
498 evas_object_smart_callback_add(bt, "clicked", my_gl_flush, gl);
499 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
500 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
501 elm_box_pack_end(bx3, bt);
502 evas_object_show(bt);
504 elm_box_pack_end(bx, bx3);
505 evas_object_show(bx3);
508 evas_object_resize(win, 320, 320);
509 evas_object_show(win);
514 static Elm_Genlist_Item_Class itc2;
515 char *gl2_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
517 const Testitem *tit = data;
519 snprintf(buf, sizeof(buf), "Item mode %i", tit->mode);
522 Evas_Object *gl2_content_get(void *data, Evas_Object *obj, const char *part)
524 const Testitem *tit = data;
526 Evas_Object *ic = elm_icon_add(obj);
527 if (!strcmp(part, "elm.swallow.icon"))
529 if (!(tit->mode & 0x3))
530 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
531 else if ((tit->mode & 0x3) == 1)
532 snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
533 else if ((tit->mode & 0x3) == 2)
534 snprintf(buf, sizeof(buf), "%s/images/panel_01.jpg", elm_app_data_dir_get());
535 else if ((tit->mode & 0x3) == 3)
536 snprintf(buf, sizeof(buf), "%s/images/rock_01.jpg", elm_app_data_dir_get());
537 elm_icon_file_set(ic, buf, NULL);
539 else if (!strcmp(part, "elm.swallow.end"))
541 if (!(tit->mode & 0x3))
542 snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", elm_app_data_dir_get());
543 else if ((tit->mode & 0x3) == 1)
544 snprintf(buf, sizeof(buf), "%s/images/sky_02.jpg", elm_app_data_dir_get());
545 else if ((tit->mode & 0x3) == 2)
546 snprintf(buf, sizeof(buf), "%s/images/sky_03.jpg", elm_app_data_dir_get());
547 else if ((tit->mode & 0x3) == 3)
548 snprintf(buf, sizeof(buf), "%s/images/sky_04.jpg", elm_app_data_dir_get());
549 elm_icon_file_set(ic, buf, NULL);
551 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
554 Eina_Bool gl2_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
558 void gl2_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
563 my_gl_update(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
565 Testitem *tit = data;
567 elm_genlist_item_update(tit->item);
571 my_gl_labels_update(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
573 Testitem *tit = data;
575 elm_genlist_item_fields_update(tit->item, "*", ELM_GENLIST_ITEM_FIELD_LABEL);
579 my_gl_contents_update(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
581 Testitem *tit = data;
583 elm_genlist_item_fields_update(tit->item, "*", ELM_GENLIST_ITEM_FIELD_CONTENT);
587 test_genlist3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
589 Evas_Object *win, *bg, *gl, *bx, *bx2, *bt;
590 static Testitem tit[3];
592 win = elm_win_add(NULL, "genlist3", ELM_WIN_BASIC);
593 elm_win_title_set(win, "Genlist 3");
594 elm_win_autodel_set(win, EINA_TRUE);
596 bg = elm_bg_add(win);
597 elm_win_resize_object_add(win, bg);
598 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
599 evas_object_show(bg);
601 bx = elm_box_add(win);
602 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
603 elm_win_resize_object_add(win, bx);
604 evas_object_show(bx);
606 gl = elm_genlist_add(win);
607 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
608 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
609 evas_object_show(gl);
611 itc2.item_style = "default";
612 itc2.func.text_get = gl2_text_get;
613 itc2.func.content_get = gl2_content_get;
614 itc2.func.state_get = gl2_state_get;
615 itc2.func.del = gl2_del;
618 tit[0].item = elm_genlist_item_append(gl, &itc2,
619 &(tit[0])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
620 NULL/* func data */);
622 tit[1].item = elm_genlist_item_append(gl, &itc2,
623 &(tit[1])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
624 NULL/* func data */);
626 tit[2].item = elm_genlist_item_append(gl, &itc2,
627 &(tit[2])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
628 NULL/* func data */);
630 elm_box_pack_end(bx, gl);
631 evas_object_show(bx);
633 bx2 = elm_box_add(win);
634 elm_box_horizontal_set(bx2, EINA_TRUE);
635 elm_box_homogeneous_set(bx2, EINA_TRUE);
636 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
637 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
639 bt = elm_button_add(win);
640 elm_object_text_set(bt, "[1]");
641 evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[0]));
642 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
643 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
644 elm_box_pack_end(bx2, bt);
645 evas_object_show(bt);
647 bt = elm_button_add(win);
648 elm_object_text_set(bt, "labels");
649 evas_object_smart_callback_add(bt, "clicked", my_gl_labels_update, &(tit[1]));
650 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
651 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
652 elm_box_pack_end(bx2, bt);
653 evas_object_show(bt);
655 bt = elm_button_add(win);
656 elm_object_text_set(bt, "contents");
657 evas_object_smart_callback_add(bt, "clicked", my_gl_contents_update, &(tit[2]));
658 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
659 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
660 elm_box_pack_end(bx2, bt);
661 evas_object_show(bt);
663 elm_box_pack_end(bx, bx2);
664 evas_object_show(bx2);
666 evas_object_resize(win, 320, 320);
667 evas_object_show(win);
673 my_gl_item_check_changed(void *data, Evas_Object *obj, void *event_info __UNUSED__)
675 Testitem *tit = data;
676 tit->onoff = elm_check_state_get(obj);
677 printf("item %p onoff = %i\n", tit, tit->onoff);
680 static Elm_Genlist_Item_Class itc3;
681 char *gl3_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
683 const Testitem *tit = data;
685 snprintf(buf, sizeof(buf), "Item mode %i", tit->mode);
688 Evas_Object *gl3_content_get(void *data, Evas_Object *obj, const char *part)
690 const Testitem *tit = data;
691 if (!strcmp(part, "elm.swallow.icon"))
695 lb = elm_label_add(obj);
696 elm_label_line_wrap_set(lb, ELM_WRAP_CHAR);
697 elm_label_wrap_width_set(lb, 201);
698 elm_object_text_set(lb, "ashj ascjscjh n asjkl hcjlh ls hzshnn zjh sh zxjcjsnd h dfw sdv edev efe fwefvv vsd cvs ws wf fvwf wd fwe f we wef we wfe rfwewef wfv wswf wefg sdfws w wsdcfwcf wsc vdv sdsd sdcd cv wsc sdcv wsc d sdcdcsd sdcdsc wdvd sdcsd wscxcv wssvd sd");
701 else if (!strcmp(part, "elm.swallow.end"))
704 ck = elm_check_add(obj);
705 evas_object_propagate_events_set(ck, EINA_FALSE);
706 elm_check_state_set(ck, tit->onoff);
707 evas_object_smart_callback_add(ck, "changed", my_gl_item_check_changed, data);
712 Eina_Bool gl3_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
716 void gl3_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
721 test_genlist4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
723 Evas_Object *win, *bg, *gl, *bx, *bx2, *bt;
724 static Testitem tit[3];
726 win = elm_win_add(NULL, "genlist4", ELM_WIN_BASIC);
727 elm_win_title_set(win, "Genlist 4");
728 elm_win_autodel_set(win, EINA_TRUE);
730 bg = elm_bg_add(win);
731 elm_win_resize_object_add(win, bg);
732 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
733 evas_object_show(bg);
735 bx = elm_box_add(win);
736 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
737 elm_win_resize_object_add(win, bx);
738 evas_object_show(bx);
740 gl = elm_genlist_add(win);
741 elm_genlist_height_for_width_mode_set(gl, EINA_TRUE);
742 elm_genlist_multi_select_set(gl, 1);
743 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
744 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
745 evas_object_show(gl);
747 itc3.item_style = "default";
748 itc3.func.text_get = gl3_text_get;
749 itc3.func.content_get = gl3_content_get;
750 itc3.func.state_get = gl3_state_get;
751 itc3.func.del = gl3_del;
754 tit[0].item = elm_genlist_item_append(gl, &itc3,
755 &(tit[0])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
756 NULL/* func data */);
758 tit[1].item = elm_genlist_item_append(gl, &itc3,
759 &(tit[1])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
760 NULL/* func data */);
762 tit[2].item = elm_genlist_item_append(gl, &itc3,
763 &(tit[2])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
764 NULL/* func data */);
766 elm_box_pack_end(bx, gl);
767 evas_object_show(bx);
769 bx2 = elm_box_add(win);
770 elm_box_horizontal_set(bx2, EINA_TRUE);
771 elm_box_homogeneous_set(bx2, EINA_TRUE);
772 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
773 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
775 bt = elm_button_add(win);
776 elm_object_text_set(bt, "[1]");
777 evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[0]));
778 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
779 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
780 elm_box_pack_end(bx2, bt);
781 evas_object_show(bt);
783 bt = elm_button_add(win);
784 elm_object_text_set(bt, "[2]");
785 evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[1]));
786 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
787 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
788 elm_box_pack_end(bx2, bt);
789 evas_object_show(bt);
791 bt = elm_button_add(win);
792 elm_object_text_set(bt, "[3]");
793 evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[2]));
794 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
795 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
796 elm_box_pack_end(bx2, bt);
797 evas_object_show(bt);
799 elm_box_pack_end(bx, bx2);
800 evas_object_show(bx2);
802 evas_object_resize(win, 320, 320);
803 evas_object_show(win);
809 my_gl_item_check_changed2(void *data, Evas_Object *obj, void *event_info __UNUSED__)
811 Testitem *tit = data;
812 tit->onoff = elm_check_state_get(obj);
813 printf("item %p onoff = %i\n", tit, tit->onoff);
816 static Elm_Genlist_Item_Class itc5;
817 char *gl5_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part)
819 const Testitem *tit = data;
821 if (!strcmp(part, "elm.text"))
823 snprintf(buf, sizeof(buf), "Item mode %i", tit->mode);
825 else if (!strcmp(part, "elm.text.sub"))
827 snprintf(buf, sizeof(buf), "%i bottles on the wall", tit->mode);
831 Evas_Object *gl5_content_get(void *data, Evas_Object *obj, const char *part)
833 const Testitem *tit = data;
835 if (!strcmp(part, "elm.swallow.icon"))
837 Evas_Object *bx = elm_box_add(obj);
839 elm_box_horizontal_set(bx, EINA_TRUE);
840 ic = elm_icon_add(obj);
841 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
842 elm_icon_file_set(ic, buf, NULL);
843 elm_icon_scale_set(ic, 0, 0);
844 evas_object_show(ic);
845 elm_box_pack_end(bx, ic);
846 ic = elm_icon_add(obj);
847 elm_icon_file_set(ic, buf, NULL);
848 elm_icon_scale_set(ic, 0, 0);
849 evas_object_show(ic);
850 elm_box_pack_end(bx, ic);
851 elm_box_horizontal_set(bx, EINA_TRUE);
852 evas_object_show(bx);
855 else if (!strcmp(part, "elm.swallow.end"))
858 ck = elm_check_add(obj);
859 evas_object_propagate_events_set(ck, EINA_FALSE);
860 elm_check_state_set(ck, tit->onoff);
861 evas_object_smart_callback_add(ck, "changed", my_gl_item_check_changed2, data);
862 evas_object_show(ck);
867 Eina_Bool gl5_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
871 void gl5_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
876 item_drag_up(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
882 item_drag_down(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
884 printf("drag down\n");
888 item_drag_left(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
890 printf("drag left\n");
894 item_drag_right(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
896 printf("drag right\n");
900 scroll_top(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
902 printf("Top edge!\n");
906 scroll_bottom(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
908 printf("Bottom edge!\n");
912 scroll_left(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
914 printf("Left edge!\n");
918 scroll_right(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
920 printf("Right edge!\n");
924 item_drag(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
930 item_drag_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
932 printf("drag stop\n");
936 item_longpress(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
938 printf("longpress\n");
942 test_genlist5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
944 Evas_Object *win, *bg, *gl, *bx, *bx2, *bt;
945 static Testitem tit[3];
947 win = elm_win_add(NULL, "genlist5", ELM_WIN_BASIC);
948 elm_win_title_set(win, "Genlist 5");
949 elm_win_autodel_set(win, EINA_TRUE);
951 bg = elm_bg_add(win);
952 elm_win_resize_object_add(win, bg);
953 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
954 evas_object_show(bg);
956 bx = elm_box_add(win);
957 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
958 elm_win_resize_object_add(win, bx);
959 evas_object_show(bx);
961 gl = elm_genlist_add(win);
962 elm_genlist_always_select_mode_set(gl, 1);
963 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
964 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
965 evas_object_show(gl);
966 itc5.item_style = "double_label";
967 itc5.func.text_get = gl5_text_get;
968 itc5.func.content_get = gl5_content_get;
969 itc5.func.state_get = gl5_state_get;
970 itc5.func.del = gl5_del;
973 tit[0].item = elm_genlist_item_append(gl, &itc5,
974 &(tit[0])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
975 NULL/* func data */);
977 tit[1].item = elm_genlist_item_append(gl, &itc5,
978 &(tit[1])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
979 NULL/* func data */);
981 tit[2].item = elm_genlist_item_append(gl, &itc5,
982 &(tit[2])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
983 NULL/* func data */);
985 elm_box_pack_end(bx, gl);
986 evas_object_show(bx);
988 evas_object_smart_callback_add(gl, "drag,start,up", item_drag_up, NULL);
989 evas_object_smart_callback_add(gl, "drag,start,down", item_drag_down, NULL);
990 evas_object_smart_callback_add(gl, "drag,start,left", item_drag_left, NULL);
991 evas_object_smart_callback_add(gl, "drag,start,right", item_drag_right, NULL);
992 evas_object_smart_callback_add(gl, "scroll,edge,top", scroll_top, NULL);
993 evas_object_smart_callback_add(gl, "scroll,edge,bottom", scroll_bottom, NULL);
994 evas_object_smart_callback_add(gl, "scroll,edge,left", scroll_left, NULL);
995 evas_object_smart_callback_add(gl, "scroll,edge,right", scroll_right, NULL);
996 evas_object_smart_callback_add(gl, "drag", item_drag, NULL);
997 evas_object_smart_callback_add(gl, "drag,stop", item_drag_stop, NULL);
998 evas_object_smart_callback_add(gl, "longpressed", item_longpress, NULL);
1000 bx2 = elm_box_add(win);
1001 elm_box_horizontal_set(bx2, EINA_TRUE);
1002 elm_box_homogeneous_set(bx2, EINA_TRUE);
1003 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
1004 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
1006 bt = elm_button_add(win);
1007 elm_object_text_set(bt, "[1]");
1008 evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[0]));
1009 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1010 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1011 elm_box_pack_end(bx2, bt);
1012 evas_object_show(bt);
1014 bt = elm_button_add(win);
1015 elm_object_text_set(bt, "[2]");
1016 evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[1]));
1017 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1018 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1019 elm_box_pack_end(bx2, bt);
1020 evas_object_show(bt);
1022 bt = elm_button_add(win);
1023 elm_object_text_set(bt, "[3]");
1024 evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[2]));
1025 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1026 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1027 elm_box_pack_end(bx2, bt);
1028 evas_object_show(bt);
1030 elm_box_pack_end(bx, bx2);
1031 evas_object_show(bx2);
1033 evas_object_resize(win, 320, 320);
1034 evas_object_show(win);
1039 static Elm_Genlist_Item_Class itc4;
1042 gl4_sel(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1044 Elm_Object_Item *glit = event_info;
1045 int depth = elm_genlist_item_expanded_depth_get(glit);
1046 printf("expanded depth for selected item is %d\n", depth);
1050 gl4_exp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1052 Elm_Object_Item *glit = event_info;
1053 Evas_Object *gl = elm_genlist_item_genlist_get(glit);
1054 int val = (int)(long) elm_object_item_data_get(glit);
1056 elm_genlist_item_append(gl, &itc4,
1057 (void *)(long) (val + 1)/* item data */,
1058 glit/* parent */, ELM_GENLIST_ITEM_NONE,
1060 NULL/* func data */);
1061 elm_genlist_item_append(gl, &itc4,
1062 (void *)(long) (val + 2)/* item data */,
1063 glit/* parent */, ELM_GENLIST_ITEM_NONE,
1065 NULL/* func data */);
1066 elm_genlist_item_append(gl, &itc4,
1067 (void *)(long) (val + 3)/* item data */,
1069 ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */,
1070 NULL/* func data */);
1073 gl4_con(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1075 Elm_Object_Item *glit = event_info;
1076 elm_genlist_item_subitems_clear(glit);
1080 gl4_exp_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1082 Elm_Object_Item *glit = event_info;
1083 elm_genlist_item_expanded_set(glit, EINA_TRUE);
1086 gl4_con_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1088 Elm_Object_Item *glit = event_info;
1089 elm_genlist_item_expanded_set(glit, EINA_FALSE);
1092 char *gl4_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
1095 snprintf(buf, sizeof(buf), "Item mode %i", (int)(long)data);
1098 Evas_Object *gl4_content_get(void *data __UNUSED__, Evas_Object *obj, const char *part)
1101 if (!strcmp(part, "elm.swallow.icon"))
1103 Evas_Object *ic = elm_icon_add(obj);
1104 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
1105 elm_icon_file_set(ic, buf, NULL);
1106 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1107 evas_object_show(ic);
1110 else if (!strcmp(part, "elm.swallow.end"))
1113 ck = elm_check_add(obj);
1114 evas_object_propagate_events_set(ck, EINA_FALSE);
1115 evas_object_show(ck);
1120 Eina_Bool gl4_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
1124 void gl4_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
1129 test_genlist6(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1131 Evas_Object *win, *bg, *gl, *bx, *bx2, *bt;
1133 win = elm_win_add(NULL, "genlist-tree", ELM_WIN_BASIC);
1134 elm_win_title_set(win, "Genlist Tree");
1135 elm_win_autodel_set(win, EINA_TRUE);
1137 bg = elm_bg_add(win);
1138 elm_win_resize_object_add(win, bg);
1139 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1140 evas_object_show(bg);
1142 bx = elm_box_add(win);
1143 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1144 elm_win_resize_object_add(win, bx);
1145 evas_object_show(bx);
1147 gl = elm_genlist_add(win);
1148 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1149 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1150 evas_object_show(gl);
1152 itc4.item_style = "default";
1153 itc4.func.text_get = gl4_text_get;
1154 itc4.func.content_get = gl4_content_get;
1155 itc4.func.state_get = gl4_state_get;
1156 itc4.func.del = gl4_del;
1158 elm_genlist_item_append(gl, &itc4,
1159 (void *)1/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */,
1160 NULL/* func data */);
1161 elm_genlist_item_append(gl, &itc4,
1162 (void *)2/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */,
1163 NULL/* func data */);
1164 elm_genlist_item_append(gl, &itc4,
1165 (void *)3/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1166 NULL/* func data */);
1168 evas_object_smart_callback_add(gl, "expand,request", gl4_exp_req, gl);
1169 evas_object_smart_callback_add(gl, "contract,request", gl4_con_req, gl);
1170 evas_object_smart_callback_add(gl, "expanded", gl4_exp, gl);
1171 evas_object_smart_callback_add(gl, "contracted", gl4_con, gl);
1173 elm_box_pack_end(bx, gl);
1174 evas_object_show(bx);
1176 bx2 = elm_box_add(win);
1177 elm_box_horizontal_set(bx2, EINA_TRUE);
1178 elm_box_homogeneous_set(bx2, EINA_TRUE);
1179 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
1180 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
1182 bt = elm_button_add(win);
1183 elm_object_text_set(bt, "[1]");
1184 // evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[0]));
1185 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1186 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1187 elm_box_pack_end(bx2, bt);
1188 evas_object_show(bt);
1190 bt = elm_button_add(win);
1191 elm_object_text_set(bt, "[2]");
1192 // evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[1]));
1193 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1194 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1195 elm_box_pack_end(bx2, bt);
1196 evas_object_show(bt);
1198 bt = elm_button_add(win);
1199 elm_object_text_set(bt, "[3]");
1200 // evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[2]));
1201 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1202 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1203 elm_box_pack_end(bx2, bt);
1204 evas_object_show(bt);
1206 elm_box_pack_end(bx, bx2);
1207 evas_object_show(bx2);
1209 evas_object_resize(win, 320, 320);
1210 evas_object_show(win);
1215 struct genlist7_data
1217 Evas_Object *win, *pager;
1220 static Elm_Genlist_Item_Class itc7;
1222 gl_sel7(void *data, Evas_Object *obj, void *event_info)
1224 if (!event_info) return;
1225 elm_genlist_item_item_class_update(event_info, &itc7);
1226 printf("sel item data [%p] on genlist obj [%p], item pointer [%p], new item style [%s] \n", data, obj, event_info, itc7.item_style);
1230 test_genlist7_back_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1232 struct genlist7_data *info = data;
1235 elm_pager_content_pop(info->pager);
1239 test_genlist7_swipe(void *data, Evas_Object *obj __UNUSED__, void *event_info)
1241 struct genlist7_data *info = data;
1242 Evas_Object *box, *entry, *button;
1243 char item_data[] = "Just a simple test";
1245 if ((!event_info) || (!data)) return;
1247 box = elm_box_add(info->win);
1248 elm_box_homogeneous_set(box, EINA_FALSE);
1249 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1250 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
1251 evas_object_show(box);
1253 entry = elm_entry_add(info->win);
1254 elm_entry_scrollable_set(entry, EINA_TRUE);
1255 elm_entry_editable_set(entry, EINA_FALSE);
1256 elm_object_text_set(entry, item_data);
1257 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1258 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1259 evas_object_show(entry);
1261 button = elm_button_add(info->win);
1262 elm_object_text_set(button, "back");
1263 evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, 0);
1264 evas_object_size_hint_align_set(button, EVAS_HINT_FILL, 0);
1265 evas_object_smart_callback_add(button, "clicked", test_genlist7_back_cb,
1267 evas_object_show(button);
1269 elm_box_pack_start(box, entry);
1270 elm_box_pack_end(box, button);
1272 elm_pager_content_push(info->pager, box);
1276 test_genlist7(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1278 Evas_Object *win, *bg, *gl, *pager;
1279 static struct genlist7_data info;
1280 static Testitem tit[3];
1282 win = elm_win_add(NULL, "genlist7", ELM_WIN_BASIC);
1283 elm_win_title_set(win, "Genlist 7");
1284 elm_win_autodel_set(win, EINA_TRUE);
1287 bg = elm_bg_add(win);
1288 elm_win_resize_object_add(win, bg);
1289 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1290 evas_object_show(bg);
1292 pager = elm_pager_add(win);
1293 elm_win_resize_object_add(win, pager);
1294 evas_object_size_hint_weight_set(pager, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1295 evas_object_size_hint_align_set(pager, EVAS_HINT_FILL, EVAS_HINT_FILL);
1296 evas_object_show(pager);
1299 gl = elm_genlist_add(win);
1300 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1301 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1302 evas_object_smart_callback_add(gl, "swipe", test_genlist7_swipe, &info);
1303 evas_object_show(gl);
1304 elm_pager_content_push(pager, gl);
1306 itc2.item_style = "default";
1307 itc2.func.text_get = gl2_text_get;
1308 itc2.func.content_get = gl2_content_get;
1309 itc2.func.state_get = gl2_state_get;
1310 itc2.func.del = gl2_del;
1312 itc7.item_style = "double_label";
1313 itc7.func.text_get = gl5_text_get;
1314 itc7.func.content_get = gl5_content_get;
1315 itc7.func.state_get = gl5_state_get;
1316 itc7.func.del = gl5_del;
1319 tit[0].item = elm_genlist_item_append(gl, &itc2,
1320 &(tit[0])/* item data */, NULL/* parent */,
1321 ELM_GENLIST_ITEM_NONE, gl_sel7/* func */,
1322 NULL/* func data */);
1324 tit[1].item = elm_genlist_item_append(gl, &itc2,
1325 &(tit[1])/* item data */, NULL/* parent */,
1326 ELM_GENLIST_ITEM_NONE, gl_sel7/* func */,
1327 NULL/* func data */);
1329 tit[2].item = elm_genlist_item_append(gl, &itc2,
1330 &(tit[2])/* item data */, NULL/* parent */,
1331 ELM_GENLIST_ITEM_NONE, gl_sel7/* func */,
1332 NULL/* func data */);
1334 evas_object_resize(win, 320, 320);
1335 evas_object_show(win);
1340 static Elm_Genlist_Item_Class itc_group;
1341 char *gl8_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
1344 snprintf(buf, sizeof(buf), "Group Index # %i (Item # %i)", (int)((long)data / 10), (int)(long)data);
1349 _bt_show_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1351 elm_genlist_item_top_show(data);
1352 //elm_genlist_item_show(data);
1353 //elm_genlist_item_middle_show(data);
1356 _bt_bring_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1358 elm_genlist_item_top_bring_in(data);
1359 //elm_genlist_item_bring_in(data);
1360 //elm_genlist_item_middle_bring_in(data);
1364 test_genlist8(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1366 Evas_Object *win, *bg, *gl, *bt[8], *bx, *bx2, *bx3;
1367 Elm_Object_Item *gli = NULL, *git = NULL;
1370 win = elm_win_add(NULL, "genlist-group", ELM_WIN_BASIC);
1371 elm_win_title_set(win, "Genlist Group");
1372 elm_win_autodel_set(win, EINA_TRUE);
1374 bg = elm_bg_add(win);
1375 elm_win_resize_object_add(win, bg);
1376 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1377 evas_object_show(bg);
1379 bx = elm_box_add(win);
1380 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1381 elm_win_resize_object_add(win, bx);
1382 evas_object_show(bx);
1384 gl = elm_genlist_add(win);
1385 evas_object_smart_callback_add(gl, "selected", _gl_selected, NULL);
1386 evas_object_smart_callback_add(gl, "clicked,double", _gl_double_clicked, NULL);
1387 evas_object_smart_callback_add(gl, "longpressed", _gl_longpress, NULL);
1388 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1389 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1390 elm_box_pack_end(bx, gl);
1391 evas_object_show(gl);
1393 itc1.item_style = "default";
1394 itc1.func.text_get = gl_text_get;
1395 itc1.func.content_get = gl_content_get;
1396 itc1.func.state_get = gl_state_get;
1397 itc1.func.del = gl_del;
1399 itc_group.item_style = "group_index";
1400 itc_group.func.text_get = gl8_text_get;
1401 itc_group.func.content_get = NULL;
1402 itc_group.func.state_get = NULL;
1403 itc_group.func.del = gl_del;
1405 bx2 = elm_box_add(win);
1406 elm_box_horizontal_set(bx2, EINA_TRUE);
1407 elm_box_homogeneous_set(bx2, EINA_TRUE);
1408 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
1409 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
1412 bt[bt_num] = elm_button_add(win);
1413 elm_object_text_set(bt[bt_num], "Show 0");
1414 evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1415 evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1416 evas_object_show(bt[bt_num]);
1417 elm_box_pack_end(bx2, bt[bt_num]);
1419 bt[++bt_num] = elm_button_add(win);
1420 elm_object_text_set(bt[bt_num], "Show 26");
1421 evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1422 evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1423 evas_object_show(bt[bt_num]);
1424 elm_box_pack_end(bx2, bt[bt_num]);
1426 bt[++bt_num] = elm_button_add(win);
1427 elm_object_text_set(bt[bt_num], "Show 101");
1428 evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1429 evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1430 evas_object_show(bt[bt_num]);
1431 elm_box_pack_end(bx2, bt[bt_num]);
1433 bt[++bt_num] = elm_button_add(win);
1434 elm_object_text_set(bt[bt_num], "Show 480");
1435 evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1436 evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1437 evas_object_show(bt[bt_num]);
1438 elm_box_pack_end(bx2, bt[bt_num]);
1440 elm_box_pack_end(bx, bx2);
1441 evas_object_show(bx2);
1443 bx3 = elm_box_add(win);
1444 elm_box_horizontal_set(bx3, EINA_TRUE);
1445 elm_box_homogeneous_set(bx3, EINA_TRUE);
1446 evas_object_size_hint_weight_set(bx3, EVAS_HINT_EXPAND, 0.0);
1447 evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL, EVAS_HINT_FILL);
1449 bt[++bt_num] = elm_button_add(win);
1450 elm_object_text_set(bt[bt_num], "Bring top 0");
1451 evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1452 evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1453 evas_object_show(bt[bt_num]);
1454 elm_box_pack_end(bx3, bt[bt_num]);
1456 bt[++bt_num] = elm_button_add(win);
1457 elm_object_text_set(bt[bt_num], "Bring top 31");
1458 evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1459 evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1460 evas_object_show(bt[bt_num]);
1461 elm_box_pack_end(bx3, bt[bt_num]);
1463 bt[++bt_num] = elm_button_add(win);
1464 elm_object_text_set(bt[bt_num], "Bring top 239");
1465 evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1466 evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1467 evas_object_show(bt[bt_num]);
1468 elm_box_pack_end(bx3, bt[bt_num]);
1470 bt[++bt_num] = elm_button_add(win);
1471 elm_object_text_set(bt[bt_num], "Bring top 477");
1472 evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1473 evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1474 evas_object_show(bt[bt_num]);
1475 elm_box_pack_end(bx3, bt[bt_num]);
1477 elm_box_pack_end(bx, bx3);
1478 evas_object_show(bx3);
1480 for (i = 0; i < 500; i++)
1484 gli = git = elm_genlist_item_append(gl, &itc_group,
1485 (void *)(long)i/* item data */,
1487 ELM_GENLIST_ITEM_GROUP,
1489 (void *)(long)(i * 10)/* func data */);
1490 elm_genlist_item_display_only_set(git, EINA_TRUE);
1494 gli = elm_genlist_item_append(gl, &itc1,
1495 (void *)(long)i/* item data */,
1497 ELM_GENLIST_ITEM_NONE,
1499 (void *)(long)(i * 10)/* func data */);
1504 evas_object_smart_callback_add(bt[0], "clicked", _bt_show_cb, gli);
1505 evas_object_smart_callback_add(bt[4], "clicked", _bt_bring_cb, gli);
1508 evas_object_smart_callback_add(bt[1], "clicked", _bt_show_cb, gli);
1511 evas_object_smart_callback_add(bt[5], "clicked", _bt_bring_cb, gli);
1514 evas_object_smart_callback_add(bt[2], "clicked", _bt_show_cb, gli);
1517 evas_object_smart_callback_add(bt[6], "clicked", _bt_bring_cb, gli);
1520 evas_object_smart_callback_add(bt[7], "clicked", _bt_bring_cb, gli);
1523 evas_object_smart_callback_add(bt[3], "clicked", _bt_show_cb, gli);
1528 evas_object_resize(win, 480, 800);
1529 evas_object_show(win);
1535 gl9_exp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1537 Elm_Object_Item *glit = event_info;
1538 Evas_Object *gl = elm_genlist_item_genlist_get(glit);
1539 int val = (int)(long) elm_object_item_data_get(glit);
1541 elm_genlist_item_append(gl, &itc1,
1542 (void *)(long) (val + 1)/* item data */,
1544 ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1545 NULL/* func data */);
1546 elm_genlist_item_append(gl, &itc1,
1547 (void *)(long) (val + 2)/* item data */,
1549 ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1550 NULL/* func data */);
1551 elm_genlist_item_append(gl, &itc1,
1552 (void *)(long) (val + 3)/* item data */,
1554 ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */,
1555 NULL/* func data */);
1558 gl9_con(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1560 Elm_Object_Item *glit = event_info;
1561 elm_genlist_item_subitems_clear(glit);
1565 gl9_exp_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1567 Elm_Object_Item *glit = event_info;
1568 elm_genlist_item_expanded_set(glit, EINA_TRUE);
1571 gl9_con_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1573 Elm_Object_Item *glit = event_info;
1574 elm_genlist_item_expanded_set(glit, EINA_FALSE);
1578 test_genlist9(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1580 Evas_Object *win, *bg, *gl, *bx;
1581 Elm_Object_Item *git;
1583 win = elm_win_add(NULL, "genlist-group-tree", ELM_WIN_BASIC);
1584 elm_win_title_set(win, "Genlist Group Tree");
1585 elm_win_autodel_set(win, EINA_TRUE);
1587 bg = elm_bg_add(win);
1588 elm_win_resize_object_add(win, bg);
1589 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1590 evas_object_show(bg);
1592 bx = elm_box_add(win);
1593 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1594 elm_win_resize_object_add(win, bx);
1595 evas_object_show(bx);
1597 gl = elm_genlist_add(win);
1598 evas_object_smart_callback_add(gl, "selected", _gl_selected, NULL);
1599 evas_object_smart_callback_add(gl, "clicked,double", _gl_double_clicked, NULL);
1600 evas_object_smart_callback_add(gl, "longpressed", _gl_longpress, NULL);
1601 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1602 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1603 elm_box_pack_end(bx, gl);
1604 evas_object_show(gl);
1606 itc1.item_style = "default";
1607 itc1.func.text_get = gl_text_get;
1608 itc1.func.content_get = gl_content_get;
1609 itc1.func.state_get = gl_state_get;
1610 itc1.func.del = gl_del;
1612 itc_group.item_style = "group_index";
1613 itc_group.func.text_get = gl8_text_get;
1614 itc_group.func.content_get = NULL;
1615 itc_group.func.state_get = NULL;
1616 itc_group.func.del = gl_del;
1618 git = elm_genlist_item_append(gl, &itc_group,
1619 (void *)0/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_GROUP, gl4_sel/* func */,
1620 NULL/* func data */);
1621 elm_genlist_item_display_only_set(git, EINA_TRUE);
1622 elm_genlist_item_append(gl, &itc1,
1623 (void *)1/* item data */, git/* parent */, ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */,
1624 NULL/* func data */);
1625 elm_genlist_item_append(gl, &itc1,
1626 (void *)2/* item data */, git/* parent */, ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1627 NULL/* func data */);
1628 elm_genlist_item_append(gl, &itc1,
1629 (void *)3/* item data */, git/* parent */, ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */,
1630 NULL/* func data */);
1631 git = elm_genlist_item_append(gl, &itc_group,
1632 (void *)4/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_GROUP, gl4_sel/* func */,
1633 NULL/* func data */);
1634 elm_genlist_item_display_only_set(git, EINA_TRUE);
1635 elm_genlist_item_append(gl, &itc1,
1636 (void *)5/* item data */, git/* parent */, ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */,
1637 NULL/* func data */);
1638 elm_genlist_item_append(gl, &itc1,
1639 (void *)6/* item data */, git/* parent */, ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1640 NULL/* func data */);
1641 elm_genlist_item_append(gl, &itc1,
1642 (void *)7/* item data */, git/* parent */, ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */,
1643 NULL/* func data */);
1645 evas_object_smart_callback_add(gl, "expand,request", gl9_exp_req, gl);
1646 evas_object_smart_callback_add(gl, "contract,request", gl9_con_req, gl);
1647 evas_object_smart_callback_add(gl, "expanded", gl9_exp, gl);
1648 evas_object_smart_callback_add(gl, "contracted", gl9_con, gl);
1650 evas_object_resize(win, 480, 800);
1651 evas_object_show(win);
1656 static Elm_Genlist_Item_Class itc10;
1657 static char *mode_type[] = { "slide", "rotate" };
1658 char *gl10_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part)
1661 if (!strcmp(part, "elm.text.mode"))
1662 snprintf(buf, sizeof(buf), "Mode # %i", (int)(long)data);
1664 snprintf(buf, sizeof(buf), "Item # %i", (int)(long)data);
1668 Evas_Object *gl10_content_get(void *data __UNUSED__, Evas_Object *obj, const char *part)
1671 Evas_Object *ic = elm_icon_add(obj);
1672 if (!strcmp(part, "elm.swallow.end"))
1673 snprintf(buf, sizeof(buf), "%s/images/bubble.png", elm_app_data_dir_get());
1675 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
1676 elm_icon_file_set(ic, buf, NULL);
1677 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1681 _gl_sel10(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1684 int v = elm_radio_value_get(data);
1686 elm_genlist_item_mode_set(event_info, mode_type[v], EINA_TRUE);
1690 _my_gl_mode_right(void *data, Evas_Object *obj __UNUSED__, void *event_info)
1693 int v = elm_radio_value_get(data);
1695 elm_genlist_item_mode_set(event_info, mode_type[v], EINA_TRUE);
1699 _my_gl_mode_left(void *data, Evas_Object *obj __UNUSED__, void *event_info)
1702 int v = elm_radio_value_get(data);
1704 elm_genlist_item_mode_set(event_info, mode_type[v], EINA_FALSE);
1708 _my_gl_mode_cancel(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1710 fprintf(stderr, "drag\n");
1712 int v = elm_radio_value_get(data);
1713 Elm_Object_Item *glit = (Elm_Object_Item *) elm_genlist_mode_item_get(obj);
1714 if (glit) elm_genlist_item_mode_set(glit, mode_type[v], EINA_FALSE);
1718 test_genlist10(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1720 Evas_Object *win, *bg, *fr, *lb, *bx, *bx2, *bx3, *rd, *rdg, *gl;
1723 win = elm_win_add(NULL, "genlist10", ELM_WIN_BASIC);
1724 elm_win_title_set(win, "Genlist Mode");
1725 elm_win_autodel_set(win, EINA_TRUE);
1727 bg = elm_bg_add(win);
1728 elm_win_resize_object_add(win, bg);
1729 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1730 evas_object_show(bg);
1732 bx = elm_box_add(win);
1733 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1734 elm_win_resize_object_add(win, bx);
1735 evas_object_show(bx);
1737 fr = elm_frame_add(win);
1738 elm_object_text_set(fr, "Mode Type");
1739 elm_box_pack_end(bx, fr);
1740 evas_object_show(fr);
1742 bx2 = elm_box_add(win);
1743 elm_object_content_set(fr, bx2);
1744 evas_object_show(bx2);
1746 lb = elm_label_add(win);
1747 elm_object_text_set(lb,
1748 "Sweep genlist items to the right.<br/>"
1749 "Test this by changing Mode Type to Slide or Rotate.");
1750 elm_box_pack_end(bx2, lb);
1751 evas_object_show(lb);
1753 bx3 = elm_box_add(win);
1754 elm_box_horizontal_set(bx3, EINA_TRUE);
1755 elm_box_pack_end(bx2, bx3);
1756 evas_object_show(bx3);
1758 rd = elm_radio_add(win);
1759 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1760 elm_radio_state_value_set(rd, 0);
1761 elm_object_text_set(rd, "Slide ");
1762 evas_object_show(rd);
1763 elm_box_pack_end(bx3, rd);
1766 rd = elm_radio_add(win);
1767 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1768 elm_radio_state_value_set(rd, 1);
1769 elm_object_text_set(rd, "Rotate");
1770 elm_radio_group_add(rd, rdg);
1771 evas_object_show(rd);
1772 elm_box_pack_end(bx3, rd);
1774 gl = elm_genlist_add(win);
1775 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1776 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1777 evas_object_smart_callback_add(gl, "drag,start,right", _my_gl_mode_right, rdg);
1778 evas_object_smart_callback_add(gl, "drag,start,left", _my_gl_mode_left, rdg);
1779 evas_object_smart_callback_add(gl, "drag,start,up", _my_gl_mode_cancel, rdg);
1780 evas_object_smart_callback_add(gl, "drag,start,down", _my_gl_mode_cancel, rdg);
1781 evas_object_show(gl);
1783 itc10.item_style = "default";
1784 itc10.func.text_get = gl10_text_get;
1785 itc10.func.content_get = gl10_content_get;
1786 itc10.func.state_get = gl_state_get;
1787 itc10.func.del = gl_del;
1788 elm_genlist_mode_item_style_set(gl, "mode");
1790 for (i = 0; i < 50; i++)
1791 elm_genlist_item_append(gl,
1793 (void *)(1000 + i)/* item data */,
1795 ELM_GENLIST_ITEM_NONE/* flags */,
1796 _gl_sel10/* func */,
1797 rdg/* func data */);
1799 elm_box_pack_end(bx, gl);
1801 evas_object_resize(win, 520, 520);
1802 evas_object_show(win);
1808 _reorder_tg_changed_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1810 elm_genlist_reorder_mode_set(data, elm_check_state_get(obj));
1814 * gl_moved is called after an item was reordered.
1815 * This is only called when reorder mode is enabled.
1817 * @param data : the genlist object passed as data.
1818 * @param obj : the genlist object.
1819 * @param item : the moved item.
1821 * If the move_after is true,
1822 * the item(*item) had been moved after the given relative item(*rel_item) in list.
1823 * If the move_after is false,
1824 * the item(*item) had been moved before the given relative item(*rel_item) in list.
1827 static void gl_moved(Evas_Object *data __UNUSED__, Evas_Object *obj __UNUSED__, Elm_Object_Item *item __UNUSED__)
1829 // if needed, add application logic.
1833 test_genlist11(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1835 Evas_Object *win, *bg, *fr, *lb, *bx, *tg, *gl;
1838 win = elm_win_add(NULL, "genlist-reorder-mode", ELM_WIN_BASIC);
1839 elm_win_title_set(win, "Genlist Reorder Mode");
1840 elm_win_autodel_set(win, EINA_TRUE);
1842 bg = elm_bg_add(win);
1843 elm_win_resize_object_add(win, bg);
1844 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1845 evas_object_show(bg);
1847 bx = elm_box_add(win);
1848 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1849 elm_win_resize_object_add(win, bx);
1850 evas_object_show(bx);
1852 fr = elm_frame_add(win);
1854 elm_object_text_set(fr, "Reorder Mode");
1855 elm_box_pack_end(bx, fr);
1856 evas_object_show(fr);
1858 lb = elm_label_add(win);
1859 elm_object_text_set(lb,
1860 "Enable reorder mode if you want to move item.<br/>"
1861 "Then long press and drag item.");
1862 elm_object_content_set(fr, lb);
1863 evas_object_show(lb);
1865 gl = elm_genlist_add(win);
1866 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1867 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1868 evas_object_show(gl);
1870 tg = elm_check_add(win);
1871 elm_object_style_set(tg, "toggle");
1872 elm_object_text_set(tg, "Reorder Mode:");
1873 elm_check_state_set(tg, elm_mirrored_get());
1874 evas_object_smart_callback_add(tg, "changed", _reorder_tg_changed_cb, gl);
1875 elm_box_pack_end(bx, tg);
1876 evas_object_show(tg);
1878 itc1.item_style = "default";
1879 itc1.func.text_get = gl_text_get;
1880 itc1.func.content_get = gl_content_get;
1881 itc1.func.state_get = gl_state_get;
1882 itc1.func.del = gl_del;
1883 evas_object_smart_callback_add(gl, "moved", (Evas_Smart_Cb)gl_moved, gl);
1885 for (i = 0; i < 50; i++)
1886 elm_genlist_item_append(gl,
1888 (void *)(1 + i)/* item data */,
1890 ELM_GENLIST_ITEM_NONE/* flags */,
1892 NULL/* func data */);
1894 elm_box_pack_end(bx, gl);
1896 evas_object_resize(win, 400, 500);
1897 evas_object_show(win);
1900 char *gl12_text_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
1902 return strdup("Enlightenment is not just a window manager for Linux/X11 and others, but also a whole suite of libraries to help you create beautiful user interfaces with much less work than doing it the old fashioned way and fighting with traditional toolkits, not to mention a traditional window manager. It covers uses from small mobile devices like phones all the way to powerful multi-core desktops (which are the primary development environment).");
1906 test_genlist12(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1908 Evas_Object *win, *bg, *bx, *gl;
1911 win = elm_win_add(NULL, "genlist-textblock", ELM_WIN_BASIC);
1912 elm_win_title_set(win, "Genlist Textblock");
1913 elm_win_autodel_set(win, EINA_TRUE);
1915 bg = elm_bg_add(win);
1916 elm_win_resize_object_add(win, bg);
1917 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1918 evas_object_show(bg);
1920 bx = elm_box_add(win);
1921 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1922 elm_win_resize_object_add(win, bx);
1923 evas_object_show(bx);
1925 gl = elm_genlist_add(win);
1926 elm_genlist_height_for_width_mode_set(gl, EINA_TRUE);
1927 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1928 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1929 elm_box_pack_end(bx, gl);
1930 evas_object_show(gl);
1932 itc1.item_style = "message";
1933 itc1.func.text_get = gl12_text_get;
1934 itc1.func.content_get = gl_content_get;
1935 itc1.func.state_get = gl_state_get;
1936 itc1.func.del = gl_del;
1938 for (i = 0; i < 1000; i++)
1940 elm_genlist_item_append(gl, &itc1,
1941 (void *)(long)i/* item data */,
1943 ELM_GENLIST_ITEM_NONE,
1945 (void *)(long)(i * 10)/* func data */);
1948 evas_object_resize(win, 400, 500);
1949 evas_object_show(win);
1953 gl13_cmp(const void *pa, const void *pb)
1955 const Elm_Object_Item *ia = pa, *ib = pb;
1956 int a = (int)(long) elm_object_item_data_get(ia);
1957 int b = (int)(long) elm_object_item_data_get(ib);
1962 test_genlist13(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1964 Elm_Object_Item *pi[6];
1965 Evas_Object *win, *bg, *bx, *gl;
1966 int i, base, idx[3] = {1, 10, 15};
1968 win = elm_win_add(NULL, "genlist-tree-insert-sorted", ELM_WIN_BASIC);
1969 elm_win_title_set(win, "Genlist Tree, Insert Sorted");
1970 elm_win_autodel_set(win, EINA_TRUE);
1972 bg = elm_bg_add(win);
1973 elm_win_resize_object_add(win, bg);
1974 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1975 evas_object_show(bg);
1977 bx = elm_box_add(win);
1978 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1979 elm_win_resize_object_add(win, bx);
1980 evas_object_show(bx);
1982 gl = elm_genlist_add(win);
1983 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1984 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1985 evas_object_show(gl);
1987 itc4.item_style = "default";
1988 itc4.func.text_get = gl4_text_get;
1989 itc4.func.content_get = NULL;
1990 itc4.func.state_get = NULL;
1991 itc4.func.del = NULL;
1993 /* mixed order to test insert sorted */
1995 for (i = 0; i < 3; i++)
1997 pi[i] = elm_genlist_item_direct_sorted_insert
1998 (gl, &itc4, (void *)idx[i]/* item data */, NULL/* parent */,
1999 ELM_GENLIST_ITEM_SUBITEMS, gl13_cmp/* cmp */,
2000 NULL/* func */, NULL/* func data */);
2003 for (i = 0, base = 100; i < 3; i++, base += 100)
2006 for (j = 0; j < 3; j++)
2008 elm_genlist_item_direct_sorted_insert
2009 (gl, &itc4, (void *)(idx[j] + base)/* item data */,
2010 pi[i]/* parent */, ELM_GENLIST_ITEM_NONE,
2011 gl13_cmp/* cmp */, NULL/* func */, NULL/* func data */);
2015 for (i = 0; i < 3; i++)
2017 pi[i + 3] = elm_genlist_item_direct_sorted_insert
2018 (gl, &itc4, (void *)(idx[i] * 2)/* item data */, NULL/* parent */,
2019 ELM_GENLIST_ITEM_SUBITEMS, gl13_cmp/* cmp */, NULL/* func */,
2020 NULL/* func data */);
2024 for (i = 0, base = 10000; i < 3; i++, base += 10000)
2027 for (j = 0; j < 3; j++)
2029 elm_genlist_item_direct_sorted_insert
2030 (gl, &itc4, (void *)(idx[j] + base)/* item data */,
2031 pi[i + 3]/* parent */, ELM_GENLIST_ITEM_NONE,
2032 gl13_cmp/* cmp */, NULL/* func */, NULL/* func data */);
2036 elm_box_pack_end(bx, gl);
2037 evas_object_show(bx);
2039 evas_object_resize(win, 320, 320);
2040 evas_object_show(win);
2044 my_gl_insert_before_rel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2046 Evas_Object *gl = data;
2047 static int i = 1000;
2048 Elm_Object_Item *gli_selected;
2050 itc1.item_style = "default";
2051 itc1.func.text_get = gl_text_get;
2052 itc1.func.content_get = NULL;
2053 itc1.func.state_get = NULL;
2054 itc1.func.del = NULL;
2056 gli_selected = elm_genlist_selected_item_get(gl);
2059 printf("no item selected\n");
2063 elm_genlist_item_insert_before(gl, &itc1,
2064 (void *)(long)i/* item data */,
2065 elm_genlist_item_parent_get(gli_selected),
2066 gli_selected/* item before */,
2067 ELM_GENLIST_ITEM_NONE,
2068 NULL/* func */, NULL/* func data */);
2073 my_gl_insert_after_rel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2075 Evas_Object *gl = data;
2077 Elm_Object_Item *gli_selected;
2079 itc1.item_style = "default";
2080 itc1.func.text_get = gl_text_get;
2081 itc1.func.content_get = NULL;
2082 itc1.func.state_get = NULL;
2083 itc1.func.del = NULL;
2085 gli_selected = elm_genlist_selected_item_get(gl);
2088 printf("no item selected\n");
2092 elm_genlist_item_insert_after(gl, &itc1,
2093 (void *)(long)i/* item data */,
2094 elm_genlist_item_parent_get(gli_selected),
2095 gli_selected/* item after */,
2096 ELM_GENLIST_ITEM_NONE,
2097 NULL/* func */, NULL/* func data */);
2102 test_genlist14(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2104 Elm_Object_Item *pi[6];
2105 Evas_Object *win, *bg, *bx, *bx2, *bt, *gl;
2107 /* index: 0, 1, 2, 3, 4, 5
2108 * items: 1, 15, 11, 2, 33, 21
2109 * final: 1, 2, 11, 15, 21, 33
2111 const int idx[6] = {1, 15, 11, 2, 33, 21};
2112 const int relative[6] = {
2113 0, /* item '1' - not used */
2114 0, /* item '15' - insert after pi[0], item '1' */
2115 -1, /* item '11' - insert before pi[1], item '15' */
2116 -2, /* item '2' - insert before pi[2], item '11' */
2117 1, /* item '33' - insert after pi[1], item '15' */
2118 -4 /* item '21' - insert before pi[4], item '33' */
2121 win = elm_win_add(NULL, "genlist-tree-insert-relative", ELM_WIN_BASIC);
2122 elm_win_title_set(win, "Genlist Tree, Insert Relative");
2123 elm_win_autodel_set(win, EINA_TRUE);
2125 bg = elm_bg_add(win);
2126 elm_win_resize_object_add(win, bg);
2127 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2128 evas_object_show(bg);
2130 bx = elm_box_add(win);
2131 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2132 elm_win_resize_object_add(win, bx);
2133 evas_object_show(bx);
2135 gl = elm_genlist_add(win);
2136 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
2137 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2138 evas_object_show(gl);
2140 itc4.item_style = "default";
2141 itc4.func.text_get = gl4_text_get;
2142 itc4.func.content_get = NULL;
2143 itc4.func.state_get = NULL;
2144 itc4.func.del = NULL;
2146 /* mixed order to test insert sorted */
2148 // BUG1: should be able to insert before=NULL, prepend
2149 // BUG2: should be able to insert after=NULL, append
2151 pi[0] = elm_genlist_item_append
2152 (gl, &itc4, (void *)idx[0]/* item data */,
2154 ELM_GENLIST_ITEM_SUBITEMS, NULL/* func */, NULL/* func data */);
2156 for (i = 1; i < 3; i++)
2158 if (relative[i] < 0)
2159 pi[i] = elm_genlist_item_insert_before
2160 (gl, &itc4, (void *)idx[i]/* item data */,
2161 NULL/* parent */, pi[-relative[i]],
2162 ELM_GENLIST_ITEM_SUBITEMS, NULL/* func */, NULL/* func data */);
2164 pi[i] = elm_genlist_item_insert_after
2165 (gl, &itc4, (void *)idx[i]/* item data */,
2166 NULL/* parent */, pi[relative[i]],
2167 ELM_GENLIST_ITEM_SUBITEMS, NULL/* func */, NULL/* func data */);
2170 for (i = 0; i < 3; i++)
2172 Elm_Object_Item *sub_glit[6];
2175 base = 1000 * (int)(long) elm_object_item_data_get(pi[i]);
2177 sub_glit[0] = elm_genlist_item_append
2178 (gl, &itc4, (void *)(long) (idx[0] + base)/* item data */, pi[i]/* parent */,
2179 ELM_GENLIST_ITEM_SUBITEMS, NULL/* func */, NULL/* func data */);
2181 for (j = 1; j < 6; j++) {
2182 if (relative[j] < 0)
2183 sub_glit[j] = elm_genlist_item_insert_before
2184 (gl, &itc4, (void *)(long) (idx[j] + base)/* item data */,
2185 pi[i]/* parent */, sub_glit[-relative[j]],
2186 ELM_GENLIST_ITEM_SUBITEMS, NULL/* func */, NULL/* func data */);
2188 sub_glit[j] = elm_genlist_item_insert_after
2189 (gl, &itc4, (void *)(long) (idx[j] + base)/* item data */,
2190 pi[i]/* parent */, sub_glit[relative[j]],
2191 ELM_GENLIST_ITEM_SUBITEMS, NULL/* func */, NULL/* func data */);
2195 for (i = 3; i < 6; i++)
2197 if (relative[i] < 0)
2198 pi[i] = elm_genlist_item_insert_before
2199 (gl, &itc4, (void *)(long) idx[i]/* item data */,
2200 NULL/* parent */, pi[-relative[i]],
2201 ELM_GENLIST_ITEM_SUBITEMS, NULL/* func */, NULL/* func data */);
2203 pi[i] = elm_genlist_item_insert_after
2204 (gl, &itc4, (void *)(long) idx[i]/* item data */,
2205 NULL/* parent */, pi[relative[i]],
2206 ELM_GENLIST_ITEM_SUBITEMS, NULL/* func */, NULL/* func data */);
2209 for (i = 3; i < 6; i++)
2211 Elm_Object_Item *sub_glit[6];
2214 base = 1000 * (int)(long) elm_object_item_data_get(pi[i]);
2216 sub_glit[0] = elm_genlist_item_append
2217 (gl, &itc4, (void *)(long) (idx[0] + base)/* item data */, pi[i]/* parent */,
2218 ELM_GENLIST_ITEM_SUBITEMS, NULL/* func */, NULL/* func data */);
2220 for (j = 1; j < 6; j++) {
2221 if (relative[j] < 0)
2222 sub_glit[j] = elm_genlist_item_insert_before
2223 (gl, &itc4, (void *)(long) (idx[j] + base)/* item data */,
2224 pi[i]/* parent */, sub_glit[-relative[j]],
2225 ELM_GENLIST_ITEM_SUBITEMS, NULL/* func */, NULL/* func data */);
2227 sub_glit[j] = elm_genlist_item_insert_after
2228 (gl, &itc4, (void *)(long) (idx[j] + base)/* item data */,
2229 pi[i]/* parent */, sub_glit[relative[j]],
2230 ELM_GENLIST_ITEM_SUBITEMS, NULL/* func */, NULL/* func data */);
2234 elm_box_pack_end(bx, gl);
2235 evas_object_show(bx);
2237 bx2 = elm_box_add(win);
2238 elm_box_horizontal_set(bx2, EINA_TRUE);
2239 elm_box_homogeneous_set(bx2, EINA_TRUE);
2240 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
2241 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
2243 bt = elm_button_add(win);
2244 elm_object_text_set(bt, "+ before");
2245 evas_object_smart_callback_add(bt, "clicked", my_gl_insert_before_rel, gl);
2246 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
2247 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
2248 elm_box_pack_end(bx2, bt);
2249 evas_object_show(bt);
2251 bt = elm_button_add(win);
2252 elm_object_text_set(bt, "+ after");
2253 evas_object_smart_callback_add(bt, "clicked", my_gl_insert_after_rel, gl);
2254 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
2255 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
2256 elm_box_pack_end(bx2, bt);
2257 evas_object_show(bt);
2259 elm_box_pack_end(bx, bx2);
2260 evas_object_show(bx2);
2262 evas_object_resize(win, 320, 320);
2263 evas_object_show(win);