This application is a thorough exercise on the gengrid widget\textquotesingle{}s A\+P\+I.

We place an Elementary gengrid widget on a window, with various knobs below its viewport, each one acting on it somehow.

The code\textquotesingle{}s relevant part begins at the grid\textquotesingle{}s creation. After instantiating it, we set its items sizes, so that we don\textquotesingle{}t end with items one finger size wide, only. We\textquotesingle{}re setting them to fat, 150 pixel wide ones, for this example. We give it some size hints, not to be discussed in this context and, than, we register a callback on one of its smart events -- the one coming each time an item gets doubly clicked. There, we just print the item handle\textquotesingle{}s value.  
\begin{DoxyCodeInclude}
   grid = elm_gengrid_add(win);
   elm\_gengrid\_item\_size\_set(grid, 150, 150);
   evas\_object\_size\_hint\_weight\_set(grid, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(grid, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_box\_pack\_end(bx, grid);
   evas\_object\_smart\_callback\_add(grid, \textcolor{stringliteral}{"clicked,double"}, \_double\_click, NULL);
   evas\_object\_smart\_callback\_add(grid, \textcolor{stringliteral}{"longpressed"}, \_long\_pressed, NULL);
   evas\_object\_show(grid);

\end{DoxyCodeInclude}
  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* item double click callback */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_double\_click(\textcolor{keywordtype}{void}        *data,
              Evas\_Object *obj,
              \textcolor{keywordtype}{void}        *event\_info)
\{
   fprintf(stdout, \textcolor{stringliteral}{"Double click on item with handle %p\(\backslash\)n"}, event\_info);
\}

\end{DoxyCodeInclude}


Before we actually start to deal with the items A\+P\+I, let\textquotesingle{}s show some things items will be using throughout all the code. The first of them is a struct to be used as item data, for all of them\+:  
\begin{DoxyCodeInclude}
\textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Example\_Item
\{
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *path;
\} Example\_Item;

\end{DoxyCodeInclude}


That path will be used to index an image, to be swallowed into one of the item\textquotesingle{}s icon spots. The images themselves are distributed with Elementary\+:  
\begin{DoxyCodeInclude}
\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *imgs[9] =
\{
   \textcolor{stringliteral}{"panel\_01.jpg"},
   \textcolor{stringliteral}{"plant\_01.jpg"},
   \textcolor{stringliteral}{"rock\_01.jpg"},
   \textcolor{stringliteral}{"rock\_02.jpg"},
   \textcolor{stringliteral}{"sky\_01.jpg"},
   \textcolor{stringliteral}{"sky\_02.jpg"},
   \textcolor{stringliteral}{"sky\_03.jpg"},
   \textcolor{stringliteral}{"sky\_04.jpg"},
   \textcolor{stringliteral}{"wood\_01.jpg"},
\};

\end{DoxyCodeInclude}


We also have an (unique) gengrid item class we\textquotesingle{}ll be using for items in the example\+:  
\begin{DoxyCodeInclude}
\textcolor{keyword}{static} Elm_Gengrid_Item_Class *gic = NULL;

\end{DoxyCodeInclude}
  
\begin{DoxyCodeInclude}
        gic->item\_style = \textcolor{stringliteral}{"default"};
        gic->func.text\_get = \_grid\_label\_get;
        gic->func.content\_get = \_grid\_content\_get;
        gic->func.state\_get = \_grid\_state\_get;
        gic->func.del = \_grid\_del;

\end{DoxyCodeInclude}


As you see, our items will follow the default theme on gengrid items. For the label fetching code, we return a string composed of the item\textquotesingle{}s image path\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* label fetching callback */}
\textcolor{keyword}{static} \textcolor{keywordtype}{char} *
\_grid\_label\_get(\textcolor{keywordtype}{void}        *data,
                Evas\_Object *obj,
                \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *part)
\{
   \textcolor{keyword}{const} Example\_Item *it = data;
   \textcolor{keywordtype}{char} buf[256];

   snprintf(buf, \textcolor{keyword}{sizeof}(buf), \textcolor{stringliteral}{"Photo %s"}, it->path);
   \textcolor{keywordflow}{return} strdup(buf);
\}

\end{DoxyCodeInclude}


For item icons, we\textquotesingle{}ll be populating the item default theme\textquotesingle{}s two icon spots, {\ttfamily \char`\"{}elm.\+swallow.\+icon\char`\"{}} and {\ttfamily \char`\"{}elm.\+swallow.\+end\char`\"{}}. The former will receive one of the images in our list (in the form of a \hyperlink{bg_02_example_page}{background}), while the latter will be a check widget. Note that we prevent the check to propagate click events, so that the user can toggle its state without messing with the respective item\textquotesingle{}s selection in the grid\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* icon fetching callback */}
\textcolor{keyword}{static} Evas\_Object *
\_grid\_content\_get(\textcolor{keywordtype}{void}        *data,
                  Evas\_Object *obj,
                  \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *part)
\{
   \textcolor{keyword}{const} Example\_Item *it = data;

   \textcolor{keywordflow}{if} (!strcmp(part, \textcolor{stringliteral}{"elm.swallow.icon"}))
     \{
        Evas\_Object *icon = elm_bg_add(obj);
        \textcolor{keywordtype}{char} buf[PATH\_MAX];

        snprintf(buf, \textcolor{keyword}{sizeof}(buf), \textcolor{stringliteral}{"%s/images/%s"}, elm_app_data_dir_get(),
                 it->path);

        elm_bg_file_set(icon, buf, NULL);
        evas\_object\_size\_hint\_aspect\_set(icon, EVAS\_ASPECT\_CONTROL\_VERTICAL, 1,
                                         1);
        evas\_object\_show(icon);
        \textcolor{keywordflow}{return} icon;
     \}
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (!strcmp(part, \textcolor{stringliteral}{"elm.swallow.end"}))
     \{
        Evas\_Object *ck;
        ck = elm_check_add(obj);
        evas\_object\_propagate\_events\_set(ck, EINA\_FALSE);
        evas\_object\_show(ck);
        \textcolor{keywordflow}{return} ck;
     \}

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

\end{DoxyCodeInclude}


As the default gengrid item\textquotesingle{}s theme does not have parts implementing item states, we\textquotesingle{}ll be just returning false for every item state\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* state fetching callback */}
\textcolor{keyword}{static} Eina\_Bool
\_grid\_state\_get(\textcolor{keywordtype}{void}        *data,
                Evas\_Object *obj,
                \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *part)
\{
   \textcolor{keywordflow}{return} EINA\_FALSE;
\}

\end{DoxyCodeInclude}


Finally, the deletion callback on gengrid items takes care of freeing the item\textquotesingle{}s label string and its data struct\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* deletion callback */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_grid\_del(\textcolor{keywordtype}{void}        *data,
          Evas\_Object *obj)
\{
   Example\_Item *it = data;

   eina\_stringshare\_del(it->path);
   free(it);
\}

\end{DoxyCodeInclude}


Let\textquotesingle{}s move to item insertion/deletion knobs, them. They are four buttons, above the grid\textquotesingle{}s viewport, namely
\begin{DoxyItemize}
\item \char`\"{}\+Append\char`\"{} (to append an item to the grid),
\item \char`\"{}\+Prepend\char`\"{} (to prepend an item to the grid),
\item \char`\"{}\+Insert before\char`\"{} (to insert an item before the selection, on the grid),
\item \char`\"{}\+Insert after\char`\"{} (to insert an item after the selection, on the grid),
\item \char`\"{}\+Clear\char`\"{} (to delete all items in the grid),
\item \char`\"{}\+Bring in 1st\char`\"{} (to make the 1st item visible, by scrolling),
\item \char`\"{}\+Show last\char`\"{} (to directly show the last item),
\end{DoxyItemize}which are displaced and declared in that order. We\textquotesingle{}re not dealing with the buttons\textquotesingle{} creation code (see \hyperlink{button_example_01}{a button example}, for more details on it), but with their {\ttfamily \char`\"{}clicked\char`\"{}} registered callbacks. For all of them, the grid\textquotesingle{}s handle is passed as {\ttfamily data}. The ones creating new items use a common code, which just gives a new {\ttfamily Example\+\_\+\+Item} struct, with {\ttfamily path} filled with a random image in our images list\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* new item with random path */}
\textcolor{keyword}{static} Example\_Item *
\_item\_new(\textcolor{keywordtype}{void})
\{
   Example\_Item *it;

   it = malloc(\textcolor{keyword}{sizeof}(*it));
   it->path = eina\_stringshare\_add(imgs[rand() % (\textcolor{keyword}{sizeof}(imgs) /
                                                  \textcolor{keyword}{sizeof}(imgs[0]))]);
   \textcolor{keywordflow}{return} it;
\}

\end{DoxyCodeInclude}


Moreover, that ones will set a common function to be issued on the selection of the items. There, we print the item handle\textquotesingle{}s value, along with the callback function data. The latter will be {\ttfamily N\+U\+L\+L}, always, because it\textquotesingle{}s what we pass when adding all icons. By using \hyperlink{group__General_ga4465a576c55d197878aeafc0bacf7bb4}{elm\+\_\+object\+\_\+item\+\_\+data\+\_\+get()}, we can have the item data back and, with that, we\textquotesingle{}re priting the item\textquotesingle{}s path string. Finally, we exemplify \hyperlink{group__Gengrid_gaca9e06b8d918dc034072efac9d32638e}{elm\+\_\+gengrid\+\_\+item\+\_\+pos\+\_\+get()}, printing the item\textquotesingle{}s position in the grid\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* item selection callback */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_grid\_sel(\textcolor{keywordtype}{void}        *data,
          Evas\_Object *obj,
          \textcolor{keywordtype}{void}        *event\_info)
\{
   \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} x, y;
   Example\_Item *it = elm_object_item_data_get(event\_info);

   elm_gengrid_item_pos_get(event\_info, &x, &y);

   fprintf(stdout, \textcolor{stringliteral}{"Item [%p], with data [%p], path %s, at position (%d, %d),"}
           \textcolor{stringliteral}{" has been selected\(\backslash\)n"}, event\_info, data, it->path, x, y);
\}

\end{DoxyCodeInclude}


The appending button will exercise elm\+\_\+gengrid\+\_\+item\+\_\+append(), simply\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* append an item */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_append\_bt\_clicked(\textcolor{keywordtype}{void}        *data,
                   Evas\_Object *obj,
                   \textcolor{keywordtype}{void}        *event\_info)
\{
   Evas\_Object *grid = data;
   Example\_Item *it = \_item\_new();

   elm\_gengrid\_item\_append(grid, gic, it, \_grid\_sel, NULL);
\}

\end{DoxyCodeInclude}


The prepending, naturally, is analogous, but exercising elm\+\_\+gengrid\+\_\+item\+\_\+prepend(), on its turn. The \char`\"{}\+Insert before\char`\"{} one will expect an item to be selected in the grid, so that it will insert a new item just before it\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* "insert before" callback */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_before\_bt\_clicked(\textcolor{keywordtype}{void}        *data,
                   Evas\_Object *obj,
                   \textcolor{keywordtype}{void}        *event\_info)
\{
   Example\_Item *it;
   Evas\_Object *grid = data;
   Elm_Object_Item *sel;

   sel = elm\_gengrid\_selected\_item\_get(grid);
   \textcolor{keywordflow}{if} (!sel)
     \textcolor{keywordflow}{return};

   it = \_item\_new();
   elm\_gengrid\_item\_insert\_before(grid, gic, it, sel, \_grid\_sel, NULL);
\}

\end{DoxyCodeInclude}


The \char`\"{}\+Insert after\char`\"{} is analogous, just using elm\+\_\+gengrid\+\_\+item\+\_\+insert\+\_\+after(), instead. The \char`\"{}\+Clear\char`\"{} button will, as expected, just issue elm\+\_\+gengrid\+\_\+clear()\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* delete items */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_clear\_cb(\textcolor{keywordtype}{void}        *data,
          Evas\_Object *obj,
          \textcolor{keywordtype}{void}        *event\_info)
