\section{slider\+\_\+example.\+c}

\begin{DoxyCodeInclude}

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

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_changed\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   \textcolor{keywordtype}{double} val = elm\_slider\_value\_get(obj);
   printf(\textcolor{stringliteral}{"Changed to %1.2f\(\backslash\)n"}, val);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_delay\_changed\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   \textcolor{keywordtype}{double} val = elm\_slider\_value\_get(obj);
   printf(\textcolor{stringliteral}{"Delay changed to %1.2f\(\backslash\)n"}, val);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{char}*
\_indicator\_format(\textcolor{keywordtype}{double} val)
\{
   \textcolor{keywordtype}{char} *indicator = malloc(\textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}) * 32);
   snprintf(indicator, 32, \textcolor{stringliteral}{"%1.2f u"}, val);
   \textcolor{keywordflow}{return} indicator;
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_indicator\_free(\textcolor{keywordtype}{char} *str)
\{
   free(str);
\}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   Evas\_Object *win, *bx, *sl, *ic;

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

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

   \textcolor{comment}{/* default */}
   sl = elm_slider_add(win);
   evas\_object\_size\_hint\_align\_set(sl, EVAS\_HINT\_FILL, 0.5);
   evas\_object\_size\_hint\_weight\_set(sl, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm\_box\_pack\_end(bx, sl);
   evas\_object\_show(sl);

   \textcolor{comment}{/* with icon, end and label */}
   sl = elm_slider_add(win);
   elm\_object\_text\_set(sl, \textcolor{stringliteral}{"Counter"});

   ic = elm_icon_add(win);
   elm\_icon\_standard\_set(ic, \textcolor{stringliteral}{"home"});
   elm\_image\_resizable\_set(ic, EINA\_FALSE, EINA\_FALSE);
   elm_object_part_content_set(sl, \textcolor{stringliteral}{"icon"}, ic);

   ic = elm_icon_add(win);
   elm\_icon\_standard\_set(ic, \textcolor{stringliteral}{"folder"});
   elm\_image\_resizable\_set(ic, EINA\_FALSE, EINA\_FALSE);
   elm_object_part_content_set(sl, \textcolor{stringliteral}{"end"}, ic);

   evas\_object\_size\_hint\_align\_set(sl, EVAS\_HINT\_FILL, 0.5);
   evas\_object\_size\_hint\_weight\_set(sl, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm\_box\_pack\_end(bx, sl);
   evas\_object\_show(sl);

   \textcolor{comment}{/* value set and span size */}
   sl = elm_slider_add(win);
   elm\_slider\_value\_set(sl, 1);
   elm\_slider\_span\_size\_set(sl, 200);
   evas\_object\_size\_hint\_align\_set(sl, EVAS\_HINT\_FILL, 0.5);
   evas\_object\_size\_hint\_weight\_set(sl, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm\_box\_pack\_end(bx, sl);
   evas\_object\_show(sl);

   \textcolor{comment}{/* with unit label and min - max */}
   sl = elm_slider_add(win);
   elm\_slider\_unit\_format\_set(sl, \textcolor{stringliteral}{"%1.0f units"});
   elm\_slider\_min\_max\_set(sl, 0, 100);
   evas\_object\_size\_hint\_align\_set(sl, EVAS\_HINT\_FILL, 0.5);
   evas\_object\_size\_hint\_weight\_set(sl, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm\_box\_pack\_end(bx, sl);
   evas\_object\_show(sl);

   \textcolor{comment}{/* with indicator label and inverted */}
   sl = elm_slider_add(win);
   elm\_slider\_indicator\_format\_set(sl, \textcolor{stringliteral}{"%1.2f"});
   elm\_slider\_inverted\_set(sl, EINA\_TRUE);
   evas\_object\_size\_hint\_align\_set(sl, EVAS\_HINT\_FILL, 0.5);
   evas\_object\_size\_hint\_weight\_set(sl, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm\_box\_pack\_end(bx, sl);
   evas\_object\_show(sl);

   \textcolor{comment}{/* vertical with indicator format func */}
   sl = elm_slider_add(win);
   elm\_slider\_horizontal\_set(sl, EINA\_FALSE);
   elm\_slider\_indicator\_format\_function\_set(sl, \_indicator\_format,
                                            \_indicator\_free);
   evas\_object\_size\_hint\_align\_set(sl, 0.5, EVAS\_HINT\_FILL);
   evas\_object\_size\_hint\_weight\_set(sl, 0, EVAS\_HINT\_EXPAND);
   elm\_box\_pack\_end(bx, sl);
   evas\_object\_show(sl);

   \textcolor{comment}{/* callbacks */}
   sl = elm_slider_add(win);
   elm\_slider\_unit\_format\_set(sl, \textcolor{stringliteral}{"%1.3f units"});
   evas\_object\_size\_hint\_align\_set(sl, EVAS\_HINT\_FILL, 0.5);
   evas\_object\_size\_hint\_weight\_set(sl, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm\_box\_pack\_end(bx, sl);
   evas\_object\_show(sl);
   evas\_object\_smart\_callback\_add(sl, \textcolor{stringliteral}{"changed"}, \_changed\_cb, NULL);
   evas\_object\_smart\_callback\_add(sl, \textcolor{stringliteral}{"delay,changed"}, \_delay\_changed\_cb, NULL);

   evas\_object\_show(win);

   elm_run();

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