\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();
   elm_shutdown();

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