In this example we will show how to load an image and move it across the window.

To load the image to our program, it needs to be declared in the .edc using the images block\+:  
\begin{DoxyCodeInclude}
     images\{
                image: \textcolor{stringliteral}{"bubble.png"} COMP;
     \}

\end{DoxyCodeInclude}


\begin{DoxyNote}{Note}
C\+O\+MP means that we are using a lossless compression
\end{DoxyNote}
Then to be able to use it in our window we must declare a part for this image\+:


\begin{DoxyCodeInclude}
                part\{
                   name: \textcolor{stringliteral}{"part\_image"};
                   type: IMAGE;
                   description\{
                       image\{
                                normal: \textcolor{stringliteral}{"bubble.png"};
                       \}
                   \}
                \}

\end{DoxyCodeInclude}


Now we move to our .c file, you will notice this define\+:  
\begin{DoxyCodeInclude}
\textcolor{preprocessor}{#define WALK 10}

\end{DoxyCodeInclude}


This means how fast we want to move the image across the screen

To load our edje file we will use this command, we do just like the last example (Basic example)\+:


\begin{DoxyCodeInclude}
  \textcolor{keywordflow}{if}(!edje\_object\_file\_set(edje\_obj, edje\_file, \textcolor{stringliteral}{"image\_group"}))
  \{
    \textcolor{keywordtype}{int} err = edje\_object\_load\_error\_get(edje\_obj);
    \textcolor{keyword}{const} \textcolor{keywordtype}{char} *errmsg = \hyperlink{group__Edje__Object__File_ga034465c2de4ab495802da20f332c386e}{edje\_load\_error\_str}(err);
    fprintf(stderr, \textcolor{stringliteral}{"Could not load the edje file - reason:%s\(\backslash\)n"}, errmsg);
    \textcolor{keywordflow}{goto} shutdown\_edje;
  \}

  \hyperlink{group__Evas__Font__Group_ga02da8091bbac768b8e86c7b74b2a94f9}{evas\_object\_move}(edje\_obj, 50, 50);
  \hyperlink{group__Evas__Font__Group_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(edje\_obj, 64, 64);
  \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(edje\_obj);

\end{DoxyCodeInclude}


If we want to move our image, we need to add a callback to be able to do this, so we define\+:


\begin{DoxyCodeInclude}
  \hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}(bg, 
      \hyperlink{group__Evas_ggad64cde0da38a60e7cb7905b3ab216968a336b86bad4f145f84c155e4922335584}{EVAS\_CALLBACK\_KEY\_DOWN}, \_on\_key\_down, edje\_obj);

\end{DoxyCodeInclude}


To get the position of the image we use this\+:  
\begin{DoxyCodeInclude}
  \hyperlink{group__Evas__Object__Group__Basic_ga6f52fab1a96dc58c85ee481d84bac871}{evas\_object\_geometry\_get}(edje\_obj, &x, &y, NULL, NULL);

\end{DoxyCodeInclude}


Now we use the if\textquotesingle{}s to check in what direction the user wants to move the image then we move it\+:


\begin{DoxyCodeInclude}
  \textcolor{keywordflow}{if}(strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key},\textcolor{stringliteral}{"Escape"}) == 0)
  \{
        \hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}();
  \}
  \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"Down"}) == 0)
  \{
        y+=WALK;
  \}
  \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"Up"}) == 0)
  \{
        y-=WALK;
  \}
  \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"Right"}) == 0)
  \{
        x+=WALK;
  \}
  \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"Left"}) == 0)
  \{
        x-=WALK;
  \}
  \textcolor{keywordflow}{else}
  \{
     fprintf(stdout, \textcolor{stringliteral}{"Key %s not supported.\(\backslash\)nCommands:%s"}, ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, commands);
     \textcolor{keywordflow}{return};
  \}

  \hyperlink{group__Evas__Font__Group_ga02da8091bbac768b8e86c7b74b2a94f9}{evas\_object\_move}(edje\_obj, x, y);

\end{DoxyCodeInclude}


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

  
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth]{basic2final}}
\end{DoxyImageNoCaption}


The complete .edc file\+: 
\begin{DoxyCodeInclude}
collections \{
   group \{
      name: "image\_group";
      max: 500 500;
      min: 50 50;

     images\{
                image: "bubble.png" COMP;
     \}

    parts\{
                part\{
                   name: "part\_image";
                   type: IMAGE;
                   description\{
                       image\{
                                normal: "bubble.png";
                       \}
                   \}
                \}
    \}

   \}
\}
\end{DoxyCodeInclude}


