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)
184 ELM_CHECK_WIDTYPE(obj, widtype);
185 Widget_Data *wd = elm_widget_data_get(obj);
188 _els_smart_icon_size_get(wd->img, w, h);
192 elm_image_no_scale_set(Evas_Object *obj, Eina_Bool no_scale)
194 ELM_CHECK_WIDTYPE(obj, widtype);
195 Widget_Data *wd = elm_widget_data_get(obj);
198 wd->no_scale = no_scale;
204 elm_image_no_scale_get(const Evas_Object *obj)
206 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
207 Widget_Data *wd = elm_widget_data_get(obj);
208 if (!wd) return EINA_FALSE;
213 elm_image_scale_set(Evas_Object *obj, Eina_Bool scale_up, Eina_Bool scale_down)
215 ELM_CHECK_WIDTYPE(obj, widtype);
216 Widget_Data *wd = elm_widget_data_get(obj);
219 wd->scale_up = scale_up;
220 wd->scale_down = scale_down;
225 elm_image_scale_get(const Evas_Object *obj, Eina_Bool *scale_up, Eina_Bool *scale_down)
227 ELM_CHECK_WIDTYPE(obj, widtype);
228 Widget_Data *wd = elm_widget_data_get(obj);
230 if (scale_up) *scale_up = wd->scale_up;
231 if (scale_down) *scale_down = wd->scale_down;
235 elm_image_fill_outside_set(Evas_Object *obj, Eina_Bool fill_outside)
237 ELM_CHECK_WIDTYPE(obj, widtype);
238 Widget_Data *wd = elm_widget_data_get(obj);
241 wd->fill_outside = fill_outside;
246 elm_image_fill_outside_get(const Evas_Object *obj)
248 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
249 Widget_Data *wd = elm_widget_data_get(obj);
251 if (!wd) return EINA_FALSE;
252 return wd->fill_outside;
256 elm_image_prescale_set(Evas_Object *obj, int size)
258 ELM_CHECK_WIDTYPE(obj, widtype);
259 Widget_Data *wd = elm_widget_data_get(obj);
262 _els_smart_icon_scale_size_set(wd->img, size);
266 elm_image_prescale_get(const Evas_Object *obj)
268 ELM_CHECK_WIDTYPE(obj, widtype) 0;
269 Widget_Data *wd = elm_widget_data_get(obj);
272 return _els_smart_icon_scale_size_get(wd->img);
276 elm_image_orient_set(Evas_Object *obj, Elm_Image_Orient orient)
278 ELM_CHECK_WIDTYPE(obj, widtype);
279 Widget_Data *wd = elm_widget_data_get(obj);
282 _els_smart_icon_orient_set(wd->img, orient);
285 EAPI Elm_Image_Orient
286 elm_image_orient_get(const Evas_Object *obj)
288 ELM_CHECK_WIDTYPE(obj, widtype) ELM_IMAGE_ORIENT_NONE;
289 Widget_Data *wd = elm_widget_data_get(obj);
290 if (!wd) return ELM_IMAGE_ORIENT_NONE;
291 return _els_smart_icon_orient_get(wd->img);
295 elm_image_editable_set(Evas_Object *obj, Eina_Bool set)
297 ELM_CHECK_WIDTYPE(obj, widtype);
298 Widget_Data *wd = elm_widget_data_get(obj);
301 _els_smart_icon_edit_set(wd->img, set, obj);
305 elm_image_editable_get(const Evas_Object *obj)
307 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
308 Widget_Data *wd = elm_widget_data_get(obj);
309 if (!wd) return EINA_FALSE;
310 return _els_smart_icon_edit_get(wd->img);
314 elm_image_object_get(const Evas_Object *obj)
316 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
317 Widget_Data *wd = elm_widget_data_get(obj);
318 if (!wd) return NULL;
319 return _els_smart_icon_object_get(wd->img);
323 elm_image_aspect_ratio_retained_set(Evas_Object *obj, Eina_Bool retained)
325 ELM_CHECK_WIDTYPE(obj, widtype);
326 Widget_Data *wd = elm_widget_data_get(obj);
328 return _els_smart_icon_aspect_ratio_retained_set(wd->img, retained);
332 elm_image_aspect_ratio_retained_get(const Evas_Object *obj)
334 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
335 Widget_Data *wd = elm_widget_data_get(obj);
336 if (!wd) return EINA_FALSE;
337 return _els_smart_icon_aspect_ratio_retained_get(wd->img);
340 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0 :*/