

In this example, we illustrate how to create and handle Evas smart objects.

A smart object is one that provides custom functions to handle clipping, hiding, moving, resizing, color setting and more on {\bfseries child} elements, automatically, for the smart object\textquotesingle{}s user. They could be as simple as a group of objects that move together (see \mbox{\hyperlink{group__Evas__Smart__Object__Clipped}{Clipped Smart Object}}) or implementations of whole complex UI widgets, providing some intelligence (thus the name) and extension to simple Evas objects.

Here, we create one as an example. What it does is to control (at maximum) 2 child objects, with regard to their geometries and colors. There can be a \char`\"{}left\char`\"{} child and a \char`\"{}right\char`\"{} one. The former will always occupy the top left quadrant of the smart object\textquotesingle{}s area, while the latter will occupy the bottom right. The smart object will also contain an {\bfseries internal} decorative border object, which will also be controlled by it, naturally.

Here is where we add it to the canvas\+: 
\begin{DoxyCodeInclude}
   d.smt = evas\_smart\_example\_add(d.evas);
   evas\_object\_move(d.smt, WIDTH / 4, HEIGHT / 4);
   evas\_object\_resize(d.smt, WIDTH / 2, HEIGHT / 2);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(d.smt);

\end{DoxyCodeInclude}


The magic starts to happen in the {\ttfamily evas\+\_\+smart\+\_\+example\+\_\+add()} function, which is one in the example smart object\textquotesingle{}s defined {\bfseries interface}. These should be the functions you would export to the users of your smart object. We made three for this one\+:
\begin{DoxyItemize}
\item {\ttfamily evas\+\_\+smart\+\_\+example\+\_\+add()}\+: add a new instance of the example smart object to a canvas
\item {\ttfamily evas\+\_\+smart\+\_\+example\+\_\+remove()}\+: remove a given child of the smart object from it
\item {\ttfamily evas\+\_\+smart\+\_\+example\+\_\+set\+\_\+left()}\+: set the left child of the smart object
\item {\ttfamily evas\+\_\+smart\+\_\+example\+\_\+set\+\_\+right()}\+: set the right child of the smart object
\end{DoxyItemize}

The object\textquotesingle{}s creation takes place as\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* add a new example smart object to a canvas */}
\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *
evas\_smart\_example\_add(\mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *evas)
\{
   \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Evas__Smart__Object__Group_gad80de73a33446f902d4b39141a8d0a05}{evas\_object\_smart\_add}}(evas, \_evas\_smart\_example\_smart\_class\_new());
\}

\end{DoxyCodeInclude}


Smart objects are defined by {\bfseries smart classes}, which are structs defining their interfaces, or {\bfseries smart functions} (see \mbox{\hyperlink{group__Evas__Smart__Group_gaea15f67e901bf5380cdb67dc1bb43391}{Evas\+\_\+\+Smart\+\_\+\+Class}}, the base class for any smart object). As you see, one has to use the \mbox{\hyperlink{group__Evas__Smart__Object__Group_gad80de73a33446f902d4b39141a8d0a05}{evas\+\_\+object\+\_\+smart\+\_\+add()}} function to instantiate smart objects. Its second parameter is what matters -- an \mbox{\hyperlink{Evas__Common_8h_a7cdfd1afece1cad64c413eb9a778ddbb}{Evas\+\_\+\+Smart}} struct, which contains all the smart class definitions (smart functions, smart callbacks, and the like). Note, however, that {\ttfamily \+\_\+evas\+\_\+smart\+\_\+example\+\_\+smart\+\_\+class\+\_\+new()} seems not to be defined in our example\textquotesingle{}s code. That\textquotesingle{}s because it came from a very handy {\bfseries helper macro}\+:  
\begin{DoxyCodeInclude}
\mbox{\hyperlink{group__Evas__Smart__Group_ga58dc94af6f064b39b2bf0155908fbe52}{EVAS\_SMART\_SUBCLASS\_NEW}}(\_evas\_smart\_example\_type, \_evas\_smart\_example,
                        \mbox{\hyperlink{struct__Evas__Smart__Class}{Evas\_Smart\_Class}}, \mbox{\hyperlink{struct__Evas__Smart__Class}{Evas\_Smart\_Class}},
                        \mbox{\hyperlink{group__Evas__Smart__Object__Clipped_gabbb2c85a3978e44404528a94be381dcd}{evas\_object\_smart\_clipped\_class\_get}}, 
      \_smart\_callbacks);

\end{DoxyCodeInclude}
 What it does is to {\bfseries subclass} a given existing smart class, thus specializing it. This is very common and useful in Evas. There is a built-\/in smart object, the \char`\"{}clipped smart object\char`\"{}, which implements a behavior mostly desired by many other smart object implementors\+: it will clip its children to its area and move them along with it, on evas\+\_\+object\+\_\+move() calls. Then, our example smart object will get that behavior for free.

