summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorcnook <kimcinoo@gmail.com>2012-03-19 06:57:39 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-03-19 06:57:39 +0000
commit4c6524af576b4b684397e6da020d4693a5445c00 (patch)
tree58898347c13ee838c18617ed3acc733013ef1551 /src/bin
parent0b1b48bc21702dcfcea55e68d5e583f75bb8fc60 (diff)
From: cnook <kimcinoo@gmail.com>
Subject: [E-devel] [Patch][elementary_test] test_layout I have attached a patch for test_layout. Please review this and give any feedbacks. Thanks. SVN revision: 69501
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/test.c2
-rw-r--r--src/bin/test_layout.c180
2 files changed, 182 insertions, 0 deletions
diff --git a/src/bin/test.c b/src/bin/test.c
index d967c4594..699f6d47f 100644
--- a/src/bin/test.c
+++ b/src/bin/test.c
@@ -37,6 +37,7 @@ void test_check(void *data, Evas_Object *obj, void *event_info);
37void test_check2(void *data, Evas_Object *obj, void *event_info); 37void test_check2(void *data, Evas_Object *obj, void *event_info);
38void test_radio(void *data, Evas_Object *obj, void *event_info); 38void test_radio(void *data, Evas_Object *obj, void *event_info);
39void test_layout(void *data, Evas_Object *obj, void *event_info); 39void test_layout(void *data, Evas_Object *obj, void *event_info);
40void test_layout2(void *data, Evas_Object *obj, void *event_info);
40void test_hover(void *data, Evas_Object *obj, void *event_info); 41void test_hover(void *data, Evas_Object *obj, void *event_info);
41void test_hover2(void *data, Evas_Object *obj, void *event_info); 42void test_hover2(void *data, Evas_Object *obj, void *event_info);
42void test_entry(void *data, Evas_Object *obj, void *event_info); 43void test_entry(void *data, Evas_Object *obj, void *event_info);
@@ -368,6 +369,7 @@ add_tests:
368 ADD_TEST(NULL, "Containers", "Table 6", test_table6); 369 ADD_TEST(NULL, "Containers", "Table 6", test_table6);
369 ADD_TEST(NULL, "Containers", "Table 7", test_table7); 370 ADD_TEST(NULL, "Containers", "Table 7", test_table7);
370 ADD_TEST(NULL, "Containers", "Layout", test_layout); 371 ADD_TEST(NULL, "Containers", "Layout", test_layout);
372 ADD_TEST(NULL, "Containers", "Layout 2", test_layout2);
371 ADD_TEST(NULL, "Containers", "Grid", test_grid); 373 ADD_TEST(NULL, "Containers", "Grid", test_grid);
372 374
373 //------------------------------// 375 //------------------------------//
diff --git a/src/bin/test_layout.c b/src/bin/test_layout.c
index b4720eba8..8b5248d6c 100644
--- a/src/bin/test_layout.c
+++ b/src/bin/test_layout.c
@@ -5,6 +5,29 @@
5#ifndef ELM_LIB_QUICKLAUNCH 5#ifndef ELM_LIB_QUICKLAUNCH
6#include <Elementary_Cursor.h> 6#include <Elementary_Cursor.h>
7 7
8struct _api_data
9{
10 unsigned int state; /* What state we are testing */
11 Evas_Object *box_layout;
12 Evas_Object *table_layout;
13 Evas_Object *ref;
14 Evas_Object *ref2;
15};
16typedef struct _api_data api_data;
17
18enum _api_state
19{
20 LAYOUT_BOX_INSERT_AT,
21 LAYOUT_BOX_INSERT_BEFORE,
22 LAYOUT_BOX_PREPEND,
23 LAYOUT_BOX_REMOVE,
24 LAYOUT_BOX_REMOVE_ALL,
25 LAYOUT_TABLE_UNPACK,
26 LAYOUT_TABLE_CLEAR,
27 API_STATE_LAST
28};
29
30typedef enum _api_state api_state;
8static void 31static void
9_clicked_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__) 32_clicked_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
10{ 33{
@@ -80,4 +103,161 @@ test_layout(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
80 103
81 evas_object_show(win); 104 evas_object_show(win);
82} 105}
106
107static void
108set_api_state(api_data *api)
109{
110 Evas_Object *box_layout = api->box_layout;
111 Evas_Object *table_layout = api->table_layout;
112 Evas_Object *obj;
113
114 /* use elm_box_children_get() to get list of children */
115 switch (api->state)
116 { /* Put all api-changes under switch */
117 case LAYOUT_BOX_INSERT_AT:
118 {
119 obj = elm_label_add(box_layout);
120 elm_object_text_set(obj, "elm_layout_box_insert_at(); is called");
121 evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND,
122 EVAS_HINT_EXPAND);
123 elm_layout_box_insert_at(box_layout, "elm.box.content", obj, 0);
124 evas_object_show(obj);
125 break;
126 }
127
128 case LAYOUT_BOX_INSERT_BEFORE:
129 {
130 obj = elm_label_add(box_layout);
131 elm_object_text_set(obj, "elm_layout_box_insert_before(); is called");
132 evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND,
133 EVAS_HINT_EXPAND);
134 elm_layout_box_insert_before(box_layout, "elm.box.content",
135 obj, api->ref);
136 evas_object_show(obj);
137 break;
138 }
139
140 case LAYOUT_BOX_PREPEND:
141 {
142 obj = elm_label_add(box_layout);
143 elm_object_text_set(obj, "elm_layout_box_prepend(); is called");
144 evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND,
145 EVAS_HINT_EXPAND);
146 elm_layout_box_prepend(box_layout, "elm.box.content", obj);
147 evas_object_show(obj);
148 break;
149 }
150
151 case LAYOUT_BOX_REMOVE:
152 {
153 elm_layout_box_remove(box_layout, "elm.box.content", api->ref);
154 evas_object_del(api->ref);
155 break;
156 }
157
158 case LAYOUT_BOX_REMOVE_ALL:
159 {
160 elm_layout_box_remove_all(box_layout, "elm.box.content", EINA_TRUE);
161 break;
162 }
163
164 case LAYOUT_TABLE_UNPACK:
165 {
166 elm_layout_table_unpack(table_layout, "elm.table.content", api->ref2);
167 evas_object_del(api->ref2);
168 break;
169 }
170
171 case LAYOUT_TABLE_CLEAR:
172 {
173 elm_layout_table_clear(table_layout, "elm.table.content", EINA_TRUE);
174 break;
175 }
176
177 default: return;
178 }
179}
180
181static void
182_api_bt_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
183{ /* Will add here a SWITCH command containing code to modify test-object */
184 /* in accordance a->state value. */
185 api_data *a = data;
186 char str[128];
187
188 printf("clicked event on API Button: api_state=<%d>\n", a->state);
189 set_api_state(a);
190 a->state++;
191 sprintf(str, "Next API function (%u)", a->state);
192 elm_object_text_set(obj, str);
193 elm_object_disabled_set(obj, a->state == API_STATE_LAST);
194}
195
196static void
197_cleanup_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
198{
199 free(data);
200}
201
202void
203test_layout2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
204{
205 Evas_Object *win, *box, *bt, *ly, *lb;
206 api_data *api = calloc(1, sizeof(api_data));
207
208 win = elm_win_util_standard_add("layout2", "Layout 2");
209 elm_win_autodel_set(win, EINA_TRUE);
210 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
211
212 box = elm_box_add(win);
213 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
214 elm_win_resize_object_add(win, box);
215 evas_object_show(box);
216
217 bt = elm_button_add(win);
218 elm_object_text_set(bt, "Next API function");
219 evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked,
220 (void *)api);
221 elm_box_pack_end(box, bt);
222 elm_object_disabled_set(bt, api->state == API_STATE_LAST);
223 evas_object_show(bt);
224
225 /* Layout Box Test */
226 api->box_layout = ly = elm_layout_add(win);
227 elm_layout_theme_set(ly, "layout", "application", "toolbar-vbox");
228 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
229 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
230 elm_box_pack_end(box, ly);
231 evas_object_show(ly);
232
233 api->ref = lb = elm_label_add(win);
234 elm_object_text_set(lb, "This is a label for the box content");
235 evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
236 evas_object_show(lb);
237
238 elm_layout_box_append(ly, "elm.box.content", lb);
239
240 /* Layout Table Test */
241 api->table_layout = ly = elm_layout_add(win);
242 elm_layout_theme_set(ly, "layout", "application", "toolbar-table");
243 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
244 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
245 elm_box_pack_end(box, ly);
246 evas_object_show(ly);
247
248 lb = elm_label_add(win);
249 elm_object_text_set(lb, "This is a label for the table content");
250 evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
251 evas_object_show(lb);
252 elm_layout_table_pack(ly, "elm.table.content", lb, 0, 0, 1, 1);
253
254 api->ref2 = lb = elm_label_add(win);
255 elm_object_text_set(lb, "col = 0, row = 1");
256 evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
257 evas_object_show(lb);
258 elm_layout_table_pack(ly, "elm.table.content", lb, 0, 1, 1, 1);
259
260 evas_object_resize(win, 320, 320);
261 evas_object_show(win);
262}
83#endif 263#endif