\section{layout\-\_\-example\-\_\-03.\-c}

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

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

\textcolor{preprocessor}{#define TITLE "example/title"}
\textcolor{preprocessor}{}\textcolor{preprocessor}{#define SWALLOW "example/custom"}
\textcolor{preprocessor}{}
\textcolor{keyword}{static} Eina\_Bool \_btn\_large = EINA\_FALSE;

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_swallow\_btn\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *btn, \textcolor{keywordtype}{void} *event\_info)
\{
   Evas\_Object *layout = data;

   \textcolor{keywordflow}{if} (\_btn\_large == EINA\_FALSE)
     \{
        \_btn\_large = EINA\_TRUE;
        elm_object_signal_emit(layout, \textcolor{stringliteral}{"button,enlarge"}, \textcolor{stringliteral}{""});
        elm\_object\_text\_set(btn, \textcolor{stringliteral}{"Reduce me!"});
     \}
   \textcolor{keywordflow}{else}
     \{
        \_btn\_large = EINA\_FALSE;
        elm_object_signal_emit(layout, \textcolor{stringliteral}{"button,reduce"}, \textcolor{stringliteral}{""});
        elm\_object\_text\_set(btn, \textcolor{stringliteral}{"Enlarge me!"});
     \}
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_size\_changed\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *layout, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *emission, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *source)
\{
   Evas\_Object *edje;
   Evas\_Coord w, h;

   elm_layout_sizing_eval(layout);
   edje = elm_layout_edje_get(layout);
   edje\_object\_size\_min\_calc(edje, &w, &h);
   printf(\textcolor{stringliteral}{"Minimum size for this theme: %dx%d\(\backslash\)n"}, w, h);
\}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   Evas\_Object *win, *btn, *layout;
   \textcolor{keywordtype}{char} buf[PATH\_MAX];

   elm_app_info_set(elm\_main, \textcolor{stringliteral}{"elementary"}, \textcolor{stringliteral}{"examples/layout\_example.edj"});
   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"layout"}, \textcolor{stringliteral}{"Layout Example"});
   elm_win_autodel_set(win, EINA\_TRUE);

   \textcolor{comment}{// Adding layout}
   layout = elm_layout_add(win);
   evas\_object\_size\_hint\_weight\_set(layout, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm_win_resize_object_add(win, layout);
   snprintf(buf, \textcolor{keyword}{sizeof}(buf), \textcolor{stringliteral}{"%s/examples/layout\_example.edj"}, 
      elm_app_data_dir_get());
   elm_layout_file_set(layout, buf, \textcolor{stringliteral}{"example/mylayout3"});
   evas\_object\_show(layout);

   elm_object_signal_callback_add(layout, \textcolor{stringliteral}{"size,changed"}, \textcolor{stringliteral}{""}, \_size\_changed\_cb, layout);

   \textcolor{comment}{// Setting title}
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *title = elm_layout_data_get(layout, \textcolor{stringliteral}{"title"});
   \textcolor{keywordflow}{if} (title)
     \{
        elm_win_title_set(win, title);
        elm_object_part_text_set(layout, TITLE, title);
     \}

   btn = elm_button_add(win);
   elm\_object\_text\_set(btn, \textcolor{stringliteral}{"Enlarge me!"});
   evas\_object\_size\_hint\_weight\_set(btn, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(btn, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm_object_part_content_set(layout, SWALLOW, btn);
   evas\_object\_smart\_callback\_add(btn, \textcolor{stringliteral}{"clicked"}, \_swallow\_btn\_cb, layout);

   evas\_object\_resize(win, 160, 160);
   evas\_object\_show(win);

   elm_run();
   elm_shutdown();

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