Elementary migration around 2011/04/06
[framework/uifw/elementary.git] / src / bin / test_launcher.c
1 #include <Elementary.h>
2 #ifdef HAVE_CONFIG_H
3 # include "elementary_config.h"
4 #endif
5 #ifndef ELM_LIB_QUICKLAUNCH
6
7 static void
8 mode_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
9 {
10    Evas_Object *win = data;
11    Evas_Object *mb;
12    Eina_List *mbs, *l;
13    
14    mbs = evas_object_data_get(win, "mbs");
15    EINA_LIST_FOREACH(mbs, l, mb)
16      {
17         if (elm_mapbuf_enabled_get(mb))
18           elm_mapbuf_enabled_set(mb, 0);
19         else
20           elm_mapbuf_enabled_set(mb, 1);
21      }
22 }
23
24 static void
25 full_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
26 {
27    Evas_Object *win = data;
28    elm_win_fullscreen_set(win, !elm_win_fullscreen_get(win));
29 }
30
31 static void
32 alpha_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
33 {
34    Evas_Object *win = data;
35    Evas_Object *mb;
36    Eina_List *mbs, *l;
37    
38    mbs = evas_object_data_get(win, "mbs");
39    EINA_LIST_FOREACH(mbs, l, mb)
40      {
41         elm_mapbuf_alpha_set(mb, elm_check_state_get(obj));
42      }
43 }
44
45 static void
46 smooth_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
47 {
48    Evas_Object *win = data;
49    Evas_Object *mb;
50    Eina_List *mbs, *l;
51    
52    mbs = evas_object_data_get(win, "mbs");
53    EINA_LIST_FOREACH(mbs, l, mb)
54      {
55         elm_mapbuf_smooth_set(mb, elm_check_state_get(obj));
56      }
57 }
58
59 static void
60 close_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
61 {
62    evas_object_del(data);
63 }
64
65 static Eina_Bool
66 tim_cb(void *data)
67 {
68    Evas_Object *tb, *sc, *mb;
69    Eina_List *list, *l;
70    
71    evas_object_data_del(data, "timer");
72    tb = evas_object_data_get(data, "tb");
73    sc = evas_object_data_get(data, "sc");
74    elm_object_scroll_freeze_push(sc);
75    evas_object_data_set(data, "dragging", (void *)(long)(1));
76    evas_object_color_set(data, 255, 255, 255, 255);
77    list = (Eina_List *)evas_object_data_get
78       (elm_object_top_widget_get(data), "mbs");
79    EINA_LIST_FOREACH(list, l, mb)
80       evas_object_color_set(mb, 128, 128, 128, 128);
81    elm_table_unpack(tb, data);
82    return EINA_FALSE;
83 }
84
85 static void
86 ic_del_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
87 {
88    Ecore_Timer *tim;
89    
90    tim = evas_object_data_get(obj, "timer");
91    if (tim)
92      {
93         evas_object_data_del(obj, "timer");
94         ecore_timer_del(tim);
95      }
96 }
97
98 static void
99 ic_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
100 {
101    Evas_Event_Mouse_Down *ev = event_info;
102    Ecore_Timer *tim;
103    Evas_Coord x, y, w, h;
104    
105    evas_object_color_set(data, 128, 0, 0, 128);
106    
107    tim = evas_object_data_get(obj, "timer");
108    if (tim) evas_object_data_del(obj, "timer");
109    tim = ecore_timer_add(1.0, tim_cb, obj);
110    evas_object_data_set(obj, "timer", tim);
111
112    evas_object_geometry_get(data, &x, &y, &w, &h);
113    evas_object_data_set(obj, "x", (void *)(long)(ev->canvas.x));
114    evas_object_data_set(obj, "y", (void *)(long)(ev->canvas.y));
115    evas_object_data_set(obj, "px", (void *)(long)(x));
116    evas_object_data_set(obj, "py", (void *)(long)(y));
117    
118    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
119      {
120         printf("double click %p\n", obj);
121      }
122 }
123
124 static void
125 ic_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
126 {
127    Evas_Event_Mouse_Up *ev = event_info;
128    Ecore_Timer *tim;
129    
130    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
131    evas_object_color_set(data, 255, 255, 255, 255);
132    tim = evas_object_data_get(obj, "timer");
133    if (tim)
134      {
135         evas_object_data_del(obj, "timer");
136         ecore_timer_del(tim);
137      }
138    if (evas_object_data_get(obj, "dragging"))
139      {
140         Evas_Object *tb, *sc, *mb;
141         Eina_List *list, *l;
142         int tbx, tby;
143         
144         evas_object_data_del(obj, "dragging");
145         tb = evas_object_data_get(obj, "tb");
146         sc = evas_object_data_get(obj, "sc");
147         elm_object_scroll_freeze_pop(sc);
148         tbx = (int)(long)evas_object_data_get(obj, "tbx");
149         tby = (int)(long)evas_object_data_get(obj, "tby");
150         elm_table_pack(tb, obj, tbx, tby, 1, 1);
151         list = (Eina_List *)evas_object_data_get
152            (elm_object_top_widget_get(obj), "mbs");
153         EINA_LIST_FOREACH(list, l, mb)
154            evas_object_color_set(mb, 255, 255, 255, 255);
155      }
156 }
157
158 static void
159 ic_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
160 {
161    Evas_Event_Mouse_Move *ev = event_info;
162    if (evas_object_data_get(obj, "dragging"))
163      {
164         Evas_Coord x, y, px, py;
165         
166         x = (Evas_Coord)(long)evas_object_data_get(obj, "x");
167         y = (Evas_Coord)(long)evas_object_data_get(obj, "y");
168         px = (Evas_Coord)(long)evas_object_data_get(obj, "px");
169         py = (Evas_Coord)(long)evas_object_data_get(obj, "py");
170         evas_object_move(obj, 
171                          px + ev->cur.canvas.x - x, 
172                          py + ev->cur.canvas.y - y);
173     }
174    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
175      {
176         Ecore_Timer *tim;
177         
178         tim = evas_object_data_get(obj, "timer");
179         if (tim)
180           {
181              evas_object_data_del(obj, "timer");
182              ecore_timer_del(tim);
183           }
184         evas_object_color_set(data, 255, 255, 255, 255);
185         return;
186      }
187 }
188
189 void
190 test_launcher(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
191 {
192    Evas_Object *win, *bg, *sc, *tb, *pad, *bt, *ic, *lb, *tb2, *mb, *ck, *bx, *bx2;
193    int i, j, k, n, m;
194    char buf[PATH_MAX];
195    const char *names[] =
196      {
197         "Hello",    "World",    "Spam",  "Egg", 
198         "Ham",      "Good",     "Bad",   "Milk", 
199         "Smell",    "Of",       "Sky",   "Gold",
200         "Hole",     "Pig",      "And",   "Calm"
201      };
202    Eina_List *mbs = NULL;
203    
204    win = elm_win_add(NULL, "launcher", ELM_WIN_BASIC);
205    elm_win_title_set(win, "Launcher");
206    elm_win_autodel_set(win, 1);
207
208    bg = elm_bg_add(win);
209    snprintf(buf, sizeof(buf), "%s/images/sky_04.jpg", PACKAGE_DATA_DIR);
210    elm_bg_file_set(bg, buf, NULL);
211    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
212    elm_win_resize_object_add(win, bg);
213    evas_object_show(bg);
214
215    bx = elm_box_add(win);
216    elm_box_homogenous_set(bx, 1);
217    elm_box_horizontal_set(bx, 1);
218    
219    sc = elm_scroller_add(win);
220    elm_scroller_bounce_set(sc, 1, 0);
221    elm_scroller_policy_set(sc, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
222    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
223    evas_object_size_hint_fill_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL);
224    
225    n = 0; m = 0;
226    for (k = 0 ; k < 8; k++)
227      {
228         tb = elm_table_add(win);
229         evas_object_size_hint_weight_set(tb, 0.0, 0.0);
230         evas_object_size_hint_align_set(tb, 0.5, 0.5);
231
232         pad = evas_object_rectangle_add(evas_object_evas_get(win));
233         evas_object_size_hint_min_set(pad, 470, 4);
234         evas_object_size_hint_weight_set(pad, 0.0, 0.0);
235         evas_object_size_hint_align_set(pad, EVAS_HINT_FILL, EVAS_HINT_FILL);
236         elm_table_pack(tb, pad, 1, 0, 5, 1);
237         
238         pad = evas_object_rectangle_add(evas_object_evas_get(win));
239         evas_object_size_hint_min_set(pad, 470, 4);
240         evas_object_size_hint_weight_set(pad, 0.0, 0.0);
241         evas_object_size_hint_align_set(pad, EVAS_HINT_FILL, EVAS_HINT_FILL);
242         elm_table_pack(tb, pad, 1, 11, 5, 1);
243         
244         pad = evas_object_rectangle_add(evas_object_evas_get(win));
245         evas_object_size_hint_min_set(pad, 4, 4);
246         evas_object_size_hint_weight_set(pad, 0.0, 0.0);
247         evas_object_size_hint_align_set(pad, EVAS_HINT_FILL, EVAS_HINT_FILL);
248         elm_table_pack(tb, pad, 0, 1, 1, 10);
249         
250         pad = evas_object_rectangle_add(evas_object_evas_get(win));
251         evas_object_size_hint_min_set(pad, 4, 4);
252         evas_object_size_hint_weight_set(pad, 0.0, 0.0);
253         evas_object_size_hint_align_set(pad, EVAS_HINT_FILL, EVAS_HINT_FILL);
254         elm_table_pack(tb, pad, 6, 1, 1, 10);
255
256         mb = elm_mapbuf_add(win);
257         elm_mapbuf_content_set(mb, tb);
258         evas_object_show(tb);
259         
260         for (j = 0; j < 5; j++)
261           {
262              for (i = 0; i < 5; i++)
263                {
264                   ic = elm_icon_add(win);
265                   elm_object_scale_set(ic, 0.5);
266                   snprintf(buf, sizeof(buf), "%s/images/icon_%02i.png", PACKAGE_DATA_DIR, n);
267                   elm_icon_file_set(ic, buf, NULL);
268                   elm_icon_scale_set(ic, 0, 0);
269                   evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
270                   evas_object_size_hint_align_set(ic, 0.5, 0.5);
271                   elm_table_pack(tb, ic, 1 + i, 1 + (j * 2), 1, 1);
272                   evas_object_show(ic);
273                   
274                   lb = elm_label_add(win);
275                   elm_object_style_set(lb, "marker");
276                   elm_label_label_set(lb, names[m]);
277                   evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
278                   evas_object_size_hint_align_set(lb, 0.5, 0.5);
279                   elm_table_pack(tb, lb, 1 + i, 1 + (j * 2) + 1, 1, 1);
280                   evas_object_show(lb);
281                   
282                   evas_object_event_callback_add(ic, EVAS_CALLBACK_DEL, ic_del_cb, ic);
283                   
284                   evas_object_event_callback_add(ic, EVAS_CALLBACK_MOUSE_DOWN, ic_down_cb, ic);
285                   evas_object_event_callback_add(ic, EVAS_CALLBACK_MOUSE_UP,   ic_up_cb,   ic);
286                   evas_object_event_callback_add(ic, EVAS_CALLBACK_MOUSE_MOVE, ic_move_cb, ic);
287                   
288                   evas_object_data_set(ic, "lb", lb);
289                   evas_object_data_set(ic, "tb", tb);
290                   evas_object_data_set(ic, "sc", sc);
291                   evas_object_data_set(ic, "bx", bx);
292                   evas_object_data_set(ic, "mb", mb);
293                   evas_object_data_set(ic, "tbx", (void *)(long)(1 + i));
294                   evas_object_data_set(ic, "tby", (void *)(long)(1 + (j * 2)));
295                   
296                   n++; if (n > 23) n = 0;
297                   m++; if (m > 15) m = 0;
298                }
299           }
300         
301         elm_box_pack_end(bx, mb);
302         evas_object_show(mb);
303         
304         mbs = eina_list_append(mbs, mb);
305      }
306
307    // fixme: free mbs
308    evas_object_data_set(win, "mbs", mbs);
309    
310    bx2 = elm_box_add(win);
311    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
312    elm_box_horizontal_set(bx2, 0);
313    elm_win_resize_object_add(win, bx2);
314    evas_object_show(bx2);
315    
316    elm_scroller_content_set(sc, bx);
317    evas_object_show(bx);
318    
319    elm_scroller_page_relative_set(sc, 1.0, 1.0);
320    evas_object_show(sc);
321
322    tb2 = elm_table_add(win);
323    evas_object_size_hint_weight_set(tb2, EVAS_HINT_EXPAND, 0.0);
324    evas_object_size_hint_fill_set(tb2, EVAS_HINT_FILL, EVAS_HINT_FILL);
325    elm_box_pack_end(bx2, tb2);
326
327    elm_box_pack_end(bx2, sc);
328    
329    ck = elm_check_add(win);
330    elm_check_label_set(ck, "Map");
331    elm_check_state_set(ck, 0);
332    evas_object_smart_callback_add(ck, "changed", mode_cb, win);
333    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
334    evas_object_size_hint_align_set(ck, 0.05, 0.99);
335    elm_table_pack(tb2, ck, 0, 0, 1, 1);
336    evas_object_show(ck);
337    
338    ck = elm_check_add(win);
339    elm_check_label_set(ck, "A");
340    elm_check_state_set(ck, 1);
341    evas_object_smart_callback_add(ck, "changed", alpha_cb, win);
342    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
343    evas_object_size_hint_align_set(ck, 0.20, 0.99);
344    elm_table_pack(tb2, ck, 1, 0, 1, 1);
345    evas_object_show(ck);
346    
347    ck = elm_check_add(win);
348    elm_check_label_set(ck, "Smo");
349    elm_check_state_set(ck, 1);
350    evas_object_smart_callback_add(ck, "changed", smooth_cb, win);
351    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
352    evas_object_size_hint_align_set(ck, 0.40, 0.99);
353    elm_table_pack(tb2, ck, 2, 0, 1, 1);
354    evas_object_show(ck);
355    
356    ck = elm_check_add(win);
357    elm_check_label_set(ck, "FS");
358    elm_check_state_set(ck, 0);
359    evas_object_smart_callback_add(ck, "changed", full_cb, win);
360    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
361    evas_object_size_hint_align_set(ck, 0.5, 0.99);
362    elm_table_pack(tb2, ck, 3, 0, 1, 1);
363    evas_object_show(ck);
364    
365    bt = elm_button_add(win);
366    elm_button_label_set(bt, "Close");
367    evas_object_smart_callback_add(bt, "clicked", close_cb, win);
368    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
369    evas_object_size_hint_align_set(bt, 0.95, 0.99);
370    elm_table_pack(tb2, bt, 4, 0, 1, 1);
371    evas_object_show(bt);
372    
373    evas_object_show(tb2);
374
375    evas_object_resize(win, 480, 800);
376    evas_object_show(win);
377 }
378
379 void
380 test_launcher2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
381 {
382    Evas_Object *win, *bg, *sc, *bt, *tb2, *mb, *ck, *bx, *ly;
383    int k;
384    char buf[PATH_MAX];
385    Eina_List *mbs = NULL;
386    
387    win = elm_win_add(NULL, "launcher2", ELM_WIN_BASIC);
388    elm_win_title_set(win, "Launcher 2");
389    elm_win_autodel_set(win, 1);
390
391    bg = elm_bg_add(win);
392    snprintf(buf, sizeof(buf), "%s/images/sky_03.jpg", PACKAGE_DATA_DIR);
393    elm_bg_file_set(bg, buf, NULL);
394    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
395    elm_win_resize_object_add(win, bg);
396    evas_object_show(bg);
397    
398    bx = elm_box_add(win);
399    elm_box_homogenous_set(bx, 1);
400    elm_box_horizontal_set(bx, 1);
401    
402    for (k = 0 ; k < 8; k++)
403      {
404         ly = elm_layout_add(win);
405         snprintf(buf, sizeof(buf), "%s/objects/test.edj", PACKAGE_DATA_DIR);
406         elm_layout_file_set(ly, buf, "layout");
407         evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
408         
409         bt = elm_button_add(win);
410         elm_button_label_set(bt, "Button 1");
411         elm_layout_content_set(ly, "element1", bt);
412         evas_object_show(bt);
413         
414         bt = elm_button_add(win);
415         elm_button_label_set(bt, "Button 2");
416         elm_layout_content_set(ly, "element2", bt);
417         evas_object_show(bt);
418         
419         bt = elm_button_add(win);
420         elm_button_label_set(bt, "Button 3");
421         elm_layout_content_set(ly, "element3", bt);
422         evas_object_show(bt);
423         
424         mb = elm_mapbuf_add(win);
425         elm_mapbuf_content_set(mb, ly);
426         evas_object_show(ly);
427         
428         elm_box_pack_end(bx, mb);
429         evas_object_show(mb);
430         
431         mbs = eina_list_append(mbs, mb);
432      }
433
434    // fixme: free mbs
435    evas_object_data_set(win, "mbs", mbs);
436    
437    sc = elm_scroller_add(win);
438    elm_scroller_bounce_set(sc, 1, 0);
439    elm_scroller_policy_set(sc, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
440    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
441    elm_win_resize_object_add(win, sc);
442    
443    elm_scroller_content_set(sc, bx);
444    evas_object_show(bx);
445    
446    elm_scroller_page_relative_set(sc, 1.0, 1.0);
447    evas_object_show(sc);
448
449    tb2 = elm_table_add(win);
450    evas_object_size_hint_weight_set(tb2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
451    elm_win_resize_object_add(win, tb2);
452    
453    ck = elm_check_add(win);
454    elm_check_label_set(ck, "Map");
455    elm_check_state_set(ck, 0);
456    evas_object_smart_callback_add(ck, "changed", mode_cb, win);
457    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
458    evas_object_size_hint_align_set(ck, 0.05, 0.99);
459    elm_table_pack(tb2, ck, 0, 0, 1, 1);
460    evas_object_show(ck);
461    
462    ck = elm_check_add(win);
463    elm_check_label_set(ck, "A");
464    elm_check_state_set(ck, 1);
465    evas_object_smart_callback_add(ck, "changed", alpha_cb, win);
466    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
467    evas_object_size_hint_align_set(ck, 0.20, 0.99);
468    elm_table_pack(tb2, ck, 1, 0, 1, 1);
469    evas_object_show(ck);
470    
471    ck = elm_check_add(win);
472    elm_check_label_set(ck, "Smo");
473    elm_check_state_set(ck, 1);
474    evas_object_smart_callback_add(ck, "changed", smooth_cb, win);
475    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
476    evas_object_size_hint_align_set(ck, 0.40, 0.99);
477    elm_table_pack(tb2, ck, 2, 0, 1, 1);
478    evas_object_show(ck);
479    
480    ck = elm_check_add(win);
481    elm_check_label_set(ck, "FS");
482    elm_check_state_set(ck, 0);
483    evas_object_smart_callback_add(ck, "changed", full_cb, win);
484    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
485    evas_object_size_hint_align_set(ck, 0.5, 0.99);
486    elm_table_pack(tb2, ck, 3, 0, 1, 1);
487    evas_object_show(ck);
488    
489    bt = elm_button_add(win);
490    elm_button_label_set(bt, "Close");
491    evas_object_smart_callback_add(bt, "clicked", close_cb, win);
492    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
493    evas_object_size_hint_align_set(bt, 0.95, 0.99);
494    elm_table_pack(tb2, bt, 4, 0, 1, 1);
495    evas_object_show(bt);
496    
497    evas_object_show(tb2);
498
499    evas_object_resize(win, 480, 800);
500    evas_object_show(win);
501 }
502
503 static void
504 l3_mode_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
505 {
506    Evas_Object *win = data;
507    Evas_Object *mb;
508    Eina_List *mbs, *l;
509    
510    mbs = evas_object_data_get(win, "mbs");
511    EINA_LIST_FOREACH(mbs, l, mb)
512      {
513         if (elm_mapbuf_enabled_get(mb))
514           elm_mapbuf_enabled_set(mb, 0);
515         else
516           elm_mapbuf_enabled_set(mb, 1);
517      }
518 }
519
520 static void
521 l3_full_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
522 {
523    Evas_Object *win = data;
524    elm_win_fullscreen_set(win, !elm_win_fullscreen_get(win));
525 }
526
527 static void
528 l3_alpha_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
529 {
530    Evas_Object *win = data;
531    Evas_Object *mb;
532    Eina_List *mbs, *l;
533    
534    mbs = evas_object_data_get(win, "mbs");
535    EINA_LIST_FOREACH(mbs, l, mb)
536      {
537         elm_mapbuf_alpha_set(mb, elm_check_state_get(obj));
538      }
539 }
540
541 static void
542 l3_smooth_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
543 {
544    Evas_Object *win = data;
545    Evas_Object *mb;
546    Eina_List *mbs, *l;
547    
548    mbs = evas_object_data_get(win, "mbs");
549    EINA_LIST_FOREACH(mbs, l, mb)
550      {
551         elm_mapbuf_smooth_set(mb, elm_check_state_get(obj));
552      }
553 }
554
555 static void
556 l3_hidden_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
557 {
558    Evas_Object *win = data;
559    Evas_Object *mb;
560    Eina_List *mbs, *l;
561    
562    mbs = evas_object_data_get(win, "mbs");
563    EINA_LIST_FOREACH(mbs, l, mb)
564      {
565         if (evas_object_visible_get(mb)) evas_object_hide(mb);
566         else evas_object_show(mb);
567      }
568 }
569
570 static void
571 l3_close_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
572 {
573    evas_object_del(data);
574 }
575
576 static Eina_Bool
577 l3_tim_cb(void *data)
578 {
579    Evas_Object *ly, *ly2, *sc, *mb;
580    Eina_List *list, *l;
581    char buf[256];
582    int slx, sly;
583    
584    evas_object_data_del(data, "timer");
585    ly = evas_object_data_get(data, "ly");
586    ly2 = evas_object_data_get(data, "ly2");
587    sc = evas_object_data_get(data, "sc");
588    elm_object_scroll_freeze_push(sc);
589    evas_object_data_set(data, "dragging", (void *)(long)1);
590    evas_object_color_set(data, 255, 255, 255, 255);
591    list = (Eina_List *)evas_object_data_get
592       (elm_object_top_widget_get(data), "mbs");
593    EINA_LIST_FOREACH(list, l, mb)
594       evas_object_color_set(mb, 128, 128, 128, 128);
595    slx = (int)(long)evas_object_data_get(data, "slx");
596    sly = (int)(long)evas_object_data_get(data, "sly");
597    snprintf(buf, sizeof(buf), "slot.%i.%i", slx, sly);
598    elm_layout_content_unset(ly, buf);
599    edje_object_signal_emit(elm_layout_edje_get(ly2), "drag", "app");
600    return EINA_FALSE;
601 }
602
603 static void
604 l3_ic_del_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
605 {
606    Ecore_Timer *tim;
607    
608    tim = evas_object_data_get(obj, "timer");
609    if (tim)
610      {
611         evas_object_data_del(obj, "timer");
612         ecore_timer_del(tim);
613      }
614 }
615
616 static void
617 l3_ic_down_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
618 {
619    Evas_Event_Mouse_Down *ev = event_info;
620    Ecore_Timer *tim;
621    Evas_Coord x, y, w, h;
622    Evas_Object *ly2;
623    
624    tim = evas_object_data_get(obj, "timer");
625    if (tim) evas_object_data_del(obj, "timer");
626    tim = ecore_timer_add(1.0, l3_tim_cb, obj);
627    evas_object_data_set(obj, "timer", tim);
628
629    ly2 = evas_object_data_get(obj, "ly2");
630    evas_object_geometry_get(ly2, &x, &y, &w, &h);
631    evas_object_data_set(obj, "x", (void *)(long)(ev->canvas.x));
632    evas_object_data_set(obj, "y", (void *)(long)(ev->canvas.y));
633    evas_object_data_set(obj, "px", (void *)(long)(x));
634    evas_object_data_set(obj, "py", (void *)(long)(y));
635    
636    edje_object_signal_emit(elm_layout_edje_get(ly2), "click", "app");
637    
638    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
639      {
640         printf("double click %p\n", obj);
641      }
642 }
643
644 static void
645 l3_ic_up_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
646 {
647    Evas_Event_Mouse_Up *ev = event_info;
648    Ecore_Timer *tim;
649    Evas_Object *ly2;
650    
651    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
652    
653    ly2 = evas_object_data_get(obj, "ly2");
654    tim = evas_object_data_get(obj, "timer");
655    if (tim)
656      {
657         evas_object_data_del(obj, "timer");
658         ecore_timer_del(tim);
659      }
660    if (evas_object_data_get(obj, "dragging"))
661      {
662         Evas_Object *ly, *sc, *mb;
663         Eina_List *list, *l;
664         int slx, sly;
665         char buf[256];
666         
667         evas_object_data_del(obj, "dragging");
668         ly = evas_object_data_get(obj, "ly");
669         sc = evas_object_data_get(obj, "sc");
670         elm_object_scroll_freeze_pop(sc);
671         slx = (int)(long)evas_object_data_get(obj, "slx");
672         sly = (int)(long)evas_object_data_get(obj, "sly");
673         snprintf(buf, sizeof(buf), "slot.%i.%i", slx, sly);
674         elm_layout_content_set(ly, buf, ly2);
675         list = (Eina_List *)evas_object_data_get
676            (elm_object_top_widget_get(obj), "mbs");
677         EINA_LIST_FOREACH(list, l, mb)
678            evas_object_color_set(mb, 255, 255, 255, 255);
679         edje_object_signal_emit(elm_layout_edje_get(ly2), "drop", "app");
680      }
681    else
682       edje_object_signal_emit(elm_layout_edje_get(ly2), "unclick", "app");
683 }
684
685 static void
686 l3_ic_move_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
687 {
688    Evas_Event_Mouse_Move *ev = event_info;
689    Evas_Object *ly2;
690    
691    ly2 = evas_object_data_get(obj, "ly2");
692    
693    if (evas_object_data_get(obj, "dragging"))
694      {
695         Evas_Coord x, y, px, py;
696         
697         x = (Evas_Coord)(long)evas_object_data_get(obj, "x");
698         y = (Evas_Coord)(long)evas_object_data_get(obj, "y");
699         px = (Evas_Coord)(long)evas_object_data_get(obj, "px");
700         py = (Evas_Coord)(long)evas_object_data_get(obj, "py");
701         evas_object_move(ly2, 
702                          px + ev->cur.canvas.x - x, 
703                          py + ev->cur.canvas.y - y);
704     }
705    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
706      {
707         Ecore_Timer *tim;
708         
709         tim = evas_object_data_get(obj, "timer");
710         if (tim)
711           {
712              evas_object_data_del(obj, "timer");
713              ecore_timer_del(tim);
714           }
715         edje_object_signal_emit(elm_layout_edje_get(ly2), "cancel", "app");
716         return;
717      }
718 }
719
720 void
721 test_launcher3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
722 {
723    Evas_Object *win, *bg, *sc, *tb, *pad, *bt, *ic, *tb2, *mb, *ck, *bx, *bx2, *ly, *ly2;
724    int i, j, k, n, m;
725    char buf[PATH_MAX];
726    const char *names[] =
727      {
728         "Hello",    "World",    "Spam",  "Egg", 
729         "Ham",      "Good",     "Bad",   "Milk", 
730         "Smell",    "Of",       "Sky",   "Gold",
731         "Hole",     "Pig",      "And",   "Calm"
732      };
733    Eina_List *mbs = NULL;
734    
735    win = elm_win_add(NULL, "launcher", ELM_WIN_BASIC);
736    elm_win_title_set(win, "Launcher");
737    elm_win_autodel_set(win, 1);
738
739    bg = elm_bg_add(win);
740    snprintf(buf, sizeof(buf), "%s/images/sky_04.jpg", PACKAGE_DATA_DIR);
741    elm_bg_file_set(bg, buf, NULL);
742    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
743    elm_win_resize_object_add(win, bg);
744    evas_object_show(bg);
745
746    bx = elm_box_add(win);
747    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
748    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
749    elm_box_homogenous_set(bx, 1);
750    elm_box_horizontal_set(bx, 1);
751    
752    sc = elm_scroller_add(win);
753    elm_scroller_bounce_set(sc, 1, 0);
754    elm_scroller_policy_set(sc, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
755    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
756    evas_object_size_hint_fill_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL);
757    
758    n = 0; m = 0;
759    for (k = 0 ; k < 8; k++)
760      {
761         tb = elm_table_add(win);
762         evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
763         evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
764
765         pad = evas_object_rectangle_add(evas_object_evas_get(win));
766         evas_object_size_hint_min_set(pad, 450, 10);
767         elm_table_pack(tb, pad, 1, 0, 1, 1);
768         
769         pad = evas_object_rectangle_add(evas_object_evas_get(win));
770         evas_object_size_hint_min_set(pad, 450, 10);
771         elm_table_pack(tb, pad, 1, 2, 1, 1);
772         
773         pad = evas_object_rectangle_add(evas_object_evas_get(win));
774         evas_object_size_hint_min_set(pad, 10, 450);
775         elm_table_pack(tb, pad, 0, 1, 1, 1);
776         
777         pad = evas_object_rectangle_add(evas_object_evas_get(win));
778         evas_object_size_hint_min_set(pad, 10, 450);
779         elm_table_pack(tb, pad, 2, 1, 1, 1);
780
781         mb = elm_mapbuf_add(win);
782         mbs = eina_list_append(mbs, mb);
783         
784         elm_mapbuf_content_set(mb, tb);
785         evas_object_show(tb);
786         elm_box_pack_end(bx, mb);
787         evas_object_show(mb);
788         
789         ly = elm_layout_add(win);
790         snprintf(buf, sizeof(buf), "%s/objects/test.edj", PACKAGE_DATA_DIR);
791         elm_layout_file_set(ly, buf, "launcher_page");
792         evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
793         evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
794         elm_table_pack(tb, ly, 1, 1, 1, 1);
795         evas_object_show(ly);
796         
797         for (j = 0; j < 4; j++)
798           {
799              for (i = 0; i < 4; i++)
800                {
801                   ly2 = elm_layout_add(win);
802                   snprintf(buf, sizeof(buf), "%s/objects/test.edj", PACKAGE_DATA_DIR);
803                   elm_layout_file_set(ly2, buf, "launcher_icon");
804                   evas_object_size_hint_weight_set(ly2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
805                   evas_object_size_hint_align_set(ly2, EVAS_HINT_FILL, EVAS_HINT_FILL);
806                   edje_object_part_text_set(elm_layout_edje_get(ly2), "label", names[m]);
807
808                   ic = elm_icon_add(win);
809                   elm_object_scale_set(ic, 0.5);
810                   snprintf(buf, sizeof(buf), "%s/images/icon_%02i.png", PACKAGE_DATA_DIR, n);
811                   elm_icon_file_set(ic, buf, NULL);
812                   elm_icon_scale_set(ic, 0, 0);
813                   evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
814                   evas_object_size_hint_align_set(ic, 0.5, 0.5);
815                   elm_layout_content_set(ly2, "slot", ic);
816                   evas_object_show(ic);
817                   
818                   evas_object_event_callback_add(ic, EVAS_CALLBACK_DEL, l3_ic_del_cb, ic);
819                   
820                   evas_object_event_callback_add(ic, EVAS_CALLBACK_MOUSE_DOWN, l3_ic_down_cb, ic);
821                   evas_object_event_callback_add(ic, EVAS_CALLBACK_MOUSE_UP,   l3_ic_up_cb,   ic);
822                   evas_object_event_callback_add(ic, EVAS_CALLBACK_MOUSE_MOVE, l3_ic_move_cb, ic);
823                   
824                   evas_object_data_set(ic, "ly", ly);
825                   evas_object_data_set(ic, "ly2", ly2);
826                   evas_object_data_set(ic, "sc", sc);
827                   evas_object_data_set(ic, "bx", bx);
828                   evas_object_data_set(ic, "mb", mb);
829                   evas_object_data_set(ic, "slx", (void *)(long)(i));
830                   evas_object_data_set(ic, "sly", (void *)(long)(j));
831                   
832                   snprintf(buf, sizeof(buf), "slot.%i.%i", i, j);
833                   elm_layout_content_set(ly, buf, ly2);
834                   evas_object_show(ly2);
835                   
836                   n++; if (n > 23) n = 0;
837                   m++; if (m > 15) m = 0;
838                }
839           }
840      }
841
842    // fixme: free mbs
843    evas_object_data_set(win, "mbs", mbs);
844    
845    bx2 = elm_box_add(win);
846    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
847    elm_box_horizontal_set(bx2, 0);
848    elm_win_resize_object_add(win, bx2);
849    evas_object_show(bx2);
850    
851    elm_scroller_content_set(sc, bx);
852    evas_object_show(bx);
853    
854    elm_scroller_page_relative_set(sc, 1.0, 1.0);
855    evas_object_show(sc);
856
857    tb2 = elm_table_add(win);
858    evas_object_size_hint_weight_set(tb2, EVAS_HINT_EXPAND, 0.0);
859    evas_object_size_hint_fill_set(tb2, EVAS_HINT_FILL, EVAS_HINT_FILL);
860    elm_box_pack_end(bx2, tb2);
861
862    elm_box_pack_end(bx2, sc);
863    
864    ck = elm_check_add(win);
865    elm_check_label_set(ck, "Map");
866    elm_check_state_set(ck, 0);
867    evas_object_smart_callback_add(ck, "changed", l3_mode_cb, win);
868    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
869    evas_object_size_hint_align_set(ck, 0.05, 0.99);
870    elm_table_pack(tb2, ck, 0, 0, 1, 1);
871    evas_object_show(ck);
872    
873    ck = elm_check_add(win);
874    elm_check_label_set(ck, "A");
875    elm_check_state_set(ck, 1);
876    evas_object_smart_callback_add(ck, "changed", l3_alpha_cb, win);
877    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
878    evas_object_size_hint_align_set(ck, 0.20, 0.99);
879    elm_table_pack(tb2, ck, 1, 0, 1, 1);
880    evas_object_show(ck);
881    
882    ck = elm_check_add(win);
883    elm_check_label_set(ck, "Smo");
884    elm_check_state_set(ck, 1);
885    evas_object_smart_callback_add(ck, "changed", l3_smooth_cb, win);
886    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
887    evas_object_size_hint_align_set(ck, 0.40, 0.99);
888    elm_table_pack(tb2, ck, 2, 0, 1, 1);
889    evas_object_show(ck);
890    
891    ck = elm_check_add(win);
892    elm_check_label_set(ck, "FS");
893    elm_check_state_set(ck, 0);
894    evas_object_smart_callback_add(ck, "changed", l3_full_cb, win);
895    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
896    evas_object_size_hint_align_set(ck, 0.5, 0.99);
897    elm_table_pack(tb2, ck, 3, 0, 1, 1);
898    evas_object_show(ck);
899    
900    ck = elm_check_add(win);
901    elm_check_label_set(ck, "Hid");
902    elm_check_state_set(ck, 0);
903    evas_object_smart_callback_add(ck, "changed", l3_hidden_cb, win);
904    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
905    evas_object_size_hint_align_set(ck, 0.5, 0.99);
906    elm_table_pack(tb2, ck, 4, 0, 1, 1);
907    evas_object_show(ck);
908    
909    bt = elm_button_add(win);
910    elm_button_label_set(bt, "Close");
911    evas_object_smart_callback_add(bt, "clicked", l3_close_cb, win);
912    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
913    evas_object_size_hint_align_set(bt, 0.95, 0.99);
914    elm_table_pack(tb2, bt, 5, 0, 1, 1);
915    evas_object_show(bt);
916    
917    evas_object_show(tb2);
918
919    evas_object_resize(win, 480, 800);
920    evas_object_show(win);
921 }
922 #endif