10 #define PACKAGE_EXAMPLES_DIR "."
14 #include <Ecore_Evas.h>
20 static Ecore_Evas *ee;
21 static const char *border_img_path = PACKAGE_EXAMPLES_DIR "/red.png";
23 static Evas_Object *bg, *r1, *r2, *r3; /* "sub" canvas objects */
24 static Evas_Object *border, *img; /* canvas objects */
27 _on_destroy(Ecore_Evas *ee __UNUSED__)
29 fprintf(stderr, "EFL-App destory, end of test\n"); fflush(stderr);
30 ecore_main_loop_quit();
34 _resize_cb(Ecore_Evas *ee)
36 int x, y, w, h, ow, oh;
39 evas_object_geometry_get(img, &x, &y, &ow, &oh);
40 ecore_evas_geometry_get(ee, &x, &y, &w, &h);
41 ecore_evas_request_geometry_get(ee, NULL, NULL, &rw, &rh);
42 fprintf(stderr, "EFL-App resize x/y=%d/%d req=%d/%d w/h=%d/%d obj=%d/%d\n", x, y, rw, rh, w, h, ow, oh); fflush(stderr);
46 main(int argc, char *argv[])
48 Evas *canvas, *sub_canvas;
62 for (i = 1; i < argc; i++) {
63 if (argv[i][0] == '@') {
64 appno = strtol(&argv[i][1], (char **)0, 0);
66 if (argv[i][0] != '-') continue;
67 if (strncasecmp(argv[i], "-width=", 7) == 0) {
68 width = strtol(&argv[i][7], (char **)0, 0);
70 else if (strncasecmp(argv[i], "-height=", 8) == 0) {
71 height = strtol(&argv[i][8], (char **)0, 0);
73 else if (strncasecmp(argv[i], "-color=", 7) == 0) {
74 color = strtoul(&argv[i][7], (char **)0, 0);
78 fprintf(stderr, "EFL-App call ecore_evas_init()\n"); fflush(stderr);
81 /* this will give you a window with an Evas canvas under the first
83 fprintf(stderr, "EFL-App create surace(ecore_evas_new(%d,%d))\n", width, height); fflush(stderr);
84 ee = ecore_evas_new(NULL, 0, 0, width, height, "frame=0");
87 ecore_evas_size_min_set(ee, width/4, height/4);
88 ecore_evas_size_max_set(ee, width*4, height*4);
90 ecore_evas_callback_resize_set(ee, _resize_cb);
92 ecore_evas_callback_delete_request_set(ee, _on_destroy);
93 sprintf(sTitle, "EFL_Native_Application_%d", appno);
94 ecore_evas_title_set(ee, sTitle);
95 fprintf(stderr, "EFL-App show surace(ecore_evas_show)\n"); fflush(stderr);
98 canvas = ecore_evas_get(ee);
100 bg = evas_object_rectangle_add(canvas);
101 rr = (color>>16)&0x0ff;
102 gg = (color>>8)&0x0ff;
104 a = (color>>24)&0x0ff;
108 evas_object_color_set(bg, r, g, b, a); /* bg color */
109 evas_object_move(bg, 0, 0); /* at origin */
110 evas_object_resize(bg, width, height); /* covers full canvas */
111 evas_object_show(bg);
113 /* this is a border around the image containing a scene of another
115 border = evas_object_image_filled_add(canvas);
116 evas_object_image_file_set(border, border_img_path, NULL);
117 evas_object_image_border_set(border, 3, 3, 3, 3);
118 evas_object_image_border_center_fill_set(border, EVAS_BORDER_FILL_NONE);
120 evas_object_move(border, width / 6, height / 6);
121 evas_object_resize(border, (2 * width) / 3, (2 * height) / 3);
122 evas_object_show(border);
124 img = ecore_evas_object_image_new(ee);
125 evas_object_image_filled_set(img, EINA_TRUE);
126 evas_object_image_size_set(
127 img, ((2 * width) / 3) - 6, ((2 * height) / 3) - 6);
128 sub_ee = ecore_evas_object_ecore_evas_get(img);
129 sub_canvas = ecore_evas_object_evas_get(img);
131 evas_object_move(img, (width / 6) + 3, (height / 6) + 3);
133 /* apply the same size on both! */
134 evas_object_resize(img, ((2 * width) / 3) - 6, ((2 * height) / 3) - 6);
135 ecore_evas_resize(sub_ee, ((2 * width) / 3) - 6, ((2 * height) / 3) - 6);
137 r1 = evas_object_rectangle_add(sub_canvas);
138 evas_object_color_set(r1, gg, bb, rr, 255);
139 evas_object_move(r1, 10, 10);
140 evas_object_resize(r1, 100, 100);
141 evas_object_show(r1);
143 r2 = evas_object_rectangle_add(sub_canvas);
147 evas_object_color_set(r2, b, g, r, 128);
148 evas_object_move(r2, 10, 10);
149 evas_object_resize(r2, 50, 50);
150 evas_object_show(r2);
152 r3 = evas_object_rectangle_add(sub_canvas);
153 evas_object_color_set(r3, bb, rr, gg, 255);
154 evas_object_move(r3, 60, 60);
155 evas_object_resize(r3, 50, 50);
156 evas_object_show(r3);
158 evas_object_show(img);
159 fprintf(stderr, "EFL-App event mainloop\n"); fflush(stderr);
160 ecore_main_loop_begin();
163 ecore_evas_shutdown();
168 fprintf(stderr, "You got to have at least one Evas engine built"
169 " and linked up to ecore-evas for this example to run properly.\n");
170 ecore_evas_shutdown();