author | kergoth <kergoth> | 2002-01-25 22:14:26 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-01-25 22:14:26 (UTC) |
commit | 15318cad33835e4e2dc620d033e43cd930676cdd (patch) (unidiff) | |
tree | c2fa0399a2c47fda8e2cd0092c73a809d17f68eb /noncore/tools/calculator | |
download | opie-15318cad33835e4e2dc620d033e43cd930676cdd.zip opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2 |
Initial revision
-rw-r--r-- | noncore/tools/calculator/.cvsignore | 4 | ||||
-rw-r--r-- | noncore/tools/calculator/Makefile.in | 139 | ||||
-rw-r--r-- | noncore/tools/calculator/calculator.pro | 13 | ||||
-rw-r--r-- | noncore/tools/calculator/calculator.ui | 1026 | ||||
-rw-r--r-- | noncore/tools/calculator/calculatorimpl.cpp | 601 | ||||
-rw-r--r-- | noncore/tools/calculator/calculatorimpl.h | 135 | ||||
-rw-r--r-- | noncore/tools/calculator/main.cpp | 35 | ||||
-rw-r--r-- | noncore/tools/calculator/qpe-calculator.control | 10 |
8 files changed, 1963 insertions, 0 deletions
diff --git a/noncore/tools/calculator/.cvsignore b/noncore/tools/calculator/.cvsignore new file mode 100644 index 0000000..f5bf2df --- a/dev/null +++ b/noncore/tools/calculator/.cvsignore | |||
@@ -0,0 +1,4 @@ | |||
1 | moc_* | ||
2 | Makefile | ||
3 | calculator.h | ||
4 | calculator.cpp | ||
diff --git a/noncore/tools/calculator/Makefile.in b/noncore/tools/calculator/Makefile.in new file mode 100644 index 0000000..d62b046 --- a/dev/null +++ b/noncore/tools/calculator/Makefile.in | |||
@@ -0,0 +1,139 @@ | |||
1 | ############################################################################# | ||
2 | |||
3 | ####### Compiler, tools and options | ||
4 | |||
5 | CXX =$(SYSCONF_CXX) $(QT_CXX_MT) | ||
6 | CXXFLAGS=$(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) | ||
7 | CC =$(SYSCONF_CC) $(QT_C_MT) | ||
8 | CFLAGS =$(SYSCONF_CFLAGS) | ||
9 | INCPATH =-I$(QPEDIR)/include | ||
10 | LFLAGS =$(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) | ||
11 | LIBS =$(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP) | ||
12 | MOC =$(SYSCONF_MOC) | ||
13 | UIC =$(SYSCONF_UIC) | ||
14 | |||
15 | ####### Target | ||
16 | |||
17 | DESTDIR = $(QPEDIR)/bin/ | ||
18 | VER_MAJ = 1 | ||
19 | VER_MIN = 0 | ||
20 | VER_PATCH = 0 | ||
21 | TARGET= calculator | ||
22 | TARGET1 = lib$(TARGET).so.$(VER_MAJ) | ||
23 | |||
24 | ####### Files | ||
25 | |||
26 | HEADERS =calculatorimpl.h | ||
27 | SOURCES =calculatorimpl.cpp \ | ||
28 | main.cpp | ||
29 | OBJECTS =calculatorimpl.o \ | ||
30 | main.o \ | ||
31 | calculator.o | ||
32 | INTERFACES = calculator.ui | ||
33 | UICDECLS = calculator.h | ||
34 | UICIMPLS = calculator.cpp | ||
35 | SRCMOC =moc_calculatorimpl.cpp \ | ||
36 | moc_calculator.cpp | ||
37 | OBJMOC =moc_calculatorimpl.o \ | ||
38 | moc_calculator.o | ||
39 | |||
40 | |||
41 | ####### Implicit rules | ||
42 | |||
43 | .SUFFIXES: .cpp .cxx .cc .C .c | ||
44 | |||
45 | .cpp.o: | ||
46 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
47 | |||
48 | .cxx.o: | ||
49 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
50 | |||
51 | .cc.o: | ||
52 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
53 | |||
54 | .C.o: | ||
55 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
56 | |||
57 | .c.o: | ||
58 | $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< | ||
59 | |||
60 | ####### Build rules | ||
61 | |||
62 | |||
63 | all: $(DESTDIR)$(TARGET) | ||
64 | |||
65 | $(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) | ||
66 | $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) | ||
67 | |||
68 | moc: $(SRCMOC) | ||
69 | |||
70 | tmake: | ||
71 | tmake calculator.pro | ||
72 | |||
73 | clean: | ||
74 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) | ||
75 | -rm -f *~ core | ||
76 | -rm -f allmoc.cpp | ||
77 | |||
78 | ####### Extension Modules | ||
79 | |||
80 | listpromodules: | ||
81 | @echo | ||
82 | |||
83 | listallmodules: | ||
84 | @echo | ||
85 | |||
86 | listaddonpromodules: | ||
87 | @echo | ||
88 | |||
89 | listaddonentmodules: | ||
90 | @echo | ||
91 | |||
92 | |||
93 | REQUIRES= | ||
94 | |||
95 | ####### Sub-libraries | ||
96 | |||
97 | |||
98 | ###### Combined headers | ||
99 | |||
100 | |||
101 | |||
102 | ####### Compile | ||
103 | |||
104 | calculatorimpl.o: calculatorimpl.cpp \ | ||
105 | calculatorimpl.h \ | ||
106 | calculator.h \ | ||
107 | $(QPEDIR)/include/qpe/resource.h \ | ||
108 | $(QPEDIR)/include/qpe/qmath.h \ | ||
109 | $(QPEDIR)/include/qpe/qpeapplication.h | ||
110 | |||
111 | main.o: main.cpp \ | ||
112 | calculatorimpl.h \ | ||
113 | calculator.h \ | ||
114 | $(QPEDIR)/include/qpe/qpeapplication.h | ||
115 | |||
116 | calculator.h: calculator.ui | ||
117 | $(UIC) calculator.ui -o calculator.h | ||
118 | |||
119 | calculator.cpp: calculator.ui | ||
120 | $(UIC) calculator.ui -i calculator.h -o calculator.cpp | ||
121 | |||
122 | calculator.o: calculator.cpp \ | ||
123 | calculator.h \ | ||
124 | calculator.ui | ||
125 | |||
126 | moc_calculatorimpl.o: moc_calculatorimpl.cpp \ | ||
127 | calculatorimpl.h \ | ||
128 | calculator.h | ||
129 | |||
130 | moc_calculator.o: moc_calculator.cpp \ | ||
131 | calculator.h | ||
132 | |||
133 | moc_calculatorimpl.cpp: calculatorimpl.h | ||
134 | $(MOC) calculatorimpl.h -o moc_calculatorimpl.cpp | ||
135 | |||
136 | moc_calculator.cpp: calculator.h | ||
137 | $(MOC) calculator.h -o moc_calculator.cpp | ||
138 | |||
139 | |||
diff --git a/noncore/tools/calculator/calculator.pro b/noncore/tools/calculator/calculator.pro new file mode 100644 index 0000000..1281fd5 --- a/dev/null +++ b/noncore/tools/calculator/calculator.pro | |||
@@ -0,0 +1,13 @@ | |||
1 | DESTDIR = $(QPEDIR)/bin | ||
2 | TEMPLATE= app | ||
3 | CONFIG = qt warn_on release | ||
4 | HEADERS = calculatorimpl.h | ||
5 | SOURCES = calculatorimpl.cpp \ | ||
6 | main.cpp | ||
7 | INCLUDEPATH += $(QPEDIR)/include | ||
8 | DEPENDPATH+= $(QPEDIR)/include | ||
9 | LIBS += -lqpe | ||
10 | INTERFACES= calculator.ui | ||
11 | TARGET = calculator | ||
12 | |||
13 | TRANSLATIONS = ../i18n/de/calculator.ts | ||
diff --git a/noncore/tools/calculator/calculator.ui b/noncore/tools/calculator/calculator.ui new file mode 100644 index 0000000..e8218ab --- a/dev/null +++ b/noncore/tools/calculator/calculator.ui | |||
@@ -0,0 +1,1026 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>Calculator</class> | ||
3 | <comment>********************************************************************* | ||
4 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
5 | ** | ||
6 | ** This file is part of Qt Palmtop Environment. | ||
7 | ** | ||
8 | ** This file may be distributed and/or modified under the terms of the | ||
9 | ** GNU General Public License version 2 as published by the Free Software | ||
10 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
11 | ** packaging of this file. | ||
12 | ** | ||
13 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
14 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
15 | ** | ||
16 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
17 | ** | ||
18 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
19 | ** not clear to you. | ||
20 | ** | ||
21 | *********************************************************************</comment> | ||
22 | <widget> | ||
23 | <class>QWidget</class> | ||
24 | <property stdset="1"> | ||
25 | <name>name</name> | ||
26 | <cstring>Calculator</cstring> | ||
27 | </property> | ||
28 | <property stdset="1"> | ||
29 | <name>geometry</name> | ||
30 | <rect> | ||
31 | <x>0</x> | ||
32 | <y>0</y> | ||
33 | <width>271</width> | ||
34 | <height>404</height> | ||
35 | </rect> | ||
36 | </property> | ||
37 | <property stdset="1"> | ||
38 | <name>sizePolicy</name> | ||
39 | <sizepolicy> | ||
40 | <hsizetype>5</hsizetype> | ||
41 | <vsizetype>5</vsizetype> | ||
42 | </sizepolicy> | ||
43 | </property> | ||
44 | <property stdset="1"> | ||
45 | <name>maximumSize</name> | ||
46 | <size> | ||
47 | <width>32767</width> | ||
48 | <height>32767</height> | ||
49 | </size> | ||
50 | </property> | ||
51 | <property stdset="1"> | ||
52 | <name>baseSize</name> | ||
53 | <size> | ||
54 | <width>235</width> | ||
55 | <height>100</height> | ||
56 | </size> | ||
57 | </property> | ||
58 | <property stdset="1"> | ||
59 | <name>caption</name> | ||
60 | <string>Experimental Calculator</string> | ||
61 | </property> | ||
62 | <property> | ||
63 | <name>layoutMargin</name> | ||
64 | </property> | ||
65 | <property> | ||
66 | <name>layoutSpacing</name> | ||
67 | </property> | ||
68 | <vbox> | ||
69 | <property stdset="1"> | ||
70 | <name>margin</name> | ||
71 | <number>0</number> | ||
72 | </property> | ||
73 | <property stdset="1"> | ||
74 | <name>spacing</name> | ||
75 | <number>0</number> | ||
76 | </property> | ||
77 | <widget> | ||
78 | <class>QLCDNumber</class> | ||
79 | <property stdset="1"> | ||
80 | <name>name</name> | ||
81 | <cstring>LCD</cstring> | ||
82 | </property> | ||
83 | <property stdset="1"> | ||
84 | <name>sizePolicy</name> | ||
85 | <sizepolicy> | ||
86 | <hsizetype>1</hsizetype> | ||
87 | <vsizetype>1</vsizetype> | ||
88 | </sizepolicy> | ||
89 | </property> | ||
90 | <property stdset="1"> | ||
91 | <name>font</name> | ||
92 | <font> | ||
93 | <pointsize>7</pointsize> | ||
94 | </font> | ||
95 | </property> | ||
96 | <property stdset="1"> | ||
97 | <name>numDigits</name> | ||
98 | <number>15</number> | ||
99 | </property> | ||
100 | <property stdset="1"> | ||
101 | <name>segmentStyle</name> | ||
102 | <enum>Flat</enum> | ||
103 | </property> | ||
104 | </widget> | ||
105 | <widget> | ||
106 | <class>QLayoutWidget</class> | ||
107 | <property stdset="1"> | ||
108 | <name>name</name> | ||
109 | <cstring>Layout4</cstring> | ||
110 | </property> | ||
111 | <hbox> | ||
112 | <property stdset="1"> | ||
113 | <name>margin</name> | ||
114 | <number>0</number> | ||
115 | </property> | ||
116 | <property stdset="1"> | ||
117 | <name>spacing</name> | ||
118 | <number>0</number> | ||
119 | </property> | ||
120 | <widget> | ||
121 | <class>QComboBox</class> | ||
122 | <property stdset="1"> | ||
123 | <name>name</name> | ||
124 | <cstring>ComboBoxFunction</cstring> | ||
125 | </property> | ||
126 | <property stdset="1"> | ||
127 | <name>sizePolicy</name> | ||
128 | <sizepolicy> | ||
129 | <hsizetype>1</hsizetype> | ||
130 | <vsizetype>1</vsizetype> | ||
131 | </sizepolicy> | ||
132 | </property> | ||
133 | </widget> | ||
134 | <widget> | ||
135 | <class>QPushButton</class> | ||
136 | <property stdset="1"> | ||
137 | <name>name</name> | ||
138 | <cstring>PushButtonMPlus</cstring> | ||
139 | </property> | ||
140 | <property stdset="1"> | ||
141 | <name>sizePolicy</name> | ||
142 | <sizepolicy> | ||
143 | <hsizetype>5</hsizetype> | ||
144 | <vsizetype>5</vsizetype> | ||
145 | </sizepolicy> | ||
146 | </property> | ||
147 | <property stdset="1"> | ||
148 | <name>focusPolicy</name> | ||
149 | <enum>TabFocus</enum> | ||
150 | </property> | ||
151 | <property stdset="1"> | ||
152 | <name>text</name> | ||
153 | <string>M+</string> | ||
154 | </property> | ||
155 | </widget> | ||
156 | <widget> | ||
157 | <class>QPushButton</class> | ||
158 | <property stdset="1"> | ||
159 | <name>name</name> | ||
160 | <cstring>PushButtonMR</cstring> | ||
161 | </property> | ||
162 | <property stdset="1"> | ||
163 | <name>sizePolicy</name> | ||
164 | <sizepolicy> | ||
165 | <hsizetype>5</hsizetype> | ||
166 | <vsizetype>5</vsizetype> | ||
167 | </sizepolicy> | ||
168 | </property> | ||
169 | <property stdset="1"> | ||
170 | <name>focusPolicy</name> | ||
171 | <enum>TabFocus</enum> | ||
172 | </property> | ||
173 | <property stdset="1"> | ||
174 | <name>text</name> | ||
175 | <string>MR</string> | ||
176 | </property> | ||
177 | </widget> | ||
178 | <widget> | ||
179 | <class>QPushButton</class> | ||
180 | <property stdset="1"> | ||
181 | <name>name</name> | ||
182 | <cstring>PushButtonMC</cstring> | ||
183 | </property> | ||
184 | <property stdset="1"> | ||
185 | <name>sizePolicy</name> | ||
186 | <sizepolicy> | ||
187 | <hsizetype>5</hsizetype> | ||
188 | <vsizetype>5</vsizetype> | ||
189 | </sizepolicy> | ||
190 | </property> | ||
191 | <property stdset="1"> | ||
192 | <name>focusPolicy</name> | ||
193 | <enum>TabFocus</enum> | ||
194 | </property> | ||
195 | <property stdset="1"> | ||
196 | <name>text</name> | ||
197 | <string>MC</string> | ||
198 | </property> | ||
199 | </widget> | ||
200 | <widget> | ||
201 | <class>QPushButton</class> | ||
202 | <property stdset="1"> | ||
203 | <name>name</name> | ||
204 | <cstring>PushButtonCE</cstring> | ||
205 | </property> | ||
206 | <property stdset="1"> | ||
207 | <name>sizePolicy</name> | ||
208 | <sizepolicy> | ||
209 | <hsizetype>5</hsizetype> | ||
210 | <vsizetype>5</vsizetype> | ||
211 | </sizepolicy> | ||
212 | </property> | ||
213 | <property stdset="1"> | ||
214 | <name>focusPolicy</name> | ||
215 | <enum>TabFocus</enum> | ||
216 | </property> | ||
217 | <property stdset="1"> | ||
218 | <name>text</name> | ||
219 | <string>CE</string> | ||
220 | </property> | ||
221 | </widget> | ||
222 | </hbox> | ||
223 | </widget> | ||
224 | <widget> | ||
225 | <class>QLayoutWidget</class> | ||
226 | <property stdset="1"> | ||
227 | <name>name</name> | ||
228 | <cstring>Layout10</cstring> | ||
229 | </property> | ||
230 | <property> | ||
231 | <name>layoutSpacing</name> | ||
232 | </property> | ||
233 | <hbox> | ||
234 | <property stdset="1"> | ||
235 | <name>margin</name> | ||
236 | <number>0</number> | ||
237 | </property> | ||
238 | <property stdset="1"> | ||
239 | <name>spacing</name> | ||
240 | <number>0</number> | ||
241 | </property> | ||
242 | <widget> | ||
243 | <class>QPushButton</class> | ||
244 | <property stdset="1"> | ||
245 | <name>name</name> | ||
246 | <cstring>PushButtonF6</cstring> | ||
247 | </property> | ||
248 | <property stdset="1"> | ||
249 | <name>sizePolicy</name> | ||
250 | <sizepolicy> | ||
251 | <hsizetype>5</hsizetype> | ||
252 | <vsizetype>5</vsizetype> | ||
253 | </sizepolicy> | ||
254 | </property> | ||
255 | <property stdset="1"> | ||
256 | <name>text</name> | ||
257 | <string></string> | ||
258 | </property> | ||
259 | </widget> | ||
260 | <widget> | ||
261 | <class>QPushButton</class> | ||
262 | <property stdset="1"> | ||
263 | <name>name</name> | ||
264 | <cstring>PushButtonF7</cstring> | ||
265 | </property> | ||
266 | <property stdset="1"> | ||
267 | <name>sizePolicy</name> | ||
268 | <sizepolicy> | ||
269 | <hsizetype>5</hsizetype> | ||
270 | <vsizetype>5</vsizetype> | ||
271 | </sizepolicy> | ||
272 | </property> | ||
273 | <property stdset="1"> | ||
274 | <name>text</name> | ||
275 | <string></string> | ||
276 | </property> | ||
277 | </widget> | ||
278 | <widget> | ||
279 | <class>QPushButton</class> | ||
280 | <property stdset="1"> | ||
281 | <name>name</name> | ||
282 | <cstring>PushButtonF8</cstring> | ||
283 | </property> | ||
284 | <property stdset="1"> | ||
285 | <name>sizePolicy</name> | ||
286 | <sizepolicy> | ||
287 | <hsizetype>5</hsizetype> | ||
288 | <vsizetype>5</vsizetype> | ||
289 | </sizepolicy> | ||
290 | </property> | ||
291 | <property stdset="1"> | ||
292 | <name>text</name> | ||
293 | <string>log</string> | ||
294 | </property> | ||
295 | </widget> | ||
296 | <widget> | ||
297 | <class>QPushButton</class> | ||
298 | <property stdset="1"> | ||
299 | <name>name</name> | ||
300 | <cstring>PushButtonF9</cstring> | ||
301 | </property> | ||
302 | <property stdset="1"> | ||
303 | <name>sizePolicy</name> | ||
304 | <sizepolicy> | ||
305 | <hsizetype>5</hsizetype> | ||
306 | <vsizetype>5</vsizetype> | ||
307 | </sizepolicy> | ||
308 | </property> | ||
309 | <property stdset="1"> | ||
310 | <name>focusPolicy</name> | ||
311 | <enum>TabFocus</enum> | ||
312 | </property> | ||
313 | <property stdset="1"> | ||
314 | <name>text</name> | ||
315 | <string>ln</string> | ||
316 | </property> | ||
317 | </widget> | ||
318 | <widget> | ||
319 | <class>QPushButton</class> | ||
320 | <property stdset="1"> | ||
321 | <name>name</name> | ||
322 | <cstring>PushButtonF11</cstring> | ||
323 | </property> | ||
324 | <property stdset="1"> | ||
325 | <name>sizePolicy</name> | ||
326 | <sizepolicy> | ||
327 | <hsizetype>5</hsizetype> | ||
328 | <vsizetype>5</vsizetype> | ||
329 | </sizepolicy> | ||
330 | </property> | ||
331 | <property stdset="1"> | ||
332 | <name>text</name> | ||
333 | <string>(</string> | ||
334 | </property> | ||
335 | </widget> | ||
336 | <widget> | ||
337 | <class>QPushButton</class> | ||
338 | <property stdset="1"> | ||
339 | <name>name</name> | ||
340 | <cstring>PushButtonF12</cstring> | ||
341 | </property> | ||
342 | <property stdset="1"> | ||
343 | <name>sizePolicy</name> | ||
344 | <sizepolicy> | ||
345 | <hsizetype>5</hsizetype> | ||
346 | <vsizetype>5</vsizetype> | ||
347 | </sizepolicy> | ||
348 | </property> | ||
349 | <property stdset="1"> | ||
350 | <name>text</name> | ||
351 | <string>)</string> | ||
352 | </property> | ||
353 | </widget> | ||
354 | </hbox> | ||
355 | </widget> | ||
356 | <widget> | ||
357 | <class>QLayoutWidget</class> | ||
358 | <property stdset="1"> | ||
359 | <name>name</name> | ||
360 | <cstring>Layout11</cstring> | ||
361 | </property> | ||
362 | <property> | ||
363 | <name>layoutSpacing</name> | ||
364 | </property> | ||
365 | <hbox> | ||
366 | <property stdset="1"> | ||
367 | <name>margin</name> | ||
368 | <number>0</number> | ||
369 | </property> | ||
370 | <property stdset="1"> | ||
371 | <name>spacing</name> | ||
372 | <number>0</number> | ||
373 | </property> | ||
374 | <widget> | ||
375 | <class>QPushButton</class> | ||
376 | <property stdset="1"> | ||
377 | <name>name</name> | ||
378 | <cstring>PushButtonF1</cstring> | ||
379 | </property> | ||
380 | <property stdset="1"> | ||
381 | <name>sizePolicy</name> | ||
382 | <sizepolicy> | ||
383 | <hsizetype>5</hsizetype> | ||
384 | <vsizetype>5</vsizetype> | ||
385 | </sizepolicy> | ||
386 | </property> | ||
387 | <property stdset="1"> | ||
388 | <name>focusPolicy</name> | ||
389 | <enum>TabFocus</enum> | ||
390 | </property> | ||
391 | <property stdset="1"> | ||
392 | <name>text</name> | ||
393 | <string>sin</string> | ||
394 | </property> | ||
395 | </widget> | ||
396 | <widget> | ||
397 | <class>QPushButton</class> | ||
398 | <property stdset="1"> | ||
399 | <name>name</name> | ||
400 | <cstring>PushButtonF2</cstring> | ||
401 | </property> | ||
402 | <property stdset="1"> | ||
403 | <name>sizePolicy</name> | ||
404 | <sizepolicy> | ||
405 | <hsizetype>5</hsizetype> | ||
406 | <vsizetype>5</vsizetype> | ||
407 | </sizepolicy> | ||
408 | </property> | ||
409 | <property stdset="1"> | ||
410 | <name>focusPolicy</name> | ||
411 | <enum>TabFocus</enum> | ||
412 | </property> | ||
413 | <property stdset="1"> | ||
414 | <name>text</name> | ||
415 | <string>cos</string> | ||
416 | </property> | ||
417 | </widget> | ||
418 | <widget> | ||
419 | <class>QPushButton</class> | ||
420 | <property stdset="1"> | ||
421 | <name>name</name> | ||
422 | <cstring>PushButtonF3</cstring> | ||
423 | </property> | ||
424 | <property stdset="1"> | ||
425 | <name>sizePolicy</name> | ||
426 | <sizepolicy> | ||
427 | <hsizetype>5</hsizetype> | ||
428 | <vsizetype>5</vsizetype> | ||
429 | </sizepolicy> | ||
430 | </property> | ||
431 | <property stdset="1"> | ||
432 | <name>focusPolicy</name> | ||
433 | <enum>TabFocus</enum> | ||
434 | </property> | ||
435 | <property stdset="1"> | ||
436 | <name>text</name> | ||
437 | <string>tan</string> | ||
438 | </property> | ||
439 | </widget> | ||
440 | <widget> | ||
441 | <class>QPushButton</class> | ||
442 | <property stdset="1"> | ||
443 | <name>name</name> | ||
444 | <cstring>PushButtonF4</cstring> | ||
445 | </property> | ||
446 | <property stdset="1"> | ||
447 | <name>sizePolicy</name> | ||
448 | <sizepolicy> | ||
449 | <hsizetype>5</hsizetype> | ||
450 | <vsizetype>5</vsizetype> | ||
451 | </sizepolicy> | ||
452 | </property> | ||
453 | <property stdset="1"> | ||
454 | <name>focusPolicy</name> | ||
455 | <enum>TabFocus</enum> | ||
456 | </property> | ||
457 | <property stdset="1"> | ||
458 | <name>text</name> | ||
459 | <string></string> | ||
460 | </property> | ||
461 | </widget> | ||
462 | <widget> | ||
463 | <class>QPushButton</class> | ||
464 | <property stdset="1"> | ||
465 | <name>name</name> | ||
466 | <cstring>PushButtonF5</cstring> | ||
467 | </property> | ||
468 | <property stdset="1"> | ||
469 | <name>sizePolicy</name> | ||
470 | <sizepolicy> | ||
471 | <hsizetype>5</hsizetype> | ||
472 | <vsizetype>5</vsizetype> | ||
473 | </sizepolicy> | ||
474 | </property> | ||
475 | <property stdset="1"> | ||
476 | <name>focusPolicy</name> | ||
477 | <enum>TabFocus</enum> | ||
478 | </property> | ||
479 | <property stdset="1"> | ||
480 | <name>text</name> | ||
481 | <string>%</string> | ||
482 | </property> | ||
483 | </widget> | ||
484 | <widget> | ||
485 | <class>QPushButton</class> | ||
486 | <property stdset="1"> | ||
487 | <name>name</name> | ||
488 | <cstring>PushButtonF10</cstring> | ||
489 | </property> | ||
490 | <property stdset="1"> | ||
491 | <name>sizePolicy</name> | ||
492 | <sizepolicy> | ||
493 | <hsizetype>5</hsizetype> | ||
494 | <vsizetype>5</vsizetype> | ||
495 | </sizepolicy> | ||
496 | </property> | ||
497 | <property stdset="1"> | ||
498 | <name>focusPolicy</name> | ||
499 | <enum>TabFocus</enum> | ||
500 | </property> | ||
501 | <property stdset="1"> | ||
502 | <name>text</name> | ||
503 | <string>+/-</string> | ||
504 | </property> | ||
505 | </widget> | ||
506 | </hbox> | ||
507 | </widget> | ||
508 | <widget> | ||
509 | <class>QLayoutWidget</class> | ||
510 | <property stdset="1"> | ||
511 | <name>name</name> | ||
512 | <cstring>Layout5</cstring> | ||
513 | </property> | ||
514 | <grid> | ||
515 | <property stdset="1"> | ||
516 | <name>margin</name> | ||
517 | <number>0</number> | ||
518 | </property> | ||
519 | <property stdset="1"> | ||
520 | <name>spacing</name> | ||
521 | <number>0</number> | ||
522 | </property> | ||
523 | <widget row="2" column="2" > | ||
524 | <class>QPushButton</class> | ||
525 | <property stdset="1"> | ||
526 | <name>name</name> | ||
527 | <cstring>PushButton3</cstring> | ||
528 | </property> | ||
529 | <property stdset="1"> | ||
530 | <name>sizePolicy</name> | ||
531 | <sizepolicy> | ||
532 | <hsizetype>5</hsizetype> | ||
533 | <vsizetype>5</vsizetype> | ||
534 | </sizepolicy> | ||
535 | </property> | ||
536 | <property stdset="1"> | ||
537 | <name>font</name> | ||
538 | <font> | ||
539 | <family>adobe-helvetica</family> | ||
540 | <pointsize>24</pointsize> | ||
541 | </font> | ||
542 | </property> | ||
543 | <property stdset="1"> | ||
544 | <name>focusPolicy</name> | ||
545 | <enum>TabFocus</enum> | ||
546 | </property> | ||
547 | <property stdset="1"> | ||
548 | <name>text</name> | ||
549 | <string>3</string> | ||
550 | </property> | ||
551 | </widget> | ||
552 | <widget row="1" column="2" > | ||
553 | <class>QPushButton</class> | ||
554 | <property stdset="1"> | ||
555 | <name>name</name> | ||
556 | <cstring>PushButton6</cstring> | ||
557 | </property> | ||
558 | <property stdset="1"> | ||
559 | <name>sizePolicy</name> | ||
560 | <sizepolicy> | ||
561 | <hsizetype>5</hsizetype> | ||
562 | <vsizetype>5</vsizetype> | ||
563 | </sizepolicy> | ||
564 | </property> | ||
565 | <property stdset="1"> | ||
566 | <name>font</name> | ||
567 | <font> | ||
568 | <family>adobe-helvetica</family> | ||
569 | <pointsize>24</pointsize> | ||
570 | </font> | ||
571 | </property> | ||
572 | <property stdset="1"> | ||
573 | <name>focusPolicy</name> | ||
574 | <enum>TabFocus</enum> | ||
575 | </property> | ||
576 | <property stdset="1"> | ||
577 | <name>text</name> | ||
578 | <string>6</string> | ||
579 | </property> | ||
580 | </widget> | ||
581 | <widget row="3" column="2" > | ||
582 | <class>QPushButton</class> | ||
583 | <property stdset="1"> | ||
584 | <name>name</name> | ||
585 | <cstring>PushButtonEquals</cstring> | ||
586 | </property> | ||
587 | <property stdset="1"> | ||
588 | <name>sizePolicy</name> | ||
589 | <sizepolicy> | ||
590 | <hsizetype>5</hsizetype> | ||
591 | <vsizetype>5</vsizetype> | ||
592 | </sizepolicy> | ||
593 | </property> | ||
594 | <property stdset="1"> | ||
595 | <name>font</name> | ||
596 | <font> | ||
597 | <family>adobe-helvetica</family> | ||
598 | <pointsize>24</pointsize> | ||
599 | </font> | ||
600 | </property> | ||
601 | <property stdset="1"> | ||
602 | <name>focusPolicy</name> | ||
603 | <enum>TabFocus</enum> | ||
604 | </property> | ||
605 | <property stdset="1"> | ||
606 | <name>text</name> | ||
607 | <string>=</string> | ||
608 | </property> | ||
609 | </widget> | ||
610 | <widget row="3" column="0" > | ||
611 | <class>QPushButton</class> | ||
612 | <property stdset="1"> | ||
613 | <name>name</name> | ||
614 | <cstring>PushButton0</cstring> | ||
615 | </property> | ||
616 | <property stdset="1"> | ||
617 | <name>sizePolicy</name> | ||
618 | <sizepolicy> | ||
619 | <hsizetype>5</hsizetype> | ||
620 | <vsizetype>5</vsizetype> | ||
621 | </sizepolicy> | ||
622 | </property> | ||
623 | <property stdset="1"> | ||
624 | <name>font</name> | ||
625 | <font> | ||
626 | <family>adobe-helvetica</family> | ||
627 | <pointsize>24</pointsize> | ||
628 | </font> | ||
629 | </property> | ||
630 | <property stdset="1"> | ||
631 | <name>focusPolicy</name> | ||
632 | <enum>TabFocus</enum> | ||
633 | </property> | ||
634 | <property stdset="1"> | ||
635 | <name>text</name> | ||
636 | <string>0</string> | ||
637 | </property> | ||
638 | </widget> | ||
639 | <widget row="1" column="3" > | ||
640 | <class>QPushButton</class> | ||
641 | <property stdset="1"> | ||
642 | <name>name</name> | ||
643 | <cstring>PushButtonMinus</cstring> | ||
644 | </property> | ||
645 | <property stdset="1"> | ||
646 | <name>sizePolicy</name> | ||
647 | <sizepolicy> | ||
648 | <hsizetype>5</hsizetype> | ||
649 | <vsizetype>5</vsizetype> | ||
650 | </sizepolicy> | ||
651 | </property> | ||
652 | <property stdset="1"> | ||
653 | <name>font</name> | ||
654 | <font> | ||
655 | <family>adobe-helvetica</family> | ||
656 | <pointsize>24</pointsize> | ||
657 | </font> | ||
658 | </property> | ||
659 | <property stdset="1"> | ||
660 | <name>focusPolicy</name> | ||
661 | <enum>TabFocus</enum> | ||
662 | </property> | ||
663 | <property stdset="1"> | ||
664 | <name>text</name> | ||
665 | <string>-</string> | ||
666 | </property> | ||
667 | </widget> | ||
668 | <widget row="2" column="3" > | ||
669 | <class>QPushButton</class> | ||
670 | <property stdset="1"> | ||
671 | <name>name</name> | ||
672 | <cstring>PushButtonTimes</cstring> | ||
673 | </property> | ||
674 | <property stdset="1"> | ||
675 | <name>sizePolicy</name> | ||
676 | <sizepolicy> | ||
677 | <hsizetype>5</hsizetype> | ||
678 | <vsizetype>5</vsizetype> | ||
679 | </sizepolicy> | ||
680 | </property> | ||
681 | <property stdset="1"> | ||
682 | <name>font</name> | ||
683 | <font> | ||
684 | <family>adobe-helvetica</family> | ||
685 | <pointsize>24</pointsize> | ||
686 | </font> | ||
687 | </property> | ||
688 | <property stdset="1"> | ||
689 | <name>focusPolicy</name> | ||
690 | <enum>TabFocus</enum> | ||
691 | </property> | ||
692 | <property stdset="1"> | ||
693 | <name>text</name> | ||
694 | <string>x</string> | ||
695 | </property> | ||
696 | </widget> | ||
697 | <widget row="1" column="0" > | ||
698 | <class>QPushButton</class> | ||
699 | <property stdset="1"> | ||
700 | <name>name</name> | ||
701 | <cstring>PushButton4</cstring> | ||
702 | </property> | ||
703 | <property stdset="1"> | ||
704 | <name>sizePolicy</name> | ||
705 | <sizepolicy> | ||
706 | <hsizetype>5</hsizetype> | ||
707 | <vsizetype>5</vsizetype> | ||
708 | </sizepolicy> | ||
709 | </property> | ||
710 | <property stdset="1"> | ||
711 | <name>font</name> | ||
712 | <font> | ||
713 | <family>adobe-helvetica</family> | ||
714 | <pointsize>24</pointsize> | ||
715 | </font> | ||
716 | </property> | ||
717 | <property stdset="1"> | ||
718 | <name>focusPolicy</name> | ||
719 | <enum>TabFocus</enum> | ||
720 | </property> | ||
721 | <property stdset="1"> | ||
722 | <name>text</name> | ||
723 | <string>4</string> | ||
724 | </property> | ||
725 | </widget> | ||
726 | <widget row="0" column="1" > | ||
727 | <class>QPushButton</class> | ||
728 | <property stdset="1"> | ||
729 | <name>name</name> | ||
730 | <cstring>PushButton8</cstring> | ||
731 | </property> | ||
732 | <property stdset="1"> | ||
733 | <name>sizePolicy</name> | ||
734 | <sizepolicy> | ||
735 | <hsizetype>5</hsizetype> | ||
736 | <vsizetype>5</vsizetype> | ||
737 | </sizepolicy> | ||
738 | </property> | ||
739 | <property stdset="1"> | ||
740 | <name>font</name> | ||
741 | <font> | ||
742 | <family>adobe-helvetica</family> | ||
743 | <pointsize>24</pointsize> | ||
744 | </font> | ||
745 | </property> | ||
746 | <property stdset="1"> | ||
747 | <name>focusPolicy</name> | ||
748 | <enum>TabFocus</enum> | ||
749 | </property> | ||
750 | <property stdset="1"> | ||
751 | <name>text</name> | ||
752 | <string>8</string> | ||
753 | </property> | ||
754 | </widget> | ||
755 | <widget row="3" column="3" > | ||
756 | <class>QPushButton</class> | ||
757 | <property stdset="1"> | ||
758 | <name>name</name> | ||
759 | <cstring>PushButtonDivide</cstring> | ||
760 | </property> | ||
761 | <property stdset="1"> | ||
762 | <name>sizePolicy</name> | ||
763 | <sizepolicy> | ||
764 | <hsizetype>5</hsizetype> | ||
765 | <vsizetype>5</vsizetype> | ||
766 | </sizepolicy> | ||
767 | </property> | ||
768 | <property stdset="1"> | ||
769 | <name>font</name> | ||
770 | <font> | ||
771 | <family>adobe-helvetica</family> | ||
772 | <pointsize>24</pointsize> | ||
773 | </font> | ||
774 | </property> | ||
775 | <property stdset="1"> | ||
776 | <name>focusPolicy</name> | ||
777 | <enum>TabFocus</enum> | ||
778 | </property> | ||
779 | <property stdset="1"> | ||
780 | <name>text</name> | ||
781 | <string>/</string> | ||
782 | </property> | ||
783 | </widget> | ||
784 | <widget row="0" column="3" > | ||
785 | <class>QPushButton</class> | ||
786 | <property stdset="1"> | ||
787 | <name>name</name> | ||
788 | <cstring>PushButtonAdd</cstring> | ||
789 | </property> | ||
790 | <property stdset="1"> | ||
791 | <name>sizePolicy</name> | ||
792 | <sizepolicy> | ||
793 | <hsizetype>5</hsizetype> | ||
794 | <vsizetype>5</vsizetype> | ||
795 | </sizepolicy> | ||
796 | </property> | ||
797 | <property stdset="1"> | ||
798 | <name>font</name> | ||
799 | <font> | ||
800 | <family>adobe-helvetica</family> | ||
801 | <pointsize>24</pointsize> | ||
802 | </font> | ||
803 | </property> | ||
804 | <property stdset="1"> | ||
805 | <name>focusPolicy</name> | ||
806 | <enum>TabFocus</enum> | ||
807 | </property> | ||
808 | <property stdset="1"> | ||
809 | <name>text</name> | ||
810 | <string>+</string> | ||
811 | </property> | ||
812 | </widget> | ||
813 | <widget row="2" column="0" > | ||
814 | <class>QPushButton</class> | ||
815 | <property stdset="1"> | ||
816 | <name>name</name> | ||
817 | <cstring>PushButton1</cstring> | ||
818 | </property> | ||
819 | <property stdset="1"> | ||
820 | <name>sizePolicy</name> | ||
821 | <sizepolicy> | ||
822 | <hsizetype>5</hsizetype> | ||
823 | <vsizetype>5</vsizetype> | ||
824 | </sizepolicy> | ||
825 | </property> | ||
826 | <property stdset="1"> | ||
827 | <name>font</name> | ||
828 | <font> | ||
829 | <family>adobe-helvetica</family> | ||
830 | <pointsize>24</pointsize> | ||
831 | </font> | ||
832 | </property> | ||
833 | <property stdset="1"> | ||
834 | <name>focusPolicy</name> | ||
835 | <enum>TabFocus</enum> | ||
836 | </property> | ||
837 | <property stdset="1"> | ||
838 | <name>text</name> | ||
839 | <string>1</string> | ||
840 | </property> | ||
841 | </widget> | ||
842 | <widget row="3" column="1" > | ||
843 | <class>QPushButton</class> | ||
844 | <property stdset="1"> | ||
845 | <name>name</name> | ||
846 | <cstring>PushButtonDecimal</cstring> | ||
847 | </property> | ||
848 | <property stdset="1"> | ||
849 | <name>sizePolicy</name> | ||
850 | <sizepolicy> | ||
851 | <hsizetype>5</hsizetype> | ||
852 | <vsizetype>5</vsizetype> | ||
853 | </sizepolicy> | ||
854 | </property> | ||
855 | <property stdset="1"> | ||
856 | <name>font</name> | ||
857 | <font> | ||
858 | <family>adobe-helvetica</family> | ||
859 | <pointsize>24</pointsize> | ||
860 | </font> | ||
861 | </property> | ||
862 | <property stdset="1"> | ||
863 | <name>focusPolicy</name> | ||
864 | <enum>TabFocus</enum> | ||
865 | </property> | ||
866 | <property stdset="1"> | ||
867 | <name>text</name> | ||
868 | <string>.</string> | ||
869 | </property> | ||
870 | </widget> | ||
871 | <widget row="1" column="1" > | ||
872 | <class>QPushButton</class> | ||
873 | <property stdset="1"> | ||
874 | <name>name</name> | ||
875 | <cstring>PushButton5</cstring> | ||
876 | </property> | ||
877 | <property stdset="1"> | ||
878 | <name>sizePolicy</name> | ||
879 | <sizepolicy> | ||
880 | <hsizetype>5</hsizetype> | ||
881 | <vsizetype>5</vsizetype> | ||
882 | </sizepolicy> | ||
883 | </property> | ||
884 | <property stdset="1"> | ||
885 | <name>font</name> | ||
886 | <font> | ||
887 | <family>adobe-helvetica</family> | ||
888 | <pointsize>24</pointsize> | ||
889 | </font> | ||
890 | </property> | ||
891 | <property stdset="1"> | ||
892 | <name>focusPolicy</name> | ||
893 | <enum>TabFocus</enum> | ||
894 | </property> | ||
895 | <property stdset="1"> | ||
896 | <name>text</name> | ||
897 | <string>5</string> | ||
898 | </property> | ||
899 | </widget> | ||
900 | <widget row="0" column="0" > | ||
901 | <class>QPushButton</class> | ||
902 | <property stdset="1"> | ||
903 | <name>name</name> | ||
904 | <cstring>PushButton7</cstring> | ||
905 | </property> | ||
906 | <property stdset="1"> | ||
907 | <name>sizePolicy</name> | ||
908 | <sizepolicy> | ||
909 | <hsizetype>5</hsizetype> | ||
910 | <vsizetype>5</vsizetype> | ||
911 | </sizepolicy> | ||
912 | </property> | ||
913 | <property stdset="1"> | ||
914 | <name>font</name> | ||
915 | <font> | ||
916 | <family>adobe-helvetica</family> | ||
917 | <pointsize>24</pointsize> | ||
918 | </font> | ||
919 | </property> | ||
920 | <property stdset="1"> | ||
921 | <name>focusPolicy</name> | ||
922 | <enum>TabFocus</enum> | ||
923 | </property> | ||
924 | <property stdset="1"> | ||
925 | <name>text</name> | ||
926 | <string>7</string> | ||
927 | </property> | ||
928 | </widget> | ||
929 | <widget row="0" column="2" > | ||
930 | <class>QPushButton</class> | ||
931 | <property stdset="1"> | ||
932 | <name>name</name> | ||
933 | <cstring>PushButton9</cstring> | ||
934 | </property> | ||
935 | <property stdset="1"> | ||
936 | <name>sizePolicy</name> | ||
937 | <sizepolicy> | ||
938 | <hsizetype>5</hsizetype> | ||
939 | <vsizetype>5</vsizetype> | ||
940 | </sizepolicy> | ||
941 | </property> | ||
942 | <property stdset="1"> | ||
943 | <name>font</name> | ||
944 | <font> | ||
945 | <family>adobe-helvetica</family> | ||
946 | <pointsize>24</pointsize> | ||
947 | </font> | ||
948 | </property> | ||
949 | <property stdset="1"> | ||
950 | <name>focusPolicy</name> | ||
951 | <enum>TabFocus</enum> | ||
952 | </property> | ||
953 | <property stdset="1"> | ||
954 | <name>text</name> | ||
955 | <string>9</string> | ||
956 | </property> | ||
957 | </widget> | ||
958 | <widget row="2" column="1" > | ||
959 | <class>QPushButton</class> | ||
960 | <property stdset="1"> | ||
961 | <name>name</name> | ||
962 | <cstring>PushButton2</cstring> | ||
963 | </property> | ||
964 | <property stdset="1"> | ||
965 | <name>sizePolicy</name> | ||
966 | <sizepolicy> | ||
967 | <hsizetype>5</hsizetype> | ||
968 | <vsizetype>5</vsizetype> | ||
969 | </sizepolicy> | ||
970 | </property> | ||
971 | <property stdset="1"> | ||
972 | <name>font</name> | ||
973 | <font> | ||
974 | <family>adobe-helvetica</family> | ||
975 | <pointsize>24</pointsize> | ||
976 | </font> | ||
977 | </property> | ||
978 | <property stdset="1"> | ||
979 | <name>focusPolicy</name> | ||
980 | <enum>TabFocus</enum> | ||
981 | </property> | ||
982 | <property stdset="1"> | ||
983 | <name>text</name> | ||
984 | <string>2</string> | ||
985 | </property> | ||
986 | </widget> | ||
987 | </grid> | ||
988 | </widget> | ||
989 | </vbox> | ||
990 | </widget> | ||
991 | <tabstops> | ||
992 | <tabstop>ComboBoxFunction</tabstop> | ||
993 | <tabstop>PushButtonMPlus</tabstop> | ||
994 | <tabstop>PushButtonMR</tabstop> | ||
995 | <tabstop>PushButtonMC</tabstop> | ||
996 | <tabstop>PushButtonCE</tabstop> | ||
997 | <tabstop>PushButtonF6</tabstop> | ||
998 | <tabstop>PushButtonF7</tabstop> | ||
999 | <tabstop>PushButtonF8</tabstop> | ||
1000 | <tabstop>PushButtonF9</tabstop> | ||
1001 | <tabstop>PushButtonF11</tabstop> | ||
1002 | <tabstop>PushButtonF12</tabstop> | ||
1003 | <tabstop>PushButtonF1</tabstop> | ||
1004 | <tabstop>PushButtonF2</tabstop> | ||
1005 | <tabstop>PushButtonF3</tabstop> | ||
1006 | <tabstop>PushButtonF4</tabstop> | ||
1007 | <tabstop>PushButtonF5</tabstop> | ||
1008 | <tabstop>PushButtonF10</tabstop> | ||
1009 | <tabstop>PushButton7</tabstop> | ||
1010 | <tabstop>PushButton8</tabstop> | ||
1011 | <tabstop>PushButton9</tabstop> | ||
1012 | <tabstop>PushButtonAdd</tabstop> | ||
1013 | <tabstop>PushButton4</tabstop> | ||
1014 | <tabstop>PushButton5</tabstop> | ||
1015 | <tabstop>PushButton6</tabstop> | ||
1016 | <tabstop>PushButtonMinus</tabstop> | ||
1017 | <tabstop>PushButton1</tabstop> | ||
1018 | <tabstop>PushButton2</tabstop> | ||
1019 | <tabstop>PushButton3</tabstop> | ||
1020 | <tabstop>PushButtonTimes</tabstop> | ||
1021 | <tabstop>PushButton0</tabstop> | ||
1022 | <tabstop>PushButtonDecimal</tabstop> | ||
1023 | <tabstop>PushButtonEquals</tabstop> | ||
1024 | <tabstop>PushButtonDivide</tabstop> | ||
1025 | </tabstops> | ||
1026 | </UI> | ||
diff --git a/noncore/tools/calculator/calculatorimpl.cpp b/noncore/tools/calculator/calculatorimpl.cpp new file mode 100644 index 0000000..2f7d7ce --- a/dev/null +++ b/noncore/tools/calculator/calculatorimpl.cpp | |||
@@ -0,0 +1,601 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include "calculatorimpl.h" | ||
22 | |||
23 | #include <qpe/resource.h> | ||
24 | #include <qpe/qmath.h> | ||
25 | #include <qpe/qpeapplication.h> | ||
26 | |||
27 | #include <qpushbutton.h> | ||
28 | #include <qcombobox.h> | ||
29 | #include <qlabel.h> | ||
30 | #include <qfont.h> | ||
31 | #include <qlayout.h> | ||
32 | #include <qstringlist.h> | ||
33 | #include <qfile.h> | ||
34 | #include <qtextstream.h> | ||
35 | #include <qmessagebox.h> | ||
36 | #include <math.h> | ||
37 | |||
38 | CalculatorImpl::CalculatorImpl( QWidget * parent, const char * name, | ||
39 | WFlags f ) | ||
40 | : Calculator( parent, name, f ) | ||
41 | { | ||
42 | xtopowerofy = Resource::loadPixmap("xtopowerofy"); | ||
43 | ythrootofx = Resource::loadPixmap("ythrootofx"); | ||
44 | oneoverx = Resource::loadPixmap("oneoverx"); | ||
45 | |||
46 | memMark = new QLabel( "m", LCD ); | ||
47 | memMark->setFont( QFont( "helvetica", 12, QFont::Bold, TRUE ) ); | ||
48 | memMark->resize( 12, 12 ); | ||
49 | memMark->move( 4, 2 ); | ||
50 | memMark->hide(); | ||
51 | mem = 0; | ||
52 | |||
53 | PushButtonMR->setEnabled( FALSE ); | ||
54 | |||
55 | current_mode = max_mode = conversion_mode_count = 0; | ||
56 | last_conversion = -1; | ||
57 | |||
58 | //bgr_command.insert( PushButtonFunction); | ||
59 | bgr_command.insert( PushButtonMPlus); | ||
60 | bgr_command.insert( PushButtonMR); | ||
61 | bgr_command.insert( PushButtonMC); | ||
62 | bgr_command.insert( PushButtonCE); | ||
63 | connect( &bgr_command, SIGNAL(clicked(int) ), this, SLOT(command_buttons(int))); | ||
64 | |||
65 | bgr_digits.insert(PushButton0); | ||
66 | bgr_digits.insert(PushButton1); | ||
67 | bgr_digits.insert(PushButton2); | ||
68 | bgr_digits.insert(PushButton3); | ||
69 | bgr_digits.insert(PushButton4); | ||
70 | bgr_digits.insert(PushButton5); | ||
71 | bgr_digits.insert(PushButton6); | ||
72 | bgr_digits.insert(PushButton7); | ||
73 | bgr_digits.insert(PushButton8); | ||
74 | bgr_digits.insert(PushButton9); | ||
75 | connect( &bgr_digits, SIGNAL(clicked(int) ), this, SLOT(enterNumber(int))); | ||
76 | |||
77 | |||
78 | bgr_std.insert(PushButtonEquals); | ||
79 | bgr_std.insert(PushButtonDecimal); | ||
80 | bgr_std.insert(PushButtonAdd); | ||
81 | bgr_std.insert(PushButtonMinus); | ||
82 | bgr_std.insert(PushButtonDivide); | ||
83 | bgr_std.insert(PushButtonTimes); | ||
84 | connect( &bgr_std, SIGNAL(clicked(int) ), this, SLOT(std_buttons(int))); | ||
85 | |||
86 | // change the / to a proper division signal | ||
87 | PushButtonDivide->setText(QChar(0xF7)); | ||
88 | |||
89 | func_buttons[0] = PushButtonF1; | ||
90 | func_buttons[1] = PushButtonF2; | ||
91 | func_buttons[2] = PushButtonF3; | ||
92 | func_buttons[3] = PushButtonF4; | ||
93 | func_buttons[4] = PushButtonF5; | ||
94 | func_buttons[5] = PushButtonF6; | ||
95 | func_buttons[6] = PushButtonF7; | ||
96 | func_buttons[7] = PushButtonF8; | ||
97 | func_buttons[8] = PushButtonF9; | ||
98 | func_buttons[9] = PushButtonF10; | ||
99 | func_buttons[10] = PushButtonF11; | ||
100 | func_buttons[11] = PushButtonF12; | ||
101 | |||
102 | for ( int x = 0 ; x < func_button_count ; x++ ) { | ||
103 | QPushButton* tmpbutton = func_buttons[x]; | ||
104 | faces << tmpbutton->text(); | ||
105 | bgr_function.insert(tmpbutton); | ||
106 | } | ||
107 | connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(do_convert(int) ) ); | ||
108 | connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(std_funcs (int) ) ); | ||
109 | |||
110 | connect(ComboBoxFunction, SIGNAL(activated(int) ), this, SLOT(function_button(int) ) ); | ||
111 | |||
112 | captions.append("Standard"); | ||
113 | ComboBoxFunction->insertItem(captions.last()); | ||
114 | |||
115 | // now add in the conversion modes | ||
116 | // when the menu gets done, these should be in a submenu | ||
117 | QString tmp = QPEApplication::qpeDir(); | ||
118 | tmp += "/etc/unit_conversion.dat"; | ||
119 | QFile myfile(tmp); | ||
120 | if ( !myfile.open( IO_Translate | IO_ReadOnly ) ) { | ||
121 | // QMessageBox::warning(this, "Warning", "Data file\nunit_conversion.dat\nnot found\nNo conversion\nfeatures will\nbe available"); | ||
122 | // disable the f button if no conv file available | ||
123 | ComboBoxFunction->setEnabled(FALSE); | ||
124 | } | ||
125 | else { | ||
126 | QString line, line2; | ||
127 | QTextStream ts(&myfile); | ||
128 | |||
129 | // first pass, see how many conversion types there are in order to allocate for them | ||
130 | while ( ! ts.eof() ) { | ||
131 | line = ts.readLine(); | ||
132 | if ( line.contains ("STARTTYPE" ) ) | ||
133 | conversion_mode_count++; | ||
134 | } | ||
135 | |||
136 | entry_list = new double[conversion_mode_count*func_button_count]; | ||
137 | |||
138 | myfile.close(); | ||
139 | myfile.open( IO_Translate | IO_ReadOnly ); | ||
140 | QTextStream ts2(&myfile); | ||
141 | |||
142 | // second pass, read in values | ||
143 | int x = 0; | ||
144 | while ( ! ts2.eof() ) { | ||
145 | line = ts2.readLine(); | ||
146 | if ( line.contains("STARTTYPE") ) { | ||
147 | captions << line.remove(0,10); | ||
148 | ComboBoxFunction->insertItem(captions.last()); | ||
149 | while ( !line.contains("ENDTYPE") ) { | ||
150 | line = ts2.readLine(); | ||
151 | if ( line.contains("NAME") ) { | ||
152 | faces << line.remove(0,5); | ||
153 | line2 = ts2.readLine(); | ||
154 | line2.remove(0,6); | ||
155 | entry_list[x] = line2.toDouble(); | ||
156 | x++; | ||
157 | } | ||
158 | } | ||
159 | } | ||
160 | } | ||
161 | } | ||
162 | myfile.close(); | ||
163 | clear(); | ||
164 | max_mode = pre_conv_modes_count + conversion_mode_count + post_conv_modes_count - 1; | ||
165 | display_pixmap_faces(); | ||
166 | |||
167 | qApp->installEventFilter( this ); | ||
168 | } | ||
169 | |||
170 | bool CalculatorImpl::eventFilter( QObject *o, QEvent *e ) | ||
171 | { | ||
172 | if ( e->type() == QEvent::KeyPress && state != sError ) { | ||
173 | QKeyEvent *k = (QKeyEvent*)e; | ||
174 | if ( k->key() >= Key_0 && k->key() <= Key_9 ) { | ||
175 | enterNumber( k->key() - Key_0 ); | ||
176 | return true; | ||
177 | } else { | ||
178 | switch ( k->key() ) { | ||
179 | case Key_Equal: | ||
180 | std_buttons(0); | ||
181 | return true; | ||
182 | case Key_Period: | ||
183 | std_buttons(1); | ||
184 | return true; | ||
185 | case Key_Plus: | ||
186 | std_buttons(2); | ||
187 | return true; | ||
188 | case Key_Minus: | ||
189 | std_buttons(3); | ||
190 | return true; | ||
191 | case Key_Slash: | ||
192 | std_buttons(4); | ||
193 | return true; | ||
194 | case Key_Asterisk: | ||
195 | std_buttons(5); | ||
196 | return true; | ||
197 | case Key_Percent: | ||
198 | execOp( oPercent ); | ||
199 | return true; | ||
200 | case Key_ParenLeft: | ||
201 | if ( current_mode < pre_conv_modes_count ) | ||
202 | execOp( oOpenBrace ); | ||
203 | return true; | ||
204 | case Key_ParenRight: | ||
205 | if ( current_mode < pre_conv_modes_count ) | ||
206 | execOp( oCloseBrace ); | ||
207 | return true; | ||
208 | default: | ||
209 | break; | ||
210 | } | ||
211 | } | ||
212 | } | ||
213 | return Calculator::eventFilter( o, e ); | ||
214 | } | ||
215 | |||
216 | void CalculatorImpl::do_convert(int button) { | ||
217 | if ( state == sError ) | ||
218 | return; | ||
219 | if ( current_mode >= pre_conv_modes_count && current_mode <= (max_mode - post_conv_modes_count) && | ||
220 | button < changeable_func_button_count ) { | ||
221 | if ( last_conversion > -1 ) { | ||
222 | if( state == sNewNumber ){ | ||
223 | acc = num | ||
224 | / (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion]) | ||
225 | * (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + button]) ; | ||
226 | num = acc; | ||
227 | LCD->display( acc ); | ||
228 | } else { | ||
229 | state = sNewNumber; | ||
230 | num = num | ||
231 | / (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion]) | ||
232 | * (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + button]) ; | ||
233 | LCD->display( num ); | ||
234 | acc = num; | ||
235 | } | ||
236 | } | ||
237 | last_conversion = button; | ||
238 | } | ||
239 | } | ||
240 | |||
241 | |||
242 | void CalculatorImpl::function_button(int mode){ | ||
243 | if ( state == sError ) | ||
244 | clear(); | ||
245 | // dont need the next line when using a popup menu | ||
246 | current_mode = mode; | ||
247 | |||
248 | // reset the last conv | ||
249 | last_conversion = -1; | ||
250 | |||
251 | // set the caption | ||
252 | this->setCaption( captions[current_mode] ); | ||
253 | |||
254 | reset_conv(); | ||
255 | |||
256 | for ( int x = 0 ; x < changeable_func_button_count ; x++ ) { | ||
257 | QPushButton* tmpbutton = func_buttons[x]; | ||
258 | |||
259 | // if its a conversion , make it a toggle button | ||
260 | if ( current_mode >= pre_conv_modes_count && current_mode <= (max_mode - post_conv_modes_count) ) { | ||
261 | tmpbutton->setToggleButton(TRUE); | ||
262 | } else { | ||
263 | tmpbutton->setToggleButton(FALSE); | ||
264 | } | ||
265 | tmpbutton->setText( faces[current_mode * func_button_count + x] ); | ||
266 | } | ||
267 | |||
268 | if ( current_mode == 0 ) display_pixmap_faces(); | ||
269 | |||
270 | if ( current_mode >= pre_conv_modes_count && current_mode <= (max_mode - post_conv_modes_count) ) { | ||
271 | bgr_function.setExclusive(TRUE); | ||
272 | } else { | ||
273 | bgr_function.setExclusive(FALSE); | ||
274 | } | ||
275 | } | ||
276 | |||
277 | void CalculatorImpl::display_pixmap_faces() { | ||
278 | QPushButton* tmpbutton = func_buttons[5]; | ||
279 | tmpbutton->setPixmap(xtopowerofy); | ||
280 | |||
281 | tmpbutton = func_buttons[6]; | ||
282 | tmpbutton->setPixmap(ythrootofx); | ||
283 | |||
284 | tmpbutton = func_buttons[3]; | ||
285 | tmpbutton->setPixmap(oneoverx); | ||
286 | } | ||
287 | |||
288 | void CalculatorImpl::clear() { | ||
289 | acc = num = 0; | ||
290 | operationStack.clear(); | ||
291 | state = sStart; | ||
292 | numDecimals = 0; | ||
293 | numOpenBraces = 0; | ||
294 | flPoint = FALSE; | ||
295 | LCD->display( 0 ); | ||
296 | fake = QString::null; | ||
297 | |||
298 | reset_conv(); | ||
299 | } | ||
300 | |||
301 | void CalculatorImpl::reset_conv() { | ||
302 | for ( int x = 0 ; x < changeable_func_button_count ; x++ ) { | ||
303 | QPushButton* tmpbutton = func_buttons[x]; | ||
304 | |||
305 | // dont carry any selections into the next mode | ||
306 | if ( tmpbutton->state() == QPushButton::On ) { | ||
307 | tmpbutton->toggle(); | ||
308 | } | ||
309 | } | ||
310 | |||
311 | last_conversion = -1; | ||
312 | } | ||
313 | |||
314 | void CalculatorImpl::std_buttons(int button) | ||
315 | { | ||
316 | if ( state == sError ) | ||
317 | return; | ||
318 | execOp( (Operation)(button + oSum) ); | ||
319 | } | ||
320 | |||
321 | void CalculatorImpl::std_funcs(int button) { | ||
322 | if ( state == sError ) | ||
323 | return; | ||
324 | if ( current_mode < pre_conv_modes_count || | ||
325 | button > changeable_func_button_count-1 ) { | ||
326 | Operation op; | ||
327 | if ( button < 10 ) | ||
328 | op = (Operation)(button + oSin); | ||
329 | else if ( button == 10 ) | ||
330 | op = oOpenBrace; | ||
331 | else | ||
332 | op = oCloseBrace; | ||
333 | execOp( op ); | ||
334 | } | ||
335 | } | ||
336 | |||
337 | void CalculatorImpl::execOp( Operation i ) | ||
338 | { | ||
339 | switch (i) { | ||
340 | // these operators only affect the current number. | ||
341 | case oDivX: | ||
342 | case oLog: | ||
343 | case oLn: | ||
344 | case oSin: | ||
345 | case oCos: | ||
346 | case oTan: | ||
347 | num = evalExpr(i); | ||
348 | break; | ||
349 | |||
350 | case oAdd: | ||
351 | case oSub: { | ||
352 | processStack( oAdd ); | ||
353 | Op op( num, i ); | ||
354 | operationStack.push( op ); | ||
355 | break; | ||
356 | } | ||
357 | case oDiv: | ||
358 | case oMult: | ||
359 | case oRoot: | ||
360 | case oXsquared: { | ||
361 | processStack( oDiv ); | ||
362 | Op op( num, i ); | ||
363 | operationStack.push( op ); | ||
364 | break; | ||
365 | } | ||
366 | case oChSign: | ||
367 | num = -num; | ||
368 | LCD->display(num); | ||
369 | return; | ||
370 | |||
371 | case oOpenBrace: { | ||
372 | Op op( 0, oOpenBrace ); | ||
373 | operationStack.push( op ); | ||
374 | numOpenBraces++; | ||
375 | state = sNewNumber; | ||
376 | return; | ||
377 | } | ||
378 | case oCloseBrace: { | ||
379 | if ( numOpenBraces == 0 ) | ||
380 | return; | ||
381 | processStack( oAdd ); | ||
382 | if ( operationStack.top().operation != oOpenBrace ) | ||
383 | qDebug( "Calculator: internal Error" ); | ||
384 | operationStack.pop(); | ||
385 | state = sNewNumber; | ||
386 | numOpenBraces--; | ||
387 | break; | ||
388 | } | ||
389 | |||
390 | case oPoint: | ||
391 | flPoint = TRUE; | ||
392 | return; | ||
393 | |||
394 | case oPercent: | ||
395 | processStack( oPercent ); | ||
396 | break; | ||
397 | |||
398 | |||
399 | case oSum: | ||
400 | processStack( oSum ); | ||
401 | break; | ||
402 | |||
403 | default: | ||
404 | return; | ||
405 | }; | ||
406 | |||
407 | if ( state == sError ) { | ||
408 | LCD->display( "Error" ); | ||
409 | return; | ||
410 | } else { | ||
411 | LCD->display(num); | ||
412 | } | ||
413 | state = sNewNumber; | ||
414 | numDecimals = 0; | ||
415 | flPoint = FALSE; | ||
416 | } | ||
417 | |||
418 | |||
419 | void CalculatorImpl::processStack( int op ) | ||
420 | { | ||
421 | //dubious percent hack, since the changeable operator precedences are | ||
422 | //pretty much hardwired to be less than the non-changeable | ||
423 | bool percent = FALSE; | ||
424 | if ( op == oPercent ) { | ||
425 | percent = TRUE; | ||
426 | op = oSum; | ||
427 | } | ||
428 | while( !operationStack.isEmpty() && operationStack.top().operation >= op ) { | ||
429 | Op operation = operationStack.pop(); | ||
430 | acc = operation.number; | ||
431 | if ( percent ) { | ||
432 | if ( operation.operation == oAdd || operation.operation == oSub ) | ||
433 | num = acc*num/100; | ||
434 | else | ||
435 | num = num / 100; | ||
436 | } | ||
437 | num = evalExpr( operation.operation ); | ||
438 | percent = FALSE; | ||
439 | } | ||
440 | } | ||
441 | |||
442 | |||
443 | double CalculatorImpl::evalExpr( int op ) { | ||
444 | double sum = 0; | ||
445 | |||
446 | switch( op ){ | ||
447 | case oPercent: sum = num / 100.; break; | ||
448 | case oDivX: | ||
449 | if (num == 0) | ||
450 | state = sError; | ||
451 | else | ||
452 | sum = 1 / num; | ||
453 | break; | ||
454 | case oXsquared: | ||
455 | sum = pow(acc,num); | ||
456 | break; | ||
457 | case oChSign: (state == sStart) ? sum = -num : sum = -acc; break; | ||
458 | case oSub: sum = acc - num; break; | ||
459 | case oMult: sum = acc * num; break; | ||
460 | case oAdd: sum = acc + num; break; | ||
461 | case oDiv: { | ||
462 | if (num == 0) { | ||
463 | state = sError; | ||
464 | } else { | ||
465 | sum = acc / num; | ||
466 | } | ||
467 | break; | ||
468 | } | ||
469 | case oRoot: | ||
470 | /* the linux library is dumb, and can't to -x to 1/n | ||
471 | when n is odd. (even and error of course is acceptable */ | ||
472 | if((acc < 0) && (int(num) == num) && (int(num) % 2 == 1 )) { | ||
473 | sum = pow(-acc, 1 / num); | ||
474 | sum = -sum; | ||
475 | } else { | ||
476 | sum = pow(acc, 1 / num); | ||
477 | } | ||
478 | break; | ||
479 | case oLog: | ||
480 | sum = log10(num); | ||
481 | break; | ||
482 | case oLn: | ||
483 | sum = log(num); | ||
484 | break; | ||
485 | case oTan: sum = qTan(num);break; | ||
486 | case oSin: sum = qSin(num);break; | ||
487 | case oCos: sum = qCos(num);break; | ||
488 | default: sum = num; break; | ||
489 | } | ||
490 | |||
491 | if ( isinf( sum ) || isnan( sum ) ) | ||
492 | state = sError; | ||
493 | return sum; | ||
494 | } | ||
495 | |||
496 | |||
497 | void CalculatorImpl::enterNumber( int n ) | ||
498 | { | ||
499 | if ( state == sError ) | ||
500 | return; | ||
501 | if( state == sStart ){ | ||
502 | if( LCD->value() > 0 ){ | ||
503 | QString s = QString::number( LCD->value(), 'g', LCD->numDigits()); | ||
504 | if( s.length() > (uint)(LCD->numDigits() - 2)) return; | ||
505 | |||
506 | } else if( (int)fake.length() >= LCD->numDigits() || numDecimals >=12 ){ | ||
507 | return; | ||
508 | } | ||
509 | } | ||
510 | |||
511 | if( state == sNewNumber ){ | ||
512 | state = sStart; | ||
513 | acc = 0; | ||
514 | if( flPoint ){ | ||
515 | numDecimals = 1; | ||
516 | num = n / pow(10, numDecimals); | ||
517 | } else | ||
518 | num = n; | ||
519 | } else if( flPoint ){ | ||
520 | numDecimals++; | ||
521 | if( num < 0 ){ | ||
522 | num -= n / pow(10, numDecimals); | ||
523 | } else { | ||
524 | num += n / pow(10, numDecimals); | ||
525 | } | ||
526 | } else { | ||
527 | num *= 10; | ||
528 | if( num < 0 ) | ||
529 | num -= n; | ||
530 | else | ||
531 | num += n; | ||
532 | } | ||
533 | |||
534 | // We need feedback in the calc display while entering fl.point zeros. | ||
535 | // This is a small hack to display sequences like: 0.000 and 1.100 | ||
536 | double integer, fraction; | ||
537 | fraction = modf( num, &integer ); | ||
538 | if( flPoint ){ | ||
539 | QString is, fs, zeros; | ||
540 | |||
541 | is = QString::number( integer, 'g', 13 ); | ||
542 | fs = QString::number( fraction, 'g', numDecimals ); | ||
543 | if( fs.contains('e') ){ | ||
544 | fs = QString::number( fraction, 'f', LCD->numDigits() ); | ||
545 | } | ||
546 | fs = fs.mid( 2, numDecimals ); | ||
547 | |||
548 | if( (integer == 0) && (fraction == 0) ) | ||
549 | fake = "0."; | ||
550 | else if( (integer != 0) && (fraction == 0) ) | ||
551 | fake = is + "."; | ||
552 | else | ||
553 | fake = is + "." + fs; | ||
554 | |||
555 | zeros.fill( '0', (numDecimals - fs.length()) ); | ||
556 | fake += zeros; | ||
557 | // ### This code sets LCD->value() to zero since it sets a text | ||
558 | // ### Avoid getting the current value from LCD->value() for | ||
559 | // ### calculations. | ||
560 | LCD->display( fake ); | ||
561 | } else | ||
562 | LCD->display( num ); | ||
563 | } | ||
564 | |||
565 | void CalculatorImpl::command_buttons(int i) { | ||
566 | if ( state == sError && i != 3 ) | ||
567 | return; | ||
568 | switch (i) { | ||
569 | case 0: // M+ | ||
570 | mem += num; | ||
571 | if( mem != 0 ){ | ||
572 | memMark->show(); | ||
573 | PushButtonMR->setEnabled( TRUE ); }; | ||
574 | state = sNewNumber; | ||
575 | break; | ||
576 | case 1: // MR | ||
577 | acc = num = mem; | ||
578 | state = sNewNumber; | ||
579 | LCD->display( mem ); | ||
580 | break; | ||
581 | case 2: // MC | ||
582 | mem = 0; | ||
583 | memMark->hide(); | ||
584 | PushButtonMR->setEnabled( FALSE ); | ||
585 | break; | ||
586 | case 3: // CE | ||
587 | if ( state == sStart ) { | ||
588 | // clear the entered number on the first press | ||
589 | state = sNewNumber; | ||
590 | num = acc = 0; | ||
591 | flPoint = FALSE; | ||
592 | LCD->display( 0 ); | ||
593 | fake = QString::null; | ||
594 | numDecimals = 0; | ||
595 | } else { | ||
596 | clear(); | ||
597 | } | ||
598 | break; | ||
599 | }; | ||
600 | |||
601 | } | ||
diff --git a/noncore/tools/calculator/calculatorimpl.h b/noncore/tools/calculator/calculatorimpl.h new file mode 100644 index 0000000..bfb726f --- a/dev/null +++ b/noncore/tools/calculator/calculatorimpl.h | |||
@@ -0,0 +1,135 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #ifndef CALCULATORIMPL_H | ||
21 | #define CALCULATORIMPL_H | ||
22 | |||
23 | |||
24 | #include <qlcdnumber.h> | ||
25 | #include "calculator.h" | ||
26 | #include <qpushbutton.h> | ||
27 | #include <qbuttongroup.h> | ||
28 | #include <qvaluestack.h> | ||
29 | |||
30 | // mode x functions | ||
31 | enum Operation { | ||
32 | oNop, | ||
33 | oOpenBrace, | ||
34 | oCloseBrace, | ||
35 | oSum, | ||
36 | oPoint, | ||
37 | oAdd, | ||
38 | oSub, | ||
39 | oDiv, | ||
40 | oMult, | ||
41 | |||
42 | // mode 0 functions | ||
43 | oSin, | ||
44 | oCos, | ||
45 | oTan, | ||
46 | oDivX, | ||
47 | oPercent, | ||
48 | oXsquared, | ||
49 | oRoot, | ||
50 | oLog, | ||
51 | oLn, | ||
52 | oChSign | ||
53 | }; | ||
54 | |||
55 | // states | ||
56 | #define sStart 0 | ||
57 | #define sNewNumber 1 | ||
58 | #define sError 2 | ||
59 | |||
60 | struct Op | ||
61 | { | ||
62 | Op() { number = 0; operation = oNop; } | ||
63 | Op( double num, Operation op ) | ||
64 | { number = num; operation = op; } | ||
65 | double number; | ||
66 | Operation operation; | ||
67 | }; | ||
68 | |||
69 | class QLabel; | ||
70 | class CalculatorImpl : public Calculator | ||
71 | { | ||
72 | Q_OBJECT | ||
73 | |||
74 | public: | ||
75 | CalculatorImpl( QWidget * parent = 0, const char * name = 0, | ||
76 | WFlags f = 0 ); | ||
77 | |||
78 | public slots: | ||
79 | void command_buttons(int); | ||
80 | void enterNumber(int i); | ||
81 | void std_buttons(int); | ||
82 | void std_funcs(int); | ||
83 | void do_convert(int); | ||
84 | void function_button(int); | ||
85 | |||
86 | protected: | ||
87 | virtual bool eventFilter( QObject *o, QEvent *e ); | ||
88 | |||
89 | private: | ||
90 | void clear(); | ||
91 | |||
92 | void reset_conv(); | ||
93 | |||
94 | void processStack( int op ); | ||
95 | |||
96 | QValueStack<Op> operationStack; | ||
97 | int state; | ||
98 | |||
99 | double acc, num, mem; | ||
100 | int numDecimals; | ||
101 | bool flPoint; | ||
102 | int numOpenBraces; | ||
103 | |||
104 | void execOp( Operation i ); | ||
105 | double evalExpr( int op ); | ||
106 | QLabel * memMark; | ||
107 | QString fake; | ||
108 | |||
109 | // useful values for conversion stuff | ||
110 | int current_mode, max_mode, conversion_mode_count, last_conversion; | ||
111 | |||
112 | // make adding new modes easier for ourselves | ||
113 | static const int pre_conv_modes_count = 1; | ||
114 | static const int post_conv_modes_count = 0; | ||
115 | |||
116 | // an array of pointers to the func buttons | ||
117 | static const int func_button_count = 12; | ||
118 | // this is an abomination | ||
119 | static const int changeable_func_button_count = 10; | ||
120 | QPushButton* func_buttons[func_button_count]; | ||
121 | |||
122 | QButtonGroup bgr_function, bgr_digits, bgr_std, bgr_command; | ||
123 | QStringList faces, captions; | ||
124 | |||
125 | // an array of doubles holding the conversion ratios | ||
126 | double* entry_list; | ||
127 | |||
128 | QPixmap xtopowerofy; | ||
129 | QPixmap ythrootofx; | ||
130 | QPixmap oneoverx; | ||
131 | |||
132 | void display_pixmap_faces(void); | ||
133 | }; | ||
134 | |||
135 | #endif | ||
diff --git a/noncore/tools/calculator/main.cpp b/noncore/tools/calculator/main.cpp new file mode 100644 index 0000000..74cd5d3 --- a/dev/null +++ b/noncore/tools/calculator/main.cpp | |||
@@ -0,0 +1,35 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include "calculatorimpl.h" | ||
22 | |||
23 | #include <qpe/qpeapplication.h> | ||
24 | |||
25 | int main( int argc, char ** argv ) | ||
26 | { | ||
27 | QPEApplication a( argc, argv ); | ||
28 | |||
29 | CalculatorImpl mw; | ||
30 | QPEApplication::setInputMethodHint( &mw, QPEApplication::AlwaysOff ); | ||
31 | mw.setCaption( CalculatorImpl::tr("Calculator") ); | ||
32 | a.showMainWidget( &mw ); | ||
33 | |||
34 | return a.exec(); | ||
35 | } | ||
diff --git a/noncore/tools/calculator/qpe-calculator.control b/noncore/tools/calculator/qpe-calculator.control new file mode 100644 index 0000000..afef70b --- a/dev/null +++ b/noncore/tools/calculator/qpe-calculator.control | |||
@@ -0,0 +1,10 @@ | |||
1 | Files: bin/calculator apps/Applications/calculator.desktop etc/unit_conversion.dat | ||
2 | Priority: optional | ||
3 | Section: qpe/applications | ||
4 | Maintainer: Warwick Allison <warwick@trolltech.com> | ||
5 | Architecture: arm | ||
6 | Version: $QPE_VERSION-3 | ||
7 | Depends: qpe-base ($QPE_VERSION) | ||
8 | Description: Calculator | ||
9 | A multi-function calculator for the Qtopia environment. | ||
10 | Includes units conversion. | ||