1 #include <Elementary_Cursor.h>
4 # include "elementary_config.h"
6 #include <Elementary.h>
7 #ifndef ELM_LIB_QUICKLAUNCH
9 static Elm_Gengrid_Item_Class *gic;
10 static Elm_Gengrid_Item_Class ggic;
12 Evas_Object *grid_content_get(void *data, Evas_Object *obj, const char *part);
13 char *grid_text_get(void *data, Evas_Object *obj __UNUSED__,
14 const char *part __UNUSED__);
15 Eina_Bool grid_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
16 const char *part __UNUSED__);
17 void grid_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__);
19 typedef struct _Testitem
21 Elm_Object_Item *item;
29 unsigned int state; /* What state we are testing */
30 Evas_Object *box; /* Use this to get box content */
33 typedef struct _api_data api_data;
43 GRID_TOOLTIP_SET_TEXT,
49 GRID_TOOLTIP_CONTENT_CB,
50 GRID_TOOLTIP_STYLE_SET,
51 GRID_TOOLTIP_WINDOW_MODE_SET,
54 typedef enum _api_state api_state;
57 set_api_state(api_data *api)
59 Evas_Object *grid = api->grid;
61 /* use elm_box_children_get() to get list of children */
63 { /* Put all api-changes under switch */
64 case GRID_ALIGN_SET: /* 0 */
65 elm_gengrid_align_set(grid, 0.2, 0.8);
68 case GRID_BRING_IN: /* 1 */
69 elm_gengrid_item_bring_in(elm_gengrid_first_item_get(grid), ELM_GENGRID_ITEM_SCROLLTO_IN);
72 case GRID_NO_SELECT_MODE: /* 2 */
73 elm_gengrid_select_mode_set(grid, ELM_OBJECT_SELECT_MODE_NONE);
76 case GRID_NO_BOUNCE: /* 3 */
77 elm_scroller_bounce_set(grid, EINA_TRUE, EINA_FALSE);
80 case GRID_PAGE_RELATIVE: /* 4 */
81 elm_scroller_bounce_set(grid, EINA_TRUE, EINA_TRUE);
82 elm_scroller_page_relative_set(grid, 0.5, 0.5);
85 case GRID_PAGE_SIZE: /* 5 */
86 elm_scroller_page_size_set(grid, 50, 25);
89 case GRID_TOOLTIP_SET_TEXT: /* 6 */
91 Elm_Object_Item *item = elm_gengrid_first_item_get(grid);
92 elm_gengrid_item_tooltip_text_set(item, "This is the first item");
96 case GRID_TOOLTIP_UNSET: /* 7 */
98 Elm_Object_Item *item = elm_gengrid_first_item_get(grid);
99 elm_gengrid_item_tooltip_unset(item);
112 _api_bt_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
113 { /* Will add here a SWITCH command containing code to modify test-object */
114 /* in accordance a->state value. */
118 printf("clicked event on API Button: api_state=<%d>\n", a->state);
121 sprintf(str, "Next API function (%u)", a->state);
122 elm_object_text_set(obj, str);
123 elm_object_disabled_set(obj, a->state == API_STATE_LAST);
126 static const char *img[9] =
139 static const char *cur[4] =
143 ELM_CURSOR_COFFEE_MUG,
147 static int n_current_pic = 0;
149 _horizontal_grid(void *data, Evas_Object *obj, void *event_info __UNUSED__)
151 Evas_Object *grid = data;
152 elm_gengrid_horizontal_set(grid, elm_check_state_get(obj));
156 grid_drag_up(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
158 printf("Drag up: %p\n", event_info);
162 grid_drag_right(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
164 printf("Drag right: %p\n", event_info);
168 grid_drag_down(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
170 printf("Drag down: %p\n", event_info);
174 grid_drag_left(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
176 printf("Drag left: %p\n", event_info);
180 grid_drag_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
182 printf("Drag stop: %p\n", event_info);
186 grid_selected(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
188 printf("Selected: %p\n", event_info);
192 grid_double_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
194 printf("Double clicked: %p\n", event_info);
198 grid_longpress(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
200 printf("longpress %p\n", event_info);
204 grid_moved(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
206 printf("moved %p\n", event_info);
210 grid_item_check_changed(void *data, Evas_Object *obj, void *event_info __UNUSED__)
213 ti->onoff = elm_check_state_get(obj);
214 printf("item %p onoff = %i\n", ti, ti->onoff);
218 grid_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
220 const Testitem *ti = data;
222 snprintf(buf, sizeof(buf), "Photo %s", ti->path);
227 grid_content_get(void *data, Evas_Object *obj, const char *part)
229 const Testitem *ti = data;
230 if (!strcmp(part, "elm.swallow.icon"))
232 Evas_Object *icon = elm_bg_add(obj);
233 elm_bg_file_set(icon, ti->path, NULL);
234 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
235 evas_object_show(icon);
238 else if (!strcmp(part, "elm.swallow.end"))
241 ck = elm_check_add(obj);
242 evas_object_propagate_events_set(ck, 0);
243 elm_check_state_set(ck, ti->onoff);
244 evas_object_smart_callback_add(ck, "changed", grid_item_check_changed, data);
245 evas_object_show(ck);
252 grid_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
258 grid_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
263 grid_sel(void *data, Evas_Object *obj, void *event_info)
265 printf("sel item data [%p] on grid obj [%p], pointer [%p]\n", data, obj, event_info);
269 _cleanup_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
275 always_select_mode_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
277 api_data *api = data;
278 if (elm_check_state_get(obj))
279 elm_gengrid_select_mode_set(api->grid, ELM_OBJECT_SELECT_MODE_ALWAYS);
281 elm_gengrid_select_mode_set(api->grid, ELM_OBJECT_SELECT_MODE_DEFAULT);
285 multi_select_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
287 api_data *api = data;
288 elm_gengrid_multi_select_set(api->grid, elm_check_state_get(obj));
292 clear_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
294 api_data *api = data;
295 elm_gengrid_clear(api->grid);
299 create_gengrid(Evas_Object *obj, int items)
301 Evas_Object *grid = NULL;
302 static Testitem ti[144];
306 grid = elm_gengrid_add(obj);
307 elm_gengrid_item_size_set(grid, 150, 150);
308 elm_gengrid_horizontal_set(grid, EINA_FALSE);
309 elm_gengrid_multi_select_set(grid, EINA_TRUE);
310 elm_gengrid_reorder_mode_set(grid, EINA_TRUE);
311 evas_object_smart_callback_add(grid, "selected", grid_selected, NULL);
312 evas_object_smart_callback_add(grid, "clicked,double", grid_double_clicked, NULL);
313 evas_object_smart_callback_add(grid, "longpressed", grid_longpress, NULL);
314 evas_object_smart_callback_add(grid, "moved", grid_moved, NULL);
315 evas_object_smart_callback_add(grid, "drag,start,up", grid_drag_up, NULL);
316 evas_object_smart_callback_add(grid, "drag,start,right", grid_drag_right, NULL);
317 evas_object_smart_callback_add(grid, "drag,start,down", grid_drag_down, NULL);
318 evas_object_smart_callback_add(grid, "drag,start,left", grid_drag_left, NULL);
319 evas_object_smart_callback_add(grid, "drag,stop", grid_drag_stop, NULL);
320 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
321 evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
323 gic = elm_gengrid_item_class_new();
324 gic->item_style = "default";
325 gic->func.text_get = grid_text_get;
326 gic->func.content_get = grid_content_get;
327 gic->func.state_get = grid_state_get;
328 gic->func.del = grid_del;
331 for (i = 0; i < items; i++)
333 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
336 ti[i].path = eina_stringshare_add(buf);
337 ti[i].item = elm_gengrid_item_append(grid, gic, &(ti[i]), grid_sel, NULL);
339 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
341 elm_gengrid_item_class_free(gic);
347 restore_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
349 api_data *api = data;
350 elm_box_clear(api->box);
351 api->grid = create_gengrid(obj, (12 * 12));
352 elm_box_pack_end(api->box, api->grid);
353 evas_object_show(api->grid);
357 filled_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
359 Evas_Object *box = (Evas_Object *)data;
363 grid = create_gengrid(box, 1);
364 elm_gengrid_filled_set(grid, elm_check_state_get(obj));
365 elm_box_pack_end(box, grid);
366 evas_object_show(grid);
370 filled_bt_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
372 Evas_Object *win, *box, *content_box, *grid, *tg;
374 win = elm_win_util_standard_add("test filled", "Test Filled");
375 elm_win_autodel_set(win, EINA_TRUE);
377 box = elm_box_add(win);
378 elm_win_resize_object_add(win, box);
379 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
380 evas_object_show(box);
382 content_box = elm_box_add(win);
383 elm_win_resize_object_add(win, content_box);
384 evas_object_size_hint_weight_set(content_box, EVAS_HINT_EXPAND,
386 evas_object_size_hint_align_set(content_box, EVAS_HINT_FILL,
388 elm_box_pack_end(box, content_box);
389 evas_object_show(content_box);
391 grid = create_gengrid(win, 1);
392 elm_box_pack_end(content_box, grid);
393 evas_object_show(grid);
395 tg = elm_check_add(win);
396 elm_object_text_set(tg, "Filled");
397 evas_object_smart_callback_add(tg, "changed", filled_cb, content_box);
398 elm_box_pack_end(box, tg);
399 evas_object_show(tg);
401 evas_object_resize(win, 450, 200);
402 evas_object_show(win);
406 cursor_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
408 Evas_Object *grid = (Evas_Object *)data;
409 Elm_Object_Item *item = NULL;
412 for ((item = elm_gengrid_first_item_get(grid)); item;
413 (item = elm_gengrid_item_next_get(item)))
415 if (!elm_check_state_get(obj))
417 elm_gengrid_item_cursor_unset(item);
421 elm_gengrid_item_cursor_set(item, cur[i]);
422 elm_gengrid_item_cursor_engine_only_set(item, EINA_FALSE);
428 cursor_bt_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
430 Evas_Object *win, *box, *content_box, *hbox, *grid, *tg;
432 win = elm_win_util_standard_add("test cursor", "Test Cursor");
433 elm_win_autodel_set(win, EINA_TRUE);
435 box = elm_box_add(win);
436 elm_win_resize_object_add(win, box);
437 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
438 evas_object_show(box);
440 content_box = elm_box_add(win);
441 elm_win_resize_object_add(win, content_box);
442 evas_object_size_hint_weight_set(content_box, EVAS_HINT_EXPAND,
444 evas_object_size_hint_align_set(content_box, EVAS_HINT_FILL,
446 elm_box_pack_end(box, content_box);
447 evas_object_show(content_box);
449 grid = create_gengrid(win, 4);
450 elm_box_pack_end(content_box, grid);
451 evas_object_show(grid);
453 hbox = elm_box_add(win);
454 elm_box_horizontal_set(hbox, EINA_TRUE);
456 tg = elm_check_add(win);
457 elm_object_text_set(tg, "Cursor");
458 evas_object_smart_callback_add(tg, "changed", cursor_cb, grid);
459 elm_box_pack_end(hbox, tg);
460 evas_object_show(tg);
462 elm_box_pack_end(box, hbox);
463 evas_object_show(hbox);
465 evas_object_resize(win, 450, 450);
466 evas_object_show(win);
470 _btn_bring_in_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
473 Elm_Object_Item *it = elm_gengrid_selected_item_get(data);
475 elm_gengrid_item_bring_in(it, ELM_GENGRID_ITEM_SCROLLTO_IN);
479 _btn_show_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
482 Elm_Object_Item *it = elm_gengrid_selected_item_get(data);
484 elm_gengrid_item_show(it, ELM_GENGRID_ITEM_SCROLLTO_IN);
488 test_gengrid(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
490 Evas_Object *win, *bt, *content_box, *bxx, *bx, *tg;
491 api_data *api = calloc(1, sizeof(api_data));
493 win = elm_win_util_standard_add("gengrid", "GenGrid");
494 elm_win_autodel_set(win, EINA_TRUE);
495 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
497 bxx = elm_box_add(win);
499 elm_win_resize_object_add(win, bxx);
500 evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
501 evas_object_show(bxx);
503 content_box = elm_box_add(win);
504 api->box = content_box;
505 evas_object_size_hint_weight_set(content_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
506 evas_object_size_hint_align_set(content_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
507 evas_object_show(content_box);
510 api->grid = create_gengrid(win, (12 * 12));
512 bt = elm_button_add(win);
513 elm_object_text_set(bt, "Next API function");
514 evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked,
516 elm_box_pack_end(bxx, bt);
517 elm_object_disabled_set(bt, api->state == API_STATE_LAST);
518 evas_object_show(bt);
520 elm_box_pack_end(content_box, api->grid);
521 elm_box_pack_end(bxx, content_box);
522 evas_object_show(api->grid);
524 bx = elm_box_add(win);
525 elm_box_horizontal_set(bx, EINA_TRUE);
526 elm_box_pack_end(bxx, bx);
527 evas_object_show(bx);
529 /* Gengrid Always Select Mode Test */
530 tg = elm_check_add(win);
531 evas_object_size_hint_weight_set(tg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
532 evas_object_size_hint_align_set(tg, EVAS_HINT_FILL, EVAS_HINT_FILL);
533 elm_object_text_set(tg, "Always Select Mode");
534 evas_object_smart_callback_add(tg, "changed", always_select_mode_cb,
536 elm_box_pack_end(bx, tg);
537 evas_object_show(tg);
539 tg = elm_check_add(win);
540 evas_object_size_hint_weight_set(tg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
541 evas_object_size_hint_align_set(tg, EVAS_HINT_FILL, EVAS_HINT_FILL);
542 elm_object_text_set(tg, "Multi Select Mode");
543 elm_check_state_set(tg, EINA_TRUE);
544 evas_object_smart_callback_add(tg, "changed", multi_select_cb,
546 elm_box_pack_end(bx, tg);
547 evas_object_show(tg);
549 /* Gengrid Clear Test */
550 bt = elm_button_add(win);
551 elm_object_text_set(bt, "Clear");
552 evas_object_smart_callback_add(bt, "clicked", clear_bt_clicked,
554 elm_box_pack_end(bx, bt);
555 evas_object_show(bt);
557 bt = elm_button_add(win);
558 elm_object_text_set(bt, "Restore");
559 evas_object_smart_callback_add(bt, "clicked", restore_bt_clicked,
561 elm_box_pack_end(bx, bt);
562 evas_object_show(bt);
564 /* Gengrid Filled Test */
565 bt = elm_button_add(win);
566 elm_object_text_set(bt, "Check Filled");
567 evas_object_smart_callback_add(bt, "clicked", filled_bt_clicked, NULL);
568 elm_box_pack_end(bx, bt);
569 evas_object_show(bt);
571 /* Item Cursor Test */
572 bt = elm_button_add(win);
573 elm_object_text_set(bt, "Check Cursor");
574 evas_object_smart_callback_add(bt, "clicked", cursor_bt_clicked,
576 elm_box_pack_end(bx, bt);
577 evas_object_show(bt);
579 bt = elm_button_add(win);
580 elm_object_text_set(bt, "Bring in");
581 evas_object_smart_callback_add(bt, "clicked", _btn_bring_in_clicked_cb, api->grid);
582 elm_box_pack_end(bx, bt);
583 evas_object_show(bt);
585 bt = elm_button_add(win);
586 elm_object_text_set(bt, "Show");
587 evas_object_smart_callback_add(bt, "clicked", _btn_show_clicked_cb, api->grid);
588 elm_box_pack_end(bx, bt);
589 evas_object_show(bt);
591 evas_object_resize(win, 600, 600);
592 evas_object_show(win);
596 _before_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
599 Evas_Object *grid = data;
600 Elm_Object_Item *sel;
603 sel = elm_gengrid_selected_item_get(grid);
606 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]);
607 n_current_pic = ((n_current_pic +1) % 9);
608 ti = calloc(1, sizeof(*ti));
610 ti->path = eina_stringshare_add(buf);
611 ti->item = elm_gengrid_item_insert_before(grid, gic, ti, sel, grid_sel,
616 compare_cb(const void *data1, const void *data2)
618 Testitem *ti1 = (Testitem *)data1;
619 Testitem *ti2 = (Testitem *)data2;
620 return strlen(ti1->path) - strlen(ti2->path);
624 _sorted_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
627 Evas_Object *grid = data;
630 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]);
631 n_current_pic = ((n_current_pic +1) % 9);
632 ti = calloc(1, sizeof(*ti));
634 ti->path = eina_stringshare_add(buf);
635 ti->item = elm_gengrid_item_sorted_insert(grid, gic, ti, compare_cb, grid_sel,
640 _after_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
643 Evas_Object *grid = data;
644 Elm_Object_Item *sel;
647 sel = elm_gengrid_selected_item_get(grid);
650 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]);
651 n_current_pic = ((n_current_pic +1) % 9);
652 ti = calloc(1, sizeof(*ti));
654 ti->path = eina_stringshare_add(buf);
655 ti->item = elm_gengrid_item_insert_after(grid, gic, ti, sel, grid_sel,
660 _delete_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
662 Evas_Object *grid = data;
663 Eina_List *l, *l2, *l3;
664 Elm_Object_Item *gg_it;
666 l = (Eina_List*)elm_gengrid_selected_items_get(grid);
668 EINA_LIST_FOREACH_SAFE(l, l2, l3, gg_it)
669 elm_object_item_del(gg_it);
673 _prepend_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
676 Evas_Object *grid = data;
679 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]);
680 n_current_pic = ((n_current_pic +1) % 9);
681 ti = calloc(1, sizeof(*ti));
683 ti->path = eina_stringshare_add(buf);
684 ti->item = elm_gengrid_item_prepend(grid, gic, ti, grid_sel, NULL);
688 _append_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
691 Evas_Object *grid = data;
694 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]);
695 n_current_pic = ((n_current_pic +1) % 9);
696 ti = calloc(1, sizeof(*ti));
698 ti->path = eina_stringshare_add(buf);
699 ti->item = elm_gengrid_item_append(grid, gic, ti, grid_sel, NULL);
703 _size_changed(void *data, Evas_Object *obj, void *event_info __UNUSED__)
705 Evas_Object *grid = data;
706 int size = elm_spinner_value_get(obj);
707 elm_gengrid_item_size_set(grid, size, size);
711 test_gengrid2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
713 Evas_Object *win, *grid, *bx, *hbx, *bt, *ck;
715 win = elm_win_util_standard_add("gengrid2", "GenGrid 2");
716 elm_win_autodel_set(win, EINA_TRUE);
718 bx = elm_box_add(win);
719 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
720 elm_win_resize_object_add(win, bx);
721 evas_object_show(bx);
723 grid = elm_gengrid_add(win);
724 elm_gengrid_item_size_set(grid, 150, 150);
725 elm_gengrid_horizontal_set(grid, EINA_FALSE);
726 elm_gengrid_multi_select_set(grid, EINA_FALSE);
727 evas_object_smart_callback_add(grid, "selected", grid_selected, NULL);
728 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
729 evas_object_size_hint_min_set(grid, 600, 500);
730 elm_box_pack_end(bx, grid);
731 evas_object_show(grid);
733 hbx = elm_box_add(win);
734 evas_object_size_hint_weight_set(hbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
735 elm_box_horizontal_set(hbx, EINA_TRUE);
736 elm_box_pack_end(bx, hbx);
737 evas_object_show(hbx);
739 bt = elm_button_add(win);
740 elm_object_text_set(bt, "Append");
741 evas_object_smart_callback_add(bt, "clicked", _append_bt_clicked, grid);
742 elm_box_pack_end(hbx, bt);
743 evas_object_show(bt);
745 bt = elm_button_add(win);
746 elm_object_text_set(bt, "Prepend");
747 evas_object_smart_callback_add(bt, "clicked", _prepend_bt_clicked, grid);
748 elm_box_pack_end(hbx, bt);
749 evas_object_show(bt);
751 bt = elm_button_add(win);
752 elm_object_text_set(bt, "Insert before");
753 evas_object_smart_callback_add(bt, "clicked", _before_bt_clicked, grid);
754 elm_box_pack_end(hbx, bt);
755 evas_object_show(bt);
757 bt = elm_button_add(win);
758 elm_object_text_set(bt, "Insert after");
759 evas_object_smart_callback_add(bt, "clicked", _after_bt_clicked, grid);
760 elm_box_pack_end(hbx, bt);
761 evas_object_show(bt);
763 bt = elm_button_add(win);
764 elm_object_text_set(bt, "Sorted insert");
765 evas_object_smart_callback_add(bt, "clicked", _sorted_bt_clicked, grid);
766 elm_box_pack_end(hbx, bt);
767 evas_object_show(bt);
769 bt = elm_button_add(win);
770 elm_object_text_set(bt, "Delete");
771 evas_object_smart_callback_add(bt, "clicked", _delete_bt_clicked, grid);
772 elm_box_pack_end(hbx, bt);
773 evas_object_show(bt);
775 bt = elm_spinner_add(win);
776 elm_spinner_min_max_set(bt, 10, 1024);
777 elm_spinner_value_set(bt, 150);
778 elm_spinner_label_format_set(bt, "Item size: %.0f");
779 evas_object_smart_callback_add(bt, "changed", _size_changed, grid);
780 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
781 elm_box_pack_end(hbx, bt);
782 evas_object_show(bt);
784 ck = elm_check_add(win);
785 elm_object_text_set(ck, "Horizontal Mode");
786 evas_object_smart_callback_add(ck, "changed", _horizontal_grid, grid);
787 elm_box_pack_end(hbx, ck);
788 evas_object_show(ck);
790 gic = elm_gengrid_item_class_new();
792 gic->item_style = "default";
793 gic->func.text_get = grid_text_get;
794 gic->func.content_get = grid_content_get;
795 gic->func.state_get = grid_state_get;
796 gic->func.del = grid_del;
798 /* item_class_ref is needed for gic. some items can be added in callbacks */
799 elm_gengrid_item_class_ref(gic);
800 elm_gengrid_item_class_free(gic);
802 evas_object_resize(win, 600, 600);
803 evas_object_show(win);
807 test_gengrid3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
809 Evas_Object *win, *grid;
810 static Testitem ti[144];
814 win = elm_win_util_standard_add("gengrid_group", "GenGrid Group");
815 elm_win_autodel_set(win, EINA_TRUE);
817 grid = elm_gengrid_add(win);
818 elm_gengrid_item_size_set(grid, 150, 150);
819 elm_gengrid_group_item_size_set(grid, 31, 31);
820 //elm_gengrid_horizontal_set(grid, EINA_TRUE);
821 elm_gengrid_horizontal_set(grid, EINA_FALSE);
822 elm_gengrid_multi_select_set(grid, EINA_TRUE);
823 elm_gengrid_reorder_mode_set(grid, EINA_TRUE);
824 evas_object_smart_callback_add(grid, "selected", grid_selected, NULL);
825 evas_object_smart_callback_add(grid, "clicked,double", grid_double_clicked, NULL);
826 evas_object_smart_callback_add(grid, "longpressed", grid_longpress, NULL);
827 evas_object_smart_callback_add(grid, "moved", grid_moved, NULL);
828 evas_object_smart_callback_add(grid, "drag,start,up", grid_drag_up, NULL);
829 evas_object_smart_callback_add(grid, "drag,start,right", grid_drag_right, NULL);
830 evas_object_smart_callback_add(grid, "drag,start,down", grid_drag_down, NULL);
831 evas_object_smart_callback_add(grid, "drag,start,left", grid_drag_left, NULL);
832 evas_object_smart_callback_add(grid, "drag,stop", grid_drag_stop, NULL);
833 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
835 gic = elm_gengrid_item_class_new();
836 gic->item_style = "default";
837 gic->func.text_get = grid_text_get;
838 gic->func.content_get = grid_content_get;
839 gic->func.state_get = grid_state_get;
840 gic->func.del = grid_del;
842 ggic.item_style = "group_index";
843 ggic.func.text_get = grid_text_get;
844 ggic.func.content_get = NULL;
845 ggic.func.state_get = NULL;
846 ggic.func.del = NULL;
849 for (i = 0; i < 12 * 12; i++)
851 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
854 ti[i].path = eina_stringshare_add(buf);
855 if (i == 0 || i == 18 || i == 53 || i == 100)
856 //if (i == 0 || i == 18)
857 ti[i].item = elm_gengrid_item_append(grid, &ggic, &(ti[i]), grid_sel, NULL);
859 ti[i].item = elm_gengrid_item_append(grid, gic, &(ti[i]), grid_sel, NULL);
861 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
863 elm_gengrid_item_class_free(gic);
865 evas_object_show(grid);
866 elm_win_resize_object_add(win, grid);
868 evas_object_resize(win, 600, 600);
869 evas_object_show(win);