The first argument to the macro,  
\begin{DoxyCodeInclude}
\textcolor{preprocessor}{#define \_evas\_smart\_example\_type "Evas\_Smart\_Example"}

\end{DoxyCodeInclude}
 will define the new smart class\textquotesingle{} name. The second tells the macro what is the {\bfseries prefix} of the function it will be declaring with a {\ttfamily \+\_\+smart\+\_\+set\+\_\+user()} suffix. On this function, we may override/extend any desired method from our parent smart class\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* setting our smart interface */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_evas\_smart\_example\_smart\_set\_user(\mbox{\hyperlink{struct__Evas__Smart__Class}{Evas\_Smart\_Class}} *sc)
\{
   \textcolor{comment}{/* specializing these two */}
   sc->\mbox{\hyperlink{struct__Evas__Smart__Class_a044206688a3b0ea9785688d2efcea4d6}{add}} = \_evas\_smart\_example\_smart\_add;
   sc->\mbox{\hyperlink{struct__Evas__Smart__Class_a1dd96f1c822fefaa68025e35de0bbde7}{del}} = \_evas\_smart\_example\_smart\_del;

   \textcolor{comment}{/* clipped smart object has no hook on resizes or calculations */}
   sc->\mbox{\hyperlink{struct__Evas__Smart__Class_afb95f2f5616403d43c464a4d939bdcfa}{resize}} = \_evas\_smart\_example\_smart\_resize;
   sc->\mbox{\hyperlink{struct__Evas__Smart__Class_a495fe27fb074354ccaf9ebc68165ed69}{calculate}} = \_evas\_smart\_example\_smart\_calculate;
\}

\end{DoxyCodeInclude}


The first function pointer\textquotesingle{}s code will take place at an example smart object\textquotesingle{}s {\bfseries creation} time\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* create and setup a new example smart object's internals */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_evas\_smart\_example\_smart\_add(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o)
\{
   \mbox{\hyperlink{group__Evas__Smart__Group_ga4aa4b72aafa0391144fb0171aeff2ccd}{EVAS\_SMART\_DATA\_ALLOC}}(o, Evas\_Smart\_Example\_Data);

   \textcolor{comment}{/* call parent\_sc->add() before member\_adding the children, otherwise the}
\textcolor{comment}{    * smart object's clipper won't be created yet, and the children won't be}
\textcolor{comment}{    * clipped to it */}
   \_evas\_smart\_example\_parent\_sc->add(o);

   \textcolor{comment}{/* this is a border around the smart object's area, delimiting it */}
   priv->border = evas\_object\_image\_filled\_add(evas\_object\_evas\_get(o));
   evas\_object\_image\_file\_set(priv->border, border\_img\_path, NULL);
   evas\_object\_image\_border\_set(priv->border, 3, 3, 3, 3);
   evas\_object\_image\_border\_center\_fill\_set(
     priv->border, EVAS\_BORDER\_FILL\_NONE);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(priv->border);
   \mbox{\hyperlink{group__Evas__Smart__Object__Group_ga6845c17effe796430cb4fc5f2cfccef0}{evas\_object\_smart\_member\_add}}(priv->border, o);
\}

\end{DoxyCodeInclude}


The \mbox{\hyperlink{group__Evas__Smart__Group_ga4aa4b72aafa0391144fb0171aeff2ccd}{E\+V\+A\+S\+\_\+\+S\+M\+A\+R\+T\+\_\+\+D\+A\+T\+A\+\_\+\+A\+L\+L\+OC}} macro will take care of allocating our smart object data, which will be available on other contexts for us (mainly in our interface functions)\+:  
\begin{DoxyCodeInclude}
\textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Evas\_Smart\_Example\_Data Evas\_Smart\_Example\_Data;

\textcolor{comment}{/*}
\textcolor{comment}{ * This structure augments clipped smart object's instance data,}
\textcolor{comment}{ * providing extra members required by our example smart object's}
\textcolor{comment}{ * implementation.}
\textcolor{comment}{ */}
\textcolor{keyword}{struct }\_Evas\_Smart\_Example\_Data
\{
   \mbox{\hyperlink{struct__Evas__Object__Smart__Clipped__Data}{Evas\_Object\_Smart\_Clipped\_Data}} base;
   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}                   *children[2], *border;
   \textcolor{keywordtype}{int}                            child\_count;
\};

\end{DoxyCodeInclude}


See that, as we\textquotesingle{}re inheriting from the clipped smart object\textquotesingle{}s class, we {\bfseries must} have their data struct as our first member. Other data of interest for us is a child members array and the border object\textquotesingle{}s handle. The latter is what is created in the last mentioned function. Note how to tell Evas the border will be managed by our smart object from that time on\+: {\ttfamily evas\+\_\+object\+\_\+smart\+\_\+member\+\_\+add(priv-\/$>$border, o);}. The counterpart of this function is exemplified on the smart object\textquotesingle{}s interface function to remove children\+: 
\begin{DoxyCodeInclude}
\textcolor{comment}{/* remove a child element, return its pointer (or NULL on errors) */}
\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *
evas\_smart\_example\_remove(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o,
                          \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *child)
\{
   \textcolor{keywordtype}{long} idx;

   EVAS\_SMART\_EXAMPLE\_DATA\_GET\_OR\_RETURN\_VAL(o, priv, NULL);

   \textcolor{keywordflow}{if} (priv->children[0] != child && priv->children[1] != child)
     \{
        fprintf(stderr, \textcolor{stringliteral}{"You are trying to remove something not belonging to"}
                        \textcolor{stringliteral}{" the example smart object!\(\backslash\)n"});
        \textcolor{keywordflow}{return} NULL;
     \}

   idx = (long)(uintptr\_t)\mbox{\hyperlink{group__Evas__Object__Group__Extras_gafbad43015793eda4ae50202c0ce0e652}{evas\_object\_data\_get}}(child, \textcolor{stringliteral}{"index"});
   idx--;

   \_evas\_smart\_example\_remove\_do(priv, child, idx);

   \mbox{\hyperlink{group__Evas__Smart__Object__Group_gaa81bbe0af70df6c90b8fc781c59237bc}{evas\_object\_smart\_callback\_call}}(
     o, EVT\_CHILDREN\_NUMBER\_CHANGED, (\textcolor{keywordtype}{void} *)(uintptr\_t)priv->child\_count);
   \mbox{\hyperlink{group__Evas__Canvas_ga4f08aefaa29ea4bfc5b3f5c89c85dd59}{evas\_object\_smart\_changed}}(o);

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

\textcolor{comment}{/* set to return any previous object set to the left position of the}

\end{DoxyCodeInclude}


At the end of that function we make use of an constant defined by the \mbox{\hyperlink{group__Evas__Smart__Group_ga58dc94af6f064b39b2bf0155908fbe52}{E\+V\+A\+S\+\_\+\+S\+M\+A\+R\+T\+\_\+\+S\+U\+B\+C\+L\+A\+S\+S\+\_\+\+N\+EW}}\+: {\ttfamily \+\_\+evas\+\_\+smart\+\_\+example\+\_\+parent\+\_\+sc}. It has the same prefix we passed to the macro, as you can see, and it holds a pointer to our {\bfseries parent} smart class. Then, we can call the specialized method, itself, after our code. The {\ttfamily del}, {\ttfamily hide}, {\ttfamily show} and {\ttfamily resize} specializations are straightforward, we let the reader take a look at them below to check their behavior. What\textquotesingle{}s interesting is the {\ttfamily calculate} one\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* act on child objects' properties, before rendering */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_evas\_smart\_example\_smart\_calculate(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o)
\{
   \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} x, y, w, h;

   EVAS\_SMART\_EXAMPLE\_DATA\_GET\_OR\_RETURN(o, priv);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga6f52fab1a96dc58c85ee481d84bac871}{evas\_object\_geometry\_get}}(o, &x, &y, &w, &h);

   evas\_object\_resize(priv->border, w, h);
   evas\_object\_move(priv->border, x, y);

   \textcolor{keywordflow}{if} (priv->children[0])
     \{
        evas\_object\_move(priv->children[0], x + 3, y + 3);
        evas\_object\_resize(priv->children[0], (w / 2) - 3, (h / 2) - 3);
     \}

   \textcolor{keywordflow}{if} (priv->children[1])
     \{
        evas\_object\_move(priv->children[1], x + (w / 2), y + (h / 2));
        evas\_object\_resize(priv->children[1], (w / 2) - 3, (h / 2) - 3);
     \}
\}

\textcolor{comment}{/* setting our smart interface */}

\end{DoxyCodeInclude}


This code will take place whenever the smart object itself is flagged \char`\"{}dirty\char`\"{}, i.\+e., must be recalculated for rendering (that could come from changes on its clipper, resizing, moving, etc). There, we make sure the decorative border lies on the edges of the smart object and the children, if any, lie on their respective quadrants.

