elm test_box.c: Used elm_bg_load_size_set. Patch by cnook
[framework/uifw/elementary.git] / src / bin / test_table.c
1 #include <Elementary.h>
2 #ifdef HAVE_CONFIG_H
3 # include "elementary_config.h"
4 #endif
5 #ifndef ELM_LIB_QUICKLAUNCH
6 void
7 test_table(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
8 {
9    Evas_Object *win, *bg, *tb, *bt;
10
11    win = elm_win_add(NULL, "table", ELM_WIN_BASIC);
12    elm_win_title_set(win, "Table");
13    elm_win_autodel_set(win, EINA_TRUE);
14
15    bg = elm_bg_add(win);
16    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
17    elm_win_resize_object_add(win, bg);
18    evas_object_show(bg);
19
20    tb = elm_table_add(win);
21    elm_win_resize_object_add(win, tb);
22    evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
23    evas_object_show(tb);
24
25    bt = elm_button_add(win);
26    elm_object_text_set(bt, "Button 1");
27    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
28    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
29    elm_table_pack(tb, bt, 0, 0, 1, 1);
30    evas_object_show(bt);
31
32    bt = elm_button_add(win);
33    elm_object_text_set(bt, "Button 2");
34    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
35    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
36    elm_table_pack(tb, bt, 1, 0, 1, 1);
37    evas_object_show(bt);
38
39    bt = elm_button_add(win);
40    elm_object_text_set(bt, "Button 3");
41    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
42    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
43    elm_table_pack(tb, bt, 2, 0, 1, 1);
44    evas_object_show(bt);
45
46    bt = elm_button_add(win);
47    elm_object_text_set(bt, "Button 4");
48    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
49    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
50    elm_table_pack(tb, bt, 0, 1, 2, 1);
51    evas_object_show(bt);
52
53    bt = elm_button_add(win);
54    elm_object_text_set(bt, "Button 5");
55    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
56    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
57    elm_table_pack(tb, bt, 2, 1, 1, 2);
58    evas_object_show(bt);
59
60    bt = elm_button_add(win);
61    elm_object_text_set(bt, "Button a");
62    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
63    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
64    elm_table_pack(tb, bt, 0, 2, 2, 1);
65    evas_object_show(bt);
66
67    evas_object_show(win);
68 }
69
70 void
71 test_table2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
72 {
73    Evas_Object *win, *bg, *tb, *bt;
74
75    win = elm_win_add(NULL, "table2", ELM_WIN_BASIC);
76    elm_win_title_set(win, "Table Homogeneous");
77    elm_win_autodel_set(win, EINA_TRUE);
78
79    bg = elm_bg_add(win);
80    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
81    elm_win_resize_object_add(win, bg);
82    evas_object_show(bg);
83
84    tb = elm_table_add(win);
85    elm_table_homogeneous_set(tb, EINA_TRUE);
86    elm_win_resize_object_add(win, tb);
87    evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
88    evas_object_show(tb);
89
90    bt = elm_button_add(win);
91    elm_object_text_set(bt, "A");
92    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
93    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
94    elm_table_pack(tb, bt, 1, 1, 2, 2);
95    evas_object_show(bt);
96
97    bt = elm_button_add(win);
98    elm_object_text_set(bt, "Blah blah blah");
99    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
100    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
101    elm_table_pack(tb, bt, 3, 0, 2, 3);
102    evas_object_show(bt);
103
104    bt = elm_button_add(win);
105    elm_object_text_set(bt, "Hallow");
106    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
107    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
108    elm_table_pack(tb, bt, 0, 3, 10, 1);
109    evas_object_show(bt);
110
111    bt = elm_button_add(win);
112    elm_object_text_set(bt, "B");
113    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
114    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
115    elm_table_pack(tb, bt, 2, 5, 2, 1);
116    evas_object_show(bt);
117
118    bt = elm_button_add(win);
119    elm_object_text_set(bt, "C");
120    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
121    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
122    elm_table_pack(tb, bt, 8, 8, 1, 1);
123    evas_object_show(bt);
124
125    bt = elm_button_add(win);
126    elm_object_text_set(bt, "Wide");
127    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
128    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
129    elm_table_pack(tb, bt, 1, 7, 7, 2);
130    evas_object_show(bt);
131
132    evas_object_show(win);
133 }
134
135 static void
136 my_tb_ch(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
137 {
138    Evas_Object *win = data;
139    Evas_Object *tb = evas_object_data_get(win, "tb");
140    Evas_Object *b2 = evas_object_data_get(win, "b2");
141
142    elm_table_unpack(tb, b2);
143    elm_table_pack(tb, b2, 1, 0, 1, 2);
144 }
145
146 void
147 test_table3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
148 {
149    Evas_Object *win, *bg, *tb, *bt;
150
151    win = elm_win_add(NULL, "table3", ELM_WIN_BASIC);
152    elm_win_title_set(win, "Table 3");
153    elm_win_autodel_set(win, EINA_TRUE);
154
155    bg = elm_bg_add(win);
156    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
157    elm_win_resize_object_add(win, bg);
158    evas_object_show(bg);
159
160    tb = elm_table_add(win);
161    elm_win_resize_object_add(win, tb);
162    evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
163    evas_object_data_set(win, "tb", tb);
164    evas_object_show(tb);
165
166    bt = elm_button_add(win);
167    elm_object_text_set(bt, "Button 1");
168    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
169    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
170    elm_table_pack(tb, bt, 0, 0, 1, 1);
171    evas_object_data_set(win, "b1", bt);
172    evas_object_smart_callback_add(bt, "clicked", my_tb_ch, win);
173    evas_object_show(bt);
174
175    bt = elm_button_add(win);
176    elm_object_text_set(bt, "Button 2");
177    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
178    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
179    elm_table_pack(tb, bt, 1, 0, 1, 1);
180    evas_object_data_set(win, "b2", bt);
181    evas_object_smart_callback_add(bt, "clicked", my_tb_ch, win);
182    evas_object_show(bt);
183
184    bt = elm_button_add(win);
185    elm_object_text_set(bt, "Button 3");
186    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
187    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
188    elm_table_pack(tb, bt, 0, 1, 1, 1);
189    evas_object_data_set(win, "b3", bt);
190    evas_object_smart_callback_add(bt, "clicked", my_tb_ch, win);
191    evas_object_show(bt);
192
193    evas_object_show(win);
194 }
195
196 void
197 test_table4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
198 {
199    Evas_Object *win, *bg, *tb, *bt;
200
201    win = elm_win_add(NULL, "table4", ELM_WIN_BASIC);
202    elm_win_title_set(win, "Table 4");
203    elm_win_autodel_set(win, EINA_TRUE);
204
205    bg = elm_bg_add(win);
206    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
207    elm_win_resize_object_add(win, bg);
208    evas_object_show(bg);
209
210    tb = elm_table_add(win);
211    elm_win_resize_object_add(win, tb);
212    evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
213    evas_object_data_set(win, "tb", tb);
214    evas_object_show(tb);
215
216    bt = elm_button_add(win);
217    elm_object_text_set(bt, "Button 1");
218    evas_object_size_hint_weight_set(bt, 0.25, 0.25);
219    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
220    elm_table_pack(tb, bt, 0, 0, 1, 1);
221    evas_object_data_set(win, "b1", bt);
222    evas_object_smart_callback_add(bt, "clicked", my_tb_ch, win);
223    evas_object_show(bt);
224
225    bt = elm_button_add(win);
226    elm_object_text_set(bt, "Button 2");
227    evas_object_size_hint_weight_set(bt, 0.75, 0.25);
228    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
229    elm_table_pack(tb, bt, 1, 0, 1, 1);
230    evas_object_data_set(win, "b2", bt);
231    evas_object_smart_callback_add(bt, "clicked", my_tb_ch, win);
232    evas_object_show(bt);
233
234    bt = elm_button_add(win);
235    elm_object_text_set(bt, "Button 3");
236    evas_object_size_hint_weight_set(bt, 0.25, 0.75);
237    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
238    elm_table_pack(tb, bt, 0, 1, 1, 1);
239    evas_object_data_set(win, "b3", bt);
240    evas_object_smart_callback_add(bt, "clicked", my_tb_ch, win);
241    evas_object_show(bt);
242
243    evas_object_show(win);
244 }
245
246 void
247 test_table5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
248 {
249    Evas_Object *win, *bg, *tb, *bt;
250
251    win = elm_win_add(NULL, "table5", ELM_WIN_BASIC);
252    elm_win_title_set(win, "Table 5");
253    elm_win_autodel_set(win, EINA_TRUE);
254
255    bg = elm_bg_add(win);
256    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
257    elm_win_resize_object_add(win, bg);
258    evas_object_show(bg);
259
260    tb = elm_table_add(win);
261    elm_table_homogeneous_set(tb, EINA_TRUE);
262    elm_win_resize_object_add(win, tb);
263    evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
264    evas_object_show(tb);
265
266    bt = elm_button_add(win);
267    elm_object_text_set(bt, "A");
268    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
269    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
270    elm_table_pack(tb, bt, 33, 0, 34, 33);
271    evas_object_show(bt);
272
273    bt = elm_button_add(win);
274    elm_object_text_set(bt, "B");
275    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
276    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
277    elm_table_pack(tb, bt, 67, 33, 33, 34);
278    evas_object_show(bt);
279
280    bt = elm_button_add(win);
281    elm_object_text_set(bt, "C");
282    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
283    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
284    elm_table_pack(tb, bt, 33, 67, 34, 33);
285    evas_object_show(bt);
286
287    bt = elm_button_add(win);
288    elm_object_text_set(bt, "D");
289    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
290    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
291    elm_table_pack(tb, bt, 0, 33, 33, 34);
292    evas_object_show(bt);
293
294    bt = elm_button_add(win);
295    elm_object_text_set(bt, "X");
296    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
297    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
298    elm_table_pack(tb, bt, 33, 33, 34, 34);
299    evas_object_show(bt);
300
301    evas_object_show(win);
302 }
303
304 void
305 test_table6(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
306 {
307    Evas_Object *win, *bg, *tb, *bt;
308
309    win = elm_win_add(NULL, "table6", ELM_WIN_BASIC);
310    elm_win_title_set(win, "Table 6");
311    elm_win_autodel_set(win, EINA_TRUE);
312
313    bg = elm_bg_add(win);
314    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
315    elm_win_resize_object_add(win, bg);
316    evas_object_show(bg);
317
318    tb = elm_table_add(win);
319    elm_table_homogeneous_set(tb, EINA_TRUE);
320    elm_win_resize_object_add(win, tb);
321    evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
322    evas_object_show(tb);
323
324    bt = elm_button_add(win);
325    elm_object_text_set(bt, "C");
326    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
327    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
328    elm_table_pack(tb, bt, 1, 1, 2, 2);
329    evas_object_show(bt);
330
331    bt = elm_button_add(win);
332    elm_object_text_set(bt, "A");
333    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
334    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
335    elm_table_pack(tb, bt, 1, 1, 2, 2);
336    evas_object_show(bt);
337
338    bt = elm_button_add(win);
339    elm_object_text_set(bt, "Blah blah blah");
340    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
341    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
342    elm_table_pack(tb, bt, 3, 0, 2, 3);
343    evas_object_show(bt);
344
345    bt = elm_button_add(win);
346    elm_object_text_set(bt, "Hallow");
347    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
348    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
349    elm_table_pack(tb, bt, 0, 3, 10, 1);
350    evas_object_show(bt);
351
352    bt = elm_button_add(win);
353    elm_object_text_set(bt, "B");
354    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
355    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
356    elm_table_pack(tb, bt, 1, 1, 1, 1);
357    evas_object_show(bt);
358
359    bt = elm_button_add(win);
360    elm_object_text_set(bt, "Wide");
361    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
362    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
363    elm_table_pack(tb, bt, 1, 7, 7, 2);
364    evas_object_show(bt);
365
366    evas_object_show(win);
367 }
368
369 #endif