\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}
1 collections \{
2    /* those 2 groups are used as custom icons for the buttons */
3    group \{ name: "icon\_green";
4       parts \{
5          part \{ name: "icon\_green";
6             type: RECT;
7             description \{ state: "default" 0.0;
8                color: 0 255 0 255;
9                aspect: 1 1;
10                aspect\_preference: VERTICAL;
11             \}
12          \}
13       \}
14    \}
15    group \{ name: "icon\_red";
16       parts \{
17          part \{ name: "icon\_red";
18             type: RECT;
19             description \{ state: "default" 0.0;
20                color: 255 0 0 255;
21                aspect: 1 1;
22                aspect\_preference: VERTICAL;
23             \}
24          \}
25       \}
26    \}
27 
28    group \{ name: "main";
29       /* set a min window size */
30       min: 250 250;
31       
32       /* tell edje that we are going to use elementary external parts */
33       externals \{
34          external: "elm";
35       \}
36       
37       /* define global variables */
38       script \{
39          public counter, toggle1, toggle2, toggle3, toggle4;
40       \}
41       
42       parts \{
43          part \{ name: "bg";
44             type: RECT;
45             description \{ state: "default" 0.0;
46                color: 255 255 255 255;
47             \}
48          \}
49 
50          part \{ name: "title";
51             type: TEXT;
52             effect: SOFT\_SHADOW;
53             description \{ state: "default" 0.0;
54                color: 255 255 255 255;
55                color3: 70 70 70 70;
56                text \{
57                   text: "Elementary buttons";
58                   font: "Sans";
59                   size: 16;
60                   align: 0.5 0.0;
61                \}
62             \}
63          \}
64 
65          /* bottom label used for reporting */
66          part \{ name: "label";
67             type: TEXT;
68             description \{ state: "default" 0.0;
69                color: 0 0 0 255;
70                text \{
71                   text: "try every buttons";
72                   font: "Sans";
73                   size: 12;
74                   align: 0.5 1.0;
75                \}
76             \}
77          \}
78 
79          /* EXTERNAL elementary button with a label */
80          part \{ name: "bt1";
81             type: EXTERNAL;
82             source: "elm/button";
83             description \{ state: "default" 0;
84                rel1 \{
85                   offset: 5 35;
86                \}
87                rel2 \{
88                   relative: 1.0 0.0;
89                   offset: -6 60;
90                \}
91                params \{
92                   string: "label" "Label only";
93                \}
94             \}
95          \}
96 
97          /* EXTERNAL elementary button with label + standard icon */
98          part \{ name: "bt2";
99             type: EXTERNAL;
100             source: "elm/button";
101             description \{ state: "default" 0;
102                rel1 \{
103                   to: "bt1";
104                   relative: 0.0 1.0;
105                   offset: 0 5;
106                \}
107                rel2 \{
108                   to: "bt1";
109                   relative: 1.0 2.0;
110                   offset: -1 5;
111                \}
112                params \{
113                   string: "label" "Label + standard icon";
114                   string: "icon" "home";
115                \}
116             \}
117          \}
118 
119          /* EXTERNAL elementary button with a label and a custom icon */
120          part \{ name: "bt3";
121             type: EXTERNAL;
122             source: "elm/button";
123             description \{ state: "default" 0;
124                rel1 \{
125                   to: "bt2";
126                   relative: 0.0 1.0;
127                   offset: 0 5;
128                \}
129                rel2 \{
130                   to: "bt2";
131                   relative: 1.0 2.0;
132                   offset: -1 5;
133                \}
134                params \{
135                   string: "label" "Label + custom icon";
136                   string: "icon" "icon\_green";
137                \}
138             \}
139          \}
140 
141          /* EXTERNAL elementary button with just a standard icon */
142          part \{ name: "bt4";
143             type: EXTERNAL;
144             source: "elm/button";
145             description \{ state: "default" 0;
146                rel1 \{
147                   to: "bt3";
148                   relative: 0.0 1.0;
149                   offset: 0 5;
150                \}
151                rel2 \{
152                   to: "bt3";
153                   relative: 0.5 2.0;
154                   offset: -6 5;
155                \}
156                params \{
157                   string: "icon" "folder";
158                \}
159             \}
160          \}
161 
162          /* EXTERNAL elementary button with just a custom icon */
163          part \{ name: "bt5";
164             type: EXTERNAL;
165             source: "elm/button";
166             description \{ state: "default" 0;
167                rel1 \{
168                   to: "bt3";
169                   relative: 0.5 1.0;
170                   offset: 5 5;
171                \}
172                rel2 \{
173                   to: "bt3";
174                   relative: 1.0 2.0;
175                   offset: 0 5;
176                \}
177                params \{
178                   string: "icon" "icon\_green";
179                \}
180             \}
181          \}
182       \}
183 
184       programs \{
185          /* bt1 clicked, change it's label and count the clicks */
186          program \{ name: "bt1\_click";
187             signal: "clicked";
188             source: "bt1";
189             script \{
190                new buf[32];
191                /* increment the global counter*/
192                set\_int(counter, get\_int(counter) + 1);
193                /* set the button label */
194                snprintf(buf, sizeof(buf), "Clicked %d times", get\_int(counter));
195                external\_param\_set\_str(PART:"bt1", "label", buf);
196                /* set the bottom label */
197                set\_text(PART:"label", "button 1 clicked: set label");
198             \}
199          \}
200 
201          /* bt2 clicked, toggle it's standard icon */
202          program \{ name: "bt2\_click";
203             signal: "clicked";
204             source: "bt2";
205             script \{
206                if (get\_int(toggle1) == 0) \{
207                   external\_param\_set\_str(PART:"bt2", "icon", "home");
208                   set\_int(toggle1, 1);
209                \}
210                else \{
211                   external\_param\_set\_str(PART:"bt2", "icon", "folder");
212                   set\_int(toggle1, 0);
213                \}
214                set\_text(PART:"label", "button 2 clicked: toggle icon");
215             \}
216          \}
217 
218          /* bt3 clicked, toggle it's custom icon */
219          program \{ name: "bt3\_click";
220             signal: "clicked";
221             source: "bt3";
222             script \{
223                if (get\_int(toggle2) == 0) \{
224                   external\_param\_set\_str(PART:"bt3", "icon", "icon\_red");
225                   set\_int(toggle2, 1);
226                \}
227                else \{
228                   external\_param\_set\_str(PART:"bt3", "icon", "icon\_green");
229                   set\_int(toggle2, 0);
230                \}
231                set\_text(PART:"label", "button 3 clicked: toggle icon");
232             \}
233          \}
234 
235          /* bt4 clicked, toggle it's icon */
236          program \{ name: "bt4\_click";
237             signal: "clicked";
238             source: "bt4";
239             script \{
240                if (get\_int(toggle3) == 0) \{
241                   external\_param\_set\_str(PART:"bt4", "icon", "home");
242                   set\_int(toggle3, 1);
243                \}
244                else \{
245                   external\_param\_set\_str(PART:"bt4", "icon", "folder");
246                   set\_int(toggle3, 0);
247                \}
248                set\_text(PART:"label", "button 4 clicked: toggle icon");
249             \}
250          \}
251 
252          /* bt5 clicked, toggle it's icon */
253          program \{ name: "bt5\_click";
254             signal: "clicked";
255             source: "bt5";
256             script \{
257                if (get\_int(toggle4) == 0) \{
258                   external\_param\_set\_str(PART:"bt5", "icon", "icon\_red");
259                   set\_int(toggle4, 1);
260                \}
261                else \{
262                   external\_param\_set\_str(PART:"bt5", "icon", "icon\_green");
263                   set\_int(toggle4, 0);
264                \}
265                set\_text(PART:"label", "button 5 clicked: toggle icon");
266             \}
267          \}
268       \}
269    \}
270 \}
\end{DoxyCodeInclude}
 