\{
   elm\_gengrid\_clear(data);

   fprintf(stdout, \textcolor{stringliteral}{"Clearing the grid!\(\backslash\)n"});
\}

\end{DoxyCodeInclude}


The \char`\"{}\+Bring in 1st\char`\"{} button is there exercise two gengrid functions -- elm\+\_\+gengrid\+\_\+first\+\_\+item\+\_\+get() and elm\+\_\+gengrid\+\_\+item\+\_\+bring\+\_\+in(). With the former, we get a handle to the first item and, with the latter, you\textquotesingle{}ll see that the widget animatedly scrolls its view until we can see that item\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* bring in 1st item */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_bring\_1st\_clicked(\textcolor{keywordtype}{void}        *data,
                   Evas\_Object *obj,
                   \textcolor{keywordtype}{void}        *event\_info)
\{
   Elm_Object_Item *gg\_it = elm\_gengrid\_first\_item\_get(data);

   \textcolor{keywordflow}{if} (!gg\_it) \textcolor{keywordflow}{return};

   elm\_gengrid\_item\_bring\_in(gg\_it, ELM\_GENGRID\_ITEM\_SCROLLTO\_IN);
\}

\end{DoxyCodeInclude}


The \char`\"{}\+Show last\char`\"{}, in its turn, will use elm\+\_\+gengrid\+\_\+last\+\_\+item\+\_\+get() and elm\+\_\+gengrid\+\_\+item\+\_\+show(). The latter differs from elm\+\_\+gengrid\+\_\+item\+\_\+bring\+\_\+in() in that it immediately replaces the contents of the grid\textquotesingle{}s viewport with the region containing the item in question\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* show last item */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_show\_last\_clicked(\textcolor{keywordtype}{void}        *data,
                   Evas\_Object *obj,
                   \textcolor{keywordtype}{void}        *event\_info)
