summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Aguirre <aguirre.nicolas@gmail.com>2015-06-28 15:33:22 +0200
committerNicolas Aguirre <aguirre.nicolas@gmail.com>2015-06-28 15:33:22 +0200
commite4068fc75180f761cf5dd0be094646f448c7218c (patch)
tree2bf185d61c6f7b535ecce0b28625178d50e5934c
parent703693f37d0c01385bfac982dab270441f45cda5 (diff)
Remove edje specific code and use elementary button, table and entry.devs/captainigloo/elm
-rw-r--r--configure.ac6
-rw-r--r--data/Makefile.am20
-rw-r--r--data/equate.edc271
-rw-r--r--data/images/.cvsignore3
-rw-r--r--data/images/Makefile.am14
-rw-r--r--data/images/bg.pngbin1114 -> 0 bytes
-rw-r--r--data/images/brushed_texture.pngbin87845 -> 0 bytes
-rw-r--r--data/images/btn_normal.pngbin589 -> 0 bytes
-rw-r--r--data/images/btn_pressed.pngbin456 -> 0 bytes
-rw-r--r--data/images/entry_disabled.pngbin1590 -> 0 bytes
-rw-r--r--data/images/entry_light_overlay.pngbin3537 -> 0 bytes
-rw-r--r--data/images/metalsphere.pngbin2683 -> 0 bytes
-rw-r--r--data/images/shading.pngbin3177 -> 0 bytes
-rw-r--r--data/images/text_button.pngbin123 -> 0 bytes
-rw-r--r--data/images/text_display.pngbin1302 -> 0 bytes
-rw-r--r--data/text.edc359
-rw-r--r--src/main.c370
17 files changed, 176 insertions, 867 deletions
diff --git a/configure.ac b/configure.ac
index 4999e38..54c8fa5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -29,21 +29,17 @@ PKG_PROG_PKG_CONFIG
29 29
30### Checks for libraries 30### Checks for libraries
31 31
32PKG_CHECK_MODULES([EQUATE], [elementary edje ecore-evas ecore ecore-input evas >= 1.0.0]) 32PKG_CHECK_MODULES([EQUATE], [elementary >= 1.7.0])
33 33
34 34
35### Checks for compiler characteristics 35### Checks for compiler characteristics
36 36
37AC_HEADER_STDC 37AC_HEADER_STDC
38 38
39
40EFL_WITH_BIN([edje], [edje-cc], [edje_cc])
41
42AC_CONFIG_FILES([ 39AC_CONFIG_FILES([
43Makefile 40Makefile
44src/Makefile 41src/Makefile
45data/Makefile 42data/Makefile
46data/images/Makefile
47]) 43])
48 44
49AC_OUTPUT 45AC_OUTPUT
diff --git a/data/Makefile.am b/data/Makefile.am
index a821443..130302b 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,23 +1,6 @@
1 1
2MAINTAINERCLEANFILES = Makefile.in 2MAINTAINERCLEANFILES = Makefile.in
3 3
4SUBDIRS = . images
5
6EDJE_CC = @edje_cc@
7EDJE_FLAGS = -v -id $(top_srcdir)/data/images
8
9EDCS = equate.edc text.edc
10EDJS = $(EDCS:%.edc=%.edj)
11SUFFIXES = .edc .edj
12
13themedir = $(pkgdatadir)/themes
14theme_DATA = $(EDJS)
15
16all: $(EDCS)
17
18.edc.edj:
19 $(EDJE_CC) $(EDJE_FLAGS) $< $@
20
21desktopdir = $(datadir)/applications 4desktopdir = $(datadir)/applications
22desktop_DATA = equate.desktop 5desktop_DATA = equate.desktop
23 6
@@ -25,6 +8,3 @@ icondir = $(datadir)/icons
25icon_DATA = equate.png 8icon_DATA = equate.png
26 9
27EXTRA_DIST = $(EDCS) equate.png equate.desktop 10EXTRA_DIST = $(EDCS) equate.png equate.desktop
28
29clean-local:
30 rm -f $(EDJS)
diff --git a/data/equate.edc b/data/equate.edc
deleted file mode 100644
index 52955ad..0000000
--- a/data/equate.edc
+++ /dev/null
@@ -1,271 +0,0 @@
1
2
3#define BUTTON_TABLE_ITEM(pname, x, y, w, h) \
4item { \
5 type: GROUP; \
6 source: pname; \
7 weight: 0.5 0.5; \
8 align: -1 -1; \
9 position: x y; \
10 span: w h; \
11}
12
13
14#define BUTTON(pname, label, emits) \
15group { name: "button/"pname; \
16 images { \
17 image: "btn_normal.png" COMP; \
18 image: "btn_pressed.png" COMP; \
19 } \
20 parts { \
21 part { name: "button_image"; \
22 mouse_events: 1; \
23 description { state: "default" 0.0; \
24 rel1.offset: 3 3; \
25 rel2.offset: -4 -4; \
26 image { \
27 normal: "btn_normal.png"; \
28 border: 7 7 7 7; \
29 } \
30 \
31 } \
32 description { state: "clicked" 0.0; \
33 inherit: "default" 0.0; \
34 image.normal: "btn_pressed.png"; \
35 image.border: 7 7 7 7; \
36 } \
37 } \
38 \
39 part { \
40 name: "elm.text"; \
41 type: TEXT; \
42 effect: SHADOW; \
43 mouse_events: 0; \
44 scale: 1; \
45 description { state: "default" 0.0; \
46 visible: 1; \
47 rel1.offset: 4 4; \
48 rel2.offset: -5 -5; \
49 color: 255 255 255 240; \
50 color3: 20 20 20 128; \
51 /* color: 172 179 191 255; */ \
52 /* color3: 0 0 0 30; */ \
53 text { \
54 font: "Sans"; \
55 size: 25; \
56 min: 1 1; \
57 align: 0.5 0.5; \
58 text_class: "button"; \
59 text: label; \
60 } \
61 } \
62 } \
63 part { \
64 name: "over1"; \
65 mouse_events: 0; \
66 type: RECT; \
67 description { \
68 state: "default" 0.0; \
69 rel2.relative: 1.0 0.5; \
70 color: 0 0 0 0; \
71 } \
72 description { state: "disabled" 0.0; \
73 inherit: "default" 0.0; \
74 } \
75 } \
76 part { name: "over2"; \
77 mouse_events: 1; \
78 repeat_events: 1; \
79 ignore_flags: ON_HOLD; \
80 type: RECT; \
81 description { \
82 state: "default" 0.0; \
83 color: 0 0 0 0; \
84 } \
85 description { \
86 state: "disabled" 0.0; \
87 inherit: "default" 0.0; \
88 visible: 0; \
89 } \
90 } \
91 part { name: "over3"; \
92 mouse_events: 1; \
93 repeat_events: 1; \
94 type: RECT; \
95 description { state: "default" 0.0; \
96 color: 255 255 255 0; \
97 } \
98 description { state: "clicked" 0.0; \
99 inherit: "default" 0.0; \
100 color: 255 255 255 0; \
101 } \
102 } \
103 \
104 \
105 } \
106 programs { \
107 program { \
108 name: "button_click"; \
109 signal: "mouse,down,1"; \
110 source: "over2"; \
111 action: STATE_SET "clicked" 0.0; \
112 target: "button_image"; \
113 } \
114 \
115 program { \
116 name: "button_unclick"; \
117 signal: "mouse,up,1"; \
118 source: "over3"; \
119 action: STATE_SET "default" 0.0; \
120 target: "button_image"; \
121 } \
122 program { \
123 name: "button_click2"; \
124 signal: "mouse,down,1"; \
125 source: "over3"; \
126 action: STATE_SET "clicked" 0.0; \
127 target: "over3"; \
128 } \
129 program { \
130 name: "button_unclick2"; \
131 signal: "mouse,up,1"; \
132 source: "over3"; \
133 action: STATE_SET "default" 0.0; \
134 transition: DECELERATE 0.5; \
135 target: "over3"; \
136 } \
137 program { \
138 name: "button_unclick3"; \
139 signal: "mouse,clicked,1"; \
140 source: "over2"; \
141 action: SIGNAL_EMIT emits ""; \
142 } \
143 } \
144}
145
146images {
147 image: "bg.png" COMP;
148 image: "shading.png" COMP;
149 image: "brushed_texture.png" COMP;
150 image: "metalsphere.png" COMP;
151 image: "entry_disabled.png" COMP;
152 image: "entry_light_overlay.png" COMP;
153}
154collections {
155
156 BUTTON("add", "+", "OP_ADD");
157 BUTTON("min", "-", "OP_SUB");
158 BUTTON("mul", "*", "OP_MUT");
159 BUTTON("div", "/", "OP_DIV");
160
161 BUTTON("seven", "7", "NUM_7");
162 BUTTON("height", "8", "NUM_8");
163 BUTTON("nine", "9", "NUM_9");
164 BUTTON("clear", "C", "OP_CLR");
165
166 BUTTON("four", "4", "NUM_4");
167 BUTTON("five", "5", "NUM_5");
168 BUTTON("six", "6", "NUM_6");
169 BUTTON("obrak", "(", "OP_OBRAK");
170
171 BUTTON("one", "1", "NUM_1");
172 BUTTON("two", "2", "NUM_2");
173 BUTTON("three", "3", "NUM_3");
174 BUTTON("cbrak", ")", "OP_CBRAK");
175
176 BUTTON("zero", "0", "NUM_0");
177 BUTTON("point", ".", "OP_DEC");
178 BUTTON("equal", "=", "OP_EQU");
179
180 group {
181 name: "Main";
182
183 parts {
184 part {
185 name: "bg";
186 type: RECT;
187 mouse_events: 0;
188 description
189 {
190 state: "default" 0.0;
191 visible: 1;
192 color: 255 255 255 255;
193 }
194 }
195
196 part {
197 name: "EquateAnswer";
198 type: TEXT;
199 mouse_events: 0;
200 description
201 {
202 state: "default" 0.0;
203 visible: 1;
204 rel1 {
205 relative: 0.0 0.0;
206 offset: 2 0;
207 } rel2 {
208 relative: 1.0 0.0;
209 offset: -1 0;
210
211 }
212 fixed: 1 1;
213 align: 0.5 0;
214 color: 0 0 0 255;
215 color3: 192 192 192 255;
216 text
217 {
218 text: "";
219 font: "Sans";
220 size: 30;
221 //fit: 0 0;
222 min: 1 1;
223 align: 1.0 0.5;
224 }
225 }
226 }
227
228 part {
229 name : "table_description";
230 type : TABLE;
231 description {
232 state : "default" 0.0;
233 fixed: 0 1;
234 rel1.to: "EquateAnswer";
235 rel1.relative: 0 1;
236 table {
237 homogeneous: TABLE;
238 padding: 0 0;
239 }
240 }
241 table {
242 items {
243 BUTTON_TABLE_ITEM("button/add", 0, 0, 1, 1);
244 BUTTON_TABLE_ITEM("button/min", 1, 0, 1, 1);
245 BUTTON_TABLE_ITEM("button/mul", 2, 0, 1, 1);
246 BUTTON_TABLE_ITEM("button/div", 3, 0, 1, 1);
247
248 BUTTON_TABLE_ITEM("button/seven", 0, 1, 1, 1);
249 BUTTON_TABLE_ITEM("button/height", 1, 1, 1, 1);
250 BUTTON_TABLE_ITEM("button/nine", 2, 1, 1, 1);
251 BUTTON_TABLE_ITEM("button/clear", 3, 1, 1, 1);
252
253 BUTTON_TABLE_ITEM("button/four", 0, 2, 1, 1);
254 BUTTON_TABLE_ITEM("button/five", 1, 2, 1, 1);
255 BUTTON_TABLE_ITEM("button/six", 2, 2, 1, 1);
256 BUTTON_TABLE_ITEM("button/obrak", 3, 2, 1, 1);
257
258 BUTTON_TABLE_ITEM("button/one", 0, 3, 1, 1);
259 BUTTON_TABLE_ITEM("button/two", 1, 3, 1, 1);
260 BUTTON_TABLE_ITEM("button/three", 2, 3, 1, 1);
261 BUTTON_TABLE_ITEM("button/cbrak", 3, 3, 1, 1);
262
263 BUTTON_TABLE_ITEM("button/zero", 0, 4, 1, 1);
264 BUTTON_TABLE_ITEM("button/point", 1, 4, 1, 1);
265 BUTTON_TABLE_ITEM("button/equal", 2, 4, 2, 1);
266 }
267 }
268 }
269 }
270
271}
diff --git a/data/images/.cvsignore b/data/images/.cvsignore
deleted file mode 100644
index 22a4e72..0000000
--- a/data/images/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
1Makefile
2Makefile.in
3
diff --git a/data/images/Makefile.am b/data/images/Makefile.am
deleted file mode 100644
index ab6db60..0000000
--- a/data/images/Makefile.am
+++ /dev/null
@@ -1,14 +0,0 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4EXTRA_DIST = \
5bg.png \
6brushed_texture.png \
7btn_normal.png \
8btn_pressed.png \
9entry_disabled.png \
10entry_light_overlay.png \
11metalsphere.png \
12shading.png \
13text_button.png \
14text_display.png
diff --git a/data/images/bg.png b/data/images/bg.png
deleted file mode 100644
index 8415d46..0000000
--- a/data/images/bg.png
+++ /dev/null
Binary files differ
diff --git a/data/images/brushed_texture.png b/data/images/brushed_texture.png
deleted file mode 100644
index 0a78068..0000000
--- a/data/images/brushed_texture.png
+++ /dev/null
Binary files differ
diff --git a/data/images/btn_normal.png b/data/images/btn_normal.png
deleted file mode 100644
index 487d22c..0000000
--- a/data/images/btn_normal.png
+++ /dev/null
Binary files differ
diff --git a/data/images/btn_pressed.png b/data/images/btn_pressed.png
deleted file mode 100644
index b1d4285..0000000
--- a/data/images/btn_pressed.png
+++ /dev/null
Binary files differ
diff --git a/data/images/entry_disabled.png b/data/images/entry_disabled.png
deleted file mode 100644
index a078d5c..0000000
--- a/data/images/entry_disabled.png
+++ /dev/null
Binary files differ
diff --git a/data/images/entry_light_overlay.png b/data/images/entry_light_overlay.png
deleted file mode 100644
index 694c3f3..0000000
--- a/data/images/entry_light_overlay.png
+++ /dev/null
Binary files differ
diff --git a/data/images/metalsphere.png b/data/images/metalsphere.png
deleted file mode 100644
index 6f8865e..0000000
--- a/data/images/metalsphere.png
+++ /dev/null
Binary files differ
diff --git a/data/images/shading.png b/data/images/shading.png
deleted file mode 100644
index ba22b29..0000000
--- a/data/images/shading.png
+++ /dev/null
Binary files differ
diff --git a/data/images/text_button.png b/data/images/text_button.png
deleted file mode 100644
index d7084b2..0000000
--- a/data/images/text_button.png
+++ /dev/null
Binary files differ
diff --git a/data/images/text_display.png b/data/images/text_display.png
deleted file mode 100644
index 96b5604..0000000
--- a/data/images/text_display.png
+++ /dev/null
Binary files differ
diff --git a/data/text.edc b/data/text.edc
deleted file mode 100644
index f7a21a1..0000000
--- a/data/text.edc
+++ /dev/null
@@ -1,359 +0,0 @@
1images {
2 image, "text_button.png" LOSSY 95;
3 image, "text_display.png" LOSSY 95;
4}
5collections {
6 group {
7 name, "Main";
8 min, 110 160;
9 max, 110 160;
10 parts {
11 part {
12 name, "bg";
13 type, RECT;
14 mouse_events, 0;
15 description
16 {
17 state, "default" 0.0;
18 visible, 1;
19 rel1 {
20 relative, 0.0 0.0;
21 offset, 0 0;
22 } rel2 {
23 relative, 1.0 1.0;
24 offset, 0 0;
25 }
26 color, 0 0 0 255;
27 }
28 }
29 part {
30 name, "answer_buf_clip";
31 type, RECT;
32 mouse_events, 0;
33 description
34 {
35 state, "default" 0.0;
36 visible, 1;
37 rel1 {
38 relative, 0.0 0.0;
39 offset, 5 5;
40 } rel2 {
41 relative, 1.0 0.0;
42 offset, -5 30;
43 }
44 color, 255 255 255 255;
45 }
46 description
47 {
48 state, "hidden" 0.0;
49 visible, 1;
50 rel1 {
51 relative, 0.0 0.0;
52 offset, 5 5;
53 } rel2 {
54 relative, 1.0 0.0;
55 offset, -5 30;
56 }
57 color, 255 255 255 0;
58 }
59 }
60 part {
61 name, "answer_buf_rect";
62 type, IMAGE;
63 mouse_events, 0;
64 clip_to, "answer_buf_clip";
65 description
66 {
67 state, "default" 0.0;
68 visible, 1;
69 rel1 {
70 relative, 0.0 0.0;
71 offset, 0 0;
72 to, "answer_buf_clip";
73 } rel2 {
74 relative, 1.0 1.0;
75 offset, 0 0;
76 to, "answer_buf_clip";
77 }
78 image
79 {
80 normal, "text_display.png";
81 border, 8 8 8 8;
82 }
83 color, 255 255 255 255;
84 }
85 }
86 part {
87 name, "EquateAnswer";
88 type, TEXT;
89 mouse_events, 0;
90 effect, OUTLINE;
91 clip_to, "answer_buf_clip";
92 description
93 {
94 state, "default" 0.0;
95 visible, 1;
96 rel1 {
97 relative, 0.0 0.0;
98 offset, 5 5;
99 to, "answer_buf_clip";
100 } rel2 {
101 relative, 1.0 1.0;
102 offset, -5 -2;
103 to, "answer_buf_clip";
104 }
105 color, 0 0 0 255;
106 color3, 192 192 192 255;
107 text
108 {
109 text, "";
110 font, "Vera";
111 size, 14;
112 fit, 0 0;
113 align, 1.0 0.5;
114 }
115 }
116 }
117 part {
118 name, "clipped_clear";
119 type, RECT;
120 mouse_events, 0;
121 description {
122 state, "default" 0.0;
123 visible, 1;
124 rel1 {
125 relative, 0.0 1.0;
126 offset, 0 0;
127 to, "answer_buf_clip";
128 } rel2 {
129 relative, 0.0 1.0;
130 offset, 24 24;
131 to, "answer_buf_clip";
132 }
133 color, 255 255 255 255;
134 }
135 description {
136 state, "clicked" 0.0;
137 visible, 1;
138 rel1 {
139 relative, 0.0 1.0;
140 offset, 0 0;
141 to, "answer_buf_clip";
142 } rel2 {
143 relative, 0.0 1.0;
144 offset, 24 24;
145 to, "answer_buf_clip";
146 }
147 color, 255 255 255 192;
148 }
149 }
150 part {
151 name, "clear_button_image";
152 type, IMAGE;
153 mouse_events, 1;
154 clip_to, "clipped_clear";
155 description
156 {
157 state, "default" 0.0;
158 visible, 1;
159 rel1 {
160 relative, 0.0 1.0;
161 offset, 0 0;
162 to, "answer_buf_clip";
163 } rel2 {
164 relative, 0.0 1.0;
165 offset, 24 24;
166 to, "answer_buf_clip";
167 }
168 image
169 {
170 normal, "text_button.png";
171 }
172 }
173 }
174 part {
175 name, "clear_button_text";
176 type, TEXT;
177 mouse_events, 1;
178 effect, SOFT_SHADOW;
179 description
180 {
181 state, "default" 0.0;
182 visible, 1;
183 rel1 {
184 relative, 0.0 0.0;
185 offset, 0 0;
186 to, "clear_button_image";
187 } rel2 {
188 relative, 1.0 1.0;
189 offset, 0 0;
190 to, "clear_button_image";
191 }
192 color, 255 255 255 255;
193 color3, 96 96 96 255;
194 text
195 {
196 text, "c";
197 font, "Vera";
198 size, 14;
199 fit, 0 0;
200 align, 0.5 0.5;
201 }
202 }
203 description {
204 state, "clicked" 0.0;
205 visible, 1;
206 rel1 {
207 relative, 0.0 0.0;
208 offset, 1 1;
209 to, "clear_button_image";
210 } rel2 {
211 relative, 1.0 1.0;
212 offset, 1 1;
213 to, "clear_button_image";
214 }
215 color, 255 255 255 255;
216 color3, 96 96 96 255;
217 text {
218 text, "c";
219 font, "Vera";
220 size, 14;
221 fit, 0 0;
222 align, 0.5 0.5;
223 }
224 }
225 }
226#define TEXT_ON(txtrel, txtpname, txtstr) \
227 part { name, txtpname; type, TEXT; mouse_events, 0; \
228 effect, SOFT_SHADOW; description { \
229 state, "default" 0.0; visible, 1; \
230 rel1 { relative, 0.0 0.0; offset, 0 0; to, txtrel; } \
231 rel2 { relative, 1.0 1.0; offset, 0 0; to, txtrel; } \
232 color, 255 255 255 255; color3, 96 96 96 255; \
233 text { text, txtstr; font, "Vera"; size, 14; \
234 fit, 0 0; align, 0.5 0.5; } } \
235 description { \
236 state, "clicked" 0.0; visible, 1; \
237 rel1 { relative, 0.0 0.0; offset, 1 1; to, txtrel; } \
238 rel2 { relative, 1.0 1.0; offset, 1 1; to, txtrel; } \
239 color, 255 255 255 255; color3, 96 96 96 255; \
240 text { text, txtstr; font, "Vera"; size, 14; \
241 fit, 0 0; align, 0.5 0.5; } } }
242
243#define RIGHT_OF(rel, clipname, pname, ptxtname, txt, bw, bh) \
244 part { name, clipname; type, RECT; mouse_events, 0; \
245 description { state, "default" 0.0; visible, 1; \
246 rel1 { relative, 1.0 0.0; offset, 0 0; to, rel; } \
247 rel2 { relative, 1.0 0.0; offset, bw bh; to, rel; } \
248 color, 255 255 255 255; } \
249 description { state, "clicked" 0.0; visible, 1; \
250 rel1 { relative, 1.0 0.0; offset, 0 0; to, rel; } \
251 rel2 { relative, 1.0 0.0; offset, bw bh; to, rel; } \
252 color, 255 255 255 192; } } \
253 part { name, pname; type, IMAGE; mouse_events, 1; \
254 clip_to, clipname ; \
255 description { state, "default" 0.0; visible, 1; \
256 rel1 { relative, 1.0 0.0; offset, 0 0; to, rel; } \
257 rel2 { relative, 1.0 0.0; offset, bw bh; to, rel; } \
258 image { normal, "text_button.png"; border, 0 0 0 6; } \
259 } } \
260 TEXT_ON(pname, ptxtname, txt)
261#define SOUTH_OF(rel, clipname, pname, ptxtname, txt, bw, bh) \
262 part { name, clipname; type, RECT; mouse_events, 0; \
263 description { state, "default" 0.0; visible, 1; \
264 rel1 { relative, 0.0 1.0; offset, 0 0; to, rel; } \
265 rel2 { relative, 0.0 1.0; offset, bw bh; to, rel; } \
266 color, 255 255 255 255; } \
267 description { state, "clicked" 0.0; visible, 1; \
268 rel1 { relative, 0.0 1.0; offset, 0 0; to, rel; } \
269 rel2 { relative, 0.0 1.0; offset, bw bh; to, rel; } \
270 color, 255 255 255 192; } } \
271 part { name, pname; type, IMAGE; mouse_events, 1; \
272 clip_to, clipname ; \
273 description { state, "default" 0.0; visible, 1; \
274 rel1 { relative, 0.0 1.0; offset, 0 0; to, rel; } \
275 rel2 { relative, 0.0 1.0; offset, bw bh; to, rel; } \
276 image { normal, "text_button.png"; border, 0 2 0 0; } \
277 } } \
278 TEXT_ON(pname, ptxtname, txt)
279
280 RIGHT_OF("clear_button_image", "clipped_divide", "divide_button_image",
281 "divide_button_text", "/", 24, 24)
282 RIGHT_OF("divide_button_image", "clipped_times", "times_button_image",
283 "times_button_text", "*", 24, 24);
284 RIGHT_OF("times_button_image", "clipped_minus", "minus_button_image",
285 "minus_button_text", "-", 24, 24);
286 SOUTH_OF("clear_button_image", "clipped_seven", "seven_button_image",
287 "seven_button_text", "7", 24, 24);
288 RIGHT_OF("seven_button_image", "clipped_eight", "eight_button_image",
289 "eight_button_text", "8", 24, 24);
290 RIGHT_OF("eight_button_image", "clipped_nine", "nine_button_image",
291 "nine_button_text", "9", 24, 24);
292 RIGHT_OF("nine_button_image", "clipped_plus", "plus_button_image",
293 "plus_button_text", "+", 24, 48);
294 SOUTH_OF("seven_button_image", "clipped_four", "four_button_image",
295 "four_button_text", "4", 24, 24);
296 RIGHT_OF("four_button_image", "clipped_five", "five_button_image",
297 "five_button_text", "5", 24, 24);
298 RIGHT_OF("five_button_image", "clipped_six", "six_button_image",
299 "six_button_text", "6", 24, 24);
300 SOUTH_OF("four_button_image", "clipped_one", "one_button_image",
301 "one_button_text", "1", 24, 24);
302 RIGHT_OF("one_button_image", "clipped_two", "two_button_image",
303 "two_button_text", "2", 24, 24);
304 RIGHT_OF("two_button_image", "clipped_three", "three_button_image",
305 "three_button_text", "3", 24, 24);
306 SOUTH_OF("three_button_image", "clipped_decimal", "decimal_button_image",
307 "decimal_button_text", ".", 24, 24);
308 SOUTH_OF("one_button_image", "clipped_zero", "zero_button_image",
309 "zero_button_text", "0", 48, 24);
310 RIGHT_OF("three_button_image", "clipped_equals", "equals_button_image",
311 "equals_button_text", "=", 24, 48);
312 }
313 programs {
314#define BUTTON_CB(pname, bclip, bname, emits, cbin, cbout) \
315 program { name, pname; signal, "mouse,clicked,1"; source, bname; \
316 action, SIGNAL_EMIT emits ""; } \
317 program { name, cbout; signal, "mouse,down,1"; source, bname; \
318 action, STATE_SET "clicked" 0.0; target, bclip; \
319 transition, LINEAR 0.1; } \
320 program { name, cbin; signal, "mouse,up,1"; source, bname; \
321 action, STATE_SET "default" 0.0; target, bclip; \
322 transition, DECELERATE 0.2; }
323 BUTTON_CB("clear_clicked", "clear_button_text", \
324 "clear_button_image", "OP_CLR", "clearin", "clearout")
325 BUTTON_CB("divide_clicked", "divide_button_text", \
326 "divide_button_image", "OP_DIV", "dividein", "divideout")
327 BUTTON_CB("multiply_clicked", "times_button_text", \
328 "times_button_image", "OP_MUT", "multiplyin", "multiplyout")
329 BUTTON_CB("addition_clicked", "plus_button_text", \
330 "plus_button_image", "OP_ADD", "additionin", "additionout")
331 BUTTON_CB("subtraction_clicked", "minus_button_text", \
332 "minus_button_image", "OP_SUB", "minusin", "minusout")
333 BUTTON_CB("equals_clicked", "equals_button_text", \
334 "equals_button_image", "OP_EQU", "clippedin", "clippedout")
335 BUTTON_CB("decimal_clicked", "decimal_button_text", \
336 "decimal_button_image", "OP_DEC", "decimalin", "decimalout")
337 BUTTON_CB("zero_clicked", "zero_button_text", \
338 "zero_button_image", "NUM_0", "zeroin", "zerout")
339 BUTTON_CB("one_clicked", "one_button_text", \
340 "one_button_image", "NUM_1", "onein", "oneout")
341 BUTTON_CB("two_clicked", "two_button_text", \
342 "two_button_image", "NUM_2", "twoin", "twoout")
343 BUTTON_CB("three_clicked", "three_button_text", \
344 "three_button_image", "NUM_3", "threein", "threeout")
345 BUTTON_CB("four_clicked", "four_button_text", \
346 "four_button_image", "NUM_4", "fourin", "fourout")
347 BUTTON_CB("five_clicked", "five_button_text", \
348 "five_button_image", "NUM_5", "fivein", "fiveout")
349 BUTTON_CB("six_clicked", "six_button_text", \
350 "six_button_image", "NUM_6", "sixin", "sixout")
351 BUTTON_CB("seven_clicked", "seven_button_text", \
352 "seven_button_image", "NUM_7", "sevenin", "sevenout")
353 BUTTON_CB("eight_clicked", "eight_button_text", \
354 "eight_button_image", "NUM_8", "eightin", "eightout")
355 BUTTON_CB("nine_clicked", "nine_button_text", \
356 "nine_button_image", "NUM_9", "ninein", "nineout")
357 }
358 }
359}
diff --git a/src/main.c b/src/main.c
index d5ef992..b1d5d81 100644
--- a/src/main.c
+++ b/src/main.c
@@ -5,8 +5,7 @@
5#include "calc.h" 5#include "calc.h"
6 6
7static Evas_Object *win; 7static Evas_Object *win;
8static Evas_Object *ly; 8static Evas_Object *entry;
9
10 9
11static const struct 10static const struct
12{ 11{
@@ -56,188 +55,106 @@ static const struct
56 55
57 56
58static void 57static void
59_signal_cb(void *data, Evas_Object * o, const char *emission, const 58_calc_do(int op)
60 char *source)
61{ 59{
62 int val = 0; 60 double result;
63 61 char buf[BUFLEN];
64 if (data)
65 {
66 double result;
67 char buf[BUFLEN];
68 62
69 val = (int) data; 63 switch (op)
70 switch (val) 64 {
71 { 65 case EQ_EXIT:
72 case EQ_EXIT: 66 elm_exit();
73 elm_exit(); 67 break;
74 break; 68 case OP_CLR:
75 case OP_CLR: 69 equate_clear();
76 equate_clear(); 70 break;
77 break; 71 case OP_DIV:
78 case OP_DIV: 72 equate_append("/");
79 equate_append("/"); 73 break;
80 break; 74 case OP_MUT:
81 case OP_MUT: 75 equate_append("*");
82 equate_append("*"); 76 break;
83 break; 77 case OP_ADD:
84 case OP_ADD: 78 equate_append("+");
85 equate_append("+"); 79 break;
86 break; 80 case OP_SUB:
87 case OP_SUB: 81 equate_append("-");
88 equate_append("-"); 82 break;
89 break; 83 case OP_EQU:
90 case OP_EQU: 84 snprintf(buf, BUFLEN, "<title><align=right>%.10g</align></title>", equate_eval());
91 snprintf(buf, BUFLEN, "%.10g", equate_eval()); 85 elm_object_text_set(entry, buf);
92 edje_object_part_text_set(o, "EquateAnswer", buf); 86 return;
93 return; 87 break;
94 break; 88 case OP_DEC:
95 case OP_DEC: 89 equate_append(".");
96 equate_append("."); 90 break;
97 break; 91 case OP_OBRAK:
98 case OP_OBRAK: 92 equate_append("(");
99 equate_append("("); 93 break;
100 break; 94 case OP_CBRAK:
101 case OP_CBRAK: 95 equate_append(")");
102 equate_append(")"); 96 break;
103 break; 97 case OP_SIN:
104 case OP_SIN: 98 equate_append("sin");
105 equate_append("sin"); 99 break;
106 break; 100 case OP_COS:
107 case OP_COS: 101 equate_append("cos");
108 equate_append("cos"); 102 break;
109 break; 103 case OP_TAN:
110 case OP_TAN: 104 equate_append("tan");
111 equate_append("tan"); 105 break;
112 break; 106 case OP_ROOT:
113 case OP_ROOT: 107 equate_append("sqrt");
114 equate_append("sqrt"); 108 break;
115 break; 109 case OP_POW:
116 case OP_POW: 110 equate_append("^");
117 equate_append("^"); 111 break;
118 break; 112 case OP_LOG:
119 case OP_LOG: 113 equate_append("log");
120 equate_append("log"); 114 break;
121 break; 115 case OP_LN:
122 case OP_LN: 116 equate_append("ln");
123 equate_append("ln"); 117 break;
124 break; 118 case OP_EXP:
125 case OP_EXP: 119 equate_append("exp");
126 equate_append("exp"); 120 break;
127 break; 121 case NUM_0:
128 case NUM_0: 122 equate_append("0");
129 equate_append("0"); 123 break;
130 break; 124 case NUM_1:
131 case NUM_1: 125 equate_append("1");
132 equate_append("1"); 126 break;
133 break; 127 case NUM_2:
134 case NUM_2: 128 equate_append("2");
135 equate_append("2"); 129 break;
136 break; 130 case NUM_3:
137 case NUM_3: 131 equate_append("3");
138 equate_append("3"); 132 break;
139 break; 133 case NUM_4:
140 case NUM_4: 134 equate_append("4");
141 equate_append("4"); 135 break;
142 break; 136 case NUM_5:
143 case NUM_5: 137 equate_append("5");
144 equate_append("5"); 138 break;
145 break; 139 case NUM_6:
146 case NUM_6: 140 equate_append("6");
147 equate_append("6"); 141 break;
148 break; 142 case NUM_7:
149 case NUM_7: 143 equate_append("7");
150 equate_append("7"); 144 break;
151 break; 145 case NUM_8:
152 case NUM_8: 146 equate_append("8");
153 equate_append("8"); 147 break;
154 break; 148 case NUM_9:
155 case NUM_9: 149 equate_append("9");
156 equate_append("9"); 150 break;
157 break; 151 default:
158 default: 152 E(1, "Unknown operator %d", op);
159 E(1, "Unknown edje signal operator %d", val); 153 break;
160 break; 154 /* etc */
161 /* etc */ 155 }
162 } 156 snprintf(buf, BUFLEN, "<title><align=right>%s</align></title>", equate_string_get());
163 edje_object_part_text_set(o, "EquateAnswer", equate_string_get()); 157 elm_object_text_set(entry, buf);
164
165 }
166}
167
168
169static void
170_edje_callbacks_define(Evas_Object * o)
171{
172 /** Equate Application Callbacks **/
173 /* EQ_EXIT - Quit Equate */
174 edje_object_signal_callback_add(o, "EQ_EXIT", "*", _signal_cb,
175 (void *) EQ_EXIT);
176 /** Equate Operation Callbacks **/
177 /* OP_CLR - Clear Display */
178 edje_object_signal_callback_add(o, "OP_CLR", "*", _signal_cb,
179 (void *) OP_CLR);
180 /* OP_DIV - Division Operator */
181 edje_object_signal_callback_add(o, "OP_DIV", "*", _signal_cb,
182 (void *) OP_DIV);
183 /* OP_MUT - Mutplication Operator */
184 edje_object_signal_callback_add(o, "OP_MUT", "*", _signal_cb,
185 (void *) OP_MUT);
186 /* OP_ADD - Addition Operator */
187 edje_object_signal_callback_add(o, "OP_ADD", "*", _signal_cb,
188 (void *) OP_ADD);
189 /* OP_SUB - Subtraction Operator */
190 edje_object_signal_callback_add(o, "OP_SUB", "*", _signal_cb,
191 (void *) OP_SUB);
192 /* OP_EQU - Equals Operator */
193 edje_object_signal_callback_add(o, "OP_EQU", "*", _signal_cb,
194 (void *) OP_EQU);
195 /* OP_DEC - Decimal Operator */
196 edje_object_signal_callback_add(o, "OP_DEC", "*", _signal_cb,
197 (void *) OP_DEC);
198 /* OP_SIN - Sin of x in degrees */
199 edje_object_signal_callback_add(o, "OP_SIN", "*", _signal_cb,
200 (void *) OP_SIN);
201 /* OP_COS - Cos of x in degree */
202 edje_object_signal_callback_add(o, "OP_COS", "*", _signal_cb,
203 (void *) OP_COS);
204 /* OP_TAN - Tan of x in degrees */
205 edje_object_signal_callback_add(o, "OP_TAN", "*", _signal_cb,
206 (void *) OP_TAN);
207 /* OP_ROOT - The square root of x */
208 edje_object_signal_callback_add(o, "OP_ROOT", "*", _signal_cb,
209 (void *) OP_ROOT);
210 /* OP_POW - Raise x to the y power */
211 edje_object_signal_callback_add(o, "OP_POW", "*", _signal_cb,
212 (void *) OP_POW);
213 /* OP_LOG - Logarithm */
214 edje_object_signal_callback_add(o, "OP_LOG", "*", _signal_cb,
215 (void *) OP_LOG);
216 /* OP_LN - the natural logarithm */
217 edje_object_signal_callback_add(o, "OP_LN", "*", _signal_cb, (void *) OP_LN);
218 /* OP_EXP - e to the x */
219 edje_object_signal_callback_add(o, "OP_EXP", "*", _signal_cb,
220 (void *) OP_EXP);
221 /* OP_OBRAK - open bracket */
222 edje_object_signal_callback_add(o, "OP_OBRAK", "*", _signal_cb,
223 (void *) OP_OBRAK);
224 /* OP_CBRAK - close bracket */
225 edje_object_signal_callback_add(o, "OP_CBRAK", "*", _signal_cb,
226 (void *) OP_CBRAK);
227
228 /** Equate Number Callbacks **/
229 edje_object_signal_callback_add(o, "NUM_0", "*", _signal_cb, (void *) NUM_0);
230 edje_object_signal_callback_add(o, "NUM_1", "*", _signal_cb, (void *) NUM_1);
231 edje_object_signal_callback_add(o, "NUM_2", "*", _signal_cb, (void *) NUM_2);
232 edje_object_signal_callback_add(o, "NUM_3", "*", _signal_cb, (void *) NUM_3);
233 edje_object_signal_callback_add(o, "NUM_4", "*", _signal_cb, (void *) NUM_4);
234 edje_object_signal_callback_add(o, "NUM_5", "*", _signal_cb, (void *) NUM_5);
235 edje_object_signal_callback_add(o, "NUM_6", "*", _signal_cb, (void *) NUM_6);
236 edje_object_signal_callback_add(o, "NUM_7", "*", _signal_cb, (void *) NUM_7);
237 edje_object_signal_callback_add(o, "NUM_8", "*", _signal_cb, (void *) NUM_8);
238 edje_object_signal_callback_add(o, "NUM_9", "*", _signal_cb, (void *) NUM_9);
239 /* NUM_PI - 3.14159 */
240 edje_object_signal_callback_add(o, "NUM_PI", "*", _signal_cb, (void *) NUM_PI);
241} 158}
242 159
243static Eina_Bool 160static Eina_Bool
@@ -250,7 +167,7 @@ _key_down_cb(void *data, int type, void *event)
250 { 167 {
251 if (!strcmp(_keymap[i].keyname, ev->key)) 168 if (!strcmp(_keymap[i].keyname, ev->key))
252 { 169 {
253 _signal_cb((void*)_keymap[i].op, elm_layout_edje_get(ly), NULL, NULL); 170 _calc_do(_keymap[i].op);
254 } 171 }
255 } 172 }
256 return EINA_TRUE; 173 return EINA_TRUE;
@@ -258,29 +175,92 @@ _key_down_cb(void *data, int type, void *event)
258} 175}
259 176
260static void 177static void
178_bt_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
179{
180 int val = (int) data;
181 _calc_do(val);
182}
183
184#define BUTTON_ADD(label, x, y, w, h, op) \
185 bt = elm_button_add(tb); \
186 elm_object_text_set(bt, label); \
187 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); \
188 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); \
189 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)op); \
190 elm_table_pack(tb, bt, x, y, w, h); \
191 evas_object_show(bt); \
192
193
194static Evas_Object *
195_gui_standard(Evas_Object *parent)
196{
197 Evas_Object *tb, *bt;
198 tb = elm_table_add(win);
199 elm_table_homogeneous_set(tb, EINA_TRUE);
200 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
201 evas_object_show(tb);
202
203 BUTTON_ADD("C", 0, 0, 1, 1, OP_CLR);
204 BUTTON_ADD("(", 1, 0, 1, 1, OP_CBRAK);
205 BUTTON_ADD(")", 2, 0, 1, 1, OP_OBRAK);
206 BUTTON_ADD("/", 3, 0, 1, 1, OP_DIV);
207
208 BUTTON_ADD("7", 0, 1, 1, 1, NUM_7);
209 BUTTON_ADD("8", 1, 1, 1, 1, NUM_8);
210 BUTTON_ADD("9", 2, 1, 1, 1, NUM_9);
211 BUTTON_ADD("x", 3, 1, 1, 1, OP_MUT);
212
213 BUTTON_ADD("4", 0, 2, 1, 1, NUM_4);
214 BUTTON_ADD("5", 1, 2, 1, 1, NUM_5);
215 BUTTON_ADD("6", 2, 2, 1, 1, NUM_6);
216 BUTTON_ADD("-", 3, 2, 1, 1, OP_SUB);
217
218 BUTTON_ADD("1", 0, 3, 1, 1, NUM_1);
219 BUTTON_ADD("2", 1, 3, 1, 1, NUM_2);
220 BUTTON_ADD("3", 2, 3, 1, 1, NUM_3);
221 BUTTON_ADD("+", 3, 3, 1, 1, OP_ADD);
222
223 BUTTON_ADD("0", 0, 4, 2, 1, NUM_0);
224 BUTTON_ADD(".", 2, 4, 1, 1, OP_DEC);
225 BUTTON_ADD("=", 3, 4, 1, 1, OP_EQU);
226
227 return tb;
228
229}
230
231static void
261_create_gui(void) 232_create_gui(void)
262{ 233{
263 char buf[1024]; 234 char buf[1024];
235 Evas_Object *tb, *bx;
264 236
265 win = elm_win_add(NULL, "equate", ELM_WIN_BASIC); 237 win = elm_win_util_standard_add("equate", "Equate");
266 elm_win_title_set(win, "Equate");
267 elm_win_autodel_set(win, EINA_TRUE); 238 elm_win_autodel_set(win, EINA_TRUE);
268 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
269 239
270 ly = elm_layout_add(win); 240 bx = elm_box_add(win);
271 snprintf(buf, sizeof(buf), "%s/themes/equate.edj", elm_app_data_dir_get()); 241 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
272 elm_layout_file_set(ly, buf, "Main"); 242 elm_win_resize_object_add(win, bx);
273 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 243 evas_object_show(bx);
274 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL); 244
275 elm_win_resize_object_add(win, ly); 245 entry = elm_entry_add(win);
276 evas_object_show(ly); 246 elm_entry_scrollable_set(entry, EINA_TRUE);
247 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0.0);
248 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, 0.5);
249 elm_scroller_policy_set(entry, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
250 elm_object_text_set(entry, "<align=right><title>0</title></align>");
251 elm_entry_single_line_set(entry, EINA_TRUE);
252 elm_box_pack_end(bx, entry);
253 evas_object_show(entry);
254
255 tb = _gui_standard(win);
256 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
257 evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
258 elm_box_pack_end(bx, tb);
277 259
278 ecore_event_handler_add (ECORE_EVENT_KEY_DOWN, _key_down_cb, NULL); 260 ecore_event_handler_add (ECORE_EVENT_KEY_DOWN, _key_down_cb, NULL);
279 261
280 evas_object_show(win); 262 evas_object_show(win);
281 evas_object_resize(win, 240, 320); 263 evas_object_resize(win, 240, 320);
282
283 _edje_callbacks_define(elm_layout_edje_get(ly));
284} 264}
285 265
286EAPI_MAIN int 266EAPI_MAIN int