aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/elementary/src/examples/mapbuf_example.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/elementary/src/examples/mapbuf_example.c')
-rw-r--r--libraries/elementary/src/examples/mapbuf_example.c126
1 files changed, 126 insertions, 0 deletions
diff --git a/libraries/elementary/src/examples/mapbuf_example.c b/libraries/elementary/src/examples/mapbuf_example.c
new file mode 100644
index 0000000..03603be
--- /dev/null
+++ b/libraries/elementary/src/examples/mapbuf_example.c
@@ -0,0 +1,126 @@
1/**
2 * Simple Elementary's <b>mapbuf widget</b> example, illustrating its API.
3 *
4 * See stdout/stderr for output. Compile with:
5 *
6 * @verbatim
7 * gcc -g mapbuf_example.c -o mapbuf_example `pkg-config --cflags --libs elementary`
8 * @endverbatim
9 */
10
11#include <Elementary.h>
12
13static void
14_on_done(void *data,
15 Evas_Object *obj,
16 void *event_info)
17{
18 elm_exit();
19}
20
21static void
22_enabled_cb(void *data, Evas_Object *obj, void *event_info)
23{
24 Evas_Object *mb = data;
25 elm_mapbuf_enabled_set(mb, elm_check_state_get(obj));
26}
27
28static void
29_alpha_cb(void *data, Evas_Object *obj, void *event_info)
30{
31 Evas_Object *mb = data;
32 elm_mapbuf_alpha_set(mb, elm_check_state_get(obj));
33}
34
35static void
36_smooth_cb(void *data, Evas_Object *obj, void *event_info)
37{
38 Evas_Object *mb = data;
39 elm_mapbuf_smooth_set(mb, elm_check_state_get(obj));
40}
41
42EAPI_MAIN int
43elm_main(int argc, char **argv)
44{
45 Evas_Object *win, *bg, *bx, *hbx, *tg, *ck, *mb, *tb, *ic;
46 unsigned int i, j;
47
48 win = elm_win_add(NULL, "mapbuf", ELM_WIN_BASIC);
49 elm_win_title_set(win, "Mapbuf Example");
50 evas_object_smart_callback_add(win, "delete,request", _on_done, NULL);
51
52 bg = elm_bg_add(win);
53 elm_win_resize_object_add(win, bg);
54 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
55 evas_object_show(bg);
56
57 bx = elm_box_add(win);
58 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
59 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
60 elm_win_resize_object_add(win, bx);
61 evas_object_show(bx);
62
63 mb = elm_mapbuf_add(win);
64 evas_object_size_hint_weight_set(mb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
65 evas_object_size_hint_align_set(mb, EVAS_HINT_FILL, EVAS_HINT_FILL);
66 elm_box_pack_end(bx, mb);
67
68 tb = elm_table_add(win);
69 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
70 evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
71 evas_object_show(tb);
72
73 for (i = 0; i < 8; i++)
74 {
75 for (j = 0; j < 8; j++)
76 {
77 ic = elm_icon_add(win);
78 elm_icon_standard_set(ic, "home");
79 elm_icon_resizable_set(ic, EINA_FALSE, EINA_FALSE);
80 evas_object_show(ic);
81 elm_table_pack(tb, ic, i, j, 1, 1);
82 }
83 }
84
85 elm_object_content_set(mb, tb);
86 evas_object_show(mb);
87
88 hbx = elm_box_add(win);
89 elm_box_horizontal_set(hbx, EINA_TRUE);
90 evas_object_size_hint_weight_set(hbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
91 evas_object_size_hint_align_set(hbx, EVAS_HINT_FILL, EVAS_HINT_FILL);
92 elm_box_pack_end(bx, hbx);
93 evas_object_show(hbx);
94
95 tg = elm_check_add(win);
96 elm_object_style_set(tg, "toggle");
97 elm_object_part_text_set(tg, "on", "Enabled");
98 elm_object_part_text_set(tg, "off", "Disabled");
99 elm_object_text_set(tg, "Map");
100 evas_object_smart_callback_add(tg, "changed", _enabled_cb, mb);
101 elm_box_pack_end(hbx, tg);
102 evas_object_show(tg);
103
104 ck = elm_check_add(win);
105 elm_object_text_set(ck, "Alpha");
106 elm_check_state_set(ck, EINA_TRUE);
107 evas_object_smart_callback_add(ck, "changed", _alpha_cb, mb);
108 elm_box_pack_end(hbx, ck);
109 evas_object_show(ck);
110
111 ck = elm_check_add(win);
112 elm_object_text_set(ck, "Smooth");
113 elm_check_state_set(ck, EINA_TRUE);
114 evas_object_smart_callback_add(ck, "changed", _smooth_cb, mb);
115 elm_box_pack_end(hbx, ck);
116 evas_object_show(ck);
117
118 evas_object_resize(win, 240, 320);
119 evas_object_show(win);
120
121 elm_run();
122 elm_shutdown();
123
124 return 0;
125}
126ELM_MAIN()