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_gengrid_bounce_set(grid, EINA_TRUE, EINA_FALSE);
80 case GRID_PAGE_RELATIVE: /* 4 */
81 elm_gengrid_bounce_set(grid, EINA_TRUE, EINA_TRUE);
82 elm_gengrid_page_relative_set(grid, 0.5, 0.5);
85 case GRID_PAGE_SIZE: /* 5 */
86 elm_gengrid_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 test_gengrid(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
472 Evas_Object *win, *bt, *content_box, *bxx, *bx, *tg;
473 api_data *api = calloc(1, sizeof(api_data));
475 win = elm_win_util_standard_add("gengrid", "GenGrid");
476 elm_win_autodel_set(win, EINA_TRUE);
477 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
479 bxx = elm_box_add(win);
481 elm_win_resize_object_add(win, bxx);
482 evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
483 evas_object_show(bxx);
485 content_box = elm_box_add(win);
486 api->box = content_box;
487 evas_object_size_hint_weight_set(content_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
488 evas_object_size_hint_align_set(content_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
489 evas_object_show(content_box);
492 api->grid = create_gengrid(win, (12 * 12));
494 bt = elm_button_add(win);
495 elm_object_text_set(bt, "Next API function");
496 evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked,
498 elm_box_pack_end(bxx, bt);
499 elm_object_disabled_set(bt, api->state == API_STATE_LAST);
500 evas_object_show(bt);
502 elm_box_pack_end(content_box, api->grid);
503 elm_box_pack_end(bxx, content_box);
504 evas_object_show(api->grid);
506 bx = elm_box_add(win);
507 elm_box_horizontal_set(bx, EINA_TRUE);
508 elm_box_pack_end(bxx, bx);
509 evas_object_show(bx);
511 /* Gengrid Always Select Mode Test */
512 tg = elm_check_add(win);
513 evas_object_size_hint_weight_set(tg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
514 evas_object_size_hint_align_set(tg, EVAS_HINT_FILL, EVAS_HINT_FILL);
515 elm_object_text_set(tg, "Always Select Mode");
516 evas_object_smart_callback_add(tg, "changed", always_select_mode_cb,
518 elm_box_pack_end(bx, tg);
519 evas_object_show(tg);
521 tg = elm_check_add(win);
522 evas_object_size_hint_weight_set(tg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
523 evas_object_size_hint_align_set(tg, EVAS_HINT_FILL, EVAS_HINT_FILL);
524 elm_object_text_set(tg, "Multi Select Mode");
525 elm_check_state_set(tg, EINA_TRUE);
526 evas_object_smart_callback_add(tg, "changed", multi_select_cb,
528 elm_box_pack_end(bx, tg);
529 evas_object_show(tg);
531 /* Gengrid Clear Test */
532 bt = elm_button_add(win);
533 elm_object_text_set(bt, "Clear");
534 evas_object_smart_callback_add(bt, "clicked", clear_bt_clicked,
536 elm_box_pack_end(bx, bt);
537 evas_object_show(bt);
539 bt = elm_button_add(win);
540 elm_object_text_set(bt, "Restore");
541 evas_object_smart_callback_add(bt, "clicked", restore_bt_clicked,
543 elm_box_pack_end(bx, bt);
544 evas_object_show(bt);
546 /* Gengrid Filled Test */
547 bt = elm_button_add(win);
548 elm_object_text_set(bt, "Check Filled");
549 evas_object_smart_callback_add(bt, "clicked", filled_bt_clicked, NULL);
550 elm_box_pack_end(bx, bt);
551 evas_object_show(bt);
553 /* Item Cursor Test */
554 bt = elm_button_add(win);
555 elm_object_text_set(bt, "Check Cursor");
556 evas_object_smart_callback_add(bt, "clicked", cursor_bt_clicked,
558 elm_box_pack_end(bx, bt);
559 evas_object_show(bt);
561 evas_object_resize(win, 600, 600);
562 evas_object_show(win);
566 _before_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
569 Evas_Object *grid = data;
570 Elm_Object_Item *sel;
573 sel = elm_gengrid_selected_item_get(grid);
576 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]);
577 n_current_pic = ((n_current_pic +1) % 9);
578 ti = calloc(1, sizeof(*ti));
580 ti->path = eina_stringshare_add(buf);
581 ti->item = elm_gengrid_item_insert_before(grid, gic, ti, sel, grid_sel,
586 compare_cb(const void *data1, const void *data2)
588 Testitem *ti1 = (Testitem *)data1;
589 Testitem *ti2 = (Testitem *)data2;
590 return strlen(ti1->path) - strlen(ti2->path);
594 _sorted_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
597 Evas_Object *grid = data;
600 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]);
601 n_current_pic = ((n_current_pic +1) % 9);
602 ti = calloc(1, sizeof(*ti));
604 ti->path = eina_stringshare_add(buf);
605 ti->item = elm_gengrid_item_sorted_insert(grid, gic, ti, compare_cb, grid_sel,
610 _after_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
613 Evas_Object *grid = data;
614 Elm_Object_Item *sel;
617 sel = elm_gengrid_selected_item_get(grid);
620 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]);
621 n_current_pic = ((n_current_pic +1) % 9);
622 ti = calloc(1, sizeof(*ti));
624 ti->path = eina_stringshare_add(buf);
625 ti->item = elm_gengrid_item_insert_after(grid, gic, ti, sel, grid_sel,
630 _delete_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
632 Evas_Object *grid = data;
633 Eina_List *l, *l2, *l3;
634 Elm_Object_Item *gg_it;
636 l = (Eina_List*)elm_gengrid_selected_items_get(grid);
638 EINA_LIST_FOREACH_SAFE(l, l2, l3, gg_it)
639 elm_object_item_del(gg_it);
643 _prepend_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
646 Evas_Object *grid = data;
649 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]);
650 n_current_pic = ((n_current_pic +1) % 9);
651 ti = calloc(1, sizeof(*ti));
653 ti->path = eina_stringshare_add(buf);
654 ti->item = elm_gengrid_item_prepend(grid, gic, ti, grid_sel, NULL);
658 _append_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
661 Evas_Object *grid = data;
664 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]);
665 n_current_pic = ((n_current_pic +1) % 9);
666 ti = calloc(1, sizeof(*ti));
668 ti->path = eina_stringshare_add(buf);
669 ti->item = elm_gengrid_item_append(grid, gic, ti, grid_sel, NULL);
673 _size_changed(void *data, Evas_Object *obj, void *event_info __UNUSED__)
675 Evas_Object *grid = data;
676 int size = elm_spinner_value_get(obj);
677 elm_gengrid_item_size_set(grid, size, size);
681 test_gengrid2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
683 Evas_Object *win, *grid, *bx, *hbx, *bt, *ck;
685 win = elm_win_util_standard_add("gengrid2", "GenGrid 2");
686 elm_win_autodel_set(win, EINA_TRUE);
688 bx = elm_box_add(win);
689 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
690 elm_win_resize_object_add(win, bx);
691 evas_object_show(bx);
693 grid = elm_gengrid_add(win);
694 elm_gengrid_item_size_set(grid, 150, 150);
695 elm_gengrid_horizontal_set(grid, EINA_FALSE);
696 elm_gengrid_multi_select_set(grid, EINA_FALSE);
697 evas_object_smart_callback_add(grid, "selected", grid_selected, NULL);
698 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
699 evas_object_size_hint_min_set(grid, 600, 500);
700 elm_box_pack_end(bx, grid);
701 evas_object_show(grid);
703 hbx = elm_box_add(win);
704 evas_object_size_hint_weight_set(hbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
705 elm_box_horizontal_set(hbx, EINA_TRUE);
706 elm_box_pack_end(bx, hbx);
707 evas_object_show(hbx);
709 bt = elm_button_add(win);
710 elm_object_text_set(bt, "Append");
711 evas_object_smart_callback_add(bt, "clicked", _append_bt_clicked, grid);
712 elm_box_pack_end(hbx, bt);
713 evas_object_show(bt);
715 bt = elm_button_add(win);
716 elm_object_text_set(bt, "Prepend");
717 evas_object_smart_callback_add(bt, "clicked", _prepend_bt_clicked, grid);
718 elm_box_pack_end(hbx, bt);
719 evas_object_show(bt);
721 bt = elm_button_add(win);
722 elm_object_text_set(bt, "Insert before");
723 evas_object_smart_callback_add(bt, "clicked", _before_bt_clicked, grid);
724 elm_box_pack_end(hbx, bt);
725 evas_object_show(bt);
727 bt = elm_button_add(win);
728 elm_object_text_set(bt, "Insert after");
729 evas_object_smart_callback_add(bt, "clicked", _after_bt_clicked, grid);
730 elm_box_pack_end(hbx, bt);
731 evas_object_show(bt);
733 bt = elm_button_add(win);
734 elm_object_text_set(bt, "Sorted insert");
735 evas_object_smart_callback_add(bt, "clicked", _sorted_bt_clicked, grid);
736 elm_box_pack_end(hbx, bt);
737 evas_object_show(bt);
739 bt = elm_button_add(win);
740 elm_object_text_set(bt, "Delete");
741 evas_object_smart_callback_add(bt, "clicked", _delete_bt_clicked, grid);
742 elm_box_pack_end(hbx, bt);
743 evas_object_show(bt);
745 bt = elm_spinner_add(win);
746 elm_spinner_min_max_set(bt, 10, 1024);
747 elm_spinner_value_set(bt, 150);
748 elm_spinner_label_format_set(bt, "Item size: %.0f");
749 evas_object_smart_callback_add(bt, "changed", _size_changed, grid);
750 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
751 elm_box_pack_end(hbx, bt);
752 evas_object_show(bt);
754 ck = elm_check_add(win);
755 elm_object_text_set(ck, "Horizontal Mode");
756 evas_object_smart_callback_add(ck, "changed", _horizontal_grid, grid);
757 elm_box_pack_end(hbx, ck);
758 evas_object_show(ck);
760 gic = elm_gengrid_item_class_new();
762 gic->item_style = "default";
763 gic->func.text_get = grid_text_get;
764 gic->func.content_get = grid_content_get;
765 gic->func.state_get = grid_state_get;
766 gic->func.del = grid_del;
768 /* item_class_ref is needed for gic. some items can be added in callbacks */
769 elm_gengrid_item_class_ref(gic);
770 elm_gengrid_item_class_free(gic);
772 evas_object_resize(win, 600, 600);
773 evas_object_show(win);
777 test_gengrid3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
779 Evas_Object *win, *grid;
780 static Testitem ti[144];
784 win = elm_win_util_standard_add("gengrid_group", "GenGrid Group");
785 elm_win_autodel_set(win, EINA_TRUE);
787 grid = elm_gengrid_add(win);
788 elm_gengrid_item_size_set(grid, 150, 150);
789 elm_gengrid_group_item_size_set(grid, 31, 31);
790 //elm_gengrid_horizontal_set(grid, EINA_TRUE);
791 elm_gengrid_horizontal_set(grid, EINA_FALSE);
792 elm_gengrid_multi_select_set(grid, EINA_TRUE);
793 elm_gengrid_reorder_mode_set(grid, EINA_TRUE);
794 evas_object_smart_callback_add(grid, "selected", grid_selected, NULL);
795 evas_object_smart_callback_add(grid, "clicked,double", grid_double_clicked, NULL);
796 evas_object_smart_callback_add(grid, "longpressed", grid_longpress, NULL);
797 evas_object_smart_callback_add(grid, "moved", grid_moved, NULL);
798 evas_object_smart_callback_add(grid, "drag,start,up", grid_drag_up, NULL);
799 evas_object_smart_callback_add(grid, "drag,start,right", grid_drag_right, NULL);
800 evas_object_smart_callback_add(grid, "drag,start,down", grid_drag_down, NULL);
801 evas_object_smart_callback_add(grid, "drag,start,left", grid_drag_left, NULL);
802 evas_object_smart_callback_add(grid, "drag,stop", grid_drag_stop, NULL);
803 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
805 gic = elm_gengrid_item_class_new();
806 gic->item_style = "default";
807 gic->func.text_get = grid_text_get;
808 gic->func.content_get = grid_content_get;
809 gic->func.state_get = grid_state_get;
810 gic->func.del = grid_del;
812 ggic.item_style = "group_index";
813 ggic.func.text_get = grid_text_get;
814 ggic.func.content_get = NULL;
815 ggic.func.state_get = NULL;
816 ggic.func.del = NULL;
819 for (i = 0; i < 12 * 12; i++)
821 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
824 ti[i].path = eina_stringshare_add(buf);
825 if (i == 0 || i == 18 || i == 53 || i == 100)
826 //if (i == 0 || i == 18)
827 ti[i].item = elm_gengrid_item_append(grid, &ggic, &(ti[i]), grid_sel, NULL);
829 ti[i].item = elm_gengrid_item_append(grid, gic, &(ti[i]), grid_sel, NULL);
831 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
833 elm_gengrid_item_class_free(gic);
835 evas_object_show(grid);
836 elm_win_resize_object_add(win, grid);
838 evas_object_resize(win, 600, 600);
839 evas_object_show(win);