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