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

\begin{DoxyCodeInclude}
\textcolor{comment}{/*}
\textcolor{comment}{ * gcc -o win\_example win\_example.c `pkg-config --cflags --libs elementary ecore-x`}
\textcolor{comment}{ */}
\textcolor{preprocessor}{#ifdef HAVE\_ELEMENTARY\_X}
\textcolor{preprocessor}{# include <Ecore\_X.h>}
\textcolor{preprocessor}{#endif}

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

\textcolor{keyword}{static} Evas\_Object *win2;

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_btn\_activate\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   elm\_win\_activate(data);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_btn\_lower\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   elm\_win\_lower(data);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_btn\_raise\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   elm\_win\_raise(data);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_btn\_borderless\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   Eina\_Bool flag = elm\_win\_borderless\_get(data);
   elm\_win\_borderless\_set(data, !flag);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_btn\_shaped\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   Eina\_Bool flag = elm\_win\_shaped\_get(data);
   elm\_win\_shaped\_set(data, !flag);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_btn\_alpha\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   Eina\_Bool flag = elm\_win\_alpha\_get(data);
   elm\_win\_alpha\_set(data, !flag);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_btn\_fullscreen\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   Eina\_Bool flag = elm\_win\_fullscreen\_get(data);
   elm\_win\_fullscreen\_set(data, !flag);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_btn\_maximized\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   Eina\_Bool flag = elm\_win\_maximized\_get(data);
   elm\_win\_maximized\_set(data, !flag);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_btn\_iconified\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   Eina\_Bool flag = elm\_win\_iconified\_get(data);
   elm\_win\_iconified\_set(data, !flag);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_btn\_rotation\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   \textcolor{keywordtype}{int} angle = elm\_win\_rotation\_get(data);
   angle = (angle + 90) % 360;
   elm\_win\_rotation\_set(data, angle);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_btn\_rotation\_resize\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   \textcolor{keywordtype}{int} angle = elm\_win\_rotation\_get(data);
   angle = (angle + 90) % 360;
   elm\_win\_rotation\_with\_resize\_set(data, angle);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_btn\_sticky\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   Eina\_Bool flag = elm\_win\_sticky\_get(data);
   elm\_win\_sticky\_set(data, !flag);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_yes\_quit\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   elm_exit();
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_no\_quit\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   evas\_object\_del(data);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_main\_win\_del\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   Evas\_Object *msg, *box, *box2, *btn, *lbl, *sep;

   msg = elm_notify_add(obj);
   elm\_notify\_align\_set(msg, 0.5, 0.5);
   elm\_notify\_allow\_events\_set(msg, EINA\_FALSE);
   evas\_object\_show(msg);

   box = elm_box_add(obj);
   evas\_object\_size\_hint\_weight\_set(box, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(box, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_object\_content\_set(msg, box);
   evas\_object\_show(box);

   lbl = elm_label_add(obj);
   elm\_object\_text\_set(lbl, \textcolor{stringliteral}{"Really want quit?"});
   evas\_object\_size\_hint\_weight\_set(lbl, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(lbl, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_box\_pack\_end(box, lbl);
   evas\_object\_show(lbl);

   sep = elm_separator_add(obj);
   elm\_separator\_horizontal\_set(sep, EINA\_TRUE);
   elm\_box\_pack\_end(box, sep);
   evas\_object\_show(sep);

   box2 = elm_box_add(obj);
   elm\_box\_horizontal\_set(box2, EINA\_TRUE);
   evas\_object\_size\_hint\_weight\_set(box2, EVAS\_HINT\_EXPAND, 0.0);
   evas\_object\_size\_hint\_align\_set(box2, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_box\_pack\_end(box, box2);
   evas\_object\_show(box2);

   btn = elm_button_add(obj);
   elm\_object\_text\_set(btn, \textcolor{stringliteral}{"Yes"});
   elm\_box\_pack\_end(box2, btn);
   evas\_object\_show(btn);

   evas\_object\_smart\_callback\_add(btn, \textcolor{stringliteral}{"clicked"}, \_yes\_quit\_cb, NULL);

   btn = elm_button_add(obj);
   elm\_object\_text\_set(btn, \textcolor{stringliteral}{"No"});
   elm\_box\_pack\_end(box2, btn);
   evas\_object\_show(btn);

   evas\_object\_smart\_callback\_add(btn, \textcolor{stringliteral}{"clicked"}, \_no\_quit\_cb, msg);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_force\_focus\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
\textcolor{preprocessor}{#ifdef HAVE\_ELEMENTARY\_X}
   Ecore\_X\_Window xwin = elm\_win\_xwindow\_get(data);
   ecore\_x\_window\_focus(xwin);
\textcolor{preprocessor}{#endif}
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_win\_focused\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event)
\{
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name = data;
   printf(\textcolor{stringliteral}{"Window focused: %s\(\backslash\)n"}, name);
\}

\textcolor{keyword}{static} Eina\_Bool
key\_down()
\{
   elm\_win\_fullscreen\_set(win2, 0);

   \textcolor{keywordflow}{return} ECORE\_CALLBACK\_PASS\_ON;
\}

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

   elm_app_info_set(elm\_main, \textcolor{stringliteral}{"elementary"}, \textcolor{stringliteral}{"images/logo.png"});

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"win-example"}, \textcolor{stringliteral}{"Elm\_Win Example"});
   elm\_win\_focus\_highlight\_enabled\_set(win, EINA\_TRUE);

   evas\_object\_smart\_callback\_add(win, \textcolor{stringliteral}{"focus,in"}, \_win\_focused\_cb, \textcolor{stringliteral}{"mainwin"});

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

   ecore\_event\_handler\_add(ECORE\_EVENT\_KEY\_DOWN, key\_down, NULL);

   bigbox = elm_box_add(win);
   elm\_box\_horizontal\_set(bigbox, EINA\_TRUE);
   evas\_object\_size\_hint\_weight\_set(bigbox, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm\_win\_resize\_object\_add(win, bigbox);
   evas\_object\_show(bigbox);

   box = elm_box_add(win);
   evas\_object\_size\_hint\_weight\_set(box, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(box, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_box\_pack\_end(bigbox, box);
   evas\_object\_show(box);

   win2 = elm_win_add(NULL, \textcolor{stringliteral}{"sub-win-example"}, ELM\_WIN\_DIALOG\_BASIC);
   elm\_win\_autodel\_set(win2, EINA\_TRUE);
   elm\_win\_title\_set(win2, \textcolor{stringliteral}{"Managed window"});
   evas\_object\_show(win2);

   evas\_object\_smart\_callback\_add(win2, \textcolor{stringliteral}{"focus,in"}, \_win\_focused\_cb, \textcolor{stringliteral}{"managed"});

   o = elm_icon_add(win2);
   sprintf(buf, \textcolor{stringliteral}{"%s/images/logo.png"}, elm_app_data_dir_get());
   elm_image_file_set(o, buf, NULL);
   elm\_image\_resizable\_set(o, EINA\_FALSE, EINA\_FALSE);
   elm\_image\_no\_scale\_set(o, EINA\_TRUE);
   elm\_win\_resize\_object\_add(win2, o);
   evas\_object\_show(o);

   o = elm_label_add(win);
   elm\_object\_text\_set(o, \textcolor{stringliteral}{"<b>Managed Window</b>"});
   elm\_box\_pack\_end(box, o);
   evas\_object\_show(o);

\textcolor{preprocessor}{#define WIN\_ACTION(name) \(\backslash\)}
\textcolor{preprocessor}{   do \{ \(\backslash\)}
\textcolor{preprocessor}{        btn = elm\_button\_add(win); \(\backslash\)}
\textcolor{preprocessor}{        elm\_object\_text\_set(btn, #name); \(\backslash\)}
\textcolor{preprocessor}{        elm\_box\_pack\_end(box, btn); \(\backslash\)}
\textcolor{preprocessor}{        evas\_object\_show(btn); \(\backslash\)}
\textcolor{preprocessor}{        evas\_object\_smart\_callback\_add(btn, "clicked", \_btn\_##name##\_cb, win2); \(\backslash\)}
\textcolor{preprocessor}{   \} while (0)}

   WIN\_ACTION(activate);
   WIN\_ACTION(lower);
   WIN\_ACTION(\textcolor{keyword}{raise});
   WIN\_ACTION(borderless);
   WIN\_ACTION(shaped);
   WIN\_ACTION(alpha);
   WIN\_ACTION(fullscreen);
   WIN\_ACTION(maximized);
   WIN\_ACTION(iconified);
   WIN\_ACTION(rotation);
   WIN\_ACTION(rotation\_resize);
   WIN\_ACTION(sticky);

   box = elm_box_add(win);
   evas\_object\_size\_hint\_weight\_set(box, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(box, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_box\_pack\_end(bigbox, box);
   evas\_object\_show(box);

   win2 = elm_win_util_standard_add(\textcolor{stringliteral}{"sub-win-example2"}, \textcolor{stringliteral}{"Non-managed window"});
   elm\_win\_autodel\_set(win2, EINA\_TRUE);
   elm\_win\_override\_set(win2, EINA\_TRUE);
   evas\_object\_show(win2);

   evas\_object\_smart\_callback\_add(win2, \textcolor{stringliteral}{"focus,in"}, \_win\_focused\_cb,
                                  \textcolor{stringliteral}{"override"});

   bigbox = elm_box_add(win2);
   evas\_object\_size\_hint\_weight\_set(bigbox, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm\_win\_resize\_object\_add(win2, bigbox);
   evas\_object\_show(bigbox);

   o = elm_label_add(win2);
   elm\_object\_text\_set(o, \textcolor{stringliteral}{"This window should have no borders or titlebar.<ps>"}
                       \textcolor{stringliteral}{"It was set in override mode, so the Window Manager<ps>"}
                       \textcolor{stringliteral}{"should ignore everything about it.<ps>"}
                       \textcolor{stringliteral}{"It's up to the program to handle it properly, and some"}
                       \textcolor{stringliteral}{"of the actions performed on it may not have any effect."}
                      );
   elm\_box\_pack\_end(bigbox, o);
   evas\_object\_show(o);

   o = elm_entry_add(win2);
   elm\_object\_text\_set(o, \textcolor{stringliteral}{"See if you can focus me"});
   elm\_entry\_single\_line\_set(o, EINA\_TRUE);
   elm\_entry\_scrollable\_set(o, EINA\_TRUE);
   evas\_object\_size\_hint\_weight\_set(o, EVAS\_HINT\_EXPAND, 0.0);
   evas\_object\_size\_hint\_align\_set(o, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_box\_pack\_end(bigbox, o);
   evas\_object\_show(o);

   o = elm_separator_add(win2);
   elm\_separator\_horizontal\_set(o, EINA\_TRUE);
   elm\_box\_pack\_end(bigbox, o);
   evas\_object\_show(o);

   o = elm_button_add(win2);
   elm\_object\_text\_set(o, \textcolor{stringliteral}{"Focus me"});
   elm\_box\_pack\_end(bigbox, o);
   evas\_object\_show(o);

   evas\_object\_smart\_callback\_add(o, \textcolor{stringliteral}{"clicked"}, \_force\_focus\_cb, win2);

   o = elm_label_add(win);
   elm\_object\_text\_set(o, \textcolor{stringliteral}{"<b>Override Window</b>"});
   elm\_box\_pack\_end(box, o);
   evas\_object\_show(o);

   WIN\_ACTION(activate);
   WIN\_ACTION(lower);
   WIN\_ACTION(\textcolor{keyword}{raise});
   WIN\_ACTION(borderless);
   WIN\_ACTION(shaped);
   WIN\_ACTION(alpha);
   WIN\_ACTION(fullscreen);
   WIN\_ACTION(maximized);
   WIN\_ACTION(iconified);
   WIN\_ACTION(rotation);
   WIN\_ACTION(rotation\_resize);
   WIN\_ACTION(sticky);

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

   elm_run();

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