\section{flipselector\-\_\-example.\-c}

\begin{DoxyCodeInclude}

\textcolor{preprocessor}{#include <Elementary.h>}

\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *commands = \(\backslash\)
                              \textcolor{stringliteral}{"commands are:\(\backslash\)n"}
                              \textcolor{stringliteral}{"\(\backslash\)tn - flip to next item\(\backslash\)n"}
                              \textcolor{stringliteral}{"\(\backslash\)tp - flip to previous item\(\backslash\)n"}
                              \textcolor{stringliteral}{"\(\backslash\)tf - print first item's label\(\backslash\)n"}
                              \textcolor{stringliteral}{"\(\backslash\)tl - print last item's label\(\backslash\)n"}
                              \textcolor{stringliteral}{"\(\backslash\)ts - print selected item's label\(\backslash\)n"}
                              \textcolor{stringliteral}{"\(\backslash\)th - print help\(\backslash\)n"};

\textcolor{keywordtype}{void} \textcolor{comment}{/* unselect the item shown in the flip selector */}
\_unsel\_cb(\textcolor{keywordtype}{void}        *data,
          Evas\_Object *obj,
          \textcolor{keywordtype}{void}        *event\_info)
\{
   Elm_Object_Item *it;
   Evas\_Object *fp = data;

   it = elm_flipselector_selected_item_get(fp);
   elm_flipselector_item_selected_set(it, EINA\_FALSE);
\}

\textcolor{keywordtype}{void} \textcolor{comment}{/* delete the item shown in the flip selector */}
\_del\_cb(\textcolor{keywordtype}{void}        *data,
        Evas\_Object *obj,
        \textcolor{keywordtype}{void}        *event\_info)
\{
   Elm_Object_Item *it;
   Evas\_Object *fp = data;

   it = elm_flipselector_selected_item_get(fp);
   \textcolor{keywordflow}{if} (it) elm_object_item_del(it);
\}

\textcolor{keywordtype}{void} \textcolor{comment}{/* underflow callback */}
\_underflow\_cb(\textcolor{keywordtype}{void}        *data,
              Evas\_Object *obj,
              \textcolor{keywordtype}{void}        *event\_info)
\{
   fprintf(stdout, \textcolor{stringliteral}{"Underflow!\(\backslash\)n"});
\}

\textcolor{keywordtype}{void} \textcolor{comment}{/* overflow callback */}
\_overflow\_cb(\textcolor{keywordtype}{void}        *data,
             Evas\_Object *obj,
             \textcolor{keywordtype}{void}        *event\_info)
\{
   fprintf(stdout, \textcolor{stringliteral}{"Overflow!\(\backslash\)n"});
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_on\_keydown(\textcolor{keywordtype}{void}              *data,
            Evas\_Object       *\textcolor{keywordtype}{object},
            Evas\_Object       *src,
            Evas\_Callback\_Type type,
            \textcolor{keywordtype}{void}              *event\_info)
\{
   Evas\_Object *fs = data;
   Evas\_Event\_Key\_Down *ev = event\_info;

   \textcolor{keywordflow}{if} (type != EVAS\_CALLBACK\_KEY\_DOWN) \textcolor{keywordflow}{return};

   \textcolor{keywordflow}{if} (strcmp(ev->keyname, \textcolor{stringliteral}{"h"}) == 0) \textcolor{comment}{/* print help */}
     \{
        fprintf(stdout, \textcolor{stringliteral}{"%s"}, commands);
        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->keyname, \textcolor{stringliteral}{"n"}) == 0) \textcolor{comment}{/* flip to next item */}
     \{
        elm_flipselector_flip_next(fs);

        fprintf(stdout, \textcolor{stringliteral}{"Flipping to next item\(\backslash\)n"});

        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->keyname, \textcolor{stringliteral}{"p"}) == 0) \textcolor{comment}{/* flip to previous item */}
     \{
        elm_flipselector_flip_prev(fs);

        fprintf(stdout, \textcolor{stringliteral}{"Flipping to previous item\(\backslash\)n"});

        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->keyname, \textcolor{stringliteral}{"f"}) == 0) \textcolor{comment}{/* print first item's label */}
     \{
        Elm_Object_Item *it;

        it = elm_flipselector_first_item_get(fs);

        fprintf(stdout, \textcolor{stringliteral}{"Flip selector's first item is: %s\(\backslash\)n"}, it ?
                elm\_object\_item\_text\_get(it) : \textcolor{stringliteral}{"none"});

        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->keyname, \textcolor{stringliteral}{"l"}) == 0) \textcolor{comment}{/* print last item's label */}
     \{
        Elm_Object_Item *it;

        it = elm_flipselector_last_item_get(fs);

        fprintf(stdout, \textcolor{stringliteral}{"Flip selector's last item is: %s\(\backslash\)n"}, it ?
                elm\_object\_item\_text\_get(it) : \textcolor{stringliteral}{"none"});

        \textcolor{keywordflow}{return};
     \}

   \textcolor{keywordflow}{if} (strcmp(ev->keyname, \textcolor{stringliteral}{"s"}) == 0) \textcolor{comment}{/* print selected item's label */}
     \{
        Elm_Object_Item *it;

        it = elm_flipselector_selected_item_get(fs);

        fprintf(stdout, \textcolor{stringliteral}{"Flip selector's selected item is: %s\(\backslash\)n"}, it ?
                elm\_object\_item\_text\_get(it) : \textcolor{stringliteral}{"none"});

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

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} i;
   Evas\_Object *win, *bx, *fp, *bt;
   \textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *lbl[] =
     \{
        \textcolor{stringliteral}{"Elementary"},
        \textcolor{stringliteral}{"Evas"},
        \textcolor{stringliteral}{"Eina"},
        \textcolor{stringliteral}{"Edje"},
        \textcolor{stringliteral}{"Eet"},
        \textcolor{stringliteral}{"Ecore"},
        \textcolor{stringliteral}{"Efreet"},
        \textcolor{stringliteral}{"Eldbus"}
     \};

   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"flipselector"}, \textcolor{stringliteral}{"Flip Selector 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);

   fp = elm_flipselector_add(win);
   evas\_object\_size\_hint\_weight\_set(fp, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_smart\_callback\_add(fp, \textcolor{stringliteral}{"underflowed"}, \_overflow\_cb, NULL);
   evas\_object\_smart\_callback\_add(fp, \textcolor{stringliteral}{"overflowed"}, \_underflow\_cb, NULL);
   \textcolor{keywordflow}{for} (i = 0; i < \textcolor{keyword}{sizeof}(lbl) / \textcolor{keyword}{sizeof}(lbl[0]); i++)
     elm_flipselector_item_append(fp, lbl[i], NULL, NULL);
   elm_box_pack_end(bx, fp);
   evas\_object\_show(fp);

   bt = elm_button_add(win);
   elm\_object\_text\_set(bt, \textcolor{stringliteral}{"Unselect item"});
   evas\_object\_smart\_callback\_add(bt, \textcolor{stringliteral}{"clicked"}, \_unsel\_cb, fp);
   elm_box_pack_end(bx, bt);
   evas\_object\_show(bt);

   bt = elm_button_add(win);
   elm\_object\_text\_set(bt, \textcolor{stringliteral}{"Delete item"});
   evas\_object\_smart\_callback\_add(bt, \textcolor{stringliteral}{"clicked"}, \_del\_cb, fp);
   elm_box_pack_end(bx, bt);
   evas\_object\_show(bt);

   elm_object_event_callback_add(win, (Elm_Event_Cb)\_on\_keydown, fp);

   evas\_object\_show(win);

   fprintf(stdout, \textcolor{stringliteral}{"%s"}, commands);
   elm_run();
   elm_shutdown();

   \textcolor{keywordflow}{return} 0;
\}
ELM_MAIN()
\end{DoxyCodeInclude}
 