And the source code\+: 
\begin{DoxyCodeInclude}

\textcolor{preprocessor}{#ifdef HAVE\_CONFIG\_H}
\textcolor{preprocessor}{# include "config.h"}
\textcolor{preprocessor}{#else}
\textcolor{preprocessor}{# define EINA\_UNUSED}
\textcolor{preprocessor}{#endif}

\textcolor{preprocessor}{#ifndef PACKAGE\_DATA\_DIR}
\textcolor{preprocessor}{#define PACKAGE\_DATA\_DIR "."}
\textcolor{preprocessor}{#endif}

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

\textcolor{preprocessor}{#include <\hyperlink{Eina_8h}{Eina.h}>}
\textcolor{preprocessor}{#include <Ecore.h>}
\textcolor{preprocessor}{#include <\hyperlink{Ecore__Evas_8h}{Ecore\_Evas.h}>}
\textcolor{preprocessor}{#include <\hyperlink{Edje_8h}{Edje.h}>}

\textcolor{preprocessor}{#define WIDTH  (700)}
\textcolor{preprocessor}{#define HEIGHT (700)}

\textcolor{preprocessor}{#define WALK 10}

\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} commands[] = \textcolor{stringliteral}{"commands are:\(\backslash\)nEsc - Exit\(\backslash\)nUp - move image up\(\backslash\)nDown - move image down\(\backslash\)n"}\(\backslash\)
    \textcolor{stringliteral}{"Right - move image to right\(\backslash\)nLeft - move image to left\(\backslash\)n"};

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_on\_key\_down(\textcolor{keywordtype}{void} *data,
              \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *evas EINA\_UNUSED,
              \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *o EINA\_UNUSED,
              \textcolor{keywordtype}{void} *einfo)
\{
  \hyperlink{struct__Evas__Event__Key__Down}{Evas\_Event\_Key\_Down} *ev;
  \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *edje\_obj;
  \textcolor{keywordtype}{int} x,y;

  ev = (\hyperlink{struct__Evas__Event__Key__Down}{Evas\_Event\_Key\_Down} *)einfo;
  edje\_obj = (\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *)data;

  \hyperlink{group__Evas__Object__Group__Basic_ga6f52fab1a96dc58c85ee481d84bac871}{evas\_object\_geometry\_get}(edje\_obj, &x, &y, NULL, NULL);

  \textcolor{keywordflow}{if}(strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key},\textcolor{stringliteral}{"Escape"}) == 0)
  \{
        \hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}();
  \}
  \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"Down"}) == 0)
  \{
        y+=WALK;
  \}
  \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"Up"}) == 0)
  \{
        y-=WALK;
  \}
  \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"Right"}) == 0)
  \{
        x+=WALK;
  \}
  \textcolor{keywordflow}{else} \textcolor{keywordflow}{if}(strcmp(ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, \textcolor{stringliteral}{"Left"}) == 0)
  \{
        x-=WALK;
  \}
  \textcolor{keywordflow}{else}
  \{
     fprintf(stdout, \textcolor{stringliteral}{"Key %s not supported.\(\backslash\)nCommands:%s"}, ev->\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}, commands);
     \textcolor{keywordflow}{return};
  \}

  \hyperlink{group__Evas__Font__Group_ga02da8091bbac768b8e86c7b74b2a94f9}{evas\_object\_move}(edje\_obj, x, y);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_on\_delete(Ecore\_Evas *ee EINA\_UNUSED)
\{
   \hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}();
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{int} argc EINA\_UNUSED, \textcolor{keywordtype}{char} **argv EINA\_UNUSED)
\{
  \textcolor{keyword}{const} \textcolor{keywordtype}{char} *edje\_file = PACKAGE\_DATA\_DIR\textcolor{stringliteral}{"/basic2.edj"};
  Ecore\_Evas *ee;
  \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *evas;
  \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *bg;
  \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *edje\_obj;

  \textcolor{keywordflow}{if}(!\hyperlink{group__Ecore__Evas__Group_ga32ddbb6457033ad435a177eb0c4fe235}{ecore\_evas\_init}())
        \textcolor{keywordflow}{return} EXIT\_FAILURE;

  \textcolor{keywordflow}{if}(!\hyperlink{group__Edje__General__Group_ga1c9c6594f38023c29fbfb2d0c8c675db}{edje\_init}())
        \textcolor{keywordflow}{goto} shutdown\_ecore\_evas;

  ee = \hyperlink{group__Ecore__Evas__Group_gac7f2cdbcb79635c34317c1183dd04cb0}{ecore\_evas\_new}(NULL, 0, 0, WIDTH, HEIGHT, NULL);

  \textcolor{keywordflow}{if}(!ee) \textcolor{keywordflow}{goto} shutdown\_edje;

  \hyperlink{group__Ecore__Evas__Group_ga3d478e975e2101b9b821ef24baf3dd9e}{ecore\_evas\_callback\_delete\_request\_set}(ee, \_on\_delete);
  \hyperlink{group__Ecore__Evas__Group_ga3b2832e0373bbafae2bb7143618535c1}{ecore\_evas\_title\_set}(ee, \textcolor{stringliteral}{"Edje show image"});

  evas = \hyperlink{group__Ecore__Evas__Group_ga75a7cc694b6069e78df47dab0b0f2d20}{ecore\_evas\_get}(ee);

  bg = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(evas);
  \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(bg, 255, 255, 255, 255); \textcolor{comment}{//White}
  \hyperlink{group__Evas__Font__Group_ga02da8091bbac768b8e86c7b74b2a94f9}{evas\_object\_move}(bg, 0, 0); \textcolor{comment}{//orign}
  \hyperlink{group__Evas__Font__Group_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(bg, WIDTH, HEIGHT); \textcolor{comment}{//cover the window}
  \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(bg);

  \hyperlink{group__Ecore__Evas__Group_gac35627a5c3a766ee42762dbcc9eb733d}{ecore\_evas\_object\_associate}(ee, bg, ECORE\_EVAS\_OBJECT\_ASSOCIATE\_BASE);
  evas\_object\_focus\_set(bg, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});

  edje\_obj = edje\_object\_add(evas);

  \textcolor{keywordflow}{if}(!edje\_object\_file\_set(edje\_obj, edje\_file, \textcolor{stringliteral}{"image\_group"}))
  \{
    \textcolor{keywordtype}{int} err = edje\_object\_load\_error\_get(edje\_obj);
    \textcolor{keyword}{const} \textcolor{keywordtype}{char} *errmsg = \hyperlink{group__Edje__Object__File_ga034465c2de4ab495802da20f332c386e}{edje\_load\_error\_str}(err);
    fprintf(stderr, \textcolor{stringliteral}{"Could not load the edje file - reason:%s\(\backslash\)n"}, errmsg);
    \textcolor{keywordflow}{goto} shutdown\_edje;
  \}

  \hyperlink{group__Evas__Font__Group_ga02da8091bbac768b8e86c7b74b2a94f9}{evas\_object\_move}(edje\_obj, 50, 50);
  \hyperlink{group__Evas__Font__Group_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(edje\_obj, 64, 64);
  \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(edje\_obj);

  \hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}(bg, 
      \hyperlink{group__Evas_ggad64cde0da38a60e7cb7905b3ab216968a336b86bad4f145f84c155e4922335584}{EVAS\_CALLBACK\_KEY\_DOWN}, \_on\_key\_down, edje\_obj);

  \hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}(ee);

  fprintf(stdout, \textcolor{stringliteral}{"%s"}, commands);

  \hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}();

  \hyperlink{group__Ecore__Evas__Group_gad3ec61f2aa03df4d3dbfd0d311e0c8dc}{ecore\_evas\_free}(ee);
  \hyperlink{group__Edje__General__Group_ga01041f6702f2d81bf10c3e41899805cb}{edje\_shutdown}();
  \hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}();

  \textcolor{keywordflow}{return} EXIT\_SUCCESS;

shutdown\_edje:
  \hyperlink{group__Edje__General__Group_ga01041f6702f2d81bf10c3e41899805cb}{edje\_shutdown}();

shutdown\_ecore\_evas:
  \hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}();

  \textcolor{keywordflow}{return} EXIT\_FAILURE;
\}
\end{DoxyCodeInclude}


To compile use this command\+: \begin{DoxyVerb}* gcc -o edje-basic2 edje-basic2.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 -id /path/to/the/image basic2.edc
* \end{DoxyVerb}
 