2 //gcc -g `pkg-config --cflags --libs elementary` layout_example_03.c -o layout_example_03
4 #include <Elementary.h>
6 # include "elementary_config.h"
9 # define PACKAGE_DATA_DIR "."
12 #define TITLE "example/title"
13 #define SWALLOW "example/custom"
15 static Eina_Bool _btn_large = EINA_FALSE;
18 _swallow_btn_cb(void *data, Evas_Object *btn, void *event_info __UNUSED__)
20 Evas_Object *layout = data;
22 if (_btn_large == EINA_FALSE)
24 _btn_large = EINA_TRUE;
25 elm_object_signal_emit(layout, "button,enlarge", "");
26 elm_object_text_set(btn, "Reduce me!");
30 _btn_large = EINA_FALSE;
31 elm_object_signal_emit(layout, "button,reduce", "");
32 elm_object_text_set(btn, "Enlarge me!");
37 _size_changed_cb(void *data __UNUSED__, Evas_Object *layout, const char *emission __UNUSED__, const char *source __UNUSED__)
42 elm_layout_sizing_eval(layout);
43 edje = elm_layout_edje_get(layout);
44 edje_object_size_min_calc(edje, &w, &h);
45 printf("Minimum size for this theme: %dx%d\n", w, h);
49 elm_main(int argc __UNUSED__, char **argv __UNUSED__)
51 Evas_Object *win, *bg, *btn, *layout;
53 win = elm_win_add(NULL, "layout", ELM_WIN_BASIC);
54 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
55 elm_win_autodel_set(win, EINA_TRUE);
58 elm_bg_color_set(bg, 255,255 ,255);
59 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
60 elm_win_resize_object_add(win, bg);
64 layout = elm_layout_add(win);
65 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
66 elm_win_resize_object_add(win, layout);
68 layout, PACKAGE_DATA_DIR "/examples/layout_example.edj",
70 evas_object_show(layout);
72 elm_object_signal_callback_add(layout, "size,changed", "", _size_changed_cb, layout);
75 const char *title = elm_layout_data_get(layout, "title");
78 elm_win_title_set(win, title);
79 elm_object_part_text_set(layout, TITLE, title);
82 btn = elm_button_add(win);
83 elm_object_text_set(btn, "Enlarge me!");
84 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
85 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
86 elm_object_part_content_set(layout, SWALLOW, btn);
87 evas_object_smart_callback_add(btn, "clicked", _swallow_btn_cb, layout);
89 evas_object_size_hint_min_set(bg, 160, 160);
90 evas_object_size_hint_max_set(bg, 640, 640);
91 evas_object_resize(win, 160, 160);
92 evas_object_show(win);