

This example shows how to manipulate and change Color classes. In this example we will create two surfaces to show what happens when you change the color class at the process and object level.

It's a very simple example, there are two surfaces created from the same E\+D\+C, but just in one of them we will set a specific color class, although both will be affected by color class set at the process level as you will see.

It's important you know that all colors has the format R G B A. Just to be easier to understand this example, we will create a small set of colors that will be used along of the example. This piece of code is shown below\+: 
\begin{DoxyCodeInclude}
\textcolor{keyword}{static} color colors\_init\_data[] =
  \{\{255, 0, 0, 255\},            \textcolor{comment}{/* red */}
   \{0, 255, 0, 255\},            \textcolor{comment}{/* green */}
   \{0, 0, 255, 255\},            \textcolor{comment}{/* blue */}
   \{0, 0, 0, 255\},              \textcolor{comment}{/* black */}
   \{255, 255, 255, 255\},        \textcolor{comment}{/* white */}
   \{128, 128, 128, 255\},        \textcolor{comment}{/* gray */}
   \{255, 255, 0, 255\},          \textcolor{comment}{/* yellow */}
   \{255, 0, 255, 255\}           \textcolor{comment}{/* pink */}
  \};

\textcolor{keyword}{static} \textcolor{keywordtype}{char} *color\_names[] =
  \{\textcolor{stringliteral}{"red"}, \textcolor{stringliteral}{"green"}, \textcolor{stringliteral}{"blue"}, \textcolor{stringliteral}{"black"}, \textcolor{stringliteral}{"white"},
   \textcolor{stringliteral}{"gray"}, \textcolor{stringliteral}{"yellow"}, \textcolor{stringliteral}{"pink"}\};

\textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
\_get\_color\_from\_name(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *n, color *c)
\{
   \textcolor{keywordtype}{int} i;
   \textcolor{keywordflow}{for} (i = 0; i < 8; i++)
     \textcolor{keywordflow}{if} (!strcmp(n, color\_names[i]))
       \{
          (*c)[0] = (colors\_init\_data[i])[0];
          (*c)[1] = (colors\_init\_data[i])[1];
          (*c)[2] = (colors\_init\_data[i])[2];
          (*c)[3] = (colors\_init\_data[i])[3];
          \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE};
       \}

   \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE};
\}

\end{DoxyCodeInclude}


Focusing on the relevant parts of the code we go right to the part where we set the new color class. For that we will use the functions edje\+\_\+color\+\_\+class\+\_\+set ( which will affect all edjes) and edje\+\_\+object\+\_\+color\+\_\+class\+\_\+set (which affects just the specific object). 
\begin{DoxyCodeInclude}
   \hyperlink{group__Edje__Object__Color__Class_ga684435de625bdbb996e405e3eaaa54ad}{edje\_color\_class\_set}(argv[1],                     \textcolor{comment}{/* class name   */}
                        c1[0], c1[1], c1[2], c1[3],  \textcolor{comment}{/* Object color */}
                        c2[0], c2[1], c2[2], c2[3],  \textcolor{comment}{/* Text outline */}
                        c3[0], c3[1], c3[2], c3[3]); \textcolor{comment}{/* Text shadow  */}

   \textcolor{comment}{/* Setting an arbitrary value just to see the difference between */}
   \textcolor{comment}{/* process level and object level */}
   edje\_object\_color\_class\_set(edje\_obj2, argv[1], \textcolor{comment}{/* class name   */}
                               128, 180, 77, 255,  \textcolor{comment}{/* Object color */}
                               200, 22, 86, 255,   \textcolor{comment}{/* Text outline */}
                               39, 90, 187, 255);  \textcolor{comment}{/* Text shadow  */}

\end{DoxyCodeInclude}
 \begin{DoxyNote}{Note}

