3 # include "elementary_config.h"
5 #include <Elementary.h>
6 #ifndef ELM_LIB_QUICKLAUNCH
11 BOX_PACK_POSITION_START,
12 BOX_PACK_POSITION_BEFORE,
13 BOX_PACK_POSITION_AFTER,
19 unsigned int state; /* What state we are testing */
20 void *box; /* Use this to get box content */
22 typedef struct _api_data api_data;
36 typedef enum _api_state api_state;
39 set_api_state(api_data *api)
41 const Eina_List *items = elm_box_children_get(api->box);
42 if (!eina_list_count(items))
45 /* use elm_box_children_get() to get list of children */
47 { /* Put all api-changes under switch */
48 case BOX_PACK_START: /* Move last item to begining */
49 elm_box_unpack(api->box, eina_list_data_get(eina_list_last(items)));
50 elm_box_pack_start(api->box, eina_list_data_get(eina_list_last(items)));
54 if (eina_list_count(items) > 1)
55 { /* Put last item before the one preceeding it */
56 elm_box_unpack(api->box, eina_list_data_get(eina_list_last(items)));
57 elm_box_pack_before(api->box,
58 eina_list_data_get(eina_list_last(items)),
59 eina_list_nth(items, eina_list_count(items)-2));
64 if (eina_list_count(items) > 1)
65 { /* Put item before last to last */
66 elm_box_unpack(api->box, eina_list_nth(items,
67 eina_list_count(items)-2));
68 elm_box_pack_after(api->box,
69 eina_list_nth(items, eina_list_count(items)-2),
70 eina_list_data_get(eina_list_last(items)));
75 elm_box_padding_set(api->box, 30, 15);
79 elm_box_align_set(api->box, 0.25, 0.75);
82 case BOX_HOMOGENEOUS_SET:
83 elm_box_homogeneous_set(api->box, EINA_TRUE);
90 elm_box_unpack_all(api->box);
91 EINA_LIST_REVERSE_FOREACH(items, l, data)
92 elm_box_pack_end(api->box, data);
97 elm_box_clear(api->box);
109 _api_bt_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
110 { /* Will add here a SWITCH command containing code to modify test-object */
111 /* in accordance a->state value. */
115 printf("clicked event on API Button: api_state=<%d>\n", a->state);
118 sprintf(str, "Next API function (%u)", a->state);
119 elm_object_text_set(obj, str);
120 elm_object_disabled_set(obj, a->state == API_STATE_LAST);
124 _cleanup_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
130 test_box_vert(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
132 Evas_Object *win, *bx, *ic, *bxx, *bt;
134 api_data *api = calloc(1, sizeof(api_data));
136 win = elm_win_util_standard_add("box-vert", "Box Vert");
137 elm_win_autodel_set(win, EINA_TRUE);
138 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
140 bxx = elm_box_add(win);
141 elm_win_resize_object_add(win, bxx);
142 evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
143 evas_object_show(bxx);
145 bx = elm_box_add(win);
147 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
148 evas_object_show(bx);
150 bt = elm_button_add(win);
151 elm_object_text_set(bt, "Next API function");
152 evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked, (void *) api);
153 elm_box_pack_end(bxx, bt);
154 elm_object_disabled_set(bt, api->state == API_STATE_LAST);
155 evas_object_show(bt);
157 elm_box_pack_end(bxx, bx);
159 ic = elm_icon_add(win);
160 snprintf(buf, sizeof(buf), "%s/images/icon_01.png", elm_app_data_dir_get());
161 elm_image_file_set(ic, buf, NULL);
162 elm_image_resizable_set(ic, 0, 0);
163 evas_object_size_hint_align_set(ic, 0.5, 0.5);
164 elm_box_pack_end(bx, ic);
165 evas_object_show(ic);
167 ic = elm_icon_add(win);
168 snprintf(buf, sizeof(buf), "%s/images/icon_02.png", elm_app_data_dir_get());
169 elm_image_file_set(ic, buf, NULL);
170 elm_image_resizable_set(ic, 0, 0);
171 evas_object_size_hint_align_set(ic, 0.0, 0.5);
172 elm_box_pack_end(bx, ic);
173 evas_object_show(ic);
175 ic = elm_icon_add(win);
176 snprintf(buf, sizeof(buf), "%s/images/icon_03.png", elm_app_data_dir_get());
177 elm_image_file_set(ic, buf, NULL);
178 elm_image_resizable_set(ic, 0, 0);
179 evas_object_size_hint_align_set(ic, EVAS_HINT_EXPAND, 0.5);
180 elm_box_pack_end(bx, ic);
181 evas_object_show(ic);
183 evas_object_show(win);
187 _del_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
189 elm_box_unpack(data, obj);
190 evas_object_move(obj, 0, 0);
191 evas_object_color_set(obj, 128, 64, 0, 128);
192 evas_object_del(obj);
196 test_box_vert2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
198 Evas_Object *win, *bx, *bt;
200 win = elm_win_util_standard_add("box-vert2", "Box Vert 2");
201 elm_win_autodel_set(win, EINA_TRUE);
203 bx = elm_box_add(win);
204 elm_win_resize_object_add(win, bx);
205 elm_box_padding_set(bx, 10, 10);
206 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
207 evas_object_show(bx);
209 bt = elm_button_add(win);
210 elm_object_text_set(bt, "Button 1");
211 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
212 evas_object_size_hint_weight_set(bt, 0.0, 0.0);
213 evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
214 elm_box_pack_end(bx, bt);
215 evas_object_show(bt);
217 bt = elm_button_add(win);
218 elm_object_text_set(bt, "Button 2");
219 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
220 evas_object_size_hint_weight_set(bt, 0.0, 0.0);
221 evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
222 elm_box_pack_end(bx, bt);
223 evas_object_show(bt);
225 bt = elm_button_add(win);
226 elm_object_text_set(bt, "Button 3");
227 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
228 evas_object_size_hint_weight_set(bt, 0.0, 0.0);
229 evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
230 elm_box_pack_end(bx, bt);
231 evas_object_show(bt);
233 bt = elm_button_add(win);
234 elm_object_text_set(bt, "Button 4");
235 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
236 evas_object_size_hint_weight_set(bt, 0.0, 0.0);
237 evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
238 elm_box_pack_end(bx, bt);
239 evas_object_show(bt);
241 bt = elm_button_add(win);
242 elm_object_text_set(bt, "Button 5");
243 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
244 evas_object_size_hint_weight_set(bt, 0.0, 0.0);
245 evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
246 elm_box_pack_end(bx, bt);
247 evas_object_show(bt);
249 evas_object_show(win);
253 test_box_horiz(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
255 Evas_Object *win, *bx, *ic, *bxx, *bt;
257 api_data *api = calloc(1, sizeof(api_data));
259 win = elm_win_util_standard_add("box-horiz", "Box Horiz");
260 elm_win_autodel_set(win, EINA_TRUE);
261 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
263 bxx = elm_box_add(win);
264 elm_win_resize_object_add(win, bxx);
265 evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
266 evas_object_show(bxx);
268 bx = elm_box_add(win);
269 elm_box_horizontal_set(bx, EINA_TRUE);
270 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
272 evas_object_show(bx);
274 bt = elm_button_add(win);
275 elm_object_text_set(bt, "Next API function");
276 evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked, (void *) api);
277 elm_box_pack_end(bxx, bt);
278 elm_object_disabled_set(bt, api->state == API_STATE_LAST);
279 evas_object_show(bt);
281 elm_box_pack_end(bxx, bx);
283 ic = elm_icon_add(win);
284 snprintf(buf, sizeof(buf), "%s/images/icon_01.png", elm_app_data_dir_get());
285 elm_image_file_set(ic, buf, NULL);
286 elm_image_resizable_set(ic, 0, 0);
287 evas_object_size_hint_align_set(ic, 0.5, 0.5);
288 elm_box_pack_end(bx, ic);
289 evas_object_show(ic);
291 ic = elm_icon_add(win);
292 snprintf(buf, sizeof(buf), "%s/images/icon_02.png", elm_app_data_dir_get());
293 elm_image_file_set(ic, buf, NULL);
294 elm_image_resizable_set(ic, 0, 0);
295 evas_object_size_hint_align_set(ic, 0.5, 0.0);
296 elm_box_pack_end(bx, ic);
297 evas_object_show(ic);
299 ic = elm_icon_add(win);
300 snprintf(buf, sizeof(buf), "%s/images/icon_03.png", elm_app_data_dir_get());
301 elm_image_file_set(ic, buf, NULL);
302 elm_image_resizable_set(ic, 0, 0);
303 evas_object_size_hint_align_set(ic, 0.0, EVAS_HINT_EXPAND);
304 elm_box_pack_end(bx, ic);
305 evas_object_show(ic);
307 evas_object_show(win);
310 static Eina_Bool radio_index[ICON_MAX];
316 for (i = 0; i < ICON_MAX; i++)
320 radio_index[i] = EINA_TRUE;
331 if (i >= ICON_MAX) return;
332 radio_index[i] = EINA_FALSE;
339 for (i = 0; i < ICON_MAX; i++)
340 radio_index[i] = EINA_FALSE;
344 _radio_new(Evas_Object *obj)
346 Evas_Object *ic, *rd;
352 if (idx == -1) return NULL;
354 ic = elm_icon_add(obj);
355 snprintf(buf, sizeof(buf), "%s/images/icon_%02d.png",
356 elm_app_data_dir_get(), idx);
357 elm_image_file_set(ic, buf, NULL);
358 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
360 rd = elm_radio_add(obj);
361 elm_radio_state_value_set(rd, idx);
362 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
363 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, 0.5);
364 elm_object_part_content_set(rd, "icon", ic);
366 rdg = evas_object_data_get(obj, "radio-group");
367 if (rdg) elm_radio_group_add(rd, rdg);
369 evas_object_show(rd);
370 evas_object_show(ic);
376 _pack_start_btn_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
381 rd = _radio_new(data);
383 elm_box_pack_start(data, rd);
387 _pack_before_btn_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
389 Evas_Object *rd, *selected_rd, *rdg;
392 rdg = evas_object_data_get(data, "radio-group");
395 selected_rd = elm_radio_selected_object_get(rdg);
396 if (!selected_rd || (selected_rd == rdg)) return;
398 rd = _radio_new(data);
400 elm_box_pack_before(data, rd, selected_rd);
404 _pack_after_btn_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
406 Evas_Object *rd, *selected_rd, *rdg;
409 rdg = evas_object_data_get(data, "radio-group");
412 selected_rd = elm_radio_selected_object_get(rdg);
413 if (!selected_rd || (selected_rd == rdg)) return;
415 rd = _radio_new(data);
417 elm_box_pack_after(data, rd, selected_rd);
421 _pack_end_btn_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
426 rd = _radio_new(data);
428 elm_box_pack_end(data, rd);
432 _unpack_btn_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
434 Evas_Object *rdg, *selected_rd;
437 rdg = evas_object_data_get(data, "radio-group");
440 selected_rd = elm_radio_selected_object_get(rdg);
441 if (selected_rd == rdg) return;
443 _index_remove(elm_radio_value_get(selected_rd));
444 elm_box_unpack(data, selected_rd);
445 evas_object_del(selected_rd);
446 elm_radio_value_set(rdg, -1);
450 _unpack_all_btn_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
452 Evas_Object *radio, *rdg;
456 rdg = evas_object_data_get(data, "radio-group");
460 rl = elm_box_children_get(data);
461 EINA_LIST_FOREACH(rl, l, radio)
464 evas_object_del(radio);
466 elm_box_unpack_all(data);
467 elm_radio_value_set(rdg, -1);
471 test_box_pack(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
473 Evas_Object *win, *sc, *bt;
474 Evas_Object *box, *lbox, *rbox;
475 Evas_Object *rd, *rdg = NULL;
478 win = elm_win_util_standard_add("box-pack", "Box Pack");
479 elm_win_autodel_set(win, EINA_TRUE);
481 box = elm_box_add(win);
482 elm_box_horizontal_set(box, EINA_TRUE);
483 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
484 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
485 elm_win_resize_object_add(win, box);
486 evas_object_show(box);
489 lbox = elm_box_add(win);
490 evas_object_size_hint_weight_set(lbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
491 evas_object_size_hint_align_set(lbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
493 sc = elm_scroller_add(win);
494 elm_scroller_bounce_set(sc, EINA_FALSE, EINA_TRUE);
495 evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
496 evas_object_size_hint_align_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL);
498 rdg = elm_radio_add(win); /* a radio for easy group handling */
499 elm_radio_state_value_set(rdg, -1);
500 evas_object_data_set(lbox, "radio-group", rdg);
502 for (i = 0; i < 3; i++)
504 rd = _radio_new(lbox);
505 elm_box_pack_end(lbox, rd);
508 elm_object_content_set(sc, lbox);
509 evas_object_show(lbox);
510 elm_box_pack_end(box, sc);
511 evas_object_show(sc);
514 rbox = elm_box_add(win);
515 evas_object_size_hint_weight_set(rbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
516 evas_object_size_hint_align_set(rbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
517 evas_object_show(rbox);
518 elm_box_pack_end(box, rbox);
520 bt = elm_button_add(win);
521 elm_object_text_set(bt, "Pack Start");
522 evas_object_show(bt);
523 elm_box_pack_end(rbox, bt);
524 evas_object_smart_callback_add(bt, "clicked", _pack_start_btn_cb, lbox);
526 bt = elm_button_add(win);
527 elm_object_text_set(bt, "Pack Before");
528 evas_object_show(bt);
529 elm_box_pack_end(rbox, bt);
530 evas_object_smart_callback_add(bt, "clicked", _pack_before_btn_cb, lbox);
532 bt = elm_button_add(win);
533 elm_object_text_set(bt, "Pack After");
534 evas_object_show(bt);
535 elm_box_pack_end(rbox, bt);
536 evas_object_smart_callback_add(bt, "clicked", _pack_after_btn_cb, lbox);
538 bt = elm_button_add(win);
539 elm_object_text_set(bt, "Pack End");
540 evas_object_show(bt);
541 elm_box_pack_end(rbox, bt);
542 evas_object_smart_callback_add(bt, "clicked", _pack_end_btn_cb, lbox);
544 bt = elm_button_add(win);
545 elm_object_text_set(bt, "Unpack");
546 evas_object_show(bt);
547 elm_box_pack_end(rbox, bt);
548 evas_object_smart_callback_add(bt, "clicked", _unpack_btn_cb, lbox);
550 bt = elm_button_add(win);
551 elm_object_text_set(bt, "Unpack All");
552 evas_object_show(bt);
553 elm_box_pack_end(rbox, bt);
554 evas_object_smart_callback_add(bt, "clicked", _unpack_all_btn_cb, lbox);
556 evas_object_resize(win, 320, 320);
557 evas_object_show(win);
561 _cb_check_changed(void *data, Evas_Object *obj, void *event __UNUSED__)
564 Evas_Object *box = data;
566 homo = elm_check_state_get(obj);
567 elm_box_homogeneous_set(box, homo);
571 test_box_homo(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
574 Evas_Object *box, *o_bg;
578 win = elm_win_util_standard_add("box-homogeneous", "Box Homogeneous");
579 elm_win_autodel_set(win, EINA_TRUE);
581 box = elm_box_add(win);
582 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
583 elm_win_resize_object_add(win, box);
584 evas_object_show(box);
586 o_bg = elm_bg_add(win);
587 snprintf(buf, sizeof(buf), "%s/images/twofish.jpg", elm_app_data_dir_get());
588 elm_bg_file_set(o_bg, buf, NULL);
589 evas_object_size_hint_weight_set(o_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
590 evas_object_size_hint_align_set(o_bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
591 elm_box_pack_end(box, o_bg);
593 rd = elm_check_add(win);
594 elm_object_text_set(rd, "Homogeneous");
595 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
596 evas_object_smart_callback_add(rd, "changed", _cb_check_changed, box);
597 elm_box_pack_end(box, rd);
598 evas_object_show(rd);
599 evas_object_show(o_bg);
601 evas_object_resize(win, 320, 320);
602 evas_object_show(win);
607 Eina_List *transitions;
609 Evas_Object_Box_Layout last_layout;
613 _test_box_transition_change(void *data)
615 Transitions_Data *tdata = data;
616 Elm_Box_Transition *layout_data;
617 Evas_Object_Box_Layout next_layout;
620 next_layout = eina_list_data_get(tdata->transitions);
621 layout_data = elm_box_transition_new(2.0, tdata->last_layout,
622 NULL, NULL, next_layout, NULL, NULL,
623 _test_box_transition_change, tdata);
624 elm_box_layout_set(tdata->box, elm_box_layout_transition, layout_data, elm_box_transition_free);
625 tdata->last_layout = next_layout;
627 tdata->transitions = eina_list_demote_list(tdata->transitions, tdata->transitions);
631 _win_del(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
633 Transitions_Data *tdata = data;
639 test_box_transition(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
641 Evas_Object *win, *bx, *bt;
642 Transitions_Data *tdata;
644 win = elm_win_util_standard_add("box-transition", "Box Transition");
645 elm_win_autodel_set(win, EINA_TRUE);
647 bx = elm_box_add(win);
648 elm_win_resize_object_add(win, bx);
649 evas_object_size_hint_weight_set(bx, 1.0, 1.0);
650 evas_object_show(bx);
652 bt = elm_button_add(win);
653 elm_object_text_set(bt, "Button 1");
654 evas_object_size_hint_weight_set(bt, 1.0, 1.0);
655 evas_object_size_hint_align_set(bt, -1.0, -1.0);
656 evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
657 elm_box_pack_end(bx, bt);
658 evas_object_resize(bt, 100, 100);
659 evas_object_show(bt);
661 bt = elm_button_add(win);
662 elm_object_text_set(bt, "Button 2");
663 evas_object_size_hint_weight_set(bt, 1.0, 1.0);
664 evas_object_size_hint_align_set(bt, -1.0, -1.0);
665 evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
666 elm_box_pack_end(bx, bt);
667 evas_object_resize(bt, 100, 100);
668 evas_object_show(bt);
670 bt = elm_button_add(win);
671 elm_object_text_set(bt, "Button 3");
672 evas_object_size_hint_weight_set(bt, 1.0, 1.0);
673 evas_object_size_hint_align_set(bt, -1.0, -1.0);
674 evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
675 elm_box_pack_end(bx, bt);
676 evas_object_resize(bt, 100, 100);
677 evas_object_show(bt);
679 tdata = calloc(1, sizeof(Transitions_Data));
681 tdata->last_layout = evas_object_box_layout_horizontal;
682 tdata->transitions = eina_list_append(tdata->transitions,
683 evas_object_box_layout_vertical);
684 tdata->transitions = eina_list_append(tdata->transitions,
685 evas_object_box_layout_horizontal);
686 tdata->transitions = eina_list_append(tdata->transitions,
687 evas_object_box_layout_stack);
688 tdata->transitions = eina_list_append(tdata->transitions,
689 evas_object_box_layout_homogeneous_vertical);
690 tdata->transitions = eina_list_append(tdata->transitions,
691 evas_object_box_layout_homogeneous_horizontal);
692 tdata->transitions = eina_list_append(tdata->transitions,
693 evas_object_box_layout_flow_vertical);
694 tdata->transitions = eina_list_append(tdata->transitions,
695 evas_object_box_layout_flow_horizontal);
696 tdata->transitions = eina_list_append(tdata->transitions,
697 evas_object_box_layout_stack);
699 evas_object_resize(win, 300, 300);
700 evas_object_resize(bx, 300, 300);
701 evas_object_smart_callback_add(win, "delete,request", _win_del, tdata);
702 evas_object_show(win);
703 elm_box_layout_set(bx, evas_object_box_layout_horizontal, NULL, NULL);
704 _test_box_transition_change(tdata);