ecore_evas_object_example.c
#include <Ecore.h>
#include <Ecore_Evas.h>
Evas_Object *cursor;
static void
_mouse_down_cb(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
static Eina_Bool flag = EINA_FALSE;
if (!flag)
{
ecore_evas_cursor_unset(data);
ecore_evas_object_cursor_set(data, NULL, 0, 1, 1);
}
else
ecore_evas_object_cursor_set(data, cursor, 0, 1, 1);
flag = !flag;
}
int
main(void)
{
Ecore_Evas *ee;
Evas_Object *bg, *obj;
int layer, x, y;
ecore_evas_init();
ee = ecore_evas_new(NULL, 0, 0, 200, 200, NULL);
ecore_evas_title_set(ee, "Ecore Evas Object Example");
ecore_evas_show(ee);
bg = evas_object_rectangle_add(ecore_evas_get(ee));
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);
evas_object_event_callback_add(bg, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, ee);
if (bg == ecore_evas_object_associate_get(ee))
printf("Association worked!\n");
cursor = evas_object_rectangle_add(ecore_evas_get(ee));
evas_object_color_set(cursor, 0, 255, 0, 255);
evas_object_resize(cursor, 5, 10);
ecore_evas_object_cursor_set(ee, cursor, 0, 1, 1);
ecore_evas_cursor_get(ee, &obj, &layer, &x, &y);
if (obj == cursor && layer == 0 && x == 1 && y == 1)
printf("Set cursor worked!\n");
ecore_main_loop_begin();
ecore_evas_free(ee);
ecore_evas_shutdown();
return 0;
}
Ecore_Evas.h
Evas wrapper functions.
EVAS_CALLBACK_MOUSE_DOWN
@ EVAS_CALLBACK_MOUSE_DOWN
Mouse Button Down Event.
Definition Evas_Common.h:422
ecore_evas_init
EAPI int ecore_evas_init(void)
Inits the Ecore_Evas system.
Definition ecore_evas.c:608
ecore_evas_title_set
EAPI void ecore_evas_title_set(Ecore_Evas *ee, const char *t)
Sets the title of an Ecore_Evas' window.
Definition ecore_evas.c:1541
ecore_evas_show
EAPI void ecore_evas_show(Ecore_Evas *ee)
Shows an Ecore_Evas' window.
Definition ecore_evas.c:1494
ecore_evas_object_cursor_set
EAPI void ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
Sets the cursor for the default pointer device.
Definition ecore_evas.c:1845
ecore_evas_cursor_unset
EAPI Evas_Object * ecore_evas_cursor_unset(Ecore_Evas *ee)
Unsets the cursor of the default pointer device.
Definition ecore_evas.c:1942
ecore_evas_get
EAPI Evas * ecore_evas_get(const Ecore_Evas *ee)
Gets an Ecore_Evas's Evas.
Definition ecore_evas.c:1314
ecore_evas_object_associate_get
EAPI Evas_Object * ecore_evas_object_associate_get(const Ecore_Evas *ee)
Gets the object associated with ee.
Definition ecore_evas_util.c:283
ecore_evas_cursor_get
EAPI void ecore_evas_cursor_get(const Ecore_Evas *ee, Evas_Object **obj, int *layer, int *hot_x, int *hot_y)
Gets information about an Ecore_Evas' default pointer device.
Definition ecore_evas.c:1902
ecore_evas_new
EAPI Ecore_Evas * ecore_evas_new(const char *engine_name, int x, int y, int w, int h, const char *extra_options)
Creates a new Ecore_Evas based on engine name and common parameters.
Definition ecore_evas.c:1053
ecore_evas_shutdown
EAPI int ecore_evas_shutdown(void)
Shuts down the Ecore_Evas system.
Definition ecore_evas.c:672
ecore_evas_object_associate
EAPI Eina_Bool ecore_evas_object_associate(Ecore_Evas *ee, Evas_Object *obj, Ecore_Evas_Object_Associate_Flags flags)
Associates the given object to this ecore evas.
Definition ecore_evas_util.c:223
ecore_evas_free
EAPI void ecore_evas_free(Ecore_Evas *ee)
Frees an Ecore_Evas.
Definition ecore_evas.c:1097
ecore_main_loop_begin
void ecore_main_loop_begin(void)
Runs the application main loop.
Definition ecore_main.c:1311
EINA_FALSE
#define EINA_FALSE
boolean value FALSE (numerical value 0)
Definition eina_types.h:533
Eina_Bool
unsigned char Eina_Bool
Type to mimic a boolean.
Definition eina_types.h:527
EINA_UNUSED
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition eina_types.h:339
Evas
Eo Evas
An opaque handle to an Evas canvas.
Definition Evas_Common.h:163
evas_object_show
EVAS_API void evas_object_show(Evas_Object *eo_obj)
Makes the given Evas object visible.
Definition evas_object_main.c:1814
evas_object_color_set
EVAS_API void evas_object_color_set(Evas_Object *obj, int r, int g, int b, int a)
Sets the general/main color of the given Evas object to the given one.
Definition evas_object_main.c:2024
evas_object_event_callback_add
EVAS_API void evas_object_event_callback_add(Evas_Object *eo_obj, Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data)
Add (register) a callback function to a given Evas object event.
Definition evas_callbacks.c:478
Evas_Object
Efl_Canvas_Object Evas_Object
An Evas Object handle.
Definition Evas_Common.h:185
evas_object_resize
EVAS_API void evas_object_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
Changes the size of the given Evas object.
Definition evas_object_main.c:1236
evas_object_rectangle_add
EVAS_API Evas_Object * evas_object_rectangle_add(Evas *e)
Adds a rectangle to the given evas.
Definition evas_object_rectangle.c:78