\begin{DoxyItemize}
\item argv\mbox{[}1\mbox{]} is the name of a color class used in the E\+D\+C.
\item The second and third colors only apply to text part.
\item The color class set for the object overrides the color previously set.
\end{DoxyItemize}
\end{DoxyNote}
After we have set the color class we will check the color classes, for that we created a function which prints all color classes and tries to get theirs values and print too.  
\begin{DoxyCodeInclude}
\_color\_classes\_print(\textcolor{keywordtype}{void})
\{
   \hyperlink{struct__Eina__List}{Eina\_List} *classes;
   \textcolor{keywordtype}{char} *class\_name;

   fprintf(stdout, \textcolor{stringliteral}{"Getting the color classes\(\backslash\)n\(\backslash\)n"});
   classes = \hyperlink{group__Edje__Object__Color__Class_gac9de6885daf1eea7d3f6e3e822a4ca65}{edje\_color\_class\_list}();
   \hyperlink{group__Eina__List__Group_gae27a2c686a0a11693f9b06957c9bba83}{EINA\_LIST\_FREE}(classes, class\_name)
     \{
        \textcolor{keywordtype}{int} r1, r2, r3, g1, g2, g3, b1, b2, b3,
          a1, a2, a3;

        fprintf(stdout, \textcolor{stringliteral}{"\(\backslash\)ncolor class: %s\(\backslash\)n"}, class\_name);
        \textcolor{keywordflow}{if} (!\hyperlink{group__Edje__Object__Color__Class_gaf4e14706bc9766011ca60862f057d56e}{edje\_color\_class\_get}(class\_name, &r1, &g1, &b1, &a1,
                                  &r2, &g2, &b2, &a2, &r3, &g3, &b3, &a3))
          fprintf(stderr, \textcolor{stringliteral}{"Cannot get the color class\(\backslash\)n"});
        \textcolor{keywordflow}{else}
          \{

             fprintf(stdout,\textcolor{stringliteral}{"Object color r: %d g: %d b: %d a: %d\(\backslash\)n"},
                     r1, g1, b1, a1);
             fprintf(stdout,\textcolor{stringliteral}{"Text outline color r: %d g: %d b: %d a: %d\(\backslash\)n"},
                     r2, g2, b2, a2);
             fprintf(stdout,\textcolor{stringliteral}{"Text shadow color r: %d g: %d b: %d a: %d\(\backslash\)n"},
                     r3, g3, b3, a3);
          \}
        free(class\_name);
     \}
\}

\end{DoxyCodeInclude}


There are two other things that are worth mentioning, we added two callbacks for the objects, one for mouse down (that we use to delete the color class) and another for the signal emmited when a color class is deleted. 
\begin{DoxyCodeInclude}
   \hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}(edje\_obj1, 
      \hyperlink{Evas__Common_8h_a99e208e463a20499aabe6faac8a8cb8aa9fa52651ccf7e47cd3b7785fc4cf393f}{EVAS\_CALLBACK\_MOUSE\_DOWN},
                                  \_on\_mouse\_down, NULL);
   edje\_object\_signal\_callback\_add(edje\_obj1, \textcolor{stringliteral}{"color\_class,del"}, \textcolor{stringliteral}{"*"},
                                   (\hyperlink{group__Edje__Object__Communication__Interface__Signal_ga678b49d17da2ad0385b8855fef35cdd4}{Edje\_Signal\_Cb}) \_color\_class\_callback\_delete,
                                   \textcolor{stringliteral}{"process"});

\end{DoxyCodeInclude}


And then we delete the color class\+:  
\begin{DoxyCodeInclude}
\_on\_mouse\_down(\textcolor{keywordtype}{void} *data EINA\_UNUSED, \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *e EINA\_UNUSED, \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *obj, \textcolor{keywordtype}{void} *
      event\_info)
