Merge "Elementary migration revision 69922 Merge remote-tracking branch 'remotes...
[framework/uifw/elementary.git] / src / lib / elm_bg.h
1 /**
2  * @defgroup Bg Bg
3  *
4  * @image html img/widget/bg/preview-00.png
5  * @image latex img/widget/bg/preview-00.eps
6  *
7  * @brief Background object, used for setting a solid color, image or
8  * Edje group as a background to a window or any container object.
9  *
10  * The bg (background) widget is used for setting (solid) background
11  * decorations to a window (unless it has transparency enabled) or to
12  * any container object. It works just like an image, but has some
13  * properties useful to a background, like setting it to tiled,
14  * centered, scaled or stretched.
15  *
16  * Default content parts of the bg widget that you can use for are:
17  * @li "overlay" - overlay of the bg
18  *
19  * Supported elm_object common APIs.
20  * @li elm_object_part_content_set
21  * @li elm_object_part_content_get
22  * @li elm_object_part_content_unset
23  *
24  * Here is some sample code using it:
25  * @li @ref bg_01_example_page
26  * @li @ref bg_02_example_page
27  * @li @ref bg_03_example_page
28  */
29
30 /**
31  * Identifiers on how a background widget is to display its image --
32  * if it was set to use an image file.
33  *
34  * @see elm_bg_option_set()
35  * @see elm_bg_option_get()
36  *
37  * @ingroup Bg
38  */
39 typedef enum
40 {
41    ELM_BG_OPTION_CENTER, /**< center the background image */
42    ELM_BG_OPTION_SCALE, /**< scale the background image, retaining aspect ratio */
43    ELM_BG_OPTION_STRETCH, /**< stretch the background image to fill the widget's area */
44    ELM_BG_OPTION_TILE, /**< tile background image at its original size */
45    ELM_BG_OPTION_LAST /**< sentinel value, also used to indicate errors */
46 } Elm_Bg_Option;
47
48 /**
49  * Add a new background to the parent
50  *
51  * @param parent The parent object
52  * @return The new object or NULL if it cannot be created
53  *
54  * @ingroup Bg
55  */
56 EAPI Evas_Object                 *elm_bg_add(Evas_Object *parent);
57
58 /**
59  * Set the file (image or edje collection) to give life for the
60  * background
61  *
62  * @param obj The background object handle
63  * @param file The file path
64  * @param group Optional key (group in Edje) within the file
65  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise
66  *
67  * This sets the image file used in the background object. If the
68  * image comes from an Edje group, it will be stretched to completely
69  * fill the background object. If it comes from a traditional image file, it
70  * will by default be centered in this widget's are (thus retaining
71  * its aspect), what could lead to some parts being not visible. You
72  * may change the mode of exhibition for a real image file with
73  * elm_bg_option_set().
74  *
75  * @note Once the image of @p obj is set, a previously set one will be
76  * deleted, even if @p file is NULL.
77  *
78  * @note This will only affect the contents of one of the background's
79  * swallow spots, namely @c "elm.swallow.background". If you want to
80  * achieve the @c Layout's file setting behavior, you'll have to call
81  * that method on this object.
82  *
83  * @ingroup Bg
84  */
85 EAPI Eina_Bool                    elm_bg_file_set(Evas_Object *obj, const char *file, const char *group);
86
87 /**
88  * Get the file (image or edje collection) set on a given background
89  * widget
90  *
91  * @param obj The background object handle
92  * @param file Where to store the requested file's path
93  * @param group Where to store the optional key within @a file, @b if
94  * it's an Edje file
95  *
96  * @note Use @c NULL pointers on the file components you're not
97  * interested in: they'll be ignored by the function.
98  *
99  * @ingroup Bg
100  */
101 EAPI void                         elm_bg_file_get(const Evas_Object *obj, const char **file, const char **group);
102
103 /**
104  * Set the mode of display for a given background widget's image
105  *
106  * @param obj The background object handle
107  * @param option The desired background option (see #Elm_Bg_Option)
108  *
109  * This sets how the background widget will display its image. This
110  * will only work if the elm_bg_file_set() was previously called with
111  * an image file on @a obj. The image can be display tiled, scaled,
112  * centered or stretched.
113  *
114  * @see elm_bg_option_get()
115  *
116  * @ingroup Bg
117  */
118 EAPI void                         elm_bg_option_set(Evas_Object *obj, Elm_Bg_Option option);
119
120 /**
121  * Get the mode of display for a given background widget's image
122  *
123  * @param obj The background object handle
124  * @return The image displaying mode in use for @a obj or
125  * #ELM_BG_OPTION_LAST, on errors.
126  *
127  * @see elm_bg_option_set() for more details
128  *
129  * @ingroup Bg
130  */
131 EAPI Elm_Bg_Option                elm_bg_option_get(const Evas_Object *obj);
132
133 /**
134  * Set the color on a given background widget
135  *
136  * @param obj The background object handle
137  * @param r The red color component's value
138  * @param g The green color component's value
139  * @param b The blue color component's value
140  *
141  * This sets the color used for the background rectangle, in RGB
142  * format. Each color component's range is from 0 to 255.
143  *
144  * @note You probably only want to use this function if you haven't
145  * previously called elm_bg_file_set(), so that you just want a solid
146  * color background.
147  *
148  * @see elm_bg_color_get()
149  *
150  * @ingroup Bg
151  */
152 EAPI void                         elm_bg_color_set(Evas_Object *obj, int r, int g, int b);
153
154 /**
155  * Get the color set on a given background widget
156  *
157  * @param obj The background object handle
158  * @param r Where to store the red color component's value
159  * @param g Where to store the green color component's value
160  * @param b Where to store the blue color component's value
161  *
162  * @note Use @c NULL pointers on the file components you're not
163  * interested in: they'll be ignored by the function.
164  *
165  * @see elm_bg_color_get() for more details
166  *
167  * @ingroup Bg
168  */
169 EAPI void                         elm_bg_color_get(const Evas_Object *obj, int *r, int *g, int *b);
170
171 /**
172  * Set the size of the pixmap representation of the image set on a
173  * given background widget.
174  *
175  * @param obj The background object handle
176  * @param w The new width of the image pixmap representation.
177  * @param h The new height of the image pixmap representation.
178  *
179  * @warning This function just makes sense if an image file was set on
180  * @p obj, with elm_bg_file_set().
181  *
182  * This function sets a new size for pixmap representation of the
183  * given bg image. It allows for the image to be loaded already in the
184  * specified size, reducing the memory usage and load time (for
185  * example, when loading a big image file with its load size set to a
186  * smaller size)
187  *
188  * @note This is just a hint for the underlying system. The real size
189  * of the pixmap may differ depending on the type of image being
190  * loaded, being bigger than requested.
191  *
192  * @ingroup Bg
193  */
194 EAPI void                         elm_bg_load_size_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
195
196 /**
197  * @}
198  */