
\begin{DoxyCodeInclude}
\textcolor{comment}{/* Compile with:}
\textcolor{comment}{ * gcc -g general\_funcs\_example.c -o general\_funcs\_example `pkg-config --cflags --libs elementary`}
\textcolor{comment}{ */}

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

\textcolor{preprocessor}{#define BIN\_DIR  "/usr/bin"}
\textcolor{preprocessor}{}\textcolor{preprocessor}{#define LIB\_DIR  "/usr/lib"}
\textcolor{preprocessor}{}\textcolor{preprocessor}{#define DATA\_DIR "/usr/local/share/elementary"}
\textcolor{preprocessor}{}
\textcolor{preprocessor}{#define WIDTH             300}
\textcolor{preprocessor}{}\textcolor{preprocessor}{#define HEIGHT            300}
\textcolor{preprocessor}{}
\textcolor{keyword}{struct }test\_data
\{
   Evas\_Object *btn;
   Eina\_Bool    btn\_enabled;
   Eina\_Bool    btn\_gets\_focus;
\};

\textcolor{keyword}{struct }test\_data d = \{NULL, EINA\_TRUE, EINA\_TRUE\};

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_btn\_enabled\_cb(\textcolor{keywordtype}{void}        *data,
                Evas\_Object *obj,
                \textcolor{keywordtype}{void}        *event)
\{
   elm_object_disabled_set(d.btn, !d.btn\_enabled);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\textcolor{comment}{/* focus callback */}
\_btn\_focus\_cb(\textcolor{keywordtype}{void}        *data,
              Evas\_Object *obj,
              \textcolor{keywordtype}{void}        *event)
\{
   elm_object_focus_set(d.btn, EINA\_TRUE);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\textcolor{comment}{/* unfocus callback */}
\_btn\_unfocus\_cb(\textcolor{keywordtype}{void}        *data,
                Evas\_Object *obj,
                \textcolor{keywordtype}{void}        *event)
\{
   elm_object_focus_set(d.btn, EINA\_FALSE);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\textcolor{comment}{/* focus allow callback */}
\_btn\_focus\_allow\_cb(\textcolor{keywordtype}{void}        *data,
                    Evas\_Object *obj,
                    \textcolor{keywordtype}{void}        *event)
\{
   elm_object_focus_allow_set(d.btn, d.btn\_gets\_focus);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void} \textcolor{comment}{/* scaling callback */}
\_btn\_scale\_cb(\textcolor{keywordtype}{void}        *data,
              Evas\_Object *obj,
              \textcolor{keywordtype}{void}        *event)
\{
   elm_object_scale_set(d.btn, elm_slider_value_get(obj));
\}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int}    argc,
         \textcolor{keywordtype}{char} **argv)
\{
   Evas\_Object *win, *box, *frame, *check, *b, *slider;

   \textcolor{comment}{/* tell elm about our app so it can figure out where to get files */}
   elm_app_compile_bin_dir_set(BIN\_DIR);
   elm_app_compile_data_dir_set(DATA\_DIR);
   elm_app_compile_lib_dir_set(LIB\_DIR);
   elm_app_info_set(elm\_main, \textcolor{stringliteral}{"elementary"}, \textcolor{stringliteral}{"images/logo.png"});

   fprintf(stdout, \textcolor{stringliteral}{"prefix was set to: %s\(\backslash\)n"}, elm_app_prefix_dir_get());
   fprintf(stdout, \textcolor{stringliteral}{"data directory is: %s\(\backslash\)n"}, elm_app_data_dir_get());
   fprintf(stdout, \textcolor{stringliteral}{"library directory is: %s\(\backslash\)n"}, elm_app_lib_dir_get());
   fprintf(stdout, \textcolor{stringliteral}{"locale directory is: %s\(\backslash\)n"}, elm_app_locale_dir_get());

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"top-level-funcs-example"},
                                   \textcolor{stringliteral}{"Elementary Top-level Functions Example"});

   \textcolor{comment}{/* by using this policy value, we avoid having to}
\textcolor{comment}{    * evas\_object\_smart\_callback\_add(win, "delete,request", \_on\_exit, NULL),}
\textcolor{comment}{    * calling elm\_exit() on that callback ourselves.}
\textcolor{comment}{    */}
   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
   elm_win_autodel_set(win, EINA\_TRUE);

   \textcolor{comment}{/* outer box */}
   box = elm_box_add(win);
   evas\_object\_size\_hint\_weight\_set(box, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm_win_resize_object_add(win, box);
   evas\_object\_show(box);

   frame = elm_frame_add(win);
   elm\_object\_text\_set(frame, \textcolor{stringliteral}{"Button"});
   evas\_object\_size\_hint\_align\_set(frame, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   evas\_object\_show(frame);
   elm_box_pack_end(box, frame);

   d.btn = elm_button_add(win);
   elm\_object\_text\_set(d.btn, \textcolor{stringliteral}{"Click me"});
   elm\_object\_content\_set(frame, d.btn);
   fprintf(stdout, \textcolor{stringliteral}{"Elementary's finger size is set to %d pixels\(\backslash\)n."},
           elm_config_finger_size_get());
   evas\_object\_show(d.btn);

   b = elm_box_add(win);
   elm_box_horizontal_set(b, EINA\_FALSE);
   evas\_object\_size\_hint\_weight\_set(b, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm_box_pack_end(box, b);
   evas\_object\_show(b);

   check = elm_check_add(win);
   evas\_object\_size\_hint\_weight\_set(check, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(check, 0.0, 0.0);
   elm\_object\_text\_set(check, \textcolor{stringliteral}{"Button enabled"});
   elm_check_state_pointer_set(check, &d.btn\_enabled);
   evas\_object\_smart\_callback\_add(check, \textcolor{stringliteral}{"changed"}, \_btn\_enabled\_cb, NULL);
   elm_box_pack_end(box, check);
   evas\_object\_show(check);

   b = elm_button_add(win);
   evas\_object\_size\_hint\_weight\_set(b, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(b, 0.0, 0.0);
   elm\_object\_text\_set(b, \textcolor{stringliteral}{"Focus top button"});
   evas\_object\_smart\_callback\_add(b, \textcolor{stringliteral}{"clicked"}, \_btn\_focus\_cb, NULL);
   elm_box_pack_end(box, b);
   evas\_object\_show(b);

   b = elm_button_add(win);
   evas\_object\_size\_hint\_weight\_set(b, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(b, 0.0, 0.0);
   elm\_object\_text\_set(b, \textcolor{stringliteral}{"Unfocus top button"});
   evas\_object\_smart\_callback\_add(b, \textcolor{stringliteral}{"clicked"}, \_btn\_unfocus\_cb, NULL);
   elm_box_pack_end(box, b);
   evas\_object\_show(b);

   check = elm_check_add(win);
   evas\_object\_size\_hint\_weight\_set(check, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(check, 0.0, 0.0);
   elm\_object\_text\_set(check, \textcolor{stringliteral}{"Button gets focus"});
   elm_check_state_pointer_set(check, &d.btn\_gets\_focus);
   evas\_object\_smart\_callback\_add(check, \textcolor{stringliteral}{"changed"}, \_btn\_focus\_allow\_cb, NULL);
   elm_box_pack_end(box, check);
   evas\_object\_show(check);

   slider = elm_slider_add(win);
   elm_slider_min_max_set(slider, 0, 4);
   elm_slider_unit_format_set(slider, \textcolor{stringliteral}{"%1.1f"});
   elm_slider_indicator_format_set(slider, \textcolor{stringliteral}{"%1.1f"});
   evas\_object\_size\_hint\_weight\_set(
      slider, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(slider, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   evas\_object\_smart\_callback\_add(slider, \textcolor{stringliteral}{"changed"}, \_btn\_scale\_cb, NULL);
   elm_box_pack_end(box, slider);
   evas\_object\_show(slider);

   evas\_object\_resize(win, WIDTH, HEIGHT);
   elm_win_focus_highlight_enabled_set(win, EINA\_TRUE);
   evas\_object\_show(win);

   elm_run(); \textcolor{comment}{/* and run the program now, starting to handle all}
\textcolor{comment}{               * events, etc. */}
   elm_shutdown(); \textcolor{comment}{/* clean up and shut down */}

   \textcolor{comment}{/* exit code */}
   \textcolor{keywordflow}{return} 0;
\}
ELM_MAIN()
\end{DoxyCodeInclude}
 