This code places an Elementary mapbuf widget on a window, to exemplify part of the widget\textquotesingle{}s A\+P\+I.

First we\textquotesingle{}ll add an window with a background and a vertical box to pack our interface elements\+:  
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


Next we\textquotesingle{}ll simply add the mapbuf widget to the box\+: 
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


But mapbuf is a container widget, it won\textquotesingle{}t do anything alone. So let\textquotesingle{}s create a table full of icons. For that we\textquotesingle{}ll loop to fill each line of each column. See \hyperlink{tutorial_table_01}{tutorial\+\_\+table\+\_\+01} if you don\textquotesingle{}t know how to use tables\+: 
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


Finally, setting mapbuf content\+: 
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


Also, would be good a horizontal box with some controls to change mapbuf behavior\+: 
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


By default map is disabled. So just setting content isn\textquotesingle{}t enough. Alpha and smooth settings will be applied when map is enabled. So we\textquotesingle{}ll add a check for that. Everytime the map properties are changed, map will need to be enabled again. So if you want to play a bit with our example, remember to always enable map again after concluding your changes. 
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


We have added a callback function to this check, so it will enable or disable map\+:  
\begin{DoxyCodeInclude}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_alpha\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   Evas\_Object *mb = data;
   elm\_mapbuf\_alpha\_set(mb, elm\_check\_state\_get(obj));
\}

\end{DoxyCodeInclude}


Let\textquotesingle{}s add check boxes for alpha blending and smooth rendering\+: 
\begin{DoxyCodeInclude}
   tg = elm_check_add(win);
   elm_object_style_set(tg, \textcolor{stringliteral}{"toggle"});
   elm_object_part_text_set(tg, \textcolor{stringliteral}{"on"}, \textcolor{stringliteral}{"Enabled"});
   elm_object_part_text_set(tg, \textcolor{stringliteral}{"off"}, \textcolor{stringliteral}{"Disabled"});
   elm\_object\_text\_set(tg, \textcolor{stringliteral}{"Map"});
   evas\_object\_smart\_callback\_add(tg, \textcolor{stringliteral}{"changed"}, \_enabled\_cb, mb);
   elm\_box\_pack\_end(hbx, tg);
   evas\_object\_show(tg);

   ck = elm_check_add(win);
   elm\_object\_text\_set(ck, \textcolor{stringliteral}{"Alpha"});
   elm\_check\_state\_set(ck, EINA\_TRUE);
   evas\_object\_smart\_callback\_add(ck, \textcolor{stringliteral}{"changed"}, \_alpha\_cb, mb);
   elm\_box\_pack\_end(hbx, ck);
   evas\_object\_show(ck);

\end{DoxyCodeInclude}


By default, mapbuf would enable alpha blending and smooth rendering, so we need to check boxes to be consistent with its behavior.

Callback functions look like the one added to the check. This way we could enable or disable the both properties\+:  
\begin{DoxyCodeInclude}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_smooth\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   Evas\_Object *mb = data;
   elm\_mapbuf\_smooth\_set(mb, elm\_check\_state\_get(obj));
\}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   Evas\_Object *win, *bx, *hbx, *tg, *ck, *mb, *tb, *ic;
   \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} i, j;

   elm_policy_set(ELM\_POLICY\_QUIT, ELM\_POLICY\_QUIT\_LAST\_WINDOW\_CLOSED);

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"mapbuf"}, \textcolor{stringliteral}{"Mapbuf Example"});
   elm\_win\_autodel\_set(win, EINA\_TRUE);

   bx = elm_box_add(win);
   evas\_object\_size\_hint\_weight\_set(bx, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm\_win\_resize\_object\_add(win, bx);
   evas\_object\_show(bx);

   mb = elm_mapbuf_add(win);
   evas\_object\_size\_hint\_weight\_set(mb, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(mb, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_box\_pack\_end(bx, mb);

   tb = elm_table_add(win);
   evas\_object\_size\_hint\_weight\_set(tb, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(tb, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   evas\_object\_show(tb);

   \textcolor{keywordflow}{for} (i = 0; i < 8; i++)
     \{
        \textcolor{keywordflow}{for} (j = 0; j < 8; j++)
          \{
             ic = elm_icon_add(win);
             elm\_icon\_standard\_set(ic, \textcolor{stringliteral}{"home"});
             elm\_image\_resizable\_set(ic, EINA\_FALSE, EINA\_FALSE);
             evas\_object\_show(ic);
             elm\_table\_pack(tb, ic, i, j, 1, 1);
          \}

\end{DoxyCodeInclude}


You\textquotesingle{}ll see that disabling alpha blending will set a black rectangle below the icons. That\textquotesingle{}s the reason you only should enable that when you\textquotesingle{}re sure the mapbuf content is 100\% solid.

See \hyperlink{mapbuf_example_8c-example}{mapbuf\+\_\+example.c}, whose window should look like this picture\+:

 
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth]{screenshots/mapbuf_example}}
\end{DoxyImageNoCaption}
 