\{
   Elm_Object_Item *gg\_it = elm\_gengrid\_last\_item\_get(data);

   \textcolor{keywordflow}{if} (!gg\_it) \textcolor{keywordflow}{return};

   elm\_gengrid\_item\_show(gg\_it, ELM\_GENGRID\_ITEM\_SCROLLTO\_IN);
\}

\end{DoxyCodeInclude}


To change the grid\textquotesingle{}s cell (items) size, we\textquotesingle{}ve placed a spinner, which has the following {\ttfamily \char`\"{}changed\char`\"{}} smart callback\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* change items' size */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_size\_changed(\textcolor{keywordtype}{void}        *data,
              Evas\_Object *obj,
              \textcolor{keywordtype}{void}        *event\_info)
\{
   Evas\_Object *grid = data;
   \textcolor{keywordtype}{int} size = elm\_spinner\_value\_get(obj);

   elm\_gengrid\_item\_size\_set(grid, size, size);
\}

\end{DoxyCodeInclude}


Experiment with it and see how the items are affected. The \char`\"{}\+Disable
item\char`\"{} button will, as the name says, disable the currently selected item\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* disable selected item */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_toggle\_disabled\_cb(\textcolor{keywordtype}{void}        *data,
                    Evas\_Object *obj,
                    \textcolor{keywordtype}{void}        *event\_info)
