\chapter{Box example -\/ basic usage}
\hypertarget{tutorial_edje_box}{}\label{tutorial_edje_box}\index{Box example -\/ basic usage@{Box example -\/ basic usage}}
This example shows how to append, insert and remove elements from an Edje box part. It will make use of the edje\+\_\+object\+\_\+part\+\_\+box functions.

To play with this example, use mouse left click to delete an existing rectangle from the box and right mouse click to add a new rectangle just before the clicked one. Use the keyboard keys "{}a"{} to append a rectangle, "{}i"{} to prepend, and "{}c"{} to remove all rectangles from the box.

We will store our example global information in the data structure defined below, and also set some callbacks for resizing the canvas and exiting the window\+:

 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ commands[]\ =\ \(\backslash\)}
\DoxyCodeLine{\ \ \textcolor{stringliteral}{"{}commands\ are:\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \textcolor{stringliteral}{"{}\(\backslash\)ti\ -\/\ prepend\ rectangle\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \textcolor{stringliteral}{"{}\(\backslash\)ta\ -\/\ append\ rectangle\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \textcolor{stringliteral}{"{}\(\backslash\)tc\ -\/\ remove\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \textcolor{stringliteral}{"{}\(\backslash\)tEsc\ -\/\ exit\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \textcolor{stringliteral}{"{}\(\backslash\)th\ -\/\ print\ help\(\backslash\)n"{}};}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_on\_destroy(Ecore\_Evas\ *ee\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}}();}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{/*\ here\ just\ to\ keep\ our\ example's\ window\ size\ and\ background\ image's}}
\DoxyCodeLine{\textcolor{comment}{\ *\ size\ in\ synchrony\ */}}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_on\_canvas\_resize(Ecore\_Evas\ *ee)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ Evas\_Object\ *bg;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *edje\_obj;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{int}\ \ \ \ \ \ \ \ \ \ w;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{int}\ \ \ \ \ \ \ \ \ \ h;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ bg\ =\ \mbox{\hyperlink{group__Ecore__Evas__Group_ga85531b3a6bcbe868d2cf5d32fab99c60}{ecore\_evas\_data\_get}}(ee,\ \textcolor{stringliteral}{"{}background"{}});}
\DoxyCodeLine{\ \ \ edje\_obj\ =\ \mbox{\hyperlink{group__Ecore__Evas__Group_ga85531b3a6bcbe868d2cf5d32fab99c60}{ecore\_evas\_data\_get}}(ee,\ \textcolor{stringliteral}{"{}edje\_obj"{}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_ga931aadf4603731e73e8a84e4b14f1493}{ecore\_evas\_geometry\_get}}(ee,\ NULL,\ NULL,\ \&w,\ \&h);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(bg,\ w,\ h);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(edje\_obj,\ w,\ h);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 In the {\ttfamily main} function, we create our {\ttfamily Ecore\+\_\+\+Evas}, add a background to it, and finally load our {\ttfamily Edje} file that contains a {\ttfamily Box} part. This part is named {\ttfamily "{}example/box"{}} in this case, and we use this name to append elements to it.

The code until now is the one that follows\+:

 
\begin{DoxyCodeInclude}{0}

\end{DoxyCodeInclude}
 Also notice that we set the callback {\ttfamily \+\_\+bg\+\_\+key\+\_\+down} for {\ttfamily "{}key down"{}} events on the background object, and that object is the one with focus.

Now we add some small rectangles to the box part, using the \doxylink{group__Edje__Object__Part_gad50eb55892c1e06edc3928e8fe8baca4}{edje\+\_\+object\+\_\+part\+\_\+box\+\_\+append()} API, and set some callbacks for {\ttfamily "{}mouse down"{}} events on every object. These callbacks will be used to add or delete objects from the box part.

 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ bg\ =\ \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(evas);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(bg,\ 255,\ 255,\ 255,\ 255);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(bg,\ WIDTH,\ HEIGHT);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gac6d65f8896ab59780553676d0017c2ef}{evas\_object\_focus\_set}}(bg,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(bg);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_gaa86c5abd200a02711aced53d27b9ddb2}{ecore\_evas\_data\_set}}(ee,\ \textcolor{stringliteral}{"{}background"{}},\ bg);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Events_gac71a1038dad71da36f57b70c8ad10252}{evas\_object\_event\_callback\_add}}(bg,\ \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968a336b86bad4f145f84c155e4922335584}{EVAS\_CALLBACK\_KEY\_DOWN}},\ \_on\_bg\_key\_down,\ ee);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ edje\_obj\ =\ \mbox{\hyperlink{group__Edje__Object__Group_ga5548cef32568746f40df9bd0be339bea}{edje\_object\_add}}(evas);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Edje__Object__Group_gaec1edd24b5bd8e82823759a8dddc1996}{edje\_object\_file\_set}}(edje\_obj,\ edje\_file,\ \textcolor{stringliteral}{"{}example/group"{}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga335c8ee6eaeaac9710656af4f8b0db91}{evas\_object\_move}}(edje\_obj,\ 0,\ 0);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(edje\_obj,\ WIDTH,\ HEIGHT);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(edje\_obj);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_gaa86c5abd200a02711aced53d27b9ddb2}{ecore\_evas\_data\_set}}(ee,\ \textcolor{stringliteral}{"{}edje\_obj"{}},\ edje\_obj);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ NRECTS;\ i++)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ Evas\_Object\ *rect;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}\ r\ =\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ red\ =\ (i\ *\ 10)\ \%\ 256;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ rect\ =\ \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(evas);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(rect,\ red,\ 0,\ 0,\ 255);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(rect,\ RECTW,\ RECTH);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ r\ =\ \mbox{\hyperlink{group__Edje__Object__Part_gad50eb55892c1e06edc3928e8fe8baca4}{edje\_object\_part\_box\_append}}(edje\_obj,\ \textcolor{stringliteral}{"{}example/box"{}},\ rect);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!r)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}An\ error\ occurred\ when\ appending\ rect\ \#\%d\ to\ the\ box.\(\backslash\)n"{}},\ i);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(rect);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Events_gac71a1038dad71da36f57b70c8ad10252}{evas\_object\_event\_callback\_add}}(}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ rect,\ \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968a9fa52651ccf7e47cd3b7785fc4cf393f}{EVAS\_CALLBACK\_MOUSE\_DOWN}},\ \_on\_rect\_mouse\_down,\ ee);}
