
\begin{DoxyCodeInclude}

\textcolor{preprocessor}{#ifdef HAVE\_CONFIG\_H}
\textcolor{preprocessor}{#include "config.h"}
\textcolor{preprocessor}{#else}
\textcolor{preprocessor}{#define PACKAGE\_EXAMPLES\_DIR "."}
\textcolor{preprocessor}{#endif}

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

\textcolor{preprocessor}{#include <stdio.h>}
\textcolor{preprocessor}{#include <errno.h>}
\textcolor{preprocessor}{#include "evas-common.h"}

\textcolor{preprocessor}{#define WIDTH  (320)}
\textcolor{preprocessor}{#define HEIGHT (240)}

\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *img\_path = PACKAGE\_EXAMPLES\_DIR EVAS\_IMAGE\_FOLDER \textcolor{stringliteral}{"/enlightenment.png"};
\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *border\_img\_path = PACKAGE\_EXAMPLES\_DIR EVAS\_IMAGE\_FOLDER \textcolor{stringliteral}{"/red.png"};

\textcolor{keyword}{struct }test\_data
\{
   Ecore\_Evas  *ee;
   \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}}        *canvas;
   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *img, *bg, *clipper, *clipper\_border, *text;
\};

\textcolor{keyword}{static} \textcolor{keyword}{struct }test\_data d = \{0\};

\textcolor{comment}{/* Keep the example's window size in sync with the background image's size */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_canvas\_resize\_cb(Ecore\_Evas *ee)
\{
   \textcolor{keywordtype}{int} w, h;

   \mbox{\hyperlink{group__Ecore__Evas__Group_ga931aadf4603731e73e8a84e4b14f1493}{ecore\_evas\_geometry\_get}}(ee, NULL, NULL, &w, &h);
   evas\_object\_resize(d.bg, w, h);
\}

\textcolor{comment}{/* Keyboard event callback routine, to enable the user to toggle various}
\textcolor{comment}{ * object properties on the clipper object.}
\textcolor{comment}{ */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_on\_keydown(\textcolor{keywordtype}{void}        *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},
            \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}}        *evas \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},
            \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},
            \textcolor{keywordtype}{void}        *einfo)
\{
   \mbox{\hyperlink{struct__Evas__Event__Key__Down}{Evas\_Event\_Key\_Down}} *ev = einfo;

   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"h"}) == 0)
     \{
        \textcolor{comment}{/* h - print help */}
        printf(\textcolor{stringliteral}{"commands are:\(\backslash\)n"}
               \textcolor{stringliteral}{"\(\backslash\)to - change clipper's opacity\(\backslash\)n"}
               \textcolor{stringliteral}{"\(\backslash\)tr - toggle clipper's color between red and white\(\backslash\)n"}
               \textcolor{stringliteral}{"\(\backslash\)tc - toggle clipper's clipping function\(\backslash\)n"}
               \textcolor{stringliteral}{"\(\backslash\)tv - toggle clipper's visibility\(\backslash\)n"});
        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"o"}) == 0)
     \{
        \textcolor{comment}{/* o - Change clipper's opacity */}
        \textcolor{keywordtype}{int} alpha, r, g, b;

        \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga0854bae878bfc39f51b9c989353c973f}{evas\_object\_color\_get}}(d.clipper, &r, &g, &b, &alpha);
        \mbox{\hyperlink{group__Evas__Utils_ga862abed1097a429dd439fbe08813cd9d}{evas\_color\_argb\_unpremul}}(alpha, &r, &g, &b);

        alpha -= 20;
        \textcolor{keywordflow}{if} (alpha < 0)
          alpha = 255;

        \mbox{\hyperlink{group__Evas__Utils_gac02bf3973675ae7591b9f34deef1554f}{evas\_color\_argb\_premul}}(alpha, &r, &g, &b);
        \mbox{\hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}}(d.clipper, r, g, b, alpha);

        printf(\textcolor{stringliteral}{"Changing clipper's opacity: %d%%\(\backslash\)n"},
                (\textcolor{keywordtype}{int})((alpha / 255.0) * 100));
        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"r"}) == 0)
     \{
        \textcolor{comment}{/* r - Toggle clipper's color between red and white */}
        \textcolor{keywordtype}{int} alpha, r, g, b;

        printf(\textcolor{stringliteral}{"Changing clipper's color to"});

        \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga0854bae878bfc39f51b9c989353c973f}{evas\_object\_color\_get}}(d.clipper, &r, &g, &b, &alpha);
        \mbox{\hyperlink{group__Evas__Utils_ga862abed1097a429dd439fbe08813cd9d}{evas\_color\_argb\_unpremul}}(alpha, &r, &g, &b);

        \textcolor{keywordflow}{if} (g > 0)
          \{
             printf(\textcolor{stringliteral}{"red\(\backslash\)n"});
             g = b = 0;
          \}
        \textcolor{keywordflow}{else}
          \{
             printf(\textcolor{stringliteral}{"white\(\backslash\)n"});
             g = b = 255;
          \}

        \mbox{\hyperlink{group__Evas__Utils_gac02bf3973675ae7591b9f34deef1554f}{evas\_color\_argb\_premul}}(alpha, &r, &g, &b);
        \mbox{\hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}}(d.clipper, r, g, b, alpha);
        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"c"}) == 0)
     \{
        \textcolor{comment}{/* o - Toggle clipper's clipping function */}
        printf(\textcolor{stringliteral}{"Toggling clipping "});

        \textcolor{keywordflow}{if} (evas\_object\_clip\_get(d.img) == d.clipper)
          \{
             evas\_object\_clip\_unset(d.img);
             printf(\textcolor{stringliteral}{"off\(\backslash\)n"});
          \}
        \textcolor{keywordflow}{else}
          \{
             evas\_object\_clip\_set(d.img, d.clipper);
             printf(\textcolor{stringliteral}{"on\(\backslash\)n"});
          \}
        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"v"}) == 0)
     \{
        \textcolor{comment}{/* v - Toggle clipper's visibility */}
        printf(\textcolor{stringliteral}{"Clipper is now "});

        \textcolor{keywordflow}{if} (evas\_object\_visible\_get(d.clipper))
          \{
             \mbox{\hyperlink{group__Evas__Object__Group__Basic_gacc307a0d7bfc9df151fd9ec75808c587}{evas\_object\_hide}}(d.clipper);
             printf(\textcolor{stringliteral}{"hidden\(\backslash\)n"});
          \}
        \textcolor{keywordflow}{else}
          \{
             \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(d.clipper);
             printf(\textcolor{stringliteral}{"visible\(\backslash\)n"});
          \}
        \textcolor{keywordflow}{return};
     \}
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{void})
\{
   \textcolor{keywordtype}{int} err;

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

   d.ee = \mbox{\hyperlink{group__Ecore__Evas__Group_gac7f2cdbcb79635c34317c1183dd04cb0}{ecore\_evas\_new}}(NULL, 10, 10, WIDTH, HEIGHT, NULL);
   \textcolor{keywordflow}{if} (!d.ee)
     \textcolor{keywordflow}{goto} error;

   \mbox{\hyperlink{group__Ecore__Evas__Group_gaac67f679c9027059a34519fbdea360df}{ecore\_evas\_callback\_resize\_set}}(d.ee, \_canvas\_resize\_cb);
   \mbox{\hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}}(d.ee);

   d.canvas = \mbox{\hyperlink{group__Ecore__Evas__Group_ga75a7cc694b6069e78df47dab0b0f2d20}{ecore\_evas\_get}}(d.ee);

   \textcolor{comment}{/* Create background.  As mentioned earlier, the evas\_object\_*}
\textcolor{comment}{    * routines are part of the legacy Evas API; with the new API}
\textcolor{comment}{    * you should use code as shown in evas-object-manipulation-eo.c.}
\textcolor{comment}{    */}
   d.bg = \mbox{\hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}}(d.canvas);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga88bfcce07ad3bcef31687e29075ae2d2}{evas\_object\_name\_set}}(d.bg, \textcolor{stringliteral}{"background rectangle"});
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}}(d.bg, 255, 255, 255, 255); \textcolor{comment}{/* white bg */}
   evas\_object\_move(d.bg, 0, 0); \textcolor{comment}{/* at canvas' origin */}
   evas\_object\_resize(d.bg, WIDTH, HEIGHT); \textcolor{comment}{/* covers full canvas */}
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(d.bg);

   evas\_object\_focus\_set(d.bg, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});
   \mbox{\hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}}(
     d.bg, \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968a336b86bad4f145f84c155e4922335584}{EVAS\_CALLBACK\_KEY\_DOWN}}, \_on\_keydown, NULL);

   \textcolor{comment}{/* Load enlightenment.png as an image object, then make it fill the}
\textcolor{comment}{    * whole canvas area.}
\textcolor{comment}{    */}
   d.img = evas\_object\_image\_filled\_add(d.canvas);
   evas\_object\_image\_file\_set(d.img, img\_path, NULL);
   err = evas\_object\_image\_load\_error\_get(d.img);
   \textcolor{keywordflow}{if} (err != EVAS\_LOAD\_ERROR\_NONE)
     \{
        \textcolor{keywordflow}{goto} panic;
     \}
   \textcolor{keywordflow}{else}
     \{
        evas\_object\_move(d.img, 0, 0);
        evas\_object\_resize(d.img, WIDTH, HEIGHT);
        \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(d.img);

        printf(\textcolor{stringliteral}{"Image object added, type is: %s\(\backslash\)n"},
                \mbox{\hyperlink{group__Evas__Object__Group__Basic_gaf5ec394604d9b8f6dafe5d6ee61b6448}{evas\_object\_type\_get}}(d.img));
     \}

   \textcolor{comment}{/* Add a second image to the canvas - a red square this time.  It}
\textcolor{comment}{    * will be given a border to emphasize its position.}
\textcolor{comment}{    */}
   d.clipper\_border = evas\_object\_image\_filled\_add(d.canvas);
   evas\_object\_image\_file\_set(d.clipper\_border, border\_img\_path, NULL);
   err = evas\_object\_image\_load\_error\_get(d.clipper\_border);
   \textcolor{keywordflow}{if} (err != EVAS\_LOAD\_ERROR\_NONE)
     \{
        \textcolor{keywordflow}{goto} panic;
     \}
   \textcolor{keywordflow}{else}
     \{
        evas\_object\_image\_border\_set(d.clipper\_border, 3, 3, 3, 3);
        evas\_object\_image\_border\_center\_fill\_set(
          d.clipper\_border, EVAS\_BORDER\_FILL\_NONE);
        evas\_object\_move(d.clipper\_border, (WIDTH / 4) - 3, (HEIGHT / 4) - 3);
        evas\_object\_resize(
          d.clipper\_border, (WIDTH / 2) + 6, (HEIGHT / 2) + 6);
        \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(d.clipper\_border);
     \}

   \textcolor{comment}{/* Lastly, add a rectangle.  It will be white (the default color for}
\textcolor{comment}{    * rectangles) and so won't change the color of anything it clips.}
\textcolor{comment}{    */}
   d.clipper = \mbox{\hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}}(d.canvas);
   evas\_object\_move(d.clipper, WIDTH / 4, HEIGHT / 4);
   evas\_object\_resize(d.clipper, WIDTH / 2, HEIGHT / 2);
   evas\_object\_clip\_set(d.img, d.clipper);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(d.clipper);

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

   \mbox{\hyperlink{group__Ecore__Evas__Group_gad3ec61f2aa03df4d3dbfd0d311e0c8dc}{ecore\_evas\_free}}(d.ee);
   \mbox{\hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}}();
   \textcolor{keywordflow}{return} 0;

error:
   fprintf(stderr, \textcolor{stringliteral}{"error: Requires at least one Evas engine built and linked"}
                   \textcolor{stringliteral}{" to ecore-evas for this example to run properly.\(\backslash\)n"});
panic:
   \mbox{\hyperlink{group__Ecore__Evas__Group_gad3ec61f2aa03df4d3dbfd0d311e0c8dc}{ecore\_evas\_free}}(d.ee);
   \mbox{\hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}}();
   \textcolor{keywordflow}{return} -1;
\}
\end{DoxyCodeInclude}
 