

The full code for this example can be found at \mbox{\hyperlink{bg_example_03_c}{bg\+\_\+example\+\_\+03.\+c}}, in the function {\ttfamily test\+\_\+bg\+\_\+options}, with the callbacks {\ttfamily \+\_\+cb\+\_\+overlay\+\_\+changed}, {\ttfamily \+\_\+cb\+\_\+color\+\_\+changed} and {\ttfamily \+\_\+cb\+\_\+radio\+\_\+changed} defined in the beginning of the file. It\textquotesingle{}s part of the {\ttfamily elementary\+\_\+test} suite, and thus has the code for the three examples referenced by this documentation.

This example will show the properties available for the background object, and will use of some more widgets to set them.

In order to do this, we will set some callbacks for these widgets. The first is for the radio buttons that will be used to choose the option passed as argument to \mbox{\hyperlink{group__Elm__Bg_ga2ed059b3cf946d10a12182fedc3125f9}{elm\+\_\+bg\+\_\+option\+\_\+set()}}\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_cb\_radio\_changed(\textcolor{keywordtype}{void}\ *data,\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *obj,\ \textcolor{keywordtype}{void}\ *event\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *o\_bg\ =\ data;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Bg_ga2ed059b3cf946d10a12182fedc3125f9}{elm\_bg\_option\_set}}(o\_bg,\ \mbox{\hyperlink{group__Elm__Radio__Group_gab56d65001a82eea600b41e4873a772e6}{elm\_radio\_value\_get}}((\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *)obj));}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 The next callback will be used when setting the overlay (using elm\+\_\+object\+\_\+content\+\_\+set())\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_cb\_overlay\_changed(\textcolor{keywordtype}{void}\ *data,\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *obj,\ \textcolor{keywordtype}{void}\ *event\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *o\_bg\ =\ data;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (\mbox{\hyperlink{group__Elm__Check_ga011ed8bd33b24ab9be27d7f162b80846}{elm\_check\_state\_get}}(obj))}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *parent,\ *over;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordtype}{char}\ buff[PATH\_MAX];}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ snprintf(buff,\ \textcolor{keyword}{sizeof}(buff),\ \textcolor{stringliteral}{"{}\%s/objects/test.edj"{}},\ \mbox{\hyperlink{group__Elm__App_gab10cf98c5aa3936dfda01d6bca366d09}{elm\_app\_data\_dir\_get}}());}
\DoxyCodeLine{\ \ \ \ \ \ \ \ parent\ =\ \mbox{\hyperlink{group__Elm__WidgetNavigation_ga958eee73092bf0da7ba0f422519fdb72}{elm\_object\_parent\_widget\_get}}(o\_bg);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ over\ =\ \mbox{\hyperlink{group__Edje__Object__Group_ga5548cef32568746f40df9bd0be339bea}{edje\_object\_add}}(\mbox{\hyperlink{group__Evas__Object__Group_ga7e211219d11abced5f3089362f7476b9}{evas\_object\_evas\_get}}(parent));}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Edje__Object__Group_gaec1edd24b5bd8e82823759a8dddc1996}{edje\_object\_file\_set}}(over,\ buff,\ \textcolor{stringliteral}{"{}bg\_overlay"{}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Elm__General_ga0531ec8867c72def7c780601764ca642}{elm\_object\_part\_content\_set}}(o\_bg,\ \textcolor{stringliteral}{"{}overlay"{}},\ over);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{\ \ \ \ \ \mbox{\hyperlink{group__Elm__General_ga0531ec8867c72def7c780601764ca642}{elm\_object\_part\_content\_set}}(o\_bg,\ \textcolor{stringliteral}{"{}overlay"{}},\ NULL);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 And the last one, used to set the color (with \mbox{\hyperlink{group__Elm__Bg_ga9431af239574a212be6988d618be5ae8}{elm\+\_\+bg\+\_\+color\+\_\+set()}})\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_cb\_color\_changed(\textcolor{keywordtype}{void}\ *data,\ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *obj,\ \textcolor{keywordtype}{void}\ *event\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}\ *o\_bg\ =\ data;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{double}\ val\ =\ 0.0;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ val\ =\ \mbox{\hyperlink{group__Elm__Spinner__Group_ga0f93a325d38ad9a249994a7dc4ea4f1b}{elm\_spinner\_value\_get}}(obj);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (\mbox{\hyperlink{group__Eina__Tools__Group_ga6bee37244b675b83d6a4f044a7a3d1e8}{EINA\_DBL\_EQ}}(val,\ 1.0))}
\DoxyCodeLine{\ \ \ \ \ \mbox{\hyperlink{group__Elm__Bg_ga9431af239574a212be6988d618be5ae8}{elm\_bg\_color\_set}}(o\_bg,\ 255,\ 255,\ 255);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (\mbox{\hyperlink{group__Eina__Tools__Group_ga6bee37244b675b83d6a4f044a7a3d1e8}{EINA\_DBL\_EQ}}(val,\ 2.0))}
\DoxyCodeLine{\ \ \ \ \ \mbox{\hyperlink{group__Elm__Bg_ga9431af239574a212be6988d618be5ae8}{elm\_bg\_color\_set}}(o\_bg,\ 255,\ 0,\ 0);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (\mbox{\hyperlink{group__Eina__Tools__Group_ga6bee37244b675b83d6a4f044a7a3d1e8}{EINA\_DBL\_EQ}}(val,\ 3.0))}
\DoxyCodeLine{\ \ \ \ \ \mbox{\hyperlink{group__Elm__Bg_ga9431af239574a212be6988d618be5ae8}{elm\_bg\_color\_set}}(o\_bg,\ 0,\ 0,\ 255);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (\mbox{\hyperlink{group__Eina__Tools__Group_ga6bee37244b675b83d6a4f044a7a3d1e8}{EINA\_DBL\_EQ}}(val,\ 4.0))}
\DoxyCodeLine{\ \ \ \ \ \mbox{\hyperlink{group__Elm__Bg_ga9431af239574a212be6988d618be5ae8}{elm\_bg\_color\_set}}(o\_bg,\ 0,\ 255,\ 0);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 We will get back to what these functions do soon. If you want to know more about how to set these callbacks and what these widgets are, look for\+: \begin{DoxyItemize}
\item \mbox{\hyperlink{group__Elm__Radio__Group_ga55ac57f03ef5a581b1fee0dce02961d2}{elm\+\_\+radio\+\_\+add()}} \item \mbox{\hyperlink{group__Elm__Check_ga467a6a6215c116a18664aa40fc95f4e3}{elm\+\_\+check\+\_\+add()}} \item \mbox{\hyperlink{group__Elm__Spinner__Group_ga31416c7caa40b21480fd3e3fc7b40dce}{elm\+\_\+spinner\+\_\+add()}}\end{DoxyItemize}
Now going to the main function, {\ttfamily test\+\_\+bg\+\_\+options}, we have the common code with the other examples\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ win\ =\ \mbox{\hyperlink{group__Elm__Win__Group_ga23d9d1ffa0a65a1a1dd482d570db1ba0}{elm\_win\_util\_standard\_add}}(\textcolor{stringliteral}{"{}bg-\/options"{}},\ \textcolor{stringliteral}{"{}Bg\ Options"{}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Win__Group_ga9a16a2f8c9fd5b6e9203ed9dcb53ea8b}{elm\_win\_autodel\_set}}(win,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}

\end{DoxyCodeInclude}
 We add a plain background to this window, so it will have the default background color behind everything\+:


\begin{DoxyCodeInclude}{0}

\end{DoxyCodeInclude}
 Then we add a vertical box (\mbox{\hyperlink{group__Elm__Box__Group_ga49ec615c90bf8bead2158d5ffab2e445}{elm\+\_\+box\+\_\+add()}}) that will hold the background object that we are going to play with, as well as a horizontal box that will hold widgets\+:


\begin{DoxyCodeInclude}{0}

\end{DoxyCodeInclude}
 Now we add the background object that is going to be of use for our example. It is an image background, as used in \mbox{\hyperlink{bg_02_example_page}{elm\+\_\+bg -\/ Image background.}} , so the code should be familiar\+:


\begin{DoxyCodeInclude}{0}

\end{DoxyCodeInclude}
 Notice the call to \mbox{\hyperlink{group__Elm__Box__Group_ga66a10dd861578521af2ab7b8c2ca65c5}{elm\+\_\+box\+\_\+pack\+\_\+end()}}\+: it will pack the background object in the end of the Elementary box declared above. Just refer to that documentation for more info.

Since this Elementary background is already an image background, we are going to play with its other properties. We will change its option (CENTER, SCALE, STRETCH, TILE), its color (RGB), and add an overlay to it. For all of these properties, we are going to add widgets that will configure them.

First, lets add the horizontal box that will hold these widgets\+: 
\begin{DoxyCodeInclude}{0}

\end{DoxyCodeInclude}
 For now, just consider this {\ttfamily hbox} as a rectangle that will contain the widgets, and will distribute them horizontally inside its content. Then we add radio buttons that will allow us to choose the property to use with this background\+:


\begin{DoxyCodeInclude}{0}

\end{DoxyCodeInclude}
 Again, I won\textquotesingle{}t give details about the use of these widgets, just look for their documentation if necessary. It\textquotesingle{}s enough to know for now that we are packing them in the {\ttfamily hbox}, setting a label for them, and the most important parts\+: setting its value to {\ttfamily ELM\+\_\+\+BG\+\_\+\+OPTION\+\_\+\+CENTER} and its callback to {\ttfamily \+\_\+cb\+\_\+radio\+\_\+changed} (the function defined in the beginning of this example). We do this for the next 3 radio buttons added after this one, each of them with a different value.

Now taking a look at the code of the callback {\ttfamily \+\_\+cb\+\_\+radio\+\_\+changed} again, it will call \mbox{\hyperlink{group__Elm__Bg_ga2ed059b3cf946d10a12182fedc3125f9}{elm\+\_\+bg\+\_\+option\+\_\+set()}} with the value set from the checked radio button, thus setting the option for this background. The background is passed as argument to the {\ttfamily data} parameter of this callback, and is referenced here as {\ttfamily o\+\_\+bg}.

Later we set the default value for this radio button\+:


\begin{DoxyCodeInclude}{0}

\end{DoxyCodeInclude}
 Then we add a checkbox for the elm\+\_\+object\+\_\+content\+\_\+set() function for the bg\+:


\begin{DoxyCodeInclude}{0}

\end{DoxyCodeInclude}
 Now look at the code of the {\ttfamily \+\_\+cb\+\_\+overlay\+\_\+changed} again. If the checkbox state is checked, an overlay will be added to the background. It\textquotesingle{}s done by creating an Edje object, and setting it with elm\+\_\+object\+\_\+content\+\_\+set() to the background object. For information about what are and how to set Edje object, look at the Edje documentation.

Finally we add a spinner object (\mbox{\hyperlink{group__Elm__Spinner__Group_ga31416c7caa40b21480fd3e3fc7b40dce}{elm\+\_\+spinner\+\_\+add()}}) to be used to select the color of our background. In its callback it\textquotesingle{}s possible to see the call to \mbox{\hyperlink{group__Elm__Bg_ga9431af239574a212be6988d618be5ae8}{elm\+\_\+bg\+\_\+color\+\_\+set()}}, which will change the color of this background. This color is used by the background to fill areas where the image doesn\textquotesingle{}t cover (in this case, where we have an image background). The spinner is also packed into the {\ttfamily hbox} \+:


\begin{DoxyCodeInclude}{0}

\end{DoxyCodeInclude}
 Then we just have to pack the {\ttfamily hbox} inside the {\ttfamily box}, set some size hints, and show our window\+:


\begin{DoxyCodeInclude}{0}

\end{DoxyCodeInclude}
 Now to see this code in action, open elementary\+\_\+test, and go to the \char`\"{}\+Bg \+Options\char`\"{} test. It should demonstrate what was implemented here. 