diff options
Diffstat (limited to 'libraries/elementary/src/bin/test_clock.c')
-rw-r--r-- | libraries/elementary/src/bin/test_clock.c | 309 |
1 files changed, 309 insertions, 0 deletions
diff --git a/libraries/elementary/src/bin/test_clock.c b/libraries/elementary/src/bin/test_clock.c new file mode 100644 index 0000000..6e28d21 --- /dev/null +++ b/libraries/elementary/src/bin/test_clock.c | |||
@@ -0,0 +1,309 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include "elementary_config.h" | ||
3 | #include "test.h" | ||
4 | #endif | ||
5 | #include <Elementary.h> | ||
6 | #ifndef ELM_LIB_QUICKLAUNCH | ||
7 | struct _api_data | ||
8 | { | ||
9 | unsigned int state; /* What state we are testing */ | ||
10 | Evas_Object *box; /* Used in set_api_state */ | ||
11 | }; | ||
12 | typedef struct _api_data api_data; | ||
13 | |||
14 | enum _api_state | ||
15 | { | ||
16 | CLOCK_HIDE_SEC, | ||
17 | CLOCK_SHOW_AM_PM, | ||
18 | CLOCK_SHOW_SEC, | ||
19 | CLOCK_EDIT_MIN, | ||
20 | CLOCK_EDIT_HOUR, | ||
21 | CLOCK_EDIT_ALL, | ||
22 | CLOCK_EDIT_ALL_ARMY, | ||
23 | API_STATE_LAST | ||
24 | }; | ||
25 | typedef enum _api_state api_state; | ||
26 | |||
27 | static void | ||
28 | set_api_state(api_data *api) | ||
29 | { | ||
30 | const Eina_List *items = elm_box_children_get(api->box); | ||
31 | Evas_Object *ck = eina_list_nth(items, 0); | ||
32 | if (!eina_list_count(items)) | ||
33 | return; | ||
34 | |||
35 | /* use elm_box_children_get() to get list of children */ | ||
36 | switch(api->state) | ||
37 | { /* Put all api-changes under switch */ | ||
38 | case CLOCK_HIDE_SEC: | ||
39 | elm_clock_show_seconds_set(ck, EINA_FALSE); | ||
40 | break; | ||
41 | |||
42 | case CLOCK_SHOW_AM_PM: | ||
43 | elm_clock_show_am_pm_set(ck, EINA_TRUE); | ||
44 | break; | ||
45 | |||
46 | case CLOCK_SHOW_SEC: | ||
47 | elm_clock_show_seconds_set(ck, EINA_TRUE); | ||
48 | break; | ||
49 | |||
50 | case CLOCK_EDIT_MIN: | ||
51 | elm_clock_edit_set(ck, ELM_CLOCK_EDIT_MIN_DECIMAL | ELM_CLOCK_EDIT_MIN_UNIT); | ||
52 | break; | ||
53 | |||
54 | case CLOCK_EDIT_HOUR: | ||
55 | elm_clock_edit_set(ck, ELM_CLOCK_EDIT_DEFAULT); | ||
56 | elm_clock_edit_set(ck, ELM_CLOCK_EDIT_HOUR_DECIMAL | ELM_CLOCK_EDIT_HOUR_UNIT); | ||
57 | break; | ||
58 | |||
59 | case CLOCK_EDIT_ALL: | ||
60 | elm_clock_edit_set(ck, ELM_CLOCK_EDIT_ALL); | ||
61 | break; | ||
62 | |||
63 | case CLOCK_EDIT_ALL_ARMY: | ||
64 | elm_clock_show_am_pm_set(ck, EINA_FALSE); | ||
65 | break; | ||
66 | |||
67 | case API_STATE_LAST: | ||
68 | |||
69 | break; | ||
70 | default: | ||
71 | return; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | static void | ||
76 | _api_bt_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__) | ||
77 | { /* Will add here a SWITCH command containing code to modify test-object */ | ||
78 | /* in accordance a->state value. */ | ||
79 | api_data *a = data; | ||
80 | char str[128]; | ||
81 | |||
82 | printf("clicked event on API Button: api_state=<%d>\n", a->state); | ||
83 | set_api_state(a); | ||
84 | a->state++; | ||
85 | sprintf(str, "Next API function (%u)", a->state); | ||
86 | elm_object_text_set(obj, str); | ||
87 | elm_object_disabled_set(obj, a->state == API_STATE_LAST); | ||
88 | } | ||
89 | |||
90 | static void | ||
91 | _cleanup_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
92 | { | ||
93 | free(data); | ||
94 | } | ||
95 | |||
96 | void | ||
97 | test_clock(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
98 | { | ||
99 | Evas_Object *win, *bx, *ck, *bt, *bxx; | ||
100 | unsigned int digedit; | ||
101 | api_data *api = calloc(1, sizeof(api_data)); | ||
102 | |||
103 | win = elm_win_util_standard_add("clock", "Clock"); | ||
104 | elm_win_autodel_set(win, EINA_TRUE); | ||
105 | evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api); | ||
106 | |||
107 | bxx = elm_box_add(win); | ||
108 | elm_win_resize_object_add(win, bxx); | ||
109 | evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
110 | evas_object_show(bxx); | ||
111 | |||
112 | bx = elm_box_add(win); | ||
113 | elm_win_resize_object_add(win, bx); | ||
114 | api->box = bx; | ||
115 | evas_object_show(bx); | ||
116 | |||
117 | bt = elm_button_add(win); | ||
118 | elm_object_text_set(bt, "Next API function"); | ||
119 | evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked, (void *) api); | ||
120 | elm_box_pack_end(bxx, bt); | ||
121 | elm_object_disabled_set(bt, EINA_TRUE); | ||
122 | evas_object_show(bt); | ||
123 | |||
124 | elm_box_pack_end(bxx, bx); | ||
125 | |||
126 | ck = elm_clock_add(win); | ||
127 | elm_box_pack_end(bx, ck); | ||
128 | evas_object_show(ck); | ||
129 | |||
130 | ck = elm_clock_add(win); | ||
131 | elm_clock_show_am_pm_set(ck, EINA_TRUE); | ||
132 | elm_box_pack_end(bx, ck); | ||
133 | elm_clock_time_set(ck, 17, 25, 0); | ||
134 | evas_object_show(ck); | ||
135 | |||
136 | ck = elm_clock_add(win); | ||
137 | elm_clock_show_seconds_set(ck, EINA_TRUE); | ||
138 | elm_box_pack_end(bx, ck); | ||
139 | evas_object_show(ck); | ||
140 | |||
141 | ck = elm_clock_add(win); | ||
142 | elm_clock_show_seconds_set(ck, EINA_TRUE); | ||
143 | elm_clock_show_am_pm_set(ck, EINA_TRUE); | ||
144 | elm_box_pack_end(bx, ck); | ||
145 | elm_clock_time_set(ck, 11, 59, 57); | ||
146 | evas_object_show(ck); | ||
147 | |||
148 | ck = elm_clock_add(win); | ||
149 | elm_clock_show_seconds_set(ck, EINA_TRUE); | ||
150 | elm_clock_show_am_pm_set(ck, EINA_FALSE); | ||
151 | elm_clock_time_set(ck, 23, 59, 57); | ||
152 | elm_box_pack_end(bx, ck); | ||
153 | evas_object_show(ck); | ||
154 | |||
155 | ck = elm_clock_add(win); | ||
156 | elm_clock_edit_set(ck, EINA_TRUE); | ||
157 | elm_clock_show_seconds_set(ck, EINA_TRUE); | ||
158 | elm_clock_show_am_pm_set(ck, EINA_TRUE); | ||
159 | elm_clock_time_set(ck, 10, 11, 12); | ||
160 | elm_box_pack_end(bx, ck); | ||
161 | evas_object_show(ck); | ||
162 | |||
163 | ck = elm_clock_add(win); | ||
164 | elm_clock_show_seconds_set(ck, EINA_TRUE); | ||
165 | elm_clock_edit_set(ck, EINA_TRUE); | ||
166 | digedit = ELM_CLOCK_EDIT_HOUR_UNIT | ELM_CLOCK_EDIT_MIN_UNIT | ELM_CLOCK_EDIT_SEC_UNIT; | ||
167 | elm_clock_edit_mode_set(ck, digedit); | ||
168 | elm_box_pack_end(bx, ck); | ||
169 | elm_clock_time_set(ck, 0, 0, 0); | ||
170 | evas_object_show(ck); | ||
171 | |||
172 | evas_object_show(win); | ||
173 | } | ||
174 | |||
175 | static void | ||
176 | _edit_bt_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__) | ||
177 | { | ||
178 | Evas_Object *ck = data; | ||
179 | |||
180 | if (!elm_clock_edit_get(ck)) | ||
181 | { | ||
182 | elm_object_text_set(obj, "Done"); | ||
183 | elm_clock_edit_set(ck, EINA_TRUE); | ||
184 | return; | ||
185 | } | ||
186 | elm_object_text_set(obj, "Edit"); | ||
187 | elm_clock_edit_set(ck, EINA_FALSE); | ||
188 | } | ||
189 | |||
190 | static void | ||
191 | _hmode_bt_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__) | ||
192 | { | ||
193 | Evas_Object *ck = data; | ||
194 | |||
195 | if (!elm_clock_show_am_pm_get(ck)) | ||
196 | { | ||
197 | elm_object_text_set(obj, "24h"); | ||
198 | elm_clock_show_am_pm_set(ck, EINA_TRUE); | ||
199 | return; | ||
200 | } | ||
201 | elm_object_text_set(obj, "12h"); | ||
202 | elm_clock_show_am_pm_set(ck, EINA_FALSE); | ||
203 | } | ||
204 | |||
205 | void | ||
206 | test_clock2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
207 | { | ||
208 | Evas_Object *win, *bx, *hbx, *ck, *bt, *bxx; | ||
209 | api_data *api = calloc(1, sizeof(api_data)); | ||
210 | |||
211 | win = elm_win_util_standard_add("clock2", "Clock 2"); | ||
212 | elm_win_autodel_set(win, EINA_TRUE); | ||
213 | evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api); | ||
214 | |||
215 | bxx = elm_box_add(win); | ||
216 | elm_win_resize_object_add(win, bxx); | ||
217 | evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
218 | evas_object_show(bxx); | ||
219 | |||
220 | bx = elm_box_add(win); | ||
221 | evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
222 | elm_win_resize_object_add(win, bx); | ||
223 | api->box = bx; | ||
224 | evas_object_show(bx); | ||
225 | |||
226 | bt = elm_button_add(win); | ||
227 | elm_object_text_set(bt, "Next API function"); | ||
228 | evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked, (void *) api); | ||
229 | elm_box_pack_end(bxx, bt); | ||
230 | elm_object_disabled_set(bt, api->state == API_STATE_LAST); | ||
231 | evas_object_show(bt); | ||
232 | |||
233 | elm_box_pack_end(bxx, bx); | ||
234 | |||
235 | ck = elm_clock_add(win); | ||
236 | elm_clock_time_set(ck, 0, 15, 3); | ||
237 | elm_clock_edit_mode_set(ck, ELM_CLOCK_EDIT_DEFAULT); | ||
238 | elm_clock_show_seconds_set(ck, EINA_TRUE); | ||
239 | elm_clock_show_am_pm_set(ck, EINA_TRUE); | ||
240 | elm_box_pack_end(bx, ck); | ||
241 | evas_object_show(ck); | ||
242 | |||
243 | hbx = elm_box_add(win); | ||
244 | evas_object_size_hint_weight_set(hbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
245 | elm_box_horizontal_set(hbx, EINA_TRUE); | ||
246 | elm_box_pack_end(bx, hbx); | ||
247 | evas_object_show(hbx); | ||
248 | |||
249 | bt = elm_button_add(win); | ||
250 | elm_object_text_set(bt, "Edit"); | ||
251 | evas_object_smart_callback_add(bt, "clicked", _edit_bt_clicked, ck); | ||
252 | elm_box_pack_end(hbx, bt); | ||
253 | evas_object_show(bt); | ||
254 | |||
255 | bt = elm_button_add(win); | ||
256 | elm_object_text_set(bt, "24h"); | ||
257 | evas_object_smart_callback_add(bt, "clicked", _hmode_bt_clicked, ck); | ||
258 | elm_box_pack_end(hbx, bt); | ||
259 | evas_object_show(bt); | ||
260 | |||
261 | evas_object_show(win); | ||
262 | } | ||
263 | |||
264 | void | ||
265 | test_clock3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
266 | { | ||
267 | Evas_Object *win, *bx, *ck, *lb; | ||
268 | |||
269 | win = elm_win_util_standard_add("clock3", "Clock 3"); | ||
270 | elm_win_autodel_set(win, EINA_TRUE); | ||
271 | |||
272 | bx = elm_box_add(win); | ||
273 | evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
274 | elm_win_resize_object_add(win, bx); | ||
275 | evas_object_show(bx); | ||
276 | |||
277 | lb = elm_label_add(win); | ||
278 | elm_object_text_set(lb, | ||
279 | "Check time updates for an user mouse button hold." | ||
280 | ); | ||
281 | evas_object_size_hint_weight_set(lb, 0.0, 0.0); | ||
282 | evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
283 | elm_box_pack_end(bx, lb); | ||
284 | evas_object_show(lb); | ||
285 | |||
286 | ck = elm_clock_add(win); | ||
287 | elm_clock_show_seconds_set(ck, 1); | ||
288 | elm_clock_edit_set(ck, EINA_TRUE); | ||
289 | elm_clock_first_interval_set(ck, 0.4); | ||
290 | elm_box_pack_end(bx, ck); | ||
291 | evas_object_show(ck); | ||
292 | |||
293 | ck = elm_clock_add(win); | ||
294 | elm_clock_show_seconds_set(ck, 1); | ||
295 | elm_clock_edit_set(ck, EINA_TRUE); | ||
296 | elm_clock_first_interval_set(ck, 1.2); | ||
297 | elm_box_pack_end(bx, ck); | ||
298 | evas_object_show(ck); | ||
299 | |||
300 | ck = elm_clock_add(win); | ||
301 | elm_clock_show_seconds_set(ck, 1); | ||
302 | elm_clock_edit_set(ck, EINA_TRUE); | ||
303 | elm_clock_first_interval_set(ck, 2.0); | ||
304 | elm_box_pack_end(bx, ck); | ||
305 | evas_object_show(ck); | ||
306 | |||
307 | evas_object_show(win); | ||
308 | } | ||
309 | #endif | ||