

This example creates an Ecore\+\_\+\+Evas(a window) and associates a background and a custom cursor for it.

We\textquotesingle{}ll start looking at the association, which is quite simple. We choose to associate using E\+C\+O\+R\+E\+\_\+\+E\+V\+A\+S\+\_\+\+O\+B\+J\+E\+C\+T\+\_\+\+A\+S\+S\+O\+C\+I\+A\+T\+E\+\_\+\+B\+A\+S\+E to have it be resized with the window, since for a background that is what\textquotesingle{}s most useful\+: 
\begin{DoxyCodeInclude}
   \hyperlink{group__Ecore__Evas__Group_gac35627a5c3a766ee42762dbcc9eb733d}{ecore\_evas\_object\_associate}(ee, bg, ECORE\_EVAS\_OBJECT\_ASSOCIATE\_BASE);

\end{DoxyCodeInclude}
 \begin{DoxyNote}{Note}
If we didn\textquotesingle{}t associate the background we\textquotesingle{}d need to listen to resize of Ecore\+\_\+\+Evas and manually resize the background or have artifacts on our window.
\end{DoxyNote}
We then check that the association worked\+: 
\begin{DoxyCodeInclude}
   \hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}(bg, 
      \hyperlink{Evas__Common_8h_a99e208e463a20499aabe6faac8a8cb8aa9fa52651ccf7e47cd3b7785fc4cf393f}{EVAS\_CALLBACK\_MOUSE\_DOWN}, \_mouse\_down\_cb, ee);

   \textcolor{keywordflow}{if} (bg == \hyperlink{group__Ecore__Evas__Group_ga55426142132c95742ab728187ca1c746}{ecore\_evas\_object\_associate\_get}(ee))
     printf(\textcolor{stringliteral}{"Association worked!\(\backslash\)n"});

\end{DoxyCodeInclude}


Next we are going to set a custom cursor, for our cursor we are going to use a small green rectangle. Our cursor is going to be on layer 0(any lower and it would be below the background and thus invisible) and clicks will be computed as happening on pixel 1, 1 of the image\+: 
\begin{DoxyCodeInclude}

   cursor = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(\hyperlink{group__Ecore__Evas__Group_ga75a7cc694b6069e78df47dab0b0f2d20}{ecore\_evas\_get}(ee));
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(cursor, 0, 255, 0, 255);
   \hyperlink{group__Evas__Font__Group_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(cursor, 5, 10);
   \hyperlink{group__Ecore__Evas__Group_ga529fe8c55bdb0f58c884a0e5f0dfff71}{ecore\_evas\_object\_cursor\_set}(ee, cursor, 0, 1, 1);

\end{DoxyCodeInclude}


We then check every one of those parameters\+: 
\begin{DoxyCodeInclude}

   \hyperlink{group__Ecore__Evas__Group_gaaa4c87c6745f098edbf786212df745d8}{ecore\_evas\_cursor\_get}(ee, &obj, &layer, &x, &y);
   \textcolor{keywordflow}{if} (obj == cursor && layer == 0 && x == 1 && y == 1)
     printf(\textcolor{stringliteral}{"Set cursor worked!\(\backslash\)n"});

\end{DoxyCodeInclude}


Here you have the full-\/source of the code\+: 
\begin{DoxyCodeInclude}

\textcolor{preprocessor}{#include <Ecore.h>}
\textcolor{preprocessor}{#include <\hyperlink{Ecore__Evas_8h}{Ecore\_Evas.h}>}

\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *cursor;

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_mouse\_down\_cb(\textcolor{keywordtype}{void} *data, \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *evas EINA\_UNUSED, \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *obj EINA\_UNUSED, \textcolor{keywordtype}{void} *
      event\_info EINA\_UNUSED)
\{
   \textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool} flag = \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE};

   \textcolor{keywordflow}{if} (!flag)
     \{
        \hyperlink{group__Ecore__Evas__Group_ga7cfb59e7b793ca2f05e3dfb1b0d67272}{ecore\_evas\_cursor\_unset}(data);
        \hyperlink{group__Ecore__Evas__Group_ga529fe8c55bdb0f58c884a0e5f0dfff71}{ecore\_evas\_object\_cursor\_set}(data, NULL, 0, 1, 1);
     \}
   \textcolor{keywordflow}{else}
     \hyperlink{group__Ecore__Evas__Group_ga529fe8c55bdb0f58c884a0e5f0dfff71}{ecore\_evas\_object\_cursor\_set}(data, cursor, 0, 1, 1);

   flag = !flag;
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{void})
\{
   Ecore\_Evas *ee;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *bg, *obj;
   \textcolor{keywordtype}{int} layer, x, y;

   \hyperlink{group__Ecore__Evas__Group_ga32ddbb6457033ad435a177eb0c4fe235}{ecore\_evas\_init}();

   ee = \hyperlink{group__Ecore__Evas__Group_gac7f2cdbcb79635c34317c1183dd04cb0}{ecore\_evas\_new}(NULL, 0, 0, 200, 200, NULL);
   \hyperlink{group__Ecore__Evas__Group_ga3b2832e0373bbafae2bb7143618535c1}{ecore\_evas\_title\_set}(ee, \textcolor{stringliteral}{"Ecore Evas Object Example"});
   \hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}(ee);

   bg = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(\hyperlink{group__Ecore__Evas__Group_ga75a7cc694b6069e78df47dab0b0f2d20}{ecore\_evas\_get}(ee));
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(bg, 0, 0, 255, 255);
   \hyperlink{group__Evas__Font__Group_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(bg, 200, 200);
   \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);
   \hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}(bg, 
      \hyperlink{Evas__Common_8h_a99e208e463a20499aabe6faac8a8cb8aa9fa52651ccf7e47cd3b7785fc4cf393f}{EVAS\_CALLBACK\_MOUSE\_DOWN}, \_mouse\_down\_cb, ee);

   \textcolor{keywordflow}{if} (bg == \hyperlink{group__Ecore__Evas__Group_ga55426142132c95742ab728187ca1c746}{ecore\_evas\_object\_associate\_get}(ee))
     printf(\textcolor{stringliteral}{"Association worked!\(\backslash\)n"});

   cursor = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(\hyperlink{group__Ecore__Evas__Group_ga75a7cc694b6069e78df47dab0b0f2d20}{ecore\_evas\_get}(ee));
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(cursor, 0, 255, 0, 255);
   \hyperlink{group__Evas__Font__Group_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(cursor, 5, 10);
   \hyperlink{group__Ecore__Evas__Group_ga529fe8c55bdb0f58c884a0e5f0dfff71}{ecore\_evas\_object\_cursor\_set}(ee, cursor, 0, 1, 1);

   \hyperlink{group__Ecore__Evas__Group_gaaa4c87c6745f098edbf786212df745d8}{ecore\_evas\_cursor\_get}(ee, &obj, &layer, &x, &y);
   \textcolor{keywordflow}{if} (obj == cursor && layer == 0 && x == 1 && y == 1)
     printf(\textcolor{stringliteral}{"Set cursor worked!\(\backslash\)n"});

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

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

   \textcolor{keywordflow}{return} 0;
\}

\end{DoxyCodeInclude}
 