2 //gcc -g `pkg-config --cflags --libs elementary` layout_example_03.c -o layout_example_03
4 #include <Elementary.h>
5 #define PACKAGE_DATA_DIR "."
7 #define TITLE "example/title"
8 #define SWALLOW "example/custom"
10 static Eina_Bool _btn_large = EINA_FALSE;
13 _swallow_btn_cb(void *data, Evas_Object *btn, void *event_info)
15 Evas_Object *layout = data;
17 if (_btn_large == EINA_FALSE)
19 _btn_large = EINA_TRUE;
20 elm_object_signal_emit(layout, "button,enlarge", "");
21 elm_object_text_set(btn, "Reduce me!");
25 _btn_large = EINA_FALSE;
26 elm_object_signal_emit(layout, "button,reduce", "");
27 elm_object_text_set(btn, "Enlarge me!");
32 _size_changed_cb(void *data, Evas_Object *layout, const char *emission, const char *source)
37 elm_layout_sizing_eval(layout);
38 edje = elm_layout_edje_get(layout);
39 edje_object_size_min_calc(edje, &w, &h);
40 printf("Minimum size for this theme: %dx%d\n", w, h);
44 elm_main(int argc, char **argv)
46 Evas_Object *win, *bg, *btn, *layout;
48 win = elm_win_add(NULL, "layout", ELM_WIN_BASIC);
49 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
50 elm_win_autodel_set(win, EINA_TRUE);
53 elm_bg_color_set(bg, 255,255 ,255);
54 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
55 elm_win_resize_object_add(win, bg);
59 layout = elm_layout_add(win);
60 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
61 elm_win_resize_object_add(win, layout);
63 layout, PACKAGE_DATA_DIR "/examples/layout_example.edj",
65 evas_object_show(layout);
67 elm_object_signal_callback_add(layout, "size,changed", "", _size_changed_cb, layout);
70 const char *title = elm_layout_data_get(layout, "title");
73 elm_win_title_set(win, title);
74 elm_object_part_text_set(layout, TITLE, title);
77 btn = elm_button_add(win);
78 elm_object_text_set(btn, "Enlarge me!");
79 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
80 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
81 elm_object_part_content_set(layout, SWALLOW, btn);
82 evas_object_smart_callback_add(btn, "clicked", _swallow_btn_cb, layout);
84 evas_object_size_hint_min_set(bg, 160, 160);
85 evas_object_size_hint_max_set(bg, 640, 640);
86 evas_object_resize(win, 160, 160);
87 evas_object_show(win);