fomatting of headers -> fixup. and documentation fixing.
[framework/uifw/elementary.git] / src / lib / elm_icon.h
1 /**
2  * @defgroup Icon Icon
3  *
4  * @image html img/widget/icon/preview-00.png
5  * @image latex img/widget/icon/preview-00.eps
6  *
7  * An object that provides standard icon images (delete, edit, arrows, etc.)
8  * or a custom file (PNG, JPG, EDJE, etc.) used for an icon.
9  *
10  * The icon image requested can be in the elementary theme, or in the
11  * freedesktop.org paths. It's possible to set the order of preference from
12  * where the image will be used.
13  *
14  * This API is very similar to @ref Image, but with ready to use images.
15  *
16  * Default images provided by the theme are described below.
17  *
18  * The first list contains icons that were first intended to be used in
19  * toolbars, but can be used in many other places too:
20  * @li home
21  * @li close
22  * @li apps
23  * @li arrow_up
24  * @li arrow_down
25  * @li arrow_left
26  * @li arrow_right
27  * @li chat
28  * @li clock
29  * @li delete
30  * @li edit
31  * @li refresh
32  * @li folder
33  * @li file
34  *
35  * Now some icons that were designed to be used in menus (but again, you can
36  * use them anywhere else):
37  * @li menu/home
38  * @li menu/close
39  * @li menu/apps
40  * @li menu/arrow_up
41  * @li menu/arrow_down
42  * @li menu/arrow_left
43  * @li menu/arrow_right
44  * @li menu/chat
45  * @li menu/clock
46  * @li menu/delete
47  * @li menu/edit
48  * @li menu/refresh
49  * @li menu/folder
50  * @li menu/file
51  *
52  * And here we have some media player specific icons:
53  * @li media_player/forward
54  * @li media_player/info
55  * @li media_player/next
56  * @li media_player/pause
57  * @li media_player/play
58  * @li media_player/prev
59  * @li media_player/rewind
60  * @li media_player/stop
61  *
62  * Signals that you can add callbacks for are:
63  *
64  * "clicked" - This is called when a user has clicked the icon
65  *
66  * An example of usage for this API follows:
67  * @li @ref tutorial_icon
68  */
69
70 /**
71  * @addtogroup Icon
72  * @{
73  */
74
75 typedef enum _Elm_Icon_Type
76 {
77    ELM_ICON_NONE,
78    ELM_ICON_FILE,
79    ELM_ICON_STANDARD
80 } Elm_Icon_Type;
81
82 /**
83  * @enum _Elm_Icon_Lookup_Order
84  * @typedef Elm_Icon_Lookup_Order
85  *
86  * Lookup order used by elm_icon_standard_set(). Should look for icons in the
87  * theme, FDO paths, or both?
88  *
89  * @ingroup Icon
90  */
91 typedef enum _Elm_Icon_Lookup_Order
92 {
93    ELM_ICON_LOOKUP_FDO_THEME, /**< icon look up order: freedesktop, theme */
94    ELM_ICON_LOOKUP_THEME_FDO, /**< icon look up order: theme, freedesktop */
95    ELM_ICON_LOOKUP_FDO, /**< icon look up order: freedesktop */
96    ELM_ICON_LOOKUP_THEME /**< icon look up order: theme */
97 } Elm_Icon_Lookup_Order;
98
99 /**
100  * Add a new icon object to the parent.
101  *
102  * @param parent The parent object
103  * @return The new object or NULL if it cannot be created
104  *
105  * @see elm_icon_file_set()
106  *
107  * @ingroup Icon
108  */
109 EAPI Evas_Object *
110                            elm_icon_add(Evas_Object *parent)
111 EINA_ARG_NONNULL(1);
112
113 /**
114  * Set the file that will be used as icon.
115  *
116  * @param obj The icon object
117  * @param file The path to file that will be used as icon image
118  * @param group The group that the icon belongs to an edje file
119  *
120  * @return (@c EINA_TRUE = success, @c EINA_FALSE = error)
121  *
122  * @note The icon image set by this function can be changed by
123  * elm_icon_standard_set().
124  *
125  * @see elm_icon_file_get()
126  *
127  * @ingroup Icon
128  */
129 EAPI Eina_Bool             elm_icon_file_set(Evas_Object *obj, const char *file, const char *group) EINA_ARG_NONNULL(1, 2);
130
131 /**
132  * Set a location in memory to be used as an icon
133  *
134  * @param obj The icon object
135  * @param img The binary data that will be used as an image
136  * @param size The size of binary data @p img
137  * @param format Optional format of @p img to pass to the image loader
138  * @param key Optional key of @p img to pass to the image loader (eg. if @p img is an edje file)
139  *
140  * The @p format string should be something like "png", "jpg", "tga",
141  * "tiff", "bmp" etc. if it is provided (NULL if not). This improves
142  * the loader performance as it tries the "correct" loader first before
143  * trying a range of other possible loaders until one succeeds.
144  *
145  * @return (@c EINA_TRUE = success, @c EINA_FALSE = error)
146  *
147  * @note The icon image set by this function can be changed by
148  * elm_icon_standard_set().
149  *
150  * @ingroup Icon
151  */
152 EAPI Eina_Bool             elm_icon_memfile_set(Evas_Object *obj, const void *img, size_t size, const char *format, const char *key) EINA_ARG_NONNULL(1, 2);
153
154 /**
155  * Get the file that will be used as icon.
156  *
157  * @param obj The icon object
158  * @param file The path to file that will be used as the icon image
159  * @param group The group that the icon belongs to, in edje file
160  *
161  * @see elm_icon_file_set()
162  *
163  * @ingroup Icon
164  */
165 EAPI void                  elm_icon_file_get(const Evas_Object *obj, const char **file, const char **group) EINA_ARG_NONNULL(1);
166
167 /**
168  * Set the file that will be used, but use a generated thumbnail.
169  *
170  * @param obj The icon object
171  * @param file The path to file that will be used as icon image
172  * @param group The group that the icon belongs to an edje file
173  *
174  * This functions like elm_icon_file_set() but requires the Ethumb library
175  * support to be enabled successfully with elm_need_ethumb(). When set
176  * the file indicated has a thumbnail generated and cached on disk for
177  * future use or will directly use an existing cached thumbnail if it
178  * is valid.
179  *
180  * @see elm_icon_file_set()
181  *
182  * @ingroup Icon
183  */
184 EAPI void                  elm_icon_thumb_set(Evas_Object *obj, const char *file, const char *group) EINA_ARG_NONNULL(1, 2);
185
186 /**
187  * Set the icon by icon standards names.
188  *
189  * @param obj The icon object
190  * @param name The icon name
191  *
192  * @return (@c EINA_TRUE = success, @c EINA_FALSE = error)
193  *
194  * For example, freedesktop.org defines standard icon names such as "home",
195  * "network", etc. There can be different icon sets to match those icon
196  * keys. The @p name given as parameter is one of these "keys", and will be
197  * used to look in the freedesktop.org paths and elementary theme. One can
198  * change the lookup order with elm_icon_order_lookup_set().
199  *
200  * If name is not found in any of the expected locations and it is the
201  * absolute path of an image file, this image will be used.
202  *
203  * @note The icon image set by this function can be changed by
204  * elm_icon_file_set().
205  *
206  * @see elm_icon_standard_get()
207  * @see elm_icon_file_set()
208  *
209  * @ingroup Icon
210  */
211 EAPI Eina_Bool             elm_icon_standard_set(Evas_Object *obj, const char *name) EINA_ARG_NONNULL(1);
212
213 /**
214  * Get the icon name set by icon standard names.
215  *
216  * @param obj The icon object
217  * @return The icon name
218  *
219  * If the icon image was set using elm_icon_file_set() instead of
220  * elm_icon_standard_set(), then this function will return @c NULL.
221  *
222  * @see elm_icon_standard_set()
223  *
224  * @ingroup Icon
225  */
226 EAPI const char           *elm_icon_standard_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
227
228 /**
229  * Set the smooth scaling for an icon object.
230  *
231  * @param obj The icon object
232  * @param smooth @c EINA_TRUE if smooth scaling should be used, @c EINA_FALSE
233  * otherwise. Default is @c EINA_TRUE.
234  *
235  * Set the scaling algorithm to be used when scaling the icon image. Smooth
236  * scaling provides a better resulting image, but is slower.
237  *
238  * The smooth scaling should be disabled when making animations that change
239  * the icon size, since they will be faster. Animations that don't require
240  * resizing of the icon can keep the smooth scaling enabled (even if the icon
241  * is already scaled, since the scaled icon image will be cached).
242  *
243  * @see elm_icon_smooth_get()
244  *
245  * @ingroup Icon
246  */
247 EAPI void                  elm_icon_smooth_set(Evas_Object *obj, Eina_Bool smooth) EINA_ARG_NONNULL(1);
248
249 /**
250  * Get whether smooth scaling is enabled for an icon object.
251  *
252  * @param obj The icon object
253  * @return @c EINA_TRUE if smooth scaling is enabled, @c EINA_FALSE otherwise.
254  *
255  * @see elm_icon_smooth_set()
256  *
257  * @ingroup Icon
258  */
259 EAPI Eina_Bool             elm_icon_smooth_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
260
261 /**
262  * Disable scaling of this object.
263  *
264  * @param obj The icon object.
265  * @param no_scale @c EINA_TRUE if the object is not scalable, @c EINA_FALSE
266  * otherwise. Default is @c EINA_FALSE.
267  *
268  * This function disables scaling of the icon object through the function
269  * elm_object_scale_set(). However, this does not affect the object
270  * size/resize in any way. For that effect, take a look at
271  * elm_icon_scale_set().
272  *
273  * @see elm_icon_no_scale_get()
274  * @see elm_icon_scale_set()
275  * @see elm_object_scale_set()
276  *
277  * @ingroup Icon
278  */
279 EAPI void                  elm_icon_no_scale_set(Evas_Object *obj, Eina_Bool no_scale) EINA_ARG_NONNULL(1);
280
281 /**
282  * Get whether scaling is disabled on the object.
283  *
284  * @param obj The icon object
285  * @return @c EINA_TRUE if scaling is disabled, @c EINA_FALSE otherwise
286  *
287  * @see elm_icon_no_scale_set()
288  *
289  * @ingroup Icon
290  */
291 EAPI Eina_Bool             elm_icon_no_scale_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
292
293 /**
294  * Set if the object is (up/down) resizable.
295  *
296  * @param obj The icon object
297  * @param scale_up A bool to set if the object is resizable up. Default is
298  * @c EINA_TRUE.
299  * @param scale_down A bool to set if the object is resizable down. Default
300  * is @c EINA_TRUE.
301  *
302  * This function limits the icon object resize ability. If @p scale_up is set to
303  * @c EINA_FALSE, the object can't have its height or width resized to a value
304  * higher than the original icon size. Same is valid for @p scale_down.
305  *
306  * @see elm_icon_scale_get()
307  *
308  * @ingroup Icon
309  */
310 EAPI void                  elm_icon_scale_set(Evas_Object *obj, Eina_Bool scale_up, Eina_Bool scale_down) EINA_ARG_NONNULL(1);
311
312 /**
313  * Get if the object is (up/down) resizable.
314  *
315  * @param obj The icon object
316  * @param scale_up A bool to set if the object is resizable up
317  * @param scale_down A bool to set if the object is resizable down
318  *
319  * @see elm_icon_scale_set()
320  *
321  * @ingroup Icon
322  */
323 EAPI void                  elm_icon_scale_get(const Evas_Object *obj, Eina_Bool *scale_up, Eina_Bool *scale_down) EINA_ARG_NONNULL(1);
324
325 /**
326  * Get the object's image size
327  *
328  * @param obj The icon object
329  * @param w A pointer to store the width in
330  * @param h A pointer to store the height in
331  *
332  * @ingroup Icon
333  */
334 EAPI void                  elm_icon_size_get(const Evas_Object *obj, int *w, int *h) EINA_ARG_NONNULL(1);
335
336 /**
337  * Set if the icon fill the entire object area.
338  *
339  * @param obj The icon object
340  * @param fill_outside @c EINA_TRUE if the object is filled outside,
341  * @c EINA_FALSE otherwise. Default is @c EINA_FALSE.
342  *
343  * When the icon object is resized to a different aspect ratio from the
344  * original icon image, the icon image will still keep its aspect. This flag
345  * tells how the image should fill the object's area. They are: keep the
346  * entire icon inside the limits of height and width of the object (@p
347  * fill_outside is @c EINA_FALSE) or let the extra width or height go outside
348  * of the object, and the icon will fill the entire object (@p fill_outside
349  * is @c EINA_TRUE).
350  *
351  * @note Unlike @ref Image, there's no option in icon to set the aspect ratio
352  * retain property to false. Thus, the icon image will always keep its
353  * original aspect ratio.
354  *
355  * @see elm_icon_fill_outside_get()
356  * @see elm_image_fill_outside_set()
357  *
358  * @ingroup Icon
359  */
360 EAPI void                  elm_icon_fill_outside_set(Evas_Object *obj, Eina_Bool fill_outside) EINA_ARG_NONNULL(1);
361
362 /**
363  * Get if the object is filled outside.
364  *
365  * @param obj The icon object
366  * @return @c EINA_TRUE if the object is filled outside, @c EINA_FALSE otherwise.
367  *
368  * @see elm_icon_fill_outside_set()
369  *
370  * @ingroup Icon
371  */
372 EAPI Eina_Bool             elm_icon_fill_outside_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
373
374 /**
375  * Set the prescale size for the icon.
376  *
377  * @param obj The icon object
378  * @param size The prescale size. This value is used for both width and
379  * height.
380  *
381  * This function sets a new size for pixmap representation of the given
382  * icon. It allows the icon to be loaded already in the specified size,
383  * reducing the memory usage and load time when loading a big icon with load
384  * size set to a smaller size.
385  *
386  * It's equivalent to the elm_bg_load_size_set() function for bg.
387  *
388  * @note this is just a hint, the real size of the pixmap may differ
389  * depending on the type of icon being loaded, being bigger than requested.
390  *
391  * @see elm_icon_prescale_get()
392  * @see elm_bg_load_size_set()
393  *
394  * @ingroup Icon
395  */
396 EAPI void                  elm_icon_prescale_set(Evas_Object *obj, int size) EINA_ARG_NONNULL(1);
397
398 /**
399  * Get the prescale size for the icon.
400  *
401  * @param obj The icon object
402  * @return The prescale size
403  *
404  * @see elm_icon_prescale_set()
405  *
406  * @ingroup Icon
407  */
408 EAPI int                   elm_icon_prescale_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
409
410 /**
411  * Gets the image object of the icon. DO NOT MODIFY THIS.
412  *
413  * @param obj The icon object
414  * @return The internal icon object
415  *
416  * @ingroup Icon
417  */
418 EAPI Evas_Object          *elm_icon_object_get(Evas_Object *obj) EINA_ARG_NONNULL(1);
419
420 /**
421  * Sets the icon lookup order used by elm_icon_standard_set().
422  *
423  * @param obj The icon object
424  * @param order The icon lookup order (can be one of
425  * ELM_ICON_LOOKUP_FDO_THEME, ELM_ICON_LOOKUP_THEME_FDO, ELM_ICON_LOOKUP_FDO
426  * or ELM_ICON_LOOKUP_THEME)
427  *
428  * @see elm_icon_order_lookup_get()
429  * @see Elm_Icon_Lookup_Order
430  *
431  * @ingroup Icon
432  */
433 EAPI void                  elm_icon_order_lookup_set(Evas_Object *obj, Elm_Icon_Lookup_Order order) EINA_ARG_NONNULL(1);
434
435 /**
436  * Gets the icon lookup order.
437  *
438  * @param obj The icon object
439  * @return The icon lookup order
440  *
441  * @see elm_icon_order_lookup_set()
442  * @see Elm_Icon_Lookup_Order
443  *
444  * @ingroup Icon
445  */
446 EAPI Elm_Icon_Lookup_Order elm_icon_order_lookup_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
447
448 /**
449  * Enable or disable preloading of the icon
450  *
451  * @param obj The icon object
452  * @param disable If EINA_TRUE, preloading will be disabled
453  * @ingroup Icon
454  */
455 EAPI void                  elm_icon_preload_set(Evas_Object *obj, Eina_Bool disable) EINA_ARG_NONNULL(1);
456
457 /**
458  * Get if the icon supports animation or not.
459  *
460  * @param obj The icon object
461  * @return @c EINA_TRUE if the icon supports animation,
462  *         @c EINA_FALSE otherwise.
463  *
464  * Return if this elm icon's image can be animated. Currently Evas only
465  * supports gif animation. If the return value is EINA_FALSE, other
466  * elm_icon_animated_XXX APIs won't work.
467  * @ingroup Icon
468  */
469 EAPI Eina_Bool             elm_icon_animated_available_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
470
471 /**
472  * Set animation mode of the icon.
473  *
474  * @param obj The icon object
475  * @param anim @c EINA_TRUE if the object do animation job,
476  * @c EINA_FALSE otherwise. Default is @c EINA_FALSE.
477  *
478  * Since the default animation mode is set to EINA_FALSE,
479  * the icon is shown without animation. Files like animated GIF files
480  * can animate, and this is supported if you enable animated support
481  * on the icon.
482  * Set it to EINA_TRUE when the icon needs to be animated.
483  * @ingroup Icon
484  */
485 EAPI void                  elm_icon_animated_set(Evas_Object *obj, Eina_Bool animated) EINA_ARG_NONNULL(1);
486
487 /**
488  * Get animation mode of the icon.
489  *
490  * @param obj The icon object
491  * @return The animation mode of the icon object
492  * @see elm_icon_animated_set
493  * @ingroup Icon
494  */
495 EAPI Eina_Bool             elm_icon_animated_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
496
497 /**
498  * Set animation play mode of the icon.
499  *
500  * @param obj The icon object
501  * @param play @c EINA_TRUE the object play animation images,
502  * @c EINA_FALSE otherwise. Default is @c EINA_FALSE.
503  *
504  * To play elm icon's animation, set play to EINA_TURE.
505  * For example, you make gif player using this set/get API and click event.
506  * This literally lets you control current play or paused state. To have
507  * this work with animated GIF files for example, you first, before
508  * setting the file have to use elm_icon_animated_set() to enable animation
509  * at all on the icon.
510  *
511  * 1. Click event occurs
512  * 2. Check play flag using elm_icon_animaged_play_get
513  * 3. If elm icon was playing, set play to EINA_FALSE.
514  *    Then animation will be stopped and vice versa
515  * @ingroup Icon
516  */
517 EAPI void                  elm_icon_animated_play_set(Evas_Object *obj, Eina_Bool play) EINA_ARG_NONNULL(1);
518
519 /**
520  * Get animation play mode of the icon.
521  *
522  * @param obj The icon object
523  * @return The play mode of the icon object
524  *
525  * @see elm_icon_animated_play_get
526  * @ingroup Icon
527  */
528 EAPI Eina_Bool             elm_icon_animated_play_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
529
530 /**
531  * @}
532  */