summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDaniel Juyung Seo <seojuyung2@gmail.com>2014-09-20 17:23:03 +0900
committerDaniel Juyung Seo <seojuyung2@gmail.com>2014-09-20 17:23:03 +0900
commitb1970bec0059bc2ff7fcc9d14f15c4c1a059a106 (patch)
treec1bfc1afcd4a3f82dff3de467fb7d4ef1faa1aa1 /src/bin
parent9eaa0e20787dfc147dd9770a4683808f83ba80af (diff)
test_radio: Did internal refactoring and added more group test example.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/test_radio.c125
1 files changed, 99 insertions, 26 deletions
diff --git a/src/bin/test_radio.c b/src/bin/test_radio.c
index 2c1a8b6cc..99eadfafc 100644
--- a/src/bin/test_radio.c
+++ b/src/bin/test_radio.c
@@ -17,34 +17,36 @@ _rdg_changed_cb(void *data EINA_UNUSED, Evas_Object *obj,
17 printf("radio group value : %d\n", elm_radio_value_get(obj)); 17 printf("radio group value : %d\n", elm_radio_value_get(obj));
18} 18}
19 19
20void 20static void
21test_radio(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, 21_group_1_create(Evas_Object *bx)
22 void *event_info EINA_UNUSED)
23{ 22{
24 Evas_Object *win, *bx, *ic, *rd, *rdg; 23 Evas_Object *bx2, *fr, *ic, *rd, *rdg;
25 char buf[PATH_MAX]; 24 char buf[PATH_MAX];
26 25
27 win = elm_win_util_standard_add("radios", "Radios"); 26 fr = elm_frame_add(bx);
28 elm_win_autodel_set(win, EINA_TRUE); 27 elm_object_text_set(fr, "Radio Group 1");
28 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
29 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
30 elm_box_pack_end(bx, fr);
31 evas_object_show(fr);
29 32
30 bx = elm_box_add(win); 33 bx2 = elm_box_add(fr);
31 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 34 elm_object_content_set(fr, bx2);
32 elm_win_resize_object_add(win, bx); 35 evas_object_show(bx2);
33 evas_object_show(bx);
34 36
35 // radio 1 37 // radio 1
36 ic = elm_icon_add(win); 38 ic = elm_icon_add(bx2);
37 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get()); 39 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
38 elm_image_file_set(ic, buf, NULL); 40 elm_image_file_set(ic, buf, NULL);
39 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); 41 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
40 42
41 rd = elm_radio_add(win); 43 rd = elm_radio_add(bx2);
42 elm_radio_state_value_set(rd, 0); 44 elm_radio_state_value_set(rd, 0);
43 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 45 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
44 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, 0.5); 46 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, 0.5);
45 elm_object_text_set(rd, "Icon sized to radio"); 47 elm_object_text_set(rd, "Icon sized to radio");
46 elm_object_part_content_set(rd, "icon", ic); 48 elm_object_part_content_set(rd, "icon", ic);
47 elm_box_pack_end(bx, rd); 49 elm_box_pack_end(bx2, rd);
48 evas_object_show(rd); 50 evas_object_show(rd);
49 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, NULL); 51 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, NULL);
50 52
@@ -52,65 +54,136 @@ test_radio(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
52 rdg = rd; 54 rdg = rd;
53 evas_object_smart_callback_add(rdg, "changed", _rdg_changed_cb, NULL); 55 evas_object_smart_callback_add(rdg, "changed", _rdg_changed_cb, NULL);
54 56
55 ic = elm_icon_add(win); 57 ic = elm_icon_add(bx2);
56 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get()); 58 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
57 elm_image_file_set(ic, buf, NULL); 59 elm_image_file_set(ic, buf, NULL);
58 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE); 60 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
59 61
60 rd = elm_radio_add(win); 62 rd = elm_radio_add(bx2);
61 elm_radio_state_value_set(rd, 1); 63 elm_radio_state_value_set(rd, 1);
62 elm_radio_group_add(rd, rdg); 64 elm_radio_group_add(rd, rdg);
63 elm_object_text_set(rd, "Icon no scale"); 65 elm_object_text_set(rd, "Icon no scale");
64 elm_object_part_content_set(rd, "icon", ic); 66 elm_object_part_content_set(rd, "icon", ic);
65 elm_box_pack_end(bx, rd); 67 elm_box_pack_end(bx2, rd);
66 evas_object_show(rd); 68 evas_object_show(rd);
67 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, NULL); 69 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, NULL);
68 70
69 rd = elm_radio_add(win); 71 rd = elm_radio_add(bx2);
70 elm_radio_state_value_set(rd, 2); 72 elm_radio_state_value_set(rd, 2);
71 elm_radio_group_add(rd, rdg); // add a radio button rd to a radio group rdg. 73 elm_radio_group_add(rd, rdg); // add a radio button rd to a radio group rdg.
72 elm_object_text_set(rd, "Label Only"); 74 elm_object_text_set(rd, "Label Only");
73 elm_box_pack_end(bx, rd); 75 elm_box_pack_end(bx2, rd);
74 evas_object_show(rd); 76 evas_object_show(rd);
75 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, NULL); 77 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, NULL);
76 78
77 rd = elm_radio_add(win); 79 rd = elm_radio_add(bx2);
78 elm_radio_state_value_set(rd, 3); 80 elm_radio_state_value_set(rd, 3);
79 elm_radio_group_add(rd, rdg); // add a radio button rd to a radio group rdg. 81 elm_radio_group_add(rd, rdg); // add a radio button rd to a radio group rdg.
80 elm_object_text_set(rd, "Disabled"); 82 elm_object_text_set(rd, "Disabled");
81 elm_object_disabled_set(rd, EINA_TRUE); 83 elm_object_disabled_set(rd, EINA_TRUE);
82 elm_box_pack_end(bx, rd); 84 elm_box_pack_end(bx2, rd);
83 evas_object_show(rd); 85 evas_object_show(rd);
84 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, NULL); 86 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, NULL);
85 87
86 ic = elm_icon_add(win); 88 ic = elm_icon_add(bx2);
87 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get()); 89 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
88 elm_image_file_set(ic, buf, NULL); 90 elm_image_file_set(ic, buf, NULL);
89 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE); 91 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
90 92
91 rd = elm_radio_add(win); 93 rd = elm_radio_add(bx2);
92 elm_radio_state_value_set(rd, 4); 94 elm_radio_state_value_set(rd, 4);
93 elm_radio_group_add(rd, rdg); // add a radio button rd to a radio group rdg. 95 elm_radio_group_add(rd, rdg); // add a radio button rd to a radio group rdg.
94 elm_object_part_content_set(rd, "icon", ic); 96 elm_object_part_content_set(rd, "icon", ic);
95 elm_box_pack_end(bx, rd); 97 elm_box_pack_end(bx2, rd);
96 evas_object_show(rd); 98 evas_object_show(rd);
97 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, NULL); 99 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, NULL);
98 100
99 ic = elm_icon_add(win); 101 ic = elm_icon_add(bx2);
100 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get()); 102 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
101 elm_image_file_set(ic, buf, NULL); 103 elm_image_file_set(ic, buf, NULL);
102 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE); 104 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
103 105
104 rd = elm_radio_add(win); 106 rd = elm_radio_add(bx2);
105 elm_radio_state_value_set(rd, 5); 107 elm_radio_state_value_set(rd, 5);
106 elm_radio_group_add(rd, rdg); // add a radio button rd to a radio group rdg. 108 elm_radio_group_add(rd, rdg); // add a radio button rd to a radio group rdg.
107 elm_object_part_content_set(rd, "icon", ic); 109 elm_object_part_content_set(rd, "icon", ic);
108 elm_object_disabled_set(rd, EINA_TRUE); 110 elm_object_disabled_set(rd, EINA_TRUE);
109 elm_box_pack_end(bx, rd); 111 elm_box_pack_end(bx2, rd);
110 evas_object_show(rd); 112 evas_object_show(rd);
111 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, NULL); 113 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, NULL);
112 114
113 elm_radio_value_set(rdg, 2); 115 elm_radio_value_set(rdg, 2);
116}
117
118static void
119_group_2_create(Evas_Object *bx)
120{
121 Evas_Object *bx2, *fr, *rd, *rdg;
122
123 fr = elm_frame_add(bx);
124 elm_object_text_set(fr, "Radio Group 2");
125 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
126 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
127 elm_box_pack_end(bx, fr);
128 evas_object_show(fr);
129
130 bx2 = elm_box_add(fr);
131 elm_object_content_set(fr, bx2);
132 elm_box_align_set(bx2, 0.0, 0.0);
133 evas_object_show(bx2);
134
135 // radio 1
136 rd = elm_radio_add(bx2);
137 elm_radio_state_value_set(rd, 1);
138 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, 0.0);
139 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, 0.5);
140 elm_object_text_set(rd, "Radio Group Test #1");
141 elm_box_pack_end(bx2, rd);
142 evas_object_show(rd);
143
144 // rdg radio group
145 rdg = rd;
146 // this works only for the first radio object
147 evas_object_smart_callback_add(rdg, "changed", _rdg_changed_cb, NULL);
148
149 // radio 2
150 rd = elm_radio_add(bx2);
151 elm_radio_state_value_set(rd, 2);
152 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, 0.0);
153 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, 0.5);
154 elm_object_text_set(rd, "Radio Group Test #2");
155 elm_radio_group_add(rd, rdg);
156 elm_box_pack_end(bx2, rd);
157 evas_object_show(rd);
158
159 // radio 2
160 rd = elm_radio_add(bx2);
161 elm_radio_state_value_set(rd, 3);
162 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, 0.0);
163 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, 0.5);
164 elm_object_text_set(rd, "Radio Group Test #3");
165 elm_radio_group_add(rd, rdg);
166 elm_box_pack_end(bx2, rd);
167 evas_object_show(rd);
168}
169
170void
171test_radio(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
172 void *event_info EINA_UNUSED)
173{
174 Evas_Object *win, *bx;
175
176 win = elm_win_util_standard_add("radios", "Radios");
177 elm_win_autodel_set(win, EINA_TRUE);
178
179 bx = elm_box_add(win);
180 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
181 elm_win_resize_object_add(win, bx);
182 elm_box_horizontal_set(bx, EINA_TRUE);
183 evas_object_show(bx);
184
185 _group_1_create(bx);
186 _group_2_create(bx);
114 187
115 evas_object_show(win); 188 evas_object_show(win);
116} 189}