\DoxyCodeLine{\ \ \ \ \ \}}

\end{DoxyCodeInclude}
 Now let\textquotesingle{}s take a look at the callbacks for key down and mouse down events\+:

 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_on\_rect\_mouse\_down(\textcolor{keywordtype}{void}\ *data,\ Evas\ *e,\ Evas\_Object\ *o,\ \textcolor{keywordtype}{void}\ *event\_info)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ Ecore\_Evas\ \ \ \ \ \ \ \ \ \ \ \ *ee;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{struct__Evas__Event__Mouse__Down}{Evas\_Event\_Mouse\_Down}}\ *ev;}
\DoxyCodeLine{\ \ \ Evas\_Object\ \ \ \ \ \ \ \ \ \ \ *edje\_obj;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ ee\ =\ (Ecore\_Evas\ *)data;}
\DoxyCodeLine{\ \ \ ev\ =\ (\mbox{\hyperlink{struct__Evas__Event__Mouse__Down}{Evas\_Event\_Mouse\_Down}}\ *)event\_info;}
\DoxyCodeLine{\ \ \ edje\_obj\ =\ \mbox{\hyperlink{group__Ecore__Evas__Group_ga85531b3a6bcbe868d2cf5d32fab99c60}{ecore\_evas\_data\_get}}(ee,\ \textcolor{stringliteral}{"{}edje\_obj"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (ev-\/>\mbox{\hyperlink{struct__Evas__Event__Mouse__Down_a0ab02808721d6c55fc642ecbb37d5ff9}{button}}\ ==\ 1)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Removing\ rect\ \%p\ under\ the\ mouse\ pointer.\(\backslash\)n"{}},\ o);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Edje__Object__Part_ga342784f4bb3a1d52e6fc5ff83336bf30}{edje\_object\_part\_box\_remove}}(edje\_obj,\ \textcolor{stringliteral}{"{}example/box"{}},\ o);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9217cf1d90690dbd1960db155d1c7476}{evas\_object\_del}}(o);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (ev-\/>\mbox{\hyperlink{struct__Evas__Event__Mouse__Down_a0ab02808721d6c55fc642ecbb37d5ff9}{button}}\ ==\ 3)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ Evas\_Object\ *rect;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}\ \ \ \ r;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ rect\ =\ \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(e);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(rect,\ 0,\ 0,\ 255,\ 255);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(rect,\ RECTW\ +\ 10,\ RECTH);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(rect);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Inserting\ rect\ \%p\ before\ the\ rectangle\ under\ the\ mouse\ pointer.\(\backslash\)n"{}},\ rect);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ r\ =\ \mbox{\hyperlink{group__Edje__Object__Part_ga84d72a9952f1cb3ffb2d9a226338e168}{edje\_object\_part\_box\_insert\_before}}(edje\_obj,\ \textcolor{stringliteral}{"{}example/box"{}},\ rect,\ o);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!r)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}An\ error\ occurred\ when\ appending\ rect\ \%p\ to\ the\ box.\(\backslash\)n"{}},\ rect);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Events_gac71a1038dad71da36f57b70c8ad10252}{evas\_object\_event\_callback\_add}}(rect,\ \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968a9fa52651ccf7e47cd3b7785fc4cf393f}{EVAS\_CALLBACK\_MOUSE\_DOWN}},\ \_on\_rect\_mouse\_down,\ NULL);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 This callback for mouse down events will get left clicks and remove the object that received that left click from the box part, and then delete it. This is done with the \doxylink{group__Edje__Object__Part_ga342784f4bb3a1d52e6fc5ff83336bf30}{edje\+\_\+object\+\_\+part\+\_\+box\+\_\+remove()} function.

