factory.... working on it. but up and kicking. it's a little unhappy
[framework/uifw/elementary.git] / src / bin / test_factory.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 fac_unrealize(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
9 {
10    // setting factory content to null deletes it
11    printf("DELETE for factory %p\n", obj);
12    elm_factory_content_set(obj, NULL);
13 }
14
15 static void
16 fac_realize_end(void *data, Evas_Object *obj, void *event_info __UNUSED__)
17 {
18    Evas_Object *win = data;
19    Evas_Object *tb, *bt;
20    int i;
21    
22    printf("ADD for factory 4 %p\n", obj);
23    tb = elm_table_add(win);
24
25    for (i = 0; i < 40; i++)
26      {
27         char buf[32];
28         
29         snprintf(buf, sizeof(buf), "%i", i);
30         
31         bt = elm_button_add(win);
32         evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
33         evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
34         elm_object_text_set(bt, buf);
35         elm_table_pack(tb, bt, 0, i, 1, 1);
36         evas_object_show(bt);
37      }
38    
39    elm_factory_content_set(obj, tb);
40    evas_object_show(tb);
41 }
42
43 static void
44 fac_realize3(void *data, Evas_Object *obj, void *event_info __UNUSED__)
45 {
46    Evas_Object *win = data;
47    Evas_Object *tb, *fc;
48    int i;
49    
50    printf("ADD for factory 3 %p\n", obj);
51    tb = elm_table_add(win);
52
53    for (i = 0; i < 40; i++)
54      {
55         fc = elm_factory_add(win);
56         // initial height per factory of 1000
57         // scrollbar will be wrong until enough
58         // children have been realized and the
59         // real size is known
60         evas_object_size_hint_min_set(fc, 0, 1000);
61         evas_object_size_hint_weight_set(fc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
62         evas_object_size_hint_align_set(fc, EVAS_HINT_FILL, EVAS_HINT_FILL);
63         evas_object_smart_callback_add(fc, "realize", fac_realize_end, win);
64         evas_object_smart_callback_add(fc, "unrealize", fac_unrealize, win);
65         elm_table_pack(tb, fc, 0, i, 1, 1);
66         evas_object_show(fc);
67      }
68
69    elm_factory_content_set(obj, tb);
70    evas_object_show(tb);
71 }
72
73 static void
74 fac_realize2(void *data, Evas_Object *obj, void *event_info __UNUSED__)
75 {
76    Evas_Object *win = data;
77    Evas_Object *tb, *fc;
78    int i;
79    
80    printf("ADD for factory 2 %p\n", obj);
81    tb = elm_table_add(win);
82
83    for (i = 0; i < 40; i++)
84      {
85         fc = elm_factory_add(win);
86         // initial height per factory of 1000
87         // scrollbar will be wrong until enough
88         // children have been realized and the
89         // real size is known
90         evas_object_size_hint_min_set(fc, 0, 1000);
91         evas_object_size_hint_weight_set(fc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
92         evas_object_size_hint_align_set(fc, EVAS_HINT_FILL, EVAS_HINT_FILL);
93         evas_object_smart_callback_add(fc, "realize", fac_realize3, win);
94         evas_object_smart_callback_add(fc, "unrealize", fac_unrealize, win);
95         elm_table_pack(tb, fc, 0, i, 1, 1);
96         evas_object_show(fc);
97      }
98
99    elm_factory_content_set(obj, tb);
100    evas_object_show(tb);
101 }
102
103 static void
104 fac_realize1(void *data, Evas_Object *obj, void *event_info __UNUSED__)
105 {
106    Evas_Object *win = data;
107    Evas_Object *tb, *fc;
108    int i;
109    
110    printf("ADD for factory 1 %p\n", obj);
111    tb = elm_table_add(win);
112
113    for (i = 0; i < 40; i++)
114      {
115         fc = elm_factory_add(win);
116         // initial height per factory of 1000
117         // scrollbar will be wrong until enough
118         // children have been realized and the
119         // real size is known
120         evas_object_size_hint_min_set(fc, 0, 1000);
121         evas_object_size_hint_weight_set(fc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
122         evas_object_size_hint_align_set(fc, EVAS_HINT_FILL, EVAS_HINT_FILL);
123         evas_object_smart_callback_add(fc, "realize", fac_realize2, win);
124         evas_object_smart_callback_add(fc, "unrealize", fac_unrealize, win);
125         elm_table_pack(tb, fc, 0, i, 1, 1);
126         evas_object_show(fc);
127      }
128
129    elm_factory_content_set(obj, tb);
130    evas_object_show(tb);
131 }
132
133 void
134 test_factory(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
135 {
136    Evas_Object *win, *bg, *tb, *sc, *fc;
137    int i;
138
139    win = elm_win_add(NULL, "factory", ELM_WIN_BASIC);
140    elm_win_title_set(win, "Factory");
141    elm_win_autodel_set(win, EINA_TRUE);
142
143    bg = elm_bg_add(win);
144    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
145    elm_win_resize_object_add(win, bg);
146    evas_object_show(bg);
147
148    tb = elm_table_add(win);
149    evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
150
151    for (i = 0; i < 40; i++)
152      {
153         fc = elm_factory_add(win);
154         // initial height per factory of 1000
155         // scrollbar will be wrong until enough
156         // children have been realized and the
157         // real size is known
158         evas_object_size_hint_min_set(fc, 0, 1000);
159         evas_object_size_hint_weight_set(fc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
160         evas_object_size_hint_align_set(fc, EVAS_HINT_FILL, EVAS_HINT_FILL);
161         evas_object_smart_callback_add(fc, "realize", fac_realize1, win);
162         evas_object_smart_callback_add(fc, "unrealize", fac_unrealize, win);
163         elm_table_pack(tb, fc, 0, i, 1, 1);
164         evas_object_show(fc);
165      }
166
167    sc = elm_scroller_add(win);
168    elm_scroller_bounce_set(sc, EINA_FALSE, EINA_TRUE);
169    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
170    elm_win_resize_object_add(win, sc);
171
172    elm_scroller_content_set(sc, tb);
173    evas_object_show(tb);
174
175    evas_object_show(sc);
176    
177    evas_object_resize(win, 320, 480);
178    evas_object_show(win);
179 }
180 #endif