After instantiating our smart object, we do some checks to exemplify some of the A\+PI on smart objects\+:  
\begin{DoxyCodeInclude}
   ret = \mbox{\hyperlink{group__Evas__Canvas_ga257a2651b93de714211d4205c0e70bb9}{evas\_object\_smart\_type\_check}}(d.smt, \_evas\_smart\_example\_type);
   printf(\textcolor{stringliteral}{"Adding smart object of type \(\backslash\)"%s\(\backslash\)" to the canvas: %s.\(\backslash\)n"},
          \_evas\_smart\_example\_type, ret ? \textcolor{stringliteral}{"success"} : \textcolor{stringliteral}{"failure"});

   d.clipper = \mbox{\hyperlink{group__Evas__Canvas_ga1ea2217e8a4abc28a35d8273949d4444}{evas\_object\_smart\_clipped\_clipper\_get}}(d.smt);
   printf(\textcolor{stringliteral}{"Checking if clipped smart object's clipper is a "}
          \textcolor{stringliteral}{"\(\backslash\)"static\(\backslash\)" one: %s\(\backslash\)n"},
          evas\_object\_static\_clip\_get(d.clipper) ? \textcolor{stringliteral}{"yes"} : \textcolor{stringliteral}{"no"});

\end{DoxyCodeInclude}
 The \mbox{\hyperlink{group__Evas__Canvas_ga257a2651b93de714211d4205c0e70bb9}{evas\+\_\+object\+\_\+smart\+\_\+type\+\_\+check()}} one will assure we have the string naming our smart class really set to the live object. The \mbox{\hyperlink{group__Evas__Canvas_ga1ea2217e8a4abc28a35d8273949d4444}{evas\+\_\+object\+\_\+smart\+\_\+clipped\+\_\+clipper\+\_\+get()}} exemplifies usage of \char`\"{}static clippers\char`\"{} -- clipped smart objects have their global clippers flagged static.

Other important things we also exemplify here are {\bfseries smart callbacks} and smart callback {\bfseries introspection\+:}  
\begin{DoxyCodeInclude}
\textcolor{preprocessor}{#define EVT\_CHILDREN\_NUMBER\_CHANGED "children,changed"}

\textcolor{keyword}{static} \textcolor{keyword}{const} \mbox{\hyperlink{struct__Evas__Smart__Cb__Description}{Evas\_Smart\_Cb\_Description}} \_smart\_callbacks[] =
\{
   \{EVT\_CHILDREN\_NUMBER\_CHANGED, \textcolor{stringliteral}{"i"}\},
   \{NULL, NULL\}
\};

\end{DoxyCodeInclude}


Here we declare our array of smart callback descriptions, which has one element only, in this case. That callback will take place, as the name indicates, whenever the number of member objects in our smart object example instance changes. That global array variable must be the last argument to \mbox{\hyperlink{group__Evas__Smart__Group_ga58dc94af6f064b39b2bf0155908fbe52}{E\+V\+A\+S\+\_\+\+S\+M\+A\+R\+T\+\_\+\+S\+U\+B\+C\+L\+A\+S\+S\+\_\+\+N\+EW}}, so that it\textquotesingle{}s registered as the {\bfseries smart class}\textquotesingle{}s callbacks description.

After we instantiate the smart object, we take a look on those descriptions and register a callback on that unique smart event\+:  
\begin{DoxyCodeInclude}
   \textcolor{keywordflow}{for} (; *descriptions; descriptions++)
     \{
        printf(\textcolor{stringliteral}{"We've found a smart callback on the smart object!"}
               \textcolor{stringliteral}{"\(\backslash\)n\(\backslash\)tname: %s\(\backslash\)n\(\backslash\)ttype: %s\(\backslash\)n"}, (*descriptions)->name,
               (*descriptions)->type);

        \textcolor{keywordflow}{if} (strcmp((*descriptions)->type, \textcolor{stringliteral}{"i"})) \textcolor{keywordflow}{continue};
        \textcolor{comment}{/* we know we don't have other types of smart callbacks}
\textcolor{comment}{         * here, just playing with it */}

        \textcolor{comment}{/* for now, we know the only one callback is the one}
\textcolor{comment}{         * reporting number of member objects changed on the}
\textcolor{comment}{         * example smart object */}
        \mbox{\hyperlink{group__Evas__Smart__Object__Group_ga18a8b179f94d21b2b09e19db11741061}{evas\_object\_smart\_callback\_add}}(
          d.smt, (*descriptions)->name,
          \_on\_example\_smart\_object\_child\_num\_change, NULL);
     \}

   evas\_object\_focus\_set(d.bg, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});

\end{DoxyCodeInclude}


The code of the callback will just print how many member objects we have, which is an integer argument of the callback itself, as flagged by its description\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* callback on number of member objects changed */}
\_on\_example\_smart\_object\_child\_num\_change(\textcolor{keywordtype}{void} *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},
                                          \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj 
      \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},
                                          \textcolor{keywordtype}{void} *event\_info)
\{
   printf(\textcolor{stringliteral}{"Number of child members on our example smart"}
          \textcolor{stringliteral}{" object changed to %llu\(\backslash\)n"}, (\textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{long} \textcolor{keywordtype}{long})(uintptr\_t)event\_info);
\}

\end{DoxyCodeInclude}


One of the points at which we issue that callback is inside the {\ttfamily evas\+\_\+smart\+\_\+example\+\_\+remove()}, code that was already shown.

As in other examples, to interact with this one there\textquotesingle{}s a command line interface. A help string can be asked for with the \textquotesingle{}h\textquotesingle{} key\+:  
\begin{DoxyCodeInclude}
\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *commands = \(\backslash\)
  \textcolor{stringliteral}{"commands are:\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tl - insert child rectangle on the left\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tr - insert child rectangle on the right\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tw - remove and delete all members from the smart object\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tright arrow - move smart object to the right\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tleft arrow - move smart object to the left\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tup arrow - move smart object up\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tdown arrow - move smart object down\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)td - decrease smart object's size\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)ti - increase smart object's size\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tc - change smart object's clipper color\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)t. - rotate object to the right\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)t, - rotate object to the left\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)th - print help\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tq - quit\(\backslash\)n"}
;

\end{DoxyCodeInclude}
 Use \textquotesingle{}l\textquotesingle{} and \textquotesingle{}r\textquotesingle{} keys, to create new rectangles and place them on the left ({\ttfamily evas\+\_\+smart\+\_\+example\+\_\+set\+\_\+left()}) or right ({\ttfamily evas\+\_\+smart\+\_\+example\+\_\+set\+\_\+right()}) spots of our smart object, respectively. The \textquotesingle{}w\textquotesingle{} command will remove all member objects from the smart object and delete them. The keyboard arrows will move the smart object along the canvas. See how it takes any child objects with it during its movement. The \textquotesingle{}d\textquotesingle{} and \textquotesingle{}i\textquotesingle{} keys will increase or decrease the smart object\textquotesingle{}s size -- see how it affects the children\textquotesingle{}s sizes, too. Finally, \textquotesingle{}c\textquotesingle{} will change the color of the smart object\textquotesingle{}s clipper (which is the exact internal clipper coming from a clipped smart object)\+:  
