1 #include <Elementary.h>
5 typedef struct _Widget_Data Widget_Data;
10 Eina_Bool scale_up : 1;
11 Eina_Bool scale_down : 1;
13 Eina_Bool fill_outside : 1;
14 Eina_Bool no_scale : 1;
17 static const char *widtype = NULL;
18 static void _del_hook(Evas_Object *obj);
19 static void _theme_hook(Evas_Object *obj);
20 static void _sizing_eval(Evas_Object *obj);
21 static void _mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
23 static const char SIG_CLICKED[] = "clicked";
25 static const Evas_Smart_Cb_Description _signals[] = {
32 _del_hook(Evas_Object *obj)
34 Widget_Data *wd = elm_widget_data_get(obj);
41 _del_pre_hook(Evas_Object *obj)
43 Widget_Data *wd = elm_widget_data_get(obj);
46 evas_object_del(wd->img);
50 _theme_hook(Evas_Object *obj)
52 Widget_Data *wd = elm_widget_data_get(obj);
59 _sizing_eval(Evas_Object *obj)
61 Widget_Data *wd = elm_widget_data_get(obj);
62 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
66 _els_smart_icon_size_get(wd->img, &w, &h);
67 _els_smart_icon_scale_up_set(wd->img, wd->scale_up);
68 _els_smart_icon_scale_down_set(wd->img, wd->scale_down);
69 _els_smart_icon_smooth_scale_set(wd->img, wd->smooth);
70 _els_smart_icon_fill_inside_set(wd->img, !(wd->fill_outside));
72 evas_object_size_hint_min_get(obj, &minw, &minh);
74 if (wd->no_scale) _els_smart_icon_scale_set(wd->img, 1.0);
77 _els_smart_icon_scale_set(wd->img, elm_widget_scale_get(obj) * _elm_config->scale);
78 _els_smart_icon_size_get(wd->img, &w, &h);
90 evas_object_size_hint_min_set(obj, minw, minh);
91 evas_object_size_hint_max_set(obj, maxw, maxh);
95 _mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
97 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
101 elm_image_add(Evas_Object *parent)
107 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
109 ELM_SET_WIDTYPE(widtype, "image");
110 elm_widget_type_set(obj, "image");
111 elm_widget_sub_object_add(parent, obj);
112 elm_widget_data_set(obj, wd);
113 elm_widget_del_hook_set(obj, _del_hook);
114 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
115 elm_widget_theme_hook_set(obj, _theme_hook);
116 elm_widget_can_focus_set(obj, EINA_FALSE);
118 wd->img = _els_smart_icon_add(e);
119 evas_object_event_callback_add(wd->img, EVAS_CALLBACK_MOUSE_UP,
121 evas_object_repeat_events_set(wd->img, EINA_TRUE);
122 elm_widget_resize_object_set(obj, wd->img);
124 evas_object_smart_callbacks_descriptions_set(obj, _signals);
126 wd->smooth = EINA_TRUE;
127 wd->scale_up = EINA_TRUE;
128 wd->scale_down = EINA_TRUE;
130 _els_smart_icon_scale_size_set(wd->img, 0);
137 elm_image_file_set(Evas_Object *obj, const char *file, const char *group)
139 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
140 Widget_Data *wd = elm_widget_data_get(obj);
144 if (!wd) return EINA_FALSE;
145 EINA_SAFETY_ON_NULL_RETURN_VAL(file, EINA_FALSE);
146 if (((p = strrchr(file, '.'))) && (!strcasecmp(p, ".edj")))
147 ret = _els_smart_icon_file_edje_set(wd->img, file, group);
149 ret = _els_smart_icon_file_key_set(wd->img, file, group);
155 elm_image_file_get(const Evas_Object *obj, const char **file, const char **group)
157 ELM_CHECK_WIDTYPE(obj, widtype);
158 Widget_Data *wd = elm_widget_data_get(obj);
160 _els_smart_icon_file_get(wd->img, file, group);
164 elm_image_smooth_set(Evas_Object *obj, Eina_Bool smooth)
166 ELM_CHECK_WIDTYPE(obj, widtype);
167 Widget_Data *wd = elm_widget_data_get(obj);
175 elm_image_smooth_get(const Evas_Object *obj)
177 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
178 Widget_Data *wd = elm_widget_data_get(obj);
180 if (!wd) return EINA_FALSE;
185 elm_image_object_size_get(const Evas_Object *obj, int *w, int *h)
189 ELM_CHECK_WIDTYPE(obj, widtype);
190 Widget_Data *wd = elm_widget_data_get(obj);
193 _els_smart_icon_size_get(wd->img, w, h);
197 elm_image_no_scale_set(Evas_Object *obj, Eina_Bool no_scale)
199 ELM_CHECK_WIDTYPE(obj, widtype);
200 Widget_Data *wd = elm_widget_data_get(obj);
203 wd->no_scale = no_scale;
209 elm_image_no_scale_get(const Evas_Object *obj)
211 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
212 Widget_Data *wd = elm_widget_data_get(obj);
213 if (!wd) return EINA_FALSE;
218 elm_image_resizable_set(Evas_Object *obj, Eina_Bool size_up, Eina_Bool size_down)
220 ELM_CHECK_WIDTYPE(obj, widtype);
221 Widget_Data *wd = elm_widget_data_get(obj);
224 wd->scale_up = size_up;
225 wd->scale_down = size_down;
230 elm_image_resizable_get(const Evas_Object *obj, Eina_Bool *size_up, Eina_Bool *size_down)
232 ELM_CHECK_WIDTYPE(obj, widtype);
233 Widget_Data *wd = elm_widget_data_get(obj);
235 if (size_up) *size_up = wd->scale_up;
236 if (size_down) *size_down = wd->scale_down;
240 elm_image_fill_outside_set(Evas_Object *obj, Eina_Bool fill_outside)
242 ELM_CHECK_WIDTYPE(obj, widtype);
243 Widget_Data *wd = elm_widget_data_get(obj);
246 wd->fill_outside = fill_outside;
251 elm_image_fill_outside_get(const Evas_Object *obj)
253 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
254 Widget_Data *wd = elm_widget_data_get(obj);
256 if (!wd) return EINA_FALSE;
257 return wd->fill_outside;
261 elm_image_preload_disabled_set(Evas_Object *obj, Eina_Bool disabled)
263 ELM_CHECK_WIDTYPE(obj, widtype);
264 Widget_Data *wd = elm_widget_data_get(obj);
267 _els_smart_icon_preload_set(wd->img, !!disabled);
271 elm_image_prescale_set(Evas_Object *obj, int size)
273 ELM_CHECK_WIDTYPE(obj, widtype);
274 Widget_Data *wd = elm_widget_data_get(obj);
277 _els_smart_icon_scale_size_set(wd->img, size);
281 elm_image_prescale_get(const Evas_Object *obj)
283 ELM_CHECK_WIDTYPE(obj, widtype) 0;
284 Widget_Data *wd = elm_widget_data_get(obj);
287 return _els_smart_icon_scale_size_get(wd->img);
291 elm_image_orient_set(Evas_Object *obj, Elm_Image_Orient orient)
293 ELM_CHECK_WIDTYPE(obj, widtype);
294 Widget_Data *wd = elm_widget_data_get(obj);
297 _els_smart_icon_orient_set(wd->img, orient);
300 EAPI Elm_Image_Orient
301 elm_image_orient_get(const Evas_Object *obj)
303 ELM_CHECK_WIDTYPE(obj, widtype) ELM_IMAGE_ORIENT_NONE;
304 Widget_Data *wd = elm_widget_data_get(obj);
305 if (!wd) return ELM_IMAGE_ORIENT_NONE;
306 return _els_smart_icon_orient_get(wd->img);
310 elm_image_editable_set(Evas_Object *obj, Eina_Bool set)
312 ELM_CHECK_WIDTYPE(obj, widtype);
313 Widget_Data *wd = elm_widget_data_get(obj);
316 _els_smart_icon_edit_set(wd->img, set, obj);
320 elm_image_editable_get(const Evas_Object *obj)
322 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
323 Widget_Data *wd = elm_widget_data_get(obj);
324 if (!wd) return EINA_FALSE;
325 return _els_smart_icon_edit_get(wd->img);
329 elm_image_object_get(const Evas_Object *obj)
331 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
332 Widget_Data *wd = elm_widget_data_get(obj);
333 if (!wd) return NULL;
334 return _els_smart_icon_object_get(wd->img);
338 elm_image_aspect_fixed_set(Evas_Object *obj, Eina_Bool fixed)
340 ELM_CHECK_WIDTYPE(obj, widtype);
341 Widget_Data *wd = elm_widget_data_get(obj);
343 _els_smart_icon_aspect_fixed_set(wd->img, fixed);
347 elm_image_aspect_fixed_get(const Evas_Object *obj)
349 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
350 Widget_Data *wd = elm_widget_data_get(obj);
351 if (!wd) return EINA_FALSE;
352 return _els_smart_icon_aspect_fixed_get(wd->img);
355 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0 :*/