Elementary migration around 2011/04/06
[framework/uifw/elementary.git] / src / bin / test_scroller.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 my_bt_go_300_300(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
8 {
9    elm_scroller_region_bring_in((Evas_Object *)data, 300, 300, 318, 318);
10 }
11
12 void
13 my_bt_go_900_300(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
14 {
15    elm_scroller_region_bring_in((Evas_Object *)data, 900, 300, 318, 318);
16 }
17
18 void
19 my_bt_go_300_900(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
20 {
21    elm_scroller_region_bring_in((Evas_Object *)data, 300, 900, 318, 318);
22 }
23
24 void
25 my_bt_go_900_900(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
26 {
27    elm_scroller_region_bring_in((Evas_Object *)data, 900, 900, 318, 318);
28 }
29
30 void
31 test_scroller(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
32 {
33    Evas_Object *win, *bg2, *tb, *tb2, *bg, *sc, *bt;
34    int i, j, n;
35    char buf[PATH_MAX];
36    const char *img[9] =
37      {
38         "panel_01.jpg", 
39           "plant_01.jpg", 
40           "rock_01.jpg", 
41           "rock_02.jpg",
42           "sky_01.jpg", 
43           "sky_02.jpg", 
44           "sky_03.jpg", 
45           "sky_04.jpg",
46           "wood_01.jpg"
47      };
48
49    win = elm_win_add(NULL, "scroller", ELM_WIN_BASIC);
50    elm_win_title_set(win, "Scroller");
51    elm_win_autodel_set(win, 1);
52
53    bg = elm_bg_add(win);
54    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
55    elm_win_resize_object_add(win, bg);
56    evas_object_show(bg);
57
58    tb = elm_table_add(win);
59    evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
60
61    n = 0;
62    for (j = 0; j < 12; j++)
63      {
64         for (i = 0; i < 12; i++)
65           {
66              bg2 = elm_bg_add(win);
67              snprintf(buf, sizeof(buf), "%s/images/%s", 
68                       PACKAGE_DATA_DIR, img[n]);
69              n++;
70              if (n >= 9) n = 0;
71              elm_bg_file_set(bg2, buf, NULL);
72              evas_object_size_hint_weight_set(bg2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
73              evas_object_size_hint_align_set(bg2, EVAS_HINT_FILL, EVAS_HINT_FILL);
74              evas_object_size_hint_min_set(bg2, 318, 318);
75              elm_table_pack(tb, bg2, i, j, 1, 1);
76              evas_object_show(bg2);
77           }
78      }
79    
80    sc = elm_scroller_add(win);
81    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
82    elm_win_resize_object_add(win, sc);
83
84    elm_scroller_content_set(sc, tb);
85    evas_object_show(tb);
86
87    elm_scroller_page_relative_set(sc, 1.0, 1.0);
88 //   elm_scroller_page_size_set(sc, 200, 200);
89    evas_object_show(sc);
90
91    tb2 = elm_table_add(win);
92    evas_object_size_hint_weight_set(tb2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
93    elm_win_resize_object_add(win, tb2);
94
95    bt = elm_button_add(win);
96    elm_button_label_set(bt, "to 300 300");
97    evas_object_smart_callback_add(bt, "clicked", my_bt_go_300_300, sc);
98    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
99    evas_object_size_hint_align_set(bt, 0.1, 0.1);
100    elm_table_pack(tb2, bt, 0, 0, 1, 1);
101    evas_object_show(bt);
102    
103    bt = elm_button_add(win);
104    elm_button_label_set(bt, "to 900 300");
105    evas_object_smart_callback_add(bt, "clicked", my_bt_go_900_300, sc);
106    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
107    evas_object_size_hint_align_set(bt, 0.9, 0.1);
108    elm_table_pack(tb2, bt, 1, 0, 1, 1);
109    evas_object_show(bt);
110    
111    bt = elm_button_add(win);
112    elm_button_label_set(bt, "to 300 900");
113    evas_object_smart_callback_add(bt, "clicked", my_bt_go_300_900, sc);
114    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
115    evas_object_size_hint_align_set(bt, 0.1, 0.9);
116    elm_table_pack(tb2, bt, 0, 1, 1, 1);
117    evas_object_show(bt);
118    
119    bt = elm_button_add(win);
120    elm_button_label_set(bt, "to 900 900");
121    evas_object_smart_callback_add(bt, "clicked", my_bt_go_900_900, sc);
122    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
123    evas_object_size_hint_align_set(bt, 0.9, 0.9);
124    elm_table_pack(tb2, bt, 1, 1, 1, 1);
125    evas_object_show(bt);
126    
127    evas_object_show(tb2);
128    
129    evas_object_resize(win, 320, 320);
130    evas_object_show(win);
131 }
132
133 void
134 click_through(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
135 {
136    printf("click went through on %p\n", obj);
137 }
138
139 void
140 test_scroller2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
141 {
142    Evas_Object *win, *bt, *bx, *bx2, *bg, *sc, *tb, *tb2, *rc;
143    int i, j;
144
145    win = elm_win_add(NULL, "scroller2", ELM_WIN_BASIC);
146    elm_win_title_set(win, "Scroller 2");
147    elm_win_autodel_set(win, 1);
148
149    bg = elm_bg_add(win);
150    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
151    elm_win_resize_object_add(win, bg);
152    evas_object_show(bg);
153
154    bx = elm_box_add(win);
155    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
156    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.0);
157
158    /* { */
159    for (i = 0; i < 3; i++)
160      {
161         bt = elm_button_add(win);
162         elm_button_label_set(bt, "Vertical");
163         evas_object_smart_callback_add(bt, "clicked", click_through, NULL);
164         evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
165         evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5);
166         elm_box_pack_end(bx, bt);
167         evas_object_show(bt);
168      }
169    /* } */
170    
171    /* { */
172    sc = elm_scroller_add(win);
173    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, 0.0);
174    evas_object_size_hint_align_set(sc, EVAS_HINT_FILL, 0.5);
175    elm_scroller_bounce_set(sc, 1, 0);
176    elm_scroller_content_min_limit(sc, 0, 1);
177    elm_box_pack_end(bx, sc);
178    evas_object_show(sc);
179    
180    bx2 = elm_box_add(win);
181    elm_box_horizontal_set(bx2, 1);
182
183    for (i = 0; i < 10; i++)
184      {
185         bt = elm_button_add(win);
186         elm_button_label_set(bt, "... Horizontal scrolling ...");
187         evas_object_smart_callback_add(bt, "clicked", click_through, NULL);
188         elm_box_pack_end(bx2, bt);
189         evas_object_show(bt);
190      }
191    
192    elm_scroller_content_set(sc, bx2);
193    evas_object_show(bx2);
194    /* } */
195
196    /* { */
197    for (i = 0; i < 3; i++)
198      {
199         bt = elm_button_add(win);
200         elm_button_label_set(bt, "Vertical");
201         evas_object_smart_callback_add(bt, "clicked", click_through, NULL);
202         evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
203         evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5);
204         elm_box_pack_end(bx, bt);
205         evas_object_show(bt);
206      }
207    /* } */
208    
209    /* { */
210    tb = elm_table_add(win);
211    evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
212    evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
213    elm_box_pack_end(bx, tb);
214    evas_object_show(tb);
215    
216    rc = evas_object_rectangle_add(evas_object_evas_get(win));
217    evas_object_size_hint_min_set(rc, 200, 120);
218    elm_table_pack(tb, rc, 0, 0, 1, 1);
219    
220    sc = elm_scroller_add(win);
221    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
222    evas_object_size_hint_align_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL);
223    elm_table_pack(tb, sc, 0, 0, 1, 1);
224    evas_object_show(sc);
225    
226    tb2 = elm_table_add(win);
227
228    for (j = 0; j < 16; j++)
229      {
230         for (i = 0; i < 16; i++)
231           {
232              bt = elm_button_add(win);
233              elm_button_label_set(bt, "Both");
234              evas_object_smart_callback_add(bt, "clicked", click_through, NULL);
235              elm_table_pack(tb2, bt, i, j, 1, 1);
236              evas_object_show(bt);
237           }
238      }
239    
240    elm_scroller_content_set(sc, tb2);
241    evas_object_show(tb2);
242    /* } */
243    
244    for (i = 0; i < 24; i++)
245      {
246         bt = elm_button_add(win);
247         elm_button_label_set(bt, "Vertical");
248         evas_object_smart_callback_add(bt, "clicked", click_through, NULL);
249         evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
250         evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0.5);
251         elm_box_pack_end(bx, bt);
252         evas_object_show(bt);
253      }
254    
255    sc = elm_scroller_add(win);
256    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
257    elm_scroller_bounce_set(sc, 0, 1);
258    elm_win_resize_object_add(win, sc);
259    elm_scroller_content_set(sc, bx);
260    evas_object_show(bx);
261    evas_object_show(sc);
262    
263    evas_object_resize(win, 320, 480);
264    evas_object_show(win);
265 }
266 #endif