forked from enlightenment/efl
you can address objects by name now all image objects by default get a name
set as the basename of the file (ie "/tmp/blah/foo.png has the name of "foo"). you can override the name if u want... or just not use it. should really use hash table - patch for this from rusty russel :) i need to wokr on this stuff before 1.0 SVN revision: 5652
This commit is contained in:
parent
a37b87adf3
commit
fc982b9fa0
|
@ -164,6 +164,8 @@ struct _Evas_Callback
|
|||
|
||||
struct _Evas_Object_Any
|
||||
{
|
||||
unsigned char marker;
|
||||
unsigned char changed;
|
||||
unsigned short type;
|
||||
struct {
|
||||
double x, y, w, h;
|
||||
|
@ -175,8 +177,6 @@ struct _Evas_Object_Any
|
|||
__attribute__ ((packed)) current,
|
||||
__attribute__ ((packed)) previous;
|
||||
|
||||
unsigned char changed;
|
||||
|
||||
unsigned char delete_me;
|
||||
|
||||
unsigned char pass_events;
|
||||
|
@ -316,6 +316,11 @@ _evas_get_previous_clipped_geometry(Evas e, Evas_Object o, double *x, double *y,
|
|||
o->previous.x, o->previous.y, o->previous.w, o->previous.h);
|
||||
}
|
||||
|
||||
/* If it seems to be a string, try destringing it */
|
||||
#define TO_OBJECT(e, obj) \
|
||||
((obj) && ((char *)(obj))[0] \
|
||||
? evas_object_get_named((e), (char *)(obj)) \
|
||||
: (obj))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ evas_callback_add(Evas e, Evas_Object o, Evas_Callback_Type callback, void (*fun
|
|||
Evas_Callback cb;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
cb = malloc(sizeof(struct _Evas_Callback));
|
||||
cb->type = callback;
|
||||
|
@ -52,6 +53,7 @@ evas_callback_del(Evas e, Evas_Object o, Evas_Callback_Type callback)
|
|||
int have_cb;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
have_cb = 1;
|
||||
while (have_cb)
|
||||
|
|
|
@ -111,6 +111,7 @@ evas_set_gradient(Evas e, Evas_Object o, Evas_Gradient grad)
|
|||
Evas_Object_Gradient_Box oo;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
if (!grad) return;
|
||||
IF_OBJ(o, OBJECT_GRADIENT_BOX) return;
|
||||
|
@ -271,6 +272,7 @@ void
|
|||
evas_set_angle(Evas e, Evas_Object o, double angle)
|
||||
{
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
switch (o->type)
|
||||
{
|
||||
|
|
|
@ -67,8 +67,23 @@ evas_add_image_from_file(Evas e, char *file)
|
|||
|
||||
if (file)
|
||||
{
|
||||
char *tmp_name, *name, *dot;
|
||||
|
||||
oo->current.file = malloc(strlen(file) + 1);
|
||||
strcpy(oo->current.file, file);
|
||||
|
||||
name = strrchr(oo->current.file, '/');
|
||||
if (!name) name = oo->current.file;
|
||||
else name++;
|
||||
|
||||
tmp_name = malloc(strlen(name) + 1);
|
||||
strcpy(tmp_name, name);
|
||||
dot = strchr(tmp_name, '.');
|
||||
if (dot) *dot = '\0';
|
||||
evas_object_set_name(e, o, tmp_name);
|
||||
if (dot) *dot = '.';
|
||||
free(tmp_name);
|
||||
|
||||
{
|
||||
Imlib_Image im;
|
||||
|
||||
|
@ -143,6 +158,7 @@ evas_set_image_file(Evas e, Evas_Object o, char *file)
|
|||
Evas_Object_Image oo;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
IF_OBJ(o, OBJECT_IMAGE) return;
|
||||
oo = o;
|
||||
|
@ -152,12 +168,27 @@ evas_set_image_file(Evas e, Evas_Object o, char *file)
|
|||
(oo->current.image.h == 0)
|
||||
)
|
||||
{
|
||||
char *tmp_name, *name, *dot;
|
||||
|
||||
_evas_free_image_renderer_data(e, o);
|
||||
if (oo->current.file)
|
||||
free(oo->current.file);
|
||||
oo->previous.file = NULL;
|
||||
oo->current.file = malloc(strlen(file) + 1);
|
||||
strcpy(oo->current.file, file);
|
||||
|
||||
name = strrchr(oo->current.file, '/');
|
||||
if (!name) name = oo->current.file;
|
||||
else name++;
|
||||
|
||||
tmp_name = malloc(strlen(name) + 1);
|
||||
strcpy(tmp_name, name);
|
||||
dot = strchr(tmp_name, '.');
|
||||
if (dot) *dot = '\0';
|
||||
evas_object_set_name(e, o, tmp_name);
|
||||
if (dot) *dot = '.';
|
||||
free(tmp_name);
|
||||
|
||||
{
|
||||
Imlib_Image im;
|
||||
|
||||
|
@ -231,6 +262,7 @@ evas_set_image_fill(Evas e, Evas_Object o, double x, double y, double w, double
|
|||
Evas_Object_Image oo;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
IF_OBJ(o, OBJECT_IMAGE) return;
|
||||
oo = o;
|
||||
|
@ -261,6 +293,7 @@ evas_get_image_size(Evas e, Evas_Object o, int *w, int *h)
|
|||
Evas_Object_Image oo;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
IF_OBJ(o, OBJECT_IMAGE) return;
|
||||
oo = o;
|
||||
|
@ -274,6 +307,8 @@ evas_set_image_border(Evas e, Evas_Object o, int l, int r, int t, int b)
|
|||
Evas_Object_Image oo;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
IF_OBJ(o, OBJECT_IMAGE) return;
|
||||
oo = o;
|
||||
|
@ -295,6 +330,8 @@ evas_get_image_border(Evas e, Evas_Object o, int *l, int *r, int *t, int *b)
|
|||
Evas_Object_Image oo;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
IF_OBJ(o, OBJECT_IMAGE) return;
|
||||
oo = o;
|
||||
|
|
|
@ -96,6 +96,7 @@ evas_set_line_xy(Evas e, Evas_Object o, double x1, double y1, double x2, double
|
|||
int event_update = 0;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
IF_OBJ(o, OBJECT_LINE) return;
|
||||
oo = (Evas_Object_Line)o;
|
||||
|
|
|
@ -168,6 +168,7 @@ void
|
|||
evas_set_color(Evas e, Evas_Object o, int r, int g, int b, int a)
|
||||
{
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
if (r < 0) r = 0;
|
||||
else if (r > 255) r = 255;
|
||||
|
@ -253,6 +254,7 @@ void
|
|||
evas_get_color(Evas e, Evas_Object o, int *r, int *g, int *b, int *a)
|
||||
{
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
switch (o->type)
|
||||
{
|
||||
|
@ -309,6 +311,7 @@ void
|
|||
evas_set_zoom_scale(Evas e, Evas_Object o, int scale)
|
||||
{
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
o->current.zoomscale = scale;
|
||||
o->changed = 1;
|
||||
|
@ -319,6 +322,7 @@ void
|
|||
evas_set_pass_events(Evas e, Evas_Object o, int pass_events)
|
||||
{
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
o->pass_events = 1;
|
||||
}
|
||||
|
@ -551,6 +555,7 @@ evas_put_data(Evas e, Evas_Object o, char *key, void *data)
|
|||
Evas_List l;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
if (!key) return;
|
||||
for (l = o->data; l; l = l->next)
|
||||
|
@ -577,6 +582,7 @@ evas_get_data(Evas e, Evas_Object o, char *key)
|
|||
Evas_List l;
|
||||
|
||||
if (!e) return NULL;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return NULL;
|
||||
if (!key) return NULL;
|
||||
for (l = o->data; l; l = l->next)
|
||||
|
@ -595,6 +601,7 @@ evas_remove_data(Evas e, Evas_Object o, char *key)
|
|||
Evas_List l;
|
||||
|
||||
if (!e) return NULL;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return NULL;
|
||||
if (!key) return NULL;
|
||||
for (l = o->data; l; l = l->next)
|
||||
|
|
|
@ -160,6 +160,7 @@ void
|
|||
evas_set_clip(Evas e, Evas_Object o, Evas_Object clip)
|
||||
{
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
if (!clip) return;
|
||||
|
||||
|
@ -177,6 +178,7 @@ void
|
|||
evas_unset_clip(Evas e, Evas_Object o)
|
||||
{
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
|
||||
if (o->clip.object)
|
||||
|
@ -193,6 +195,7 @@ Evas_Object
|
|||
evas_get_clip_object(Evas e, Evas_Object o)
|
||||
{
|
||||
if (!e) return NULL;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return NULL;
|
||||
|
||||
return o->clip.object;
|
||||
|
@ -202,6 +205,7 @@ Evas_List
|
|||
evas_get_clip_list(Evas e, Evas_Object o)
|
||||
{
|
||||
if (!e) return NULL;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return NULL;
|
||||
|
||||
return o->clip.list;
|
||||
|
@ -212,6 +216,7 @@ void
|
|||
evas_del_object(Evas e, Evas_Object o)
|
||||
{
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
_evas_cleanup_clip(e, o);
|
||||
e->changed = 1;
|
||||
|
@ -228,6 +233,7 @@ evas_set_layer(Evas e, Evas_Object o, int layer_num)
|
|||
int removed;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
if (layer_num == o->current.layer) return;
|
||||
removed = 0;
|
||||
|
@ -295,6 +301,7 @@ evas_get_layer(Evas e, Evas_Object o)
|
|||
int removed;
|
||||
|
||||
if (!e) return 0;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return 0;
|
||||
return o->current.layer;
|
||||
}
|
||||
|
@ -446,6 +453,7 @@ evas_raise(Evas e, Evas_Object o)
|
|||
Evas_Layer layer;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
layer = _evas_get_object_layer(e, o);
|
||||
if (layer)
|
||||
|
@ -488,6 +496,7 @@ evas_stack_above(Evas e, Evas_Object o, Evas_Object above)
|
|||
Evas_Layer layer;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
layer = _evas_get_object_layer(e, o);
|
||||
if (layer)
|
||||
|
@ -509,6 +518,8 @@ evas_stack_below(Evas e, Evas_Object o, Evas_Object below)
|
|||
Evas_Layer layer;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
layer = _evas_get_object_layer(e, o);
|
||||
if (layer)
|
||||
|
@ -531,6 +542,7 @@ evas_move(Evas e, Evas_Object o, double x, double y)
|
|||
int event_update = 0;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
if ((o->type == OBJECT_LINE)) return;
|
||||
if ((x == o->current.x) && (y == o->current.y)) return;
|
||||
|
@ -575,6 +587,7 @@ evas_resize(Evas e, Evas_Object o, double w, double h)
|
|||
int event_update = 0;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
if ((o->type == OBJECT_LINE)) return;
|
||||
if ((o->type == OBJECT_TEXT)) return;
|
||||
|
@ -599,6 +612,7 @@ void
|
|||
evas_get_geometry(Evas e, Evas_Object o, double *x, double *y, double *w, double *h)
|
||||
{
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
if (x) *x = o->current.x;
|
||||
if (y) *y = o->current.y;
|
||||
|
@ -612,6 +626,7 @@ void
|
|||
evas_show(Evas e, Evas_Object o)
|
||||
{
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
o->current.visible = 1;
|
||||
o->changed = 1;
|
||||
|
@ -624,6 +639,7 @@ void
|
|||
evas_hide(Evas e, Evas_Object o)
|
||||
{
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
o->current.visible = 0;
|
||||
o->changed = 1;
|
||||
|
@ -663,6 +679,7 @@ void
|
|||
evas_object_set_name(Evas e, Evas_Object o, char *name)
|
||||
{
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
if (o->name) free(o->name);
|
||||
o->name = NULL;
|
||||
|
@ -677,6 +694,7 @@ char *
|
|||
evas_object_get_name(Evas e, Evas_Object o)
|
||||
{
|
||||
if (!e) return NULL;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return NULL;
|
||||
return o->name;
|
||||
}
|
||||
|
|
|
@ -135,6 +135,7 @@ evas_add_point(Evas e, Evas_Object o, double x, double y)
|
|||
Evas_Point p;
|
||||
Evas_Object_Poly oo;
|
||||
|
||||
o = TO_OBJECT(e, o);
|
||||
IF_OBJ(o, OBJECT_POLYGON) return;
|
||||
oo = o;
|
||||
p = malloc(sizeof(struct _Evas_Point));
|
||||
|
|
|
@ -202,6 +202,7 @@ evas_get_text_string(Evas e, Evas_Object o)
|
|||
Evas_Object_Text oo;
|
||||
|
||||
if (!e) return NULL;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return NULL;
|
||||
IF_OBJ(o, OBJECT_TEXT) return "";
|
||||
oo = o;
|
||||
|
@ -214,6 +215,7 @@ evas_get_text_font(Evas e, Evas_Object o)
|
|||
Evas_Object_Text oo;
|
||||
|
||||
if (!e) return NULL;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return NULL;
|
||||
IF_OBJ(o, OBJECT_TEXT) return "";
|
||||
oo = o;
|
||||
|
@ -226,6 +228,7 @@ evas_get_text_size(Evas e, Evas_Object o)
|
|||
Evas_Object_Text oo;
|
||||
|
||||
if (!e) return 0;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return 0;
|
||||
IF_OBJ(o, OBJECT_TEXT) return 0;
|
||||
oo = o;
|
||||
|
@ -238,6 +241,8 @@ evas_get_text_height(Evas e, Evas_Object o)
|
|||
Evas_Object_Text oo;
|
||||
|
||||
if (!e) return 0;
|
||||
o = TO_OBJECT(e, o);
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return 0;
|
||||
IF_OBJ(o, OBJECT_TEXT) return 0;
|
||||
oo = o;
|
||||
|
@ -266,6 +271,7 @@ evas_text_at_position(Evas e, Evas_Object o, double x, double y,
|
|||
int cx, cy, cw, ch;
|
||||
|
||||
if (!e) return -1;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return -1;
|
||||
IF_OBJ(o, OBJECT_TEXT) return -1;
|
||||
oo = o;
|
||||
|
@ -280,8 +286,8 @@ evas_text_at_position(Evas e, Evas_Object o, double x, double y,
|
|||
if (fn)
|
||||
{
|
||||
ret = __evas_imlib_text_get_character_at_pos(fn, oo->current.text,
|
||||
(int)(x - o->current.x),
|
||||
(int)(y - o->current.y),
|
||||
(int)(x),
|
||||
(int)(y),
|
||||
&cx, &cy, &cw, &ch);
|
||||
if (char_x) *char_x = (double)cx;
|
||||
if (char_y) *char_y = (double)cy;
|
||||
|
@ -301,8 +307,8 @@ evas_text_at_position(Evas e, Evas_Object o, double x, double y,
|
|||
if (fn)
|
||||
{
|
||||
ret = __evas_x11_text_get_character_at_pos(fn, oo->current.text,
|
||||
(int)(x - o->current.x),
|
||||
(int)(y - o->current.y),
|
||||
(int)(x),
|
||||
(int)(y),
|
||||
&cx, &cy, &cw, &ch);
|
||||
if (char_x) *char_x = (double)cx;
|
||||
if (char_y) *char_y = (double)cy;
|
||||
|
@ -322,8 +328,8 @@ evas_text_at_position(Evas e, Evas_Object o, double x, double y,
|
|||
if (fn)
|
||||
{
|
||||
ret = __evas_gl_text_get_character_at_pos(fn, oo->current.text,
|
||||
(int)(x - o->current.x),
|
||||
(int)(y - o->current.y),
|
||||
(int)(x),
|
||||
(int)(y),
|
||||
&cx, &cy, &cw, &ch);
|
||||
if (char_x) *char_x = (double)cx;
|
||||
if (char_y) *char_y = (double)cy;
|
||||
|
@ -343,8 +349,8 @@ evas_text_at_position(Evas e, Evas_Object o, double x, double y,
|
|||
if (fn)
|
||||
{
|
||||
ret = __evas_render_text_get_character_at_pos(fn, oo->current.text,
|
||||
(int)(x - o->current.x),
|
||||
(int)(y - o->current.y),
|
||||
(int)(x),
|
||||
(int)(y),
|
||||
&cx, &cy, &cw, &ch);
|
||||
if (char_x) *char_x = (double)cx;
|
||||
if (char_y) *char_y = (double)cy;
|
||||
|
@ -364,8 +370,8 @@ evas_text_at_position(Evas e, Evas_Object o, double x, double y,
|
|||
if (fn)
|
||||
{
|
||||
ret = __evas_image_text_get_character_at_pos(fn, oo->current.text,
|
||||
(int)(x - o->current.x),
|
||||
(int)(y - o->current.y),
|
||||
(int)(x),
|
||||
(int)(y),
|
||||
&cx, &cy, &cw, &ch);
|
||||
if (char_x) *char_x = (double)cx;
|
||||
if (char_y) *char_y = (double)cy;
|
||||
|
@ -498,6 +504,7 @@ evas_text_get_ascent_descent(Evas e, Evas_Object o,
|
|||
Evas_Object_Text oo;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
IF_OBJ(o, OBJECT_TEXT) return;
|
||||
oo = o;
|
||||
|
@ -584,6 +591,8 @@ evas_text_get_max_ascent_descent(Evas e, Evas_Object o,
|
|||
Evas_Object_Text oo;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
IF_OBJ(o, OBJECT_TEXT) return;
|
||||
oo = o;
|
||||
|
@ -670,6 +679,7 @@ evas_text_get_advance(Evas e, Evas_Object o,
|
|||
Evas_Object_Text oo;
|
||||
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
IF_OBJ(o, OBJECT_TEXT) return;
|
||||
oo = o;
|
||||
|
@ -750,6 +760,7 @@ evas_text_get_inset(Evas e, Evas_Object o)
|
|||
int inset;
|
||||
|
||||
if (!e) return 0;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return 0;
|
||||
IF_OBJ(o, OBJECT_TEXT) return 0;
|
||||
oo = o;
|
||||
|
@ -830,6 +841,7 @@ void
|
|||
evas_set_text(Evas e, Evas_Object o, char *text)
|
||||
{
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
switch (o->type)
|
||||
{
|
||||
|
@ -970,6 +982,7 @@ void
|
|||
evas_set_font(Evas e, Evas_Object o, char *font, int size)
|
||||
{
|
||||
if (!e) return;
|
||||
o = TO_OBJECT(e, o);
|
||||
if (!o) return;
|
||||
if (!font) return;
|
||||
if (size < 0) size = 0;
|
||||
|
|
Loading…
Reference in New Issue