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));
71 if (wd->no_scale) _els_smart_icon_scale_set(wd->img, 1.0);
74 _els_smart_icon_scale_set(wd->img, elm_widget_scale_get(obj) * _elm_config->scale);
75 _els_smart_icon_size_get(wd->img, &w, &h);
87 evas_object_size_hint_min_set(obj, minw, minh);
88 evas_object_size_hint_max_set(obj, maxw, maxh);
92 _mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
94 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
98 elm_image_add(Evas_Object *parent)
104 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
106 ELM_SET_WIDTYPE(widtype, "image");
107 elm_widget_type_set(obj, "image");
108 elm_widget_sub_object_add(parent, obj);
109 elm_widget_data_set(obj, wd);
110 elm_widget_del_hook_set(obj, _del_hook);
111 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
112 elm_widget_theme_hook_set(obj, _theme_hook);
113 elm_widget_can_focus_set(obj, EINA_FALSE);
115 wd->img = _els_smart_icon_add(e);
116 evas_object_event_callback_add(wd->img, EVAS_CALLBACK_MOUSE_UP,
118 evas_object_repeat_events_set(wd->img, EINA_TRUE);
119 elm_widget_resize_object_set(obj, wd->img);
121 evas_object_smart_callbacks_descriptions_set(obj, _signals);
123 wd->smooth = EINA_TRUE;
124 wd->scale_up = EINA_TRUE;
125 wd->scale_down = EINA_TRUE;
127 _els_smart_icon_scale_size_set(wd->img, 0);
134 elm_image_file_set(Evas_Object *obj, const char *file, const char *group)
136 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
137 Widget_Data *wd = elm_widget_data_get(obj);
141 if (!wd) return EINA_FALSE;
142 EINA_SAFETY_ON_NULL_RETURN_VAL(file, EINA_FALSE);
143 if (((p = strrchr(file, '.'))) && (!strcasecmp(p, ".edj")))
144 ret = _els_smart_icon_file_edje_set(wd->img, file, group);
146 ret = _els_smart_icon_file_key_set(wd->img, file, group);
152 elm_image_file_get(const Evas_Object *obj, const char **file, const char **group)
154 ELM_CHECK_WIDTYPE(obj, widtype);
155 Widget_Data *wd = elm_widget_data_get(obj);
157 _els_smart_icon_file_get(wd->img, file, group);
161 elm_image_smooth_set(Evas_Object *obj, Eina_Bool smooth)
163 ELM_CHECK_WIDTYPE(obj, widtype);
164 Widget_Data *wd = elm_widget_data_get(obj);
172 elm_image_smooth_get(const Evas_Object *obj)
174 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
175 Widget_Data *wd = elm_widget_data_get(obj);
177 if (!wd) return EINA_FALSE;
182 elm_image_object_size_get(const Evas_Object *obj, int *w, int *h)
186 ELM_CHECK_WIDTYPE(obj, widtype);
187 Widget_Data *wd = elm_widget_data_get(obj);
190 _els_smart_icon_size_get(wd->img, w, h);
194 elm_image_no_scale_set(Evas_Object *obj, Eina_Bool no_scale)
196 ELM_CHECK_WIDTYPE(obj, widtype);
197 Widget_Data *wd = elm_widget_data_get(obj);
200 wd->no_scale = no_scale;
206 elm_image_no_scale_get(const Evas_Object *obj)
208 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
209 Widget_Data *wd = elm_widget_data_get(obj);
210 if (!wd) return EINA_FALSE;
215 elm_image_scale_set(Evas_Object *obj, Eina_Bool scale_up, Eina_Bool scale_down)
217 ELM_CHECK_WIDTYPE(obj, widtype);
218 Widget_Data *wd = elm_widget_data_get(obj);
221 wd->scale_up = scale_up;
222 wd->scale_down = scale_down;
227 elm_image_scale_get(const Evas_Object *obj, Eina_Bool *scale_up, Eina_Bool *scale_down)
229 ELM_CHECK_WIDTYPE(obj, widtype);
230 Widget_Data *wd = elm_widget_data_get(obj);
232 if (scale_up) *scale_up = wd->scale_up;
233 if (scale_down) *scale_down = wd->scale_down;
237 elm_image_fill_outside_set(Evas_Object *obj, Eina_Bool fill_outside)
239 ELM_CHECK_WIDTYPE(obj, widtype);
240 Widget_Data *wd = elm_widget_data_get(obj);
243 wd->fill_outside = fill_outside;
248 elm_image_fill_outside_get(const Evas_Object *obj)
250 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
251 Widget_Data *wd = elm_widget_data_get(obj);
253 if (!wd) return EINA_FALSE;
254 return wd->fill_outside;
258 elm_image_prescale_set(Evas_Object *obj, int size)
260 ELM_CHECK_WIDTYPE(obj, widtype);
261 Widget_Data *wd = elm_widget_data_get(obj);
264 _els_smart_icon_scale_size_set(wd->img, size);
268 elm_image_prescale_get(const Evas_Object *obj)
270 ELM_CHECK_WIDTYPE(obj, widtype) 0;
271 Widget_Data *wd = elm_widget_data_get(obj);
274 return _els_smart_icon_scale_size_get(wd->img);
278 elm_image_orient_set(Evas_Object *obj, Elm_Image_Orient orient)
280 ELM_CHECK_WIDTYPE(obj, widtype);
281 Widget_Data *wd = elm_widget_data_get(obj);
284 _els_smart_icon_orient_set(wd->img, orient);
287 EAPI Elm_Image_Orient
288 elm_image_orient_get(const Evas_Object *obj)
290 ELM_CHECK_WIDTYPE(obj, widtype) ELM_IMAGE_ORIENT_NONE;
291 Widget_Data *wd = elm_widget_data_get(obj);
292 if (!wd) return ELM_IMAGE_ORIENT_NONE;
293 return _els_smart_icon_orient_get(wd->img);
297 elm_image_editable_set(Evas_Object *obj, Eina_Bool set)
299 ELM_CHECK_WIDTYPE(obj, widtype);
300 Widget_Data *wd = elm_widget_data_get(obj);
303 _els_smart_icon_edit_set(wd->img, set, obj);
307 elm_image_editable_get(const Evas_Object *obj)
309 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
310 Widget_Data *wd = elm_widget_data_get(obj);
311 if (!wd) return EINA_FALSE;
312 return _els_smart_icon_edit_get(wd->img);
316 elm_image_object_get(const Evas_Object *obj)
318 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
319 Widget_Data *wd = elm_widget_data_get(obj);
320 if (!wd) return NULL;
321 return _els_smart_icon_object_get(wd->img);
325 elm_image_aspect_fixed_set(Evas_Object *obj, Eina_Bool fixed)
327 ELM_CHECK_WIDTYPE(obj, widtype);
328 Widget_Data *wd = elm_widget_data_get(obj);
330 _els_smart_icon_aspect_fixed_set(wd->img, fixed);
334 elm_image_aspect_fixed_get(const Evas_Object *obj)
336 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
337 Widget_Data *wd = elm_widget_data_get(obj);
338 if (!wd) return EINA_FALSE;
339 return _els_smart_icon_aspect_fixed_get(wd->img);
342 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0 :*/