diff options
author | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
commit | 07274513e984f0b5544586c74508ccd16e7dcafa (patch) | |
tree | b32ff2a9136fbc1a4a6a0ed1e4d79cde0f5f16d9 /libraries/edje/src/examples/edje-signals-messages.c | |
parent | Added Irrlicht 1.8, but without all the Windows binaries. (diff) | |
download | SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.zip SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.gz SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.bz2 SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.xz |
Remove EFL, since it's been released now.
Diffstat (limited to '')
-rw-r--r-- | libraries/edje/src/examples/edje-signals-messages.c | 254 |
1 files changed, 0 insertions, 254 deletions
diff --git a/libraries/edje/src/examples/edje-signals-messages.c b/libraries/edje/src/examples/edje-signals-messages.c deleted file mode 100644 index 4949415..0000000 --- a/libraries/edje/src/examples/edje-signals-messages.c +++ /dev/null | |||
@@ -1,254 +0,0 @@ | |||
1 | /** | ||
2 | * Simple Edje example illustrating the Edje signals and messages | ||
3 | * | ||
4 | * You'll need at least one Evas engine built for it (excluding the | ||
5 | * buffer one). See stdout/stderr for output. | ||
6 | * | ||
7 | * @verbatim | ||
8 | * gcc -o edje-signals-messages edje-signals-messages.c `pkg-config --libs --cflags evas ecore ecore-evas edje` | ||
9 | * @endverbatim | ||
10 | */ | ||
11 | |||
12 | #ifdef HAVE_CONFIG_H | ||
13 | #include "config.h" | ||
14 | #else | ||
15 | #define PACKAGE_EXAMPLES_DIR "." | ||
16 | #define __UNUSED__ | ||
17 | #endif | ||
18 | |||
19 | #include <Ecore.h> | ||
20 | #include <Ecore_Evas.h> | ||
21 | #include <Edje.h> | ||
22 | #include <stdio.h> | ||
23 | |||
24 | #define WIDTH (300) | ||
25 | #define HEIGHT (300) | ||
26 | |||
27 | #define MSG_COLOR 1 | ||
28 | #define MSG_TEXT 2 | ||
29 | |||
30 | static const char commands[] = \ | ||
31 | "commands are:\n" | ||
32 | "\tt - toggle right rectangle's visibility\n" | ||
33 | "\tEsc - exit\n" | ||
34 | "\th - print help\n"; | ||
35 | |||
36 | static Eina_Bool right_rect_show = EINA_TRUE; | ||
37 | |||
38 | static void | ||
39 | _on_keydown(void *data, | ||
40 | Evas *evas __UNUSED__, | ||
41 | Evas_Object *o __UNUSED__, | ||
42 | void *einfo) | ||
43 | { | ||
44 | Evas_Event_Key_Down *ev; | ||
45 | Evas_Object *edje_obj; | ||
46 | |||
47 | ev = (Evas_Event_Key_Down *)einfo; | ||
48 | edje_obj = (Evas_Object *)data; | ||
49 | |||
50 | if (!strcmp(ev->keyname, "h")) /* print help */ | ||
51 | { | ||
52 | fprintf(stdout, commands); | ||
53 | return; | ||
54 | } | ||
55 | else if (!strcmp(ev->keyname, "t")) /* toggle right rectangle's visibility */ | ||
56 | { | ||
57 | char buf[1024]; | ||
58 | |||
59 | right_rect_show = !right_rect_show; | ||
60 | snprintf(buf, sizeof(buf), "part_right,%s", | ||
61 | right_rect_show ? "show" : "hide"); | ||
62 | |||
63 | printf("emitting %s\n", buf); | ||
64 | |||
65 | edje_object_signal_emit(edje_obj, buf, ""); | ||
66 | |||
67 | return; | ||
68 | } | ||
69 | else if (!strcmp(ev->keyname, "Escape")) | ||
70 | ecore_main_loop_quit(); | ||
71 | else | ||
72 | { | ||
73 | printf("unhandled key: %s\n", ev->keyname); | ||
74 | fprintf(stdout, commands); | ||
75 | } | ||
76 | } | ||
77 | |||
78 | static void | ||
79 | _on_delete(Ecore_Evas *ee __UNUSED__) | ||
80 | { | ||
81 | ecore_main_loop_quit(); | ||
82 | } | ||
83 | |||
84 | /* print signals coming from theme */ | ||
85 | static void | ||
86 | _sig_print(const char *emission, | ||
87 | const char *source) | ||
88 | { | ||
89 | fprintf(stdout, "Signal %s coming from part %s!\n", emission, source); | ||
90 | } | ||
91 | |||
92 | static void | ||
93 | _on_mouse_wheel(void *data __UNUSED__, | ||
94 | Evas_Object *obj __UNUSED__, | ||
95 | const char *emission, | ||
96 | const char *source) | ||
97 | { | ||
98 | _sig_print(emission, source); | ||
99 | } | ||
100 | |||
101 | /* mouse over signals */ | ||
102 | static void | ||
103 | _on_mouse_over(void *data __UNUSED__, | ||
104 | Evas_Object *edje_obj, | ||
105 | const char *emission, | ||
106 | const char *source) | ||
107 | { | ||
108 | int i; | ||
109 | |||
110 | _sig_print(emission, source); | ||
111 | |||
112 | Edje_Message_Int_Set *msg = malloc(sizeof(*msg) + 3 * sizeof(int)); | ||
113 | msg->count = 4; | ||
114 | for (i = 0; i < 4; i++) | ||
115 | msg->val[i] = rand() % 256; | ||
116 | |||
117 | edje_object_message_send(edje_obj, EDJE_MESSAGE_INT_SET, MSG_COLOR, msg); | ||
118 | |||
119 | free(msg); | ||
120 | } | ||
121 | |||
122 | /* print out received message string */ | ||
123 | static void | ||
124 | _message_handle(void *data __UNUSED__, | ||
125 | Evas_Object *obj __UNUSED__, | ||
126 | Edje_Message_Type type, | ||
127 | int id, | ||
128 | void *msg) | ||
129 | { | ||
130 | Edje_Message_String *m; | ||
131 | |||
132 | if (type != EDJE_MESSAGE_STRING) return; | ||
133 | if (id != MSG_TEXT) return; | ||
134 | |||
135 | m = msg; | ||
136 | |||
137 | fprintf(stdout, "String message received: %s\n", m->str); | ||
138 | } | ||
139 | |||
140 | int | ||
141 | main(int argc __UNUSED__, char *argv[]) | ||
142 | { | ||
143 | char border_img_path[PATH_MAX]; | ||
144 | char edje_file_path[PATH_MAX]; | ||
145 | const char *edje_file = "signals-messages.edj"; | ||
146 | Ecore_Evas *ee; | ||
147 | Evas *evas; | ||
148 | Evas_Object *bg; | ||
149 | Evas_Object *edje_obj; | ||
150 | Evas_Object *border; | ||
151 | Eina_Prefix *pfx; | ||
152 | |||
153 | if (!ecore_evas_init()) | ||
154 | return EXIT_FAILURE; | ||
155 | |||
156 | if (!edje_init()) | ||
157 | goto shutdown_ecore_evas; | ||
158 | |||
159 | pfx = eina_prefix_new(argv[0], main, | ||
160 | "EDJE_EXAMPLES", | ||
161 | "edje/examples", | ||
162 | edje_file, | ||
163 | PACKAGE_BIN_DIR, | ||
164 | PACKAGE_LIB_DIR, | ||
165 | PACKAGE_DATA_DIR, | ||
166 | PACKAGE_DATA_DIR); | ||
167 | if (!pfx) | ||
168 | goto shutdown_edje; | ||
169 | |||
170 | /* this will give you a window with an Evas canvas under the first | ||
171 | * engine available */ | ||
172 | ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); | ||
173 | if (!ee) | ||
174 | goto free_prefix; | ||
175 | |||
176 | ecore_evas_callback_delete_request_set(ee, _on_delete); | ||
177 | ecore_evas_title_set(ee, "Edje Basics Example"); | ||
178 | |||
179 | evas = ecore_evas_get(ee); | ||
180 | |||
181 | bg = evas_object_rectangle_add(evas); | ||
182 | evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */ | ||
183 | evas_object_move(bg, 0, 0); /* at canvas' origin */ | ||
184 | evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ | ||
185 | evas_object_show(bg); | ||
186 | evas_object_focus_set(bg, EINA_TRUE); | ||
187 | ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); | ||
188 | |||
189 | edje_obj = edje_object_add(evas); | ||
190 | |||
191 | snprintf(edje_file_path, sizeof(edje_file_path), | ||
192 | "%s/examples/%s", eina_prefix_data_get(pfx), edje_file); | ||
193 | if (!edje_object_file_set(edje_obj, edje_file_path, "example_group")) | ||
194 | { | ||
195 | int err = edje_object_load_error_get(edje_obj); | ||
196 | const char *errmsg = edje_load_error_str(err); | ||
197 | fprintf(stderr, "Could not load 'example_group' from " | ||
198 | "signals-messages.edj: %s\n", errmsg); | ||
199 | |||
200 | evas_object_del(edje_obj); | ||
201 | goto free_prefix; | ||
202 | } | ||
203 | |||
204 | edje_object_signal_callback_add(edje_obj, "mouse,wheel,*", "part_left", | ||
205 | _on_mouse_wheel, NULL); | ||
206 | |||
207 | edje_object_signal_callback_add(edje_obj, "mouse,over", "part_right", | ||
208 | _on_mouse_over, NULL); | ||
209 | |||
210 | edje_object_message_handler_set(edje_obj, _message_handle, NULL); | ||
211 | |||
212 | evas_object_move(edje_obj, 20, 20); | ||
213 | evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40); | ||
214 | evas_object_show(edje_obj); | ||
215 | |||
216 | evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, edje_obj); | ||
217 | |||
218 | snprintf(border_img_path, sizeof(border_img_path), | ||
219 | "%s/edje/examples/red.png", eina_prefix_data_get(pfx)); | ||
220 | |||
221 | /* this is a border around the Edje object above, here just to | ||
222 | * emphasize its geometry */ | ||
223 | border = evas_object_image_filled_add(evas); | ||
224 | evas_object_image_file_set(border, border_img_path, NULL); | ||
225 | evas_object_image_border_set(border, 2, 2, 2, 2); | ||
226 | evas_object_image_border_center_fill_set(border, EVAS_BORDER_FILL_NONE); | ||
227 | |||
228 | evas_object_resize(border, WIDTH - 40 + 4, HEIGHT - 40 + 4); | ||
229 | evas_object_move(border, 20 - 2, 20 - 2); | ||
230 | evas_object_repeat_events_set(border, EINA_TRUE); | ||
231 | evas_object_show(border); | ||
232 | |||
233 | fprintf(stdout, commands); | ||
234 | |||
235 | ecore_evas_show(ee); | ||
236 | |||
237 | ecore_main_loop_begin(); | ||
238 | |||
239 | eina_prefix_free(pfx); | ||
240 | ecore_evas_free(ee); | ||
241 | ecore_evas_shutdown(); | ||
242 | edje_shutdown(); | ||
243 | |||
244 | return EXIT_SUCCESS; | ||
245 | |||
246 | free_prefix: | ||
247 | eina_prefix_free(pfx); | ||
248 | shutdown_edje: | ||
249 | edje_shutdown(); | ||
250 | shutdown_ecore_evas: | ||
251 | ecore_evas_shutdown(); | ||
252 | |||
253 | return EXIT_FAILURE; | ||
254 | } | ||