\begin{DoxyCodeInclude}
   d.clipper = \mbox{\hyperlink{group__Evas__Canvas_ga1ea2217e8a4abc28a35d8273949d4444}{evas\_object\_smart\_clipped\_clipper\_get}}(d.smt);
   printf(\textcolor{stringliteral}{"Checking if clipped smart object's clipper is a "}
          \textcolor{stringliteral}{"\(\backslash\)"static\(\backslash\)" one: %s\(\backslash\)n"},
          evas\_object\_static\_clip\_get(d.clipper) ? \textcolor{stringliteral}{"yes"} : \textcolor{stringliteral}{"no"});

   \mbox{\hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}}(
     d.clipper, clipper\_colors[cur\_color].r, clipper\_colors[cur\_color].g,
     clipper\_colors[cur\_color].b, clipper\_colors[cur\_color].a);

\end{DoxyCodeInclude}


\char`\"{}\+Real life\char`\"{} examples of smart objects are Edje and Emotion objects\+: they both have independent libraries implementing their behavior. The full example follows.


\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} *commands = \(\backslash\)
  \textcolor{stringliteral}{"commands are:\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tl - insert child rectangle on the left\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tr - insert child rectangle on the right\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tw - remove and delete all members from the smart object\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tright arrow - move smart object to the right\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tleft arrow - move smart object to the left\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tup arrow - move smart object up\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tdown arrow - move smart object down\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)td - decrease smart object's size\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)ti - increase smart object's size\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tc - change smart object's clipper color\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)t. - rotate object to the right\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)t, - rotate object to the left\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)th - print help\(\backslash\)n"}
  \textcolor{stringliteral}{"\(\backslash\)tq - quit\(\backslash\)n"}
;

