\chapter{Flip selector widget example}
\hypertarget{flipselector_example}{}\label{flipselector_example}\index{Flip selector widget example@{Flip selector widget example}}
This code places an Elementary flip selector widget on a window, along with two buttons trigerring actions on it (though its API).

The selector is being populated with the following items\+:  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{static}\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *lbl[]\ =}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}Elementary"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}Evas"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}Eina"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}Edje"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}Eet"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}Ecore"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}Efreet"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}Eldbus"{}}}
\DoxyCodeLine{\ \ \ \ \ \};}

\end{DoxyCodeInclude}
 Next, we create it, populating it with those items and registering two (smart) callbacks on it\+:  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ fp\ =\ \mbox{\hyperlink{group__Elm__Flipselector_gaeebeba2650b6d8da966edeec157b1746}{elm\_flipselector\_add}}(win);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group_ga9379629ad8ad2860aa786d838a4a106a}{evas\_object\_size\_hint\_weight\_set}}(fp,\ \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}},\ \mbox{\hyperlink{Evas__Common_8h_aa47c85083d3dae0111c21ec49359306a}{EVAS\_HINT\_EXPAND}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Smart__Object__Group_gac12dd6655f488cc47ce6cf00eb7d12b2}{evas\_object\_smart\_callback\_add}}(fp,\ \textcolor{stringliteral}{"{}underflowed"{}},\ \_overflow\_cb,\ NULL);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Smart__Object__Group_gac12dd6655f488cc47ce6cf00eb7d12b2}{evas\_object\_smart\_callback\_add}}(fp,\ \textcolor{stringliteral}{"{}overflowed"{}},\ \_underflow\_cb,\ NULL);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ \textcolor{keyword}{sizeof}(lbl)\ /\ \textcolor{keyword}{sizeof}(lbl[0]);\ i++)}
\DoxyCodeLine{\ \ \ \ \ elm\_flipselector\_item\_append(fp,\ lbl[i],\ NULL,\ NULL);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Box__Group_ga66a10dd861578521af2ab7b8c2ca65c5}{elm\_box\_pack\_end}}(bx,\ fp);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(fp);}

\end{DoxyCodeInclude}
 Those two callbacks will take place whenever one of those smart events occur, and they will just print something to {\ttfamily stdout\+:}  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keywordtype}{void}\ \textcolor{comment}{/*\ underflow\ callback\ */}}
\DoxyCodeLine{\_underflow\_cb(\textcolor{keywordtype}{void}\ \ \ \ \ \ \ \ *data\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ Evas\_Object\ *obj\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ \ \ \ \ \ \ \ *event\_info\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}Underflow!\(\backslash\)n"{}});}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{void}\ \textcolor{comment}{/*\ overflow\ callback\ */}}
\DoxyCodeLine{\_overflow\_cb(\textcolor{keywordtype}{void}\ \ \ \ \ \ \ \ *data\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ Evas\_Object\ *obj\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ \ \ \ \ \ \ \ *event\_info\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}Overflow!\(\backslash\)n"{}});}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
Flip the sheets on the widget while looking at the items list, in the source code, and you\textquotesingle{}ll get the idea of those events.

The two buttons below the flip selector will take the actions described in their labels\+:  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ bt\ =\ \mbox{\hyperlink{group__Elm__Button_gaf5caf46d74c4e122a18da323935d25e4}{elm\_button\_add}}(win);}
\DoxyCodeLine{\ \ \ elm\_object\_text\_set(bt,\ \textcolor{stringliteral}{"{}Unselect\ item"{}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Smart__Object__Group_gac12dd6655f488cc47ce6cf00eb7d12b2}{evas\_object\_smart\_callback\_add}}(bt,\ \textcolor{stringliteral}{"{}clicked"{}},\ \_unsel\_cb,\ fp);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Box__Group_ga66a10dd861578521af2ab7b8c2ca65c5}{elm\_box\_pack\_end}}(bx,\ bt);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(bt);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ bt\ =\ \mbox{\hyperlink{group__Elm__Button_gaf5caf46d74c4e122a18da323935d25e4}{elm\_button\_add}}(win);}
\DoxyCodeLine{\ \ \ elm\_object\_text\_set(bt,\ \textcolor{stringliteral}{"{}Delete\ item"{}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Smart__Object__Group_gac12dd6655f488cc47ce6cf00eb7d12b2}{evas\_object\_smart\_callback\_add}}(bt,\ \textcolor{stringliteral}{"{}clicked"{}},\ \_del\_cb,\ fp);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__Box__Group_ga66a10dd861578521af2ab7b8c2ca65c5}{elm\_box\_pack\_end}}(bx,\ bt);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga07208fcafd4739de606bc35fff684bf5}{evas\_object\_show}}(bt);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Elm__General_gae2d2f3ef544f5aa59a0d89fbb67584e5}{elm\_object\_event\_callback\_add}}(win,\ \_on\_keydown,\ fp);}

