svn update: 48945 (latest:48959)
[framework/uifw/elementary.git] / src / bin / test_launcher.c
1 #include <Elementary.h>
2 #ifndef ELM_LIB_QUICKLAUNCH
3
4 static void
5 mode_cb(void *data, Evas_Object *obj, void *event_info)
6 {
7    Evas_Object *win = data;
8    Evas_Object *mb;
9    Eina_List *mbs, *l;
10    
11    mbs = evas_object_data_get(win, "mbs");
12    EINA_LIST_FOREACH(mbs, l, mb)
13      {
14         if (elm_mapbuf_enabled_get(mb))
15           elm_mapbuf_enabled_set(mb, 0);
16         else
17           elm_mapbuf_enabled_set(mb, 1);
18      }
19 }
20
21 static void
22 full_cb(void *data, Evas_Object *obj, void *event_info)
23 {
24    Evas_Object *win = data;
25    elm_win_fullscreen_set(win, !elm_win_fullscreen_get(win));
26 }
27
28 static void
29 alpha_cb(void *data, Evas_Object *obj, void *event_info)
30 {
31    Evas_Object *win = data;
32    Evas_Object *mb;
33    Eina_List *mbs, *l;
34    
35    mbs = evas_object_data_get(win, "mbs");
36    EINA_LIST_FOREACH(mbs, l, mb)
37      {
38         elm_mapbuf_alpha_set(mb, elm_check_state_get(obj));
39      }
40 }
41
42 static void
43 smooth_cb(void *data, Evas_Object *obj, void *event_info)
44 {
45    Evas_Object *win = data;
46    Evas_Object *mb;
47    Eina_List *mbs, *l;
48    
49    mbs = evas_object_data_get(win, "mbs");
50    EINA_LIST_FOREACH(mbs, l, mb)
51      {
52         elm_mapbuf_smooth_set(mb, elm_check_state_get(obj));
53      }
54 }
55
56 static void
57 close_cb(void *data, Evas_Object *obj, void *event_info)
58 {
59    evas_object_del(data);
60 }
61
62 static void
63 ic_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
64 {
65    evas_object_color_set(data, 128, 0, 0, 128);
66 }
67
68 static void
69 ic_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
70 {
71    evas_object_color_set(data, 255, 255, 255, 255);
72 }
73
74 void
75 test_launcher(void *data, Evas_Object *obj, void *event_info)
76 {
77    Evas_Object *win, *bg, *sc, *tb, *pad, *bt, *ic, *lb, *tb2, *mb, *ck, *bx, *rc;
78    int i, j, k, n, m;
79    char buf[PATH_MAX];
80    const char *names[] =
81      {
82         "Hello",    "World",    "Spam",  "Egg", 
83         "Ham",      "Good",     "Bad",   "Milk", 
84         "Smell",    "Of",       "Sky",   "Gold",
85         "Hole",     "Pig",      "And",   "Calm"
86      };
87    Eina_List *mbs = NULL;
88    
89    win = elm_win_add(NULL, "launcher", ELM_WIN_BASIC);
90    elm_win_title_set(win, "Launcher");
91    elm_win_autodel_set(win, 1);
92
93    bg = elm_bg_add(win);
94    snprintf(buf, sizeof(buf), "%s/images/sky_04.jpg", PACKAGE_DATA_DIR);
95    elm_bg_file_set(bg, buf, NULL);
96    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
97    elm_win_resize_object_add(win, bg);
98    evas_object_show(bg);
99    
100    bx = elm_box_add(win);
101    elm_box_homogenous_set(bx, 1);
102    elm_box_horizontal_set(bx, 1);
103    
104    n = 0; m = 0;
105    for (k = 0 ; k < 8; k++)
106      {
107         tb = elm_table_add(win);
108         evas_object_size_hint_weight_set(tb, 0.0, 0.0);
109         evas_object_size_hint_align_set(tb, 0.5, 0.5);
110
111         pad = evas_object_rectangle_add(evas_object_evas_get(win));
112         evas_object_size_hint_min_set(pad, 470, 4);
113         evas_object_size_hint_weight_set(pad, 0.0, 0.0);
114         evas_object_size_hint_align_set(pad, EVAS_HINT_FILL, EVAS_HINT_FILL);
115         elm_table_pack(tb, pad, 1, 0, 5, 1);
116         
117         pad = evas_object_rectangle_add(evas_object_evas_get(win));
118         evas_object_size_hint_min_set(pad, 470, 4);
119         evas_object_size_hint_weight_set(pad, 0.0, 0.0);
120         evas_object_size_hint_align_set(pad, EVAS_HINT_FILL, EVAS_HINT_FILL);
121         elm_table_pack(tb, pad, 1, 11, 5, 1);
122         
123         pad = evas_object_rectangle_add(evas_object_evas_get(win));
124         evas_object_size_hint_min_set(pad, 4, 4);
125         evas_object_size_hint_weight_set(pad, 0.0, 0.0);
126         evas_object_size_hint_align_set(pad, EVAS_HINT_FILL, EVAS_HINT_FILL);
127         elm_table_pack(tb, pad, 0, 1, 1, 10);
128         
129         pad = evas_object_rectangle_add(evas_object_evas_get(win));
130         evas_object_size_hint_min_set(pad, 4, 4);
131         evas_object_size_hint_weight_set(pad, 0.0, 0.0);
132         evas_object_size_hint_align_set(pad, EVAS_HINT_FILL, EVAS_HINT_FILL);
133         elm_table_pack(tb, pad, 6, 1, 1, 10);
134
135         for (j = 0; j < 5; j++)
136           {
137              for (i = 0; i < 5; i++)
138                {
139                   ic = elm_icon_add(win);
140                   elm_object_scale_set(ic, 0.5);
141                   snprintf(buf, sizeof(buf), "%s/images/icon_%02i.png", PACKAGE_DATA_DIR, n);
142                   elm_icon_file_set(ic, buf, NULL);
143                   elm_icon_scale_set(ic, 0, 0);
144                   evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
145                   evas_object_size_hint_align_set(ic, 0.5, 0.5);
146                   elm_table_pack(tb, ic, 1 + i, 1 + (j * 2), 1, 1);
147                   evas_object_show(ic);
148                   
149                   lb = elm_label_add(win);
150                   elm_object_style_set(lb, "marker");
151                   elm_label_label_set(lb, names[m]);
152                   evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
153                   evas_object_size_hint_align_set(lb, 0.5, 0.5);
154                   elm_table_pack(tb, lb, 1 + i, 1 + (j * 2) + 1, 1, 1);
155                   evas_object_show(lb);
156                   
157                   rc = evas_object_rectangle_add(evas_object_evas_get(win));
158                   evas_object_color_set(rc, 0, 0, 0, 0);
159                   evas_object_size_hint_weight_set(rc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
160                   evas_object_size_hint_align_set(rc, EVAS_HINT_FILL, EVAS_HINT_FILL);
161                   elm_table_pack(tb, rc, 1 + i, 1 + (j * 2), 1, 2);
162                   evas_object_show(rc);
163                   
164                   evas_object_event_callback_add(rc, EVAS_CALLBACK_MOUSE_DOWN, ic_down_cb, lb);
165                   evas_object_event_callback_add(rc, EVAS_CALLBACK_MOUSE_UP,   ic_up_cb,   lb);
166                   
167                   evas_object_event_callback_add(rc, EVAS_CALLBACK_MOUSE_DOWN, ic_down_cb, ic);
168                   evas_object_event_callback_add(rc, EVAS_CALLBACK_MOUSE_UP,   ic_up_cb,   ic);
169                   
170                   n++; if (n > 23) n = 0;
171                   m++; if (m > 15) m = 0;
172                }
173           }
174         mb = elm_mapbuf_add(win);
175         elm_mapbuf_content_set(mb, tb);
176         evas_object_show(tb);
177         
178         elm_box_pack_end(bx, mb);
179         evas_object_show(mb);
180         
181         mbs = eina_list_append(mbs, mb);
182      }
183
184    // fixme: free mbs
185    evas_object_data_set(win, "mbs", mbs);
186    
187    sc = elm_scroller_add(win);
188    elm_scroller_bounce_set(sc, 1, 0);
189    elm_scroller_policy_set(sc, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
190    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
191    elm_win_resize_object_add(win, sc);
192    
193    elm_scroller_content_set(sc, bx);
194    evas_object_show(bx);
195    
196    elm_scroller_page_relative_set(sc, 1.0, 1.0);
197    evas_object_show(sc);
198
199    tb2 = elm_table_add(win);
200    evas_object_size_hint_weight_set(tb2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
201    elm_win_resize_object_add(win, tb2);
202    
203    ck = elm_check_add(win);
204    elm_check_label_set(ck, "Map");
205    elm_check_state_set(ck, 0);
206    evas_object_smart_callback_add(ck, "changed", mode_cb, win);
207    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
208    evas_object_size_hint_align_set(ck, 0.05, 0.99);
209    elm_table_pack(tb2, ck, 0, 0, 1, 1);
210    evas_object_show(ck);
211    
212    ck = elm_check_add(win);
213    elm_check_label_set(ck, "A");
214    elm_check_state_set(ck, 1);
215    evas_object_smart_callback_add(ck, "changed", alpha_cb, win);
216    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
217    evas_object_size_hint_align_set(ck, 0.20, 0.99);
218    elm_table_pack(tb2, ck, 1, 0, 1, 1);
219    evas_object_show(ck);
220    
221    ck = elm_check_add(win);
222    elm_check_label_set(ck, "Smo");
223    elm_check_state_set(ck, 1);
224    evas_object_smart_callback_add(ck, "changed", smooth_cb, win);
225    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
226    evas_object_size_hint_align_set(ck, 0.40, 0.99);
227    elm_table_pack(tb2, ck, 2, 0, 1, 1);
228    evas_object_show(ck);
229    
230    ck = elm_check_add(win);
231    elm_check_label_set(ck, "FS");
232    elm_check_state_set(ck, 0);
233    evas_object_smart_callback_add(ck, "changed", full_cb, win);
234    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
235    evas_object_size_hint_align_set(ck, 0.5, 0.99);
236    elm_table_pack(tb2, ck, 3, 0, 1, 1);
237    evas_object_show(ck);
238    
239    bt = elm_button_add(win);
240    elm_button_label_set(bt, "Close");
241    evas_object_smart_callback_add(bt, "clicked", close_cb, win);
242    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
243    evas_object_size_hint_align_set(bt, 0.95, 0.99);
244    elm_table_pack(tb2, bt, 4, 0, 1, 1);
245    evas_object_show(bt);
246    
247    evas_object_show(tb2);
248
249    evas_object_resize(win, 480, 800);
250    evas_object_show(win);
251 }
252
253 void
254 test_launcher2(void *data, Evas_Object *obj, void *event_info)
255 {
256    Evas_Object *win, *bg, *sc, *tb, *pad, *bt, *ic, *lb, *tb2, *mb, *ck, *bx, *rc, *ly;
257    int i, j, k, n, m;
258    char buf[PATH_MAX];
259    Eina_List *mbs = NULL;
260    
261    win = elm_win_add(NULL, "launcher", ELM_WIN_BASIC);
262    elm_win_title_set(win, "Launcher");
263    elm_win_autodel_set(win, 1);
264
265    bg = elm_bg_add(win);
266    snprintf(buf, sizeof(buf), "%s/images/sky_03.jpg", PACKAGE_DATA_DIR);
267    elm_bg_file_set(bg, buf, NULL);
268    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
269    elm_win_resize_object_add(win, bg);
270    evas_object_show(bg);
271    
272    bx = elm_box_add(win);
273    elm_box_homogenous_set(bx, 1);
274    elm_box_horizontal_set(bx, 1);
275    
276    for (k = 0 ; k < 8; k++)
277      {
278         ly = elm_layout_add(win);
279         snprintf(buf, sizeof(buf), "%s/objects/test.edj", PACKAGE_DATA_DIR);
280         elm_layout_file_set(ly, buf, "layout");
281         evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
282         
283         bt = elm_button_add(win);
284         elm_button_label_set(bt, "Button 1");
285         elm_layout_content_set(ly, "element1", bt);
286         evas_object_show(bt);
287         
288         bt = elm_button_add(win);
289         elm_button_label_set(bt, "Button 2");
290         elm_layout_content_set(ly, "element2", bt);
291         evas_object_show(bt);
292         
293         bt = elm_button_add(win);
294         elm_button_label_set(bt, "Button 3");
295         elm_layout_content_set(ly, "element3", bt);
296         evas_object_show(bt);
297         
298         mb = elm_mapbuf_add(win);
299         elm_mapbuf_content_set(mb, ly);
300         evas_object_show(ly);
301         
302         elm_box_pack_end(bx, mb);
303         evas_object_show(mb);
304         
305         mbs = eina_list_append(mbs, mb);
306      }
307
308    // fixme: free mbs
309    evas_object_data_set(win, "mbs", mbs);
310    
311    sc = elm_scroller_add(win);
312    elm_scroller_bounce_set(sc, 1, 0);
313    elm_scroller_policy_set(sc, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
314    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
315    elm_win_resize_object_add(win, sc);
316    
317    elm_scroller_content_set(sc, bx);
318    evas_object_show(bx);
319    
320    elm_scroller_page_relative_set(sc, 1.0, 1.0);
321    evas_object_show(sc);
322
323    tb2 = elm_table_add(win);
324    evas_object_size_hint_weight_set(tb2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
325    elm_win_resize_object_add(win, tb2);
326    
327    ck = elm_check_add(win);
328    elm_check_label_set(ck, "Map");
329    elm_check_state_set(ck, 0);
330    evas_object_smart_callback_add(ck, "changed", mode_cb, win);
331    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
332    evas_object_size_hint_align_set(ck, 0.05, 0.99);
333    elm_table_pack(tb2, ck, 0, 0, 1, 1);
334    evas_object_show(ck);
335    
336    ck = elm_check_add(win);
337    elm_check_label_set(ck, "A");
338    elm_check_state_set(ck, 1);
339    evas_object_smart_callback_add(ck, "changed", alpha_cb, win);
340    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
341    evas_object_size_hint_align_set(ck, 0.20, 0.99);
342    elm_table_pack(tb2, ck, 1, 0, 1, 1);
343    evas_object_show(ck);
344    
345    ck = elm_check_add(win);
346    elm_check_label_set(ck, "Smo");
347    elm_check_state_set(ck, 1);
348    evas_object_smart_callback_add(ck, "changed", smooth_cb, win);
349    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
350    evas_object_size_hint_align_set(ck, 0.40, 0.99);
351    elm_table_pack(tb2, ck, 2, 0, 1, 1);
352    evas_object_show(ck);
353    
354    ck = elm_check_add(win);
355    elm_check_label_set(ck, "FS");
356    elm_check_state_set(ck, 0);
357    evas_object_smart_callback_add(ck, "changed", full_cb, win);
358    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
359    evas_object_size_hint_align_set(ck, 0.5, 0.99);
360    elm_table_pack(tb2, ck, 3, 0, 1, 1);
361    evas_object_show(ck);
362    
363    bt = elm_button_add(win);
364    elm_button_label_set(bt, "Close");
365    evas_object_smart_callback_add(bt, "clicked", close_cb, win);
366    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
367    evas_object_size_hint_align_set(bt, 0.95, 0.99);
368    elm_table_pack(tb2, bt, 4, 0, 1, 1);
369    evas_object_show(bt);
370    
371    evas_object_show(tb2);
372
373    evas_object_resize(win, 480, 800);
374    evas_object_show(win);
375 }
376 #endif