However, on right clicks it will create a new rectangle object, and add it just before the right clicked object, using \doxylink{group__Edje__Object__Part_ga84d72a9952f1cb3ffb2d9a226338e168}{edje\+\_\+object\+\_\+part\+\_\+box\+\_\+insert\+\_\+before()}.

And this is the key down callback\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_on\_bg\_key\_down(\textcolor{keywordtype}{void}\ *data,\ Evas\ *e,\ Evas\_Object\ *o\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keywordtype}{void}\ *event\_info)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ Ecore\_Evas\ \ \ \ \ \ \ \ \ \ *ee;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{struct__Evas__Event__Key__Down}{Evas\_Event\_Key\_Down}}\ *ev;}
\DoxyCodeLine{\ \ \ Evas\_Object\ \ \ \ \ \ \ \ \ *edje\_obj;}
\DoxyCodeLine{\ \ \ Evas\_Object\ \ \ \ \ \ \ \ \ *rect;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}\ \ \ \ \ \ \ \ \ \ \ \ r;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ ee\ =\ (Ecore\_Evas\ *)data;}
\DoxyCodeLine{\ \ \ ev\ =\ (\mbox{\hyperlink{struct__Evas__Event__Key__Down}{Evas\_Event\_Key\_Down}}\ *)event\_info;}
\DoxyCodeLine{\ \ \ edje\_obj\ =\ \mbox{\hyperlink{group__Ecore__Evas__Group_ga85531b3a6bcbe868d2cf5d32fab99c60}{ecore\_evas\_data\_get}}(ee,\ \textcolor{stringliteral}{"{}edje\_obj"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!strcmp(ev-\/>\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}},\ \textcolor{stringliteral}{"{}h"{}}))}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(commands);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!strcmp(ev-\/>\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}},\ \textcolor{stringliteral}{"{}i"{}}))}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ rect\ =\ \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(e);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(rect,\ 0,\ 0,\ 128,\ 255);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(rect,\ RECTW\ +\ 30,\ RECTH);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(rect);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Inserting\ rect\ \%p\ before\ the\ rectangle\ under\ the\ mouse\ pointer.\(\backslash\)n"{}},\ rect);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ r\ =\ \mbox{\hyperlink{group__Edje__Object__Part_ga10611460a18e65464a61ecfc3db79385}{edje\_object\_part\_box\_insert\_at}}(edje\_obj,\ \textcolor{stringliteral}{"{}example/box"{}},\ rect,\ 0);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!r)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}An\ error\ occurred\ when\ appending\ rect\ \%p\ to\ the\ box.\(\backslash\)n"{}},\ rect);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Events_gac71a1038dad71da36f57b70c8ad10252}{evas\_object\_event\_callback\_add}}(rect,\ \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968a9fa52651ccf7e47cd3b7785fc4cf393f}{EVAS\_CALLBACK\_MOUSE\_DOWN}},\ \_on\_rect\_mouse\_down,\ NULL);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (!strcmp(ev-\/>\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}},\ \textcolor{stringliteral}{"{}a"{}}))}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ rect\ =\ \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(e);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(rect,\ 0,\ 128,\ 0,\ 255);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(rect,\ RECTW,\ RECTH);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(rect);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Inserting\ rect\ \%p\ before\ the\ rectangle\ under\ the\ mouse\ pointer.\(\backslash\)n"{}},\ rect);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ r\ =\ \mbox{\hyperlink{group__Edje__Object__Part_gad50eb55892c1e06edc3928e8fe8baca4}{edje\_object\_part\_box\_append}}(edje\_obj,\ \textcolor{stringliteral}{"{}example/box"{}},\ rect);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!r)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}An\ error\ occurred\ when\ appending\ rect\ \%p\ to\ the\ box.\(\backslash\)n"{}},\ rect);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Events_gac71a1038dad71da36f57b70c8ad10252}{evas\_object\_event\_callback\_add}}(rect,\ \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968a9fa52651ccf7e47cd3b7785fc4cf393f}{EVAS\_CALLBACK\_MOUSE\_DOWN}},\ \_on\_rect\_mouse\_down,\ NULL);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (!strcmp(ev-\/>\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}},\ \textcolor{stringliteral}{"{}c"{}}))}
\DoxyCodeLine{\ \ \ \ \ \mbox{\hyperlink{group__Edje__Object__Part_ga3fbdfc7f39ae0928e7c71651123abd24}{edje\_object\_part\_box\_remove\_all}}(edje\_obj,\ \textcolor{stringliteral}{"{}example/box"{}},\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (!strcmp(ev-\/>\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}},\ \textcolor{stringliteral}{"{}Escape"{}}))}
\DoxyCodeLine{\ \ \ \ \ \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}}();}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}unhandled\ key:\ \%s\(\backslash\)n"{}},\ ev-\/>\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(commands);}
\DoxyCodeLine{\ \ \ \ \ \}}