\{
   Elm_Object_Item *gg\_it = elm\_gengrid\_selected\_item\_get(data);

   \textcolor{keywordflow}{if} (!gg\_it) \textcolor{keywordflow}{return};

   elm\_gengrid\_item\_selected\_set(gg\_it, EINA\_FALSE);
   elm\_object\_item\_disabled\_set(gg\_it, EINA\_TRUE);
\}

\end{DoxyCodeInclude}
 Note that we also make use of elm\+\_\+gengrid\+\_\+item\+\_\+selected\+\_\+set(), there, thus making the item unselected before we actually disable it.

To toggle between horizontal and vertical layouting modes on the grid, use the \char`\"{}\+Horizontal mode\char`\"{} check, which will call the respective A\+P\+I function on the grid\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* change layouting mode */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_horizontal\_grid(\textcolor{keywordtype}{void}        *data,
                 Evas\_Object *obj,
                 \textcolor{keywordtype}{void}        *event\_info)
\{
   Evas\_Object *grid = data;

   elm\_gengrid\_horizontal\_set(grid, elm\_check\_state\_get(obj));
\}

\end{DoxyCodeInclude}


If you toggle the check right after that one, \char`\"{}\+Always select\char`\"{}, you\textquotesingle{}ll notice all subsequent clicks on the {\bfseries same} grid item will still issue the selection callback on it, what is different from when it\textquotesingle{}s not checked. This is the elm\+\_\+gengrid\+\_\+select\+\_\+mode\+\_\+set() behavior\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* "always select" callback */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_always\_select\_change(\textcolor{keywordtype}{void}        *data,
                      Evas\_Object *obj,
                      \textcolor{keywordtype}{void}        *event\_info)
