2 //gcc -o bg_example_03 bg_example_03.c -g `pkg-config --cflags --libs elementary`
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", elm_app_data_dir_get());
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 elm_app_info_set(elm_main, "elementary", "objects/test.edj");
68 win = elm_win_add(NULL, "bg-options", ELM_WIN_BASIC);
69 elm_win_title_set(win, "Bg Options");
70 evas_object_smart_callback_add(win, "delete,request", on_done, NULL);
71 elm_win_autodel_set(win, EINA_TRUE);
74 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
75 elm_win_resize_object_add(win, bg);
78 box = elm_box_add(win);
79 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
80 elm_win_resize_object_add(win, box);
81 evas_object_show(box);
83 o_bg = elm_bg_add(win);
84 snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
85 elm_bg_file_set(o_bg, buf, NULL);
86 evas_object_size_hint_weight_set(o_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
87 evas_object_size_hint_align_set(o_bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
88 elm_box_pack_end(box, o_bg);
89 evas_object_show(o_bg);
91 hbox = elm_box_add(win);
92 elm_box_horizontal_set(hbox, EINA_TRUE);
93 evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
94 evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
96 rd = elm_radio_add(win);
97 elm_radio_state_value_set(rd, ELM_BG_OPTION_CENTER);
98 elm_object_text_set(rd, "Center");
99 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
100 evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
101 elm_box_pack_end(hbox, rd);
102 evas_object_show(rd);
105 rd = elm_radio_add(win);
106 elm_radio_state_value_set(rd, ELM_BG_OPTION_SCALE);
107 elm_radio_group_add(rd, rdg);
108 elm_object_text_set(rd, "Scale");
109 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
110 evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
111 elm_box_pack_end(hbox, rd);
112 evas_object_show(rd);
114 rd = elm_radio_add(win);
115 elm_radio_state_value_set(rd, ELM_BG_OPTION_STRETCH);
116 elm_radio_group_add(rd, rdg);
117 elm_object_text_set(rd, "Stretch");
118 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
119 evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
120 elm_box_pack_end(hbox, rd);
121 evas_object_show(rd);
123 rd = elm_radio_add(win);
124 elm_radio_state_value_set(rd, ELM_BG_OPTION_TILE);
125 elm_radio_group_add(rd, rdg);
126 elm_object_text_set(rd, "Tile");
127 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
128 evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
129 elm_box_pack_end(hbox, rd);
130 evas_object_show(rd);
132 elm_radio_value_set(rdg, ELM_BG_OPTION_SCALE);
134 rd = elm_check_add(win);
135 elm_object_text_set(rd, "Show Overlay");
136 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
137 evas_object_smart_callback_add(rd, "changed", _cb_overlay_changed, o_bg);
138 elm_box_pack_end(hbox, rd);
139 evas_object_show(rd);
141 /* color choices ... this is ghetto, but we don't have a 'colorpicker'
143 rd = elm_spinner_add(win);
144 elm_object_style_set(rd, "vertical");
145 elm_spinner_min_max_set(rd, 1, 4);
146 elm_spinner_label_format_set(rd, "%.0f");
147 elm_spinner_editable_set(rd, EINA_FALSE);
148 elm_spinner_special_value_add(rd, 1, "White");
149 elm_spinner_special_value_add(rd, 2, "Red");
150 elm_spinner_special_value_add(rd, 3, "Blue");
151 elm_spinner_special_value_add(rd, 4, "Green");
152 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
153 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, EVAS_HINT_FILL);
154 evas_object_smart_callback_add(rd, "changed", _cb_color_changed, o_bg);
155 elm_box_pack_end(hbox, rd);
156 evas_object_show(rd);
158 elm_box_pack_end(box, hbox);
159 evas_object_show(hbox);
161 evas_object_resize(win, 460, 320);
162 evas_object_show(win);