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


\begin{DoxyCodeInclude}
collections \{
   \textcolor{comment}{/* those 2 groups are used as custom icons for the buttons */}
   group \{ name: \textcolor{stringliteral}{"icon\_green"};
      parts \{
         part \{ name: \textcolor{stringliteral}{"icon\_green"};
            type: RECT;
            description \{ state: \textcolor{stringliteral}{"default"} 0.0;
               color: 0 255 0 255;
               aspect: 1 1;
               aspect\_preference: VERTICAL;
            \}
         \}
      \}
   \}
   group \{ name: \textcolor{stringliteral}{"icon\_red"};
      parts \{
         part \{ name: \textcolor{stringliteral}{"icon\_red"};
            type: RECT;
            description \{ state: \textcolor{stringliteral}{"default"} 0.0;
               color: 255 0 0 255;
               aspect: 1 1;
               aspect\_preference: VERTICAL;
            \}
         \}
      \}
   \}

   group \{ name: \textcolor{stringliteral}{"main"};
      \textcolor{comment}{/* set a min window size */}
      min: 250 250;
      
      \textcolor{comment}{/* tell edje that we are going to use elementary external parts */}
      externals \{
         external: \textcolor{stringliteral}{"elm"};
      \}
      
      \textcolor{comment}{/* define global variables */}
      script \{
         \textcolor{keyword}{public} counter, toggle1, toggle2, toggle3, toggle4;
      \}
      
      parts \{
         part \{ name: \textcolor{stringliteral}{"bg"};
            type: RECT;
            description \{ state: \textcolor{stringliteral}{"default"} 0.0;
               color: 255 255 255 255;
            \}
         \}

         part \{ name: \textcolor{stringliteral}{"title"};
            type: TEXT;
            effect: SOFT\_SHADOW;
            description \{ state: \textcolor{stringliteral}{"default"} 0.0;
               color: 255 255 255 255;
               color3: 70 70 70 70;
               text \{
                  text: \textcolor{stringliteral}{"Elementary buttons"};
                  font: \textcolor{stringliteral}{"Sans"};
                  size: 16;
                  align: 0.5 0.0;
               \}
            \}
         \}

         \textcolor{comment}{/* bottom label used for reporting */}
         part \{ name: \textcolor{stringliteral}{"label"};
            type: TEXT;
            description \{ state: \textcolor{stringliteral}{"default"} 0.0;
               color: 0 0 0 255;
               text \{
                  text: \textcolor{stringliteral}{"try every buttons"};
                  font: \textcolor{stringliteral}{"Sans"};
                  size: 12;
                  align: 0.5 1.0;
               \}
            \}
         \}

         \textcolor{comment}{/* EXTERNAL elementary button with a label */}
         part \{ name: \textcolor{stringliteral}{"bt1"};
            type: EXTERNAL;
            source: \textcolor{stringliteral}{"elm/button"};
            description \{ state: \textcolor{stringliteral}{"default"} 0;
               rel1 \{
                  offset: 5 35;
               \}
               rel2 \{
                  relative: 1.0 0.0;
                  offset: -6 60;
               \}
               params \{
                  \textcolor{keywordtype}{string}: \textcolor{stringliteral}{"label"} \textcolor{stringliteral}{"Label only"};
               \}
            \}
         \}

         \textcolor{comment}{/* EXTERNAL elementary button with label + standard icon */}
         part \{ name: \textcolor{stringliteral}{"bt2"};
            type: EXTERNAL;
            source: \textcolor{stringliteral}{"elm/button"};
            description \{ state: \textcolor{stringliteral}{"default"} 0;
               rel1 \{
                  to: \textcolor{stringliteral}{"bt1"};
                  relative: 0.0 1.0;
                  offset: 0 5;
               \}
               rel2 \{
                  to: \textcolor{stringliteral}{"bt1"};
                  relative: 1.0 2.0;
                  offset: -1 5;
               \}
               params \{
                  \textcolor{keywordtype}{string}: \textcolor{stringliteral}{"label"} \textcolor{stringliteral}{"Label + standard icon"};
                  \textcolor{keywordtype}{string}: \textcolor{stringliteral}{"icon"} \textcolor{stringliteral}{"home"};
               \}
            \}
         \}

         \textcolor{comment}{/* EXTERNAL elementary button with a label and a custom icon */}
         part \{ name: \textcolor{stringliteral}{"bt3"};
            type: EXTERNAL;
            source: \textcolor{stringliteral}{"elm/button"};
            description \{ state: \textcolor{stringliteral}{"default"} 0;
               rel1 \{
                  to: \textcolor{stringliteral}{"bt2"};
                  relative: 0.0 1.0;
                  offset: 0 5;
               \}
               rel2 \{
                  to: \textcolor{stringliteral}{"bt2"};
                  relative: 1.0 2.0;
                  offset: -1 5;
               \}
               params \{
                  \textcolor{keywordtype}{string}: \textcolor{stringliteral}{"label"} \textcolor{stringliteral}{"Label + custom icon"};
                  \textcolor{keywordtype}{string}: \textcolor{stringliteral}{"icon"} \textcolor{stringliteral}{"icon\_green"};
               \}
            \}
         \}

         \textcolor{comment}{/* EXTERNAL elementary button with just a standard icon */}
         part \{ name: \textcolor{stringliteral}{"bt4"};
            type: EXTERNAL;
            source: \textcolor{stringliteral}{"elm/button"};
            description \{ state: \textcolor{stringliteral}{"default"} 0;
               rel1 \{
                  to: \textcolor{stringliteral}{"bt3"};
                  relative: 0.0 1.0;
                  offset: 0 5;
               \}
               rel2 \{
                  to: \textcolor{stringliteral}{"bt3"};
                  relative: 0.5 2.0;
                  offset: -6 5;
               \}
               params \{
                  \textcolor{keywordtype}{string}: \textcolor{stringliteral}{"icon"} \textcolor{stringliteral}{"folder"};
               \}
            \}
         \}

         \textcolor{comment}{/* EXTERNAL elementary button with just a custom icon */}
         part \{ name: \textcolor{stringliteral}{"bt5"};
            type: EXTERNAL;
            source: \textcolor{stringliteral}{"elm/button"};
            description \{ state: \textcolor{stringliteral}{"default"} 0;
               rel1 \{
                  to: \textcolor{stringliteral}{"bt3"};
                  relative: 0.5 1.0;
                  offset: 5 5;
               \}
               rel2 \{
                  to: \textcolor{stringliteral}{"bt3"};
                  relative: 1.0 2.0;
                  offset: 0 5;
               \}
               params \{
                  \textcolor{keywordtype}{string}: \textcolor{stringliteral}{"icon"} \textcolor{stringliteral}{"icon\_green"};
               \}
            \}
         \}
      \}

      programs \{
         \textcolor{comment}{/* bt1 clicked, change it's label and count the clicks */}
         program \{ name: \textcolor{stringliteral}{"bt1\_click"};
            signal: \textcolor{stringliteral}{"clicked"};
            source: \textcolor{stringliteral}{"bt1"};
            script \{
               \textcolor{keyword}{new} buf[32];
               \textcolor{comment}{/* increment the global counter*/}
               set\_int(counter, get\_int(counter) + 1);
               \textcolor{comment}{/* set the button label */}
               snprintf(buf, \textcolor{keyword}{sizeof}(buf), \textcolor{stringliteral}{"Clicked %d times"}, get\_int(counter));
               external\_param\_set\_str(PART:\textcolor{stringliteral}{"bt1"}, \textcolor{stringliteral}{"label"}, buf);
               \textcolor{comment}{/* set the bottom label */}
               set\_text(PART:\textcolor{stringliteral}{"label"}, \textcolor{stringliteral}{"button 1 clicked: set label"});
            \}
         \}

         \textcolor{comment}{/* bt2 clicked, toggle it's standard icon */}
         program \{ name: \textcolor{stringliteral}{"bt2\_click"};
            signal: \textcolor{stringliteral}{"clicked"};
            source: \textcolor{stringliteral}{"bt2"};
            script \{
               \textcolor{keywordflow}{if} (get\_int(toggle1) == 0) \{
                  external\_param\_set\_str(PART:\textcolor{stringliteral}{"bt2"}, \textcolor{stringliteral}{"icon"}, \textcolor{stringliteral}{"home"});
                  set\_int(toggle1, 1);
               \}
               \textcolor{keywordflow}{else} \{
                  external\_param\_set\_str(PART:\textcolor{stringliteral}{"bt2"}, \textcolor{stringliteral}{"icon"}, \textcolor{stringliteral}{"folder"});
                  set\_int(toggle1, 0);
               \}
               set\_text(PART:\textcolor{stringliteral}{"label"}, \textcolor{stringliteral}{"button 2 clicked: toggle icon"});
            \}
         \}

         \textcolor{comment}{/* bt3 clicked, toggle it's custom icon */}
         program \{ name: \textcolor{stringliteral}{"bt3\_click"};
            signal: \textcolor{stringliteral}{"clicked"};
            source: \textcolor{stringliteral}{"bt3"};
            script \{
               \textcolor{keywordflow}{if} (get\_int(toggle2) == 0) \{
                  external\_param\_set\_str(PART:\textcolor{stringliteral}{"bt3"}, \textcolor{stringliteral}{"icon"}, \textcolor{stringliteral}{"icon\_red"});
                  set\_int(toggle2, 1);
               \}
               \textcolor{keywordflow}{else} \{
                  external\_param\_set\_str(PART:\textcolor{stringliteral}{"bt3"}, \textcolor{stringliteral}{"icon"}, \textcolor{stringliteral}{"icon\_green"});
                  set\_int(toggle2, 0);
               \}
               set\_text(PART:\textcolor{stringliteral}{"label"}, \textcolor{stringliteral}{"button 3 clicked: toggle icon"});
            \}
         \}

         \textcolor{comment}{/* bt4 clicked, toggle it's icon */}
         program \{ name: \textcolor{stringliteral}{"bt4\_click"};
            signal: \textcolor{stringliteral}{"clicked"};
            source: \textcolor{stringliteral}{"bt4"};
            script \{
               \textcolor{keywordflow}{if} (get\_int(toggle3) == 0) \{
                  external\_param\_set\_str(PART:\textcolor{stringliteral}{"bt4"}, \textcolor{stringliteral}{"icon"}, \textcolor{stringliteral}{"home"});
                  set\_int(toggle3, 1);
               \}
               \textcolor{keywordflow}{else} \{
                  external\_param\_set\_str(PART:\textcolor{stringliteral}{"bt4"}, \textcolor{stringliteral}{"icon"}, \textcolor{stringliteral}{"folder"});
                  set\_int(toggle3, 0);
               \}
               set\_text(PART:\textcolor{stringliteral}{"label"}, \textcolor{stringliteral}{"button 4 clicked: toggle icon"});
            \}
         \}

         \textcolor{comment}{/* bt5 clicked, toggle it's icon */}
         program \{ name: \textcolor{stringliteral}{"bt5\_click"};
            signal: \textcolor{stringliteral}{"clicked"};
            source: \textcolor{stringliteral}{"bt5"};
            script \{
               \textcolor{keywordflow}{if} (get\_int(toggle4) == 0) \{
                  external\_param\_set\_str(PART:\textcolor{stringliteral}{"bt5"}, \textcolor{stringliteral}{"icon"}, \textcolor{stringliteral}{"icon\_red"});
                  set\_int(toggle4, 1);
               \}
               \textcolor{keywordflow}{else} \{
                  external\_param\_set\_str(PART:\textcolor{stringliteral}{"bt5"}, \textcolor{stringliteral}{"icon"}, \textcolor{stringliteral}{"icon\_green"});
                  set\_int(toggle4, 0);
               \}
               set\_text(PART:\textcolor{stringliteral}{"label"}, \textcolor{stringliteral}{"button 5 clicked: toggle icon"});
            \}
         \}
      \}
   \}
\}
\end{DoxyCodeInclude}
 