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

\begin{DoxyCodeInclude}
\textcolor{comment}{/*}
\textcolor{comment}{ * gcc -o inwin\_example inwin\_example.c `pkg-config --cflags --libs elementary`}
\textcolor{comment}{ */}
\textcolor{preprocessor}{#include <Elementary.h>}

\textcolor{keyword}{static} Evas\_Object *inwin = NULL;
\textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *styles[] = \{
     \textcolor{stringliteral}{"default"},
     \textcolor{stringliteral}{"minimal"},
     \textcolor{stringliteral}{"minimal\_vertical"}
\};
\textcolor{keyword}{static} \textcolor{keywordtype}{int} current\_style = 0;

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_inwin\_hide(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   \textcolor{keywordflow}{if} (inwin)
     \{
        evas\_object\_hide(inwin);
        \textcolor{keywordflow}{return};
     \}
   elm\_object\_text\_set(obj, \textcolor{stringliteral}{"No inwin!"});
   elm_object_disabled_set(obj, EINA\_TRUE);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_inwin\_destroy(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   \textcolor{keywordflow}{if} (inwin)
     \{
        evas\_object\_del(inwin);
        inwin = NULL;
        \textcolor{keywordflow}{return};
     \}
   elm\_object\_text\_set(obj, \textcolor{stringliteral}{"No inwin!"});
   elm_object_disabled_set(obj, EINA\_TRUE);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_btn\_click\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   Evas\_Object *o, *parent;

   \textcolor{keywordflow}{if} (inwin)
     \{
        elm_win_inwin_activate(inwin);
        \textcolor{keywordflow}{return};
     \}

   parent = elm_object_top_widget_get(obj);
   inwin = elm_win_inwin_add(parent);
   elm_object_style_set(inwin, styles[current\_style]);
   evas\_object\_show(inwin);

   current\_style = (current\_style + 1) % 3;

   o = elm_box_add(parent);
   evas\_object\_size\_hint\_weight\_set(o, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(o, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm_win_inwin_content_set(inwin, o);
   evas\_object\_show(o);

   o = elm_label_add(parent);
   elm\_object\_text\_set(o, \textcolor{stringliteral}{"Click on the first button to hide the Inwin.<ps>"}
                       \textcolor{stringliteral}{"Second to destroy it<ps>"});
   evas\_object\_show(o);

   elm_box_pack_end(elm_win_inwin_content_get(inwin), o);

   o = elm_button_add(parent);
   elm\_object\_text\_set(o, \textcolor{stringliteral}{"Hide"});
   evas\_object\_show(o);

   evas\_object\_smart\_callback\_add(o, \textcolor{stringliteral}{"clicked"}, \_inwin\_hide, NULL);

   elm_box_pack_end(elm_win_inwin_content_get(inwin), o);

   o = elm_button_add(parent);
   elm\_object\_text\_set(o, \textcolor{stringliteral}{"Destroy"});
   evas\_object\_show(o);

   evas\_object\_smart\_callback\_add(o, \textcolor{stringliteral}{"clicked"}, \_inwin\_destroy, NULL);

   elm_box_pack_end(elm_win_inwin_content_get(inwin), o);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_win\_del\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   \textcolor{keywordflow}{if} (inwin)
     \{
        Evas\_Object *hover, *o = elm_win_inwin_content_unset(inwin);
        evas\_object\_del(inwin);
        inwin = NULL;
        hover = elm_hover_add(obj);
        elm_hover_target_set(hover, obj);
        elm_object_part_content_set(hover, \textcolor{stringliteral}{"middle"}, o);
        evas\_object\_show(hover);
        \textcolor{keywordflow}{return};
     \}
   evas\_object\_del(obj);
\}

\textcolor{keyword}{static} Eina\_Bool
\_screenshot\_hack\_cb(\textcolor{keywordtype}{void} *data)
\{
   \_btn\_click\_cb(NULL, data, NULL);
   \textcolor{keywordflow}{return} EINA\_FALSE;
\}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} *argv[])
\{
   Evas\_Object *win, *box, *o;

   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"inwin-example"}, \textcolor{stringliteral}{"Inwin Example"});
   elm_win_autodel_set(win, EINA\_TRUE);

   evas\_object\_smart\_callback\_add(win, \textcolor{stringliteral}{"delete,request"}, \_win\_del\_cb, NULL);

   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);

   o = elm_button_add(win);
   elm\_object\_text\_set(o, \textcolor{stringliteral}{"Inwin!"});
   evas\_object\_size\_hint\_weight\_set(o, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(o, 0.0, 0.0);
   elm_box_pack_end(box, o);
   evas\_object\_show(o);

   evas\_object\_smart\_callback\_add(o, \textcolor{stringliteral}{"clicked"}, \_btn\_click\_cb, NULL);

   \textcolor{keywordflow}{if} (!strncmp(elm_config_engine_get(), \textcolor{stringliteral}{"shot"}, 4))
     ecore\_timer\_add(0.1, \_screenshot\_hack\_cb, o);

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

   elm_run();

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