move around - flatter.
[profile/ivi/evas.git] / src / lib / canvas / evas_main.c
1 #include "evas_common.h"
2 #include "evas_private.h"
3
4 extern Evas_List *evas_modules;
5 static int initcount = 0;
6
7 EAPI int
8 evas_init(void)
9 {
10    if (initcount == 0)
11      evas_module_init();
12    return ++initcount;
13 }
14
15 EAPI int
16 evas_shutdown(void)
17 {
18    initcount--;
19    if (initcount == 0)
20      {
21         evas_font_dir_cache_free();
22         evas_common_shutdown();
23         evas_module_shutdown();
24      }
25    return initcount;
26 }
27
28 /**
29  * @defgroup Evas_Canvas Evas Canvas
30  *
31  * Functions that deal with the basic evas object.  They are the
32  * functions you need to use at a minimum to get a working evas, and
33  * to destroy it.
34  *
35  */
36
37 /**
38  * Creates a new empty evas.
39  *
40  * Note that before you can use the evas, you will to at a minimum:
41  * @li Set its render method with @ref evas_output_method_set .
42  * @li Set its viewport size with @ref evas_output_viewport_set .
43  * @li Set its size of the canvas with @ref evas_output_size_set .
44  * @li Ensure that the render engine is given the correct settings with
45  *     @ref evas_engine_info_set .
46  *
47  * This function should only fail if the memory allocation fails.
48  *
49  * @return  A new uninitialised Evas canvas on success.  Otherwise, @c NULL.
50  * @ingroup Evas_Canvas
51  */
52 EAPI Evas *
53 evas_new(void)
54 {
55    Evas *e;
56
57    e = calloc(1, sizeof(Evas));
58    if (!e) return NULL;
59
60    e->magic = MAGIC_EVAS;
61    e->output.render_method = RENDER_METHOD_INVALID;
62    e->viewport.w = 1;
63    e->viewport.h = 1;
64    e->hinting = EVAS_FONT_HINTING_BYTECODE;
65
66    evas_array_setup(&e->delete_objects, 16);
67    evas_array_setup(&e->active_objects, 16);
68    evas_array_setup(&e->restack_objects, 16);
69    evas_array_setup(&e->render_objects, 16);
70    evas_array_setup(&e->pending_objects, 16);
71    evas_array_setup(&e->obscuring_objects, 16);
72    evas_array_setup(&e->temporary_objects, 16);
73
74    return e;
75 }
76
77 /**
78  * Frees the given evas and any objects created on it.
79  *
80  * Any objects with 'free' callbacks will have those callbacks called
81  * in this function.
82  *
83  * @param   e The given evas.
84  * @ingroup Evas_Canvas
85  */
86 EAPI void
87 evas_free(Evas *e)
88 {
89    Evas_Object_List *l;
90    int i;
91    int del;
92
93    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
94    return;
95    MAGIC_CHECK_END();
96
97    if (e->walking_list == 0) evas_render_idle_flush(e);
98
99    if (e->walking_list > 0) return;
100    del = 1;
101    e->walking_list++;
102    e->cleanup = 1;
103    while (del)
104      {
105         del = 0;
106         for (l = (Evas_Object_List *)(e->layers); l; l = l->next)
107           {
108              Evas_Layer *lay;
109              Evas_Object_List *ll;
110
111              lay = (Evas_Layer *)l;
112              evas_layer_pre_free(lay);
113              for (ll = (Evas_Object_List *)lay->objects; ll; ll = ll->next)
114                {
115                   Evas_Object *o;
116
117                   o = (Evas_Object *)ll;
118                   if ((o->callbacks) && (o->callbacks->walking_list))
119                     {
120                        /* Defer free */
121                        e->delete_me = 1;
122                        e->walking_list--;
123                        return;
124                     }
125                   if (!o->delete_me)
126                     del = 1;
127                }
128           }
129      }
130    while (e->layers)
131      {
132         Evas_Layer *lay;
133
134         lay = e->layers;
135         evas_layer_del(lay);
136         evas_layer_free(lay);
137      }
138    e->walking_list--;
139    
140    evas_font_path_clear(e);
141    e->pointer.object.in = evas_list_free(e->pointer.object.in);
142
143    if (e->name_hash) evas_hash_free(e->name_hash);
144
145    while (e->damages)
146      {
147         free(e->damages->data);
148         e->damages = evas_list_remove(e->damages, e->damages->data);
149      }
150    while (e->obscures)
151      {
152         free(e->obscures->data);
153         e->obscures = evas_list_remove(e->obscures, e->obscures->data);
154      }
155
156    if (e->engine.func) 
157      {
158         e->engine.func->info_free(e, e->engine.info);
159         e->engine.func->context_free(e->engine.data.output, e->engine.data.context);
160         e->engine.func->output_free(e->engine.data.output);
161      }
162
163    for (i = 0; i < e->modifiers.mod.count; i++)
164      free(e->modifiers.mod.list[i]);
165    if (e->modifiers.mod.list) free(e->modifiers.mod.list);
166
167    for (i = 0; i < e->locks.lock.count; i++)
168      free(e->locks.lock.list[i]);
169    if (e->locks.lock.list) free(e->locks.lock.list);
170
171    if (e->engine.module) evas_module_unref(e->engine.module);
172
173    evas_array_flush(&e->delete_objects);
174    evas_array_flush(&e->active_objects);
175    evas_array_flush(&e->restack_objects);
176    evas_array_flush(&e->render_objects);
177    evas_array_flush(&e->pending_objects);
178    evas_array_flush(&e->obscuring_objects);
179    evas_array_flush(&e->temporary_objects);
180
181    e->magic = 0;
182    free(e);
183 }
184
185 /**
186  * @defgroup Evas_Output_Method Evas Render Engine Functions
187  *
188  * Functions that are used to set the render engine for a given function, and
189  * then get that engine working.
190  *
191  * The following code snippet shows how they can be used to
192  * initialise an evas that uses the X11 software engine:
193  * @code
194  * Evas *evas;
195  * Evas_Engine_Info_Software_X11 *einfo;
196  * extern Display *display;
197  * extern Window win;
198  *
199  * evas = evas_new();
200  * evas_output_method_set(evas, evas_render_method_lookup("software_x11"));
201  * evas_output_size_set(evas, 640, 480);
202  * evas_output_viewport_set(evas, 0, 0, 640, 480);
203  * einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(evas);
204  * einfo->info.display = display;
205  * einfo->info.visual = DefaultVisual(display, DefaultScreen(display));
206  * einfo->info.colormap = DefaultColormap(display, DefaultScreen(display));
207  * einfo->info.drawable = win;
208  * einfo->info.depth = DefaultDepth(display, DefaultScreen(display));
209  * evas_engine_info_set(evas, (Evas_Engine_Info *)einfo);
210  * @endcode
211  */
212
213 /**
214  * Sets the output engine for the given evas.
215  *
216  * Once the output engine for an evas is set, any attempt to change it
217  * will be ignored.  The value for @p render_method can be found using
218  * @ref evas_render_method_lookup .
219  *
220  * @param   e             The given evas.
221  * @param   render_method The numeric engine value to use.
222  * @ingroup Evas_Output_Method
223  */
224 EAPI void
225 evas_output_method_set(Evas *e, int render_method)
226 {
227    Evas_List *l;
228    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
229    return;
230    MAGIC_CHECK_END();
231
232    /* if our engine to set it to is invalid - abort */
233    if (render_method == RENDER_METHOD_INVALID) return;
234    /* if the engine is already set up - abort */
235    if (e->output.render_method != RENDER_METHOD_INVALID) return;
236    /* iterate trough the list to find the id */
237    for (l = evas_modules; l; l = l->next)
238      {
239         Evas_Module *em;
240         Evas_Module_Engine *eme;
241         
242         em = l->data;
243         if (em->type != EVAS_MODULE_TYPE_ENGINE) continue;
244         if (!em->data) continue;
245         eme = (Evas_Module_Engine *)em->data;
246         if (eme->id != render_method) continue;
247         if (!evas_module_load(em)) return;
248         /* set the correct render */
249         e->output.render_method = render_method;
250         e->engine.func = (em->functions);
251         evas_module_use(em);
252         if (e->engine.module) evas_module_unref(e->engine.module);
253         e->engine.module = em;
254         evas_module_ref(em);
255         /* get the engine info struct */
256         if (e->engine.func->info) e->engine.info = e->engine.func->info(e);
257         return;
258      }
259 }
260
261 /**
262  * Retrieves the number of the output engine used for the given evas.
263  * @param   e The given evas.
264  * @return  The ID number of the output engine being used.  @c 0 is
265  *          returned if there is an error.
266  * @ingroup Evas_Output_Method
267  */
268 EAPI int
269 evas_output_method_get(const Evas *e)
270 {
271    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
272    return RENDER_METHOD_INVALID;
273    MAGIC_CHECK_END();
274
275    return e->output.render_method;
276 }
277
278 /**
279  * Retrieves the current render engine info struct from the given evas.
280  *
281  * The returned structure is publicly modifiable.  The contents are valid
282  * until either @ref evas_engine_info_set or @ref evas_render are called.
283  *
284  * This structure does not need to be freed by the caller.
285  *
286  * @param   e The given evas.
287  * @return  A pointer to the Engine Info structure.  @c NULL is returned if
288  *          an engine has not yet been assigned.
289  * @ingroup Evas_Output_Method
290  */
291 EAPI Evas_Engine_Info *
292 evas_engine_info_get(const Evas *e)
293 {
294    Evas_Engine_Info *info;
295
296    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
297    return NULL;
298    MAGIC_CHECK_END();
299
300    if (!e->engine.info) return NULL;
301
302    info = e->engine.info;
303    ((Evas *)e)->engine.info_magic = info->magic;
304
305    return info;
306 }
307
308 /**
309  * Applies the engine settings for the given evas from the given @c
310  * Evas_Engine_Info structure.
311  *
312  * To get the Evas_Engine_Info structure to use, call @ref
313  * evas_engine_info_get .  Do not try to obtain a pointer to an
314  * @c Evas_Engine_Info structure in any other way.
315  *
316  * You will need to call this function at least once before you can
317  * create objects on an evas or render that evas.  Some engines allow
318  * their settings to be changed more than once.
319  *
320  * Once called, the @p info pointer should be considered invalid.
321  *
322  * Example:
323  *
324  * @param   e    The pointer to the Evas Canvas
325  * @param   info The pointer to the Engine Info to use
326  * @ingroup Evas_Output_Method
327  */
328 EAPI void
329 evas_engine_info_set(Evas *e, Evas_Engine_Info *info)
330 {
331    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
332    return;
333    MAGIC_CHECK_END();
334    if (!info) return;
335    if (info != e->engine.info) return;
336    if (info->magic != e->engine.info_magic) return;
337    e->engine.func->setup(e, info);
338 }
339
340 /**
341  * @defgroup Evas_Output_Size Evas Output and Viewport Resizing Functions
342  *
343  * Functions that set and retrieve the output and viewport size of an evas.
344  */
345
346 /**
347  * Sets the output size of the render engine of the given evas.
348  *
349  * The evas will render to a rectangle of the given size once this
350  * function is called.  The output size is independent of the viewport
351  * size.  The viewport will be stretched to fill the given rectangle.
352  *
353  * The units used for @p w and @p h depend on the engine used by the
354  * evas.
355  *
356  * @param   e The given evas.
357  * @param   w The width in output units, usually pixels.
358  * @param   h The height in output units, usually pixels.
359  * @ingroup Evas_Output_Size
360  */
361 EAPI void
362 evas_output_size_set(Evas *e, int w, int h)
363 {
364    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
365    return;
366    MAGIC_CHECK_END();
367
368    if ((w == e->output.w) && (h == e->output.h)) return;
369    if (w < 1) w = 1;
370    if (h < 1) h = 1;
371    e->output.w = w;
372    e->output.h = h;
373    e->output.changed = 1;
374    e->output_validity++;
375    e->changed = 1;
376    evas_render_invalidate(e);
377 }
378
379 /**
380  * Retrieve the output size of the render engine of the given evas.
381  *
382  * The output size is given in whatever the output units are for the
383  * engine.
384  *
385  * If either @p w or @p h is @c NULL, then it is ignored.  If @p e is
386  * invalid, the returned results are undefined.
387  *
388  * @param   e The given evas.
389  * @param   w The pointer to an integer to store the width in.
390  * @param   h The pointer to an integer to store the height in.
391  * @ingroup Evas_Output_Size
392  */
393 EAPI void
394 evas_output_size_get(const Evas *e, int *w, int *h)
395 {
396    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
397    if (w) *w = 0;
398    if (h) *h = 0;
399    return;
400    MAGIC_CHECK_END();
401
402    if (w) *w = e->output.w;
403    if (h) *h = e->output.h;
404 }
405
406 /**
407  * Sets the output viewport of the given evas in evas units.
408  *
409  * The output viewport is the area of the evas that will be visible to the
410  * viewer.  The viewport will be stretched to fit the output target of the
411  * evas when rendering is performed.
412  *
413  * @note The coordinate values do not have to map 1-to-1 with the output
414  *       target.  However, it is generally advised that it is done for ease
415  *       of use.
416  *
417  * @param   e The given evas.
418  * @param   x The top-left corner x value of the viewport.
419  * @param   y The top-left corner y value of the viewport.
420  * @param   w The width of the viewport.  Must be greater than 0.
421  * @param   h The height of the viewport.  Must be greater than 0.
422  * @ingroup Evas_Output_Size
423  */
424 EAPI void
425 evas_output_viewport_set(Evas *e, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
426 {
427    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
428    return;
429    MAGIC_CHECK_END();
430
431    if ((x == e->viewport.x) && (y == e->viewport.y) &&
432        (w == e->viewport.w) && (h == e->viewport.h)) return;
433    if (w <= 0) return;
434    if (h <= 0) return;
435    if ((x != 0) || (y != 0))
436      {
437         printf("EVAS: compat error. viewport x,y != 0,0 not supported\n");
438         x = 0;
439         y = 0;
440      }
441    e->viewport.x = x;
442    e->viewport.y = y;
443    e->viewport.w = w;
444    e->viewport.h = h;
445    e->viewport.changed = 1;
446    e->output_validity++;
447    e->changed = 1;
448 }
449
450 /**
451  * Get the render engine's output viewport co-ordinates in canvas units.
452  * @param e The pointer to the Evas Canvas
453  * @param x The pointer to a x variable to be filled in
454  * @param y The pointer to a y variable to be filled in
455  * @param w The pointer to a width variable to be filled in
456  * @param h The pointer to a height variable to be filled in
457  * @ingroup Evas_Output_Size
458  *
459  * Calling this function writes the current canvas output viewport size and
460  * location values into the variables pointed to by @p x, @p y, @p w and @p h.
461  * On success the variables have the output location and size values written to
462  * them in canvas units. Any of @p x, @p y, @p w or @p h that are NULL will not
463  * be written to. If @p e is invalid, the results are undefined.
464  *
465  * Example:
466  * @code
467  * extern Evas *evas;
468  * Evas_Coord x, y, width, height;
469  *
470  * evas_output_viewport_get(evas, &x, &y, &w, &h);
471  * @endcode
472  */
473 EAPI void
474 evas_output_viewport_get(const Evas *e, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
475 {
476    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
477    if (x) *x = 0;
478    if (y) *y = 0;
479    if (w) *w = 0;
480    if (h) *h = 0;
481    return;
482    MAGIC_CHECK_END();
483
484    if (x) *x = e->viewport.x;
485    if (y) *y = e->viewport.y;
486    if (w) *w = e->viewport.w;
487    if (h) *h = e->viewport.h;
488 }
489
490 /**
491  * @defgroup Evas_Coord_Mapping_Group Evas Coordinate Mapping Functions
492  *
493  * Functions that are used to map coordinates from the canvas to the
494  * screen or the screen to the canvas.
495  */
496
497 /**
498  * Convert/scale an ouput screen co-ordinate into canvas co-ordinates
499  *
500  * @param e The pointer to the Evas Canvas
501  * @param x The screen/output x co-ordinate
502  * @return The screen co-ordinate translated to canvas unit co-ordinates
503  * @ingroup Evas_Coord_Mapping_Group
504  *
505  * This function takes in a horizontal co-ordinate as the @p x parameter and
506  * converts it into canvas units, accounting for output size, viewport size
507  * and location, returning it as the function return value. If @p e is
508  * invalid, the results are undefined.
509  *
510  * Example:
511  * @code
512  * extern Evas *evas;
513  * extern int screen_x;
514  * Evas_Coord canvas_x;
515  *
516  * canvas_x = evas_coord_screen_x_to_world(evas, screen_x);
517  * @endcode
518  */
519 EAPI Evas_Coord
520 evas_coord_screen_x_to_world(const Evas *e, int x)
521 {
522    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
523    return 0;
524    MAGIC_CHECK_END();
525    if (e->output.w == e->viewport.w) return e->viewport.x + x;
526    return (long long)e->viewport.x + (((long long)x * (long long)e->viewport.w) / (long long)e->output.w);
527 }
528
529 /**
530  * Convert/scale an ouput screen co-ordinate into canvas co-ordinates
531  *
532  * @param e The pointer to the Evas Canvas
533  * @param y The screen/output y co-ordinate
534  * @return The screen co-ordinate translated to canvas unit co-ordinates
535  * @ingroup Evas_Coord_Mapping_Group
536  *
537  * This function takes in a vertical co-ordinate as the @p y parameter and
538  * converts it into canvas units, accounting for output size, viewport size
539  * and location, returning it as the function return value. If @p e is
540  * invalid, the results are undefined.
541  *
542  * Example:
543  * @code
544  * extern Evas *evas;
545  * extern int screen_y;
546  * Evas_Coord canvas_y;
547  *
548  * canvas_y = evas_coord_screen_y_to_world(evas, screen_y);
549  * @endcode
550  */
551 EAPI Evas_Coord
552 evas_coord_screen_y_to_world(const Evas *e, int y)
553 {
554    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
555    return 0;
556    MAGIC_CHECK_END();
557    if (e->output.h == e->viewport.h) return e->viewport.y + y;
558    return (long long)e->viewport.y + (((long long)y * (long long)e->viewport.h) / (long long)e->output.h);
559 }
560
561 /**
562  * Convert/scale a canvas co-ordinate into output screen co-ordinates
563  *
564  * @param e The pointer to the Evas Canvas
565  * @param x The canvas x co-ordinate
566  * @return The output/screen co-ordinate translated to output co-ordinates
567  * @ingroup Evas_Coord_Mapping_Group
568  *
569  * This function takes in a horizontal co-ordinate as the @p x parameter and
570  * converts it into output units, accounting for output size, viewport size
571  * and location, returning it as the function return value. If @p e is
572  * invalid, the results are undefined.
573  *
574  * Example:
575  * @code
576  * extern Evas *evas;
577  * int screen_x;
578  * extern Evas_Coord canvas_x;
579  *
580  * screen_x = evas_coord_world_x_to_screen(evas, canvas_x);
581  * @endcode
582  */
583 EAPI int
584 evas_coord_world_x_to_screen(const Evas *e, Evas_Coord x)
585 {
586    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
587    return 0;
588    MAGIC_CHECK_END();
589    if (e->output.w == e->viewport.w) return x - e->viewport.x;
590    return (int)((((long long)x - (long long)e->viewport.x) * (long long)e->output.w) /  (long long)e->viewport.w);
591 }
592
593 /**
594  * Convert/scale a canvas co-ordinate into output screen co-ordinates
595  *
596  * @param e The pointer to the Evas Canvas
597  * @param y The canvas y co-ordinate
598  * @return The output/screen co-ordinate translated to output co-ordinates
599  * @ingroup Evas_Coord_Mapping_Group
600  *
601  * This function takes in a vertical co-ordinate as the @p x parameter and
602  * converts it into output units, accounting for output size, viewport size
603  * and location, returning it as the function return value. If @p e is
604  * invalid, the results are undefined.
605  *
606  * Example:
607  * @code
608  * extern Evas *evas;
609  * int screen_y;
610  * extern Evas_Coord canvas_y;
611  *
612  * screen_y = evas_coord_world_y_to_screen(evas, canvas_y);
613  * @endcode
614  */
615 EAPI int
616 evas_coord_world_y_to_screen(const Evas *e, Evas_Coord y)
617 {
618    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
619    return 0;
620    MAGIC_CHECK_END();
621    if (e->output.h == e->viewport.h) return y - e->viewport.y;
622    return (int)((((long long)y - (long long)e->viewport.y) * (long long)e->output.h) /  (long long)e->viewport.h);
623 }
624
625 /**
626  * Look up a numeric ID from a string name of a rendering engine.
627  *
628  * @param name The string name of an engine
629  * @return A numeric (opaque) ID for the rendering engine
630  * @ingroup Evas_Output_Method
631  *
632  * This function looks up a numeric return value for the named engine in the
633  * string @p name. This is a normal C string, NUL byte terminated. The name
634  * is case sensitive. If the rendering engine is available, a numeric ID for
635  * that engine is returned that is not 0. If the engine is not available, 0
636  * is returned, indicating an invalid engine.
637  *
638  * The programmer should NEVER rely on the numeric ID of an engine unless it is
639  * returned by this function. Programs should NOT be written accessing render
640  * method ID's directly, without first obtaining it from this function.
641  *
642  * Example:
643  * @code
644  * int engine_id;
645  * Evas *evas;
646  *
647  * evas = evas_new();
648  * if (!evas)
649  *   {
650  *     fprintf(stderr, "ERROR: Canvas creation failed. Fatal error.\n");
651  *     exit(-1);
652  *   }
653  * engine_id = evas_render_method_lookup("software_x11");
654  * if (!engine_id)
655  *   {
656  *     fprintf(stderr, "ERROR: Requested rendering engine is absent.\n");
657  *     exit(-1);
658  *   }
659  * evas_output_method_set(evas, engine_id);
660  * @endcode
661  */
662 EAPI int
663 evas_render_method_lookup(const char *name)
664 {
665    static int i = 1;
666    Evas_Module *em;
667    Evas_Module_Engine *eem;
668    
669    if (!name) return RENDER_METHOD_INVALID;
670    /* search on the engines list for the name */
671    em = evas_module_find_type(EVAS_MODULE_TYPE_ENGINE, name);
672    
673    if (!em) return RENDER_METHOD_INVALID;
674    
675    eem = (Evas_Module_Engine *)em->data;
676    if (!eem)
677      {
678         eem = malloc(sizeof(Evas_Module_Engine));
679         em->data = eem;
680         eem->id = i;
681         i++;
682      }
683    return eem->id;
684 }
685
686 /**
687  * List all the rendering engines compiled into the copy of the Evas library
688  *
689  * @return A linked list whose data members are C strings of engine names
690  * @ingroup Evas_Output_Method
691  *
692  * Calling this will return a handle (pointer) to an Evas linked list. Each node
693  * in the linked list will have the data pointer be a (char *) pointer to the
694  * string name of the rendering engine available. The strings should never be
695  * modified, neither should the list be modified. This list should be cleaned up
696  * as soon as the program no longer needs it using
697  * evas_render_method_list_free(). If no engines are available from Evas, NULL
698  * will be returned.
699  *
700  * Example:
701  * @code
702  * Evas_List *engine_list, *l;
703  *
704  * engine_list = evas_render_method_list();
705  * if (!engine_list)
706  *   {
707  *     fprintf(stderr, "ERROR: Evas supports no engines! Exit.\n");
708  *     exit(-1);
709  *   }
710  * printf("Availible Evas Engines:\n");
711  * for (l = engine_list; l; l = l->next)
712  *   {
713  *     char *engine_name;
714  *
715  *     engine_name = l->data;
716  *     printf("%s\n", engine_name);
717  *   }
718  * evas_render_method_list_free(engine_list);
719  * @endcode
720  */
721 EAPI Evas_List *
722 evas_render_method_list(void)
723 {
724    Evas_List *methods = NULL;
725
726    /* FIXME: get from modules - this is currently coded-in */
727 #ifdef BUILD_ENGINE_SOFTWARE_DDRAW
728    methods = evas_list_append(methods, strdup("software_ddraw"));
729 #endif
730 #ifdef BUILD_ENGINE_SOFTWARE_16_DDRAW
731    methods = evas_list_append(methods, strdup("software_16_ddraw"));
732 #endif
733 #ifdef BUILD_ENGINE_DIRECT3D
734    methods = evas_list_append(methods, strdup("direct3d"));
735 #endif
736 #ifdef BUILD_ENGINE_SOFTWARE_16_WINCE
737    methods = evas_list_append(methods, strdup("software_16_wince"));
738 #endif
739 #ifdef BUILD_ENGINE_SOFTWARE_X11
740    methods = evas_list_append(methods, strdup("software_x11"));
741 #endif
742 #ifdef BUILD_ENGINE_XRENDER_X11
743    methods = evas_list_append(methods, strdup("xrender_x11"));
744 #endif
745 #ifdef BUILD_ENGINE_SOFTWARE_XCB
746    methods = evas_list_append(methods, strdup("software_xcb"));
747 #endif
748 #ifdef BUILD_ENGINE_XRENDER_XCB
749    methods = evas_list_append(methods, strdup("xrender_xcb"));
750 #endif
751 #ifdef BUILD_ENGINE_SOFTWARE_16_X11
752    methods = evas_list_append(methods, strdup("software_16_x11"));
753 #endif
754 #ifdef BUILD_ENGINE_GL_X11
755    methods = evas_list_append(methods, strdup("gl_x11"));
756 #endif
757 #ifdef BUILD_ENGINE_GL_GLEW
758    methods = evas_list_append(methods, strdup("gl_glew"));
759 #endif
760 #ifdef BUILD_ENGINE_CAIRO_X11
761    methods = evas_list_append(methods, strdup("cairo_x11"));
762 #endif
763 #ifdef BUILD_ENGINE_DIRECTFB
764    methods = evas_list_append(methods, strdup("directfb"));
765 #endif
766 #ifdef BUILD_ENGINE_FB
767    methods = evas_list_append(methods, strdup("fb"));
768 #endif
769 #ifdef BUILD_ENGINE_BUFFER
770    methods = evas_list_append(methods, strdup("buffer"));
771 #endif
772 #ifdef BUILD_ENGINE_SOFTWARE_WIN32_GDI
773    methods = evas_list_append(methods, strdup("software_win32_gdi"));
774 #endif
775 #ifdef BUILD_ENGINE_SOFTWARE_QTOPIA
776    methods = evas_list_append(methods, strdup("software_qtopia"));
777 #endif
778 #ifdef BUILD_ENGINE_SDL
779    methods = evas_list_append(methods, strdup("software_sdl"));
780 #endif
781
782    return methods;
783 }
784
785 /**
786  * This function should be called to free a list of engine names
787  *
788  * @param list The Evas_List base pointer for the engine list to be freed
789  * @ingroup Evas_Output_Method
790  *
791  * When this function is called it will free the engine list passed in as
792  * @p list. The list should only be a list of engines generated by calling
793  * evas_render_method_list(). If @p list is NULL, nothing will happen.
794  *
795  * Example:
796  * @code
797  * Evas_List *engine_list, *l;
798  *
799  * engine_list = evas_render_method_list();
800  * if (!engine_list)
801  *   {
802  *     fprintf(stderr, "ERROR: Evas supports no engines! Exit.\n");
803  *     exit(-1);
804  *   }
805  * printf("Availible Evas Engines:\n");
806  * for (l = engine_list; l; l = l->next)
807  *   {
808  *     char *engine_name;
809  *
810  *     engine_name = l->data;
811  *     printf("%s\n", engine_name);
812  *   }
813  * evas_render_method_list_free(engine_list);
814  * @endcode
815  */
816 EAPI void
817 evas_render_method_list_free(Evas_List *list)
818 {
819    while (list)
820      {
821         free(list->data);
822         list = evas_list_remove(list, list->data);
823      }
824 }
825
826 /**
827  * @defgroup Evas_Pointer_Group Evas Pointer Functions
828  *
829  * Functions that deal with the status of the pointer.
830  */
831
832 /**
833  * This function returns the current known pointer co-ordinates
834  *
835  * @param e The pointer to the Evas Canvas
836  * @param x The pointer to an integer to be filled in
837  * @param y The pointer to an integer to be filled in
838  * @ingroup Evas_Pointer_Group
839  *
840  * This function returns the current known screen/output co-ordinates of the
841  * mouse pointer and sets the contents of the integers pointed to by @p x
842  * and @p y to contain these co-ordinates. If @p e is not a valid canvas the
843  * results of this function are undefined.
844  *
845  * Example:
846  * @code
847  * extern Evas *evas;
848  * int mouse_x, mouse_y;
849  *
850  * evas_pointer_output_xy_get(evas, &mouse_x, &mouse_y);
851  * printf("Mouse is at screen position %i, %i\n", mouse_x, mouse_y);
852  * @endcode
853  */
854 EAPI void
855 evas_pointer_output_xy_get(const Evas *e, int *x, int *y)
856 {
857    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
858    if (x) *x = 0;
859    if (y) *y = 0;
860    return;
861    MAGIC_CHECK_END();
862    if (x) *x = e->pointer.x;
863    if (y) *y = e->pointer.y;
864 }
865
866 /**
867  * This function returns the current known pointer co-ordinates
868  *
869  * @param e The pointer to the Evas Canvas
870  * @param x The pointer to a Evas_Coord to be filled in
871  * @param y The pointer to a Evas_Coord to be filled in
872  * @ingroup Evas_Pointer_Group
873  *
874  * This function returns the current known canvas unit co-ordinates of the
875  * mouse pointer and sets the contents of the Evas_Coords pointed to by @p x
876  * and @p y to contain these co-ordinates. If @p e is not a valid canvas the
877  * results of this function are undefined.
878  *
879  * Example:
880  * @code
881  * extern Evas *evas;
882  * Evas_Coord mouse_x, mouse_y;
883  *
884  * evas_pointer_output_xy_get(evas, &mouse_x, &mouse_y);
885  * printf("Mouse is at canvas position %f, %f\n", mouse_x, mouse_y);
886  * @endcode
887  */
888 EAPI void
889 evas_pointer_canvas_xy_get(const Evas *e, Evas_Coord *x, Evas_Coord *y)
890 {
891    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
892    if (x) *x = 0;
893    if (y) *y = 0;
894    return;
895    MAGIC_CHECK_END();
896    if (x) *x = e->pointer.x;
897    if (y) *y = e->pointer.y;
898 }
899
900 /**
901  * Returns a bitmask with the mouse buttons currently pressed, set to 1
902  *
903  * @param e The pointer to the Evas Canvas
904  * @return A bitmask of the currently depressed buttons on the cavas
905  * @ingroup Evas_Pointer_Group
906  *
907  * Calling this function will return a 32-bit integer with the appropriate bits
908  * set to 1 that correspond to a mouse button being depressed. This limits
909  * Evas to a mouse devices with a maximum of 32 buttons, but that is generally
910  * in excess of any host system's pointing device abilities.
911  *
912  * A canvas by default begins with no mouse buttons being pressed and only
913  * calls to evas_event_feed_mouse_down(), evas_event_feed_mouse_down_data(),
914  * evas_event_feed_mouse_up() and evas_event_feed_mouse_up_data() will alter
915  * that.
916  *
917  * The least significant bit corresponds to the first mouse button (button 1)
918  * and the most significant bit corresponds to the last mouse button
919  * (button 32).
920  *
921  * If @p e is not a valid canvas, the return value is undefined.
922  *
923  * Example:
924  * @code
925  * extern Evas *evas;
926  * int button_mask, i;
927  *
928  * button_mask = evas_pointer_button_down_mask_get(evas);
929  * printf("Buttons currently pressed:\n");
930  * for (i = 0; i < 32; i++)
931  *   {
932  *     if ((button_mask & (1 << i)) != 0) printf("Button %i\n", i + 1);
933  *   }
934  * @endcode
935  */
936 EAPI int
937 evas_pointer_button_down_mask_get(const Evas *e)
938 {
939    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
940    return 0;
941    MAGIC_CHECK_END();
942    return (int)e->pointer.button;
943 }
944
945 /**
946  * Returns whether the mouse pointer is logically inside the canvas
947  *
948  * @param e The pointer to the Evas Canvas
949  * @return An integer that is 1 if the mouse is inside the canvas, 0 otherwise
950  * @ingroup Evas_Pointer_Group
951  *
952  * When this function is called it will return a value of either 0 or 1,
953  * depending on if evas_event_feed_mouse_in(), evas_event_feed_mouse_in_data(),
954  * or evas_event_feed_mouse_out(), evas_event_feed_mouse_out_data() have been
955  * called to feed in a mouse enter event into the canvas.
956  *
957  * A return value of 1 indicates the mouse is logically inside the canvas, and
958  * 0 implies it is logically outside the canvas.
959  *
960  * A canvas begins with the mouse being assumed outside (0).
961  *
962  * If @p e is not a valid canvas, the return value is undefined.
963  *
964  * Example:
965  * @code
966  * extern Evas *evas;
967  *
968  * if (evas_pointer_inside_get(evas)) printf("Mouse is in!\n");
969  * else printf("Mouse is out!\n");
970  * @endcode
971  */
972 EAPI Evas_Bool
973 evas_pointer_inside_get(const Evas *e)
974 {
975    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
976    return 0;
977    MAGIC_CHECK_END();
978    return (int)e->pointer.inside;
979 }
980
981 /**
982  * Attaches a specific pointer to the evas for fetching later
983  * 
984  * @param e The canvas to attach the pointer to
985  * @param data The pointer to attach
986  */
987 EAPI void
988 evas_data_attach_set(Evas *e, void *data)
989 {
990    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
991    return;
992    MAGIC_CHECK_END();
993    e->attach_data = data;
994 }
995
996 /**
997  * Returns the pointer attached by evas_data_attach_set()
998  * 
999  * @param e The canvas to attach the pointer to
1000  * @return The pointer attached
1001  */
1002 EAPI void *
1003 evas_data_attach_get(const Evas *e)
1004 {
1005    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
1006    return NULL;
1007    MAGIC_CHECK_END();
1008    return e->attach_data;
1009 }
1010
1011 void
1012 _evas_walk(Evas *e)
1013 {
1014    e->walking_list++;
1015 }
1016
1017 void
1018 _evas_unwalk(Evas *e)
1019 {
1020    e->walking_list--;
1021    if ((e->walking_list == 0) && (e->delete_me)) evas_free(e);
1022 }
1023