2 //gcc -o bg_example_03 bg_example_03.c -g `pkg-config --cflags --libs elementary` -DDATA_DIR="\"<directory>\""
3 //where directory is the a path where images/plant_01.jpg can be found.
5 #include <Elementary.h>
7 # define DATA_DIR "/usr/share/elementary"
11 on_done(void *data, Evas_Object *obj, void *event_info)
13 /* quit the mainloop (elm_run) */
18 _cb_radio_changed(void *data, Evas_Object *obj, void *event)
20 Evas_Object *o_bg = data;
22 elm_bg_option_set(o_bg, elm_radio_value_get((Evas_Object *)obj));
26 _cb_overlay_changed(void *data, Evas_Object *obj, void *event)
28 Evas_Object *o_bg = data;
30 if (elm_check_state_get(obj))
32 Evas_Object *parent, *over;
35 snprintf(buff, sizeof(buff), "%s/objects/test.edj", DATA_DIR);
36 parent = elm_object_parent_widget_get(o_bg);
37 over = edje_object_add(evas_object_evas_get(parent));
38 edje_object_file_set(over, buff, "bg_overlay");
39 elm_object_part_content_set(o_bg, "overlay", over);
42 elm_object_part_content_set(o_bg, "overlay", NULL);
46 _cb_color_changed(void *data, Evas_Object *obj, void *event)
48 Evas_Object *o_bg = data;
51 val = elm_spinner_value_get(obj);
53 elm_bg_color_set(o_bg, 255, 255, 255);
55 elm_bg_color_set(o_bg, 255, 0, 0);
57 elm_bg_color_set(o_bg, 0, 0, 255);
59 elm_bg_color_set(o_bg, 0, 255, 0);
63 elm_main(int argc, char **argv)
65 Evas_Object *win, *bg;
66 Evas_Object *box, *hbox, *o_bg;
67 Evas_Object *rd, *rdg;
70 win = elm_win_add(NULL, "bg-options", ELM_WIN_BASIC);
71 elm_win_title_set(win, "Bg Options");
72 evas_object_smart_callback_add(win, "delete,request", on_done, NULL);
73 elm_win_autodel_set(win, EINA_TRUE);
76 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
77 elm_win_resize_object_add(win, bg);
80 box = elm_box_add(win);
81 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
82 elm_win_resize_object_add(win, box);
83 evas_object_show(box);
85 o_bg = elm_bg_add(win);
86 snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", DATA_DIR);
87 elm_bg_file_set(o_bg, buf, NULL);
88 evas_object_size_hint_weight_set(o_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
89 evas_object_size_hint_align_set(o_bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
90 elm_box_pack_end(box, o_bg);
91 evas_object_show(o_bg);
93 hbox = elm_box_add(win);
94 elm_box_horizontal_set(hbox, EINA_TRUE);
95 evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
96 evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
98 rd = elm_radio_add(win);
99 elm_radio_state_value_set(rd, ELM_BG_OPTION_CENTER);
100 elm_object_text_set(rd, "Center");
101 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
102 evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
103 elm_box_pack_end(hbox, rd);
104 evas_object_show(rd);
107 rd = elm_radio_add(win);
108 elm_radio_state_value_set(rd, ELM_BG_OPTION_SCALE);
109 elm_radio_group_add(rd, rdg);
110 elm_object_text_set(rd, "Scale");
111 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
112 evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
113 elm_box_pack_end(hbox, rd);
114 evas_object_show(rd);
116 rd = elm_radio_add(win);
117 elm_radio_state_value_set(rd, ELM_BG_OPTION_STRETCH);
118 elm_radio_group_add(rd, rdg);
119 elm_object_text_set(rd, "Stretch");
120 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
121 evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
122 elm_box_pack_end(hbox, rd);
123 evas_object_show(rd);
125 rd = elm_radio_add(win);
126 elm_radio_state_value_set(rd, ELM_BG_OPTION_TILE);
127 elm_radio_group_add(rd, rdg);
128 elm_object_text_set(rd, "Tile");
129 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
130 evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
131 elm_box_pack_end(hbox, rd);
132 evas_object_show(rd);
134 elm_radio_value_set(rdg, ELM_BG_OPTION_SCALE);
136 rd = elm_check_add(win);
137 elm_object_text_set(rd, "Show Overlay");
138 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
139 evas_object_smart_callback_add(rd, "changed", _cb_overlay_changed, o_bg);
140 elm_box_pack_end(hbox, rd);
141 evas_object_show(rd);
143 /* color choices ... this is ghetto, but we don't have a 'colorpicker'
145 rd = elm_spinner_add(win);
146 elm_object_style_set(rd, "vertical");
147 elm_spinner_min_max_set(rd, 1, 4);
148 elm_spinner_label_format_set(rd, "%.0f");
149 elm_spinner_editable_set(rd, EINA_FALSE);
150 elm_spinner_special_value_add(rd, 1, "White");
151 elm_spinner_special_value_add(rd, 2, "Red");
152 elm_spinner_special_value_add(rd, 3, "Blue");
153 elm_spinner_special_value_add(rd, 4, "Green");
154 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
155 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, EVAS_HINT_FILL);
156 evas_object_smart_callback_add(rd, "changed", _cb_color_changed, o_bg);
157 elm_box_pack_end(hbox, rd);
158 evas_object_show(rd);
160 elm_box_pack_end(box, hbox);
161 evas_object_show(hbox);
163 evas_object_size_hint_min_set(bg, 160, 160);
164 evas_object_size_hint_max_set(bg, 640, 640);
165 evas_object_resize(win, 320, 320);
166 evas_object_show(win);