\hypertarget{external_elm_button_8edc-example}{}\doxysection{external\+\_\+elm\+\_\+button.\+edc}
This example create some elementary buttons and do some actions on user click.


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{collections \{}
\DoxyCodeLine{   /* those 2 groups are used as custom icons for the buttons */}
\DoxyCodeLine{   group \{ name: "icon\_green";}
\DoxyCodeLine{      parts \{}
\DoxyCodeLine{         part \{ name: "icon\_green";}
\DoxyCodeLine{            type: RECT;}
\DoxyCodeLine{            description \{ state: "default" 0.0;}
\DoxyCodeLine{               color: 0 255 0 255;}
\DoxyCodeLine{               aspect: 1 1;}
\DoxyCodeLine{               aspect\_preference: VERTICAL;}
\DoxyCodeLine{            \}}
\DoxyCodeLine{         \}}
\DoxyCodeLine{      \}}
\DoxyCodeLine{   \}}
\DoxyCodeLine{   group \{ name: "icon\_red";}
\DoxyCodeLine{      parts \{}
\DoxyCodeLine{         part \{ name: "icon\_red";}
\DoxyCodeLine{            type: RECT;}
\DoxyCodeLine{            description \{ state: "default" 0.0;}
\DoxyCodeLine{               color: 255 0 0 255;}
\DoxyCodeLine{               aspect: 1 1;}
\DoxyCodeLine{               aspect\_preference: VERTICAL;}
\DoxyCodeLine{            \}}
\DoxyCodeLine{         \}}
\DoxyCodeLine{      \}}
\DoxyCodeLine{   \}}
\DoxyCodeLine{}
\DoxyCodeLine{   group \{ name: "main";}
\DoxyCodeLine{      /* set a min window size */}
\DoxyCodeLine{      min: 250 250;}
\DoxyCodeLine{      }
\DoxyCodeLine{      /* tell edje that we are going to use elementary external parts */}
\DoxyCodeLine{      externals \{}
\DoxyCodeLine{         external: "elm";}
\DoxyCodeLine{      \}}
\DoxyCodeLine{      }
\DoxyCodeLine{      /* define global variables */}
\DoxyCodeLine{      script \{}
\DoxyCodeLine{         public counter, toggle1, toggle2, toggle3, toggle4;}
\DoxyCodeLine{      \}}
\DoxyCodeLine{      }
\DoxyCodeLine{      parts \{}
\DoxyCodeLine{         part \{ name: "bg";}
\DoxyCodeLine{            type: RECT;}
\DoxyCodeLine{            description \{ state: "default" 0.0;}
\DoxyCodeLine{               color: 255 255 255 255;}
\DoxyCodeLine{            \}}
\DoxyCodeLine{         \}}
\DoxyCodeLine{}
\DoxyCodeLine{         part \{ name: "title";}
\DoxyCodeLine{            type: TEXT;}
\DoxyCodeLine{            effect: SOFT\_SHADOW;}
\DoxyCodeLine{            description \{ state: "default" 0.0;}
\DoxyCodeLine{               color: 255 255 255 255;}
\DoxyCodeLine{               color3: 70 70 70 70;}
\DoxyCodeLine{               text \{}
\DoxyCodeLine{                  text: "Elementary buttons";}
\DoxyCodeLine{                  font: "Sans";}
\DoxyCodeLine{                  size: 16;}
\DoxyCodeLine{                  align: 0.5 0.0;}
\DoxyCodeLine{               \}}
\DoxyCodeLine{            \}}
\DoxyCodeLine{         \}}
\DoxyCodeLine{}
\DoxyCodeLine{         /* bottom label used for reporting */}
\DoxyCodeLine{         part \{ name: "label";}
\DoxyCodeLine{            type: TEXT;}
\DoxyCodeLine{            description \{ state: "default" 0.0;}
\DoxyCodeLine{               color: 0 0 0 255;}
\DoxyCodeLine{               text \{}
\DoxyCodeLine{                  text: "try every buttons";}
\DoxyCodeLine{                  font: "Sans";}
\DoxyCodeLine{                  size: 12;}
\DoxyCodeLine{                  align: 0.5 1.0;}
\DoxyCodeLine{               \}}
\DoxyCodeLine{            \}}
\DoxyCodeLine{         \}}
\DoxyCodeLine{}
\DoxyCodeLine{         /* EXTERNAL elementary button with a label */}
\DoxyCodeLine{         part \{ name: "bt1";}
\DoxyCodeLine{            type: EXTERNAL;}
\DoxyCodeLine{            source: "elm/button";}
\DoxyCodeLine{            description \{ state: "default" 0;}
\DoxyCodeLine{               rel1 \{}
\DoxyCodeLine{                  offset: 5 35;}
\DoxyCodeLine{               \}}
\DoxyCodeLine{               rel2 \{}
\DoxyCodeLine{                  relative: 1.0 0.0;}
\DoxyCodeLine{                  offset: -\/6 60;}
\DoxyCodeLine{               \}}
\DoxyCodeLine{               params \{}
\DoxyCodeLine{                  string: "label" "Label only";}
\DoxyCodeLine{               \}}
\DoxyCodeLine{            \}}
\DoxyCodeLine{         \}}
\DoxyCodeLine{}
\DoxyCodeLine{         /* EXTERNAL elementary button with label + standard icon */}
\DoxyCodeLine{         part \{ name: "bt2";}
\DoxyCodeLine{            type: EXTERNAL;}
\DoxyCodeLine{            source: "elm/button";}
\DoxyCodeLine{            description \{ state: "default" 0;}
\DoxyCodeLine{               rel1 \{}
\DoxyCodeLine{                  to: "bt1";}
\DoxyCodeLine{                  relative: 0.0 1.0;}
\DoxyCodeLine{                  offset: 0 5;}
\DoxyCodeLine{               \}}
\DoxyCodeLine{               rel2 \{}
\DoxyCodeLine{                  to: "bt1";}
\DoxyCodeLine{                  relative: 1.0 2.0;}
\DoxyCodeLine{                  offset: -\/1 5;}
\DoxyCodeLine{               \}}
\DoxyCodeLine{               params \{}
\DoxyCodeLine{                  string: "label" "Label + standard icon";}
\DoxyCodeLine{                  string: "icon" "home";}
\DoxyCodeLine{               \}}
\DoxyCodeLine{            \}}
\DoxyCodeLine{         \}}
\DoxyCodeLine{}
\DoxyCodeLine{         /* EXTERNAL elementary button with a label and a custom icon */}
\DoxyCodeLine{         part \{ name: "bt3";}
\DoxyCodeLine{            type: EXTERNAL;}
\DoxyCodeLine{            source: "elm/button";}
\DoxyCodeLine{            description \{ state: "default" 0;}
\DoxyCodeLine{               rel1 \{}
\DoxyCodeLine{                  to: "bt2";}
\DoxyCodeLine{                  relative: 0.0 1.0;}
\DoxyCodeLine{                  offset: 0 5;}
\DoxyCodeLine{               \}}
\DoxyCodeLine{               rel2 \{}
\DoxyCodeLine{                  to: "bt2";}
\DoxyCodeLine{                  relative: 1.0 2.0;}
\DoxyCodeLine{                  offset: -\/1 5;}
\DoxyCodeLine{               \}}
\DoxyCodeLine{               params \{}
\DoxyCodeLine{                  string: "label" "Label + custom icon";}
\DoxyCodeLine{                  string: "icon" "icon\_green";}
\DoxyCodeLine{               \}}
\DoxyCodeLine{            \}}
\DoxyCodeLine{         \}}
\DoxyCodeLine{}
\DoxyCodeLine{         /* EXTERNAL elementary button with just a standard icon */}
\DoxyCodeLine{         part \{ name: "bt4";}
\DoxyCodeLine{            type: EXTERNAL;}
\DoxyCodeLine{            source: "elm/button";}
\DoxyCodeLine{            description \{ state: "default" 0;}
\DoxyCodeLine{               rel1 \{}
\DoxyCodeLine{                  to: "bt3";}
\DoxyCodeLine{                  relative: 0.0 1.0;}
\DoxyCodeLine{                  offset: 0 5;}
\DoxyCodeLine{               \}}
\DoxyCodeLine{               rel2 \{}
\DoxyCodeLine{                  to: "bt3";}
\DoxyCodeLine{                  relative: 0.5 2.0;}
\DoxyCodeLine{                  offset: -\/6 5;}
\DoxyCodeLine{               \}}
\DoxyCodeLine{               params \{}
\DoxyCodeLine{                  string: "icon" "folder";}
\DoxyCodeLine{               \}}
\DoxyCodeLine{            \}}
\DoxyCodeLine{         \}}
\DoxyCodeLine{}
\DoxyCodeLine{         /* EXTERNAL elementary button with just a custom icon */}
\DoxyCodeLine{         part \{ name: "bt5";}
\DoxyCodeLine{            type: EXTERNAL;}
\DoxyCodeLine{            source: "elm/button";}
\DoxyCodeLine{            description \{ state: "default" 0;}
\DoxyCodeLine{               rel1 \{}
\DoxyCodeLine{                  to: "bt3";}
\DoxyCodeLine{                  relative: 0.5 1.0;}
\DoxyCodeLine{                  offset: 5 5;}
\DoxyCodeLine{               \}}
\DoxyCodeLine{               rel2 \{}
\DoxyCodeLine{                  to: "bt3";}
\DoxyCodeLine{                  relative: 1.0 2.0;}
\DoxyCodeLine{                  offset: 0 5;}
\DoxyCodeLine{               \}}
\DoxyCodeLine{               params \{}
\DoxyCodeLine{                  string: "icon" "icon\_green";}
\DoxyCodeLine{               \}}
\DoxyCodeLine{            \}}
\DoxyCodeLine{         \}}
\DoxyCodeLine{      \}}
\DoxyCodeLine{}
\DoxyCodeLine{      programs \{}
\DoxyCodeLine{         /* bt1 clicked, change it's label and count the clicks */}
\DoxyCodeLine{         program \{ name: "bt1\_click";}
\DoxyCodeLine{            signal: "clicked";}
\DoxyCodeLine{            source: "bt1";}
\DoxyCodeLine{            script \{}
\DoxyCodeLine{               new buf[32];}
\DoxyCodeLine{               /* increment the global counter*/}
\DoxyCodeLine{               set\_int(counter, get\_int(counter) + 1);}
\DoxyCodeLine{               /* set the button label */}
\DoxyCodeLine{               snprintf(buf, sizeof(buf), "Clicked \%d times", get\_int(counter));}
\DoxyCodeLine{               external\_param\_set\_str(PART:"bt1", "label", buf);}
\DoxyCodeLine{               /* set the bottom label */}
\DoxyCodeLine{               set\_text(PART:"label", "button 1 clicked: set label");}
\DoxyCodeLine{            \}}
\DoxyCodeLine{         \}}
\DoxyCodeLine{}
\DoxyCodeLine{         /* bt2 clicked, toggle it's standard icon */}
\DoxyCodeLine{         program \{ name: "bt2\_click";}
\DoxyCodeLine{            signal: "clicked";}
\DoxyCodeLine{            source: "bt2";}
\DoxyCodeLine{            script \{}
\DoxyCodeLine{               if (get\_int(toggle1) == 0) \{}
\DoxyCodeLine{                  external\_param\_set\_str(PART:"bt2", "icon", "home");}
\DoxyCodeLine{                  set\_int(toggle1, 1);}
\DoxyCodeLine{               \}}
\DoxyCodeLine{               else \{}
\DoxyCodeLine{                  external\_param\_set\_str(PART:"bt2", "icon", "folder");}
\DoxyCodeLine{                  set\_int(toggle1, 0);}
\DoxyCodeLine{               \}}
\DoxyCodeLine{               set\_text(PART:"label", "button 2 clicked: toggle icon");}
\DoxyCodeLine{            \}}
\DoxyCodeLine{         \}}
\DoxyCodeLine{}
\DoxyCodeLine{         /* bt3 clicked, toggle it's custom icon */}
\DoxyCodeLine{         program \{ name: "bt3\_click";}
\DoxyCodeLine{            signal: "clicked";}
\DoxyCodeLine{            source: "bt3";}
\DoxyCodeLine{            script \{}
\DoxyCodeLine{               if (get\_int(toggle2) == 0) \{}
\DoxyCodeLine{                  external\_param\_set\_str(PART:"bt3", "icon", "icon\_red");}
\DoxyCodeLine{                  set\_int(toggle2, 1);}
\DoxyCodeLine{               \}}
\DoxyCodeLine{               else \{}
\DoxyCodeLine{                  external\_param\_set\_str(PART:"bt3", "icon", "icon\_green");}
\DoxyCodeLine{                  set\_int(toggle2, 0);}
\DoxyCodeLine{               \}}
\DoxyCodeLine{               set\_text(PART:"label", "button 3 clicked: toggle icon");}
\DoxyCodeLine{            \}}
\DoxyCodeLine{         \}}
\DoxyCodeLine{}
\DoxyCodeLine{         /* bt4 clicked, toggle it's icon */}
\DoxyCodeLine{         program \{ name: "bt4\_click";}
\DoxyCodeLine{            signal: "clicked";}
\DoxyCodeLine{            source: "bt4";}
\DoxyCodeLine{            script \{}
\DoxyCodeLine{               if (get\_int(toggle3) == 0) \{}
\DoxyCodeLine{                  external\_param\_set\_str(PART:"bt4", "icon", "home");}
\DoxyCodeLine{                  set\_int(toggle3, 1);}
\DoxyCodeLine{               \}}
\DoxyCodeLine{               else \{}
\DoxyCodeLine{                  external\_param\_set\_str(PART:"bt4", "icon", "folder");}
\DoxyCodeLine{                  set\_int(toggle3, 0);}
\DoxyCodeLine{               \}}
\DoxyCodeLine{               set\_text(PART:"label", "button 4 clicked: toggle icon");}
\DoxyCodeLine{            \}}
\DoxyCodeLine{         \}}
\DoxyCodeLine{}
\DoxyCodeLine{         /* bt5 clicked, toggle it's icon */}
\DoxyCodeLine{         program \{ name: "bt5\_click";}
\DoxyCodeLine{            signal: "clicked";}
\DoxyCodeLine{            source: "bt5";}
\DoxyCodeLine{            script \{}
\DoxyCodeLine{               if (get\_int(toggle4) == 0) \{}
\DoxyCodeLine{                  external\_param\_set\_str(PART:"bt5", "icon", "icon\_red");}
\DoxyCodeLine{                  set\_int(toggle4, 1);}
\DoxyCodeLine{               \}}
\DoxyCodeLine{               else \{}
\DoxyCodeLine{                  external\_param\_set\_str(PART:"bt5", "icon", "icon\_green");}
\DoxyCodeLine{                  set\_int(toggle4, 0);}
\DoxyCodeLine{               \}}
\DoxyCodeLine{               set\_text(PART:"label", "button 5 clicked: toggle icon");}
\DoxyCodeLine{            \}}
\DoxyCodeLine{         \}}
\DoxyCodeLine{      \}}
\DoxyCodeLine{   \}}
\DoxyCodeLine{\}}
\end{DoxyCodeInclude}
 