elementary - updated XXX
[framework/uifw/elementary.git] / src / lib / elm_image.h
1 /**
2  * @defgroup Image Image
3  *
4  * @image html img/widget/image/preview-00.png
5  * @image latex img/widget/image/preview-00.eps
6
7  *
8  * An object that allows one to load an image file to it. It can be used
9  * anywhere like any other elementary widget.
10  *
11  * This widget provides most of the functionality provided from @ref Bg or @ref
12  * Icon, but with a slightly different API (use the one that fits better your
13  * needs).
14  *
15  * The features not provided by those two other image widgets are:
16  * @li allowing to get the basic @c Evas_Object with elm_image_object_get();
17  * @li change the object orientation with elm_image_orient_set();
18  * @li and turning the image editable with elm_image_editable_set().
19  *
20  * Signals that you can add callbacks for are:
21  *
22  * @li @c "clicked" - This is called when a user has clicked the image
23  *
24  * An example of usage for this API follows:
25  * @li @ref tutorial_image
26  */
27
28 /**
29  * @addtogroup Image
30  * @{
31  */
32
33 /**
34  * Possible orientation options for elm_image_orient_set().
35  *
36  * @image html elm_image_orient_set.png
37  * @image latex elm_image_orient_set.eps width=\textwidth
38  *
39  * @ingroup Image
40  */
41 typedef enum
42 {
43    ELM_IMAGE_ORIENT_NONE = 0, /**< no orientation change */
44    ELM_IMAGE_ORIENT_0 = 0, /**< no orientation change */
45    ELM_IMAGE_ROTATE_90 = 1, /**< rotate 90 degrees clockwise */
46    ELM_IMAGE_ROTATE_180 = 2, /**< rotate 180 degrees clockwise */
47    ELM_IMAGE_ROTATE_270 = 3, /**< rotate 90 degrees counter-clockwise (i.e. 270 degrees clockwise) */
48    ELM_IMAGE_FLIP_HORIZONTAL = 4, /**< flip image horizontally */
49    ELM_IMAGE_FLIP_VERTICAL = 5, /**< flip image vertically */
50    ELM_IMAGE_FLIP_TRANSPOSE = 6, /**< flip the image along the y = (width - x) line (bottom-left to top-right) */
51    ELM_IMAGE_FLIP_TRANSVERSE = 7 /**< flip the image along the y = x line (top-left to bottom-right) */
52 } Elm_Image_Orient;
53
54 /**
55  * Add a new image to the parent.
56  *
57  * @param parent The parent object
58  * @return The new object or NULL if it cannot be created
59  *
60  * @see elm_image_file_set()
61  *
62  * @ingroup Image
63  */
64 EAPI Evas_Object     *elm_image_add(Evas_Object *parent);
65
66 /**
67  * Set the file that will be used as image.
68  *
69  * @param obj The image object
70  * @param file The path to file that will be used as image
71  * @param group The group that the image belongs in edje file (if it's an
72  * edje image)
73  *
74  * @return (@c EINA_TRUE = success, @c EINA_FALSE = error)
75  *
76  * @see elm_image_file_get()
77  *
78  * @ingroup Image
79  */
80 EAPI Eina_Bool        elm_image_file_set(Evas_Object *obj, const char *file, const char *group);
81
82 /**
83  * Get the file that will be used as image.
84  *
85  * @param obj The image object
86  * @param file The path to file
87  * @param group The group that the image belongs in edje file
88  *
89  * @see elm_image_file_set()
90  *
91  * @ingroup Image
92  */
93 EAPI void             elm_image_file_get(const Evas_Object *obj, const char **file, const char **group);
94
95 /**
96  * Set the smooth effect for an image.
97  *
98  * @param obj The image object
99  * @param smooth @c EINA_TRUE if smooth scaling should be used, @c EINA_FALSE
100  * otherwise. Default is @c EINA_TRUE.
101  *
102  * Set the scaling algorithm to be used when scaling the image. Smooth
103  * scaling provides a better resulting image, but is slower.
104  *
105  * The smooth scaling should be disabled when making animations that change
106  * the image size, since it will be faster. Animations that don't require
107  * resizing of the image can keep the smooth scaling enabled (even if the
108  * image is already scaled, since the scaled image will be cached).
109  *
110  * @see elm_image_smooth_get()
111  *
112  * @ingroup Image
113  */
114 EAPI void             elm_image_smooth_set(Evas_Object *obj, Eina_Bool smooth);
115
116 /**
117  * Get the smooth effect for an image.
118  *
119  * @param obj The image object
120  * @return @c EINA_TRUE if smooth scaling is enabled, @c EINA_FALSE otherwise.
121  *
122  * @see elm_image_smooth_get()
123  *
124  * @ingroup Image
125  */
126 EAPI Eina_Bool        elm_image_smooth_get(const Evas_Object *obj);
127
128 /**
129  * Gets the current size of the image.
130  *
131  * @param obj The image object.
132  * @param w Pointer to store width, or NULL.
133  * @param h Pointer to store height, or NULL.
134  *
135  * This is the real size of the image, not the size of the object.
136  *
137  * @ingroup Image
138  */
139 EAPI void             elm_image_object_size_get(const Evas_Object *obj, int *w, int *h);
140
141 /**
142  * Disable scaling of this object.
143  *
144  * @param obj The image object.
145  * @param no_scale @c EINA_TRUE if the object is not scalable, @c EINA_FALSE
146  * otherwise. Default is @c EINA_FALSE.
147  *
148  * This function disables scaling of the elm_image widget through the
149  * function elm_object_scale_set(). However, this does not affect the widget
150  * size/resize in any way. For that effect, take a look at
151  * elm_image_scale_set().
152  *
153  * @see elm_image_no_scale_get()
154  * @see elm_image_scale_set()
155  * @see elm_object_scale_set()
156  *
157  * @ingroup Image
158  */
159 EAPI void             elm_image_no_scale_set(Evas_Object *obj, Eina_Bool no_scale);
160
161 /**
162  * Get whether scaling is disabled on the object.
163  *
164  * @param obj The image object
165  * @return @c EINA_TRUE if scaling is disabled, @c EINA_FALSE otherwise
166  *
167  * @see elm_image_no_scale_set()
168  *
169  * @ingroup Image
170  */
171 EAPI Eina_Bool        elm_image_no_scale_get(const Evas_Object *obj);
172
173 /**
174  * Set if the object is (up/down) resizeable.
175  *
176  * @param obj The image object
177  * @param scale_up A bool to set if the object is resizeable up. Default is
178  * @c EINA_TRUE.
179  * @param scale_down A bool to set if the object is resizeable down. Default
180  * is @c EINA_TRUE.
181  *
182  * This function limits the image resize ability. If @p scale_up is set to
183  * @c EINA_FALSE, the object can't have its height or width resized to a value
184  * higher than the original image size. Same is valid for @p scale_down.
185  *
186  * @see elm_image_scale_get()
187  *
188  * @ingroup Image
189  */
190 //XXX: elm_image_resizable_set
191 EAPI void             elm_image_scale_set(Evas_Object *obj, Eina_Bool scale_up, Eina_Bool scale_down);
192
193 /**
194  * Get if the object is (up/down) resizeable.
195  *
196  * @param obj The image object
197  * @param scale_up A bool to set if the object is resizeable up
198  * @param scale_down A bool to set if the object is resizeable down
199  *
200  * @see elm_image_scale_set()
201  *
202  * @ingroup Image
203  */
204 //XXX: elm_image_resizable_get
205 EAPI void             elm_image_scale_get(const Evas_Object *obj, Eina_Bool *scale_up, Eina_Bool *scale_down);
206
207 /**
208  * Set if the image fills the entire object area, when keeping the aspect ratio.
209  *
210  * @param obj The image object
211  * @param fill_outside @c EINA_TRUE if the object is filled outside,
212  * @c EINA_FALSE otherwise. Default is @c EINA_FALSE.
213  *
214  * When the image should keep its aspect ratio even if resized to another
215  * aspect ratio, there are two possibilities to resize it: keep the entire
216  * image inside the limits of height and width of the object (@p fill_outside
217  * is @c EINA_FALSE) or let the extra width or height go outside of the object,
218  * and the image will fill the entire object (@p fill_outside is @c EINA_TRUE).
219  *
220  * @note This option will have no effect if
221  * elm_image_aspect_fixed_set() is set to @c EINA_FALSE.
222  *
223  * @see elm_image_fill_outside_get()
224  * @see elm_image_aspect_fixed_set()
225  *
226  * @ingroup Image
227  */
228 EAPI void             elm_image_fill_outside_set(Evas_Object *obj, Eina_Bool fill_outside);
229
230 /**
231  * Get if the object is filled outside
232  *
233  * @param obj The image object
234  * @return @c EINA_TRUE if the object is filled outside, @c EINA_FALSE otherwise.
235  *
236  * @see elm_image_fill_outside_set()
237  *
238  * @ingroup Image
239  */
240 EAPI Eina_Bool        elm_image_fill_outside_get(const Evas_Object *obj);
241
242 /**
243  * Set the prescale size for the image
244  *
245  * @param obj The image object
246  * @param size The prescale size. This value is used for both width and
247  * height.
248  *
249  * This function sets a new size for pixmap representation of the given
250  * image. It allows the image to be loaded already in the specified size,
251  * reducing the memory usage and load time when loading a big image with load
252  * size set to a smaller size.
253  *
254  * It's equivalent to the elm_bg_load_size_set() function for bg.
255  *
256  * @note this is just a hint, the real size of the pixmap may differ
257  * depending on the type of image being loaded, being bigger than requested.
258  *
259  * @see elm_image_prescale_get()
260  * @see elm_bg_load_size_set()
261  *
262  * @ingroup Image
263  */
264 EAPI void             elm_image_prescale_set(Evas_Object *obj, int size);
265
266 /**
267  * Get the prescale size for the image
268  *
269  * @param obj The image object
270  * @return The prescale size
271  *
272  * @see elm_image_prescale_set()
273  *
274  * @ingroup Image
275  */
276 EAPI int              elm_image_prescale_get(const Evas_Object *obj);
277
278 /**
279  * Set the image orientation.
280  *
281  * @param obj The image object
282  * @param orient The image orientation @ref Elm_Image_Orient
283  *  Default is #ELM_IMAGE_ORIENT_NONE.
284  *
285  * This function allows to rotate or flip the given image.
286  *
287  * @see elm_image_orient_get()
288  * @see @ref Elm_Image_Orient
289  *
290  * @ingroup Image
291  */
292 EAPI void             elm_image_orient_set(Evas_Object *obj, Elm_Image_Orient orient);
293
294 /**
295  * Get the image orientation.
296  *
297  * @param obj The image object
298  * @return The image orientation @ref Elm_Image_Orient
299  *
300  * @see elm_image_orient_set()
301  * @see @ref Elm_Image_Orient
302  *
303  * @ingroup Image
304  */
305 EAPI Elm_Image_Orient elm_image_orient_get(const Evas_Object *obj);
306
307 /**
308  * Make the image 'editable'.
309  *
310  * @param obj Image object.
311  * @param set Turn on or off editability. Default is @c EINA_FALSE.
312  *
313  * This means the image is a valid drag target for drag and drop, and can be
314  * cut or pasted too.
315  *
316  * @ingroup Image
317  */
318 EAPI void             elm_image_editable_set(Evas_Object *obj, Eina_Bool set);
319
320 /**
321  * Check if the image is 'editable'.
322  *
323  * @param obj Image object.
324  * @return Editability.
325  *
326  * A return value of EINA_TRUE means the image is a valid drag target
327  * for drag and drop, and can be cut or pasted too.
328  *
329  * @ingroup Image
330  */
331 EAPI Eina_Bool        elm_image_editable_get(const Evas_Object *obj);
332
333 /**
334  * Get the inlined image object of the image widget.
335  *
336  * @param obj The image object to get the inlined image from
337  * @return The inlined image object, or NULL if none exists
338  *
339  * This function allows one to get the underlying @c Evas_Object of type
340  * Image from this elementary widget. It can be useful to do things like get
341  * the pixel data, save the image to a file, etc.
342  *
343  * @note Be careful to not manipulate it, as it is under control of
344  * elementary.
345  *
346  * @ingroup Image
347  */
348 EAPI Evas_Object     *elm_image_object_get(const Evas_Object *obj);
349
350 /**
351  * Set whether the original aspect ratio of the image should be kept on resize.
352  *
353  * @param obj The image object.
354  * @param fixed @c EINA_TRUE if the image should retain the aspect,
355  * @c EINA_FALSE otherwise.
356  *
357  * The original aspect ratio (width / height) of the image is usually
358  * distorted to match the object's size. Enabling this option will retain
359  * this original aspect, and the way that the image is fit into the object's
360  * area depends on the option set by elm_image_fill_outside_set().
361  *
362  * @see elm_image_aspect_fixed_get()
363  * @see elm_image_fill_outside_set()
364  *
365  * @ingroup Image
366  */
367 EAPI void             elm_image_aspect_fixed_set(Evas_Object *obj, Eina_Bool fixed);
368
369 /**
370  * Get if the object retains the original aspect ratio.
371  *
372  * @param obj The image object.
373  * @return @c EINA_TRUE if the object keeps the original aspect, @c EINA_FALSE
374  * otherwise.
375  *
376  * @ingroup Image
377  */
378 EAPI Eina_Bool        elm_image_aspect_fixed_get(const Evas_Object *obj);
379
380 /**
381  * @}
382  */