\{
   Evas\_Object *grid = data;
   Eina\_Bool always = elm\_check\_state\_get(obj);

   \textcolor{keywordflow}{if} (always)
     elm\_gengrid\_select\_mode\_set(grid, ELM\_OBJECT\_SELECT\_MODE\_ALWAYS);
   \textcolor{keywordflow}{else}
     elm\_gengrid\_select\_mode\_set(grid, ELM\_OBJECT\_SELECT\_MODE\_DEFAULT);

   fprintf(stdout, \textcolor{stringliteral}{"\(\backslash\)"Always select\(\backslash\)" mode for gengrid items is now %s\(\backslash\)n"},
           always ? \textcolor{stringliteral}{"on"} : \textcolor{stringliteral}{"off"});
\}

\end{DoxyCodeInclude}


One more check follows, \char`\"{}\+Bouncing\char`\"{}, which will turn on/off the bouncing animations on the grid, when one scrolls past its borders. Experiment with scrolling the grid to get the idea, having it turned on and off\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* "bouncing mode" callback */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_bouncing\_change(\textcolor{keywordtype}{void}        *data,
                 Evas\_Object *obj,
                 \textcolor{keywordtype}{void}        *event\_info)
\{
   Evas\_Object *grid = data;
   Eina\_Bool bounce = elm\_check\_state\_get(obj);

   elm_scroller_bounce_set(grid, bounce, bounce);

   fprintf(stdout, \textcolor{stringliteral}{"Bouncing effect for gengrid is now %s\(\backslash\)n"},
           bounce ? \textcolor{stringliteral}{"on"} : \textcolor{stringliteral}{"off"});
\}

\end{DoxyCodeInclude}


The next two checks will affect items selection on the grid. The first, \char`\"{}\+Multi-\/selection\char`\"{}, will make it possible to select more the one item on the grid. Because it wouldn\textquotesingle{}t make sense to fetch for an unique selected item on this case, we also disable two of the buttons, which insert items relatively, if multi-\/selection is on\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* multi-selection callback */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_multi\_change(\textcolor{keywordtype}{void}        *data,
              Evas\_Object *obj,
              \textcolor{keywordtype}{void}        *event\_info)
