\hypertarget{evas-smart-interface_8c-example}{}\section{evas-\/smart-\/interface.\+c}

\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}{#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\)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{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 \textcolor{stringliteral}{"/red.png"};

\textcolor{preprocessor}{#define \_evas\_smart\_example\_type "Evas\_Smart\_Example"}

\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} iface1\_data[] = \textcolor{stringliteral}{"iface1\_data"};
\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} IFACE1\_NAME[] = \textcolor{stringliteral}{"iface1"};

\textcolor{keyword}{static} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}} \_iface1\_add(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *);
\textcolor{keyword}{static} \textcolor{keywordtype}{void}      \_iface1\_del(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *);
\textcolor{keyword}{static} \textcolor{keywordtype}{void}      \_iface1\_custom\_fn(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *);

\textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Evas\_Smart\_Example\_Interface Evas\_Smart\_Example\_Interface;
\textcolor{keyword}{struct }\_Evas\_Smart\_Example\_Interface
\{
   \mbox{\hyperlink{struct__Evas__Smart__Interface}{Evas\_Smart\_Interface}} base;
   void                 (*example\_func)(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj);
\};

\textcolor{keyword}{static} Evas\_Smart\_Example\_Interface iface1;

\textcolor{keyword}{static} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}
\_iface1\_add(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})
\{
   printf(\textcolor{stringliteral}{"iface1's add()!\(\backslash\)n"});

   \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_iface1\_del(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj)
\{
   printf(\textcolor{stringliteral}{"iface1's del()! Data is %s\(\backslash\)n"},
          (\textcolor{keywordtype}{char} *)\mbox{\hyperlink{group__Evas__Canvas_gaed3359faaae2d7cffd3e24441591da04}{evas\_object\_smart\_interface\_data\_get}}
          (obj, (\mbox{\hyperlink{struct__Evas__Smart__Interface}{Evas\_Smart\_Interface}} *)&iface1));
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_iface1\_custom\_fn(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})
\{
   printf(\textcolor{stringliteral}{"iface1's custom\_fn()!\(\backslash\)n"});
\}

\textcolor{keyword}{static} \textcolor{keyword}{const} \mbox{\hyperlink{struct__Evas__Smart__Interface}{Evas\_Smart\_Interface}} *\_smart\_interfaces[] =
\{
   (\mbox{\hyperlink{struct__Evas__Smart__Interface}{Evas\_Smart\_Interface}} *)&iface1, NULL
\};

\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_ga647c0365b6819db617e5e8dc33d592f6}{EVAS\_SMART\_SUBCLASS\_IFACE\_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,
  \_smart\_interfaces);

\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}{/* 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__Smart__Object__Group_ga6845c17effe796430cb4fc5f2cfccef0}{evas\_object\_smart\_member\_add}}(priv->border, o);

   \_evas\_smart\_example\_parent\_sc->add(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\_show(\mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *o)
\{
   EVAS\_SMART\_EXAMPLE\_DATA\_GET(o, priv);

   \textcolor{keywordflow}{if} (priv->children[0]) \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(priv->children[0]);
   \textcolor{keywordflow}{if} (priv->children[1]) \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(priv->children[1]);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(priv->border);

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

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

   \textcolor{keywordflow}{if} (priv->children[0]) \mbox{\hyperlink{group__Evas__Object__Group__Basic_gacc307a0d7bfc9df151fd9ec75808c587}{evas\_object\_hide}}(priv->children[0]);
   \textcolor{keywordflow}{if} (priv->children[1]) \mbox{\hyperlink{group__Evas__Object__Group__Basic_gacc307a0d7bfc9df151fd9ec75808c587}{evas\_object\_hide}}(priv->children[1]);
   \mbox{\hyperlink{group__Evas__Object__Group__Basic_gacc307a0d7bfc9df151fd9ec75808c587}{evas\_object\_hide}}(priv->border);

   \_evas\_smart\_example\_parent\_sc->hide(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;
   sc->\mbox{\hyperlink{struct__Evas__Smart__Class_a1aa57fda1f2e428b91e771a1d3a3a9de}{show}} = \_evas\_smart\_example\_smart\_show;
   sc->\mbox{\hyperlink{struct__Evas__Smart__Class_ad48724181a7379c046e754b20ece69b8}{hide}} = \_evas\_smart\_example\_smart\_hide;

   \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}
\_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 */}
     \{
        printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, 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"}
               \textcolor{stringliteral}{" 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"}
               \textcolor{stringliteral}{" 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);

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

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

        \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{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;
   Evas\_Smart\_Example\_Interface *iface;
   \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);

   iface = (Evas\_Smart\_Example\_Interface *)&iface1;
   iface->base.name = IFACE1\_NAME;
   iface->base.private\_size = \textcolor{keyword}{sizeof}(iface1\_data);
   iface->base.add = \_iface1\_add;
   iface->base.del = \_iface1\_del;
   iface->example\_func = \_iface1\_custom\_fn;

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

   iface = (Evas\_Smart\_Example\_Interface *)\mbox{\hyperlink{group__Evas__Canvas_ga726849e13d3bbc0c7ce182e3f82ce07f}{evas\_object\_smart\_interface\_get}}
       (d.smt, IFACE1\_NAME);
   \textcolor{keywordflow}{if} (iface)
     \{
        \textcolor{keywordtype}{char} *data;

        printf(\textcolor{stringliteral}{"We've found a smart interface on the smart object!"}
               \textcolor{stringliteral}{"\(\backslash\)n\(\backslash\)tname: %s\(\backslash\)n"}, iface->base.name);

        printf(\textcolor{stringliteral}{"Setting its interface data...\(\backslash\)n"});
        data = \mbox{\hyperlink{group__Evas__Canvas_gaed3359faaae2d7cffd3e24441591da04}{evas\_object\_smart\_interface\_data\_get}}
            (d.smt, (\mbox{\hyperlink{struct__Evas__Smart__Interface}{Evas\_Smart\_Interface}} *)iface);
        memcpy(data, iface1\_data, \textcolor{keyword}{sizeof}(iface1\_data));

        printf(\textcolor{stringliteral}{"Calling an interface's function...\(\backslash\)n"});
        iface->example\_func(d.smt);
     \}

   printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, 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}
 