In this example, we illustrate how to organize your objects on a table, using the edje\+\_\+object\+\_\+part\+\_\+table functions.

To be easier to understand the objects in this example will be four simple rects, when the user click over one item with the left button its is removed from the table, if any other button was used all items are removed. For each action is printed a message with the current number of rows and columns.

We started creating an E\+D\+C file with one part of the type T\+A\+B\+L\+E called {\bfseries \char`\"{}table\+\_\+part\char`\"{}}, that is the part which we will refer to access the table\+: 
\begin{DoxyCodeInclude}
1 collections \{
2    group \{
3       name: "example\_table";
4       min: 50 50;
5 
6       parts \{
7          part \{
8             name: "table\_part";
9             type: TABLE;
10             description \{
11                min: 50 50;
12                state: "default" 0.0;
13                rel1.relative: 0.0 0.0;
14                rel2.relative: 1.0 1.0;
15             \}
16          \}
17       \}
18    \}
19 \}
\end{DoxyCodeInclude}


On the other hand, in the C file we first create the rectangles and added a callback for mouse down, as you can see bellow\+:  
\begin{DoxyCodeInclude}
\_rects\_create(\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *evas, \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} **rects, \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *edje\_obj)
\{
   \textcolor{keywordtype}{int} i;

   \textcolor{keywordflow}{for} (i = 0; i < 4; i++)
     \{
        rects[i] = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(evas);
        evas\_object\_size\_hint\_min\_set(rects[i], 200, 200);
        evas\_object\_size\_hint\_weight\_set(rects[i], 1.0, 1.0);
        \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(rects[i]);
        \hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}(rects[i], 
      \hyperlink{Evas__Common_8h_a99e208e463a20499aabe6faac8a8cb8aa9fa52651ccf7e47cd3b7785fc4cf393f}{EVAS\_CALLBACK\_MOUSE\_DOWN},
                                       \_on\_mouse\_down, edje\_obj);
     \}
\}

\end{DoxyCodeInclude}


With the objects created we have to pack them into the table, to do this, we just have to use the function edje\+\_\+object\+\_\+part\+\_\+table\+\_\+pack().  
\begin{DoxyCodeInclude}
   \textcolor{keywordflow}{if} (!edje\_object\_part\_table\_pack(edje\_obj, \textcolor{stringliteral}{"table\_part"}, rects[0],
                                    0, 0, 1, 2))
     fprintf(stderr, \textcolor{stringliteral}{"Cannot add the rectangle 1 to table\(\backslash\)n"});

   \textcolor{keywordflow}{if} (!edje\_object\_part\_table\_pack(edje\_obj, \textcolor{stringliteral}{"table\_part"}, rects[1],
                                    0, 1, 1, 1))
     fprintf(stderr, \textcolor{stringliteral}{"Cannot add the rectangle 2 to table\(\backslash\)n"});

   \textcolor{keywordflow}{if} (!edje\_object\_part\_table\_pack(edje\_obj, \textcolor{stringliteral}{"table\_part"}, rects[2],
                                    1, 0, 1, 1))
     fprintf(stderr, \textcolor{stringliteral}{"Cannot add the rectangle 3 to table\(\backslash\)n"});

   \textcolor{keywordflow}{if} (!edje\_object\_part\_table\_pack(edje\_obj, \textcolor{stringliteral}{"table\_part"}, rects[3],
                                    1, 1, 1, 1))
     fprintf(stderr, \textcolor{stringliteral}{"Cannot add the rectangle 4 to table\(\backslash\)n"});

\end{DoxyCodeInclude}


