2002-11-08 00:02:15 -08:00
|
|
|
#include "evas_common.h"
|
|
|
|
#include "evas_private.h"
|
|
|
|
|
|
|
|
/* all public */
|
2003-03-04 18:30:20 -08:00
|
|
|
|
|
|
|
/**
|
2006-12-07 23:51:48 -08:00
|
|
|
* @defgroup Evas_Smart_Group Evas Smart Functions
|
2003-03-04 18:30:20 -08:00
|
|
|
*
|
2006-12-07 23:51:48 -08:00
|
|
|
* Functions that deal with Evas_Smart's.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-11-01 14:50:36 -07:00
|
|
|
/**
|
|
|
|
* @addtogroup Evas_Smart_Group
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2006-12-07 23:51:48 -08:00
|
|
|
/**
|
|
|
|
* Create an Evas_Smart, which can be used to instantiate new smart objects.
|
|
|
|
*
|
|
|
|
* This function internally creates an Evas_Smart_Class and sets the
|
|
|
|
* provided callbacks. Callbacks that are unneeded (or marked DEPRECATED
|
|
|
|
* below) should be set to NULL.
|
|
|
|
*
|
2009-09-03 22:13:19 -07:00
|
|
|
* Alternatively you can create an Evas_Smart_Class yourself and use
|
2006-12-07 23:51:48 -08:00
|
|
|
* evas_smart_class_new().
|
|
|
|
*
|
|
|
|
* @param name a unique name for the smart
|
|
|
|
* @param func_add callback called when smart object is added
|
|
|
|
* @param func_del callback called when smart object is deleted
|
|
|
|
* @param func_layer_set DEPRECATED
|
|
|
|
* @param func_raise DEPRECATED
|
|
|
|
* @param func_lower DEPRECATED
|
|
|
|
* @param func_stack_above DEPRECATED
|
|
|
|
* @param func_stack_below DEPRECATED
|
2009-09-03 22:13:19 -07:00
|
|
|
* @param func_move callback called when smart object is moved
|
|
|
|
* @param func_resize callback called when smart object is resized
|
2006-12-07 23:51:48 -08:00
|
|
|
* @param func_show callback called when smart object is shown
|
|
|
|
* @param func_hide callback called when smart object is hidden
|
|
|
|
* @param func_color_set callback called when smart object has its color set
|
|
|
|
* @param func_clip_set callback called when smart object has its clip set
|
|
|
|
* @param func_clip_unset callback called when smart object has its clip unset
|
|
|
|
* @param data a pointer to user data for the smart
|
|
|
|
* @return an Evas_Smart
|
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 Evas_Smart *
|
2003-01-09 20:58:51 -08:00
|
|
|
evas_smart_new(const char *name,
|
|
|
|
void (*func_add) (Evas_Object *o),
|
|
|
|
void (*func_del) (Evas_Object *o),
|
2009-02-25 15:39:19 -08:00
|
|
|
void (*func_layer_set) (Evas_Object *o, int l) __UNUSED__,
|
|
|
|
void (*func_raise) (Evas_Object *o) __UNUSED__,
|
|
|
|
void (*func_lower) (Evas_Object *o) __UNUSED__,
|
|
|
|
void (*func_stack_above) (Evas_Object *o, Evas_Object *above) __UNUSED__,
|
|
|
|
void (*func_stack_below) (Evas_Object *o, Evas_Object *below) __UNUSED__,
|
2003-10-17 20:34:00 -07:00
|
|
|
void (*func_move) (Evas_Object *o, Evas_Coord x, Evas_Coord y),
|
|
|
|
void (*func_resize) (Evas_Object *o, Evas_Coord w, Evas_Coord h),
|
2003-01-09 20:58:51 -08:00
|
|
|
void (*func_show) (Evas_Object *o),
|
|
|
|
void (*func_hide) (Evas_Object *o),
|
|
|
|
void (*func_color_set) (Evas_Object *o, int r, int g, int b, int a),
|
|
|
|
void (*func_clip_set) (Evas_Object *o, Evas_Object *clip),
|
|
|
|
void (*func_clip_unset) (Evas_Object *o),
|
|
|
|
const void *data)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
Evas_Smart *s;
|
2008-02-08 12:03:48 -08:00
|
|
|
Evas_Smart_Class *sc;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2009-09-21 09:08:51 -07:00
|
|
|
WARN("----- WARNING. evas_smart_new() will be deprecated and removed soon"
|
|
|
|
"----- Please use evas_smart_class_new() instead");
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
if (!name) return NULL;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2003-01-09 20:58:51 -08:00
|
|
|
s = evas_mem_calloc(sizeof(Evas_Smart));
|
2002-11-08 00:02:15 -08:00
|
|
|
if (!s) return NULL;
|
|
|
|
|
|
|
|
s->magic = MAGIC_SMART;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2003-10-08 20:05:17 -07:00
|
|
|
s->class_allocated = 1;
|
|
|
|
|
2008-02-08 12:03:48 -08:00
|
|
|
sc = evas_mem_calloc(sizeof(Evas_Smart_Class));
|
|
|
|
if (!sc)
|
2003-01-09 20:58:51 -08:00
|
|
|
{
|
|
|
|
free(s);
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-02-08 12:03:48 -08:00
|
|
|
sc->name = name;
|
|
|
|
sc->add = func_add;
|
|
|
|
sc->del = func_del;
|
|
|
|
sc->move = func_move;
|
|
|
|
sc->resize = func_resize;
|
|
|
|
sc->show = func_show;
|
|
|
|
sc->hide = func_hide;
|
|
|
|
sc->color_set = func_color_set;
|
|
|
|
sc->clip_set = func_clip_set;
|
|
|
|
sc->clip_unset = func_clip_unset;
|
|
|
|
sc->data = (void *)data;
|
|
|
|
s->smart_class = sc;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2003-03-04 18:30:20 -08:00
|
|
|
/**
|
2006-12-07 23:51:48 -08:00
|
|
|
* Free an Evas_Smart
|
|
|
|
*
|
|
|
|
* If this smart was created using evas_smart_class_new(), the associated
|
|
|
|
* Evas_Smart_Class will not be freed.
|
2003-03-04 18:30:20 -08:00
|
|
|
*
|
2006-12-07 23:51:48 -08:00
|
|
|
* @param s the Evas_Smart to free
|
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_smart_free(Evas_Smart *s)
|
2005-05-21 19:49:50 -07:00
|
|
|
{
|
2002-11-08 00:02:15 -08:00
|
|
|
MAGIC_CHECK(s, Evas_Smart, MAGIC_SMART);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
s->delete_me = 1;
|
|
|
|
if (s->usage > 0) return;
|
2008-02-08 12:03:48 -08:00
|
|
|
if (s->class_allocated) free((void *)s->smart_class);
|
2002-11-08 00:02:15 -08:00
|
|
|
free(s);
|
|
|
|
}
|
|
|
|
|
2003-10-08 20:05:17 -07:00
|
|
|
/**
|
2006-12-07 23:51:48 -08:00
|
|
|
* Creates an Evas_Smart from an Evas_Smart_Class.
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2009-09-17 15:38:10 -07:00
|
|
|
* @param sc the smart class definition
|
2006-12-07 23:51:48 -08:00
|
|
|
* @return an Evas_Smart
|
2003-10-08 20:05:17 -07:00
|
|
|
*/
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI Evas_Smart *
|
2007-08-04 06:12:43 -07:00
|
|
|
evas_smart_class_new(const Evas_Smart_Class *sc)
|
2003-10-08 20:05:17 -07:00
|
|
|
{
|
|
|
|
Evas_Smart *s;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2003-10-08 20:05:17 -07:00
|
|
|
if (!sc) return NULL;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2006-12-01 19:20:56 -08:00
|
|
|
/* api does not match abi! for now refuse as we only have 1 version */
|
|
|
|
if (sc->version != EVAS_SMART_CLASS_VERSION) return NULL;
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2003-10-08 20:05:17 -07:00
|
|
|
s = evas_mem_calloc(sizeof(Evas_Smart));
|
|
|
|
if (!s) return NULL;
|
|
|
|
|
|
|
|
s->magic = MAGIC_SMART;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2008-02-08 12:03:48 -08:00
|
|
|
s->smart_class = sc;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2003-10-08 20:05:17 -07:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2006-12-07 23:51:48 -08:00
|
|
|
* Get the Evas_Smart_Class of an Evas_Smart
|
2005-05-21 19:49:50 -07:00
|
|
|
*
|
2006-12-07 23:51:48 -08:00
|
|
|
* @param s the Evas_Smart
|
|
|
|
* @return the Evas_Smart_Class
|
2003-10-08 20:05:17 -07:00
|
|
|
*/
|
2007-08-04 06:12:43 -07:00
|
|
|
EAPI const Evas_Smart_Class *
|
2008-02-08 13:42:01 -08:00
|
|
|
evas_smart_class_get(const Evas_Smart *s)
|
2003-10-08 20:05:17 -07:00
|
|
|
{
|
|
|
|
MAGIC_CHECK(s, Evas_Smart, MAGIC_SMART);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
return s->smart_class;
|
|
|
|
}
|
|
|
|
|
2003-03-04 18:30:20 -08:00
|
|
|
/**
|
2009-09-17 15:38:10 -07:00
|
|
|
* @brief Get the data pointer set on an Evas_Smart.
|
|
|
|
*
|
|
|
|
* @param s Evas_Smart
|
2006-12-07 23:51:48 -08:00
|
|
|
*
|
2009-09-03 22:13:19 -07:00
|
|
|
* This data pointer is set either as the final parameter to
|
2006-12-07 23:51:48 -08:00
|
|
|
* evas_smart_new or as the data field in the Evas_Smart_Class passed
|
|
|
|
* in to evas_smart_class_new
|
2003-03-04 18:30:20 -08:00
|
|
|
*/
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI void *
|
2008-02-08 13:42:01 -08:00
|
|
|
evas_smart_data_get(const Evas_Smart *s)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
MAGIC_CHECK(s, Evas_Smart, MAGIC_SMART);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
2003-10-17 20:34:00 -07:00
|
|
|
return (void *)s->smart_class->data;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2008-11-01 14:50:36 -07:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
/* internal funcs */
|
|
|
|
void
|
|
|
|
evas_object_smart_use(Evas_Smart *s)
|
|
|
|
{
|
|
|
|
s->usage++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_object_smart_unuse(Evas_Smart *s)
|
|
|
|
{
|
|
|
|
s->usage--;
|
2004-02-01 17:33:46 -08:00
|
|
|
if ((s->usage <= 0) && (s->delete_me)) evas_smart_free(s);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|