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