\textcolor{preprocessor}{#define WHITE \{255, 255, 255, 255\}}
\textcolor{preprocessor}{#define RED   \{255, 0, 0, 255\}}
\textcolor{preprocessor}{#define GREEN \{0, 255, 0, 255\}}
\textcolor{preprocessor}{#define BLUE  \{0, 0, 255, 255\}}

\textcolor{keyword}{struct }test\_data
\{
   Ecore\_Evas  *ee;
   \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}}        *evas;
   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *smt, *bg, *clipper, *rects[2];
\};

\textcolor{keyword}{struct }color\_tuple
\{
   \textcolor{keywordtype}{int} r, g, b, a;
\} clipper\_colors[4] = \{WHITE, RED, GREEN, BLUE\};

\textcolor{keywordtype}{int} cur\_color = 0;
\textcolor{keywordtype}{int} cur\_angle = 0;

\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *
\_index\_to\_color(\textcolor{keywordtype}{int} i)
\{
   \textcolor{keywordflow}{switch} (i)
     \{
      \textcolor{keywordflow}{case} 0:
        \textcolor{keywordflow}{return} \textcolor{stringliteral}{"WHITE (default)"};

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

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

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

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

\textcolor{keyword}{static} \textcolor{keyword}{struct }test\_data d = \{0\};
\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *border\_img\_path = PACKAGE\_EXAMPLES\_DIR EVAS\_IMAGE\_FOLDER \textcolor{stringliteral}{"/red.png"};

\textcolor{preprocessor}{#define \_evas\_smart\_example\_type "Evas\_Smart\_Example"}
\textcolor{preprocessor}{#define EVT\_CHILDREN\_NUMBER\_CHANGED "children,changed"}

\textcolor{keyword}{static} \textcolor{keyword}{const} \mbox{\hyperlink{struct__Evas__Smart__Cb__Description}{Evas\_Smart\_Cb\_Description}} \_smart\_callbacks[] =
\{
   \{EVT\_CHILDREN\_NUMBER\_CHANGED, \textcolor{stringliteral}{"i"}\},
   \{NULL, NULL\}
\};

\textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Evas\_Smart\_Example\_Data Evas\_Smart\_Example\_Data;

\textcolor{comment}{/*}
\textcolor{comment}{ * This structure augments clipped smart object's instance data,}
\textcolor{comment}{ * providing extra members required by our example smart object's}
\textcolor{comment}{ * implementation.}
\textcolor{comment}{ */}
\textcolor{keyword}{struct }\_Evas\_Smart\_Example\_Data
\{
   \mbox{\hyperlink{struct__Evas__Object__Smart__Clipped__Data}{Evas\_Object\_Smart\_Clipped\_Data}} base;
   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}}                   *children[2], *border;
   \textcolor{keywordtype}{int}                            child\_count;
\};

\textcolor{preprocessor}{#define EVAS\_SMART\_EXAMPLE\_DATA\_GET(o, ptr) \(\backslash\)}
\textcolor{preprocessor}{  Evas\_Smart\_Example\_Data * ptr = evas\_object\_smart\_data\_get(o)}

\textcolor{preprocessor}{#define EVAS\_SMART\_EXAMPLE\_DATA\_GET\_OR\_RETURN(o, ptr)        \(\backslash\)}
\textcolor{preprocessor}{  EVAS\_SMART\_EXAMPLE\_DATA\_GET(o, ptr);                       \(\backslash\)}
\textcolor{preprocessor}{  if (!ptr)                                                  \(\backslash\)}
\textcolor{preprocessor}{    \{                                                        \(\backslash\)}
\textcolor{preprocessor}{       fprintf(stderr, "No widget data for object %p (%s)!", \(\backslash\)}
\textcolor{preprocessor}{               o, evas\_object\_type\_get(o));                  \(\backslash\)}
\textcolor{preprocessor}{       fflush(stderr);                                       \(\backslash\)}
\textcolor{preprocessor}{       abort();                                              \(\backslash\)}
\textcolor{preprocessor}{       return;                                               \(\backslash\)}
\textcolor{preprocessor}{    \}}

\textcolor{preprocessor}{#define EVAS\_SMART\_EXAMPLE\_DATA\_GET\_OR\_RETURN\_VAL(o, ptr, val) \(\backslash\)}
\textcolor{preprocessor}{  EVAS\_SMART\_EXAMPLE\_DATA\_GET(o, ptr);                         \(\backslash\)}
\textcolor{preprocessor}{  if (!ptr)                                                    \(\backslash\)}
\textcolor{preprocessor}{    \{                                                          \(\backslash\)}
\textcolor{preprocessor}{       fprintf(stderr, "No widget data for object %p (%s)!",   \(\backslash\)}
\textcolor{preprocessor}{               o, evas\_object\_type\_get(o));                    \(\backslash\)}
\textcolor{preprocessor}{       fflush(stderr);                                         \(\backslash\)}
\textcolor{preprocessor}{       abort();                                                \(\backslash\)}
\textcolor{preprocessor}{       return val;                                             \(\backslash\)}
\textcolor{preprocessor}{    \}}

\mbox{\hyperlink{group__Evas__Smart__Group_ga58dc94af6f064b39b2bf0155908fbe52}{EVAS\_SMART\_SUBCLASS\_NEW}}(\_evas\_smart\_example\_type, \_evas\_smart\_example,
                        \mbox{\hyperlink{struct__Evas__Smart__Class}{Evas\_Smart\_Class}}, \mbox{\hyperlink{struct__Evas__Smart__Class}{Evas\_Smart\_Class}},
                        \mbox{\hyperlink{group__Evas__Smart__Object__Clipped_gabbb2c85a3978e44404528a94be381dcd}{evas\_object\_smart\_clipped\_class\_get}}, 
      \_smart\_callbacks);

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

\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{keywordtype}{void}
\_on\_child\_del(\textcolor{keywordtype}{void} *data,
              \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,
              \textcolor{keywordtype}{void} *einfo \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})
\{
   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *example\_smart = data;
   \textcolor{keywordtype}{long} idx;

   EVAS\_SMART\_EXAMPLE\_DATA\_GET(example\_smart, priv);

   idx = (long)(uintptr\_t)\mbox{\hyperlink{group__Evas__Object__Group__Extras_gafbad43015793eda4ae50202c0ce0e652}{evas\_object\_data\_get}}(o, \textcolor{stringliteral}{"index"});
   idx--;

   priv->children[idx] = NULL;

   \mbox{\hyperlink{group__Evas__Smart__Object__Group_ga12034359ab780a3a0e8b20b83475ed15}{evas\_object\_smart\_member\_del}}(o);
   \mbox{\hyperlink{group__Evas__Canvas_ga4f08aefaa29ea4bfc5b3f5c89c85dd59}{evas\_object\_smart\_changed}}(example\_smart);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_evas\_smart\_example\_child\_callbacks\_unregister(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj)
\{
   \mbox{\hyperlink{group__Evas__Object__Group__Extras_ga70134a7068c9bff4107a761abe0a2ad4}{evas\_object\_data\_set}}(obj, \textcolor{stringliteral}{"index"}, NULL);
   \mbox{\hyperlink{group__Evas__Object__Group__Events_gab271959a45d1d5348f6e78a14def44c2}{evas\_object\_event\_callback\_del}}(obj, 
      \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968aab869b5d534f02f1b3e151e2406a8c24}{EVAS\_CALLBACK\_FREE}}, \_on\_child\_del);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_evas\_smart\_example\_child\_callbacks\_register(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o,
                                             \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *child,
                                             \textcolor{keywordtype}{long} idx)
\{
   \mbox{\hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}}(child, 
      \mbox{\hyperlink{Evas__Common_8h_ad64cde0da38a60e7cb7905b3ab216968aab869b5d534f02f1b3e151e2406a8c24}{EVAS\_CALLBACK\_FREE}}, \_on\_child\_del, o);
   \mbox{\hyperlink{group__Evas__Object__Group__Extras_ga70134a7068c9bff4107a761abe0a2ad4}{evas\_object\_data\_set}}(child, \textcolor{stringliteral}{"index"}, (\textcolor{keywordtype}{void} *)(uintptr\_t)(++idx));
\}

\textcolor{comment}{/* create and setup a new example smart object's internals */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_evas\_smart\_example\_smart\_add(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o)
\{
   \mbox{\hyperlink{group__Evas__Smart__Group_ga4aa4b72aafa0391144fb0171aeff2ccd}{EVAS\_SMART\_DATA\_ALLOC}}(o, Evas\_Smart\_Example\_Data);

   \textcolor{comment}{/* call parent\_sc->add() before member\_adding the children, otherwise the}
\textcolor{comment}{    * smart object's clipper won't be created yet, and the children won't be}
\textcolor{comment}{    * clipped to it */}
   \_evas\_smart\_example\_parent\_sc->add(o);

   \textcolor{comment}{/* this is a border around the smart object's area, delimiting it */}
   priv->border = evas\_object\_image\_filled\_add(evas\_object\_evas\_get(o));
   evas\_object\_image\_file\_set(priv->border, border\_img\_path, NULL);
   evas\_object\_image\_border\_set(priv->border, 3, 3, 3, 3);
   evas\_object\_image\_border\_center\_fill\_set(
     priv->border, EVAS\_BORDER\_FILL\_NONE);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(priv->border);
   \mbox{\hyperlink{group__Evas__Smart__Object__Group_ga6845c17effe796430cb4fc5f2cfccef0}{evas\_object\_smart\_member\_add}}(priv->border, o);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_evas\_smart\_example\_smart\_del(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o)
\{
   EVAS\_SMART\_EXAMPLE\_DATA\_GET(o, priv);

   \textcolor{keywordflow}{if} (priv->children[0])
     \{
        \_evas\_smart\_example\_child\_callbacks\_unregister(priv->children[0]);
        priv->children[0] = NULL;
     \}

   \textcolor{keywordflow}{if} (priv->children[1])
     \{
        \_evas\_smart\_example\_child\_callbacks\_unregister(priv->children[1]);
        priv->children[1] = NULL;
     \}

   \_evas\_smart\_example\_parent\_sc->del(o);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_evas\_smart\_example\_smart\_resize(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o,
                                 \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} w,
                                 \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} h)
\{
   \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} ow, oh;
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga6f52fab1a96dc58c85ee481d84bac871}{evas\_object\_geometry\_get}}(o, NULL, NULL, &ow, &oh);
   \textcolor{keywordflow}{if} ((ow == w) && (oh == h)) \textcolor{keywordflow}{return};

   \textcolor{comment}{/* this will trigger recalculation */}
   \mbox{\hyperlink{group__Evas__Canvas_ga4f08aefaa29ea4bfc5b3f5c89c85dd59}{evas\_object\_smart\_changed}}(o);
\}

\textcolor{comment}{/* act on child objects' properties, before rendering */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_evas\_smart\_example\_smart\_calculate(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o)
\{
   \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} x, y, w, h;

   EVAS\_SMART\_EXAMPLE\_DATA\_GET\_OR\_RETURN(o, priv);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga6f52fab1a96dc58c85ee481d84bac871}{evas\_object\_geometry\_get}}(o, &x, &y, &w, &h);

   evas\_object\_resize(priv->border, w, h);
   evas\_object\_move(priv->border, x, y);

   \textcolor{keywordflow}{if} (priv->children[0])
     \{
        evas\_object\_move(priv->children[0], x + 3, y + 3);
        evas\_object\_resize(priv->children[0], (w / 2) - 3, (h / 2) - 3);
     \}

   \textcolor{keywordflow}{if} (priv->children[1])
     \{
        evas\_object\_move(priv->children[1], x + (w / 2), y + (h / 2));
        evas\_object\_resize(priv->children[1], (w / 2) - 3, (h / 2) - 3);
     \}
\}

\textcolor{comment}{/* setting our smart interface */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_evas\_smart\_example\_smart\_set\_user(\mbox{\hyperlink{struct__Evas__Smart__Class}{Evas\_Smart\_Class}} *sc)
\{
   \textcolor{comment}{/* specializing these two */}
   sc->\mbox{\hyperlink{struct__Evas__Smart__Class_a044206688a3b0ea9785688d2efcea4d6}{add}} = \_evas\_smart\_example\_smart\_add;
   sc->\mbox{\hyperlink{struct__Evas__Smart__Class_a1dd96f1c822fefaa68025e35de0bbde7}{del}} = \_evas\_smart\_example\_smart\_del;

   \textcolor{comment}{/* clipped smart object has no hook on resizes or calculations */}
   sc->\mbox{\hyperlink{struct__Evas__Smart__Class_afb95f2f5616403d43c464a4d939bdcfa}{resize}} = \_evas\_smart\_example\_smart\_resize;
   sc->\mbox{\hyperlink{struct__Evas__Smart__Class_a495fe27fb074354ccaf9ebc68165ed69}{calculate}} = \_evas\_smart\_example\_smart\_calculate;
\}

\textcolor{comment}{/* BEGINS example smart object's own interface */}

\textcolor{comment}{/* add a new example smart object to a canvas */}
\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *
evas\_smart\_example\_add(\mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *evas)
\{
   \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Evas__Smart__Object__Group_gad80de73a33446f902d4b39141a8d0a05}{evas\_object\_smart\_add}}(evas, \_evas\_smart\_example\_smart\_class\_new());
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_evas\_smart\_example\_remove\_do(Evas\_Smart\_Example\_Data *priv,
                              \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *child,
                              \textcolor{keywordtype}{int} idx)
\{
   priv->children[idx] = NULL;
   priv->child\_count--;
   \_evas\_smart\_example\_child\_callbacks\_unregister(child);
   \mbox{\hyperlink{group__Evas__Smart__Object__Group_ga12034359ab780a3a0e8b20b83475ed15}{evas\_object\_smart\_member\_del}}(child);
\}

\textcolor{comment}{/* remove a child element, return its pointer (or NULL on errors) */}
\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *
evas\_smart\_example\_remove(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o,
                          \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *child)
\{
   \textcolor{keywordtype}{long} idx;

   EVAS\_SMART\_EXAMPLE\_DATA\_GET\_OR\_RETURN\_VAL(o, priv, NULL);

   \textcolor{keywordflow}{if} (priv->children[0] != child && priv->children[1] != child)
     \{
        fprintf(stderr, \textcolor{stringliteral}{"You are trying to remove something not belonging to"}
                        \textcolor{stringliteral}{" the example smart object!\(\backslash\)n"});
        \textcolor{keywordflow}{return} NULL;
     \}

   idx = (long)(uintptr\_t)\mbox{\hyperlink{group__Evas__Object__Group__Extras_gafbad43015793eda4ae50202c0ce0e652}{evas\_object\_data\_get}}(child, \textcolor{stringliteral}{"index"});
   idx--;

   \_evas\_smart\_example\_remove\_do(priv, child, idx);

   \mbox{\hyperlink{group__Evas__Smart__Object__Group_gaa81bbe0af70df6c90b8fc781c59237bc}{evas\_object\_smart\_callback\_call}}(
     o, EVT\_CHILDREN\_NUMBER\_CHANGED, (\textcolor{keywordtype}{void} *)(uintptr\_t)priv->child\_count);
   \mbox{\hyperlink{group__Evas__Canvas_ga4f08aefaa29ea4bfc5b3f5c89c85dd59}{evas\_object\_smart\_changed}}(o);

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

\textcolor{comment}{/* set to return any previous object set to the left position of the}
\textcolor{comment}{ * smart object or NULL, if any (or on errors) */}
\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *
evas\_smart\_example\_set\_left(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o,
                            \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *child)
\{
   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *ret = NULL;

   EVAS\_SMART\_EXAMPLE\_DATA\_GET\_OR\_RETURN\_VAL(o, priv, NULL);
   \textcolor{keywordflow}{if} (!child)
     \textcolor{keywordflow}{return} NULL;

   \textcolor{keywordflow}{if} (priv->children[1] == child)
     \{
        fprintf(stderr, \textcolor{stringliteral}{"You mustn't place a child on both slots of"}
                        \textcolor{stringliteral}{" the example smart object!\(\backslash\)n"});
        \textcolor{keywordflow}{return} NULL;
     \}

   \textcolor{keywordflow}{if} (priv->children[0])
     \{
        \textcolor{keywordflow}{if} (priv->children[0] != child)
          \{
             ret = priv->children[0];
             \_evas\_smart\_example\_remove\_do(priv, priv->children[0], 0);
          \}
        \textcolor{keywordflow}{else} \textcolor{keywordflow}{return} child;
     \}

   priv->children[0] = child;
   \_evas\_smart\_example\_child\_callbacks\_register(o, child, 0);
   \mbox{\hyperlink{group__Evas__Smart__Object__Group_ga6845c17effe796430cb4fc5f2cfccef0}{evas\_object\_smart\_member\_add}}(child, o);
   \mbox{\hyperlink{group__Evas__Canvas_ga4f08aefaa29ea4bfc5b3f5c89c85dd59}{evas\_object\_smart\_changed}}(o);

   priv->child\_count++;
   \textcolor{keywordflow}{if} (!ret)
     \{
        \mbox{\hyperlink{group__Evas__Smart__Object__Group_gaa81bbe0af70df6c90b8fc781c59237bc}{evas\_object\_smart\_callback\_call}}(
          o, EVT\_CHILDREN\_NUMBER\_CHANGED, (\textcolor{keywordtype}{void} *)(uintptr\_t)priv->child\_count);
     \}

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

\textcolor{comment}{/* set to return any previous object set to the right position of the}
\textcolor{comment}{ * smart object or NULL, if any (or on errors) */}
\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *
evas\_smart\_example\_set\_right(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o,
                             \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *child)
\{
   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *ret = NULL;

   EVAS\_SMART\_EXAMPLE\_DATA\_GET\_OR\_RETURN\_VAL(o, priv, NULL);
   \textcolor{keywordflow}{if} (!child)
     \textcolor{keywordflow}{return} NULL;

   \textcolor{keywordflow}{if} (priv->children[0] == child)
     \{
        fprintf(stderr, \textcolor{stringliteral}{"You mustn't place a child on both slots of"}
                        \textcolor{stringliteral}{" the example smart object!\(\backslash\)n"});
        \textcolor{keywordflow}{return} NULL;
     \}

   \textcolor{keywordflow}{if} (priv->children[1])
     \{
        \textcolor{keywordflow}{if} (priv->children[1] != child)
          \{
             ret = priv->children[1];
             \_evas\_smart\_example\_remove\_do(priv, priv->children[1], 1);
          \}
        \textcolor{keywordflow}{else} \textcolor{keywordflow}{return} child;
     \}

   priv->children[1] = child;
   \_evas\_smart\_example\_child\_callbacks\_register(o, child, 1);
   \mbox{\hyperlink{group__Evas__Smart__Object__Group_ga6845c17effe796430cb4fc5f2cfccef0}{evas\_object\_smart\_member\_add}}(child, o);
   \mbox{\hyperlink{group__Evas__Canvas_ga4f08aefaa29ea4bfc5b3f5c89c85dd59}{evas\_object\_smart\_changed}}(o);

   priv->child\_count++;
   \textcolor{keywordflow}{if} (!ret)
     \{
        \mbox{\hyperlink{group__Evas__Smart__Object__Group_gaa81bbe0af70df6c90b8fc781c59237bc}{evas\_object\_smart\_callback\_call}}(
          o, EVT\_CHILDREN\_NUMBER\_CHANGED, (\textcolor{keywordtype}{void} *)(uintptr\_t)priv->child\_count);
     \}

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

\textcolor{comment}{/* END OF example smart object's own interface */}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_map\_update(\textcolor{keywordtype}{void})
\{
   Evas\_Map *m;
   \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} x, y, w, h;

   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga6f52fab1a96dc58c85ee481d84bac871}{evas\_object\_geometry\_get}}(d.smt, &x, &y, &w, &h);
   m = \mbox{\hyperlink{group__Evas__Object__Group__Map_ga68a1a6d2dfdd5c9d88a9200eb78cca4e}{evas\_map\_new}}(4);
   \mbox{\hyperlink{group__Evas__Object__Group__Map_gaa21f5c7338fbb125b8e50890b3fefb91}{evas\_map\_util\_points\_populate\_from\_object}}(m, d.smt);
   \mbox{\hyperlink{group__Evas__Object__Group__Map_ga0db530bdf4f619b3c9c4c74c3e87ccac}{evas\_map\_util\_rotate}}(m, cur\_angle, x + (w / 2), y + (h / 2));
   evas\_object\_map\_set(d.smt, m);
   evas\_object\_map\_enable\_set(d.smt, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});
   \mbox{\hyperlink{group__Evas__Object__Group__Map_gab3e18d6086e352b121a57c130041bb24}{evas\_map\_free}}(m);
\}

