1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/**
* Ecore example illustrating the basics of ecore evas usage.
*
* You'll need at least one Evas engine built for it (excluding the
* buffer one). See stdout/stderr for output.
*
* @verbatim
* gcc -o ecore_evas_basics_example ecore_evas_basics_example.c `pkg-config --libs --cflags ecore-evas`
* @endverbatim
*/
#include <Ecore.h>
#include <Ecore_Evas.h>
#include <unistd.h>
static Eina_Bool
_stdin_cb(void *data, Ecore_Fd_Handler *handler)
{
Eina_List *l;
Ecore_Evas *ee;
char c;
scanf("%c", &c);
if (c == 'h')
EINA_LIST_FOREACH(ecore_evas_ecore_evas_list_get(), l, ee)
ecore_evas_hide(ee);
else if (c == 's')
EINA_LIST_FOREACH(ecore_evas_ecore_evas_list_get(), l, ee)
ecore_evas_show(ee);
return ECORE_CALLBACK_RENEW;
}
static void
_on_delete(Ecore_Evas *ee)
{
free(ecore_evas_data_get(ee, "key"));
ecore_main_loop_quit();
}
int
main(void)
{
Ecore_Evas *ee;
Evas *canvas;
Evas_Object *bg;
Eina_List *engines, *l;
char *data;
if(ecore_evas_init() <= 0)
return 1;
engines = ecore_evas_engines_get();
printf("Available engines:\n");
EINA_LIST_FOREACH(engines, l, data)
printf("%s\n", data);
ecore_evas_engines_free(engines);
ee = ecore_evas_new(NULL, 0, 0, 200, 200, NULL);
ecore_evas_title_set(ee, "Ecore Evas basics Example");
ecore_evas_show(ee);
data = malloc(sizeof(char) * 6);
sprintf(data, "%s", "hello");
ecore_evas_data_set(ee, "key", data);
ecore_evas_callback_delete_request_set(ee, _on_delete);
printf("Using %s engine!\n", ecore_evas_engine_name_get(ee));
canvas = ecore_evas_get(ee);
if(ecore_evas_ecore_evas_get(canvas) == ee)
printf("Everything is sane!\n");
bg = evas_object_rectangle_add(canvas);
evas_object_color_set(bg, 0, 0, 255, 255);
evas_object_resize(bg, 200, 200);
evas_object_show(bg);
ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
ecore_main_fd_handler_add(STDIN_FILENO,
ECORE_FD_READ | ECORE_FD_ERROR,
_stdin_cb,
NULL, NULL, NULL);
ecore_main_loop_begin();
ecore_evas_free(ee);
ecore_evas_shutdown();
return 0;
}
|