\end{DoxyCodeInclude}
 It will insert elements at the beginning of the box if "{}i"{} was pressed, using \doxylink{group__Edje__Object__Part_ga10611460a18e65464a61ecfc3db79385}{edje\+\_\+object\+\_\+part\+\_\+box\+\_\+insert\+\_\+at()}. It will also append objects to the box if "{}a"{} was pressed, just exactly like we did in the {\ttfamily main} function. And will remove all objects (deleting them) if "{}c"{} was pressed.

As you can see, this example uses the {\ttfamily "{}horizontal\+\_\+flow"{}} layout for the box, where each item is put linearly in rows, in as many rows as necessary to store all of them.

The example\textquotesingle{}s window should look like this picture\+:

  
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth]{edje-box-example}}
\end{DoxyImageNoCaption}


The full source code follows\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#ifdef\ HAVE\_CONFIG\_H}}
\DoxyCodeLine{\textcolor{preprocessor}{\#\ include\ "{}config.h"{}}}
\DoxyCodeLine{\textcolor{preprocessor}{\#else}}
\DoxyCodeLine{\textcolor{preprocessor}{\#\ define\ EINA\_UNUSED}}
\DoxyCodeLine{\textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#ifndef\ PACKAGE\_DATA\_DIR}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define\ PACKAGE\_DATA\_DIR\ "{}."{}}}
\DoxyCodeLine{\textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <Ecore.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{Ecore__Evas_8h}{Ecore\_Evas.h}}>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{Edje_8h}{Edje.h}}>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#define\ WIDTH\ \ 300}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define\ HEIGHT\ 300}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#define\ RECTW\ 30}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define\ RECTH\ 30}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#define\ NRECTS\ 20}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ commands[]\ =\ \(\backslash\)}
\DoxyCodeLine{\ \ \textcolor{stringliteral}{"{}commands\ are:\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \textcolor{stringliteral}{"{}\(\backslash\)ti\ -\/\ prepend\ rectangle\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \textcolor{stringliteral}{"{}\(\backslash\)ta\ -\/\ append\ rectangle\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \textcolor{stringliteral}{"{}\(\backslash\)tc\ -\/\ remove\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \textcolor{stringliteral}{"{}\(\backslash\)tEsc\ -\/\ exit\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \textcolor{stringliteral}{"{}\(\backslash\)th\ -\/\ print\ help\(\backslash\)n"{}};}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_on\_destroy(Ecore\_Evas\ *ee\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}}();}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{/*\ here\ just\ to\ keep\ our\ example's\ window\ size\ and\ background\ image's}}
\DoxyCodeLine{\textcolor{comment}{\ *\ size\ in\ synchrony\ */}}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_on\_canvas\_resize(Ecore\_Evas\ *ee)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ Evas\_Object\ *bg;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *edje\_obj;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{int}\ \ \ \ \ \ \ \ \ \ w;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{int}\ \ \ \ \ \ \ \ \ \ h;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ bg\ =\ \mbox{\hyperlink{group__Ecore__Evas__Group_ga85531b3a6bcbe868d2cf5d32fab99c60}{ecore\_evas\_data\_get}}(ee,\ \textcolor{stringliteral}{"{}background"{}});}
\DoxyCodeLine{\ \ \ edje\_obj\ =\ \mbox{\hyperlink{group__Ecore__Evas__Group_ga85531b3a6bcbe868d2cf5d32fab99c60}{ecore\_evas\_data\_get}}(ee,\ \textcolor{stringliteral}{"{}edje\_obj"{}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_ga931aadf4603731e73e8a84e4b14f1493}{ecore\_evas\_geometry\_get}}(ee,\ NULL,\ NULL,\ \&w,\ \&h);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(bg,\ w,\ h);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(edje\_obj,\ w,\ h);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_on\_rect\_mouse\_down(\textcolor{keywordtype}{void}\ *data,\ Evas\ *e,\ Evas\_Object\ *o,\ \textcolor{keywordtype}{void}\ *event\_info)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ Ecore\_Evas\ \ \ \ \ \ \ \ \ \ \ \ *ee;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{struct__Evas__Event__Mouse__Down}{Evas\_Event\_Mouse\_Down}}\ *ev;}
\DoxyCodeLine{\ \ \ Evas\_Object\ \ \ \ \ \ \ \ \ \ \ *edje\_obj;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ ee\ =\ (Ecore\_Evas\ *)data;}
\DoxyCodeLine{\ \ \ ev\ =\ (\mbox{\hyperlink{struct__Evas__Event__Mouse__Down}{Evas\_Event\_Mouse\_Down}}\ *)event\_info;}
\DoxyCodeLine{\ \ \ edje\_obj\ =\ \mbox{\hyperlink{group__Ecore__Evas__Group_ga85531b3a6bcbe868d2cf5d32fab99c60}{ecore\_evas\_data\_get}}(ee,\ \textcolor{stringliteral}{"{}edje\_obj"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (ev-\/>\mbox{\hyperlink{struct__Evas__Event__Mouse__Down_a0ab02808721d6c55fc642ecbb37d5ff9}{button}}\ ==\ 1)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Removing\ rect\ \%p\ under\ the\ mouse\ pointer.\(\backslash\)n"{}},\ o);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Edje__Object__Part_ga342784f4bb3a1d52e6fc5ff83336bf30}{edje\_object\_part\_box\_remove}}(edje\_obj,\ \textcolor{stringliteral}{"{}example/box"{}},\ o);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9217cf1d90690dbd1960db155d1c7476}{evas\_object\_del}}(o);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (ev-\/>\mbox{\hyperlink{struct__Evas__Event__Mouse__Down_a0ab02808721d6c55fc642ecbb37d5ff9}{button}}\ ==\ 3)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ Evas\_Object\ *rect;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}\ \ \ \ r;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ rect\ =\ \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(e);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(rect,\ 0,\ 0,\ 255,\ 255);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(rect,\ RECTW\ +\ 10,\ RECTH);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(rect);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Inserting\ rect\ \%p\ before\ the\ rectangle\ under\ the\ mouse\ pointer.\(\backslash\)n"{}},\ rect);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ r\ =\ \mbox{\hyperlink{group__Edje__Object__Part_ga84d72a9952f1cb3ffb2d9a226338e168}{edje\_object\_part\_box\_insert\_before}}(edje\_obj,\ \textcolor{stringliteral}{"{}example/box"{}},\ rect,\ o);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!r)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}An\ error\ occurred\ when\ appending\ rect\ \%p\ to\ the\ box.\(\backslash\)n"{}},\ rect);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Events_gac71a1038dad71da36f57b70c8ad10252}{evas\_object\_event\_callback\_add}}(rect,\ \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968a9fa52651ccf7e47cd3b7785fc4cf393f}{EVAS\_CALLBACK\_MOUSE\_DOWN}},\ \_on\_rect\_mouse\_down,\ NULL);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_on\_bg\_key\_down(\textcolor{keywordtype}{void}\ *data,\ Evas\ *e,\ Evas\_Object\ *o\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keywordtype}{void}\ *event\_info)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ Ecore\_Evas\ \ \ \ \ \ \ \ \ \ *ee;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{struct__Evas__Event__Key__Down}{Evas\_Event\_Key\_Down}}\ *ev;}
\DoxyCodeLine{\ \ \ Evas\_Object\ \ \ \ \ \ \ \ \ *edje\_obj;}
\DoxyCodeLine{\ \ \ Evas\_Object\ \ \ \ \ \ \ \ \ *rect;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}\ \ \ \ \ \ \ \ \ \ \ \ r;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ ee\ =\ (Ecore\_Evas\ *)data;}
\DoxyCodeLine{\ \ \ ev\ =\ (\mbox{\hyperlink{struct__Evas__Event__Key__Down}{Evas\_Event\_Key\_Down}}\ *)event\_info;}
\DoxyCodeLine{\ \ \ edje\_obj\ =\ \mbox{\hyperlink{group__Ecore__Evas__Group_ga85531b3a6bcbe868d2cf5d32fab99c60}{ecore\_evas\_data\_get}}(ee,\ \textcolor{stringliteral}{"{}edje\_obj"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!strcmp(ev-\/>\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}},\ \textcolor{stringliteral}{"{}h"{}}))}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(commands);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return};}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!strcmp(ev-\/>\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}},\ \textcolor{stringliteral}{"{}i"{}}))}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ rect\ =\ \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(e);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(rect,\ 0,\ 0,\ 128,\ 255);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(rect,\ RECTW\ +\ 30,\ RECTH);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(rect);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Inserting\ rect\ \%p\ before\ the\ rectangle\ under\ the\ mouse\ pointer.\(\backslash\)n"{}},\ rect);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ r\ =\ \mbox{\hyperlink{group__Edje__Object__Part_ga10611460a18e65464a61ecfc3db79385}{edje\_object\_part\_box\_insert\_at}}(edje\_obj,\ \textcolor{stringliteral}{"{}example/box"{}},\ rect,\ 0);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!r)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}An\ error\ occurred\ when\ appending\ rect\ \%p\ to\ the\ box.\(\backslash\)n"{}},\ rect);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Events_gac71a1038dad71da36f57b70c8ad10252}{evas\_object\_event\_callback\_add}}(rect,\ \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968a9fa52651ccf7e47cd3b7785fc4cf393f}{EVAS\_CALLBACK\_MOUSE\_DOWN}},\ \_on\_rect\_mouse\_down,\ NULL);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (!strcmp(ev-\/>\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}},\ \textcolor{stringliteral}{"{}a"{}}))}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ rect\ =\ \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(e);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(rect,\ 0,\ 128,\ 0,\ 255);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(rect,\ RECTW,\ RECTH);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(rect);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Inserting\ rect\ \%p\ before\ the\ rectangle\ under\ the\ mouse\ pointer.\(\backslash\)n"{}},\ rect);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ r\ =\ \mbox{\hyperlink{group__Edje__Object__Part_gad50eb55892c1e06edc3928e8fe8baca4}{edje\_object\_part\_box\_append}}(edje\_obj,\ \textcolor{stringliteral}{"{}example/box"{}},\ rect);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!r)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}An\ error\ occurred\ when\ appending\ rect\ \%p\ to\ the\ box.\(\backslash\)n"{}},\ rect);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Events_gac71a1038dad71da36f57b70c8ad10252}{evas\_object\_event\_callback\_add}}(rect,\ \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968a9fa52651ccf7e47cd3b7785fc4cf393f}{EVAS\_CALLBACK\_MOUSE\_DOWN}},\ \_on\_rect\_mouse\_down,\ NULL);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (!strcmp(ev-\/>\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}},\ \textcolor{stringliteral}{"{}c"{}}))}
\DoxyCodeLine{\ \ \ \ \ \mbox{\hyperlink{group__Edje__Object__Part_ga3fbdfc7f39ae0928e7c71651123abd24}{edje\_object\_part\_box\_remove\_all}}(edje\_obj,\ \textcolor{stringliteral}{"{}example/box"{}},\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (!strcmp(ev-\/>\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}},\ \textcolor{stringliteral}{"{}Escape"{}}))}
\DoxyCodeLine{\ \ \ \ \ \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}}();}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}unhandled\ key:\ \%s\(\backslash\)n"{}},\ ev-\/>\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ printf(commands);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}}
\DoxyCodeLine{main(\textcolor{keywordtype}{int}\ argc\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},\ \textcolor{keywordtype}{char}\ *argv[]\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ \ *edje\_file\ =\ PACKAGE\_DATA\_DIR\textcolor{stringliteral}{"{}/box.edj"{}};}
\DoxyCodeLine{\ \ \ Ecore\_Evas\ \ *ee;}
\DoxyCodeLine{\ \ \ Evas\ \ \ \ \ \ \ \ *evas;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *bg;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *edje\_obj;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{int}\ \ \ \ \ \ \ \ \ \ i;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!\mbox{\hyperlink{group__Ecore__Evas__Group_ga32ddbb6457033ad435a177eb0c4fe235}{ecore\_evas\_init}}())}
\DoxyCodeLine{\ \ \ \ \ \textcolor{keywordflow}{return}\ EXIT\_FAILURE;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!\mbox{\hyperlink{group__Edje__General__Group_ga1c9c6594f38023c29fbfb2d0c8c675db}{edje\_init}}())}
\DoxyCodeLine{\ \ \ \ \ \textcolor{keywordflow}{goto}\ shutdown\_ecore\_evas;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{comment}{/*\ this\ will\ give\ you\ a\ window\ with\ an\ Evas\ canvas\ under\ the\ first}}
\DoxyCodeLine{\textcolor{comment}{\ \ \ \ *\ engine\ available\ */}}
\DoxyCodeLine{\ \ \ ee\ =\ \mbox{\hyperlink{group__Ecore__Evas__Group_gaaa770b6f2f1395f9eeb0e50e26c3f933}{ecore\_evas\_new}}(NULL,\ 0,\ 0,\ WIDTH,\ HEIGHT,\ NULL);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (!ee)\ \textcolor{keywordflow}{goto}\ shutdown\_edje;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_ga3680b5c89157167318192157a5d24ec4}{ecore\_evas\_callback\_destroy\_set}}(ee,\ \_on\_destroy);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_gaac67f679c9027059a34519fbdea360df}{ecore\_evas\_callback\_resize\_set}}(ee,\ \_on\_canvas\_resize);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_ga3b2832e0373bbafae2bb7143618535c1}{ecore\_evas\_title\_set}}(ee,\ \textcolor{stringliteral}{"{}Edje\ Box\ Example"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ evas\ =\ \mbox{\hyperlink{group__Ecore__Evas__Group_ga6f8d214cd55bc940d7cc62fecd8dbc06}{ecore\_evas\_get}}(ee);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ bg\ =\ \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(evas);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(bg,\ 255,\ 255,\ 255,\ 255);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(bg,\ WIDTH,\ HEIGHT);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gac6d65f8896ab59780553676d0017c2ef}{evas\_object\_focus\_set}}(bg,\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(bg);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_gaa86c5abd200a02711aced53d27b9ddb2}{ecore\_evas\_data\_set}}(ee,\ \textcolor{stringliteral}{"{}background"{}},\ bg);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Events_gac71a1038dad71da36f57b70c8ad10252}{evas\_object\_event\_callback\_add}}(bg,\ \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968a336b86bad4f145f84c155e4922335584}{EVAS\_CALLBACK\_KEY\_DOWN}},\ \_on\_bg\_key\_down,\ ee);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ edje\_obj\ =\ \mbox{\hyperlink{group__Edje__Object__Group_ga5548cef32568746f40df9bd0be339bea}{edje\_object\_add}}(evas);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Edje__Object__Group_gaec1edd24b5bd8e82823759a8dddc1996}{edje\_object\_file\_set}}(edje\_obj,\ edje\_file,\ \textcolor{stringliteral}{"{}example/group"{}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga335c8ee6eaeaac9710656af4f8b0db91}{evas\_object\_move}}(edje\_obj,\ 0,\ 0);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(edje\_obj,\ WIDTH,\ HEIGHT);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(edje\_obj);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_gaa86c5abd200a02711aced53d27b9ddb2}{ecore\_evas\_data\_set}}(ee,\ \textcolor{stringliteral}{"{}edje\_obj"{}},\ edje\_obj);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ NRECTS;\ i++)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ Evas\_Object\ *rect;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}\ r\ =\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ red\ =\ (i\ *\ 10)\ \%\ 256;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ rect\ =\ \mbox{\hyperlink{group__Evas__Object__Rectangle_ga1b7a9d8e6ce240590c1734da5f3449d2}{evas\_object\_rectangle\_add}}(evas);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_gab751e9d24c16e74af6f7c08ea5b930c2}{evas\_object\_color\_set}}(rect,\ red,\ 0,\ 0,\ 255);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group_gacad94595f83580c18908cb3b69b08d1a}{evas\_object\_resize}}(rect,\ RECTW,\ RECTH);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ r\ =\ \mbox{\hyperlink{group__Edje__Object__Part_gad50eb55892c1e06edc3928e8fe8baca4}{edje\_object\_part\_box\_append}}(edje\_obj,\ \textcolor{stringliteral}{"{}example/box"{}},\ rect);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!r)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}An\ error\ occurred\ when\ appending\ rect\ \#\%d\ to\ the\ box.\(\backslash\)n"{}},\ i);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(rect);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Events_gac71a1038dad71da36f57b70c8ad10252}{evas\_object\_event\_callback\_add}}(}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ rect,\ \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968a9fa52651ccf7e47cd3b7785fc4cf393f}{EVAS\_CALLBACK\_MOUSE\_DOWN}},\ \_on\_rect\_mouse\_down,\ ee);}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ printf(commands);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}}(ee);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}}();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_gad3ec61f2aa03df4d3dbfd0d311e0c8dc}{ecore\_evas\_free}}(ee);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}}();}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Edje__General__Group_ga01041f6702f2d81bf10c3e41899805cb}{edje\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ EXIT\_SUCCESS;}
\DoxyCodeLine{}
\DoxyCodeLine{\ shutdown\_edje:}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Edje__General__Group_ga01041f6702f2d81bf10c3e41899805cb}{edje\_shutdown}}();}
\DoxyCodeLine{\ shutdown\_ecore\_evas:}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ EXIT\_FAILURE;}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}


To compile use this command\+: \begin{DoxyVerb}* gcc -o edje-box edje-box.c -DPACKAGE_BIN_DIR=\"/Where/enlightenment/is/installed/bin\" -DPACKAGE_LIB_DIR=\"/Where/enlightenment/is/installed/lib\"
* -DPACKAGE_DATA_DIR=\"/Where/enlightenment/is/installed/share\"
* `pkg-config --cflags --libs evas ecore ecore-evas edje`
*
* edje_cc box.edc
* \end{DoxyVerb}
 