
\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 <\mbox{\hyperlink{Edje_8h}{Edje.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        480}

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

\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}} *bg, *rect, *container, *border;
\};

\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{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *
\_get\_aspect\_name(Evas\_Aspect\_Control aspect)
\{
   \textcolor{keywordflow}{switch} (aspect)
     \{
      \textcolor{keywordflow}{case} 0:
        \textcolor{keywordflow}{return} \textcolor{stringliteral}{"NONE"};

      \textcolor{keywordflow}{case} 1:
        \textcolor{keywordflow}{return} \textcolor{stringliteral}{"NEITHER"};

      \textcolor{keywordflow}{case} 2:
        \textcolor{keywordflow}{return} \textcolor{stringliteral}{"HORIZONTAL"};

      \textcolor{keywordflow}{case} 3:
        \textcolor{keywordflow}{return} \textcolor{stringliteral}{"VERTICAL"};

      \textcolor{keywordflow}{case} 4:
        \textcolor{keywordflow}{return} \textcolor{stringliteral}{"BOTH"};

      \textcolor{keywordflow}{default}:
        \textcolor{keywordflow}{return} \textcolor{stringliteral}{"INVALID"};
     \}
\}

\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}}        *\mbox{\hyperlink{namespaceevas}{evas}} \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},
            \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o,
            \textcolor{keywordtype}{void}        *einfo)
