2002-11-08 00:02:15 -08:00
|
|
|
#include "evas_common.h"
|
|
|
|
#include "evas_private.h"
|
|
|
|
|
|
|
|
typedef struct _Evas_Object_Smart Evas_Object_Smart;
|
|
|
|
typedef struct _Evas_Smart_Callback Evas_Smart_Callback;
|
|
|
|
|
|
|
|
struct _Evas_Object_Smart
|
|
|
|
{
|
|
|
|
DATA32 magic;
|
|
|
|
void *engine_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _Evas_Smart_Callback
|
|
|
|
{
|
2006-05-31 11:33:46 -07:00
|
|
|
const char *event;
|
2002-11-08 00:02:15 -08:00
|
|
|
void (*func) (void *data, Evas_Object *obj, void *event_info);
|
|
|
|
void *func_data;
|
2007-06-28 16:22:20 -07:00
|
|
|
char delete_me : 1;
|
2002-11-08 00:02:15 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* private methods for smart objects */
|
2003-01-19 20:36:17 -08:00
|
|
|
static void evas_object_smart_callbacks_clear(Evas_Object *obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
static void evas_object_smart_init(Evas_Object *obj);
|
|
|
|
static void *evas_object_smart_new(void);
|
|
|
|
static void evas_object_smart_render(Evas_Object *obj, void *output, void *context, void *surface, int x, int y);
|
|
|
|
static void evas_object_smart_free(Evas_Object *obj);
|
|
|
|
static void evas_object_smart_render_pre(Evas_Object *obj);
|
|
|
|
static void evas_object_smart_render_post(Evas_Object *obj);
|
|
|
|
|
2007-05-06 04:29:37 -07:00
|
|
|
static const Evas_Object_Func object_func =
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
/* methods (compulsory) */
|
|
|
|
evas_object_smart_free,
|
|
|
|
evas_object_smart_render,
|
|
|
|
evas_object_smart_render_pre,
|
|
|
|
evas_object_smart_render_post,
|
|
|
|
/* these are optional. NULL = nothing */
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
/* public funcs */
|
2003-03-04 18:30:20 -08:00
|
|
|
/**
|
2006-12-07 23:51:48 -08:00
|
|
|
* @defgroup Evas_Smart_Object_Group Evas Smart Object Functions
|
2003-03-04 18:30:20 -08:00
|
|
|
*
|
2006-12-07 23:51:48 -08:00
|
|
|
* Functions dealing with evas smart objects.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2006-12-07 23:51:48 -08:00
|
|
|
* Smart objects are groupings of primitive evas objects that behave as a
|
|
|
|
* cohesive group. For instance, a file manager icon may be a smart object
|
|
|
|
* composed of an image object, a text label and two rectangles that appear
|
|
|
|
* behind the image and text when the icon is selected. As a smart object,
|
|
|
|
* the normal evas api could be used on the icon object.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* Store a pointer to user data for a smart object.
|
|
|
|
*
|
|
|
|
* @param obj The smart object
|
|
|
|
* @param data A pointer to user data
|
|
|
|
* @ingroup Evas_Smart_Object_Group
|
2003-03-04 18:30:20 -08:00
|
|
|
*/
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_smart_data_set(Evas_Object *obj, void *data)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
obj->smart.data = data;
|
|
|
|
}
|
|
|
|
|
2003-03-04 18:30:20 -08:00
|
|
|
/**
|
2006-12-07 23:51:48 -08:00
|
|
|
* Retrieve user data stored on a smart object.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2006-12-07 23:51:48 -08:00
|
|
|
* @param obj The smart object
|
|
|
|
* @return A pointer to data stored using evas_object_smart_data_set(), or
|
|
|
|
* NULL if none has been set.
|
|
|
|
* @ingroup Evas_Smart_Object_Group
|
2003-03-04 18:30:20 -08:00
|
|
|
*/
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void *
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_smart_data_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
return obj->smart.data;
|
|
|
|
}
|
|
|
|
|
2003-03-04 18:30:20 -08:00
|
|
|
/**
|
2006-12-07 23:51:48 -08:00
|
|
|
* Get the Evas_Smart from which @p obj was created.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2006-12-07 23:51:48 -08:00
|
|
|
* @param obj a smart object
|
|
|
|
* @return the Evas_Smart
|
|
|
|
* @ingroup Evas_Smart_Object_Group
|
2003-03-04 18:30:20 -08:00
|
|
|
*/
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI Evas_Smart *
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_smart_smart_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
return obj->smart.smart;
|
|
|
|
}
|
|
|
|
|
2003-03-04 18:30:20 -08:00
|
|
|
/**
|
2006-12-07 23:51:48 -08:00
|
|
|
* Set an evas object as a member of a smart object.
|
2003-03-04 18:30:20 -08:00
|
|
|
*
|
2006-12-07 23:51:48 -08:00
|
|
|
* @param obj The member object
|
|
|
|
* @param smart_obj The smart object
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2006-12-07 23:51:48 -08:00
|
|
|
* Members will automatically be stacked and layered with the smart object.
|
|
|
|
* The various stacking function will operate on members relative to the
|
|
|
|
* other members instead of the entire canvas.
|
|
|
|
*
|
|
|
|
* Non-member objects can not interleave a smart object's members.
|
|
|
|
*
|
|
|
|
* @ingroup Evas_Smart_Object_Group
|
2003-03-04 18:30:20 -08:00
|
|
|
*/
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_smart_member_add(Evas_Object *obj, Evas_Object *smart_obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
MAGIC_CHECK(smart_obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Smart *)(smart_obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2006-07-30 07:30:24 -07:00
|
|
|
if (obj->delete_me)
|
|
|
|
{
|
|
|
|
printf("EVAS ERROR: Adding deleted object %p to smart obj %p\n", obj, smart_obj);
|
|
|
|
abort();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (smart_obj->delete_me)
|
|
|
|
{
|
|
|
|
printf("EVAS ERROR: Adding object %p to deleted smart obj %p\n", obj, smart_obj);
|
|
|
|
abort();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (obj->smart.parent == smart_obj) return;
|
2005-10-26 19:44:36 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
if (obj->smart.parent) evas_object_smart_member_del(obj);
|
2005-10-26 19:44:36 -07:00
|
|
|
|
|
|
|
evas_object_release(obj, 1);
|
|
|
|
obj->layer = smart_obj->layer;
|
|
|
|
obj->cur.layer = obj->layer->layer;
|
2005-11-08 03:59:21 -08:00
|
|
|
obj->layer->usage++;
|
2002-11-08 00:02:15 -08:00
|
|
|
obj->smart.parent = smart_obj;
|
2005-10-26 19:44:36 -07:00
|
|
|
smart_obj->smart.contained = evas_object_list_append(smart_obj->smart.contained, obj);
|
2005-07-22 03:28:11 -07:00
|
|
|
evas_object_smart_member_cache_invalidate(obj);
|
2005-10-26 19:44:36 -07:00
|
|
|
obj->restack = 1;
|
|
|
|
evas_object_change(obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2003-03-04 18:30:20 -08:00
|
|
|
/**
|
2006-12-07 23:51:48 -08:00
|
|
|
* Removes a member object from a smart object.
|
|
|
|
*
|
|
|
|
* @param obj the member object
|
|
|
|
* @ingroup Evas_Smart_Object_Group
|
2003-03-04 18:30:20 -08:00
|
|
|
*
|
2006-12-07 23:51:48 -08:00
|
|
|
* This removes a member object from a smart object. The object will still
|
|
|
|
* be on the canvas, but no longer associated with whichever smart object
|
|
|
|
* it was associated with.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2003-03-04 18:30:20 -08:00
|
|
|
*/
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_smart_member_del(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
if (!obj->smart.parent) return;
|
2005-10-26 19:44:36 -07:00
|
|
|
obj->smart.parent->smart.contained = evas_object_list_remove(obj->smart.parent->smart.contained, obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
obj->smart.parent = NULL;
|
2005-07-22 03:28:11 -07:00
|
|
|
evas_object_smart_member_cache_invalidate(obj);
|
2005-11-08 03:59:21 -08:00
|
|
|
obj->layer->usage--;
|
2005-10-26 19:44:36 -07:00
|
|
|
obj->cur.layer = obj->layer->layer;
|
|
|
|
evas_object_inject(obj, obj->layer->evas);
|
|
|
|
obj->restack = 1;
|
|
|
|
evas_object_change(obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2006-08-02 19:14:53 -07:00
|
|
|
/**
|
|
|
|
* Gets the smart parent of an Evas_Object
|
|
|
|
* @param obj the Evas_Object you want to get the parent
|
|
|
|
* @return Returns the smart parent of @a obj, or NULL if @a obj is not a smart member of another Evas_Object
|
2006-12-07 23:51:48 -08:00
|
|
|
* @ingroup Evas_Smart_Object_Group
|
2006-08-02 19:14:53 -07:00
|
|
|
*/
|
|
|
|
EAPI Evas_Object *
|
|
|
|
evas_object_smart_parent_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
return obj->smart.parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the list of the member objects of an Evas_Object
|
|
|
|
* @param obj the Evas_Object you want to get the list of member objects
|
|
|
|
* @return Returns the list of the member objects of @a obj.
|
|
|
|
* The returned list should be freed with evas_list_free() when you no longer need it
|
|
|
|
*/
|
|
|
|
EAPI Evas_List *
|
|
|
|
evas_object_smart_members_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_List *members;
|
|
|
|
Evas_Object_List *member;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
members = NULL;
|
|
|
|
for (member = obj->smart.contained; member; member = member->next)
|
|
|
|
members = evas_list_append(members, member);
|
|
|
|
|
|
|
|
return members;
|
|
|
|
}
|
|
|
|
|
2003-03-04 18:30:20 -08:00
|
|
|
/**
|
2006-12-07 23:51:48 -08:00
|
|
|
* Instantiates a new smart object described by @p s.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2006-12-07 23:51:48 -08:00
|
|
|
* @param e the evas on which to add the object
|
|
|
|
* @param s the Evas_Smart describing the smart object
|
|
|
|
* @return a new Evas_Object
|
|
|
|
* @ingroup Evas_Smart_Object_Group
|
2003-03-04 18:30:20 -08:00
|
|
|
*/
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI Evas_Object *
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_smart_add(Evas *e, Evas_Smart *s)
|
|
|
|
{
|
|
|
|
Evas_Object *obj;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
MAGIC_CHECK(s, Evas_Smart, MAGIC_SMART);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
|
|
|
obj = evas_object_new();
|
|
|
|
if (!obj) return NULL;
|
|
|
|
obj->smart.smart = s;
|
2003-10-08 20:05:17 -07:00
|
|
|
obj->type = s->smart_class->name;
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_smart_init(obj);
|
|
|
|
evas_object_inject(obj, e);
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_smart_use(s);
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2003-10-08 20:05:17 -07:00
|
|
|
if (s->smart_class->add) s->smart_class->add(obj);
|
2005-05-21 19:49:50 -07:00
|
|
|
|
|
|
|
return obj;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2003-03-04 18:30:20 -08:00
|
|
|
/**
|
2006-12-07 23:51:48 -08:00
|
|
|
* Add a callback for the smart event specified by @p event.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2006-12-07 23:51:48 -08:00
|
|
|
* @param obj a smart object
|
|
|
|
* @param event the event name
|
|
|
|
* @param func the callback function
|
|
|
|
* @param data user data to be passed to the callback function
|
|
|
|
* @ingroup Evas_Smart_Object_Group
|
2003-03-04 18:30:20 -08:00
|
|
|
*/
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void
|
2003-01-09 20:58:51 -08:00
|
|
|
evas_object_smart_callback_add(Evas_Object *obj, const char *event, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
|
|
|
Evas_Smart_Callback *cb;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
if (!event) return;
|
|
|
|
if (!func) return;
|
|
|
|
cb = calloc(1, sizeof(Evas_Smart_Callback));
|
2005-11-30 00:45:20 -08:00
|
|
|
cb->event = evas_stringshare_add(event);
|
2002-11-08 00:02:15 -08:00
|
|
|
cb->func = func;
|
2003-01-09 20:58:51 -08:00
|
|
|
cb->func_data = (void *)data;
|
2002-11-08 00:02:15 -08:00
|
|
|
obj->smart.callbacks = evas_list_prepend(obj->smart.callbacks, cb);
|
|
|
|
}
|
|
|
|
|
2003-03-04 18:30:20 -08:00
|
|
|
/**
|
2006-12-07 23:51:48 -08:00
|
|
|
* Remove a smart callback
|
2003-03-04 18:30:20 -08:00
|
|
|
*
|
2006-12-07 23:51:48 -08:00
|
|
|
* Removes a callback that was added by evas_object_smart_callback_add()
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2006-12-07 23:51:48 -08:00
|
|
|
* @param obj a smart object
|
|
|
|
* @param event the event name
|
|
|
|
* @param func the callback function
|
|
|
|
* @return the data pointer
|
|
|
|
* @ingroup Evas_Smart_Object_Group
|
2003-03-04 18:30:20 -08:00
|
|
|
*/
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void *
|
2003-01-09 20:58:51 -08:00
|
|
|
evas_object_smart_callback_del(Evas_Object *obj, const char *event, void (*func) (void *data, Evas_Object *obj, void *event_info))
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
|
|
|
Evas_List *l;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
2003-10-17 20:34:00 -07:00
|
|
|
return NULL;
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
2003-10-17 20:34:00 -07:00
|
|
|
return NULL;
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK_END();
|
2003-10-17 20:34:00 -07:00
|
|
|
if (!event) return NULL;
|
2002-11-08 00:02:15 -08:00
|
|
|
for (l = obj->smart.callbacks; l; l = l->next)
|
|
|
|
{
|
|
|
|
Evas_Smart_Callback *cb;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
cb = l->data;
|
|
|
|
if ((!strcmp(cb->event, event)) && (cb->func == func))
|
|
|
|
{
|
|
|
|
void *data;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
data = cb->func_data;
|
2003-01-19 20:36:17 -08:00
|
|
|
cb->delete_me = 1;
|
|
|
|
obj->smart.deletions_waiting = 1;
|
|
|
|
evas_object_smart_callbacks_clear(obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-03-04 18:30:20 -08:00
|
|
|
/**
|
2006-12-07 23:51:48 -08:00
|
|
|
* Call any smart callbacks on @p obj for @p event.
|
|
|
|
*
|
|
|
|
* @param obj the smart object
|
|
|
|
* @param event the event name
|
|
|
|
* @param event_info an event specific struct of info to pass to the callback
|
2003-03-04 18:30:20 -08:00
|
|
|
*
|
2006-12-07 23:51:48 -08:00
|
|
|
* This should be called internally in the smart object when some specific
|
|
|
|
* event has occured. The documentation for the smart object should include
|
|
|
|
* a list of possible events and what type of @p event_info to expect.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2006-12-07 23:51:48 -08:00
|
|
|
* @ingroup Evas_Smart_Object_Group
|
2003-03-04 18:30:20 -08:00
|
|
|
*/
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void
|
2003-01-09 20:58:51 -08:00
|
|
|
evas_object_smart_callback_call(Evas_Object *obj, const char *event, void *event_info)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
|
|
|
Evas_List *l;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
if (!event) return;
|
2003-01-19 20:36:17 -08:00
|
|
|
if (obj->delete_me) return;
|
|
|
|
obj->smart.walking_list++;
|
2002-11-08 00:02:15 -08:00
|
|
|
for (l = obj->smart.callbacks; l; l = l->next)
|
|
|
|
{
|
|
|
|
Evas_Smart_Callback *cb;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
cb = l->data;
|
2003-01-19 20:36:17 -08:00
|
|
|
if (!cb->delete_me)
|
|
|
|
{
|
|
|
|
if (!strcmp(cb->event, event))
|
|
|
|
cb->func(cb->func_data, obj, event_info);
|
|
|
|
}
|
|
|
|
if (obj->delete_me)
|
|
|
|
break;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2003-01-19 20:36:17 -08:00
|
|
|
obj->smart.walking_list--;
|
|
|
|
evas_object_smart_callbacks_clear(obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* internal calls */
|
2003-01-19 20:36:17 -08:00
|
|
|
static void
|
|
|
|
evas_object_smart_callbacks_clear(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2003-01-19 20:36:17 -08:00
|
|
|
if (obj->smart.walking_list) return;
|
|
|
|
if (!obj->smart.deletions_waiting) return;
|
|
|
|
for (l = obj->smart.callbacks; l;)
|
|
|
|
{
|
|
|
|
Evas_Smart_Callback *cb;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2003-01-19 20:36:17 -08:00
|
|
|
cb = l->data;
|
|
|
|
l = l->next;
|
|
|
|
if (cb->delete_me)
|
|
|
|
{
|
|
|
|
obj->smart.callbacks = evas_list_remove(obj->smart.callbacks, cb);
|
2005-11-30 00:45:20 -08:00
|
|
|
if (cb->event) evas_stringshare_del(cb->event);
|
2003-01-19 20:36:17 -08:00
|
|
|
free(cb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
void
|
|
|
|
evas_object_smart_del(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Smart *s;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
s = obj->smart.smart;
|
2006-10-15 05:15:36 -07:00
|
|
|
if (obj->delete_me) return;
|
2003-10-08 20:05:17 -07:00
|
|
|
if ((s) && (s->smart_class->del)) s->smart_class->del(obj);
|
2003-01-09 21:38:47 -08:00
|
|
|
if (obj->smart.parent) evas_object_smart_member_del(obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
if (s) evas_object_smart_unuse(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_object_smart_cleanup(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Smart *s;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
s = obj->smart.smart;
|
2005-04-26 19:35:48 -07:00
|
|
|
if (obj->smart.parent)
|
|
|
|
evas_object_smart_member_del(obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
while (obj->smart.contained)
|
2005-10-26 19:44:36 -07:00
|
|
|
evas_object_smart_member_del((Evas_Object *)obj->smart.contained);
|
2002-11-08 00:02:15 -08:00
|
|
|
while (obj->smart.callbacks)
|
|
|
|
{
|
|
|
|
Evas_Smart_Callback *cb;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
cb = obj->smart.callbacks->data;
|
|
|
|
obj->smart.callbacks = evas_list_remove(obj->smart.callbacks, cb);
|
2005-11-30 00:45:20 -08:00
|
|
|
if (cb->event) evas_stringshare_del(cb->event);
|
2002-11-08 00:02:15 -08:00
|
|
|
free(cb);
|
|
|
|
}
|
2003-10-17 20:34:00 -07:00
|
|
|
obj->smart.parent = NULL;
|
2003-01-19 19:54:00 -08:00
|
|
|
obj->smart.data = NULL;
|
|
|
|
obj->smart.smart = NULL;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2005-07-22 03:28:11 -07:00
|
|
|
void
|
|
|
|
evas_object_smart_member_cache_invalidate(Evas_Object *obj)
|
|
|
|
{
|
2005-10-26 19:44:36 -07:00
|
|
|
Evas_Object_List *l;
|
2005-07-22 03:28:11 -07:00
|
|
|
|
|
|
|
obj->parent_cache_valid = 0;
|
|
|
|
for (l = obj->smart.contained; l; l = l->next)
|
|
|
|
{
|
|
|
|
Evas_Object *obj2;
|
|
|
|
|
2005-10-26 19:44:36 -07:00
|
|
|
obj2 = (Evas_Object *)l;
|
2005-07-22 03:28:11 -07:00
|
|
|
evas_object_smart_member_cache_invalidate(obj2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
/* all nice and private */
|
|
|
|
static void
|
|
|
|
evas_object_smart_init(Evas_Object *obj)
|
|
|
|
{
|
2006-12-07 23:51:48 -08:00
|
|
|
/* alloc smart obj, setup methods and default values */
|
2002-11-08 00:02:15 -08:00
|
|
|
obj->object_data = evas_object_smart_new();
|
|
|
|
/* set up default settings for this kind of object */
|
|
|
|
obj->cur.color.r = 255;
|
|
|
|
obj->cur.color.g = 255;
|
|
|
|
obj->cur.color.b = 255;
|
|
|
|
obj->cur.color.a = 255;
|
2007-10-04 21:52:10 -07:00
|
|
|
obj->cur.geometry.x = 0;
|
|
|
|
obj->cur.geometry.y = 0;
|
|
|
|
obj->cur.geometry.w = 0;
|
|
|
|
obj->cur.geometry.h = 0;
|
2002-11-08 00:02:15 -08:00
|
|
|
obj->cur.layer = 0;
|
|
|
|
/* set up object-specific settings */
|
|
|
|
obj->prev = obj->cur;
|
|
|
|
/* set up methods (compulsory) */
|
|
|
|
obj->func = &object_func;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
evas_object_smart_new(void)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
/* alloc obj private data */
|
|
|
|
o = calloc(1, sizeof(Evas_Object_Smart));
|
|
|
|
o->magic = MAGIC_OBJ_SMART;
|
|
|
|
return o;
|
|
|
|
}
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
static void
|
|
|
|
evas_object_smart_free(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Smart *o;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
/* frees private object data. very simple here */
|
|
|
|
o = (Evas_Object_Smart *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
/* free obj */
|
|
|
|
o->magic = 0;
|
|
|
|
free(o);
|
|
|
|
}
|
|
|
|
|
2005-05-21 19:49:50 -07:00
|
|
|
static void
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_smart_render(Evas_Object *obj, void *output, void *context, void *surface, int x, int y)
|
|
|
|
{
|
2003-10-17 20:34:00 -07:00
|
|
|
return;
|
|
|
|
obj = output = context = surface = NULL;
|
|
|
|
x = y = 0;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_smart_render_pre(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
if (obj->pre_render_done) return;
|
|
|
|
obj->pre_render_done = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_smart_render_post(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
obj->prev = obj->cur;
|
|
|
|
}
|