\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}{"q"}) == 0) \textcolor{comment}{/* print help */}
     \{
        \_on\_destroy(NULL);
        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"h"}) == 0) \textcolor{comment}{/* print help */}
     \{
        puts(commands);
        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"w"}) == 0) \textcolor{comment}{/* clear out smart object (WRT}
\textcolor{comment}{                                       * members) */}
     \{
        \textcolor{keywordflow}{if} (d.rects[0])
          \{
             evas\_smart\_example\_remove(d.smt, d.rects[0]);
             \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga7e7a625dab7a3890532aa13b43117076}{evas\_object\_del}}(d.rects[0]);
          \}
        \textcolor{keywordflow}{if} (d.rects[1])
          \{
             evas\_smart\_example\_remove(d.smt, d.rects[1]);
             \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga7e7a625dab7a3890532aa13b43117076}{evas\_object\_del}}(d.rects[1]);
          \}

        memset(d.rects, 0, \textcolor{keyword}{sizeof}(d.rects));

        printf(\textcolor{stringliteral}{"Deleting all members of the smart object.\(\backslash\)n"});

        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"l"}) == 0) \textcolor{comment}{/* insert random colored}
\textcolor{comment}{                                       * rectangle on the left */}
     \{
        \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *rect = \mbox{\hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}}(d.evas), *prev;
        \mbox{\hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}}(
          rect, rand() % 255, rand() % 255, rand() % 255, 255);
        \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(rect);

        prev = evas\_smart\_example\_set\_left(d.smt, rect);
        d.rects[0] = rect;

        printf(\textcolor{stringliteral}{"Setting smart object's left spot with a new rectangle.\(\backslash\)n"});
        printf(\textcolor{stringliteral}{"Checking its new smart object parent: %s\(\backslash\)n"},
               evas\_object\_smart\_parent\_get(rect) == d.smt ? \textcolor{stringliteral}{"OK!"} :
               \textcolor{stringliteral}{"Failure!"});
        \textcolor{keywordflow}{if} (prev)
          \{
             \textcolor{keywordtype}{int} r, g, b;

             \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga0854bae878bfc39f51b9c989353c973f}{evas\_object\_color\_get}}(prev, &r, &g, &b, NULL);
             printf(\textcolor{stringliteral}{"Deleting previous left child,"}
                    \textcolor{stringliteral}{" which had colors (%d, %d, %d)\(\backslash\)n"}, r, g, b);
             \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga7e7a625dab7a3890532aa13b43117076}{evas\_object\_del}}(prev);
          \}

        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"r"}) == 0) \textcolor{comment}{/* insert random colored}
\textcolor{comment}{                                       * rectangle on the right */}
     \{
        \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *rect = \mbox{\hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}}(d.evas), *prev;
        \mbox{\hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}}(
          rect, rand() % 255, rand() % 255, rand() % 255, 255);
        \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(rect);

        prev = evas\_smart\_example\_set\_right(d.smt, rect);
        d.rects[1] = rect;

        printf(\textcolor{stringliteral}{"Setting smart object's right spot with a new rectangle.\(\backslash\)n"});
        printf(\textcolor{stringliteral}{"Checking its new smart object parent: %s\(\backslash\)n"},
               evas\_object\_smart\_parent\_get(rect) == d.smt ? \textcolor{stringliteral}{"OK!"} :
               \textcolor{stringliteral}{"Failure!"});
        \textcolor{keywordflow}{if} (prev)
          \{
             \textcolor{keywordtype}{int} r, g, b;

             \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga0854bae878bfc39f51b9c989353c973f}{evas\_object\_color\_get}}(prev, &r, &g, &b, NULL);
             printf(\textcolor{stringliteral}{"Deleting previous right child,"}
                    \textcolor{stringliteral}{" which had colors (%d, %d, %d)\(\backslash\)n"}, r, g, b);
             \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga7e7a625dab7a3890532aa13b43117076}{evas\_object\_del}}(prev);
          \}

        \textcolor{keywordflow}{return};
     \}

   \textcolor{comment}{/* move smart object along the canvas */}
   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"Right"}) == 0 || strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"Left"}) == 0 ||
       strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"Up"}) == 0 || strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"Down"}) == 0)
     \{
        \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} x, y;

        \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga6f52fab1a96dc58c85ee481d84bac871}{evas\_object\_geometry\_get}}(d.smt, &x, &y, NULL, NULL);

        \textcolor{keywordflow}{switch} (ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}[0])
          \{
           \textcolor{keywordflow}{case} \textcolor{charliteral}{'R'}:
             x += 20;
             \textcolor{keywordflow}{break};

           \textcolor{keywordflow}{case} \textcolor{charliteral}{'L'}:
             x -= 20;
             \textcolor{keywordflow}{break};

           \textcolor{keywordflow}{case} \textcolor{charliteral}{'U'}:
             y -= 20;
             \textcolor{keywordflow}{break};

           \textcolor{keywordflow}{case} \textcolor{charliteral}{'D'}:
             y += 20;
             \textcolor{keywordflow}{break};
          \}

        evas\_object\_move(d.smt, x, y);
        \_map\_update();

        \textcolor{keywordflow}{return};
     \}

   \textcolor{comment}{/* increase smart object's size */}
   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"i"}) == 0)
     \{
        \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} w, h;

        \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga6f52fab1a96dc58c85ee481d84bac871}{evas\_object\_geometry\_get}}(d.smt, NULL, NULL, &w, &h);

        w *= 1.1;
        h *= 1.1;

        evas\_object\_resize(d.smt, w, h);
        \_map\_update();

        \textcolor{keywordflow}{return};
     \}

   \textcolor{comment}{/* decrease smart object's size */}
   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"d"}) == 0)
     \{
        \mbox{\hyperlink{Evas__Common_8h_a2453e92182bad3b0e0d84e5aff433b07}{Evas\_Coord}} w, h;

        \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga6f52fab1a96dc58c85ee481d84bac871}{evas\_object\_geometry\_get}}(d.smt, NULL, NULL, &w, &h);

        w *= 0.9;
        h *= 0.9;

        evas\_object\_resize(d.smt, w, h);
        \_map\_update();

        \textcolor{keywordflow}{return};
     \}

   \textcolor{comment}{/* change smart object's clipper color */}
   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"c"}) == 0)
     \{
        cur\_color = (cur\_color + 1) % 4;

        \mbox{\hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}}(
          d.clipper, clipper\_colors[cur\_color].r, clipper\_colors[cur\_color].g,
          clipper\_colors[cur\_color].b, clipper\_colors[cur\_color].a);

        fprintf(stderr, \textcolor{stringliteral}{"Changing clipper's color to %s\(\backslash\)n"},
                \_index\_to\_color(cur\_color));

        \textcolor{keywordflow}{return};
     \}

   \textcolor{comment}{/* rotate object to the right */}
   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"period"}) == 0)
     \{
        cur\_angle = (cur\_angle + 30) % 360;
        \_map\_update();
        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}}, \textcolor{stringliteral}{"comma"}) == 0)
     \{
        cur\_angle = (cur\_angle - 30) % 360;
        \_map\_update();
        \textcolor{keywordflow}{return};
     \}

   fprintf(stderr, \textcolor{stringliteral}{"Invalid key: '%s'\(\backslash\)n"}, ev->\mbox{\hyperlink{struct__Evas__Event__Key__Down_a70473bba88a1afaee180a54150513824}{key}});
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\textcolor{comment}{/* callback on number of member objects changed */}
\_on\_example\_smart\_object\_child\_num\_change(\textcolor{keywordtype}{void} *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},
                                          \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj 
      \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},
                                          \textcolor{keywordtype}{void} *event\_info)
