2005-10-24 09:19:17 -07:00
|
|
|
#include "e.h"
|
2005-11-22 01:27:25 -08:00
|
|
|
|
|
|
|
typedef struct _E_Widget_Data E_Widget_Data;
|
|
|
|
struct _E_Widget_Data
|
|
|
|
{
|
|
|
|
Evas_Object *img;
|
2007-02-20 19:55:18 -08:00
|
|
|
int minw, minh;
|
2005-11-22 01:27:25 -08:00
|
|
|
};
|
|
|
|
|
2006-03-03 20:11:51 -08:00
|
|
|
static void _e_wid_del_hook(Evas_Object *obj);
|
|
|
|
|
2005-10-24 09:19:17 -07:00
|
|
|
/* local subsystem functions */
|
|
|
|
|
|
|
|
/* externally accessible functions */
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI Evas_Object *
|
2005-10-24 09:19:17 -07:00
|
|
|
e_widget_image_add_from_object(Evas *evas, Evas_Object *object, int minw, int minh)
|
|
|
|
{
|
2005-11-22 01:27:25 -08:00
|
|
|
Evas_Object *obj, *o;
|
|
|
|
E_Widget_Data *wd;
|
2007-02-20 19:55:18 -08:00
|
|
|
int mw = 0, mh = 0;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-10-24 09:19:17 -07:00
|
|
|
obj = e_widget_add(evas);
|
2006-03-03 20:11:51 -08:00
|
|
|
e_widget_del_hook_set(obj, _e_wid_del_hook);
|
2005-11-22 01:27:25 -08:00
|
|
|
wd = calloc(1, sizeof(E_Widget_Data));
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-10-25 15:01:50 -07:00
|
|
|
evas_object_show(object);
|
2005-11-22 01:27:25 -08:00
|
|
|
o = e_icon_add(evas);
|
2006-01-12 18:11:11 -08:00
|
|
|
e_icon_fill_inside_set(o, 1);
|
|
|
|
e_icon_object_set(o, object);
|
2005-11-22 01:27:25 -08:00
|
|
|
wd->img = o;
|
2007-02-20 19:55:18 -08:00
|
|
|
e_widget_data_set(obj, wd);
|
2005-10-24 09:19:17 -07:00
|
|
|
e_widget_can_focus_set(obj, 0);
|
2007-02-20 19:55:18 -08:00
|
|
|
wd->minw = minw <= 0 ? minw : 0;
|
|
|
|
wd->minh = minh <= 0 ? minh : 0;
|
|
|
|
edje_object_size_min_get(object, &mw, &mh);
|
|
|
|
if (minw || minh)
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_set(obj, minw, minh);
|
2007-02-20 19:55:18 -08:00
|
|
|
else
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_set(obj, mw, mh);
|
2005-11-22 01:27:25 -08:00
|
|
|
e_widget_sub_object_add(obj, o);
|
|
|
|
e_widget_resize_object_set(obj, o);
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-10-24 09:19:17 -07:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI Evas_Object *
|
2007-01-12 05:22:34 -08:00
|
|
|
e_widget_image_add_from_file(Evas *evas, const char *file, int minw, int minh)
|
2012-06-20 23:19:43 -07:00
|
|
|
{
|
2005-11-22 01:27:25 -08:00
|
|
|
Evas_Object *obj, *o, *o2;
|
|
|
|
E_Widget_Data *wd;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-10-24 09:19:17 -07:00
|
|
|
obj = e_widget_add(evas);
|
2005-11-22 01:27:25 -08:00
|
|
|
wd = calloc(1, sizeof(E_Widget_Data));
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-11-22 01:27:25 -08:00
|
|
|
o = e_icon_add(evas);
|
2006-01-12 18:11:11 -08:00
|
|
|
e_icon_fill_inside_set(o, 1);
|
2005-11-22 01:27:25 -08:00
|
|
|
o2 = evas_object_image_add(evas);
|
|
|
|
evas_object_image_file_set(o2, file, NULL);
|
|
|
|
e_icon_object_set(o, o2);
|
2012-06-20 23:19:43 -07:00
|
|
|
|
|
|
|
wd->img = o;
|
2005-10-24 09:19:17 -07:00
|
|
|
evas_object_show(o);
|
2012-06-20 23:19:43 -07:00
|
|
|
e_widget_data_set(obj, wd);
|
2005-10-24 09:19:17 -07:00
|
|
|
e_widget_can_focus_set(obj, 0);
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_set(obj, minw, minh);
|
2005-10-24 09:19:17 -07:00
|
|
|
e_widget_sub_object_add(obj, o);
|
2005-10-25 15:01:50 -07:00
|
|
|
e_widget_resize_object_set(obj, o);
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-10-25 15:01:50 -07:00
|
|
|
return obj;
|
2005-10-24 09:19:17 -07:00
|
|
|
}
|
2005-11-22 01:27:25 -08:00
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2008-02-06 12:47:59 -08:00
|
|
|
e_widget_image_edje_set(Evas_Object *obj, const char *file, const char *part)
|
2005-11-22 01:27:25 -08:00
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-11-22 01:27:25 -08:00
|
|
|
wd = e_widget_data_get(obj);
|
|
|
|
e_icon_file_edje_set(wd->img, file, part);
|
|
|
|
evas_object_show(wd->img);
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2008-02-06 12:47:59 -08:00
|
|
|
e_widget_image_file_set(Evas_Object *obj, const char *file)
|
2005-11-22 01:27:25 -08:00
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-11-22 01:27:25 -08:00
|
|
|
wd = e_widget_data_get(obj);
|
|
|
|
e_icon_file_set(wd->img, file);
|
|
|
|
evas_object_show(wd->img);
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2008-02-06 12:47:59 -08:00
|
|
|
e_widget_image_file_key_set(Evas_Object *obj, const char *file, const char *key)
|
2005-11-22 01:27:25 -08:00
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-11-22 01:27:25 -08:00
|
|
|
wd = e_widget_data_get(obj);
|
|
|
|
e_icon_file_key_set(wd->img, file, key);
|
|
|
|
evas_object_show(wd->img);
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-11-22 01:27:25 -08:00
|
|
|
e_widget_image_object_set(Evas_Object *obj, Evas_Object *o)
|
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
2007-02-20 19:55:18 -08:00
|
|
|
int mw, mh;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-11-22 01:27:25 -08:00
|
|
|
wd = e_widget_data_get(obj);
|
|
|
|
e_icon_object_set(wd->img, o);
|
2007-02-20 19:55:18 -08:00
|
|
|
edje_object_size_min_get(o, &mw, &mh);
|
|
|
|
if (wd->minw || wd->minh)
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_set(obj, wd->minw, wd->minh);
|
2007-02-20 19:55:18 -08:00
|
|
|
else
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_set(obj, mw, mh);
|
2005-11-22 01:27:25 -08:00
|
|
|
evas_object_show(wd->img);
|
|
|
|
}
|
2006-03-03 20:11:51 -08:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_wid_del_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2006-03-03 20:11:51 -08:00
|
|
|
wd = e_widget_data_get(obj);
|
|
|
|
free(wd);
|
|
|
|
}
|