\{
   \hyperlink{struct__Evas__Event__Mouse__Down}{Evas\_Event\_Mouse\_Down} *ev = event\_info;

   \textcolor{keywordflow}{if} (ev->\hyperlink{struct__Evas__Event__Mouse__Down_a0ab02808721d6c55fc642ecbb37d5ff9}{button} == 1)
     \{
        \textcolor{keywordflow}{if} (obj == edje\_obj1)
          \hyperlink{group__Edje__Object__Color__Class_ga0d30416497554e3f50c893de5c0cccad}{edje\_color\_class\_del}(selected\_class);
        \textcolor{keywordflow}{else}
          edje\_object\_color\_class\_del(edje\_obj2, selected\_class);
     \}

\end{DoxyCodeInclude}


Our example will look like this, if you run with the parameters \char`\"{}green\+\_\+class gray pink yellow\char`\"{}\+:

  
\begin{DoxyImage}
\includegraphics{edje-color-class-example}
\caption{width=}
\end{DoxyImage}
 ~\newline
   
\begin{DoxyImage}
\includegraphics{edje-color-class-example2}
\caption{width=}
\end{DoxyImage}


The full source code follows\+: 
\begin{DoxyCodeInclude}

\textcolor{preprocessor}{#ifdef HAVE\_CONFIG\_H}
\textcolor{preprocessor}{# include "config.h"}
\textcolor{preprocessor}{#else}
\textcolor{preprocessor}{# define EINA\_UNUSED}
\textcolor{preprocessor}{#endif}

\textcolor{preprocessor}{#ifndef PACKAGE\_DATA\_DIR}
\textcolor{preprocessor}{#define PACKAGE\_DATA\_DIR "."}
\textcolor{preprocessor}{#endif}

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

\textcolor{preprocessor}{#define WIDTH  (400)}
\textcolor{preprocessor}{#define HEIGHT (400)}

\textcolor{keyword}{typedef} \textcolor{keywordtype}{int} color[4];           \textcolor{comment}{/* rgba */}

\textcolor{keyword}{static} Ecore\_Evas *ee1, *ee2;
\textcolor{keyword}{static} \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *evas1, *evas2;
\textcolor{keyword}{static} \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *bg1, *edje\_obj1, *bg2, *edje\_obj2;
\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *selected\_class;

\textcolor{keyword}{static} color colors\_init\_data[] =
  \{\{255, 0, 0, 255\},            \textcolor{comment}{/* red */}
   \{0, 255, 0, 255\},            \textcolor{comment}{/* green */}
   \{0, 0, 255, 255\},            \textcolor{comment}{/* blue */}
   \{0, 0, 0, 255\},              \textcolor{comment}{/* black */}
   \{255, 255, 255, 255\},        \textcolor{comment}{/* white */}
   \{128, 128, 128, 255\},        \textcolor{comment}{/* gray */}
   \{255, 255, 0, 255\},          \textcolor{comment}{/* yellow */}
   \{255, 0, 255, 255\}           \textcolor{comment}{/* pink */}
  \};

\textcolor{keyword}{static} \textcolor{keywordtype}{char} *color\_names[] =
  \{\textcolor{stringliteral}{"red"}, \textcolor{stringliteral}{"green"}, \textcolor{stringliteral}{"blue"}, \textcolor{stringliteral}{"black"}, \textcolor{stringliteral}{"white"},
   \textcolor{stringliteral}{"gray"}, \textcolor{stringliteral}{"yellow"}, \textcolor{stringliteral}{"pink"}\};

\textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
\_get\_color\_from\_name(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *n, color *c)
\{
   \textcolor{keywordtype}{int} i;
   \textcolor{keywordflow}{for} (i = 0; i < 8; i++)
     \textcolor{keywordflow}{if} (!strcmp(n, color\_names[i]))
       \{
          (*c)[0] = (colors\_init\_data[i])[0];
          (*c)[1] = (colors\_init\_data[i])[1];
          (*c)[2] = (colors\_init\_data[i])[2];
          (*c)[3] = (colors\_init\_data[i])[3];
          \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE};
       \}

   \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE};
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_color\_classes\_print(\textcolor{keywordtype}{void})
\{
   \hyperlink{struct__Eina__List}{Eina\_List} *classes;
   \textcolor{keywordtype}{char} *class\_name;

   fprintf(stdout, \textcolor{stringliteral}{"Getting the color classes\(\backslash\)n\(\backslash\)n"});
   classes = \hyperlink{group__Edje__Object__Color__Class_gac9de6885daf1eea7d3f6e3e822a4ca65}{edje\_color\_class\_list}();
   \hyperlink{group__Eina__List__Group_gae27a2c686a0a11693f9b06957c9bba83}{EINA\_LIST\_FREE}(classes, class\_name)
     \{
        \textcolor{keywordtype}{int} r1, r2, r3, g1, g2, g3, b1, b2, b3,
          a1, a2, a3;

        fprintf(stdout, \textcolor{stringliteral}{"\(\backslash\)ncolor class: %s\(\backslash\)n"}, class\_name);
        \textcolor{keywordflow}{if} (!\hyperlink{group__Edje__Object__Color__Class_gaf4e14706bc9766011ca60862f057d56e}{edje\_color\_class\_get}(class\_name, &r1, &g1, &b1, &a1,
                                  &r2, &g2, &b2, &a2, &r3, &g3, &b3, &a3))
          fprintf(stderr, \textcolor{stringliteral}{"Cannot get the color class\(\backslash\)n"});
        \textcolor{keywordflow}{else}
          \{

             fprintf(stdout,\textcolor{stringliteral}{"Object color r: %d g: %d b: %d a: %d\(\backslash\)n"},
                     r1, g1, b1, a1);
             fprintf(stdout,\textcolor{stringliteral}{"Text outline color r: %d g: %d b: %d a: %d\(\backslash\)n"},
                     r2, g2, b2, a2);
             fprintf(stdout,\textcolor{stringliteral}{"Text shadow color r: %d g: %d b: %d a: %d\(\backslash\)n"},
                     r3, g3, b3, a3);
          \}
        free(class\_name);
     \}
\}

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

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_on\_mouse\_down(\textcolor{keywordtype}{void} *data EINA\_UNUSED, \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *e EINA\_UNUSED, \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *obj, \textcolor{keywordtype}{void} *
      event\_info)
\{
   \hyperlink{struct__Evas__Event__Mouse__Down}{Evas\_Event\_Mouse\_Down} *ev = event\_info;

   \textcolor{keywordflow}{if} (ev->\hyperlink{struct__Evas__Event__Mouse__Down_a0ab02808721d6c55fc642ecbb37d5ff9}{button} == 1)
     \{
        \textcolor{keywordflow}{if} (obj == edje\_obj1)
          \hyperlink{group__Edje__Object__Color__Class_ga0d30416497554e3f50c893de5c0cccad}{edje\_color\_class\_del}(selected\_class);
        \textcolor{keywordflow}{else}
          edje\_object\_color\_class\_del(edje\_obj2, selected\_class);
     \}
\}

\textcolor{comment}{/* here just to keep our example's window size}
\textcolor{comment}{ * in synchrony. */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_canvas\_resize\_cb(Ecore\_Evas *\_ee)
\{
   \textcolor{keywordtype}{int} w, h;

   \hyperlink{group__Ecore__Evas__Group_ga931aadf4603731e73e8a84e4b14f1493}{ecore\_evas\_geometry\_get}(\_ee, NULL, NULL, &w, &h);

   \textcolor{keywordflow}{if} (\_ee == ee1)
     \{
        evas\_object\_resize(bg1, w, h);
        evas\_object\_resize(edje\_obj1, w, h);
     \}
   \textcolor{keywordflow}{else}
     \{
        evas\_object\_resize(bg2, w, h);
        evas\_object\_resize(edje\_obj2, w, h);
     \}
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_color\_class\_callback\_delete(\textcolor{keywordtype}{void} *data, \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *e EINA\_UNUSED, \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *obj EINA\_UNUSED,
                             \textcolor{keyword}{const} \textcolor{keywordtype}{char} *emission, \textcolor{keywordtype}{void} *source EINA\_UNUSED)
\{
   \textcolor{keywordflow}{if} (!strcmp(data, \textcolor{stringliteral}{"process"}))
     fprintf(stdout, \textcolor{stringliteral}{"Color class: %s deleted on process level\(\backslash\)n"}, emission);
   \textcolor{keywordflow}{else}
     fprintf(stdout, \textcolor{stringliteral}{"Color class: %s deleted on object level\(\backslash\)n"}, emission);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{int}
\_create\_windows(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *edje\_file\_path)
\{
  \textcolor{comment}{/* this will give you a window with an Evas canvas under the first}
\textcolor{comment}{    * engine available */}
   ee1 = \hyperlink{group__Ecore__Evas__Group_gac7f2cdbcb79635c34317c1183dd04cb0}{ecore\_evas\_new}(NULL, 0, 0, WIDTH, HEIGHT, NULL);
   \textcolor{keywordflow}{if} (!ee1)
     \textcolor{keywordflow}{return} 0;
   ee2 = \hyperlink{group__Ecore__Evas__Group_gac7f2cdbcb79635c34317c1183dd04cb0}{ecore\_evas\_new}(NULL, 0, 0, WIDTH, HEIGHT, NULL);
   \textcolor{keywordflow}{if} (!ee2)
     \textcolor{keywordflow}{return} 0;

   \hyperlink{group__Ecore__Evas__Group_ga3680b5c89157167318192157a5d24ec4}{ecore\_evas\_callback\_destroy\_set}(ee1, \_on\_destroy);
   \hyperlink{group__Ecore__Evas__Group_gaac67f679c9027059a34519fbdea360df}{ecore\_evas\_callback\_resize\_set}(ee1, \_canvas\_resize\_cb);
   \hyperlink{group__Ecore__Evas__Group_ga3b2832e0373bbafae2bb7143618535c1}{ecore\_evas\_title\_set}(ee1, \textcolor{stringliteral}{"Edje Color Class Example"});

   \hyperlink{group__Ecore__Evas__Group_ga3680b5c89157167318192157a5d24ec4}{ecore\_evas\_callback\_destroy\_set}(ee2, \_on\_destroy);
   \hyperlink{group__Ecore__Evas__Group_gaac67f679c9027059a34519fbdea360df}{ecore\_evas\_callback\_resize\_set}(ee2, \_canvas\_resize\_cb);
   \hyperlink{group__Ecore__Evas__Group_ga3b2832e0373bbafae2bb7143618535c1}{ecore\_evas\_title\_set}(ee2, \textcolor{stringliteral}{"Edje Object Color Class Example"});

   evas1 = \hyperlink{group__Ecore__Evas__Group_ga75a7cc694b6069e78df47dab0b0f2d20}{ecore\_evas\_get}(ee1);
   evas2 = \hyperlink{group__Ecore__Evas__Group_ga75a7cc694b6069e78df47dab0b0f2d20}{ecore\_evas\_get}(ee2);

   bg1 = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(evas1);
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(bg1, 255, 255, 255, 255); \textcolor{comment}{/* white bg */}
   evas\_object\_move(bg1, 0, 0);                    \textcolor{comment}{/* at canvas' origin */}
   evas\_object\_resize(bg1, WIDTH, HEIGHT);         \textcolor{comment}{/* covers full canvas */}
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(bg1);

   bg2 = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(evas2);
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(bg2, 255, 255, 255, 255); \textcolor{comment}{/* white bg */}
   evas\_object\_move(bg2, 0, 0);                    \textcolor{comment}{/* at canvas' origin */}
   evas\_object\_resize(bg2, WIDTH, HEIGHT);         \textcolor{comment}{/* covers full canvas */}
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(bg2);

   edje\_obj1 = edje\_object\_add(evas1);
   \hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}(edje\_obj1, 
      \hyperlink{Evas__Common_8h_a99e208e463a20499aabe6faac8a8cb8aa9fa52651ccf7e47cd3b7785fc4cf393f}{EVAS\_CALLBACK\_MOUSE\_DOWN},
                                  \_on\_mouse\_down, NULL);

   edje\_object\_file\_set(edje\_obj1, edje\_file\_path, \textcolor{stringliteral}{"example\_color\_class"});
   evas\_object\_move(edje\_obj1, 0, 0); \textcolor{comment}{/* at canvas' origin */}
   evas\_object\_resize(edje\_obj1, WIDTH, HEIGHT);
   edje\_object\_part\_text\_set(edje\_obj1, \textcolor{stringliteral}{"part\_four"}, \textcolor{stringliteral}{"EDJE EXAMPLE"});
   edje\_object\_signal\_callback\_add(edje\_obj1, \textcolor{stringliteral}{"color\_class,del"}, \textcolor{stringliteral}{"*"},
                                   (\hyperlink{group__Edje__Object__Communication__Interface__Signal_ga678b49d17da2ad0385b8855fef35cdd4}{Edje\_Signal\_Cb}) \_color\_class\_callback\_delete,
                                   \textcolor{stringliteral}{"process"});
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(edje\_obj1);

   edje\_obj2 = edje\_object\_add(evas2);
   \hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}(edje\_obj2, 
      \hyperlink{Evas__Common_8h_a99e208e463a20499aabe6faac8a8cb8aa9fa52651ccf7e47cd3b7785fc4cf393f}{EVAS\_CALLBACK\_MOUSE\_DOWN},
                                  \_on\_mouse\_down, NULL);

   edje\_object\_file\_set(edje\_obj2, edje\_file\_path, \textcolor{stringliteral}{"example\_color\_class"});
   evas\_object\_move(edje\_obj2, 0, 0); \textcolor{comment}{/* at canvas' origin */}
   evas\_object\_resize(edje\_obj2, WIDTH, HEIGHT);
   edje\_object\_part\_text\_set(edje\_obj2, \textcolor{stringliteral}{"part\_four"}, \textcolor{stringliteral}{"EDJE OBJECT EXAMPLE"});
   edje\_object\_signal\_callback\_add(edje\_obj2, \textcolor{stringliteral}{"color\_class,del"}, \textcolor{stringliteral}{"*"},
                                   (\hyperlink{group__Edje__Object__Communication__Interface__Signal_ga678b49d17da2ad0385b8855fef35cdd4}{Edje\_Signal\_Cb}) \_color\_class\_callback\_delete,
                                   \textcolor{stringliteral}{"object"});
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(edje\_obj2);

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

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} *argv[])
\{
   \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *edje\_file = PACKAGE\_DATA\_DIR\textcolor{stringliteral}{"/color-class.edj"};
   color        c1, c2, c3;
   \textcolor{keywordtype}{int}          i;

   \textcolor{keywordflow}{if} (argc != 5)
     \{
        fprintf(stderr, \textcolor{stringliteral}{"You have to use: %s color\_class\_name color1, color2,"} \(\backslash\)
                \textcolor{stringliteral}{"color3\(\backslash\)n"}, argv[0]);
        fprintf(stderr, \textcolor{stringliteral}{"Available colors:\(\backslash\)n"});
        \textcolor{keywordflow}{for} (i = 0; i < 8; i++)
          fprintf(stderr, \textcolor{stringliteral}{"%s\(\backslash\)n"}, color\_names[i]);

        \textcolor{keywordflow}{return} EXIT\_FAILURE;
     \}

   selected\_class = argv[1];
   \textcolor{keywordflow}{if} (!(\_get\_color\_from\_name(argv[2], &c1) &&
         \_get\_color\_from\_name(argv[3], &c2) &&
         \_get\_color\_from\_name(argv[4], &c3)))
     \{
        fprintf(stderr, \textcolor{stringliteral}{"Color not available!\(\backslash\)n"});
        \textcolor{keywordflow}{return} EXIT\_FAILURE;
     \}

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

   \textcolor{keywordflow}{if} (!\hyperlink{group__Edje__General__Group_ga1c9c6594f38023c29fbfb2d0c8c675db}{edje\_init}())
     \textcolor{keywordflow}{goto} shutdown\_ecore\_evas;

   \textcolor{keywordflow}{if} (!\_create\_windows(edje\_file)) \textcolor{keywordflow}{goto} shutdown\_edje;

   \hyperlink{group__Edje__Object__Color__Class_ga684435de625bdbb996e405e3eaaa54ad}{edje\_color\_class\_set}(argv[1],                     \textcolor{comment}{/* class name   */}
                        c1[0], c1[1], c1[2], c1[3],  \textcolor{comment}{/* Object color */}
                        c2[0], c2[1], c2[2], c2[3],  \textcolor{comment}{/* Text outline */}
                        c3[0], c3[1], c3[2], c3[3]); \textcolor{comment}{/* Text shadow  */}

   \textcolor{comment}{/* Setting an arbitrary value just to see the difference between */}
   \textcolor{comment}{/* process level and object level */}
   edje\_object\_color\_class\_set(edje\_obj2, argv[1], \textcolor{comment}{/* class name   */}
                               128, 180, 77, 255,  \textcolor{comment}{/* Object color */}
                               200, 22, 86, 255,   \textcolor{comment}{/* Text outline */}
                               39, 90, 187, 255);  \textcolor{comment}{/* Text shadow  */}

   \_color\_classes\_print();

   \hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}(ee1);
   \hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}(ee2);

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

   \hyperlink{group__Ecore__Evas__Group_gad3ec61f2aa03df4d3dbfd0d311e0c8dc}{ecore\_evas\_free}(ee1);
   \hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}();
   \hyperlink{group__Edje__General__Group_ga01041f6702f2d81bf10c3e41899805cb}{edje\_shutdown}();

   \textcolor{keywordflow}{return} EXIT\_SUCCESS;

 shutdown\_edje:
   \hyperlink{group__Edje__General__Group_ga01041f6702f2d81bf10c3e41899805cb}{edje\_shutdown}();
 shutdown\_ecore\_evas:
   \hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}();

   \textcolor{keywordflow}{return} EXIT\_FAILURE;
\}
\end{DoxyCodeInclude}


The theme used in this example is\+: 
\begin{DoxyCodeInclude}
1 color\_classes \{
2     color\_class \{
3        name: "red\_class";
4        color: 255 0 0 255;       /* red */
5        color2: 255 0 0 255;      /* red */
6        color3: 255 0 0 255;      /* red */
7     \}
8     color\_class \{
9        name: "green\_class";
10        color: 0 255 0 255;       /* green */
11        color2: 0 255 0 255;      /* green */
12        color3: 0 255 0 255;      /* green */
13     \}
14     color\_class \{
15        name: "blue\_class";
16        color: 0 0 255 255;       /* blue */
17        color2: 0 0 255 255;      /* blue */
18        color3: 0 0 255 255;      /* blue */
19     \}
20 \}
21 
22 collections \{
23    group \{
24       name: "example\_color\_class";
25       max: 500 500;
26       min: 50 50;
27 
28       parts \{
29          part \{
30             name: "part\_one";
31             type: RECT;
32             scale: 1;
33             description \{
34                state: "default" 0.0;
35                color: 255 255 255 255;
36                color\_class: "blue\_class";
37                rel1.relative: 0.0 0.0;
38                rel2.relative: 0.5 0.5;
39             \}
40          \}
41 
42          part \{
43             name: "part\_two";
44             type: RECT;
45             description \{
46                state: "default" 0.0;
47                color: 255 255 255 255;
48                color\_class: "green\_class";
49                rel1.relative: 0.5 0.0;
50                rel2.relative: 1.0 0.5;
51             \}
52          \}
53          part \{
54             name: "part\_three";
55             type: RECT;
56             description \{
57                state: "default" 0.0;
58                color: 255 255 255 255;
59                color\_class: "red\_class";
60                rel1.relative: 0.0 0.5;
61                rel2.relative: 1.0 1.0;
62             \}
63          \}
64          part \{
65             name: "part\_four";
66             type: TEXT;
67             effect: OUTLINE\_SHADOW;
68             description \{
69                state: "default" 0.0;
70                min: 50 50;
71                color: 255 255 255 255;
72                color2: 255 255 255 255;
73                color3: 255 255 255 255;
74                color\_class: "blue\_class";
75                rel1.relative: 0.0 0.5;
76                rel2.relative: 1.0 1.0;
77                text \{
78                   text\_class: "example";
79                   font: "arial";
80                   size: 45;
81                   min: 1 1;
82                \}
83             \}
84          \}
85       \}
86    \}
87 \}
\end{DoxyCodeInclude}


To compile use this command\+: \begin{DoxyVerb}* gcc -o edje-color-class edje-color-class.c -DPACKAGE_BIN_DIR=\"/Where/enlightenment/is/installed/bin\"
* -DPACKAGE_LIB_DIR=\"/Where/enlightenment/is/installed/lib\"
* -DPACKAGE_DATA_DIR=\"/Where/enlightenment/is/installed/share\"
* `pkg-config --cflags --libs evas ecore ecore-evas edje`
*
* edje_cc color-class.edc
* \end{DoxyVerb}
 