summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDaniel Juyung Seo <seojuyung2@gmail.com>2013-11-05 14:18:47 +0900
committerDaniel Juyung Seo <seojuyung2@gmail.com>2013-11-05 14:18:54 +0900
commit6f620ec0938cc72715175c63b8a3c2f5b9a7b07f (patch)
treec1d9ce1db0d4f0bce5d34e56adf2c65de3e1c62b /src/bin
parentb0244d1285c76be7f5f003c75e944a6753092422 (diff)
test_list.c: Added elm_list_multi_select_mode_set() example.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/test_list.c91
1 files changed, 88 insertions, 3 deletions
diff --git a/src/bin/test_list.c b/src/bin/test_list.c
index 05eee009c..c1bfe2b66 100644
--- a/src/bin/test_list.c
+++ b/src/bin/test_list.c
@@ -276,7 +276,8 @@ scroll_right(void *data EINA_UNUSED,
276} 276}
277 277
278static void 278static void
279_cleanup_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 279_cleanup_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
280 void *event_info EINA_UNUSED)
280{ 281{
281 free(data); 282 free(data);
282} 283}
@@ -564,6 +565,14 @@ test_list_horizontal(void *data EINA_UNUSED,
564 565
565/***********/ 566/***********/
566 567
568typedef struct _List2_Data List2_Data;
569struct _List2_Data
570{
571 Evas_Object *list;
572 Evas_Object *rd1;
573 Evas_Object *rd2;
574};
575
567static void 576static void
568my_li2_clear(void *data, 577my_li2_clear(void *data,
569 Evas_Object *obj EINA_UNUSED, 578 Evas_Object *obj EINA_UNUSED,
@@ -579,6 +588,78 @@ my_li2_sel(void *data EINA_UNUSED,
579{ 588{
580 Elm_Object_Item *list_it = elm_list_selected_item_get(obj); 589 Elm_Object_Item *list_it = elm_list_selected_item_get(obj);
581 elm_list_item_selected_set(list_it, EINA_FALSE); 590 elm_list_item_selected_set(list_it, EINA_FALSE);
591 printf("item selected\n");
592}
593
594static void
595_multi_select_changed_cb(void *data, Evas_Object *obj,
596 void *event_info EINA_UNUSED)
597{
598 Eina_Bool multi = elm_check_state_get(obj);
599 List2_Data *ld = data;
600 if (!ld) return;
601
602 elm_list_multi_select_set(ld->list, multi);
603 elm_object_disabled_set(ld->rd1, !multi);
604 elm_object_disabled_set(ld->rd2, !multi);
605}
606
607static void
608_multi_select_mode_changed_cb(void *data, Evas_Object *obj,
609 void *event_info EINA_UNUSED)
610{
611 elm_list_multi_select_mode_set(data, elm_radio_value_get(obj));
612}
613
614static void
615_multi_select_frame_create(Evas_Object *bx, List2_Data *ld)
616{
617 Evas_Object *fr, *bx2, *bx3, *tg, *rd, *rdg;
618 if (!ld) return;
619
620 fr = elm_frame_add(bx);
621 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0.0);
622 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, 0.5);
623 elm_object_text_set(fr, "Multi Select Option");
624 elm_box_pack_end(bx, fr);
625 evas_object_show(fr);
626
627 bx2 = elm_box_add(fr);
628 elm_object_content_set(fr, bx2);
629 evas_object_show(bx2);
630
631 tg = elm_check_add(bx2);
632 elm_object_style_set(tg, "toggle");
633 elm_object_text_set(tg, "Multi Select Mode");
634 elm_box_pack_end(bx2, tg);
635 evas_object_show(tg);
636
637 bx3 = elm_box_add(bx2);
638 elm_box_horizontal_set(bx3, EINA_TRUE);
639 elm_box_pack_end(bx2, bx3);
640 evas_object_show(bx3);
641
642 ld->rd1 = rdg = rd = elm_radio_add(bx3);
643 elm_radio_state_value_set(rd, ELM_OBJECT_MULTI_SELECT_MODE_DEFAULT);
644 elm_object_text_set(rd, "Default Mode");
645 elm_box_pack_end(bx3, rd);
646 evas_object_show(rd);
647 elm_object_disabled_set(rd, EINA_TRUE);
648 evas_object_smart_callback_add(rd, "changed",
649 _multi_select_mode_changed_cb, ld->list);
650
651 ld->rd2 = rd = elm_radio_add(bx3);
652 elm_radio_state_value_set(rd, ELM_OBJECT_MULTI_SELECT_MODE_WITH_CONTROL);
653 elm_radio_group_add(rd, rdg);
654 elm_object_text_set(rd, "With Control Mode");
655 elm_box_pack_end(bx3, rd);
656 evas_object_show(rd);
657 elm_object_disabled_set(rd, EINA_TRUE);
658 evas_object_smart_callback_add(rd, "changed",
659 _multi_select_mode_changed_cb, ld->list);
660
661 evas_object_smart_callback_add(tg, "changed",
662 _multi_select_changed_cb, ld);
582} 663}
583 664
584void 665void
@@ -589,12 +670,14 @@ test_list2(void *data EINA_UNUSED,
589 Evas_Object *win, *bg, *li, *ic, *ic2, *bx, *bx2, *bt; 670 Evas_Object *win, *bg, *li, *ic, *ic2, *bx, *bx2, *bt;
590 char buf[PATH_MAX]; 671 char buf[PATH_MAX];
591 Elm_Object_Item *list_it; 672 Elm_Object_Item *list_it;
673 List2_Data *ld = calloc(1, sizeof(List2_Data));
592 674
593 win = elm_win_add(NULL, "list2", ELM_WIN_BASIC); 675 win = elm_win_add(NULL, "list2", ELM_WIN_BASIC);
594 elm_win_title_set(win, "List 2"); 676 elm_win_title_set(win, "List 2");
595 elm_win_autodel_set(win, EINA_TRUE); 677 elm_win_autodel_set(win, EINA_TRUE);
596 evas_object_resize(win, 320, 400); 678 evas_object_resize(win, 320, 500);
597 evas_object_show(win); 679 evas_object_show(win);
680 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, ld);
598 681
599 bg = elm_bg_add(win); 682 bg = elm_bg_add(win);
600 snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get()); 683 snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
@@ -608,7 +691,7 @@ test_list2(void *data EINA_UNUSED,
608 elm_win_resize_object_add(win, bx); 691 elm_win_resize_object_add(win, bx);
609 evas_object_show(bx); 692 evas_object_show(bx);
610 693
611 li = elm_list_add(bx); 694 ld->list = li = elm_list_add(bx);
612 evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL); 695 evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
613 evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 696 evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
614 elm_list_mode_set(li, ELM_LIST_LIMIT); 697 elm_list_mode_set(li, ELM_LIST_LIMIT);
@@ -683,6 +766,8 @@ test_list2(void *data EINA_UNUSED,
683 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); 766 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
684 elm_box_pack_end(bx, bt); 767 elm_box_pack_end(bx, bt);
685 evas_object_show(bt); 768 evas_object_show(bt);
769
770 _multi_select_frame_create(bx, ld);
686} 771}
687 772
688/***********/ 773/***********/