#include <Elementary.h>
#include "elm_priv.h"
-
-/**
- * @defgroup Image Image
- *
- * A standard image that may be provided by the theme (delete, edit,
- * arrows etc.) or a custom file (PNG, JPG, EDJE etc.) used for an
- * icon. The Icon may scale or not and of course... support alpha
- * channels.
- *
- * Signals that you can add callbacks for are:
- *
- * - clicked: This is called when a user has clicked the image
- * - drop: Something has been dropped on the image
- */
+#include "els_icon.h"
typedef struct _Widget_Data Widget_Data;
static void _sizing_eval(Evas_Object *obj);
static void _mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static const char SIG_CLICKED[] = "clicked";
+
+static const Evas_Smart_Cb_Description _signals[] = {
+ {SIG_CLICKED, ""},
+ {NULL, NULL}
+};
+
+
static void
_del_hook(Evas_Object *obj)
{
if (wd->no_scale) _els_smart_icon_scale_set(wd->img, 1.0);
else
{
- _els_smart_icon_scale_set(wd->img, elm_widget_scale_get(obj) * _elm_config->scale);
- _els_smart_icon_size_get(wd->img, &w, &h);
+ _els_smart_icon_scale_set(wd->img, elm_widget_scale_get(obj) * _elm_config->scale);
+ _els_smart_icon_size_get(wd->img, &w, &h);
}
if (!wd->scale_down)
{
- minw = w;
- minh = h;
+ minw = w;
+ minh = h;
}
if (!wd->scale_up)
{
- maxw = w;
- maxh = h;
+ maxw = w;
+ maxh = h;
}
evas_object_size_hint_min_set(obj, minw, minh);
evas_object_size_hint_max_set(obj, maxw, maxh);
static void
_mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- evas_object_smart_callback_call(data, "clicked", NULL);
+ evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
}
-/**
- * Add a new image to the parent
- *
- * @param parent The parent object
- * @return The new object or NULL if it cannot be created
- *
- * @ingroup Image
- */
EAPI Evas_Object *
elm_image_add(Evas_Object *parent)
{
Widget_Data *wd;
ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
-
+
ELM_SET_WIDTYPE(widtype, "image");
elm_widget_type_set(obj, "image");
elm_widget_sub_object_add(parent, obj);
wd->img = _els_smart_icon_add(e);
evas_object_event_callback_add(wd->img, EVAS_CALLBACK_MOUSE_UP,
- _mouse_up, obj);
+ _mouse_up, obj);
evas_object_repeat_events_set(wd->img, EINA_TRUE);
elm_widget_resize_object_set(obj, wd->img);
+ evas_object_smart_callbacks_descriptions_set(obj, _signals);
+
wd->smooth = EINA_TRUE;
wd->scale_up = EINA_TRUE;
wd->scale_down = EINA_TRUE;
return obj;
}
-/**
- * Set the file that will be used as image
- *
- * @param obj The image object
- * @param file The path to file that will be used as image
- * @param group The group that the image belongs in edje file
- *
- * @return (1 = success, 0 = error)
- *
- * @ingroup Image
- */
EAPI Eina_Bool
elm_image_file_set(Evas_Object *obj, const char *file, const char *group)
{
return ret;
}
-/**
- * Get the file that will be used as image
- *
- * @param obj The image object
- * @param file The path to file
- * @param group The group that the image belongs in edje file
- *
- * @ingroup Image
- */
EAPI void
elm_image_file_get(const Evas_Object *obj, const char **file, const char **group)
{
_els_smart_icon_file_get(wd->img, file, group);
}
-/**
- * Set the smooth effect for a image
- *
- * @param obj The image object
- * @param smooth A bool to set (or no) smooth effect
- * (1 = smooth, 0 = not smooth)
- *
- * @ingroup Image
- */
EAPI void
elm_image_smooth_set(Evas_Object *obj, Eina_Bool smooth)
{
_sizing_eval(obj);
}
-/**
- * Get the smooth effect for a image
- *
- * @param obj The image object
- * @return If setted smooth effect
- *
- * @ingroup Image
- */
EAPI Eina_Bool
elm_image_smooth_get(const Evas_Object *obj)
{
return wd->smooth;
}
-/**
- * Gets the current size of the image.
- *
- * Either width or height (or both) may be NULL.
- *
- * On error, neither w or h will be written too.
- *
- * @param obj The image object.
- * @param w Pointer to store width, or NULL.
- * @param h Pointer to store height, or NULL.
- */
EAPI void
elm_image_object_size_get(const Evas_Object *obj, int *w, int *h)
{
+ if (w) *w = 0;
+ if (h) *h = 0;
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
_els_smart_icon_size_get(wd->img, w, h);
}
-/**
- * Set if the object are scalable
- *
- * @param obj The image object.
- * @param no_scale A bool to set scale (or no).
- * (1 = no_scale, 0 = scale)
- *
- * @ingroup Image
- */
EAPI void
elm_image_no_scale_set(Evas_Object *obj, Eina_Bool no_scale)
{
}
-/**
- * Get if the object isn't scalable
- *
- * @param obj The image object
- * @return If isn't scalable
- *
- * @ingroup Image
- */
EAPI Eina_Bool
elm_image_no_scale_get(const Evas_Object *obj)
{
return wd->no_scale;
}
-/**
- * Set if the object is (up/down) scalable
- *
- * @param obj The image object
- * @param scale_up A bool to set if the object is scalable up
- * @param scale_down A bool to set if the object is scalable down
- *
- * @ingroup Image
- */
EAPI void
-elm_image_scale_set(Evas_Object *obj, Eina_Bool scale_up, Eina_Bool scale_down)
+elm_image_resizable_set(Evas_Object *obj, Eina_Bool size_up, Eina_Bool size_down)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- wd->scale_up = scale_up;
- wd->scale_down = scale_down;
+ wd->scale_up = size_up;
+ wd->scale_down = size_down;
_sizing_eval(obj);
}
-/**
- * Get if the object is (up/down) scalable
- *
- * @param obj The image object
- * @param scale_up A bool to set if the object is scalable up
- * @param scale_down A bool to set if the object is scalable down
- *
- * @ingroup Image
- */
EAPI void
-elm_image_scale_get(const Evas_Object *obj, Eina_Bool *scale_up, Eina_Bool *scale_down)
+elm_image_resizable_get(const Evas_Object *obj, Eina_Bool *size_up, Eina_Bool *size_down)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- if (scale_up) *scale_up = wd->scale_up;
- if (scale_down) *scale_down = wd->scale_down;
+ if (size_up) *size_up = wd->scale_up;
+ if (size_down) *size_down = wd->scale_down;
}
-/**
- * Set if the object is filled outside
- *
- * @param obj The image object
- * @param fill_outside A bool to set if the object is filled outside
- * (1 = filled, 0 = no filled)
- *
- * @ingroup Image
- */
EAPI void
elm_image_fill_outside_set(Evas_Object *obj, Eina_Bool fill_outside)
{
_sizing_eval(obj);
}
-/**
- * Get if the object is filled outside
- *
- * @param obj The image object
- * @return If the object is filled outside
- *
- * @ingroup Image
- */
EAPI Eina_Bool
elm_image_fill_outside_get(const Evas_Object *obj)
{
return wd->fill_outside;
}
-/**
- * Set the prescale size for the image
- *
- * @param obj The image object
- * @param size The prescale size
- *
- * @ingroup Image
- */
+EAPI void
+elm_image_preload_disabled_set(Evas_Object *obj, Eina_Bool disabled)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+
+ if (!wd) return;
+ _els_smart_icon_preload_set(wd->img, !!disabled);
+}
+
EAPI void
elm_image_prescale_set(Evas_Object *obj, int size)
{
_els_smart_icon_scale_size_set(wd->img, size);
}
-/**
- * Get the prescale size for the image
- *
- * @param obj The image object
- * @return The prescale size
- *
- * @ingroup Image
- */
EAPI int
elm_image_prescale_get(const Evas_Object *obj)
{
return _els_smart_icon_scale_size_get(wd->img);
}
-/**
- * Set the image orient
- *
- * @param obj The image object
- * @param orient The image orient
- * (ELM_IMAGE_ORIENT_NONE, ELM_IMAGE_ROTATE_90_CW,
- * ELM_IMAGE_ROTATE_180_CW, ELM_IMAGE_ROTATE_90_CCW,
- * ELM_IMAGE_FLIP_HORIZONTAL,ELM_IMAGE_FLIP_VERTICAL,
- * ELM_IMAGE_FLIP_TRANSPOSE, ELM_IMAGE_FLIP_TRANSVERSE)
- *
- * @ingroup Image
- */
EAPI void
elm_image_orient_set(Evas_Object *obj, Elm_Image_Orient orient)
{
_els_smart_icon_orient_set(wd->img, orient);
}
-/**
- * Get the image orient
- *
- * @param obj The image object
- * @return The image orient
- * (ELM_IMAGE_ORIENT_NONE, ELM_IMAGE_ROTATE_90_CW,
- * ELM_IMAGE_ROTATE_180_CW, ELM_IMAGE_ROTATE_90_CCW,
- * ELM_IMAGE_FLIP_HORIZONTAL,ELM_IMAGE_FLIP_VERTICAL,
- * ELM_IMAGE_FLIP_TRANSPOSE, ELM_IMAGE_FLIP_TRANSVERSE)
- *
- * @ingroup Image
- */
EAPI Elm_Image_Orient
elm_image_orient_get(const Evas_Object *obj)
{
return _els_smart_icon_orient_get(wd->img);
}
-/**
- * Make the image 'editable'.
- *
- * This means the image is a valid drag target for drag and drop, and can be
- * cut or pasted too.
- *
- * @param obj Image object.
- * @param set Turn on or off editability.
- */
EAPI void
elm_image_editable_set(Evas_Object *obj, Eina_Bool set)
{
_els_smart_icon_edit_set(wd->img, set, obj);
}
-/**
- * Make the image 'editable'.
- *
- * This means the image is a valid drag target for drag and drop, and can be
- * cut or pasted too.
- *
- * @param obj Image object.
- * @return Editability.
- */
EAPI Eina_Bool
elm_image_editable_get(const Evas_Object *obj)
{
return _els_smart_icon_edit_get(wd->img);
}
+EAPI Evas_Object *
+elm_image_object_get(const Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ return _els_smart_icon_object_get(wd->img);
+}
+
+EAPI void
+elm_image_aspect_fixed_set(Evas_Object *obj, Eina_Bool fixed)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ _els_smart_icon_aspect_fixed_set(wd->img, fixed);
+}
+
+EAPI Eina_Bool
+elm_image_aspect_fixed_get(const Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return EINA_FALSE;
+ return _els_smart_icon_aspect_fixed_get(wd->img);
+}
-/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/
+/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0 :*/