Evas object smart interfaces

- Main Page
- Related Pages
- Topics
- Data Structures
- Files
- Examples

Evas object smart interfaces

In this example, we illustrate how to create and handle Evas smart interfaces. Note that we use the same code base of the Evas object smart objects example, here. We just augment it with an interfaces demonstration.

A smart interface is just a functions interface a given smart object is declaring to support and or use. In Evas, interfaces are very simple: no interface inheritance, no interface overriding. Their purpose is to extend an object's capabilities and behavior beyond the sub-classing schema.

Here, together with a custom smart object, we create and declare the object as using an Evas interface. It'll have a custom function, too, besides the `add()` and del() obligatory ones. To demonstrate interface data, which is bound to object instances, we'll have a string as this data.

Here is where we declare our interface:

static const char iface1_data[] = "iface1_data";
static const char IFACE1_NAME[] = "iface1";
static Eina_Bool _iface1_add(Evas_Object *);
static void _iface1_del(Evas_Object *);
static void _iface1_custom_fn(Evas_Object *);
typedef struct _Evas_Smart_Example_Interface Evas_Smart_Example_Interface;
struct _Evas_Smart_Example_Interface
{
Evas_Smart_Interface base;
void (*example_func)(Evas_Object *obj);
};
static Evas_Smart_Example_Interface iface1;
static Eina_Bool
_iface1_add(Evas_Object *obj EINA_UNUSED)
{
printf("iface1's add()!\n");
return EINA_TRUE;
}
static void
_iface1_del(Evas_Object *obj)
{
printf("iface1's del()! Data is %s\n",
(char *)evas_object_smart_interface_data_get
(obj, (Evas_Smart_Interface *)&iface1));
}
static void
_iface1_custom_fn(Evas_Object *obj EINA_UNUSED)
{
printf("iface1's custom_fn()!\n");
}
static const Evas_Smart_Interface *_smart_interfaces[] =
{
(Evas_Smart_Interface *)&iface1, NULL
EINA_TRUE
#define EINA_TRUE
boolean value TRUE (numerical value 1)
Definition eina_types.h:539
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_object_smart_interface_data_get
EVAS_API void * evas_object_smart_interface_data_get(const Evas_Object *eo_obj, const Evas_Smart_Interface *iface)
Retrieve an Evas smart object interface's private data.
Definition evas_object_smart.c:180
_Evas_Smart_Interface
A smart object's base interface definition.
Definition Evas_Common.h:1989
};

Note that there's error checking for interfaces creation, by means of the `add()` method's return value (`_iface1_add()`, here).

Now note that here we are filling in the interface's fields dynamically. Let's move on to that code region:

iface = (Evas_Smart_Example_Interface *)&iface1;
iface->base.name = IFACE1_NAME;
iface->base.private_size = sizeof(iface1_data);
iface->base.add = _iface1_add;
iface->base.del = _iface1_del;
iface->example_func = _iface1_custom_fn;
d.smt = evas_smart_example_add(d.evas);

