1 #include <Elementary.h>
2 #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;
27 typedef enum _api_state api_state;
30 set_api_state(api_data *api)
32 const Eina_List *items = elm_box_children_get(api->box);
33 if(!eina_list_count(items))
36 Evas_Object *gl = eina_list_nth(items, 0); /* Genlist is the first item */
37 /* use elm_box_children_get() to get list of children */
39 {/* Put all api-changes under switch */
40 case HORIZONTAL_SET: /* 0 */
41 elm_genlist_mode_set(gl, ELM_LIST_LIMIT);
44 case NO_SELECT_MODE_SET: /* 1 */
45 elm_genlist_select_mode_set(gl, ELM_OBJECT_SELECT_MODE_NONE);
46 elm_genlist_mode_set(gl, ELM_LIST_SCROLL); /* Back to default */
49 case COMPRESS_MODE_SET: /* 2 */
50 elm_genlist_select_mode_set(gl, ELM_OBJECT_SELECT_MODE_DEFAULT);
51 elm_genlist_mode_set(gl, ELM_LIST_COMPRESS);
54 case BOUNCE_SET: /* 3 */
55 elm_genlist_bounce_set(gl, EINA_FALSE, EINA_FALSE);
58 case HOMOGENEOUS_SET: /* 4 */
59 elm_genlist_bounce_set(gl, EINA_TRUE, EINA_TRUE); /* Back to default */
60 elm_genlist_homogeneous_set(gl, EINA_TRUE);
63 case SCROLLER_POLICY_SET: /* 5 */
64 elm_genlist_homogeneous_set(gl, EINA_FALSE); /* Back to default */
65 elm_genlist_scroller_policy_set(gl, ELM_SCROLLER_POLICY_ON, ELM_SCROLLER_POLICY_ON);
68 case TOOLTIP_TEXT_SET: /* 6 */
70 elm_genlist_item_tooltip_text_set(elm_genlist_first_item_get(gl), "Tooltip text from API");
71 elm_genlist_item_bring_in(elm_genlist_first_item_get(gl),
72 ELM_GENLIST_ITEM_SCROLLTO_IN);
76 case ITEM_CURSOR_SET: /* 7 */
77 elm_genlist_item_cursor_set(elm_genlist_first_item_get(gl), ELM_CURSOR_HAND2);
86 _api_bt_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
87 { /* Will add here a SWITCH command containing code to modify test-object */
88 /* in accordance a->state value. */
92 printf("clicked event on API Button: api_state=<%d>\n", a->state);
95 sprintf(str, "Next API function (%u)", a->state);
96 elm_object_text_set(obj, str);
97 elm_object_disabled_set(obj, a->state == API_STATE_LAST);
100 * In this example some calls to elm_genlist_item_append() are used which give the
101 * value of an int as 'item data' and 'func data' after casting into (void*). For
102 * sure this works only on architectures where sizeof(int)==sizeof(void*).
103 * For real world usage you should hold a data structure or value in your
104 * application and then give only a pointer to this data as data pointer.
107 typedef struct _Testitem
109 Elm_Object_Item *item;
115 static Elm_Genlist_Item_Class *itc1;
116 static Elm_Genlist_Item_Class *itc15;
117 char *gl_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
120 snprintf(buf, sizeof(buf), "Item # %i", (int)(long)data);
124 Evas_Object *gl_content_get(void *data __UNUSED__, Evas_Object *obj, const char *part)
127 Evas_Object *ic = elm_icon_add(obj);
128 if (!strcmp(part, "elm.swallow.end"))
129 snprintf(buf, sizeof(buf), "%s/images/bubble.png", elm_app_data_dir_get());
131 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
132 elm_icon_file_set(ic, buf, NULL);
133 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
137 Eina_Bool gl_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
143 gl_sel(void *data, Evas_Object *obj, void *event_info)
145 printf("sel item data [%p] on genlist obj [%p], item pointer [%p]\n", data, obj, event_info);
149 _move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
151 Evas_Object *gl = data;
152 Evas_Event_Mouse_Move *ev = event_info;
154 Elm_Object_Item *gli;
155 gli = elm_genlist_at_xy_item_get(gl, ev->cur.canvas.x, ev->cur.canvas.y, &where);
157 printf("over %p, where %i\n", elm_object_item_data_get(gli), where);
159 printf("over none, where %i\n", where);
163 _bt50_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
165 elm_genlist_item_bring_in(data, ELM_GENLIST_ITEM_SCROLLTO_IN);
169 _bt1500_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
171 elm_genlist_item_bring_in(data, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
175 _gl_selected(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
177 printf("selected: %p\n", event_info);
181 _gl_double_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
183 printf("double clicked: %p\n", event_info);
187 _gl_longpress(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
189 printf("longpress %p\n", event_info);
193 _cleanup_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
199 test_genlist(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
201 Evas_Object *win, *gl, *bt_50, *bt_1500, *bx, *bxx, *bt;
203 Elm_Object_Item *gli;
205 api_data *api = calloc(1, sizeof(api_data));
207 win = elm_win_util_standard_add("genlist", "Genlist");
208 elm_win_autodel_set(win, EINA_TRUE);
209 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
211 bxx = elm_box_add(win);
212 elm_win_resize_object_add(win, bxx);
213 evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
214 evas_object_show(bxx);
216 bx = elm_box_add(win);
217 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
218 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
220 evas_object_show(bx);
222 bt = elm_button_add(win);
223 elm_object_text_set(bt, "Next API function");
224 evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked, (void *) api);
225 elm_box_pack_end(bxx, bt);
226 elm_object_disabled_set(bt, api->state == API_STATE_LAST);
227 evas_object_show(bt);
229 elm_box_pack_end(bxx, bx);
231 gl = elm_genlist_add(win);
232 evas_object_smart_callback_add(gl, "selected", _gl_selected, NULL);
233 evas_object_smart_callback_add(gl, "clicked,double", _gl_double_clicked, NULL);
234 evas_object_smart_callback_add(gl, "longpressed", _gl_longpress, NULL);
235 // FIXME: This causes genlist to resize the horiz axis very slowly :(
236 // Reenable this and resize the window horizontally, then try to resize it back
237 //elm_genlist_mode_set(gl, ELM_LIST_LIMIT);
238 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
239 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
240 elm_box_pack_end(bx, gl);
241 evas_object_show(gl);
243 over = evas_object_rectangle_add(evas_object_evas_get(win));
244 evas_object_color_set(over, 0, 0, 0, 0);
245 evas_object_event_callback_add(over, EVAS_CALLBACK_MOUSE_MOVE, _move, gl);
246 evas_object_repeat_events_set(over, 1);
247 evas_object_show(over);
248 evas_object_size_hint_weight_set(over, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
249 elm_win_resize_object_add(win, over);
251 itc1 = elm_genlist_item_class_new();
252 itc1->item_style = "default";
253 itc1->func.text_get = gl_text_get;
254 itc1->func.content_get = gl_content_get;
255 itc1->func.state_get = gl_state_get;
256 itc1->func.del = NULL;
258 bt_50 = elm_button_add(win);
259 elm_object_text_set(bt_50, "Go to 50");
260 evas_object_show(bt_50);
261 elm_box_pack_end(bx, bt_50);
263 bt_1500 = elm_button_add(win);
264 elm_object_text_set(bt_1500, "Go to 1500");
265 evas_object_show(bt_1500);
266 elm_box_pack_end(bx, bt_1500);
268 for (i = 0; i < 2000; i++)
270 gli = elm_genlist_item_append(gl, itc1,
271 (void *)(long)i/* item data */,
273 ELM_GENLIST_ITEM_NONE,
275 (void *)(long)(i * 10)/* func data */);
277 evas_object_smart_callback_add(bt_50, "clicked", _bt50_cb, gli);
279 evas_object_smart_callback_add(bt_1500, "clicked", _bt1500_cb, gli);
281 elm_genlist_item_class_free(itc1);
283 evas_object_resize(win, 480, 800);
284 evas_object_show(win);
290 my_gl_clear(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
292 Evas_Object *gl = data;
293 elm_genlist_clear(gl);
297 my_gl_add(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
299 Evas_Object *gl = data;
302 itc1->item_style = "default";
303 itc1->func.text_get = gl_text_get;
304 itc1->func.content_get = gl_content_get;
305 itc1->func.state_get = gl_state_get;
306 itc1->func.del = NULL;
308 elm_genlist_item_append(gl, itc1,
309 (void *)(long)i/* item data */,
311 ELM_GENLIST_ITEM_NONE,
313 (void *)(long)(i * 10)/* func data */);
318 my_gl_insert_before(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
320 Evas_Object *gl = data;
322 Elm_Object_Item *gli_selected;
324 itc1->item_style = "default";
325 itc1->func.text_get = gl_text_get;
326 itc1->func.content_get = gl_content_get;
327 itc1->func.state_get = gl_state_get;
328 itc1->func.del = NULL;
330 gli_selected = elm_genlist_selected_item_get(gl);
333 printf("no item selected\n");
337 elm_genlist_item_insert_before(gl, itc1,
338 (void *)(long)i/* item data */,
340 gli_selected /* item before */,
341 ELM_GENLIST_ITEM_NONE,
343 (void *)(long)(i * 10)/* func data */);
348 my_gl_insert_after(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
350 Evas_Object *gl = data;
352 Elm_Object_Item *gli_selected;
354 itc1->item_style = "default";
355 itc1->func.text_get = gl_text_get;
356 itc1->func.content_get = gl_content_get;
357 itc1->func.state_get = gl_state_get;
358 itc1->func.del = NULL;
360 gli_selected = elm_genlist_selected_item_get(gl);
363 printf("no item selected\n");
367 elm_genlist_item_insert_after(gl, itc1,
368 (void *)(long)i/* item data */,
370 gli_selected /* item after */,
371 ELM_GENLIST_ITEM_NONE,
373 (void *)(long)(i * 10)/* func data */);
378 my_gl_del(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
380 Evas_Object *gl = data;
381 Elm_Object_Item *gli = elm_genlist_selected_item_get(gl);
384 printf("no item selected\n");
387 elm_object_item_del(gli);
391 my_gl_disable(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
393 Evas_Object *gl = data;
394 Elm_Object_Item *gli = elm_genlist_selected_item_get(gl);
397 printf("no item selected\n");
400 elm_object_item_disabled_set(gli, EINA_TRUE);
401 elm_genlist_item_selected_set(gli, EINA_FALSE);
402 elm_genlist_item_update(gli);
406 my_gl_update_all(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
408 Evas_Object *gl = data;
410 Elm_Object_Item *it = elm_genlist_first_item_get(gl);
413 elm_genlist_item_update(it);
416 it = elm_genlist_item_next_get(it);
421 my_gl_first(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
423 Evas_Object *gl = data;
424 Elm_Object_Item *gli = elm_genlist_first_item_get(gl);
426 elm_genlist_item_show(gli, ELM_GENLIST_ITEM_SCROLLTO_IN);
427 elm_genlist_item_selected_set(gli, 1);
431 my_gl_last(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
433 Evas_Object *gl = data;
434 Elm_Object_Item *gli = elm_genlist_last_item_get(gl);
436 elm_genlist_item_show(gli, ELM_GENLIST_ITEM_SCROLLTO_IN);
437 elm_genlist_item_selected_set(gli, 1);
441 my_gl_flush_delay(void *data __UNUSED__)
443 elm_cache_all_flush();
444 return ECORE_CALLBACK_CANCEL;
448 my_gl_flush(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
450 ecore_timer_add(1.2, my_gl_flush_delay, NULL);
454 test_genlist2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
456 Evas_Object *win, *bg, *gl, *bx, *bx2, *bx3, *bt;
457 Elm_Object_Item *gli[10];
460 win = elm_win_add(NULL, "genlist2", ELM_WIN_BASIC);
461 elm_win_title_set(win, "Genlist 2");
462 elm_win_autodel_set(win, EINA_TRUE);
464 bg = elm_bg_add(win);
465 snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
466 elm_bg_file_set(bg, buf, NULL);
467 elm_win_resize_object_add(win, bg);
468 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
469 evas_object_show(bg);
471 bx = elm_box_add(win);
472 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
473 elm_win_resize_object_add(win, bx);
474 evas_object_show(bx);
476 gl = elm_genlist_add(win);
477 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
478 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
479 evas_object_show(gl);
481 itc1 = elm_genlist_item_class_new();
482 itc1->item_style = "default";
483 itc1->func.text_get = gl_text_get;
484 itc1->func.content_get = gl_content_get;
485 itc1->func.state_get = gl_state_get;
486 itc1->func.del = NULL;
488 gli[0] = elm_genlist_item_append(gl, itc1,
489 (void *)1001/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
490 (void *)1001/* func data */);
491 gli[1] = elm_genlist_item_append(gl, itc1,
492 (void *)1002/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
493 (void *)1002/* func data */);
494 gli[2] = elm_genlist_item_append(gl, itc1,
495 (void *)1003/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
496 (void *)1003/* func data */);
497 gli[3] = elm_genlist_item_prepend(gl, itc1,
498 (void *)1004/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
499 (void *)1004/* func data */);
500 gli[4] = elm_genlist_item_prepend(gl, itc1,
501 (void *)1005/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
502 (void *)1005/* func data */);
503 gli[5] = elm_genlist_item_insert_before(gl, itc1,
504 (void *)1006/* item data */, NULL/* parent */, gli[2]/* rel */, ELM_GENLIST_ITEM_NONE,
505 gl_sel/* func */, (void *)1006/* func data */);
506 gli[6] = elm_genlist_item_insert_after(gl, itc1,
507 (void *)1007/* item data */, NULL/* parent */, gli[2]/* rel */, ELM_GENLIST_ITEM_NONE,
508 gl_sel/* func */, (void *)1007/* func data */);
509 elm_box_pack_end(bx, gl);
511 bx2 = elm_box_add(win);
512 elm_box_horizontal_set(bx2, EINA_TRUE);
513 elm_box_homogeneous_set(bx2, EINA_TRUE);
514 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
515 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
517 bt = elm_button_add(win);
518 elm_object_text_set(bt, "/\\");
519 evas_object_smart_callback_add(bt, "clicked", my_gl_first, gl);
520 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
521 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
522 elm_box_pack_end(bx2, bt);
523 evas_object_show(bt);
525 bt = elm_button_add(win);
526 elm_object_text_set(bt, "\\/");
527 evas_object_smart_callback_add(bt, "clicked", my_gl_last, gl);
528 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
529 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
530 elm_box_pack_end(bx2, bt);
531 evas_object_show(bt);
533 bt = elm_button_add(win);
534 elm_object_text_set(bt, "#");
535 evas_object_smart_callback_add(bt, "clicked", my_gl_disable, gl);
536 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
537 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
538 elm_box_pack_end(bx2, bt);
539 evas_object_show(bt);
541 bt = elm_button_add(win);
542 elm_object_text_set(bt, "U");
543 evas_object_smart_callback_add(bt, "clicked", my_gl_update_all, gl);
544 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
545 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
546 elm_box_pack_end(bx2, bt);
547 evas_object_show(bt);
549 elm_box_pack_end(bx, bx2);
550 evas_object_show(bx2);
552 bx2 = elm_box_add(win);
553 elm_box_horizontal_set(bx2, EINA_TRUE);
554 elm_box_homogeneous_set(bx2, EINA_TRUE);
555 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
556 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
558 bt = elm_button_add(win);
559 elm_object_text_set(bt, "X");
560 evas_object_smart_callback_add(bt, "clicked", my_gl_clear, gl);
561 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
562 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
563 elm_box_pack_end(bx2, bt);
564 evas_object_show(bt);
566 bt = elm_button_add(win);
567 elm_object_text_set(bt, "+");
568 evas_object_smart_callback_add(bt, "clicked", my_gl_add, gl);
569 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
570 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
571 elm_box_pack_end(bx2, bt);
572 evas_object_show(bt);
574 bt = elm_button_add(win);
575 elm_object_text_set(bt, "-");
576 evas_object_smart_callback_add(bt, "clicked", my_gl_del, gl);
577 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
578 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
579 elm_box_pack_end(bx2, bt);
580 evas_object_show(bt);
582 elm_box_pack_end(bx, bx2);
583 evas_object_show(bx2);
585 bx3 = elm_box_add(win);
586 elm_box_horizontal_set(bx3, EINA_TRUE);
587 elm_box_homogeneous_set(bx3, EINA_TRUE);
588 evas_object_size_hint_weight_set(bx3, EVAS_HINT_EXPAND, 0.0);
589 evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL, EVAS_HINT_FILL);
591 bt = elm_button_add(win);
592 elm_object_text_set(bt, "+ before");
593 evas_object_smart_callback_add(bt, "clicked", my_gl_insert_before, gl);
594 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
595 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
596 elm_box_pack_end(bx3, bt);
597 evas_object_show(bt);
599 bt = elm_button_add(win);
600 elm_object_text_set(bt, "+ after");
601 evas_object_smart_callback_add(bt, "clicked", my_gl_insert_after, gl);
602 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
603 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
604 elm_box_pack_end(bx3, bt);
605 evas_object_show(bt);
607 bt = elm_button_add(win);
608 elm_object_text_set(bt, "Flush");
609 evas_object_smart_callback_add(bt, "clicked", my_gl_flush, gl);
610 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
611 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
612 elm_box_pack_end(bx3, bt);
613 evas_object_show(bt);
615 elm_box_pack_end(bx, bx3);
616 evas_object_show(bx3);
618 /* item_class_ref is needed for itc1. some items can be added in callbacks */
619 elm_genlist_item_class_ref(itc1);
620 elm_genlist_item_class_free(itc1);
622 evas_object_resize(win, 320, 320);
623 evas_object_show(win);
628 static Elm_Genlist_Item_Class itc2;
630 char *gl2_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
632 const Testitem *tit = data;
634 snprintf(buf, sizeof(buf), "Item mode %i", tit->mode);
638 Evas_Object *gl2_content_get(void *data, Evas_Object *obj, const char *part)
640 const Testitem *tit = data;
642 Evas_Object *ic = elm_icon_add(obj);
643 if (!strcmp(part, "elm.swallow.icon"))
645 if (!(tit->mode & 0x3))
646 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
647 else if ((tit->mode & 0x3) == 1)
648 snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
649 else if ((tit->mode & 0x3) == 2)
650 snprintf(buf, sizeof(buf), "%s/images/panel_01.jpg", elm_app_data_dir_get());
651 else if ((tit->mode & 0x3) == 3)
652 snprintf(buf, sizeof(buf), "%s/images/rock_01.jpg", elm_app_data_dir_get());
653 elm_icon_file_set(ic, buf, NULL);
655 else if (!strcmp(part, "elm.swallow.end"))
657 if (!(tit->mode & 0x3))
658 snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", elm_app_data_dir_get());
659 else if ((tit->mode & 0x3) == 1)
660 snprintf(buf, sizeof(buf), "%s/images/sky_02.jpg", elm_app_data_dir_get());
661 else if ((tit->mode & 0x3) == 2)
662 snprintf(buf, sizeof(buf), "%s/images/sky_03.jpg", elm_app_data_dir_get());
663 else if ((tit->mode & 0x3) == 3)
664 snprintf(buf, sizeof(buf), "%s/images/sky_04.jpg", elm_app_data_dir_get());
665 elm_icon_file_set(ic, buf, NULL);
667 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
671 Eina_Bool gl2_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
677 my_gl_update(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
679 Testitem *tit = data;
681 elm_genlist_item_update(tit->item);
685 my_gl_labels_update(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
687 Testitem *tit = data;
689 elm_genlist_item_fields_update(tit->item, "*", ELM_GENLIST_ITEM_FIELD_TEXT);
693 my_gl_contents_update(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
695 Testitem *tit = data;
697 elm_genlist_item_fields_update(tit->item, "*", ELM_GENLIST_ITEM_FIELD_CONTENT);
701 test_genlist3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
703 Evas_Object *win, *gl, *bx, *bx2, *bt;
704 static Testitem tit[3];
706 win = elm_win_util_standard_add("genlist3", "Genlist 3");
707 elm_win_autodel_set(win, EINA_TRUE);
709 bx = elm_box_add(win);
710 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
711 elm_win_resize_object_add(win, bx);
712 evas_object_show(bx);
714 gl = elm_genlist_add(win);
715 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
716 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
717 evas_object_show(gl);
719 itc2.item_style = "default";
720 itc2.func.text_get = gl2_text_get;
721 itc2.func.content_get = gl2_content_get;
722 itc2.func.state_get = gl2_state_get;
723 itc2.func.del = NULL;
726 tit[0].item = elm_genlist_item_append(gl, &itc2,
727 &(tit[0])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
728 NULL/* func data */);
730 tit[1].item = elm_genlist_item_append(gl, &itc2,
731 &(tit[1])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
732 NULL/* func data */);
734 tit[2].item = elm_genlist_item_append(gl, &itc2,
735 &(tit[2])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
736 NULL/* func data */);
738 elm_box_pack_end(bx, gl);
739 evas_object_show(bx);
741 bx2 = elm_box_add(win);
742 elm_box_horizontal_set(bx2, EINA_TRUE);
743 elm_box_homogeneous_set(bx2, EINA_TRUE);
744 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
745 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
747 bt = elm_button_add(win);
748 elm_object_text_set(bt, "[1]");
749 evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[0]));
750 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
751 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
752 elm_box_pack_end(bx2, bt);
753 evas_object_show(bt);
755 bt = elm_button_add(win);
756 elm_object_text_set(bt, "labels");
757 evas_object_smart_callback_add(bt, "clicked", my_gl_labels_update, &(tit[1]));
758 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
759 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
760 elm_box_pack_end(bx2, bt);
761 evas_object_show(bt);
763 bt = elm_button_add(win);
764 elm_object_text_set(bt, "contents");
765 evas_object_smart_callback_add(bt, "clicked", my_gl_contents_update, &(tit[2]));
766 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
767 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
768 elm_box_pack_end(bx2, bt);
769 evas_object_show(bt);
771 elm_box_pack_end(bx, bx2);
772 evas_object_show(bx2);
774 evas_object_resize(win, 320, 320);
775 evas_object_show(win);
781 my_gl_item_check_changed(void *data, Evas_Object *obj, void *event_info __UNUSED__)
783 Testitem *tit = data;
784 tit->onoff = elm_check_state_get(obj);
785 printf("item %p onoff = %i\n", tit, tit->onoff);
788 static Elm_Genlist_Item_Class itc3;
790 char *gl3_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
792 const Testitem *tit = data;
794 snprintf(buf, sizeof(buf), "Item mode %i", tit->mode);
798 Evas_Object *gl3_content_get(void *data, Evas_Object *obj, const char *part)
800 const Testitem *tit = data;
801 if (!strcmp(part, "elm.swallow.icon"))
805 lb = elm_label_add(obj);
806 elm_label_line_wrap_set(lb, ELM_WRAP_CHAR);
807 elm_label_wrap_width_set(lb, 201);
808 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");
811 else if (!strcmp(part, "elm.swallow.end"))
814 ck = elm_check_add(obj);
815 evas_object_propagate_events_set(ck, EINA_FALSE);
816 elm_check_state_set(ck, tit->onoff);
817 evas_object_smart_callback_add(ck, "changed", my_gl_item_check_changed, data);
823 Eina_Bool gl3_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
829 test_genlist4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
831 Evas_Object *win, *gl, *bx, *bx2, *bt;
832 static Testitem tit[3];
834 win = elm_win_util_standard_add("genlist4", "Genlist 4");
835 elm_win_autodel_set(win, EINA_TRUE);
837 bx = elm_box_add(win);
838 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
839 elm_win_resize_object_add(win, bx);
840 evas_object_show(bx);
842 gl = elm_genlist_add(win);
843 elm_genlist_mode_set(gl, ELM_LIST_COMPRESS);
844 elm_genlist_multi_select_set(gl, 1);
845 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
846 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
847 evas_object_show(gl);
849 itc3.item_style = "default";
850 itc3.func.text_get = gl3_text_get;
851 itc3.func.content_get = gl3_content_get;
852 itc3.func.state_get = gl3_state_get;
853 itc3.func.del = NULL;
856 tit[0].item = elm_genlist_item_append(gl, &itc3,
857 &(tit[0])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
858 NULL/* func data */);
860 tit[1].item = elm_genlist_item_append(gl, &itc3,
861 &(tit[1])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
862 NULL/* func data */);
864 tit[2].item = elm_genlist_item_append(gl, &itc3,
865 &(tit[2])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
866 NULL/* func data */);
868 elm_box_pack_end(bx, gl);
869 evas_object_show(bx);
871 bx2 = elm_box_add(win);
872 elm_box_horizontal_set(bx2, EINA_TRUE);
873 elm_box_homogeneous_set(bx2, EINA_TRUE);
874 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
875 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
877 bt = elm_button_add(win);
878 elm_object_text_set(bt, "[1]");
879 evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[0]));
880 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
881 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
882 elm_box_pack_end(bx2, bt);
883 evas_object_show(bt);
885 bt = elm_button_add(win);
886 elm_object_text_set(bt, "[2]");
887 evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[1]));
888 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
889 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
890 elm_box_pack_end(bx2, bt);
891 evas_object_show(bt);
893 bt = elm_button_add(win);
894 elm_object_text_set(bt, "[3]");
895 evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[2]));
896 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
897 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
898 elm_box_pack_end(bx2, bt);
899 evas_object_show(bt);
901 elm_box_pack_end(bx, bx2);
902 evas_object_show(bx2);
904 evas_object_resize(win, 320, 320);
905 evas_object_show(win);
911 my_gl_item_check_changed2(void *data, Evas_Object *obj, void *event_info __UNUSED__)
913 Testitem *tit = data;
914 tit->onoff = elm_check_state_get(obj);
915 printf("item %p onoff = %i\n", tit, tit->onoff);
918 static Elm_Genlist_Item_Class itc5;
920 char *gl5_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part)
922 const Testitem *tit = data;
924 if (!strcmp(part, "elm.text"))
926 snprintf(buf, sizeof(buf), "Item mode %i", tit->mode);
928 else if (!strcmp(part, "elm.text.sub"))
930 snprintf(buf, sizeof(buf), "%i bottles on the wall", tit->mode);
935 Evas_Object *gl5_content_get(void *data, Evas_Object *obj, const char *part)
937 const Testitem *tit = data;
939 if (!strcmp(part, "elm.swallow.icon"))
941 Evas_Object *bx = elm_box_add(obj);
943 elm_box_horizontal_set(bx, EINA_TRUE);
944 ic = elm_icon_add(obj);
945 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
946 elm_icon_file_set(ic, buf, NULL);
947 elm_icon_resizable_set(ic, 0, 0);
948 evas_object_show(ic);
949 elm_box_pack_end(bx, ic);
950 ic = elm_icon_add(obj);
951 elm_icon_file_set(ic, buf, NULL);
952 elm_icon_resizable_set(ic, 0, 0);
953 evas_object_show(ic);
954 elm_box_pack_end(bx, ic);
955 elm_box_horizontal_set(bx, EINA_TRUE);
956 evas_object_show(bx);
959 else if (!strcmp(part, "elm.swallow.end"))
962 ck = elm_check_add(obj);
963 evas_object_propagate_events_set(ck, EINA_FALSE);
964 elm_check_state_set(ck, tit->onoff);
965 evas_object_smart_callback_add(ck, "changed", my_gl_item_check_changed2, data);
966 evas_object_show(ck);
972 Eina_Bool gl5_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
978 item_drag_up(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
984 item_drag_down(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
986 printf("drag down\n");
990 item_drag_left(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
992 printf("drag left\n");
996 item_drag_right(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
998 printf("drag right\n");
1002 scroll_top(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1004 printf("Top edge!\n");
1008 scroll_bottom(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1010 printf("Bottom edge!\n");
1014 scroll_left(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1016 printf("Left edge!\n");
1020 scroll_right(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1022 printf("Right edge!\n");
1026 item_drag(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1032 item_drag_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1034 printf("drag stop\n");
1038 item_longpress(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1040 printf("longpress\n");
1044 test_genlist5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1046 Evas_Object *win, *gl, *bx, *bx2, *bt;
1047 static Testitem tit[3];
1049 win = elm_win_util_standard_add("genlist5", "Genlist 5");
1050 elm_win_autodel_set(win, EINA_TRUE);
1052 bx = elm_box_add(win);
1053 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1054 elm_win_resize_object_add(win, bx);
1055 evas_object_show(bx);
1057 gl = elm_genlist_add(win);
1058 elm_genlist_select_mode_set(gl, ELM_OBJECT_SELECT_MODE_ALWAYS);
1059 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1060 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1061 evas_object_show(gl);
1062 itc5.item_style = "double_label";
1063 itc5.func.text_get = gl5_text_get;
1064 itc5.func.content_get = gl5_content_get;
1065 itc5.func.state_get = gl5_state_get;
1066 itc5.func.del = NULL;
1069 tit[0].item = elm_genlist_item_append(gl, &itc5,
1070 &(tit[0])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
1071 NULL/* func data */);
1073 tit[1].item = elm_genlist_item_append(gl, &itc5,
1074 &(tit[1])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
1075 NULL/* func data */);
1077 tit[2].item = elm_genlist_item_append(gl, &itc5,
1078 &(tit[2])/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl_sel/* func */,
1079 NULL/* func data */);
1081 elm_box_pack_end(bx, gl);
1082 evas_object_show(bx);
1084 evas_object_smart_callback_add(gl, "drag,start,up", item_drag_up, NULL);
1085 evas_object_smart_callback_add(gl, "drag,start,down", item_drag_down, NULL);
1086 evas_object_smart_callback_add(gl, "drag,start,left", item_drag_left, NULL);
1087 evas_object_smart_callback_add(gl, "drag,start,right", item_drag_right, NULL);
1088 evas_object_smart_callback_add(gl, "scroll,edge,top", scroll_top, NULL);
1089 evas_object_smart_callback_add(gl, "scroll,edge,bottom", scroll_bottom, NULL);
1090 evas_object_smart_callback_add(gl, "scroll,edge,left", scroll_left, NULL);
1091 evas_object_smart_callback_add(gl, "scroll,edge,right", scroll_right, NULL);
1092 evas_object_smart_callback_add(gl, "drag", item_drag, NULL);
1093 evas_object_smart_callback_add(gl, "drag,stop", item_drag_stop, NULL);
1094 evas_object_smart_callback_add(gl, "longpressed", item_longpress, NULL);
1096 bx2 = elm_box_add(win);
1097 elm_box_horizontal_set(bx2, EINA_TRUE);
1098 elm_box_homogeneous_set(bx2, EINA_TRUE);
1099 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
1100 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
1102 bt = elm_button_add(win);
1103 elm_object_text_set(bt, "[1]");
1104 evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[0]));
1105 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1106 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1107 elm_box_pack_end(bx2, bt);
1108 evas_object_show(bt);
1110 bt = elm_button_add(win);
1111 elm_object_text_set(bt, "[2]");
1112 evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[1]));
1113 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1114 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1115 elm_box_pack_end(bx2, bt);
1116 evas_object_show(bt);
1118 bt = elm_button_add(win);
1119 elm_object_text_set(bt, "[3]");
1120 evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[2]));
1121 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1122 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1123 elm_box_pack_end(bx2, bt);
1124 evas_object_show(bt);
1126 elm_box_pack_end(bx, bx2);
1127 evas_object_show(bx2);
1129 evas_object_resize(win, 320, 320);
1130 evas_object_show(win);
1135 static Elm_Genlist_Item_Class itc4;
1138 gl4_sel(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1140 Elm_Object_Item *glit = event_info;
1141 int depth = elm_genlist_item_expanded_depth_get(glit);
1142 printf("expanded depth for selected item is %d\n", depth);
1146 gl4_exp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1148 Elm_Object_Item *glit = event_info;
1149 Evas_Object *gl = elm_object_item_widget_get(glit);
1150 int val = (int)(long) elm_object_item_data_get(glit);
1152 elm_genlist_item_append(gl, &itc4,
1153 (void *)(long) (val + 1)/* item data */,
1154 glit/* parent */, ELM_GENLIST_ITEM_NONE,
1156 NULL/* func data */);
1157 elm_genlist_item_append(gl, &itc4,
1158 (void *)(long) (val + 2)/* item data */,
1159 glit/* parent */, ELM_GENLIST_ITEM_NONE,
1161 NULL/* func data */);
1162 elm_genlist_item_append(gl, &itc4,
1163 (void *)(long) (val + 3)/* item data */,
1165 ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
1166 NULL/* func data */);
1169 gl4_con(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1171 Elm_Object_Item *glit = event_info;
1172 elm_genlist_item_subitems_clear(glit);
1176 gl4_exp_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1178 Elm_Object_Item *glit = event_info;
1179 elm_genlist_item_expanded_set(glit, EINA_TRUE);
1183 gl4_con_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1185 Elm_Object_Item *glit = event_info;
1186 elm_genlist_item_expanded_set(glit, EINA_FALSE);
1189 char *gl4_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
1192 snprintf(buf, sizeof(buf), "Item mode %i", (int)(long)data);
1196 Evas_Object *gl4_content_get(void *data __UNUSED__, Evas_Object *obj, const char *part)
1199 if (!strcmp(part, "elm.swallow.icon"))
1201 Evas_Object *ic = elm_icon_add(obj);
1202 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
1203 elm_icon_file_set(ic, buf, NULL);
1204 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1205 evas_object_show(ic);
1208 else if (!strcmp(part, "elm.swallow.end"))
1211 ck = elm_check_add(obj);
1212 evas_object_propagate_events_set(ck, EINA_FALSE);
1213 evas_object_show(ck);
1219 Eina_Bool gl4_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
1224 void gl4_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
1226 printf("item deleted.\n");
1230 test_genlist6(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1232 Evas_Object *win, *gl, *bx, *bx2, *bt;
1234 win = elm_win_util_standard_add("genlist-tree", "Genlist Tree");
1235 elm_win_autodel_set(win, EINA_TRUE);
1237 bx = elm_box_add(win);
1238 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1239 elm_win_resize_object_add(win, bx);
1240 evas_object_show(bx);
1242 gl = elm_genlist_add(win);
1243 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1244 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1245 evas_object_show(gl);
1247 itc4.item_style = "default";
1248 itc4.func.text_get = gl4_text_get;
1249 itc4.func.content_get = gl4_content_get;
1250 itc4.func.state_get = gl4_state_get;
1251 itc4.func.del = gl4_del;
1253 elm_genlist_item_append(gl, &itc4,
1254 (void *)1/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
1255 NULL/* func data */);
1256 elm_genlist_item_append(gl, &itc4,
1257 (void *)2/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
1258 NULL/* func data */);
1259 elm_genlist_item_append(gl, &itc4,
1260 (void *)3/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1261 NULL/* func data */);
1263 evas_object_smart_callback_add(gl, "expand,request", gl4_exp_req, gl);
1264 evas_object_smart_callback_add(gl, "contract,request", gl4_con_req, gl);
1265 evas_object_smart_callback_add(gl, "expanded", gl4_exp, gl);
1266 evas_object_smart_callback_add(gl, "contracted", gl4_con, gl);
1268 elm_box_pack_end(bx, gl);
1269 evas_object_show(bx);
1271 bx2 = elm_box_add(win);
1272 elm_box_horizontal_set(bx2, EINA_TRUE);
1273 elm_box_homogeneous_set(bx2, EINA_TRUE);
1274 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
1275 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
1277 bt = elm_button_add(win);
1278 elm_object_text_set(bt, "[1]");
1279 // evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[0]));
1280 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1281 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1282 elm_box_pack_end(bx2, bt);
1283 evas_object_show(bt);
1285 bt = elm_button_add(win);
1286 elm_object_text_set(bt, "[2]");
1287 // evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[1]));
1288 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1289 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1290 elm_box_pack_end(bx2, bt);
1291 evas_object_show(bt);
1293 bt = elm_button_add(win);
1294 elm_object_text_set(bt, "[3]");
1295 // evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[2]));
1296 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
1297 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1298 elm_box_pack_end(bx2, bt);
1299 evas_object_show(bt);
1301 elm_box_pack_end(bx, bx2);
1302 evas_object_show(bx2);
1304 evas_object_resize(win, 320, 320);
1305 evas_object_show(win);
1310 struct genlist7_data
1312 Evas_Object *win, *naviframe;
1315 static Elm_Genlist_Item_Class itc7;
1318 gl_sel7(void *data, Evas_Object *obj, void *event_info)
1320 if (!event_info) return;
1321 elm_genlist_item_item_class_update(event_info, &itc7);
1322 printf("sel item data [%p] on genlist obj [%p], item pointer [%p], new item style [%s] \n", data, obj, event_info, itc7.item_style);
1326 test_genlist7_back_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1328 struct genlist7_data *info = data;
1331 elm_naviframe_item_pop(info->naviframe);
1335 test_genlist7_swipe(void *data, Evas_Object *obj __UNUSED__, void *event_info)
1337 struct genlist7_data *info = data;
1338 Evas_Object *box, *entry, *button;
1339 char item_data[] = "Just a simple test";
1341 if ((!event_info) || (!data)) return;
1343 box = elm_box_add(info->win);
1344 elm_box_homogeneous_set(box, EINA_FALSE);
1345 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1346 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
1347 evas_object_show(box);
1349 entry = elm_entry_add(info->win);
1350 elm_entry_scrollable_set(entry, EINA_TRUE);
1351 elm_entry_editable_set(entry, EINA_FALSE);
1352 elm_object_text_set(entry, item_data);
1353 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1354 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1355 evas_object_show(entry);
1357 button = elm_button_add(info->win);
1358 elm_object_text_set(button, "back");
1359 evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, 0);
1360 evas_object_size_hint_align_set(button, EVAS_HINT_FILL, 0);
1361 evas_object_smart_callback_add(button, "clicked", test_genlist7_back_cb,
1363 evas_object_show(button);
1365 elm_box_pack_start(box, entry);
1366 elm_box_pack_end(box, button);
1368 elm_naviframe_item_simple_push(info->naviframe, box);
1372 test_genlist7(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1374 Evas_Object *win, *gl, *naviframe;
1375 static struct genlist7_data info;
1376 static Testitem tit[3];
1378 win = elm_win_util_standard_add("genlist7", "Genlist 7");
1379 elm_win_autodel_set(win, EINA_TRUE);
1382 naviframe = elm_naviframe_add(win);
1383 elm_win_resize_object_add(win, naviframe);
1384 evas_object_size_hint_weight_set(naviframe, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1385 evas_object_size_hint_align_set(naviframe, EVAS_HINT_FILL, EVAS_HINT_FILL);
1386 evas_object_show(naviframe);
1387 info.naviframe = naviframe;
1389 gl = elm_genlist_add(win);
1390 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1391 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1392 evas_object_smart_callback_add(gl, "swipe", test_genlist7_swipe, &info);
1393 evas_object_show(gl);
1394 elm_naviframe_item_simple_push(naviframe, gl);
1396 itc2.item_style = "default";
1397 itc2.func.text_get = gl2_text_get;
1398 itc2.func.content_get = gl2_content_get;
1399 itc2.func.state_get = gl2_state_get;
1400 itc2.func.del = NULL;
1402 itc7.item_style = "double_label";
1403 itc7.func.text_get = gl5_text_get;
1404 itc7.func.content_get = gl5_content_get;
1405 itc7.func.state_get = gl5_state_get;
1406 itc7.func.del = NULL;
1409 tit[0].item = elm_genlist_item_append(gl, &itc2,
1410 &(tit[0])/* item data */, NULL/* parent */,
1411 ELM_GENLIST_ITEM_NONE, gl_sel7/* func */,
1412 NULL/* func data */);
1414 tit[1].item = elm_genlist_item_append(gl, &itc2,
1415 &(tit[1])/* item data */, NULL/* parent */,
1416 ELM_GENLIST_ITEM_NONE, gl_sel7/* func */,
1417 NULL/* func data */);
1419 tit[2].item = elm_genlist_item_append(gl, &itc2,
1420 &(tit[2])/* item data */, NULL/* parent */,
1421 ELM_GENLIST_ITEM_NONE, gl_sel7/* func */,
1422 NULL/* func data */);
1424 evas_object_resize(win, 320, 320);
1425 evas_object_show(win);
1430 static Elm_Genlist_Item_Class itc_group;
1432 char *gl8_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
1435 snprintf(buf, sizeof(buf), "Group Index # %i (Item # %i)", (int)((long)data / 10), (int)(long)data);
1440 _bt_show_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1442 elm_genlist_item_show(data, ELM_GENLIST_ITEM_SCROLLTO_TOP);
1446 _bt_bring_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1448 elm_genlist_item_bring_in(data, ELM_GENLIST_ITEM_SCROLLTO_TOP);
1452 test_genlist8(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1454 Evas_Object *win, *gl, *bt[8], *bx, *bx2, *bx3;
1455 Elm_Object_Item *gli = NULL, *git = NULL;
1458 win = elm_win_util_standard_add("genlist-group", "Genlist Group");
1459 elm_win_autodel_set(win, EINA_TRUE);
1461 bx = elm_box_add(win);
1462 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1463 elm_win_resize_object_add(win, bx);
1464 evas_object_show(bx);
1466 gl = elm_genlist_add(win);
1467 evas_object_smart_callback_add(gl, "selected", _gl_selected, NULL);
1468 evas_object_smart_callback_add(gl, "clicked,double", _gl_double_clicked, NULL);
1469 evas_object_smart_callback_add(gl, "longpressed", _gl_longpress, NULL);
1470 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1471 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1472 elm_box_pack_end(bx, gl);
1473 evas_object_show(gl);
1475 itc1 = elm_genlist_item_class_new();
1476 itc1->item_style = "default";
1477 itc1->func.text_get = gl_text_get;
1478 itc1->func.content_get = gl_content_get;
1479 itc1->func.state_get = gl_state_get;
1480 itc1->func.del = NULL;
1482 itc_group.item_style = "group_index";
1483 itc_group.func.text_get = gl8_text_get;
1484 itc_group.func.content_get = NULL;
1485 itc_group.func.state_get = NULL;
1486 itc_group.func.del = NULL;
1488 bx2 = elm_box_add(win);
1489 elm_box_horizontal_set(bx2, EINA_TRUE);
1490 elm_box_homogeneous_set(bx2, EINA_TRUE);
1491 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
1492 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
1495 bt[bt_num] = elm_button_add(win);
1496 elm_object_text_set(bt[bt_num], "Show 0");
1497 evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1498 evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1499 evas_object_show(bt[bt_num]);
1500 elm_box_pack_end(bx2, bt[bt_num]);
1502 bt[++bt_num] = elm_button_add(win);
1503 elm_object_text_set(bt[bt_num], "Show 26");
1504 evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1505 evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1506 evas_object_show(bt[bt_num]);
1507 elm_box_pack_end(bx2, bt[bt_num]);
1509 bt[++bt_num] = elm_button_add(win);
1510 elm_object_text_set(bt[bt_num], "Show 101");
1511 evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1512 evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1513 evas_object_show(bt[bt_num]);
1514 elm_box_pack_end(bx2, bt[bt_num]);
1516 bt[++bt_num] = elm_button_add(win);
1517 elm_object_text_set(bt[bt_num], "Show 480");
1518 evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1519 evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1520 evas_object_show(bt[bt_num]);
1521 elm_box_pack_end(bx2, bt[bt_num]);
1523 elm_box_pack_end(bx, bx2);
1524 evas_object_show(bx2);
1526 bx3 = elm_box_add(win);
1527 elm_box_horizontal_set(bx3, EINA_TRUE);
1528 elm_box_homogeneous_set(bx3, EINA_TRUE);
1529 evas_object_size_hint_weight_set(bx3, EVAS_HINT_EXPAND, 0.0);
1530 evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL, EVAS_HINT_FILL);
1532 bt[++bt_num] = elm_button_add(win);
1533 elm_object_text_set(bt[bt_num], "Bring top 0");
1534 evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1535 evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1536 evas_object_show(bt[bt_num]);
1537 elm_box_pack_end(bx3, bt[bt_num]);
1539 bt[++bt_num] = elm_button_add(win);
1540 elm_object_text_set(bt[bt_num], "Bring top 31");
1541 evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1542 evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1543 evas_object_show(bt[bt_num]);
1544 elm_box_pack_end(bx3, bt[bt_num]);
1546 bt[++bt_num] = elm_button_add(win);
1547 elm_object_text_set(bt[bt_num], "Bring top 239");
1548 evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1549 evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1550 evas_object_show(bt[bt_num]);
1551 elm_box_pack_end(bx3, bt[bt_num]);
1553 bt[++bt_num] = elm_button_add(win);
1554 elm_object_text_set(bt[bt_num], "Bring top 477");
1555 evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL);
1556 evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0);
1557 evas_object_show(bt[bt_num]);
1558 elm_box_pack_end(bx3, bt[bt_num]);
1560 elm_box_pack_end(bx, bx3);
1561 evas_object_show(bx3);
1563 for (i = 0; i < 500; i++)
1567 gli = git = elm_genlist_item_append(gl, &itc_group,
1568 (void *)(long)i/* item data */,
1570 ELM_GENLIST_ITEM_GROUP,
1572 (void *)(long)(i * 10)/* func data */);
1573 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1577 gli = elm_genlist_item_append(gl, itc1,
1578 (void *)(long)i/* item data */,
1580 ELM_GENLIST_ITEM_NONE,
1582 (void *)(long)(i * 10)/* func data */);
1587 evas_object_smart_callback_add(bt[0], "clicked", _bt_show_cb, gli);
1588 evas_object_smart_callback_add(bt[4], "clicked", _bt_bring_cb, gli);
1591 evas_object_smart_callback_add(bt[1], "clicked", _bt_show_cb, gli);
1594 evas_object_smart_callback_add(bt[5], "clicked", _bt_bring_cb, gli);
1597 evas_object_smart_callback_add(bt[2], "clicked", _bt_show_cb, gli);
1600 evas_object_smart_callback_add(bt[6], "clicked", _bt_bring_cb, gli);
1603 evas_object_smart_callback_add(bt[7], "clicked", _bt_bring_cb, gli);
1606 evas_object_smart_callback_add(bt[3], "clicked", _bt_show_cb, gli);
1610 elm_genlist_item_class_free(itc1);
1612 evas_object_resize(win, 480, 800);
1613 evas_object_show(win);
1619 gl9_exp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1621 Elm_Object_Item *glit = event_info;
1622 Evas_Object *gl = elm_object_item_widget_get(glit);
1623 int val = (int)(long) elm_object_item_data_get(glit);
1625 elm_genlist_item_append(gl, itc1,
1626 (void *)(long) (val + 1)/* item data */,
1628 ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1629 NULL/* func data */);
1630 elm_genlist_item_append(gl, itc1,
1631 (void *)(long) (val + 2)/* item data */,
1633 ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1634 NULL/* func data */);
1635 elm_genlist_item_append(gl, itc1,
1636 (void *)(long) (val + 3)/* item data */,
1638 ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
1639 NULL/* func data */);
1643 gl9_con(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1645 Elm_Object_Item *glit = event_info;
1646 elm_genlist_item_subitems_clear(glit);
1650 gl9_exp_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1652 Elm_Object_Item *glit = event_info;
1653 elm_genlist_item_expanded_set(glit, EINA_TRUE);
1657 gl9_con_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1659 Elm_Object_Item *glit = event_info;
1660 elm_genlist_item_expanded_set(glit, EINA_FALSE);
1664 test_genlist9(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1666 Evas_Object *win, *gl, *bx;
1667 Elm_Object_Item *git;
1669 win = elm_win_util_standard_add("genlist-group-tree", "Genlist Group Tree");
1670 elm_win_autodel_set(win, EINA_TRUE);
1672 bx = elm_box_add(win);
1673 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1674 elm_win_resize_object_add(win, bx);
1675 evas_object_show(bx);
1677 gl = elm_genlist_add(win);
1678 evas_object_smart_callback_add(gl, "selected", _gl_selected, NULL);
1679 evas_object_smart_callback_add(gl, "clicked,double", _gl_double_clicked, NULL);
1680 evas_object_smart_callback_add(gl, "longpressed", _gl_longpress, NULL);
1681 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1682 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1683 elm_box_pack_end(bx, gl);
1684 evas_object_show(gl);
1686 itc1 = elm_genlist_item_class_new();
1687 itc1->item_style = "default";
1688 itc1->func.text_get = gl_text_get;
1689 itc1->func.content_get = gl_content_get;
1690 itc1->func.state_get = gl_state_get;
1691 itc1->func.del = NULL;
1693 itc_group.item_style = "group_index";
1694 itc_group.func.text_get = gl8_text_get;
1695 itc_group.func.content_get = NULL;
1696 itc_group.func.state_get = NULL;
1697 itc_group.func.del = NULL;
1699 git = elm_genlist_item_append(gl, &itc_group,
1700 (void *)0/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_GROUP, gl4_sel/* func */,
1701 NULL/* func data */);
1702 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1704 elm_genlist_item_append(gl, itc1,
1705 (void *)1/* item data */, git/* parent */, ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
1706 NULL/* func data */);
1707 elm_genlist_item_append(gl, itc1,
1708 (void *)2/* item data */, git/* parent */, ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1709 NULL/* func data */);
1710 elm_genlist_item_append(gl, itc1,
1711 (void *)3/* item data */, git/* parent */, ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
1712 NULL/* func data */);
1713 git = elm_genlist_item_append(gl, &itc_group,
1714 (void *)4/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_GROUP, gl4_sel/* func */,
1715 NULL/* func data */);
1716 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1718 elm_genlist_item_append(gl, itc1,
1719 (void *)5/* item data */, git/* parent */, ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
1720 NULL/* func data */);
1721 elm_genlist_item_append(gl, itc1,
1722 (void *)6/* item data */, git/* parent */, ELM_GENLIST_ITEM_NONE, gl4_sel/* func */,
1723 NULL/* func data */);
1724 elm_genlist_item_append(gl, itc1,
1725 (void *)7/* item data */, git/* parent */, ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
1726 NULL/* func data */);
1727 elm_genlist_item_class_free(itc1);
1729 evas_object_smart_callback_add(gl, "expand,request", gl9_exp_req, gl);
1730 evas_object_smart_callback_add(gl, "contract,request", gl9_con_req, gl);
1731 evas_object_smart_callback_add(gl, "expanded", gl9_exp, gl);
1732 evas_object_smart_callback_add(gl, "contracted", gl9_con, gl);
1734 evas_object_resize(win, 480, 800);
1735 evas_object_show(win);
1740 static Elm_Genlist_Item_Class itc10;
1741 static char *mode_type[] = { "slide", "rotate" };
1743 char *gl10_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part)
1746 if (!strcmp(part, "elm.text.mode"))
1747 snprintf(buf, sizeof(buf), "Mode # %i", (int)(long)data);
1749 snprintf(buf, sizeof(buf), "Item # %i", (int)(long)data);
1753 Evas_Object *gl10_content_get(void *data __UNUSED__, Evas_Object *obj, const char *part)
1756 Evas_Object *ic = elm_icon_add(obj);
1757 if (!strcmp(part, "elm.swallow.end"))
1758 snprintf(buf, sizeof(buf), "%s/images/bubble.png", elm_app_data_dir_get());
1760 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
1761 elm_icon_file_set(ic, buf, NULL);
1762 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1767 _gl_sel10(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1770 int v = elm_radio_value_get(data);
1772 elm_genlist_item_decorate_mode_set(event_info, mode_type[v], EINA_TRUE);
1776 _my_gl_mode_right(void *data, Evas_Object *obj __UNUSED__, void *event_info)
1779 int v = elm_radio_value_get(data);
1781 elm_genlist_item_decorate_mode_set(event_info, mode_type[v], EINA_TRUE);
1785 _my_gl_mode_left(void *data, Evas_Object *obj __UNUSED__, void *event_info)
1788 int v = elm_radio_value_get(data);
1790 elm_genlist_item_decorate_mode_set(event_info, mode_type[v], EINA_FALSE);
1794 _my_gl_mode_cancel(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1796 fprintf(stderr, "drag\n");
1798 int v = elm_radio_value_get(data);
1799 Elm_Object_Item *glit = (Elm_Object_Item *) elm_genlist_decorated_item_get(obj);
1800 if (glit) elm_genlist_item_decorate_mode_set(glit, mode_type[v], EINA_FALSE);
1804 test_genlist10(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1806 Evas_Object *win, *fr, *lb, *bx, *bx2, *bx3, *rd, *rdg, *gl;
1809 win = elm_win_util_standard_add("genlist10", "Genlist Mode");
1810 elm_win_autodel_set(win, EINA_TRUE);
1812 bx = elm_box_add(win);
1813 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1814 elm_win_resize_object_add(win, bx);
1815 evas_object_show(bx);
1817 fr = elm_frame_add(win);
1818 elm_object_text_set(fr, "Mode Type");
1819 elm_box_pack_end(bx, fr);
1820 evas_object_show(fr);
1822 bx2 = elm_box_add(win);
1823 elm_object_content_set(fr, bx2);
1824 evas_object_show(bx2);
1826 lb = elm_label_add(win);
1827 elm_object_text_set(lb,
1828 "Sweep genlist items to the right.<br/>"
1829 "Test this by changing Mode Type to Slide or Rotate.");
1830 elm_box_pack_end(bx2, lb);
1831 evas_object_show(lb);
1833 bx3 = elm_box_add(win);
1834 elm_box_horizontal_set(bx3, EINA_TRUE);
1835 elm_box_pack_end(bx2, bx3);
1836 evas_object_show(bx3);
1838 rd = elm_radio_add(win);
1839 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1840 elm_radio_state_value_set(rd, 0);
1841 elm_object_text_set(rd, "Slide ");
1842 evas_object_show(rd);
1843 elm_box_pack_end(bx3, rd);
1846 rd = elm_radio_add(win);
1847 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1848 elm_radio_state_value_set(rd, 1);
1849 elm_object_text_set(rd, "Rotate");
1850 elm_radio_group_add(rd, rdg);
1851 evas_object_show(rd);
1852 elm_box_pack_end(bx3, rd);
1854 gl = elm_genlist_add(win);
1855 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1856 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1857 evas_object_smart_callback_add(gl, "drag,start,right", _my_gl_mode_right, rdg);
1858 evas_object_smart_callback_add(gl, "drag,start,left", _my_gl_mode_left, rdg);
1859 evas_object_smart_callback_add(gl, "drag,start,up", _my_gl_mode_cancel, rdg);
1860 evas_object_smart_callback_add(gl, "drag,start,down", _my_gl_mode_cancel, rdg);
1861 evas_object_show(gl);
1863 itc10.item_style = "default";
1864 itc10.decorate_item_style = "mode";
1865 itc10.func.text_get = gl10_text_get;
1866 itc10.func.content_get = gl10_content_get;
1867 itc10.func.state_get = gl_state_get;
1868 itc10.func.del = NULL;
1870 for (i = 0; i < 50; i++)
1871 elm_genlist_item_append(gl,
1873 (void *)(long)(1000 + i)/* item data */,
1875 ELM_GENLIST_ITEM_NONE/* flags */,
1876 _gl_sel10/* func */,
1877 rdg/* func data */);
1879 elm_box_pack_end(bx, gl);
1881 evas_object_resize(win, 520, 520);
1882 evas_object_show(win);
1888 _reorder_tg_changed_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1890 elm_genlist_reorder_mode_set(data, elm_check_state_get(obj));
1894 * gl_moved is called after an item was reordered.
1895 * This is only called when reorder mode is enabled.
1897 * @param data : the genlist object passed as data.
1898 * @param obj : the genlist object.
1899 * @param item : the moved item.
1901 * If the move_after is true,
1902 * the item(*item) had been moved after the given relative item(*rel_item) in list.
1903 * If the move_after is false,
1904 * the item(*item) had been moved before the given relative item(*rel_item) in list.
1907 static void gl_moved(Evas_Object *data __UNUSED__, Evas_Object *obj __UNUSED__, Elm_Object_Item *item __UNUSED__)
1909 // if needed, add application logic.
1913 test_genlist11(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1915 Evas_Object *win, *fr, *lb, *bx, *tg, *gl;
1918 win = elm_win_util_standard_add("genlist-reorder-mode", "Genlist Reorder Mode");
1919 elm_win_autodel_set(win, EINA_TRUE);
1921 bx = elm_box_add(win);
1922 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1923 elm_win_resize_object_add(win, bx);
1924 evas_object_show(bx);
1926 fr = elm_frame_add(win);
1928 elm_object_text_set(fr, "Reorder Mode");
1929 elm_box_pack_end(bx, fr);
1930 evas_object_show(fr);
1932 lb = elm_label_add(win);
1933 elm_object_text_set(lb,
1934 "Enable reorder mode if you want to move item.<br/>"
1935 "Then long press and drag item.");
1936 elm_object_content_set(fr, lb);
1937 evas_object_show(lb);
1939 gl = elm_genlist_add(win);
1940 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1941 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1942 evas_object_show(gl);
1944 tg = elm_check_add(win);
1945 elm_object_style_set(tg, "toggle");
1946 elm_object_text_set(tg, "Reorder Mode:");
1947 elm_check_state_set(tg, elm_config_mirrored_get());
1948 evas_object_smart_callback_add(tg, "changed", _reorder_tg_changed_cb, gl);
1949 elm_box_pack_end(bx, tg);
1950 evas_object_show(tg);
1952 itc1 = elm_genlist_item_class_new();
1953 itc1->item_style = "default";
1954 itc1->func.text_get = gl_text_get;
1955 itc1->func.content_get = gl_content_get;
1956 itc1->func.state_get = gl_state_get;
1957 itc1->func.del = NULL;
1958 evas_object_smart_callback_add(gl, "moved", (Evas_Smart_Cb)gl_moved, gl);
1960 for (i = 0; i < 50; i++)
1961 elm_genlist_item_append(gl,
1963 (void *)(long)(1 + i)/* item data */,
1965 ELM_GENLIST_ITEM_NONE/* flags */,
1967 NULL/* func data */);
1969 elm_genlist_item_class_free(itc1);
1971 elm_box_pack_end(bx, gl);
1973 evas_object_resize(win, 400, 500);
1974 evas_object_show(win);
1977 char *gl12_text_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
1979 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).");
1983 test_genlist12(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1985 Evas_Object *win, *bx, *gl;
1988 win = elm_win_util_standard_add("genlist-textblock", "Genlist Textblock");
1989 elm_win_autodel_set(win, EINA_TRUE);
1991 bx = elm_box_add(win);
1992 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1993 elm_win_resize_object_add(win, bx);
1994 evas_object_show(bx);
1996 gl = elm_genlist_add(win);
1997 elm_genlist_mode_set(gl, ELM_LIST_COMPRESS);
1998 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1999 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
2000 elm_box_pack_end(bx, gl);
2001 evas_object_show(gl);
2003 itc1->item_style = "message";
2004 itc1->func.text_get = gl12_text_get;
2005 itc1->func.content_get = gl_content_get;
2006 itc1->func.state_get = gl_state_get;
2007 itc1->func.del = NULL;
2009 for (i = 0; i < 1000; i++)
2011 elm_genlist_item_append(gl, itc1,
2012 (void *)(long)i/* item data */,
2014 ELM_GENLIST_ITEM_NONE,
2016 (void *)(long)(i * 10)/* func data */);
2018 elm_genlist_item_class_free(itc1);
2020 evas_object_resize(win, 400, 500);
2021 evas_object_show(win);
2025 gl13_cmp(const void *pa, const void *pb)
2027 const Elm_Object_Item *ia = pa, *ib = pb;
2028 int a = (int)(long) elm_object_item_data_get(ia);
2029 int b = (int)(long) elm_object_item_data_get(ib);
2034 test_genlist13(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2036 Elm_Object_Item *pi[6];
2037 Evas_Object *win, *bx, *gl; int i, base, idx[3] = {1, 10, 15};
2039 win = elm_win_util_standard_add("genlist-tree-insert-sorted", "Genlist Tree, Insert Sorted");
2040 elm_win_autodel_set(win, EINA_TRUE);
2042 bx = elm_box_add(win);
2043 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2044 elm_win_resize_object_add(win, bx);
2045 evas_object_show(bx);
2047 gl = elm_genlist_add(win);
2048 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
2049 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2050 evas_object_show(gl);
2052 itc4.item_style = "default";
2053 itc4.func.text_get = gl4_text_get;
2054 itc4.func.content_get = NULL;
2055 itc4.func.state_get = NULL;
2056 itc4.func.del = NULL;
2058 /* mixed order to test insert sorted */
2060 for (i = 0; i < 3; i++)
2062 pi[i] = elm_genlist_item_sorted_insert
2063 (gl, &itc4, (void *)(long)idx[i]/* item data */, NULL/* parent */,
2064 ELM_GENLIST_ITEM_TREE, gl13_cmp/* cmp */,
2065 NULL/* func */, NULL/* func data */);
2068 for (i = 0, base = 100; i < 3; i++, base += 100)
2071 for (j = 0; j < 3; j++)
2073 elm_genlist_item_sorted_insert
2074 (gl, &itc4, (void *)(long)(idx[j] + base)/* item data */,
2075 pi[i]/* parent */, ELM_GENLIST_ITEM_NONE,
2076 gl13_cmp/* cmp */, NULL/* func */, NULL/* func data */);
2080 for (i = 0; i < 3; i++)
2082 pi[i + 3] = elm_genlist_item_sorted_insert
2083 (gl, &itc4, (void *)(long)(idx[i] * 2)/* item data */, NULL/* parent */,
2084 ELM_GENLIST_ITEM_TREE, gl13_cmp/* cmp */, NULL/* func */,
2085 NULL/* func data */);
2089 for (i = 0, base = 10000; i < 3; i++, base += 10000)
2092 for (j = 0; j < 3; j++)
2094 elm_genlist_item_sorted_insert
2095 (gl, &itc4, (void *)(long)(idx[j] + base)/* item data */,
2096 pi[i + 3]/* parent */, ELM_GENLIST_ITEM_NONE,
2097 gl13_cmp/* cmp */, NULL/* func */, NULL/* func data */);
2101 elm_box_pack_end(bx, gl);
2102 evas_object_show(bx);
2104 evas_object_resize(win, 320, 320);
2105 evas_object_show(win);
2109 my_gl_insert_before_rel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2111 Evas_Object *gl = data;
2112 static int i = 1000;
2113 Elm_Object_Item *gli_selected;
2115 itc1->item_style = "default";
2116 itc1->func.text_get = gl_text_get;
2117 itc1->func.content_get = NULL;
2118 itc1->func.state_get = NULL;
2119 itc1->func.del = NULL;
2121 gli_selected = elm_genlist_selected_item_get(gl);
2124 printf("no item selected\n");
2128 elm_genlist_item_insert_before(gl, itc1,
2129 (void *)(long)i/* item data */,
2130 elm_genlist_item_parent_get(gli_selected),
2131 gli_selected/* item before */,
2132 ELM_GENLIST_ITEM_NONE,
2133 NULL/* func */, NULL/* func data */);
2138 my_gl_insert_after_rel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2140 Evas_Object *gl = data;
2142 Elm_Object_Item *gli_selected;
2144 itc1->item_style = "default";
2145 itc1->func.text_get = gl_text_get;
2146 itc1->func.content_get = NULL;
2147 itc1->func.state_get = NULL;
2148 itc1->func.del = NULL;
2150 gli_selected = elm_genlist_selected_item_get(gl);
2153 printf("no item selected\n");
2157 elm_genlist_item_insert_after(gl, itc1,
2158 (void *)(long)i/* item data */,
2159 elm_genlist_item_parent_get(gli_selected),
2160 gli_selected/* item after */,
2161 ELM_GENLIST_ITEM_NONE,
2162 NULL/* func */, NULL/* func data */);
2167 test_genlist14(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2169 Elm_Object_Item *pi[6];
2170 Evas_Object *win, *bx, *bx2, *bt, *gl;
2172 /* index: 0, 1, 2, 3, 4, 5
2173 * items: 1, 15, 11, 2, 33, 21
2174 * final: 1, 2, 11, 15, 21, 33
2176 const int idx[6] = {1, 15, 11, 2, 33, 21};
2177 const int relative[6] = {
2178 0, /* item '1' - not used */
2179 0, /* item '15' - insert after pi[0], item '1' */
2180 -1, /* item '11' - insert before pi[1], item '15' */
2181 -2, /* item '2' - insert before pi[2], item '11' */
2182 1, /* item '33' - insert after pi[1], item '15' */
2183 -4 /* item '21' - insert before pi[4], item '33' */
2186 win = elm_win_util_standard_add("genlist-tree-insert-relative", "Genlist Tree, Insert Relative");
2187 elm_win_autodel_set(win, EINA_TRUE);
2189 bx = elm_box_add(win);
2190 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2191 elm_win_resize_object_add(win, bx);
2192 evas_object_show(bx);
2194 gl = elm_genlist_add(win);
2195 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
2196 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2197 evas_object_show(gl);
2199 itc1 = elm_genlist_item_class_new();
2201 itc4.item_style = "default";
2202 itc4.func.text_get = gl4_text_get;
2203 itc4.func.content_get = NULL;
2204 itc4.func.state_get = NULL;
2205 itc4.func.del = NULL;
2207 /* mixed order to test insert sorted */
2209 // BUG1: should be able to insert before=NULL, prepend
2210 // BUG2: should be able to insert after=NULL, append
2212 pi[0] = elm_genlist_item_append
2213 (gl, &itc4, (void *)(long)idx[0]/* item data */,
2215 ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2217 for (i = 1; i < 3; i++)
2219 if (relative[i] < 0)
2220 pi[i] = elm_genlist_item_insert_before
2221 (gl, &itc4, (void *)(long)idx[i]/* item data */,
2222 NULL/* parent */, pi[-relative[i]],
2223 ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2225 pi[i] = elm_genlist_item_insert_after
2226 (gl, &itc4, (void *)(long)idx[i]/* item data */,
2227 NULL/* parent */, pi[relative[i]],
2228 ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2231 for (i = 0; i < 3; i++)
2233 Elm_Object_Item *sub_glit[6];
2236 base = 1000 * (int)(long) elm_object_item_data_get(pi[i]);
2238 sub_glit[0] = elm_genlist_item_append
2239 (gl, &itc4, (void *)(long) (idx[0] + base)/* item data */, pi[i]/* parent */,
2240 ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2242 for (j = 1; j < 6; j++) {
2243 if (relative[j] < 0)
2244 sub_glit[j] = elm_genlist_item_insert_before
2245 (gl, &itc4, (void *)(long) (idx[j] + base)/* item data */,
2246 pi[i]/* parent */, sub_glit[-relative[j]],
2247 ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2249 sub_glit[j] = elm_genlist_item_insert_after
2250 (gl, &itc4, (void *)(long) (idx[j] + base)/* item data */,
2251 pi[i]/* parent */, sub_glit[relative[j]],
2252 ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2256 for (i = 3; i < 6; i++)
2258 if (relative[i] < 0)
2259 pi[i] = elm_genlist_item_insert_before
2260 (gl, &itc4, (void *)(long) idx[i]/* item data */,
2261 NULL/* parent */, pi[-relative[i]],
2262 ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2264 pi[i] = elm_genlist_item_insert_after
2265 (gl, &itc4, (void *)(long) idx[i]/* item data */,
2266 NULL/* parent */, pi[relative[i]],
2267 ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2270 for (i = 3; i < 6; i++)
2272 Elm_Object_Item *sub_glit[6];
2275 base = 1000 * (int)(long) elm_object_item_data_get(pi[i]);
2277 sub_glit[0] = elm_genlist_item_append
2278 (gl, &itc4, (void *)(long) (idx[0] + base)/* item data */, pi[i]/* parent */,
2279 ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2281 for (j = 1; j < 6; j++) {
2282 if (relative[j] < 0)
2283 sub_glit[j] = elm_genlist_item_insert_before
2284 (gl, &itc4, (void *)(long) (idx[j] + base)/* item data */,
2285 pi[i]/* parent */, sub_glit[-relative[j]],
2286 ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2288 sub_glit[j] = elm_genlist_item_insert_after
2289 (gl, &itc4, (void *)(long) (idx[j] + base)/* item data */,
2290 pi[i]/* parent */, sub_glit[relative[j]],
2291 ELM_GENLIST_ITEM_TREE, NULL/* func */, NULL/* func data */);
2295 elm_box_pack_end(bx, gl);
2296 evas_object_show(bx);
2298 bx2 = elm_box_add(win);
2299 elm_box_horizontal_set(bx2, EINA_TRUE);
2300 elm_box_homogeneous_set(bx2, EINA_TRUE);
2301 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
2302 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
2304 bt = elm_button_add(win);
2305 elm_object_text_set(bt, "+ before");
2306 evas_object_smart_callback_add(bt, "clicked", my_gl_insert_before_rel, gl);
2307 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
2308 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
2309 elm_box_pack_end(bx2, bt);
2310 evas_object_show(bt);
2312 bt = elm_button_add(win);
2313 elm_object_text_set(bt, "+ after");
2314 evas_object_smart_callback_add(bt, "clicked", my_gl_insert_after_rel, gl);
2315 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
2316 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
2317 elm_box_pack_end(bx2, bt);
2318 evas_object_show(bt);
2320 elm_box_pack_end(bx, bx2);
2321 evas_object_show(bx2);
2323 /* item_class_ref is needed for itc1. some items can be added in callbacks */
2324 elm_genlist_item_class_ref(itc1);
2325 elm_genlist_item_class_free(itc1);
2327 evas_object_resize(win, 320, 320);
2328 evas_object_show(win);
2331 static void _edit_icon_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2333 Elm_Object_Item *item = (Elm_Object_Item *)data;
2334 elm_object_item_del(item);
2337 char *gl15_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
2339 const Testitem *tit = data;
2341 snprintf(buf, sizeof(buf), "Item #%i", tit->mode);
2345 Evas_Object *gl15_content_get(void *data, Evas_Object *obj, const char *part)
2347 Testitem *tit = data;
2350 // "edit_default" EDC layout is like below. each part is swallow part.
2351 // the existing item is swllowed to elm.swallow.edit.content part.
2352 // ----------------------------------------------------------------
2353 // | elm.edit.icon.1 | elm.swallow.edit.content | elm.edit.icon,2 |
2354 // ----------------------------------------------------------------
2356 if (!strcmp(part, "elm.swallow.end"))
2358 Evas_Object *ic = elm_icon_add(obj);
2359 snprintf(buf, sizeof(buf), "%s/images/bubble.png", PACKAGE_DATA_DIR);
2360 elm_icon_file_set(ic, buf, NULL);
2361 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
2364 else if (!strcmp(part, "elm.edit.icon.1"))
2367 ck = elm_check_add(obj);
2368 elm_check_state_pointer_set(ck, &tit->checked);
2369 evas_object_propagate_events_set(ck, EINA_FALSE);
2370 evas_object_show(ck);
2373 else if (!strcmp(part, "elm.edit.icon.2"))
2375 Evas_Object *icn = elm_icon_add(obj);
2376 snprintf(buf, sizeof(buf), "%s/images/icon_06.png", PACKAGE_DATA_DIR);
2377 elm_icon_file_set(icn, buf, NULL);
2378 evas_object_propagate_events_set(icn, EINA_FALSE);
2379 evas_object_size_hint_aspect_set(icn, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
2380 evas_object_smart_callback_add(icn, "clicked", _edit_icon_clicked_cb, (void *)tit->item);
2387 gl15_sel(void *data, Evas_Object *obj, void *event_info __UNUSED__)
2389 Testitem *tit = data;
2390 if (elm_genlist_decorate_mode_get(obj))
2392 if (!tit->checked) tit->checked = EINA_TRUE;
2393 else tit->checked = EINA_FALSE;
2395 elm_genlist_item_update(tit->item);
2399 gl15_edit_mode(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2401 elm_genlist_decorate_mode_set(data, EINA_TRUE);
2402 elm_genlist_select_mode_set(data, ELM_OBJECT_SELECT_MODE_ALWAYS);
2406 gl15_normal_mode(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2408 elm_genlist_decorate_mode_set(data, EINA_FALSE);
2409 elm_genlist_select_mode_set(data, ELM_OBJECT_SELECT_MODE_DEFAULT);
2412 void gl15_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
2414 printf("item deleted.\n");
2418 test_genlist15(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2420 Evas_Object *win, *bx, *bx2, *bt, *gl;
2422 static Testitem tit[100];
2424 win = elm_win_util_standard_add("genlist-edit-mode", "Genlist Edit Mode");
2425 elm_win_autodel_set(win, EINA_TRUE);
2427 bx = elm_box_add(win);
2428 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2429 elm_win_resize_object_add(win, bx);
2430 evas_object_show(bx);
2432 gl = elm_genlist_add(win);
2433 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
2434 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2435 evas_object_show(gl);
2437 itc15 = elm_genlist_item_class_new();
2438 itc15->item_style = "default";
2439 itc15->func.text_get = gl15_text_get;
2440 itc15->func.content_get = gl15_content_get;
2441 itc15->func.state_get = gl_state_get;
2442 itc15->func.del = gl15_del;
2443 itc15->decorate_all_item_style = "edit";
2445 for (i = 0; i < 100; i++)
2448 tit[i].item = elm_genlist_item_append(gl, itc15,
2449 &(tit[i])/* item data */,
2451 ELM_GENLIST_ITEM_NONE/* flags */,
2453 (void *)(long)&(tit[i])/* func data */);
2455 elm_genlist_item_class_free(itc15);
2456 elm_box_pack_end(bx, gl);
2457 evas_object_show(bx);
2459 bx2 = elm_box_add(win);
2460 elm_box_horizontal_set(bx2, EINA_TRUE);
2461 elm_box_homogeneous_set(bx2, EINA_TRUE);
2462 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
2463 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
2465 bt = elm_button_add(win);
2466 elm_object_text_set(bt, "Edit mode");
2467 evas_object_smart_callback_add(bt, "clicked", gl15_edit_mode, gl);
2468 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
2469 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
2470 elm_box_pack_end(bx2, bt);
2471 evas_object_show(bt);
2473 bt = elm_button_add(win);
2474 elm_object_text_set(bt, "Normal mode");
2475 evas_object_smart_callback_add(bt, "clicked", gl15_normal_mode,gl);
2476 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
2477 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
2478 elm_box_pack_end(bx2, bt);
2479 evas_object_show(bt);
2481 elm_box_pack_end(bx, bx2);
2482 evas_object_show(bx2);
2484 evas_object_resize(win, 520, 520);
2485 evas_object_show(win);
2488 static void _flip_icon_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2490 const Testitem *tit = data;
2492 if (elm_genlist_item_flip_get(tit->item))
2493 elm_genlist_item_flip_set(tit->item, EINA_FALSE);
2495 elm_genlist_item_flip_set(tit->item, EINA_TRUE);
2498 char *gl16_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
2500 const Testitem *tit = data;
2502 snprintf(buf, sizeof(buf), "Item #%i", tit->mode);
2506 Evas_Object *gl16_content_get(void *data, Evas_Object *obj, const char *part)
2508 Testitem *tit = data;
2511 if (!strcmp(part, "elm.text.flip"))
2513 Evas_Object *btn = elm_button_add(obj);
2514 elm_object_text_set(btn, "flipped content placement");
2515 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
2516 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0.0);
2517 evas_object_smart_callback_add(btn, "clicked", _flip_icon_clicked_cb, (void *)tit);
2518 evas_object_show(btn);
2521 else if (!strcmp(part, "elm.edit.icon.1"))
2523 Evas_Object *icn = elm_icon_add(obj);
2524 snprintf(buf, sizeof(buf), "%s/images/icon_04.png", PACKAGE_DATA_DIR);
2525 elm_icon_file_set(icn, buf, NULL);
2526 evas_object_propagate_events_set(icn, EINA_FALSE);
2527 evas_object_size_hint_aspect_set(icn, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
2530 else if (!strcmp(part, "elm.edit.icon.2"))
2532 Evas_Object *icn = elm_icon_add(obj);
2533 snprintf(buf, sizeof(buf), "%s/images/icon_09.png", PACKAGE_DATA_DIR);
2534 elm_icon_file_set(icn, buf, NULL);
2535 evas_object_propagate_events_set(icn, EINA_FALSE);
2536 evas_object_size_hint_aspect_set(icn, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
2537 evas_object_smart_callback_add(icn, "clicked", _flip_icon_clicked_cb, (void *)tit);
2544 test_genlist16(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2546 Evas_Object *win, *bx, *gl;
2548 static Testitem tit[100];
2550 win = elm_win_util_standard_add("genlist-flip-mode", "Genlist Flip Mode");
2551 elm_win_autodel_set(win, EINA_TRUE);
2553 bx = elm_box_add(win);
2554 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2555 elm_win_resize_object_add(win, bx);
2556 evas_object_show(bx);
2558 gl = elm_genlist_add(win);
2559 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
2560 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2561 evas_object_show(gl);
2563 /* note: flip mode can be used with/without edit mode */
2564 elm_genlist_decorate_mode_set(gl, EINA_TRUE);
2565 elm_genlist_select_mode_set(gl, ELM_OBJECT_SELECT_MODE_ALWAYS);
2567 itc15 = elm_genlist_item_class_new();
2568 itc15->item_style = "default";
2569 itc15->func.text_get = gl16_text_get;
2570 itc15->func.content_get = gl16_content_get;
2571 itc15->func.state_get = gl_state_get;
2572 itc15->func.del = NULL;
2573 itc15->decorate_all_item_style = "edit";
2575 for (i = 0; i < 100; i++)
2578 tit[i].item = elm_genlist_item_append(gl, itc15,
2579 &(tit[i])/* item data */,
2581 ELM_GENLIST_ITEM_NONE/* flags */,
2583 (void *)(long)&(tit[i])/* func data */);
2585 elm_genlist_item_class_free(itc15);
2586 elm_box_pack_end(bx, gl);
2587 evas_object_show(bx);
2589 evas_object_resize(win, 520, 520);
2590 evas_object_show(win);
2593 static Elm_Genlist_Item_Class itc17;
2596 gl17_sel(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2598 Elm_Object_Item *glit = event_info;
2599 int depth = elm_genlist_item_expanded_depth_get(glit);
2600 printf("expanded depth for selected item is %d\n", depth);
2604 gl17_exp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2606 Elm_Object_Item *glit = event_info;
2607 Evas_Object *gl = elm_object_item_widget_get(glit);
2608 int val = (int)(long) elm_object_item_data_get(glit);
2610 elm_genlist_item_append(gl, &itc17,
2611 (void *)(long) (val + 1)/* item data */,
2613 ELM_GENLIST_ITEM_TREE, gl17_sel/* func */,
2614 NULL/* func data */);
2615 elm_genlist_item_append(gl, &itc17,
2616 (void *)(long) (val + 2)/* item data */,
2618 ELM_GENLIST_ITEM_TREE, gl17_sel/* func */,
2619 NULL/* func data */);
2620 elm_genlist_item_append(gl, &itc17,
2621 (void *)(long) (val + 3)/* item data */,
2623 ELM_GENLIST_ITEM_TREE, gl17_sel/* func */,
2624 NULL/* func data */);
2625 elm_genlist_item_append(gl, &itc17,
2626 (void *)(long) (val + 4)/* item data */,
2628 ELM_GENLIST_ITEM_TREE, gl17_sel/* func */,
2629 NULL/* func data */);
2630 elm_genlist_item_append(gl, &itc17,
2631 (void *)(long) (val + 5)/* item data */,
2633 ELM_GENLIST_ITEM_TREE, gl17_sel/* func */,
2634 NULL/* func data */);
2635 elm_genlist_item_append(gl, &itc17,
2636 (void *)(long) (val + 6)/* item data */,
2638 ELM_GENLIST_ITEM_TREE, gl17_sel/* func */,
2639 NULL/* func data */);
2643 gl17_con(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2645 Elm_Object_Item *glit = event_info;
2646 elm_genlist_item_subitems_clear(glit);
2650 gl17_exp_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2652 Elm_Object_Item *glit = event_info;
2653 elm_genlist_item_expanded_set(glit, EINA_TRUE);
2657 gl17_con_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
2659 Elm_Object_Item *glit = event_info;
2660 elm_genlist_item_expanded_set(glit, EINA_FALSE);
2663 char *gl17_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
2666 snprintf(buf, sizeof(buf), "Item mode %i", (int)(long)data);
2670 Evas_Object *gl17_content_get(void *data __UNUSED__, Evas_Object *obj, const char *part)
2673 if (!strcmp(part, "elm.swallow.icon"))
2675 Evas_Object *ic = elm_icon_add(obj);
2676 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
2677 elm_icon_file_set(ic, buf, NULL);
2678 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
2679 evas_object_show(ic);
2682 else if (!strcmp(part, "elm.swallow.end"))
2685 ck = elm_check_add(obj);
2686 evas_object_propagate_events_set(ck, EINA_FALSE);
2687 evas_object_show(ck);
2693 Eina_Bool gl17_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
2698 void gl17_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
2700 printf("item deleted.\n");
2704 gl17_enabled_set(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2706 elm_genlist_tree_effect_enabled_set(data, EINA_TRUE);
2710 gl17_disabled_set(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2712 elm_genlist_tree_effect_enabled_set(data, EINA_FALSE);
2716 test_genlist17(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2718 Evas_Object *win, *gl, *bx, *bx2, *bt;
2720 win = elm_win_util_standard_add("genlist17", "Genlist Tree Effect");
2721 elm_win_autodel_set(win, EINA_TRUE);
2723 bx = elm_box_add(win);
2724 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2725 elm_win_resize_object_add(win, bx);
2726 evas_object_show(bx);
2728 gl = elm_genlist_add(win);
2729 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
2730 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2731 evas_object_show(gl);
2733 elm_genlist_tree_effect_enabled_set(gl,EINA_TRUE);
2735 itc17.item_style = "tree_effect";
2736 itc17.func.text_get = gl17_text_get;
2737 itc17.func.content_get = gl17_content_get;
2738 itc17.func.state_get = gl17_state_get;
2739 itc17.func.del = gl17_del;
2741 elm_genlist_item_append(gl, &itc17,
2742 (void *)1/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_TREE, gl17_sel/* func */,
2743 NULL/* func data */);
2744 elm_genlist_item_append(gl, &itc17,
2745 (void *)2/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_TREE, gl17_sel/* func */,
2746 NULL/* func data */);
2747 elm_genlist_item_append(gl, &itc17,
2748 (void *)3/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_TREE, gl17_sel/* func */,
2749 NULL/* func data */);
2751 evas_object_smart_callback_add(gl, "expand,request", gl17_exp_req, gl);
2752 evas_object_smart_callback_add(gl, "contract,request", gl17_con_req, gl);
2753 evas_object_smart_callback_add(gl, "expanded", gl17_exp, gl);
2754 evas_object_smart_callback_add(gl, "contracted", gl17_con, gl);
2756 elm_box_pack_end(bx, gl);
2757 evas_object_show(bx);
2759 bx2 = elm_box_add(win);
2760 elm_box_horizontal_set(bx2, EINA_TRUE);
2761 elm_box_homogeneous_set(bx2, EINA_TRUE);
2762 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
2763 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
2765 bt = elm_button_add(win);
2766 elm_object_text_set(bt, "Enable");
2767 evas_object_smart_callback_add(bt, "clicked", gl17_enabled_set, gl);
2768 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
2769 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
2770 elm_box_pack_end(bx2, bt);
2771 evas_object_show(bt);
2773 bt = elm_button_add(win);
2774 elm_object_text_set(bt, "Disable");
2775 evas_object_smart_callback_add(bt, "clicked", gl17_disabled_set, gl);
2776 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
2777 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
2778 elm_box_pack_end(bx2, bt);
2779 evas_object_show(bt);
2781 elm_box_pack_end(bx, bx2);
2782 evas_object_show(bx2);
2784 evas_object_resize(win, 320, 320);
2785 evas_object_show(win);