2 //gcc -o bg_example_03 bg_example_03.c -g `pkg-config --cflags --libs elementary` -DPACKAGE_DATA_DIR="\"<directory>\""
3 //where directory is the a path where images/plant_01.jpg can be found.
5 #include <Elementary.h>
8 on_done(void *data, Evas_Object *obj, void *event_info)
10 /* quit the mainloop (elm_run) */
15 _cb_radio_changed(void *data, Evas_Object *obj, void *event)
17 Evas_Object *o_bg = data;
19 elm_bg_option_set(o_bg, elm_radio_value_get((Evas_Object *)obj));
23 _cb_overlay_changed(void *data, Evas_Object *obj, void *event)
25 Evas_Object *o_bg = data;
27 if (elm_check_state_get(obj))
29 Evas_Object *parent, *over;
32 snprintf(buff, sizeof(buff), "%s/objects/test.edj", PACKAGE_DATA_DIR);
33 parent = elm_object_parent_widget_get(o_bg);
34 over = edje_object_add(evas_object_evas_get(parent));
35 edje_object_file_set(over, buff, "bg_overlay");
36 elm_object_part_content_set(o_bg, "overlay", over);
39 elm_object_part_content_set(o_bg, "overlay", NULL);
43 _cb_color_changed(void *data, Evas_Object *obj, void *event)
45 Evas_Object *o_bg = data;
48 val = elm_spinner_value_get(obj);
50 elm_bg_color_set(o_bg, 255, 255, 255);
52 elm_bg_color_set(o_bg, 255, 0, 0);
54 elm_bg_color_set(o_bg, 0, 0, 255);
56 elm_bg_color_set(o_bg, 0, 255, 0);
60 elm_main(int argc, char **argv)
62 Evas_Object *win, *bg;
63 Evas_Object *box, *hbox, *o_bg;
64 Evas_Object *rd, *rdg;
67 win = elm_win_add(NULL, "bg-options", ELM_WIN_BASIC);
68 elm_win_title_set(win, "Bg Options");
69 evas_object_smart_callback_add(win, "delete,request", on_done, NULL);
70 elm_win_autodel_set(win, EINA_TRUE);
73 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
74 elm_win_resize_object_add(win, bg);
77 box = elm_box_add(win);
78 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
79 elm_win_resize_object_add(win, box);
80 evas_object_show(box);
82 o_bg = elm_bg_add(win);
83 snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", PACKAGE_DATA_DIR);
84 elm_bg_file_set(o_bg, buf, NULL);
85 evas_object_size_hint_weight_set(o_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
86 evas_object_size_hint_align_set(o_bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
87 elm_box_pack_end(box, o_bg);
88 evas_object_show(o_bg);
90 hbox = elm_box_add(win);
91 elm_box_horizontal_set(hbox, EINA_TRUE);
92 evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
93 evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
95 rd = elm_radio_add(win);
96 elm_radio_state_value_set(rd, ELM_BG_OPTION_CENTER);
97 elm_object_text_set(rd, "Center");
98 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
99 evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
100 elm_box_pack_end(hbox, rd);
101 evas_object_show(rd);
104 rd = elm_radio_add(win);
105 elm_radio_state_value_set(rd, ELM_BG_OPTION_SCALE);
106 elm_radio_group_add(rd, rdg);
107 elm_object_text_set(rd, "Scale");
108 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
109 evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
110 elm_box_pack_end(hbox, rd);
111 evas_object_show(rd);
113 rd = elm_radio_add(win);
114 elm_radio_state_value_set(rd, ELM_BG_OPTION_STRETCH);
115 elm_radio_group_add(rd, rdg);
116 elm_object_text_set(rd, "Stretch");
117 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
118 evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
119 elm_box_pack_end(hbox, rd);
120 evas_object_show(rd);
122 rd = elm_radio_add(win);
123 elm_radio_state_value_set(rd, ELM_BG_OPTION_TILE);
124 elm_radio_group_add(rd, rdg);
125 elm_object_text_set(rd, "Tile");
126 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
127 evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
128 elm_box_pack_end(hbox, rd);
129 evas_object_show(rd);
131 elm_radio_value_set(rdg, ELM_BG_OPTION_SCALE);
133 rd = elm_check_add(win);
134 elm_object_text_set(rd, "Show Overlay");
135 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
136 evas_object_smart_callback_add(rd, "changed", _cb_overlay_changed, o_bg);
137 elm_box_pack_end(hbox, rd);
138 evas_object_show(rd);
140 /* color choices ... this is ghetto, but we don't have a 'colorpicker'
142 rd = elm_spinner_add(win);
143 elm_object_style_set(rd, "vertical");
144 elm_spinner_min_max_set(rd, 1, 4);
145 elm_spinner_label_format_set(rd, "%.0f");
146 elm_spinner_editable_set(rd, EINA_FALSE);
147 elm_spinner_special_value_add(rd, 1, "White");
148 elm_spinner_special_value_add(rd, 2, "Red");
149 elm_spinner_special_value_add(rd, 3, "Blue");
150 elm_spinner_special_value_add(rd, 4, "Green");
151 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
152 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, EVAS_HINT_FILL);
153 evas_object_smart_callback_add(rd, "changed", _cb_color_changed, o_bg);
154 elm_box_pack_end(hbox, rd);
155 evas_object_show(rd);
157 elm_box_pack_end(box, hbox);
158 evas_object_show(hbox);
160 evas_object_size_hint_min_set(bg, 160, 160);
161 evas_object_size_hint_max_set(bg, 640, 640);
162 evas_object_resize(win, 320, 320);
163 evas_object_show(win);