The other bit of code that is relevant to us now is our event handler for when the user click over the rectangle. Here we use the function edje\+\_\+object\+\_\+part\+\_\+table\+\_\+unpack() to remove the item from the table or edje\+\_\+object\+\_\+part\+\_\+table\+\_\+clear() to remove all items, it depends on which mouse button the user uses.  
\begin{DoxyCodeInclude}
\_on\_mouse\_down(\textcolor{keywordtype}{void} *data, \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *evas 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;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *edje\_obj;

   ev = (\hyperlink{struct__Evas__Event__Mouse__Down}{Evas\_Event\_Mouse\_Down} *)event\_info;
   edje\_obj = (\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *)data;

   \textcolor{keywordflow}{if} (ev->\hyperlink{struct__Evas__Event__Mouse__Down_a0ab02808721d6c55fc642ecbb37d5ff9}{button} != 1)
     edje\_object\_part\_table\_clear(edje\_obj, \textcolor{stringliteral}{"table\_part"}, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (!edje\_object\_part\_table\_unpack(edje\_obj, \textcolor{stringliteral}{"table\_part"}, obj))
     fprintf(stderr, \textcolor{stringliteral}{"Cannot remove the selected rectangle\(\backslash\)n"});

   \hyperlink{group__Evas__Object__Group__Basic_ga7e7a625dab7a3890532aa13b43117076}{evas\_object\_del}(obj);
   \_columns\_rows\_print(edje\_obj);
\}

\end{DoxyCodeInclude}


Finally, the last important thing in this example is about how to know how many columns and rows are there in the table, It should be noted that this function don\textquotesingle{}t tell you how many items are there in the table, just the number of the columns and rows of the table.  
\begin{DoxyCodeInclude}
\}

\end{DoxyCodeInclude}


The example\textquotesingle{}s window should look like this picture\+:

  
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth]{edje-table-example}}
\end{DoxyImageNoCaption}


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}{static} \textcolor{keywordtype}{void}
\_on\_delete(Ecore\_Evas *ee EINA\_UNUSED)
\{
   \hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}();
\}

