summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Aguirre <aguirre.nicolas@gmail.com>2011-10-06 05:54:34 +0000
committerNicolas Aguirre <aguirre.nicolas@gmail.com>2011-10-06 05:54:34 +0000
commit7b462f7c571b5909ad2fd0ab941bd17c7bb8e0d8 (patch)
treeaa9507736d52a115893877a0c666b902642cf7e0
parent83ed76b8771dd069f4c69b01b5f82218ed2e5aad (diff)
PROTO/equate: Cleanup code, and add bracket support.
SVN revision: 63874
-rw-r--r--data/Makefile.am8
-rw-r--r--data/equate.desktop11
-rw-r--r--data/equate.edc24
-rw-r--r--data/equate.pngbin0 -> 23817 bytes
-rw-r--r--src/Equate.h72
-rw-r--r--src/Makefile.am8
-rw-r--r--src/calc.h1
-rw-r--r--src/calc_parse.c1
-rw-r--r--src/edje.c299
-rw-r--r--src/gui.c43
-rw-r--r--src/gui.h12
-rw-r--r--src/main.c234
12 files changed, 292 insertions, 421 deletions
diff --git a/data/Makefile.am b/data/Makefile.am
index 93fffbd..a821443 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -18,7 +18,13 @@ all: $(EDCS)
18.edc.edj: 18.edc.edj:
19 $(EDJE_CC) $(EDJE_FLAGS) $< $@ 19 $(EDJE_CC) $(EDJE_FLAGS) $< $@
20 20
21EXTRA_DIST = $(EDCS) 21desktopdir = $(datadir)/applications
22desktop_DATA = equate.desktop
23
24icondir = $(datadir)/icons
25icon_DATA = equate.png
26
27EXTRA_DIST = $(EDCS) equate.png equate.desktop
22 28
23clean-local: 29clean-local:
24 rm -f $(EDJS) 30 rm -f $(EDJS)
diff --git a/data/equate.desktop b/data/equate.desktop
new file mode 100644
index 0000000..1115a94
--- /dev/null
+++ b/data/equate.desktop
@@ -0,0 +1,11 @@
1[Desktop Entry]
2Type=Application
3Name=Equate
4GenericName=Calculator
5Comment=EFL Calculator
6Icon=equate
7TryExec=equate
8Exec=equate
9Terminal=false
10Categories=X-ENLIGHTENMENT;Utility;
11StartupWMClass=equate
diff --git a/data/equate.edc b/data/equate.edc
index 3be7973..52955ad 100644
--- a/data/equate.edc
+++ b/data/equate.edc
@@ -52,7 +52,7 @@ group { name: "button/"pname; \
52 /* color3: 0 0 0 30; */ \ 52 /* color3: 0 0 0 30; */ \
53 text { \ 53 text { \
54 font: "Sans"; \ 54 font: "Sans"; \
55 size: 20; \ 55 size: 25; \
56 min: 1 1; \ 56 min: 1 1; \
57 align: 0.5 0.5; \ 57 align: 0.5 0.5; \
58 text_class: "button"; \ 58 text_class: "button"; \
@@ -166,20 +166,20 @@ collections {
166 BUTTON("four", "4", "NUM_4"); 166 BUTTON("four", "4", "NUM_4");
167 BUTTON("five", "5", "NUM_5"); 167 BUTTON("five", "5", "NUM_5");
168 BUTTON("six", "6", "NUM_6"); 168 BUTTON("six", "6", "NUM_6");
169 //BUTTON("nine", "9", "OP_DIV"); 169 BUTTON("obrak", "(", "OP_OBRAK");
170
170 BUTTON("one", "1", "NUM_1"); 171 BUTTON("one", "1", "NUM_1");
171 BUTTON("two", "2", "NUM_2"); 172 BUTTON("two", "2", "NUM_2");
172 BUTTON("three", "3", "NUM_3"); 173 BUTTON("three", "3", "NUM_3");
173 BUTTON("equal", "=", "OP_EQU"); 174 BUTTON("cbrak", ")", "OP_CBRAK");
174 175
175 BUTTON("zero", "0", "NUM_0"); 176 BUTTON("zero", "0", "NUM_0");
176 BUTTON("point", ".", "OP_DEC"); 177 BUTTON("point", ".", "OP_DEC");
177 178 BUTTON("equal", "=", "OP_EQU");
178 179
179 group { 180 group {
180 name: "Main"; 181 name: "Main";
181 min: 200 296; 182
182 max: 200 296;
183 parts { 183 parts {
184 part { 184 part {
185 name: "bg"; 185 name: "bg";
@@ -217,7 +217,7 @@ collections {
217 { 217 {
218 text: ""; 218 text: "";
219 font: "Sans"; 219 font: "Sans";
220 size: 25; 220 size: 30;
221 //fit: 0 0; 221 //fit: 0 0;
222 min: 1 1; 222 min: 1 1;
223 align: 1.0 0.5; 223 align: 1.0 0.5;
@@ -230,7 +230,7 @@ collections {
230 type : TABLE; 230 type : TABLE;
231 description { 231 description {
232 state : "default" 0.0; 232 state : "default" 0.0;
233 fixed: 1 1; 233 fixed: 0 1;
234 rel1.to: "EquateAnswer"; 234 rel1.to: "EquateAnswer";
235 rel1.relative: 0 1; 235 rel1.relative: 0 1;
236 table { 236 table {
@@ -253,14 +253,16 @@ collections {
253 BUTTON_TABLE_ITEM("button/four", 0, 2, 1, 1); 253 BUTTON_TABLE_ITEM("button/four", 0, 2, 1, 1);
254 BUTTON_TABLE_ITEM("button/five", 1, 2, 1, 1); 254 BUTTON_TABLE_ITEM("button/five", 1, 2, 1, 1);
255 BUTTON_TABLE_ITEM("button/six", 2, 2, 1, 1); 255 BUTTON_TABLE_ITEM("button/six", 2, 2, 1, 1);
256 BUTTON_TABLE_ITEM("button/equal", 3, 2, 1, 3); 256 BUTTON_TABLE_ITEM("button/obrak", 3, 2, 1, 1);
257 257
258 BUTTON_TABLE_ITEM("button/one", 0, 3, 1, 1); 258 BUTTON_TABLE_ITEM("button/one", 0, 3, 1, 1);
259 BUTTON_TABLE_ITEM("button/two", 1, 3, 1, 1); 259 BUTTON_TABLE_ITEM("button/two", 1, 3, 1, 1);
260 BUTTON_TABLE_ITEM("button/three", 2, 3, 1, 1); 260 BUTTON_TABLE_ITEM("button/three", 2, 3, 1, 1);
261 BUTTON_TABLE_ITEM("button/cbrak", 3, 3, 1, 1);
261 262
262 BUTTON_TABLE_ITEM("button/zero", 0, 4, 2, 1); 263 BUTTON_TABLE_ITEM("button/zero", 0, 4, 1, 1);
263 BUTTON_TABLE_ITEM("button/point", 2, 4, 1, 1); 264 BUTTON_TABLE_ITEM("button/point", 1, 4, 1, 1);
265 BUTTON_TABLE_ITEM("button/equal", 2, 4, 2, 1);
264 } 266 }
265 } 267 }
266 } 268 }
diff --git a/data/equate.png b/data/equate.png
new file mode 100644
index 0000000..32022cf
--- /dev/null
+++ b/data/equate.png
Binary files differ
diff --git a/src/Equate.h b/src/Equate.h
index 16751ce..66cb856 100644
--- a/src/Equate.h
+++ b/src/Equate.h
@@ -7,50 +7,42 @@
7 fprintf(stderr,fmt, args); \ 7 fprintf(stderr,fmt, args); \
8 } while(0) 8 } while(0)
9 9
10#include "calc.h"
11 10
12#include <Elementary.h> 11#include <Elementary.h>
13#include <stdlib.h>
14#include <sys/types.h>
15#include <sys/stat.h>
16#include <unistd.h>
17#include <limits.h>
18#include <stdio.h>
19#include <string.h>
20
21 12
22#include "config.h" 13#include "config.h"
14#include "calc.h"
23 15
24#define BUFLEN 100 16#define BUFLEN 100
25 17
26/* structures */ 18#define EQ_EXIT 1
27typedef struct 19#define OP_CLR 2
28{ 20#define OP_DIV 3
29 Ecore_Evas *ee; 21#define OP_MUT 4
30 Evas_Object *edje; 22#define OP_ADD 5
31} Gui; 23#define OP_SUB 6
32 24#define OP_EQU 7
33typedef enum 25#define OP_DEC 8
34{ 26#define OP_SIN 9
35 DEFAULT, 27#define OP_COS 10
36 BASIC, 28#define OP_TAN 11
37 SCI, 29#define OP_ROOT 12
38 EDJE 30#define OP_POW 13
39} Mode; 31#define OP_LOG 14
40 32#define OP_LN 15
41typedef struct 33#define OP_EXP 16
42{ 34#define OP_OBRAK 17
43 Mode mode; 35#define OP_CBRAK 18
44 char *theme; 36
45} Conf; 37#define NUM_0 20
46 38#define NUM_1 21
47typedef struct 39#define NUM_2 22
48{ 40#define NUM_3 23
49 Gui gui; 41#define NUM_4 24
50 Conf conf; 42#define NUM_5 25
51} Equate; 43#define NUM_6 26
52 44#define NUM_7 27
53void equate_init(Equate * equate); 45#define NUM_8 28
54void equate_quit(); 46#define NUM_9 29
55 47#define NUM_PI 30
56#include "gui.h" 48
diff --git a/src/Makefile.am b/src/Makefile.am
index 59b6204..e982af9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,19 +5,17 @@ AM_CPPFLAGS = \
5-I. \ 5-I. \
6-I$(top_srcdir)/lib \ 6-I$(top_srcdir)/lib \
7-I$(top_builddir)/lib \ 7-I$(top_builddir)/lib \
8-DPACKAGE_PKGDATA_DIR=\"$(pkgdatadir)\" \ 8-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" \
9-DPACKAGE_BIN_DIR=\"$(pkgbindir)\" \
9@EQUATE_CFLAGS@ 10@EQUATE_CFLAGS@
10 11
11bin_PROGRAMS = equate 12bin_PROGRAMS = equate
12 13
13equate_SOURCES = \ 14equate_SOURCES = \
14gui.c \
15calc_parse.c \ 15calc_parse.c \
16edje.c \
17main.c \ 16main.c \
18Equate.h \ 17Equate.h \
19calc.h \ 18calc.h
20gui.h
21 19
22equate_LDADD = @EQUATE_LIBS@ 20equate_LDADD = @EQUATE_LIBS@
23 21
diff --git a/src/calc.h b/src/calc.h
index 9e49c08..cd8e190 100644
--- a/src/calc.h
+++ b/src/calc.h
@@ -5,6 +5,7 @@
5void equate_clear(void); 5void equate_clear(void);
6int equate_append(char *str); 6int equate_append(char *str);
7double equate_eval(void); 7double equate_eval(void);
8const char *equate_string_get(void);
8 9
9/* Fonctions type. */ 10/* Fonctions type. */
10typedef double (*func_t) (double); 11typedef double (*func_t) (double);
diff --git a/src/calc_parse.c b/src/calc_parse.c
index faae4a5..88cf797 100644
--- a/src/calc_parse.c
+++ b/src/calc_parse.c
@@ -75,6 +75,7 @@
75#line 1 "calc.y" 75#line 1 "calc.y"
76 76
77#include <math.h> /* For math functions, cos(), sin(), etc. */ 77#include <math.h> /* For math functions, cos(), sin(), etc. */
78#include "calc.h"
78#include "Equate.h" 79#include "Equate.h"
79 80
80#define YYERROR_VERBOSE 81#define YYERROR_VERBOSE
diff --git a/src/edje.c b/src/edje.c
deleted file mode 100644
index 7d8e6cb..0000000
--- a/src/edje.c
+++ /dev/null
@@ -1,299 +0,0 @@
1#include "Equate.h"
2
3/**
4 * Edjification by atmos and digitalfallout
5 * edje_signals.[ch] handle the edje part of equate. Translate signals
6 * our edje emits into the backend. All the operators, functions, and
7 * input values must have a #define'd numeric constant so it can be
8 * evaluated in _equate_interp.
9 *
10 * Jan 10 DigitalFallout
11 * Added theme path detection
12 *
13 */
14
15#define EQ_EXIT 1
16#define OP_CLR 2
17#define OP_DIV 3
18#define OP_MUT 4
19#define OP_ADD 5
20#define OP_SUB 6
21#define OP_EQU 7
22#define OP_DEC 8
23#define OP_SIN 9
24#define OP_COS 10
25#define OP_TAN 11
26#define OP_ROOT 12
27#define OP_POW 13
28#define OP_LOG 14
29#define OP_LN 15
30#define OP_EXP 16
31
32#define NUM_0 20
33#define NUM_1 21
34#define NUM_2 22
35#define NUM_3 23
36#define NUM_4 24
37#define NUM_5 25
38#define NUM_6 26
39#define NUM_7 27
40#define NUM_8 28
41#define NUM_9 29
42#define NUM_PI 30
43
44/**
45 * defined in calc.tab.c
46 */
47extern void equate_clear(void);
48extern double equate_eval(void);
49extern int equate_append(char *str);
50extern const char *equate_string_get(void);
51
52Evas_Object *equate_edje_root;
53Ecore_Evas *equate_edje_window;
54int equate_edje_inited;
55
56static void
57_no_filter_cb(void *data, Evas_Object * o, const char *emission, const
58 char *source)
59{
60
61 //printf("emission: %s\t source: %s\n", emission, source);
62
63}
64
65/**
66 * Interpret all of our different signals, and do things !
67 */
68static void
69_equate_interp(void *data, Evas_Object * o, const char *emission, const
70 char *source)
71{
72 int val = 0;
73
74 if (data)
75 {
76 double result;
77 char buf[BUFLEN];
78
79 val = (int) data;
80 switch (val)
81 {
82 case EQ_EXIT:
83 ecore_main_loop_quit();
84 break;
85 case OP_CLR:
86 equate_clear();
87 break;
88 case OP_DIV:
89 equate_append("/");
90 break;
91 case OP_MUT:
92 equate_append("*");
93 break;
94 case OP_ADD:
95 equate_append("+");
96 break;
97 case OP_SUB:
98 equate_append("-");
99 break;
100 case OP_EQU:
101 snprintf(buf, BUFLEN, "%.10g", equate_eval());
102 edje_object_part_text_set(o, "EquateAnswer", buf);
103 return;
104 break;
105 case OP_DEC:
106 equate_append(".");
107 break;
108 case OP_SIN:
109 equate_append("sin");
110 break;
111 case OP_COS:
112 equate_append("cos");
113 break;
114 case OP_TAN:
115 equate_append("tan");
116 break;
117 case OP_ROOT:
118 equate_append("sqrt");
119 break;
120 case OP_POW:
121 equate_append("^");
122 break;
123 case OP_LOG:
124 equate_append("log");
125 break;
126 case OP_LN:
127 equate_append("ln");
128 break;
129 case OP_EXP:
130 equate_append("exp");
131 break;
132 case NUM_0:
133 equate_append("0");
134 break;
135 case NUM_1:
136 equate_append("1");
137 break;
138 case NUM_2:
139 equate_append("2");
140 break;
141 case NUM_3:
142 equate_append("3");
143 break;
144 case NUM_4:
145 equate_append("4");
146 break;
147 case NUM_5:
148 equate_append("5");
149 break;
150 case NUM_6:
151 equate_append("6");
152 break;
153 case NUM_7:
154 equate_append("7");
155 break;
156 case NUM_8:
157 equate_append("8");
158 break;
159 case NUM_9:
160 equate_append("9");
161 break;
162 default:
163 E(1, "Unknown edje signal operator %d", val);
164 break;
165 /* etc */
166 }
167 edje_object_part_text_set(o, "EquateAnswer", equate_string_get());
168
169 }
170}
171
172/* equate_edje_callback_define - setup the edje signal interceptions
173 * @o - the object we're assigning these callbacks to
174 */
175void
176equate_edje_callback_define(Evas_Object * o)
177{
178
179 edje_object_signal_callback_add(o,
180 "*", "*", _no_filter_cb,
181 NULL);
182
183 /** Equate Application Callbacks **/
184 /* EQ_EXIT - Quit Equate */
185 edje_object_signal_callback_add(o,
186 "EQ_EXIT", "*", _equate_interp,
187 (void *) EQ_EXIT);
188
189 /** Equate Operation Callbacks **/
190 /* OP_CLR - Clear Display */
191 edje_object_signal_callback_add(o,
192 "OP_CLR", "*", _equate_interp,
193 (void *) OP_CLR);
194
195 /* OP_DIV - Division Operator */
196 edje_object_signal_callback_add(o,
197 "OP_DIV", "*", _equate_interp,
198 (void *) OP_DIV);
199
200 /* OP_MUT - Mutplication Operator */
201 edje_object_signal_callback_add(o,
202 "OP_MUT", "*", _equate_interp,
203 (void *) OP_MUT);
204
205 /* OP_ADD - Addition Operator */
206 edje_object_signal_callback_add(o,
207 "OP_ADD", "*", _equate_interp,
208 (void *) OP_ADD);
209
210 /* OP_SUB - Subtraction Operator */
211 edje_object_signal_callback_add(o,
212 "OP_SUB", "*", _equate_interp,
213 (void *) OP_SUB);
214
215 /* OP_EQU - Equals Operator */
216 edje_object_signal_callback_add(o,
217 "OP_EQU", "*", _equate_interp,
218 (void *) OP_EQU);
219
220 /* OP_DEC - Decimal Operator */
221 edje_object_signal_callback_add(o,
222 "OP_DEC", "*", _equate_interp,
223 (void *) OP_DEC);
224 /* OP_SIN - Sin of x in degrees */
225 edje_object_signal_callback_add(o,
226 "OP_SIN", "*", _equate_interp,
227 (void *) OP_SIN);
228 /* OP_COS - Cos of x in degree */
229 edje_object_signal_callback_add(o,
230 "OP_COS", "*", _equate_interp,
231 (void *) OP_COS);
232 /* OP_TAN - Tan of x in degrees */
233 edje_object_signal_callback_add(o,
234 "OP_TAN", "*", _equate_interp,
235 (void *) OP_TAN);
236 /* OP_ROOT - The square root of x */
237 edje_object_signal_callback_add(o,
238 "OP_ROOT", "*", _equate_interp,
239 (void *) OP_ROOT);
240 /* OP_POW - Raise x to the y power */
241 edje_object_signal_callback_add(o,
242 "OP_POW", "*", _equate_interp,
243 (void *) OP_POW);
244 /* OP_LOG - Logarithm */
245 edje_object_signal_callback_add(o,
246 "OP_LOG", "*", _equate_interp,
247 (void *) OP_LOG);
248 /* OP_LN - the natural logarithm */
249 edje_object_signal_callback_add(o,
250 "OP_LN", "*", _equate_interp, (void *) OP_LN);
251 /* OP_EXP - e to the x */
252 edje_object_signal_callback_add(o,
253 "OP_EXP", "*", _equate_interp,
254 (void *) OP_EXP);
255
256 /** Equate Number Callbacks **/
257 /* NUM_0 - Zero */
258 edje_object_signal_callback_add(o,
259 "NUM_0", "*", _equate_interp, (void *) NUM_0);
260
261 /* NUM_1 - One */
262 edje_object_signal_callback_add(o,
263 "NUM_1", "*", _equate_interp, (void *) NUM_1);
264
265 /* NUM_2 - Two */
266 edje_object_signal_callback_add(o,
267 "NUM_2", "*", _equate_interp, (void *) NUM_2);
268
269 /* NUM_3 - Three */
270 edje_object_signal_callback_add(o,
271 "NUM_3", "*", _equate_interp, (void *) NUM_3);
272
273 /* NUM_4 - Four */
274 edje_object_signal_callback_add(o,
275 "NUM_4", "*", _equate_interp, (void *) NUM_4);
276
277 /* NUM_5 - Five */
278 edje_object_signal_callback_add(o,
279 "NUM_5", "*", _equate_interp, (void *) NUM_5);
280
281 /* NUM_6 - Six */
282 edje_object_signal_callback_add(o,
283 "NUM_6", "*", _equate_interp, (void *) NUM_6);
284
285 /* NUM_7 - Seven */
286 edje_object_signal_callback_add(o,
287 "NUM_7", "*", _equate_interp, (void *) NUM_7);
288
289 /* NUM_8 - Eight */
290 edje_object_signal_callback_add(o,
291 "NUM_8", "*", _equate_interp, (void *) NUM_8);
292
293 /* NUM_9 - Nine */
294 edje_object_signal_callback_add(o,
295 "NUM_9", "*", _equate_interp, (void *) NUM_9);
296 /* NUM_PI - 3.14159 */
297 edje_object_signal_callback_add(o, "NUM_PI", "*", _equate_interp,
298 (void *) NUM_PI);
299}
diff --git a/src/gui.c b/src/gui.c
deleted file mode 100644
index 8a703bb..0000000
--- a/src/gui.c
+++ /dev/null
@@ -1,43 +0,0 @@
1#include "Equate.h"
2
3int inited = 0;
4
5Evas_Object *win;
6Evas_Object *ly;
7
8void
9equate_init_gui(Equate * equate, int argc, char **argv)
10{
11 char buf[1024];
12 char *pkgdatadir;
13
14 if (inited == 1)
15 return;
16 if (equate)
17 {
18 win = elm_win_add(NULL, "equate", ELM_WIN_BASIC);
19 elm_win_title_set(win, "Equate");
20 elm_win_autodel_set(win, EINA_TRUE);
21 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
22
23
24 ly = elm_layout_add(win);
25 pkgdatadir = getenv("EQUATE_PKGDATA_DIR");
26 if (!pkgdatadir)
27 pkgdatadir = PACKAGE_PKGDATA_DIR;
28 snprintf(buf, sizeof(buf), "%s/themes/equate.edj", pkgdatadir);
29 elm_layout_file_set(ly, buf, "Main");
30 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
31 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
32 elm_win_resize_object_add(win, ly);
33 evas_object_show(ly);
34
35 evas_object_show(win);
36 evas_object_resize(win, 200, 296);
37
38 equate_edje_callback_define(elm_layout_edje_get(ly));
39
40 inited = 1;
41 }
42}
43
diff --git a/src/gui.h b/src/gui.h
deleted file mode 100644
index 8f98334..0000000
--- a/src/gui.h
+++ /dev/null
@@ -1,12 +0,0 @@
1#ifndef _EQUATE_GUI_H
2#define _EQUATE_GUI_H
3
4/* needed 'cos generated h files suck */
5double yyresult(void);
6
7void update_display(char *text);
8
9void equate_gui_init(Equate * equate, int argc, char **arvg);
10void equate_gui_quit(void);
11void equate_gui_update(Equate * equate);
12#endif
diff --git a/src/main.c b/src/main.c
index cee7e8d..df6d177 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,22 +1,236 @@
1#include <Elementary.h>
2#ifndef ELM_LIB_QUICKLAUNCH
3
1#include "Equate.h" 4#include "Equate.h"
5#include "calc.h"
2 6
3Equate equate; 7static Evas_Object *win;
8static Evas_Object *ly;
4 9
5int 10static void
6main(int argc, char *argv[], char *env[]) 11_signal_cb(void *data, Evas_Object * o, const char *emission, const
12 char *source)
7{ 13{
8 int nextarg = 1, parse_ret, found; 14 int val = 0;
9 char *arg;
10 15
11 elm_init(argc, argv); 16 if (data)
17 {
18 double result;
19 char buf[BUFLEN];
12 20
13 equate.conf.mode = EDJE; 21 val = (int) data;
14 math_init(); 22 switch (val)
15 equate_init_gui(&equate, argc, argv); 23 {
24 case EQ_EXIT:
25 elm_exit();
26 break;
27 case OP_CLR:
28 equate_clear();
29 break;
30 case OP_DIV:
31 equate_append("/");
32 break;
33 case OP_MUT:
34 equate_append("*");
35 break;
36 case OP_ADD:
37 equate_append("+");
38 break;
39 case OP_SUB:
40 equate_append("-");
41 break;
42 case OP_EQU:
43 snprintf(buf, BUFLEN, "%.10g", equate_eval());
44 edje_object_part_text_set(o, "EquateAnswer", buf);
45 return;
46 break;
47 case OP_DEC:
48 equate_append(".");
49 break;
50 case OP_OBRAK:
51 equate_append("(");
52 break;
53 case OP_CBRAK:
54 equate_append(")");
55 break;
56 case OP_SIN:
57 equate_append("sin");
58 break;
59 case OP_COS:
60 equate_append("cos");
61 break;
62 case OP_TAN:
63 equate_append("tan");
64 break;
65 case OP_ROOT:
66 equate_append("sqrt");
67 break;
68 case OP_POW:
69 equate_append("^");
70 break;
71 case OP_LOG:
72 equate_append("log");
73 break;
74 case OP_LN:
75 equate_append("ln");
76 break;
77 case OP_EXP:
78 equate_append("exp");
79 break;
80 case NUM_0:
81 equate_append("0");
82 break;
83 case NUM_1:
84 equate_append("1");
85 break;
86 case NUM_2:
87 equate_append("2");
88 break;
89 case NUM_3:
90 equate_append("3");
91 break;
92 case NUM_4:
93 equate_append("4");
94 break;
95 case NUM_5:
96 equate_append("5");
97 break;
98 case NUM_6:
99 equate_append("6");
100 break;
101 case NUM_7:
102 equate_append("7");
103 break;
104 case NUM_8:
105 equate_append("8");
106 break;
107 case NUM_9:
108 equate_append("9");
109 break;
110 default:
111 E(1, "Unknown edje signal operator %d", val);
112 break;
113 /* etc */
114 }
115 edje_object_part_text_set(o, "EquateAnswer", equate_string_get());
16 116
17 elm_run(); 117 }
118}
119
120
121static void
122_edje_callbacks_define(Evas_Object * o)
123{
124 /** Equate Application Callbacks **/
125 /* EQ_EXIT - Quit Equate */
126 edje_object_signal_callback_add(o, "EQ_EXIT", "*", _signal_cb,
127 (void *) EQ_EXIT);
128 /** Equate Operation Callbacks **/
129 /* OP_CLR - Clear Display */
130 edje_object_signal_callback_add(o, "OP_CLR", "*", _signal_cb,
131 (void *) OP_CLR);
132 /* OP_DIV - Division Operator */
133 edje_object_signal_callback_add(o, "OP_DIV", "*", _signal_cb,
134 (void *) OP_DIV);
135 /* OP_MUT - Mutplication Operator */
136 edje_object_signal_callback_add(o, "OP_MUT", "*", _signal_cb,
137 (void *) OP_MUT);
138 /* OP_ADD - Addition Operator */
139 edje_object_signal_callback_add(o, "OP_ADD", "*", _signal_cb,
140 (void *) OP_ADD);
141 /* OP_SUB - Subtraction Operator */
142 edje_object_signal_callback_add(o, "OP_SUB", "*", _signal_cb,
143 (void *) OP_SUB);
144 /* OP_EQU - Equals Operator */
145 edje_object_signal_callback_add(o, "OP_EQU", "*", _signal_cb,
146 (void *) OP_EQU);
147 /* OP_DEC - Decimal Operator */
148 edje_object_signal_callback_add(o, "OP_DEC", "*", _signal_cb,
149 (void *) OP_DEC);
150 /* OP_SIN - Sin of x in degrees */
151 edje_object_signal_callback_add(o, "OP_SIN", "*", _signal_cb,
152 (void *) OP_SIN);
153 /* OP_COS - Cos of x in degree */
154 edje_object_signal_callback_add(o, "OP_COS", "*", _signal_cb,
155 (void *) OP_COS);
156 /* OP_TAN - Tan of x in degrees */
157 edje_object_signal_callback_add(o, "OP_TAN", "*", _signal_cb,
158 (void *) OP_TAN);
159 /* OP_ROOT - The square root of x */
160 edje_object_signal_callback_add(o, "OP_ROOT", "*", _signal_cb,
161 (void *) OP_ROOT);
162 /* OP_POW - Raise x to the y power */
163 edje_object_signal_callback_add(o, "OP_POW", "*", _signal_cb,
164 (void *) OP_POW);
165 /* OP_LOG - Logarithm */
166 edje_object_signal_callback_add(o, "OP_LOG", "*", _signal_cb,
167 (void *) OP_LOG);
168 /* OP_LN - the natural logarithm */
169 edje_object_signal_callback_add(o, "OP_LN", "*", _signal_cb, (void *) OP_LN);
170 /* OP_EXP - e to the x */
171 edje_object_signal_callback_add(o, "OP_EXP", "*", _signal_cb,
172 (void *) OP_EXP);
173 /* OP_OBRAK - open bracket */
174 edje_object_signal_callback_add(o, "OP_OBRAK", "*", _signal_cb,
175 (void *) OP_OBRAK);
176 /* OP_CBRAK - close bracket */
177 edje_object_signal_callback_add(o, "OP_CBRAK", "*", _signal_cb,
178 (void *) OP_CBRAK);
179
180 /** Equate Number Callbacks **/
181 edje_object_signal_callback_add(o, "NUM_0", "*", _signal_cb, (void *) NUM_0);
182 edje_object_signal_callback_add(o, "NUM_1", "*", _signal_cb, (void *) NUM_1);
183 edje_object_signal_callback_add(o, "NUM_2", "*", _signal_cb, (void *) NUM_2);
184 edje_object_signal_callback_add(o, "NUM_3", "*", _signal_cb, (void *) NUM_3);
185 edje_object_signal_callback_add(o, "NUM_4", "*", _signal_cb, (void *) NUM_4);
186 edje_object_signal_callback_add(o, "NUM_5", "*", _signal_cb, (void *) NUM_5);
187 edje_object_signal_callback_add(o, "NUM_6", "*", _signal_cb, (void *) NUM_6);
188 edje_object_signal_callback_add(o, "NUM_7", "*", _signal_cb, (void *) NUM_7);
189 edje_object_signal_callback_add(o, "NUM_8", "*", _signal_cb, (void *) NUM_8);
190 edje_object_signal_callback_add(o, "NUM_9", "*", _signal_cb, (void *) NUM_9);
191 /* NUM_PI - 3.14159 */
192 edje_object_signal_callback_add(o, "NUM_PI", "*", _signal_cb, (void *) NUM_PI);
193}
194
195static void
196_create_gui(void)
197{
198 char buf[1024];
18 199
200 win = elm_win_add(NULL, "equate", ELM_WIN_BASIC);
201 elm_win_title_set(win, "Equate");
202 elm_win_autodel_set(win, EINA_TRUE);
203 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
204
205 ly = elm_layout_add(win);
206 snprintf(buf, sizeof(buf), "%s/themes/equate.edj", elm_app_data_dir_get());
207 elm_layout_file_set(ly, buf, "Main");
208 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
209 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
210 elm_win_resize_object_add(win, ly);
211 evas_object_show(ly);
212
213 evas_object_show(win);
214 evas_object_resize(win, 240, 320);
215
216 _edje_callbacks_define(elm_layout_edje_get(ly));
217}
218
219EAPI_MAIN int
220elm_main(int argc, char **argv)
221{
222
223 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
224 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
225 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
226 elm_app_info_set(elm_main, "equate", "images/equate.png");
227
228 math_init();
229 _create_gui();
230 elm_run();
19 elm_shutdown(); 231 elm_shutdown();
20 232
21 return 0; 233 return 0;
22} 234}
235#endif
236ELM_MAIN()