This code places an Elementary segment control widgets on a window, to exemplify part of the widget\textquotesingle{}s A\+PI.

Let\textquotesingle{}s start adding a segment control to our window\+:  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   sc = \mbox{\hyperlink{group__Elm__Segment__Control_ga6c0d5f4de78c9c66b4a09680d3c85f46}{elm\_segment\_control\_add}}(win);}
\DoxyCodeLine{   evas\_object\_size\_hint\_weight\_set(sc, \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}}, \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Win_ga505d6bd217e5ee01e82b548ec35986eb}{elm\_win\_resize\_object\_add}}(win, sc);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(sc);}

\end{DoxyCodeInclude}


Now will add an item only with label\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   elm\_segment\_control\_item\_add(sc, NULL, \textcolor{stringliteral}{"only text"});}

\end{DoxyCodeInclude}


Really simple. To add an item with only an icon, the icon needs to be created first, them added with this same function\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   ic = \mbox{\hyperlink{group__Elm__Icon_ga5739728c1209f90422cf65a778a16502}{elm\_icon\_add}}(win);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Icon_gab764b4c6c90543f254c013eff6a6db66}{elm\_icon\_standard\_set}}(ic, \textcolor{stringliteral}{"close"});}
\DoxyCodeLine{   elm\_segment\_control\_item\_add(sc, ic, NULL);}

\end{DoxyCodeInclude}


If an item with label and icon is required, it can be done as well. In this case, instead of a label (or icon) centered, the item will display an icon at left and the label at right\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   ic = \mbox{\hyperlink{group__Elm__Icon_ga5739728c1209f90422cf65a778a16502}{elm\_icon\_add}}(win);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Icon_gab764b4c6c90543f254c013eff6a6db66}{elm\_icon\_standard\_set}}(ic, \textcolor{stringliteral}{"home"});}
\DoxyCodeLine{   elm\_segment\_control\_item\_add(sc, ic, \textcolor{stringliteral}{"Home"});}

\end{DoxyCodeInclude}


But, if you need to add some items that can have or not a label, but want that all of them looks the same way, with icon at left, just add an empty string label. It\textquotesingle{}s done on our example to illustrate that\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   ic = \mbox{\hyperlink{group__Elm__Icon_ga5739728c1209f90422cf65a778a16502}{elm\_icon\_add}}(win);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Icon_gab764b4c6c90543f254c013eff6a6db66}{elm\_icon\_standard\_set}}(ic, \textcolor{stringliteral}{"close"});}
\DoxyCodeLine{   elm\_segment\_control\_item\_add(sc, ic, \textcolor{stringliteral}{""});}

\end{DoxyCodeInclude}


So far, all the item were added to the last position of the widget, but if something different is required, it can be done using another insertion function. Let\textquotesingle{}s suppose we want to put an item just before the last item\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   count = elm\_segment\_control\_item\_count\_get(sc);}
\DoxyCodeLine{   elm\_segment\_control\_item\_insert\_at(sc, NULL, \textcolor{stringliteral}{"Inserted at"}, count -\/ 1);}

\end{DoxyCodeInclude}


There are two ways to delete items. Using the item handle, like\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   seg\_it = elm\_segment\_control\_item\_insert\_at(sc, NULL, \textcolor{stringliteral}{"To be deleted"}, 2);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__General_gad1b5a0d41fa322b28000a290154ec3a4}{elm\_object\_item\_del}}(seg\_it);}

\end{DoxyCodeInclude}


Or using item\textquotesingle{}s index\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   elm\_segment\_control\_item\_insert\_at(sc, NULL, \textcolor{stringliteral}{"To be deleted"}, 2);}
\DoxyCodeLine{   elm\_segment\_control\_item\_del\_at(sc, 2);}

\end{DoxyCodeInclude}


To set properties of an item already added to the widget, you just need to get the item and set icon or label, as the following code shows\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   seg\_it = elm\_segment\_control\_item\_get(sc, 0);}

\end{DoxyCodeInclude}


Finally, it\textquotesingle{}s possible to select an item from the code, and also get the selected item. We will select the item at the center of the widget and print its position. 
\begin{DoxyCodeInclude}{0}

\end{DoxyCodeInclude}


See the full \mbox{\hyperlink{segment_control_example_8c-example}{example}}, whose window should look like this picture\+:

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