\end{DoxyCodeInclude}
  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keywordtype}{void}\ \textcolor{comment}{/*\ unselect\ the\ item\ shown\ in\ the\ flip\ selector\ */}}
\DoxyCodeLine{\_unsel\_cb(\textcolor{keywordtype}{void}\ \ \ \ \ \ \ \ *data,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ Evas\_Object\ *obj\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ \ \ \ \ \ \ \ *event\_info\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ Elm\_Object\_Item\ *it;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *fp\ =\ data;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ it\ =\ elm\_flipselector\_selected\_item\_get(fp);}
\DoxyCodeLine{\ \ \ elm\_flipselector\_item\_selected\_set(it,\ \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}});}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{void}\ \textcolor{comment}{/*\ delete\ the\ item\ shown\ in\ the\ flip\ selector\ */}}
\DoxyCodeLine{\_del\_cb(\textcolor{keywordtype}{void}\ \ \ \ \ \ \ \ *data,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ Evas\_Object\ *obj\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ \ \ \ \ \ \ \ *event\_info\ \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ Elm\_Object\_Item\ *it;}
\DoxyCodeLine{\ \ \ Evas\_Object\ *fp\ =\ data;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ it\ =\ elm\_flipselector\_selected\_item\_get(fp);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (it)\ \mbox{\hyperlink{group__Elm__General_gad1b5a0d41fa322b28000a290154ec3a4}{elm\_object\_item\_del}}(it);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 Click on them to exercise those flip selector API calls. To interact with the other parts of this API, there\textquotesingle{}s a command line interface, whose help string can be asked for with the \textquotesingle{}h\textquotesingle{} key\+:  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *commands\ =\ \(\backslash\)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}commands\ are:\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)tn\ -\/\ flip\ to\ next\ item\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)tp\ -\/\ flip\ to\ previous\ item\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)tf\ -\/\ print\ first\ item's\ label\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)tl\ -\/\ print\ last\ item's\ label\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)ts\ -\/\ print\ selected\ item's\ label\(\backslash\)n"{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}\(\backslash\)th\ -\/\ print\ help\(\backslash\)n"{}};}

\end{DoxyCodeInclude}
 The \textquotesingle{}n\textquotesingle{} and \textquotesingle{}p\textquotesingle{} keys will exemplify elm\+\_\+flipselector\+\_\+flip\+\_\+next() and elm\+\_\+flipselector\+\_\+flip\+\_\+prev(), respectively. \textquotesingle{}f\textquotesingle{} and \textquotesingle{}l\textquotesingle{} account for elm\+\_\+flipselector\+\_\+first\+\_\+item\+\_\+get() and elm\+\_\+flipselector\+\_\+last\+\_\+item\+\_\+get(), respectively. Finally, \textquotesingle{}s\textquotesingle{} will issue elm\+\_\+flipselector\+\_\+selected\+\_\+item\+\_\+get() on our example flip selector widget.

See the full \doxylink{flipselector_example_8c-example}{example}, whose window should look like this picture\+:

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


See the full \doxysectlink{flipselector_example_c}{source code}{0} for this example. 