summaryrefslogtreecommitdiff
path: root/legacy/ecore/ecore.c.in
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2003-09-23 08:09:32 +0000
committerCarsten Haitzler <raster@rasterman.com>2003-09-23 08:09:32 +0000
commita5c2425084f670998654b7cf002d961dce963e82 (patch)
tree26bb48a4db414be854a6028c43364c23a02b4d3b /legacy/ecore/ecore.c.in
parentcddaadb4477f3cc1b36d4f4fe68ba1f6abfa8a3d (diff)
damn you salizar! damn you!
errr. i mean. ecore moves to HEAD! SVN revision: 7475
Diffstat (limited to '')
-rw-r--r--legacy/ecore/ecore.c.in235
1 files changed, 235 insertions, 0 deletions
diff --git a/legacy/ecore/ecore.c.in b/legacy/ecore/ecore.c.in
new file mode 100644
index 0000000000..cd06dd95ca
--- /dev/null
+++ b/legacy/ecore/ecore.c.in
@@ -0,0 +1,235 @@
1/**
2@file
3@brief Ecore Library Public API Calls
4
5These routines are used for Ecore Library interaction
6*/
7
8/**
9
10@mainpage Ecore
11@image latex ecore_big.eps width=5cm
12@image html ecore.png
13@version 1.0.0
14@author Carsten Haitzler <raster@rasterman.com>
15@date 2000-2003
16
17
18
19
20
21
22
23
24
25
26
27
28
29@section intro What is Ecore?
30
31Ecore is a clean and tiny event loop library with many modules to do lots of
32convenient things for a programmer, to save time and effort.
33
34It's small and lean, designed to work on embedded systems all the way to
35large and powerful multi-cpu workstations. It serialises all system signals,
36events etc. into a single event queue, that is easily processed without
37needing to worry about concurrency. A properly written, event-driven program
38using this kind of programming doesn't need threads, nor has to worry about
39concurrency. It turns a program into a state machine, and makes it very
40robust and easy to follow.
41
42Ecore gives you other handy primitives, such as timers to tick over for you
43and call specified functions at particular times so the programmer can use
44this to do things, like animate, or time out on connections or tasks that take
45too long etc.
46
47Idle handlers are provided too, as well as calls on entering an idle state
48(often a very good time to update the state of the program). All events that
49enter the system are passed to specific callback functions that the program
50sets up to handle those events. Handling them is simple and other Ecore
51modules produce more events on the queue, coming from other sources such as
52file descriptors etc.
53
54Ecore also lets you have functions called when file descriptors become active
55for reading or writing, allowing for streamlined, non-blocking IO.
56
57Here is an exmaple of a simple program and its basic event loop flow:
58
59@image html prog_flow.png
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76@section work How does Ecore work?
77
78Ecore is very easy to learn and use. All the function calls are designed to
79be easy to remember, explicit in describing what they do, and heavily
80name-spaced. Ecore programs can start and be very simple.
81
82For example:
83
84@code
85#include <Ecore.h>
86
87int main(int argc, const char **argv)
88{
89 ecore_init();
90 ecore_app_args_set(argc, argv);
91 ecore_main_loop_begin();
92 ecore_shutdown();
93 return 0;
94}
95@endcode
96
97This program is very simple and does't check for errors, but it does start up
98and begin a main loop waiting for events or timers to tick off. This program
99doesn't set up any, but now we can expand on this simple program a little
100more by adding some event handlers and timers.
101
102@code
103#include <Ecore.h>
104
105Ecore_Timer *timer1 = NULL;
106Ecore_Event_Handler *handler1 = NULL;
107double start_time = 0.0;
108
109int timer_func(void *data)
110{
111 printf("Tick timer. Sec: %3.2f\n", ecore_time_get() - start_time);
112 return 1;
113}
114
115int exit_func(int ev_type, void *ev, void *data)
116{
117 Ecore_Event_Signal_Exit *e;
118
119 e = (Ecore_Event_Signal_Exit *)ev;
120 if (e->interrupt) printf("Exit: interrupt\n");
121 else if (e->quit) printf("Exit: quit\n");
122 else if (e->terminate) printf("Exit: terminate\n");
123 ecore_main_loop_quit();
124 return 1;
125}
126
127int main(int argc, const char **argv)
128{
129 ecore_init();
130 ecore_app_args_set(argc, argv);
131 start_time = ecore_time_get();
132 handler1 = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, exit_func, NULL);
133 timer1 = ecore_timer_add(0.5, timer_func, NULL);
134 ecore_main_loop_begin();
135 ecore_shutdown();
136 return 0;
137}
138@endcode
139
140In the previous example, we initialize our application and get the time at which
141our program has started so we can calculate an offset. We set up a timer to
142tick off in 0.5 seconds, and since it returns 1, will keep ticking off every
1430.5 seconds until it returns 0, or is deleted by hand. An event handler is set
144up to call a function - exit_func(), whenever an event of type
145ECORE_EVENT_SIGNAL_EXIT is received (CTRL-C on the command line will cause
146such an event to happen). If this event occurs it tells you what kind of
147exit signal was received, and asks the main loop to quit when it is finished
148by calling ecore_main_loop_quit().
149
150The handles returned by ecore_timer_add() and ecore_event_handler_add() are
151only stored here as an example. If you don't need to address the timer or
152event handler again you don't need to store the result, so just call the
153function, and don't assign the result to any variable.
154
155This program looks slightly more complex than needed to do these simple
156things, but in principle, programs don't get any more complex. You add more
157event handlers, for more events, will have more timers and such, BUT it all
158follows the same principles as shown in this example.
159
160
161
162
163
164
165
166
167@section compiling How to compile using Ecore?
168
169This section has to be documented. Below is just a quick line to handle all
170Ecore modules at once.
171
172@verbatim
173gcc *.c \
174-I/usr/local/include -I/usr/X11R6/include \
175-L/usr/local/lib -L/usr/X11R6/lib \
176-lecore -lecore_evas -lecore_x -lecore_fb -lecore_job \
177`evas-config --cflags --libs`
178@endverbatim
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193@section install How is it installed?
194
195Suggested configure options for evas for a Linux desktop X display:
196
197@verbatim
198./configure \
199--enable-ecore-x \
200--enable-ecore-fb \
201--enable-ecore-evas \
202--enable-ecore-evas-gl \
203--enable-ecore-job
204make CFLAGS="-O9 -mpentiumpro -march=pentiumpro -mcpu=pentiumpro"
205@endverbatim
206
207
208
209
210
211
212
213
214
215
216
217
218@section tutorial Ecore Tutorial
219
220You will find a more comprehensive @ref tut here, going through many examples
221with tips and hints as to how best do some things.
222
223
224
225
226
227@todo (1.0) Document API
228
229*/
230
231/** @page tut Ecore Tutorial
232
233Here is a tutotial for using Ecore...
234
235*/