\{
   \textcolor{keyword}{const} Evas\_Modifier *mods;
   \mbox{\hyperlink{struct__Evas__Event__Key__Down}{Evas\_Event\_Key\_Down}} *ev = einfo;

   mods = \mbox{\hyperlink{group__Evas__Canvas_gaad42bb4caa43c1cfef4096f6ac2b99ec}{evas\_key\_modifier\_get}}(evas\_object\_evas\_get(o));

   \textcolor{keywordflow}{if} (\mbox{\hyperlink{group__Evas__Keys_ga6cc24a5ea4b39b84c7a3e617de3db261}{evas\_key\_modifier\_is\_set}}(mods, \textcolor{stringliteral}{"Shift"}) &&
       strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"h"}) == 0) \textcolor{comment}{/* print help */}
     \{
        printf(\textcolor{stringliteral}{"commands are:\(\backslash\)n"}
               \textcolor{stringliteral}{"\(\backslash\)tc - cycle aspect control on object\(\backslash\)n"}
               \textcolor{stringliteral}{"\(\backslash\)th - change horizontal aspect component\(\backslash\)n"}
               \textcolor{stringliteral}{"\(\backslash\)tv - change vertical aspect component\(\backslash\)n"}
               \textcolor{stringliteral}{"\(\backslash\)ts - print current object's status\(\backslash\)n"}
               \textcolor{stringliteral}{"\(\backslash\)tH - print help\(\backslash\)n"});
        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"s"}) == 0) \textcolor{comment}{/* get aspect status of the obj */}
     \{
        \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} w, h;
        Evas\_Aspect\_Control aspect;

        evas\_object\_size\_hint\_aspect\_get(d.rect, &aspect, &w, &h);

        printf(\textcolor{stringliteral}{"Object has aspect %s, with horizontal compontent %d"}
               \textcolor{stringliteral}{" and vertical component %d\(\backslash\)n"},
               \_get\_aspect\_name(aspect), w, h);

        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"c"}) == 0) \textcolor{comment}{/* cycle aspect control on obj */}
     \{
        \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} w, h;
        Evas\_Aspect\_Control aspect;

        evas\_object\_size\_hint\_aspect\_get(d.rect, &aspect, &w, &h);

        aspect = (aspect + 1) % 5;

        evas\_object\_size\_hint\_aspect\_set(d.rect, aspect, w, h);

        printf(\textcolor{stringliteral}{"Changing aspect control to %s\(\backslash\)n"},
               \_get\_aspect\_name(aspect));

        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"h"}) == 0) \textcolor{comment}{/* change horizontal aspect component */}
     \{
        \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} w, h;
        Evas\_Aspect\_Control aspect;

        evas\_object\_size\_hint\_aspect\_get(d.rect, &aspect, &w, &h);

        w = (w + 1) % 3;

        evas\_object\_size\_hint\_aspect\_set(d.rect, aspect, w, h);

        printf(\textcolor{stringliteral}{"Changing horizontal aspect component to %d\(\backslash\)n"}, w);

        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"v"}) == 0) \textcolor{comment}{/* change vertical aspect component */}
     \{
        \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} w, h;
        Evas\_Aspect\_Control aspect;

        evas\_object\_size\_hint\_aspect\_get(d.rect, &aspect, &w, &h);

        h = (h + 1) % 3;

        evas\_object\_size\_hint\_aspect\_set(d.rect, aspect, w, h);

        printf(\textcolor{stringliteral}{"Changing vertical aspect component to %d\(\backslash\)n"}, h);

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

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{void})
\{
   \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}} ret;

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

   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Edje__General__Group_ga1c9c6594f38023c29fbfb2d0c8c675db}{edje\_init}}())
     \textcolor{keywordflow}{return} EXIT\_FAILURE;

   \textcolor{comment}{/* this will give you a window with an Evas canvas under the first}
\textcolor{comment}{    * engine available */}
   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} \mbox{\hyperlink{namespaceefl_1_1eina_1_1log__level_a0eec9fe47d243634f680b56a7d768ec7}{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);

   \textcolor{comment}{/* the canvas pointer, de facto */}
   d.canvas = \mbox{\hyperlink{group__Ecore__Evas__Group_ga75a7cc694b6069e78df47dab0b0f2d20}{ecore\_evas\_get}}(d.ee);

   d.bg = \mbox{\hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}}(d.canvas);
   \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);

   d.container = edje\_object\_add(d.canvas);
   ret = edje\_object\_file\_set(d.container, edje\_file\_path, \textcolor{stringliteral}{"main"});
   \textcolor{keywordflow}{if} (!ret)
     \{
        Edje\_Load\_Error err = edje\_object\_load\_error\_get(d.container);
        \textcolor{keyword}{const} \textcolor{keywordtype}{char} *msg = edje\_load\_error\_str(err);
        fprintf(stderr, \textcolor{stringliteral}{"could not load 'main' from %s: %s"},
                edje\_file\_path, msg);

        \textcolor{keywordflow}{goto} panic;
     \}

   evas\_object\_move(d.container, (WIDTH / 4), (HEIGHT / 4));
   evas\_object\_resize(d.container, (WIDTH / 2), (HEIGHT / 2));
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(d.container);

   d.rect = \mbox{\hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}}(d.canvas);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}}(d.rect, 0, 0, 255, 255);
   evas\_object\_size\_hint\_aspect\_set(d.rect, EVAS\_ASPECT\_CONTROL\_NONE, 1, 1);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(d.rect);

   edje\_object\_part\_swallow(d.container, \textcolor{stringliteral}{"content"}, d.rect);
   \mbox{\hyperlink{group__Evas__Smart__Object__Group_ga4f08aefaa29ea4bfc5b3f5c89c85dd59}{evas\_object\_smart\_changed}}(d.container);

   \textcolor{comment}{/* this is a border around the edje object, container of the}
\textcolor{comment}{    * rectangle we are going to experiment with (change its aspect}
\textcolor{comment}{    * hints). this way you can see how their sizes relate */}
   d.border = evas\_object\_image\_filled\_add(d.canvas);
   evas\_object\_image\_file\_set(d.border, border\_img\_path, NULL);
   evas\_object\_image\_border\_set(d.border, 3, 3, 3, 3);
   evas\_object\_image\_border\_center\_fill\_set(d.border, EVAS\_BORDER\_FILL\_NONE);
   evas\_object\_move(d.border, (WIDTH / 4) - 3, (HEIGHT / 4) - 3);
   evas\_object\_resize(d.border, (WIDTH / 2) + 6, (HEIGHT / 2) + 6);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(d.border);

   \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}}();
   \mbox{\hyperlink{group__Edje__General__Group_ga01041f6702f2d81bf10c3e41899805cb}{edje\_shutdown}}();
   \textcolor{keywordflow}{return} 0;

\mbox{\hyperlink{namespaceefl_1_1eina_1_1log__level_a0eec9fe47d243634f680b56a7d768ec7}{error}}:
   fprintf(stderr, \textcolor{stringliteral}{"you got to have at least one evas engine built and linked"}
                   \textcolor{stringliteral}{" up 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}}();
   \mbox{\hyperlink{group__Edje__General__Group_ga01041f6702f2d81bf10c3e41899805cb}{edje\_shutdown}}();

   \textcolor{keywordflow}{return} -1;
\}
\end{DoxyCodeInclude}
 