\{
   Evas\_Object *grid = data;
   Eina\_Bool multi = elm\_check\_state\_get(obj);

   elm\_gengrid\_multi\_select\_set(grid, multi);

   fprintf(stdout, \textcolor{stringliteral}{"Multi-selection for gengrid is now %s\(\backslash\)n"},
           multi ? \textcolor{stringliteral}{"on"} : \textcolor{stringliteral}{"off"});

   elm_object_disabled_set(before\_bt, multi);
   elm_object_disabled_set(after\_bt, multi);

   \textcolor{keywordflow}{if} (!multi)
     \{
        Elm_Object_Item *gg\_it;
        \textcolor{keyword}{const} Eina\_List *selected = elm\_gengrid\_selected\_items\_get(grid), *l;
        EINA\_LIST\_FOREACH(selected, l, gg\_it)
           elm\_gengrid\_item\_selected\_set(gg\_it, EINA\_FALSE);
     \}

\end{DoxyCodeInclude}


Note that we also {\bfseries unselect} all items in the grid, when returning from multi-\/selection mode, making use of elm\+\_\+gengrid\+\_\+item\+\_\+selected\+\_\+set().

The second check acting on selection, \char`\"{}\+No selection\char`\"{}, is just what its name depicts -- no selection will be allowed anymore, on the grid, while it\textquotesingle{}s on. Check it out for yourself, interacting with the program\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* no selection callback */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_no\_sel\_change(\textcolor{keywordtype}{void}        *data,
               Evas\_Object *obj,
               \textcolor{keywordtype}{void}        *event\_info)
\{
   Evas\_Object *grid = data;
   Eina\_Bool no\_sel = elm\_check\_state\_get(obj);

   \textcolor{keywordflow}{if} (no\_sel)
     elm\_gengrid\_select\_mode\_set(grid, ELM\_OBJECT\_SELECT\_MODE\_NONE);
   \textcolor{keywordflow}{else}
     elm\_gengrid\_select\_mode\_set(grid, ELM\_OBJECT\_SELECT\_MODE\_DEFAULT);

   fprintf(stdout, \textcolor{stringliteral}{"Selection for gengrid items is now %s\(\backslash\)n"},
           no\_sel ? \textcolor{stringliteral}{"disabled"} : \textcolor{stringliteral}{"enabled"});
\}

\end{DoxyCodeInclude}


We have, finally, one more line of knobs, now sliders, to change the grids behavior. The two first will change the horizontal {\bfseries alignment} of the whole actual grid of items within the gengrid\textquotesingle{}s viewport\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* items grid horizontal alignment change */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_h\_align\_change\_cb(\textcolor{keywordtype}{void}        *data,
                   Evas\_Object *obj,
                   \textcolor{keywordtype}{void}        *event\_info)
\{
   \textcolor{keywordtype}{double} v\_align;
   \textcolor{keywordtype}{double} val = elm\_slider\_value\_get(obj);

   elm\_gengrid\_align\_get(data, NULL, &v\_align);

   fprintf(stdout, \textcolor{stringliteral}{"Setting horizontal alignment to %f\(\backslash\)n"}, val);
   elm\_gengrid\_align\_set(data, val, v\_align);
\}

\end{DoxyCodeInclude}


Naturally, the vertical counterpart just issues elm\+\_\+gengrid\+\_\+align\+\_\+set() changing the second alignment component, instead.

The last slider will change the grid\textquotesingle{}s {\bfseries page size}, relative to its own one. Try to change those values and, one manner of observing the paging behavior, is to scroll softly and release the mouse button, with different page sizes, at different grid positions, while having lots of items in it -- you\textquotesingle{}ll see it snapping to page boundaries differenty, for each configuration\+:  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* page relative size change */}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_page\_change\_cb(\textcolor{keywordtype}{void}        *data,
                Evas\_Object *obj,
                \textcolor{keywordtype}{void}        *event\_info)
\{
   \textcolor{keywordtype}{double} val = elm\_slider\_value\_get(obj);

   elm_scroller_page_relative_set(data, val, val);

   fprintf(stdout, \textcolor{stringliteral}{"Setting grid page's relative size to %f\(\backslash\)n"}, val);
\}

\end{DoxyCodeInclude}


This is how the example program\textquotesingle{}s window looks like\+:  
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth]{screenshots/gengrid_example}}
\end{DoxyImageNoCaption}


Note that it starts with three items which we included at will\+:  
\begin{DoxyCodeInclude}
   \_append\_bt\_clicked(grid, NULL, NULL);
   \_append\_bt\_clicked(grid, NULL, NULL);
   \_append\_bt\_clicked(grid, NULL, NULL);

\end{DoxyCodeInclude}


See the full \hyperlink{gengrid_example_c}{source code} for this example. 