\textcolor{comment}{/* Try to get the number of columns and rows of the table}
\textcolor{comment}{ * and print them. */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_columns\_rows\_print(\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *edje\_obj)
\{
   \textcolor{keywordtype}{int} cols, rows;

   \textcolor{keywordflow}{if} (edje\_object\_part\_table\_col\_row\_size\_get(edje\_obj, \textcolor{stringliteral}{"table\_part"}, &cols,
                                               &rows))
     fprintf(stdout, \textcolor{stringliteral}{"Number of columns: %d\(\backslash\)nNumber of rows: %d\(\backslash\)n"}, cols, rows);
   \textcolor{keywordflow}{else}
     fprintf(stderr, \textcolor{stringliteral}{"Cannot get the number of columns and rows\(\backslash\)n"});
\}

\textcolor{comment}{/* here just to keep our example's window size and table items}
\textcolor{comment}{ * size in synchrony. */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_on\_canvas\_resize(Ecore\_Evas *ee)
\{
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *bg;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *edje\_obj;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} **rects;
   \textcolor{keywordtype}{int}          i;
   \textcolor{keywordtype}{int}          w;
   \textcolor{keywordtype}{int}          h;

   bg = \hyperlink{group__Ecore__Evas__Group_gae00d4a4feb8aec5de03e464fe21a1d30}{ecore\_evas\_data\_get}(ee, \textcolor{stringliteral}{"background"});
   edje\_obj = \hyperlink{group__Ecore__Evas__Group_gae00d4a4feb8aec5de03e464fe21a1d30}{ecore\_evas\_data\_get}(ee, \textcolor{stringliteral}{"edje\_obj"});
   rects = \hyperlink{group__Ecore__Evas__Group_gae00d4a4feb8aec5de03e464fe21a1d30}{ecore\_evas\_data\_get}(ee, \textcolor{stringliteral}{"rects"});
   \hyperlink{group__Ecore__Evas__Group_ga931aadf4603731e73e8a84e4b14f1493}{ecore\_evas\_geometry\_get}(ee, NULL, NULL, &w, &h);

   \hyperlink{group__Evas__Font__Group_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(bg, w, h);
   \hyperlink{group__Evas__Font__Group_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(edje\_obj, w, h);

   \textcolor{keywordflow}{for} (i = 0; i < 4; i++)
     evas\_object\_size\_hint\_min\_set(rects[i], w/2, h/2);
\}

\textcolor{comment}{/* Mouse button 1 = remove the clicked item}
\textcolor{comment}{ * any other button = remove all items. */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_on\_mouse\_down(\textcolor{keywordtype}{void} *data, \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *evas 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;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *edje\_obj;

   ev = (\hyperlink{struct__Evas__Event__Mouse__Down}{Evas\_Event\_Mouse\_Down} *)event\_info;
   edje\_obj = (\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *)data;

   \textcolor{keywordflow}{if} (ev->\hyperlink{struct__Evas__Event__Mouse__Down_a0ab02808721d6c55fc642ecbb37d5ff9}{button} != 1)
     edje\_object\_part\_table\_clear(edje\_obj, \textcolor{stringliteral}{"table\_part"}, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (!edje\_object\_part\_table\_unpack(edje\_obj, \textcolor{stringliteral}{"table\_part"}, obj))
     fprintf(stderr, \textcolor{stringliteral}{"Cannot remove the selected rectangle\(\backslash\)n"});

   \hyperlink{group__Evas__Object__Group__Basic_ga7e7a625dab7a3890532aa13b43117076}{evas\_object\_del}(obj);
   \_columns\_rows\_print(edje\_obj);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_rects\_create(\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *evas, \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} **rects, \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *edje\_obj)
\{
   \textcolor{keywordtype}{int} i;

   \textcolor{keywordflow}{for} (i = 0; i < 4; i++)
     \{
        rects[i] = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(evas);
        evas\_object\_size\_hint\_min\_set(rects[i], 200, 200);
        evas\_object\_size\_hint\_weight\_set(rects[i], 1.0, 1.0);
        \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(rects[i]);
        \hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}(rects[i], 
      \hyperlink{Evas__Common_8h_a99e208e463a20499aabe6faac8a8cb8aa9fa52651ccf7e47cd3b7785fc4cf393f}{EVAS\_CALLBACK\_MOUSE\_DOWN},
                                       \_on\_mouse\_down, edje\_obj);
     \}
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{int} argc EINA\_UNUSED, \textcolor{keywordtype}{char} *argv[] EINA\_UNUSED)
\{
   \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *edje\_file = PACKAGE\_DATA\_DIR\textcolor{stringliteral}{"/table.edj"};
   Ecore\_Evas  *ee;
   \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}        *evas;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *bg;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *edje\_obj;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *rects[4];

   \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{comment}{/* this will give you a window with an Evas canvas under the first}
\textcolor{comment}{    * engine available */}
   ee = \hyperlink{group__Ecore__Evas__Group_gac7f2cdbcb79635c34317c1183dd04cb0}{ecore\_evas\_new}(NULL, 0, 0, WIDTH, HEIGHT, NULL);
   \textcolor{keywordflow}{if} (!ee) \textcolor{keywordflow}{goto} shutdown\_edje;

   \hyperlink{group__Ecore__Evas__Group_ga3d478e975e2101b9b821ef24baf3dd9e}{ecore\_evas\_callback\_delete\_request\_set}(ee, \_on\_delete);
   \hyperlink{group__Ecore__Evas__Group_gaac67f679c9027059a34519fbdea360df}{ecore\_evas\_callback\_resize\_set}(ee, \_on\_canvas\_resize);
   \hyperlink{group__Ecore__Evas__Group_ga3b2832e0373bbafae2bb7143618535c1}{ecore\_evas\_title\_set}(ee, \textcolor{stringliteral}{"Edje Table Example"});

   evas = \hyperlink{group__Ecore__Evas__Group_ga75a7cc694b6069e78df47dab0b0f2d20}{ecore\_evas\_get}(ee);

   bg = \hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}(evas);
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(bg, 255, 255, 255, 255); \textcolor{comment}{/* white bg */}
   \hyperlink{group__Evas__Font__Group_ga02da8091bbac768b8e86c7b74b2a94f9}{evas\_object\_move}(bg, 0, 0); \textcolor{comment}{/* at canvas' origin */}
   \hyperlink{group__Evas__Font__Group_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(bg, WIDTH, HEIGHT); \textcolor{comment}{/* covers full canvas */}
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(bg);
   \hyperlink{group__Ecore__Evas__Group_gaa86c5abd200a02711aced53d27b9ddb2}{ecore\_evas\_data\_set}(ee, \textcolor{stringliteral}{"background"}, bg);

   edje\_obj = edje\_object\_add(evas);

   edje\_object\_file\_set(edje\_obj, edje\_file, \textcolor{stringliteral}{"example\_table"});
   \hyperlink{group__Evas__Font__Group_ga02da8091bbac768b8e86c7b74b2a94f9}{evas\_object\_move}(edje\_obj, 0, 0); \textcolor{comment}{/* at canvas' origin */}
   \hyperlink{group__Evas__Font__Group_ga21e8604c0e4a93e469bff4bd069e82b5}{evas\_object\_resize}(edje\_obj, WIDTH, HEIGHT);
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(edje\_obj);
   \hyperlink{group__Ecore__Evas__Group_gaa86c5abd200a02711aced53d27b9ddb2}{ecore\_evas\_data\_set}(ee, \textcolor{stringliteral}{"edje\_obj"}, edje\_obj);

   \_rects\_create(evas, rects, edje\_obj);
   \hyperlink{group__Ecore__Evas__Group_gaa86c5abd200a02711aced53d27b9ddb2}{ecore\_evas\_data\_set}(ee, \textcolor{stringliteral}{"rects"}, rects);

   \textcolor{comment}{/* Colouring the rectangles */}
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(rects[0], 255, 0, 0, 255);
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(rects[1], 0, 255, 0, 255);
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(rects[2], 0, 0, 255, 255);
   \hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}(rects[3], 128, 128, 128, 255);

   \textcolor{comment}{/* Packing the rectangles into the table */}
   \textcolor{keywordflow}{if} (!edje\_object\_part\_table\_pack(edje\_obj, \textcolor{stringliteral}{"table\_part"}, rects[0],
                                    0, 0, 1, 2))
     fprintf(stderr, \textcolor{stringliteral}{"Cannot add the rectangle 1 to table\(\backslash\)n"});

   \textcolor{keywordflow}{if} (!edje\_object\_part\_table\_pack(edje\_obj, \textcolor{stringliteral}{"table\_part"}, rects[1],
                                    0, 1, 1, 1))
     fprintf(stderr, \textcolor{stringliteral}{"Cannot add the rectangle 2 to table\(\backslash\)n"});

   \textcolor{keywordflow}{if} (!edje\_object\_part\_table\_pack(edje\_obj, \textcolor{stringliteral}{"table\_part"}, rects[2],
                                    1, 0, 1, 1))
     fprintf(stderr, \textcolor{stringliteral}{"Cannot add the rectangle 3 to table\(\backslash\)n"});

   \textcolor{keywordflow}{if} (!edje\_object\_part\_table\_pack(edje\_obj, \textcolor{stringliteral}{"table\_part"}, rects[3],
                                    1, 1, 1, 1))
     fprintf(stderr, \textcolor{stringliteral}{"Cannot add the rectangle 4 to table\(\backslash\)n"});

   \_columns\_rows\_print(edje\_obj);

   \hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}(ee);

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

   \hyperlink{group__Ecore__Evas__Group_gad3ec61f2aa03df4d3dbfd0d311e0c8dc}{ecore\_evas\_free}(ee);
   \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}


To compile use this command\+: \begin{DoxyVerb}* gcc -o edje-table edje-table.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 table.edc
* \end{DoxyVerb}
 