summaryrefslogtreecommitdiff
path: root/src/examples/elementary/bg_example_03.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-03-23 12:56:14 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-03-23 13:24:41 -0700
commitc2a1c49ab2042f559b28e840e54feb8494888e0e (patch)
treec6eb110b7c479499854eede9d0c3ab0a80c9a11a /src/examples/elementary/bg_example_03.c
parent9340855597e7e465435c69b6278650346688da14 (diff)
elementary: move all legacy files to their expected new location.
Diffstat (limited to 'src/examples/elementary/bg_example_03.c')
-rw-r--r--src/examples/elementary/bg_example_03.c156
1 files changed, 156 insertions, 0 deletions
diff --git a/src/examples/elementary/bg_example_03.c b/src/examples/elementary/bg_example_03.c
new file mode 100644
index 0000000000..be44f2576d
--- /dev/null
+++ b/src/examples/elementary/bg_example_03.c
@@ -0,0 +1,156 @@
1//Compile with:
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.
4
5#include <Elementary.h>
6
7static void
8_cb_radio_changed(void *data, Evas_Object *obj, void *event)
9{
10 Evas_Object *o_bg = data;
11
12 elm_bg_option_set(o_bg, elm_radio_value_get((Evas_Object *)obj));
13}
14
15static void
16_cb_overlay_changed(void *data, Evas_Object *obj, void *event)
17{
18 Evas_Object *o_bg = data;
19
20 if (elm_check_state_get(obj))
21 {
22 Evas_Object *parent, *over;
23 char buff[PATH_MAX];
24
25 snprintf(buff, sizeof(buff), "%s/objects/test.edj", elm_app_data_dir_get());
26 parent = elm_object_parent_widget_get(o_bg);
27 over = edje_object_add(evas_object_evas_get(parent));
28 edje_object_file_set(over, buff, "bg_overlay");
29 elm_object_part_content_set(o_bg, "overlay", over);
30 }
31 else
32 elm_object_part_content_set(o_bg, "overlay", NULL);
33}
34
35static void
36_cb_color_changed(void *data, Evas_Object *obj, void *event)
37{
38 Evas_Object *o_bg = data;
39 double val = 0.0;
40
41 val = elm_spinner_value_get(obj);
42 if (val == 1.0)
43 elm_bg_color_set(o_bg, 255, 255, 255);
44 else if (val == 2.0)
45 elm_bg_color_set(o_bg, 255, 0, 0);
46 else if (val == 3.0)
47 elm_bg_color_set(o_bg, 0, 0, 255);
48 else if (val == 4.0)
49 elm_bg_color_set(o_bg, 0, 255, 0);
50}
51
52EAPI_MAIN int
53elm_main(int argc, char **argv)
54{
55 Evas_Object *win;
56 Evas_Object *box, *hbox, *o_bg;
57 Evas_Object *rd, *rdg;
58 char buf[PATH_MAX];
59
60 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
61 elm_app_info_set(elm_main, "elementary", "objects/test.edj");
62
63 win = elm_win_util_standard_add("bg-options", "Bg Options");
64 elm_win_autodel_set(win, EINA_TRUE);
65
66 box = elm_box_add(win);
67 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
68 elm_win_resize_object_add(win, box);
69 evas_object_show(box);
70
71 o_bg = elm_bg_add(win);
72 snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
73 elm_bg_file_set(o_bg, buf, NULL);
74 evas_object_size_hint_weight_set(o_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
75 evas_object_size_hint_align_set(o_bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
76 elm_box_pack_end(box, o_bg);
77 evas_object_show(o_bg);
78
79 hbox = elm_box_add(win);
80 elm_box_horizontal_set(hbox, EINA_TRUE);
81 evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
82 evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
83
84 rd = elm_radio_add(win);
85 elm_radio_state_value_set(rd, ELM_BG_OPTION_CENTER);
86 elm_object_text_set(rd, "Center");
87 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
88 evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
89 elm_box_pack_end(hbox, rd);
90 evas_object_show(rd);
91 rdg = rd;
92
93 rd = elm_radio_add(win);
94 elm_radio_state_value_set(rd, ELM_BG_OPTION_SCALE);
95 elm_radio_group_add(rd, rdg);
96 elm_object_text_set(rd, "Scale");
97 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
98 evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
99 elm_box_pack_end(hbox, rd);
100 evas_object_show(rd);
101
102 rd = elm_radio_add(win);
103 elm_radio_state_value_set(rd, ELM_BG_OPTION_STRETCH);
104 elm_radio_group_add(rd, rdg);
105 elm_object_text_set(rd, "Stretch");
106 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
107 evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
108 elm_box_pack_end(hbox, rd);
109 evas_object_show(rd);
110
111 rd = elm_radio_add(win);
112 elm_radio_state_value_set(rd, ELM_BG_OPTION_TILE);
113 elm_radio_group_add(rd, rdg);
114 elm_object_text_set(rd, "Tile");
115 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
116 evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
117 elm_box_pack_end(hbox, rd);
118 evas_object_show(rd);
119
120 elm_radio_value_set(rdg, ELM_BG_OPTION_SCALE);
121
122 rd = elm_check_add(win);
123 elm_object_text_set(rd, "Show Overlay");
124 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
125 evas_object_smart_callback_add(rd, "changed", _cb_overlay_changed, o_bg);
126 elm_box_pack_end(hbox, rd);
127 evas_object_show(rd);
128
129 /* color choices ... this is ghetto, but we don't have a 'colorpicker'
130 * widget yet :( */
131 rd = elm_spinner_add(win);
132 elm_object_style_set(rd, "vertical");
133 elm_spinner_min_max_set(rd, 1, 4);
134 elm_spinner_label_format_set(rd, "%.0f");
135 elm_spinner_editable_set(rd, EINA_FALSE);
136 elm_spinner_special_value_add(rd, 1, "White");
137 elm_spinner_special_value_add(rd, 2, "Red");
138 elm_spinner_special_value_add(rd, 3, "Blue");
139 elm_spinner_special_value_add(rd, 4, "Green");
140 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
141 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, EVAS_HINT_FILL);
142 evas_object_smart_callback_add(rd, "changed", _cb_color_changed, o_bg);
143 elm_box_pack_end(hbox, rd);
144 evas_object_show(rd);
145
146 elm_box_pack_end(box, hbox);
147 evas_object_show(hbox);
148
149 evas_object_resize(win, 460, 320);
150 evas_object_show(win);
151
152 elm_run();
153
154 return 0;
155}
156ELM_MAIN()