As important as setting the function pointers, is declaring the `private_size` as to match exactly the size of the data blob we want to have allocated for us by Evas. This will happen automatically inside `evas_smart_example_add()`. Later, on this code, we deal exactly with that data blob, more specifically writing on it (as it's not done inside `_iface1_add()`, here:

iface = (Evas_Smart_Example_Interface *)evas_object_smart_interface_get
(d.smt, IFACE1_NAME);
if (iface)
{
char *data;
printf("We've found a smart interface on the smart object!"
"\n\tname: %s\n", iface->base.name);
printf("Setting its interface data...\n");
data = evas_object_smart_interface_data_get
(d.smt, (Evas_Smart_Interface *)iface);
memcpy(data, iface1_data, sizeof(iface1_data));
printf("Calling an interface's function...\n");
iface->example_func(d.smt);
}
evas_object_smart_interface_get
EVAS_API const void * evas_object_smart_interface_get(const Evas_Object *eo_obj, const char *name)
Retrieve an Evas smart object's interface, by name string pointer.
Definition evas_object_smart.c:156

Before accessing the interface data, we exercise the interface fetching call evas_object_smart_interface_get(), with the name string we used to be interface's name. With that handle in hands, we issue evas_object_smart_interface_data_get() and write the string we want as data on that memory region. That will make up for the string you get on `_iface1_del()`.

The full example follows.

#ifdef HAVE_CONFIG_H
#include "config.h"
#else
#define PACKAGE_EXAMPLES_DIR "."
#endif
#include <Ecore.h>
#include <Ecore_Evas.h>
#include <stdio.h>
#include <errno.h>
#define WIDTH (320)
#define HEIGHT (240)
static const char *commands = \
"commands are:\n"
"\tl - insert child rectangle on the left\n"
"\tr - insert child rectangle on the right\n"
"\tw - remove and delete all members from the smart object\n"
"\tright arrow - move smart object to the right\n"
"\tleft arrow - move smart object to the left\n"
"\tup arrow - move smart object up\n"
"\tdown arrow - move smart object down\n"
"\td - decrease smart object's size\n"
"\ti - increase smart object's size\n"
"\tc - change smart object's clipper color\n"
"\th - print help\n"
"\tq - quit\n"
;
#define WHITE {255, 255, 255, 255}
#define RED {255, 0, 0, 255}
#define GREEN {0, 255, 0, 255}
#define BLUE {0, 0, 255, 255}
struct test_data
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *smt, *bg, *clipper, *rects[2];
};
struct color_tuple
{
int r, g, b, a;
} clipper_colors[4] = {WHITE, RED, GREEN, BLUE};
int cur_color = 0;
static const char *
_index_to_color(int i)
{
switch (i)
{
case 0:
return "WHITE (default)";
case 1:
return "RED";
case 2:
return "GREEN";
case 3:
return "BLUE";
default:
return "other";
}
}
static struct test_data d = {0};
static const char *border_img_path = PACKAGE_EXAMPLES_DIR "/red.png";
#define _evas_smart_example_type "Evas_Smart_Example"
static const char iface1_data[] = "iface1_data";
static const char IFACE1_NAME[] = "iface1";
static Eina_Bool _iface1_add(Evas_Object *);
static void _iface1_del(Evas_Object *);
static void _iface1_custom_fn(Evas_Object *);
typedef struct _Evas_Smart_Example_Interface Evas_Smart_Example_Interface;
struct _Evas_Smart_Example_Interface
{
Evas_Smart_Interface base;
void (*example_func)(Evas_Object *obj);
};
static Evas_Smart_Example_Interface iface1;
static Eina_Bool
_iface1_add(Evas_Object *obj EINA_UNUSED)
{
printf("iface1's add()!\n");
return EINA_TRUE;
}
static void
_iface1_del(Evas_Object *obj)
{
printf("iface1's del()! Data is %s\n",
(char *)evas_object_smart_interface_data_get
(obj, (Evas_Smart_Interface *)&iface1));
}
static void
_iface1_custom_fn(Evas_Object *obj EINA_UNUSED)
{
printf("iface1's custom_fn()!\n");
}
static const Evas_Smart_Interface *_smart_interfaces[] =
{
(Evas_Smart_Interface *)&iface1, NULL
};
#define EVT_CHILDREN_NUMBER_CHANGED "children,changed"
static const Evas_Smart_Cb_Description _smart_callbacks[] =
{
{EVT_CHILDREN_NUMBER_CHANGED, "i"},
{NULL, NULL}
};
typedef struct _Evas_Smart_Example_Data Evas_Smart_Example_Data;
/*
* This structure augments clipped smart object's instance data,
* providing extra members required by our example smart object's
* implementation.
*/
struct _Evas_Smart_Example_Data
{
Evas_Object_Smart_Clipped_Data base;
Evas_Object *children[2], *border;
int child_count;
};
#define EVAS_SMART_EXAMPLE_DATA_GET(o, ptr) \
Evas_Smart_Example_Data * ptr = evas_object_smart_data_get(o)
#define EVAS_SMART_EXAMPLE_DATA_GET_OR_RETURN(o, ptr) \
EVAS_SMART_EXAMPLE_DATA_GET(o, ptr); \
if (!ptr) \
{ \
fprintf(stderr, "No widget data for object %p (%s)!", \
o, evas_object_type_get(o)); \
fflush(stderr); \
abort(); \
return; \
}
#define EVAS_SMART_EXAMPLE_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
EVAS_SMART_EXAMPLE_DATA_GET(o, ptr); \
if (!ptr) \
{ \
fprintf(stderr, "No widget data for object %p (%s)!", \
o, evas_object_type_get(o)); \
fflush(stderr); \
abort(); \
return val; \
}
EVAS_SMART_SUBCLASS_IFACE_NEW
(_evas_smart_example_type, _evas_smart_example, Evas_Smart_Class,
Evas_Smart_Class, evas_object_smart_clipped_class_get, _smart_callbacks,
_smart_interfaces);
static void
_on_destroy(Ecore_Evas *ee EINA_UNUSED)
{
ecore_main_loop_quit();
}
/* Keep the example's window size in sync with the background image's size */
static void
_canvas_resize_cb(Ecore_Evas *ee)
{
int w, h;
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
evas_object_resize(d.bg, w, h);
}
static void
_on_child_del(void *data,
Evas *evas EINA_UNUSED,
Evas_Object *o,
void *einfo EINA_UNUSED)
{
Evas_Object *example_smart = data;
long idx;
EVAS_SMART_EXAMPLE_DATA_GET(example_smart, priv);
idx = (long)(uintptr_t)evas_object_data_get(o, "index");
idx--;
priv->children[idx] = NULL;
evas_object_smart_member_del(o);
evas_object_smart_changed(example_smart);
}
static void
_evas_smart_example_child_callbacks_unregister(Evas_Object *obj)
{
evas_object_data_set(obj, "index", NULL);
evas_object_event_callback_del(obj, EVAS_CALLBACK_FREE, _on_child_del);
}
static void
_evas_smart_example_child_callbacks_register(Evas_Object *o,
Evas_Object *child,
long idx)
{
evas_object_event_callback_add(child, EVAS_CALLBACK_FREE, _on_child_del, o);
evas_object_data_set(child, "index", (void *)(uintptr_t)(++idx));
}
/* create and setup a new example smart object's internals */
static void
_evas_smart_example_smart_add(Evas_Object *o)
{
EVAS_SMART_DATA_ALLOC(o, Evas_Smart_Example_Data);
/* this is a border around the smart object's area, delimiting it */
priv->border = evas_object_image_filled_add(evas_object_evas_get(o));
evas_object_image_file_set(priv->border, border_img_path, NULL);
evas_object_image_border_set(priv->border, 3, 3, 3, 3);
evas_object_image_border_center_fill_set(
priv->border, EVAS_BORDER_FILL_NONE);
evas_object_smart_member_add(priv->border, o);
_evas_smart_example_parent_sc->add(o);
}
static void
_evas_smart_example_smart_del(Evas_Object *o)
{
EVAS_SMART_EXAMPLE_DATA_GET(o, priv);
if (priv->children[0])
{
_evas_smart_example_child_callbacks_unregister(priv->children[0]);
priv->children[0] = NULL;
}
if (priv->children[1])
{
_evas_smart_example_child_callbacks_unregister(priv->children[1]);
priv->children[1] = NULL;
}
_evas_smart_example_parent_sc->del(o);
}
static void
_evas_smart_example_smart_show(Evas_Object *o)
{
EVAS_SMART_EXAMPLE_DATA_GET(o, priv);
if (priv->children[0]) evas_object_show(priv->children[0]);
if (priv->children[1]) evas_object_show(priv->children[1]);
evas_object_show(priv->border);
_evas_smart_example_parent_sc->show(o);
}
static void
_evas_smart_example_smart_hide(Evas_Object *o)
{
EVAS_SMART_EXAMPLE_DATA_GET(o, priv);
if (priv->children[0]) evas_object_hide(priv->children[0]);
if (priv->children[1]) evas_object_hide(priv->children[1]);
evas_object_hide(priv->border);
_evas_smart_example_parent_sc->hide(o);
}
static void
_evas_smart_example_smart_resize(Evas_Object *o,
Evas_Coord w,
Evas_Coord h)
{
Evas_Coord ow, oh;
evas_object_geometry_get(o, NULL, NULL, &ow, &oh);
if ((ow == w) && (oh == h)) return;
/* this will trigger recalculation */
evas_object_smart_changed(o);
}
/* act on child objects' properties, before rendering */
static void
_evas_smart_example_smart_calculate(Evas_Object *o)
{
Evas_Coord x, y, w, h;
EVAS_SMART_EXAMPLE_DATA_GET_OR_RETURN(o, priv);
evas_object_geometry_get(o, &x, &y, &w, &h);
evas_object_resize(priv->border, w, h);
evas_object_move(priv->border, x, y);
if (priv->children[0])
{
evas_object_move(priv->children[0], x + 3, y + 3);
evas_object_resize(priv->children[0], (w / 2) - 3, (h / 2) - 3);
}
if (priv->children[1])
{
evas_object_move(priv->children[1], x + (w / 2), y + (h / 2));
evas_object_resize(priv->children[1], (w / 2) - 3, (h / 2) - 3);
}
}
/* setting our smart interface */
static void
_evas_smart_example_smart_set_user(Evas_Smart_Class *sc)
{
/* specializing these two */
sc->add = _evas_smart_example_smart_add;
sc->del = _evas_smart_example_smart_del;
sc->show = _evas_smart_example_smart_show;
sc->hide = _evas_smart_example_smart_hide;
/* clipped smart object has no hook on resizes or calculations */
sc->resize = _evas_smart_example_smart_resize;
sc->calculate = _evas_smart_example_smart_calculate;
}
/* BEGINS example smart object's own interface */
/* add a new example smart object to a canvas */
Evas_Object *
evas_smart_example_add(Evas *evas)
{
return evas_object_smart_add(evas, _evas_smart_example_smart_class_new());
}
static void
_evas_smart_example_remove_do(Evas_Smart_Example_Data *priv,
Evas_Object *child,
int idx)
{
priv->children[idx] = NULL;
priv->child_count--;
_evas_smart_example_child_callbacks_unregister(child);
evas_object_smart_member_del(child);
}
/* remove a child element, return its pointer (or NULL on errors) */
Evas_Object *
evas_smart_example_remove(Evas_Object *o,
Evas_Object *child)
{
long idx;
EVAS_SMART_EXAMPLE_DATA_GET_OR_RETURN_VAL(o, priv, NULL);
if (priv->children[0] != child && priv->children[1] != child)
{
fprintf(stderr, "You are trying to remove something not belonging to"
" the example smart object!\n");
return NULL;
}
idx = (long)(uintptr_t)evas_object_data_get(child, "index");
idx--;
_evas_smart_example_remove_do(priv, child, idx);
evas_object_smart_callback_call(
o, EVT_CHILDREN_NUMBER_CHANGED, (void *)(uintptr_t)priv->child_count);
evas_object_smart_changed(o);
return child;
}
/* set to return any previous object set to the left position of the
* smart object or NULL, if any (or on errors) */
Evas_Object *
evas_smart_example_set_left(Evas_Object *o,
Evas_Object *child)
{
Evas_Object *ret = NULL;
EVAS_SMART_EXAMPLE_DATA_GET_OR_RETURN_VAL(o, priv, NULL);
if (!child)
return NULL;
if (priv->children[1] == child)
{
fprintf(stderr, "You mustn't place a child on both slots of"
" the example smart object!\n");
return NULL;
}
if (priv->children[0])
{
if (priv->children[0] != child)
{
ret = priv->children[0];
_evas_smart_example_remove_do(priv, priv->children[0], 0);
}
else return child;
}
priv->children[0] = child;
_evas_smart_example_child_callbacks_register(o, child, 0);
evas_object_smart_member_add(child, o);
evas_object_smart_changed(o);
priv->child_count++;
if (!ret)
{
evas_object_smart_callback_call(
o, EVT_CHILDREN_NUMBER_CHANGED, (void *)(uintptr_t)priv->child_count);
}
return ret;
}
/* set to return any previous object set to the right position of the
* smart object or NULL, if any (or on errors) */
Evas_Object *
evas_smart_example_set_right(Evas_Object *o,
Evas_Object *child)
{
Evas_Object *ret = NULL;
EVAS_SMART_EXAMPLE_DATA_GET_OR_RETURN_VAL(o, priv, NULL);
if (!child)
return NULL;
if (priv->children[0] == child)
{
fprintf(stderr, "You mustn't place a child on both slots of"
" the example smart object!\n");
return NULL;
}
if (priv->children[1])
{
if (priv->children[1] != child)
{
ret = priv->children[1];
_evas_smart_example_remove_do(priv, priv->children[1], 1);
}
else return child;
}
priv->children[1] = child;
_evas_smart_example_child_callbacks_register(o, child, 1);
evas_object_smart_member_add(child, o);
evas_object_smart_changed(o);
priv->child_count++;
if (!ret)
{
evas_object_smart_callback_call(
o, EVT_CHILDREN_NUMBER_CHANGED, (void *)(uintptr_t)priv->child_count);
}
return ret;
}
/* END OF example smart object's own interface */
static void
_on_keydown(void *data EINA_UNUSED,
Evas *evas EINA_UNUSED,
Evas_Object *o EINA_UNUSED,
void *einfo)
{
Evas_Event_Key_Down *ev = einfo;
if (strcmp(ev->key, "q") == 0) /* print help */
{
_on_destroy(NULL);
return;
}
if (strcmp(ev->key, "h") == 0) /* print help */
{
printf("%s\n", commands);
return;
}
if (strcmp(ev->key, "w") == 0) /* clear out smart object (WRT
* members) */
{
if (d.rects[0])
{
evas_smart_example_remove(d.smt, d.rects[0]);
evas_object_del(d.rects[0]);
}
if (d.rects[1])
{
evas_smart_example_remove(d.smt, d.rects[1]);
evas_object_del(d.rects[1]);
}
memset(d.rects, 0, sizeof(d.rects));
printf("Deleting all members of the smart object.\n");
return;
}
if (strcmp(ev->key, "l") == 0) /* insert random colored
* rectangle on the left */
{
Evas_Object *rect = evas_object_rectangle_add(d.evas), *prev;
evas_object_color_set(
rect, rand() % 255, rand() % 255, rand() % 255, 255);
evas_object_show(rect);
prev = evas_smart_example_set_left(d.smt, rect);
d.rects[0] = rect;
printf("Setting smart object's left spot with a new"
" rectangle.\n");
printf("Checking its new smart object parent: %s\n",
evas_object_smart_parent_get(rect) == d.smt ? "OK!" :
"Failure!");
if (prev)
{
int r, g, b;
evas_object_color_get(prev, &r, &g, &b, NULL);
printf("Deleting previous left child,"
" which had colors (%d, %d, %d)\n", r, g, b);
evas_object_del(prev);
}
return;
}
if (strcmp(ev->key, "r") == 0) /* insert random colored
* rectangle on the right */
{
Evas_Object *rect = evas_object_rectangle_add(d.evas), *prev;
evas_object_color_set(
rect, rand() % 255, rand() % 255, rand() % 255, 255);
evas_object_show(rect);
prev = evas_smart_example_set_right(d.smt, rect);
d.rects[1] = rect;
printf("Setting smart object's right spot with a new"
" rectangle.\n");
printf("Checking its new smart object parent: %s\n",
evas_object_smart_parent_get(rect) == d.smt ? "OK!" :
"Failure!");
if (prev)
{
int r, g, b;
evas_object_color_get(prev, &r, &g, &b, NULL);
printf("Deleting previous right child,"
" which had colors (%d, %d, %d)\n", r, g, b);
evas_object_del(prev);
}
return;
}
/* move smart object along the canvas */
if (strcmp(ev->key, "Right") == 0 || strcmp(ev->key, "Left") == 0 ||
strcmp(ev->key, "Up") == 0 || strcmp(ev->key, "Down") == 0)
{
Evas_Coord x, y;
evas_object_geometry_get(d.smt, &x, &y, NULL, NULL);
switch (ev->key[0])
{
case 'R':
x += 20;
break;
case 'L':
x -= 20;
break;
case 'U':
y -= 20;
break;
case 'D':
y += 20;
break;
}
evas_object_move(d.smt, x, y);
return;
}
/* increase smart object's size */
if (strcmp(ev->key, "i") == 0)
{
Evas_Coord w, h;
evas_object_geometry_get(d.smt, NULL, NULL, &w, &h);
w *= 1.1;
h *= 1.1;
evas_object_resize(d.smt, w, h);
return;
}
/* decrease smart object's size */
if (strcmp(ev->key, "d") == 0)
{
Evas_Coord w, h;
evas_object_geometry_get(d.smt, NULL, NULL, &w, &h);
w *= 0.9;
h *= 0.9;
evas_object_resize(d.smt, w, h);
return;
}
/* change smart object's clipper color */
if (strcmp(ev->key, "c") == 0)
{
cur_color = (cur_color + 1) % 4;
evas_object_color_set(
d.clipper, clipper_colors[cur_color].r, clipper_colors[cur_color].g,
clipper_colors[cur_color].b, clipper_colors[cur_color].a);
fprintf(stderr, "Changing clipper's color to %s\n",
_index_to_color(cur_color));
return;
}
}
static void
/* callback on number of member objects changed */
_on_example_smart_object_child_num_change(void *data EINA_UNUSED,
Evas_Object *obj EINA_UNUSED,
void *event_info)
{
printf("Number of child members on our example smart"
" object changed to %llu\n", (unsigned long long)(uintptr_t)event_info);
}
int
main(void)
{
const Evas_Smart_Cb_Description **descriptions;
Evas_Smart_Example_Interface *iface;
unsigned int count;
Eina_Bool ret;
if (!ecore_evas_init())
return EXIT_FAILURE;
/* this will give you a window with an Evas canvas under the first
* engine available */
d.ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL);
if (!d.ee)
goto error;
ecore_evas_callback_destroy_set(d.ee, _on_destroy);
ecore_evas_callback_resize_set(d.ee, _canvas_resize_cb);
ecore_evas_show(d.ee);
/* the canvas pointer, de facto */
d.evas = ecore_evas_get(d.ee);
d.bg = evas_object_rectangle_add(d.evas);
evas_object_color_set(d.bg, 255, 255, 255, 255);
evas_object_move(d.bg, 0, 0);
evas_object_resize(d.bg, WIDTH, HEIGHT);
evas_object_show(d.bg);
iface = (Evas_Smart_Example_Interface *)&iface1;
iface->base.name = IFACE1_NAME;
iface->base.private_size = sizeof(iface1_data);
iface->base.add = _iface1_add;
iface->base.del = _iface1_del;
iface->example_func = _iface1_custom_fn;
d.smt = evas_smart_example_add(d.evas);
evas_object_move(d.smt, WIDTH / 4, HEIGHT / 4);
evas_object_resize(d.smt, WIDTH / 2, HEIGHT / 2);
evas_object_show(d.smt);
ret = evas_object_smart_type_check(d.smt, _evas_smart_example_type);
printf("Adding smart object of type \"%s\" to the canvas: %s.\n",
_evas_smart_example_type, ret ? "success" : "failure");
d.clipper = evas_object_smart_clipped_clipper_get(d.smt);
printf("Checking if clipped smart object's clipper is a "
"\"static\" one: %s\n",
evas_object_static_clip_get(d.clipper) ? "yes" : "no");
evas_object_color_set(
d.clipper, clipper_colors[cur_color].r, clipper_colors[cur_color].g,
clipper_colors[cur_color].b, clipper_colors[cur_color].a);
evas_object_smart_callbacks_descriptions_get(
d.smt, &descriptions, &count, NULL, NULL);
for (; *descriptions; descriptions++)
{
printf("We've found a smart callback on the smart object!"
"\n\tname: %s\n\ttype: %s\n", (*descriptions)->name,
(*descriptions)->type);
if (strcmp((*descriptions)->type, "i")) continue;
/* we know we don't have other types of smart callbacks
* here, just playing with it */
/* for now, we know the only one callback is the one
* reporting number of member objects changed on the
* example smart object */
evas_object_smart_callback_add(
d.smt, (*descriptions)->name,
_on_example_smart_object_child_num_change, NULL);
}
evas_object_focus_set(d.bg, EINA_TRUE);
evas_object_event_callback_add(
d.bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, NULL);
iface = (Evas_Smart_Example_Interface *)evas_object_smart_interface_get
(d.smt, IFACE1_NAME);
if (iface)
{
char *data;
printf("We've found a smart interface on the smart object!"
"\n\tname: %s\n", iface->base.name);
printf("Setting its interface data...\n");
data = evas_object_smart_interface_data_get
(d.smt, (Evas_Smart_Interface *)iface);
memcpy(data, iface1_data, sizeof(iface1_data));
printf("Calling an interface's function...\n");
iface->example_func(d.smt);
}
printf("%s\n", commands);
ecore_main_loop_begin();
ecore_evas_free(d.ee);
ecore_evas_shutdown();
return 0;
error:
fprintf(stderr, "error: Requires at least one Evas engine built and linked"
" to ecore-evas for this example to run properly.\n");
ecore_evas_shutdown();
return -1;
}
Ecore_Evas.h
Evas wrapper functions.
Evas_Coord
int Evas_Coord
Type used for coordinates (in pixels, int).
Definition Evas_Common.h:116
EVAS_CALLBACK_KEY_DOWN
@ EVAS_CALLBACK_KEY_DOWN
Key Press Event.
Definition Evas_Common.h:430
EVAS_CALLBACK_FREE
@ EVAS_CALLBACK_FREE
Object Being Freed (Called after Del)
Definition Evas_Common.h:429
ecore_evas_init
EAPI int ecore_evas_init(void)
Inits the Ecore_Evas system.
Definition ecore_evas.c:602
ecore_evas_callback_destroy_set
EAPI void ecore_evas_callback_destroy_set(Ecore_Evas *ee, Ecore_Evas_Event_Cb func)
Sets a callback for Ecore_Evas destroy events.
Definition ecore_evas.c:1185
ecore_evas_show
EAPI void ecore_evas_show(Ecore_Evas *ee)
Shows an Ecore_Evas' window.
Definition ecore_evas.c:1480
ecore_evas_get
EAPI Evas * ecore_evas_get(const Ecore_Evas *ee)
Gets an Ecore_Evas's Evas.
Definition ecore_evas.c:1300
ecore_evas_geometry_get
EAPI void ecore_evas_geometry_get(const Ecore_Evas *ee, int *x, int *y, int *w, int *h)
Gets the geometry of an Ecore_Evas.
Definition ecore_evas.c:1362
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:1039
ecore_evas_callback_resize_set
EAPI void ecore_evas_callback_resize_set(Ecore_Evas *ee, Ecore_Evas_Event_Cb func)
Sets a callback for Ecore_Evas resize events.
Definition ecore_evas.c:1140
ecore_evas_shutdown
EAPI int ecore_evas_shutdown(void)
Shuts down the Ecore_Evas system.
Definition ecore_evas.c:666
ecore_evas_free
EAPI void ecore_evas_free(Ecore_Evas *ee)
Frees an Ecore_Evas.
Definition ecore_evas.c:1083
ecore_main_loop_quit
void ecore_main_loop_quit(void)
Quits the main loop once all the events currently on the queue have been processed.
Definition ecore_main.c:1326
ecore_main_loop_begin
void ecore_main_loop_begin(void)
Runs the application main loop.
Definition ecore_main.c:1316
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_geometry_get
EVAS_API void evas_object_geometry_get(const Evas_Object *eo_obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
Retrieves the position and (rectangular) size of the given Evas object.
Definition evas_object_main.c:1335
evas_object_del
EVAS_API void evas_object_del(Evas_Object *obj)
Marks the given Evas object for deletion (when Evas will free its memory).
Definition evas_object_main.c:928
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_color_get
EVAS_API void evas_object_color_get(const Evas_Object *obj, int *r, int *g, int *b, int *a)
Retrieves the general/main color of the given Evas object.
Definition evas_object_main.c:2071
evas_object_hide
EVAS_API void evas_object_hide(Evas_Object *eo_obj)
Makes the given Evas object invisible.
Definition evas_object_main.c:1823
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_data_set
EVAS_API void evas_object_data_set(Evas_Object *eo_obj, const char *key, const void *data)
Set an attached data pointer to an object with a given string key.
Definition evas_data.c:5
evas_object_move
EVAS_API void evas_object_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
Move the given Evas object to the given location inside its canvas' viewport.
Definition evas_object_main.c:1171
evas_object_evas_get
EVAS_API Evas * evas_object_evas_get(const Eo *eo_obj)
Get the Evas to which this object belongs to.
Definition evas_object_main.c:2662
evas_object_static_clip_get
EVAS_API Eina_Bool evas_object_static_clip_get(const Evas_Object *eo_obj)
Get the "static clipper" hint flag for a given Evas object.
Definition evas_object_main.c:2574
evas_object_smart_parent_get
EVAS_API Efl_Canvas_Object * evas_object_smart_parent_get(const Efl_Canvas_Object *obj)
Gets the parent smart object of a given Evas object, if it has one.
Definition efl_canvas_object_eo.legacy.c:100
evas_object_focus_set
EVAS_API void evas_object_focus_set(Efl_Canvas_Object *obj, Eina_Bool focus)
Indicates that this object is the keyboard event receiver on its canvas.
Definition efl_canvas_object_eo.legacy.c:39
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_image_border_set
EVAS_API void evas_object_image_border_set(Evas_Object *obj, int l, int r, int t, int b)
Dimensions of this image's border, a region that does not scale with the center area.
Definition evas_image_legacy.c:117
evas_object_image_border_center_fill_set
EVAS_API void evas_object_image_border_center_fill_set(Evas_Object *obj, Evas_Border_Fill_Mode fill)
Specifies how the center part of the object (not the borders) should be drawn when EFL is rendering i...
Definition evas_image_legacy.c:145
evas_object_image_file_set
EVAS_API void evas_object_image_file_set(Evas_Object *obj, const char *file, const char *key)
Set the source file from where an image object must fetch the real image data (it may be an Eet file,...
Definition evas_image_legacy.c:194
evas_object_image_filled_add
EVAS_API Evas_Object * evas_object_image_filled_add(Evas *eo_e)
Creates a new image object that automatically scales its bound image to the object's area,...
Definition evas_image_legacy.c:35
EVAS_BORDER_FILL_NONE
@ EVAS_BORDER_FILL_NONE
Image's center region is not to be rendered.
Definition Evas_Legacy.h:5721
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
EVAS_SMART_DATA_ALLOC
#define EVAS_SMART_DATA_ALLOC(o, priv_type)
Convenience macro to allocate smart data only if needed.
Definition Evas_Common.h:2314
EVAS_SMART_SUBCLASS_IFACE_NEW
#define EVAS_SMART_SUBCLASS_IFACE_NEW(smart_name, prefix, api_type, parent_type, parent_func, cb_desc, ifaces)
Definition Evas_Common.h:2258
evas_object_smart_clipped_class_get
EVAS_API const Evas_Smart_Class * evas_object_smart_clipped_class_get(void)
Get a pointer to the clipped smart object's class, to use for proper inheritance.
Definition evas_object_smart_clipped.c:121
evas_object_smart_clipped_clipper_get
EVAS_API Evas_Object * evas_object_smart_clipped_clipper_get(const Evas_Object *eo_obj)
Get the clipper object for the given clipped smart object.
Definition evas_object_smart_clipped.c:14
evas_object_smart_type_check
EVAS_API Eina_Bool evas_object_smart_type_check(const Evas_Object *eo_obj, const char *type)
Checks whether a given smart object or any of its smart object parents is of a given smart class.
Definition evas_object_smart.c:430
evas_object_smart_changed
EVAS_API void evas_object_smart_changed(Efl_Canvas_Group *obj)
Marks the object as dirty.
Definition efl_canvas_group_eo.legacy.c:15
evas_object_smart_add
EVAS_API Evas_Object * evas_object_smart_add(Evas *eo_e, Evas_Smart *s)
Instantiates a new smart object described by s.
Definition evas_object_smart.c:702
evas_object_smart_callback_call
EVAS_API void evas_object_smart_callback_call(Evas_Object *eo_obj, const char *event, void *event_info)
Call a given smart callback on the smart object obj.
Definition evas_object_smart.c:1151
evas_object_smart_callbacks_descriptions_get
EVAS_API void evas_object_smart_callbacks_descriptions_get(const Eo *eo_obj, const Evas_Smart_Cb_Description ***class_descriptions, unsigned int *class_count, const Evas_Smart_Cb_Description ***instance_descriptions, unsigned int *instance_count)
Retrieve an smart object's know smart callback descriptions (both instance and class ones).
Definition evas_object_smart.c:1217
evas_object_smart_member_del
EVAS_API void evas_object_smart_member_del(Evas_Object *eo_obj)
Removes a member object from a given smart object.
Definition evas_object_smart.c:344
evas_object_smart_member_add
EVAS_API void evas_object_smart_member_add(Evas_Object *eo_obj, Evas_Object *smart_obj)
Set an Evas object as a member of a given smart object.
Definition evas_object_smart.c:210
evas_object_smart_callback_add
EVAS_API void evas_object_smart_callback_add(Evas_Object *eo_obj, const char *event, Evas_Smart_Cb func, const void *data)
Add (register) a callback function to the smart event specified by event on the smart object obj.
Definition evas_object_smart.c:1040
_Evas_Event_Key_Down
Key press event.
Definition Evas_Legacy.h:314
_Evas_Event_Key_Down::key
const char * key
The logical key : (eg shift+1 == exclamation)
Definition Evas_Legacy.h:320
_Evas_Object_Smart_Clipped_Data
Definition Evas_Common.h:2580
_Evas_Smart_Cb_Description
Describes a callback issued by a smart object (evas_object_smart_callback_call()),...
Definition Evas_Common.h:2008
_Evas_Smart_Class
A smart object's base class definition.
Definition Evas_Common.h:1948
_Evas_Smart_Class::add
void(* add)(Evas_Object *o)
code to be run when adding object to a canvas
Definition Evas_Common.h:1951
_Evas_Smart_Class::show
void(* show)(Evas_Object *o)
code to be run when showing object on a canvas
Definition Evas_Common.h:1955
_Evas_Smart_Class::del
void(* del)(Evas_Object *o)
code to be run when removing object from a canvas
Definition Evas_Common.h:1952
_Evas_Smart_Class::calculate
void(* calculate)(Evas_Object *o)
code to be run when object has rendering updates on a canvas
Definition Evas_Common.h:1960
_Evas_Smart_Class::hide
void(* hide)(Evas_Object *o)
code to be run when hiding object on a canvas
Definition Evas_Common.h:1956
_Evas_Smart_Class::resize
void(* resize)(Evas_Object *o, Evas_Coord w, Evas_Coord h)
code to be run when resizing object on a canvas.
Definition Evas_Common.h:1954