\{
   printf(\textcolor{stringliteral}{"Number of child members on our example smart"}
          \textcolor{stringliteral}{" object changed to %llu\(\backslash\)n"}, (\textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{long} \textcolor{keywordtype}{long})(uintptr\_t)event\_info);
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{void})
\{
   \textcolor{keyword}{const} \mbox{\hyperlink{struct__Evas__Smart__Cb__Description}{Evas\_Smart\_Cb\_Description}} **descriptions;
   \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} count;
   \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}} ret;

   srand(time(NULL));

   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Ecore__Evas__Group_ga32ddbb6457033ad435a177eb0c4fe235}{ecore\_evas\_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} error;

   \mbox{\hyperlink{group__Ecore__Evas__Group_ga3680b5c89157167318192157a5d24ec4}{ecore\_evas\_callback\_destroy\_set}}(d.ee, \_on\_destroy);
   \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.evas = \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.evas);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}}(d.bg, 255, 255, 255, 255);
   evas\_object\_move(d.bg, 0, 0);
   evas\_object\_resize(d.bg, WIDTH, HEIGHT);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(d.bg);

   d.smt = evas\_smart\_example\_add(d.evas);
   evas\_object\_move(d.smt, WIDTH / 4, HEIGHT / 4);
   evas\_object\_resize(d.smt, WIDTH / 2, HEIGHT / 2);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(d.smt);

   ret = \mbox{\hyperlink{group__Evas__Canvas_ga257a2651b93de714211d4205c0e70bb9}{evas\_object\_smart\_type\_check}}(d.smt, \_evas\_smart\_example\_type);
   printf(\textcolor{stringliteral}{"Adding smart object of type \(\backslash\)"%s\(\backslash\)" to the canvas: %s.\(\backslash\)n"},
          \_evas\_smart\_example\_type, ret ? \textcolor{stringliteral}{"success"} : \textcolor{stringliteral}{"failure"});

   d.clipper = \mbox{\hyperlink{group__Evas__Canvas_ga1ea2217e8a4abc28a35d8273949d4444}{evas\_object\_smart\_clipped\_clipper\_get}}(d.smt);
   printf(\textcolor{stringliteral}{"Checking if clipped smart object's clipper is a "}
          \textcolor{stringliteral}{"\(\backslash\)"static\(\backslash\)" one: %s\(\backslash\)n"},
          evas\_object\_static\_clip\_get(d.clipper) ? \textcolor{stringliteral}{"yes"} : \textcolor{stringliteral}{"no"});

   \mbox{\hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}}(
     d.clipper, clipper\_colors[cur\_color].r, clipper\_colors[cur\_color].g,
     clipper\_colors[cur\_color].b, clipper\_colors[cur\_color].a);

   \mbox{\hyperlink{group__Evas__Canvas_ga78cb1ef59bcf3e20e2b437dbf1f5aac8}{evas\_object\_smart\_callbacks\_descriptions\_get}}(
     d.smt, &descriptions, &count, NULL, NULL);

   \textcolor{keywordflow}{for} (; *descriptions; descriptions++)
     \{
        printf(\textcolor{stringliteral}{"We've found a smart callback on the smart object!"}
               \textcolor{stringliteral}{"\(\backslash\)n\(\backslash\)tname: %s\(\backslash\)n\(\backslash\)ttype: %s\(\backslash\)n"}, (*descriptions)->name,
               (*descriptions)->type);

        \textcolor{keywordflow}{if} (strcmp((*descriptions)->type, \textcolor{stringliteral}{"i"})) \textcolor{keywordflow}{continue};
        \textcolor{comment}{/* we know we don't have other types of smart callbacks}
\textcolor{comment}{         * here, just playing with it */}

        \textcolor{comment}{/* for now, we know the only one callback is the one}
\textcolor{comment}{         * reporting number of member objects changed on the}
\textcolor{comment}{         * example smart object */}
        \mbox{\hyperlink{group__Evas__Smart__Object__Group_ga18a8b179f94d21b2b09e19db11741061}{evas\_object\_smart\_callback\_add}}(
          d.smt, (*descriptions)->name,
          \_on\_example\_smart\_object\_child\_num\_change, NULL);
     \}

   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);

   puts(commands);
   \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"});
   \mbox{\hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}}();
   \textcolor{keywordflow}{return} -1;
\}
\end{DoxyCodeInclude}
 