
\begin{DoxyCodeInclude}
\textcolor{comment}{//Compile with:}
\textcolor{comment}{//gcc -o bg\_example\_03 bg\_example\_03.c -g `pkg-config --cflags --libs elementary`}
\textcolor{comment}{//where directory is the a path where images/plant\_01.jpg can be found.}

\textcolor{preprocessor}{#include <Elementary.h>}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_cb\_radio\_changed(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   Evas\_Object *o\_bg = data;

   elm_bg_option_set(o\_bg, elm_radio_value_get((Evas\_Object *)obj));
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_cb\_overlay\_changed(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   Evas\_Object *o\_bg = data;

   \textcolor{keywordflow}{if} (elm_check_state_get(obj))
     \{
        Evas\_Object *parent, *over;
        \textcolor{keywordtype}{char} buff[PATH\_MAX];

        snprintf(buff, \textcolor{keyword}{sizeof}(buff), \textcolor{stringliteral}{"%s/objects/test.edj"}, elm_app_data_dir_get());
        parent = elm_object_parent_widget_get(o\_bg);
        over = edje\_object\_add(evas\_object\_evas\_get(parent));
        edje\_object\_file\_set(over, buff, \textcolor{stringliteral}{"bg\_overlay"});
        elm_object_part_content_set(o\_bg, \textcolor{stringliteral}{"overlay"}, over);
     \}
   \textcolor{keywordflow}{else}
     elm_object_part_content_set(o\_bg, \textcolor{stringliteral}{"overlay"}, NULL);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_cb\_color\_changed(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   Evas\_Object *o\_bg = data;
   \textcolor{keywordtype}{double} val = 0.0;

   val = elm_spinner_value_get(obj);
   \textcolor{keywordflow}{if} (val == 1.0)
     elm_bg_color_set(o\_bg, 255, 255, 255);
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (val == 2.0)
     elm_bg_color_set(o\_bg, 255, 0, 0);
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (val == 3.0)
     elm_bg_color_set(o\_bg, 0, 0, 255);
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (val == 4.0)
     elm_bg_color_set(o\_bg, 0, 255, 0);
\}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   Evas\_Object *win;
   Evas\_Object *box, *hbox, *o\_bg;
   Evas\_Object *rd, *rdg;
   \textcolor{keywordtype}{char} buf[PATH\_MAX];

   elm_policy_set(ELM\_POLICY\_QUIT, ELM\_POLICY\_QUIT\_LAST\_WINDOW\_CLOSED);
   elm_app_info_set(elm\_main, \textcolor{stringliteral}{"elementary"}, \textcolor{stringliteral}{"objects/test.edj"});

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"bg-options"}, \textcolor{stringliteral}{"Bg Options"});
   elm_win_autodel_set(win, EINA\_TRUE);

   box = elm_box_add(win);
   evas\_object\_size\_hint\_weight\_set(box, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm_win_resize_object_add(win, box);
   evas\_object\_show(box);

   o\_bg = elm_bg_add(win);
   snprintf(buf, \textcolor{keyword}{sizeof}(buf), \textcolor{stringliteral}{"%s/images/plant\_01.jpg"}, elm_app_data_dir_get());
   elm_bg_file_set(o\_bg, buf, NULL);
   evas\_object\_size\_hint\_weight\_set(o\_bg, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(o\_bg, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm_box_pack_end(box, o\_bg);
   evas\_object\_show(o\_bg);

   hbox = elm_box_add(win);
   elm_box_horizontal_set(hbox, EINA\_TRUE);
   evas\_object\_size\_hint\_weight\_set(hbox, EVAS\_HINT\_EXPAND, EVAS\_HINT\_FILL);
   evas\_object\_size\_hint\_align\_set(hbox, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);

   rd = elm_radio_add(win);
   elm_radio_state_value_set(rd, ELM\_BG\_OPTION\_CENTER);
   elm\_object\_text\_set(rd, \textcolor{stringliteral}{"Center"});
   evas\_object\_size\_hint\_weight\_set(rd, EVAS\_HINT\_EXPAND, EVAS\_HINT\_FILL);
   evas\_object\_smart\_callback\_add(rd, \textcolor{stringliteral}{"changed"}, \_cb\_radio\_changed, o\_bg);
   elm_box_pack_end(hbox, rd);
   evas\_object\_show(rd);
   rdg = rd;

   rd = elm_radio_add(win);
   elm_radio_state_value_set(rd, ELM_BG_OPTION_SCALE);
   elm_radio_group_add(rd, rdg);
   elm\_object\_text\_set(rd, \textcolor{stringliteral}{"Scale"});
   evas\_object\_size\_hint\_weight\_set(rd, EVAS\_HINT\_EXPAND, EVAS\_HINT\_FILL);
   evas\_object\_smart\_callback\_add(rd, \textcolor{stringliteral}{"changed"}, \_cb\_radio\_changed, o\_bg);
   elm_box_pack_end(hbox, rd);
   evas\_object\_show(rd);

   rd = elm_radio_add(win);
   elm_radio_state_value_set(rd, ELM_BG_OPTION_STRETCH);
   elm_radio_group_add(rd, rdg);
   elm\_object\_text\_set(rd, \textcolor{stringliteral}{"Stretch"});
   evas\_object\_size\_hint\_weight\_set(rd, EVAS\_HINT\_EXPAND, EVAS\_HINT\_FILL);
   evas\_object\_smart\_callback\_add(rd, \textcolor{stringliteral}{"changed"}, \_cb\_radio\_changed, o\_bg);
   elm_box_pack_end(hbox, rd);
   evas\_object\_show(rd);

   rd = elm_radio_add(win);
   elm_radio_state_value_set(rd, ELM_BG_OPTION_TILE);
   elm_radio_group_add(rd, rdg);
   elm\_object\_text\_set(rd, \textcolor{stringliteral}{"Tile"});
   evas\_object\_size\_hint\_weight\_set(rd, EVAS\_HINT\_EXPAND, EVAS\_HINT\_FILL);
   evas\_object\_smart\_callback\_add(rd, \textcolor{stringliteral}{"changed"}, \_cb\_radio\_changed, o\_bg);
   elm_box_pack_end(hbox, rd);
   evas\_object\_show(rd);

   elm_radio_value_set(rdg, ELM_BG_OPTION_SCALE);

   rd = elm_check_add(win);
   elm\_object\_text\_set(rd, \textcolor{stringliteral}{"Show Overlay"});
   evas\_object\_size\_hint\_weight\_set(rd, EVAS\_HINT\_EXPAND, EVAS\_HINT\_FILL);
   evas\_object\_smart\_callback\_add(rd, \textcolor{stringliteral}{"changed"}, \_cb\_overlay\_changed, o\_bg);
   elm_box_pack_end(hbox, rd);
   evas\_object\_show(rd);

   \textcolor{comment}{/* color choices ... this is ghetto, but we don't have a 'colorpicker'}
\textcolor{comment}{    * widget yet :( */}
   rd = elm_spinner_add(win);
   elm_object_style_set(rd, \textcolor{stringliteral}{"vertical"});
   elm_spinner_min_max_set(rd, 1, 4);
   elm_spinner_label_format_set(rd, \textcolor{stringliteral}{"%.0f"});
   elm_spinner_editable_set(rd, EINA\_FALSE);
   elm_spinner_special_value_add(rd, 1, \textcolor{stringliteral}{"White"});
   elm_spinner_special_value_add(rd, 2, \textcolor{stringliteral}{"Red"});
   elm_spinner_special_value_add(rd, 3, \textcolor{stringliteral}{"Blue"});
   elm_spinner_special_value_add(rd, 4, \textcolor{stringliteral}{"Green"});
   evas\_object\_size\_hint\_weight\_set(rd, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(rd, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   evas\_object\_smart\_callback\_add(rd, \textcolor{stringliteral}{"changed"}, \_cb\_color\_changed, o\_bg);
   elm_box_pack_end(hbox, rd);
   evas\_object\_show(rd);

   elm_box_pack_end(box, hbox);
   evas\_object\_show(hbox);

   evas\_object\_resize(win, 460, 320);
   evas\_object\_show(win);

   elm_run();

   \textcolor{keywordflow}{return} 0;
\}
ELM_MAIN()
\end{DoxyCodeInclude}
 